Ignore:
Timestamp:
Dec 31, 2012, 7:13:14 AM (11 years ago)
Author:
rvelices
Message:

upgraded js libs
jquery from 1.8.2 to 1.8.3
jquery jCrop from 0.9.9 to 0.9.10

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/themes/default/js/plugins/jquery.Jcrop.js

    r13038 r19682  
    11/**
    2  * jquery.Jcrop.js v0.9.9
    3  * jQuery Image Cropping Plugin
    4  * @author Kelly Hallman <khallman@gmail.com>
    5  * Copyright (c) 2008-2011 Kelly Hallman - released under MIT License {{{
     2 * jquery.Jcrop.js v0.9.10
     3 * jQuery Image Cropping Plugin - released under MIT License
     4 * Author: Kelly Hallman <khallman@gmail.com>
     5 * http://github.com/tapmodo/Jcrop
     6 * Copyright (c) 2008-2012 Tapmodo Interactive LLC {{{
    67 *
    78 * Permission is hereby granted, free of charge, to any person
     
    3738    // Internal Methods {{{
    3839    function px(n) {
    39       return parseInt(n, 10) + 'px';
    40     }
    41     function pct(n) {
    42       return parseInt(n, 10) + '%';
     40      return n + 'px';
    4341    }
    4442    function cssClass(cl) {
     
    5048    function getPos(obj) //{{{
    5149    {
    52       // Updated in v0.9.4 to use built-in dimensions plugin
    5350      var pos = $(obj).offset();
    5451      return [pos.left, pos.top];
     
    6259    function setOptions(opt) //{{{
    6360    {
    64       if (typeof(opt) !== 'object') {
    65         opt = {};
    66       }
     61      if (typeof(opt) !== 'object') opt = {};
    6762      options = $.extend(options, opt);
    6863
    69       if (typeof(options.onChange) !== 'function') {
    70         options.onChange = function () {};
    71       }
    72       if (typeof(options.onSelect) !== 'function') {
    73         options.onSelect = function () {};
    74       }
    75       if (typeof(options.onRelease) !== 'function') {
    76         options.onRelease = function () {};
    77       }
    78     }
    79     //}}}
    80     function myCursor(type) //{{{
    81     {
    82       if (type !== lastcurs) {
    83         Tracker.setCursor(type);
    84         lastcurs = type;
    85       }
     64      $.each(['onChange','onSelect','onRelease','onDblClick'],function(i,e) {
     65        if (typeof(options[e]) !== 'function') options[e] = function () {};
     66      });
    8667    }
    8768    //}}}
     
    188169          return false;
    189170        }
     171       
     172        // Fix position of crop area when dragged the very first time.
     173        // Necessary when crop image is in a hidden element when page is loaded.
     174        docOffset = getPos($img);
     175
    190176        btndown = true;
    191177        startDragMode(ord, mouseAbs(e));
     
    216202    {
    217203      return {
    218         x: parseInt(c.x * xscale, 10),
    219         y: parseInt(c.y * yscale, 10),
    220         x2: parseInt(c.x2 * xscale, 10),
    221         y2: parseInt(c.y2 * yscale, 10),
    222         w: parseInt(c.w * xscale, 10),
    223         h: parseInt(c.h * yscale, 10)
     204        x: c.x * xscale,
     205        y: c.y * yscale,
     206        x2: c.x2 * xscale,
     207        y2: c.y2 * yscale,
     208        w: c.w * xscale,
     209        h: c.h * yscale
    224210      };
    225211    }
     
    248234      docOffset = getPos($img);
    249235      Selection.disableHandles();
    250       myCursor('crosshair');
     236      Tracker.setCursor('crosshair');
    251237      var pos = mouseAbs(e);
    252238      Coords.setPressed(pos);
     
    300286    var img_css = {
    301287      border: 'none',
     288      visibility: 'visible',
    302289      margin: 0,
    303290      padding: 0,
    304       position: 'absolute'
     291      position: 'absolute',
     292      top: 0,
     293      left: 0
    305294    };
    306295
    307     var $origimg = $(obj);
    308     var $img = $origimg.clone().removeAttr('id').css(img_css);
    309 
    310     $img.width($origimg.width());
    311     $img.height($origimg.height());
    312     $origimg.after($img).hide();
     296    var $origimg = $(obj),
     297      img_mode = true;
     298
     299    if (obj.tagName == 'IMG') {
     300      // Fix size of crop image.
     301      // Necessary when crop image is within a hidden element when page is loaded.
     302      if ($origimg[0].width != 0 && $origimg[0].height != 0) {
     303        // Obtain dimensions from contained img element.
     304        $origimg.width($origimg[0].width);
     305        $origimg.height($origimg[0].height);
     306      } else {
     307        // Obtain dimensions from temporary image in case the original is not loaded yet (e.g. IE 7.0).
     308        var tempImage = new Image();
     309        tempImage.src = $origimg[0].src;
     310        $origimg.width(tempImage.width);
     311        $origimg.height(tempImage.height);
     312      }
     313
     314      var $img = $origimg.clone().removeAttr('id').css(img_css).show();
     315
     316      $img.width($origimg.width());
     317      $img.height($origimg.height());
     318      $origimg.after($img).hide();
     319
     320    } else {
     321      $img = $origimg.css(img_css).show();
     322      img_mode = false;
     323      if (options.shade === null) { options.shade = true; }
     324    }
    313325
    314326    presize($img, options.boxWidth, options.boxHeight);
     
    323335      }).insertAfter($origimg).append($img);
    324336
    325     delete(options.bgColor);
    326337    if (options.addClass) {
    327338      $div.addClass(options.addClass);
    328339    }
    329340
    330     var $img2 = $('<img />')
    331         .attr('src', $img.attr('src')).css(img_css).width(boundx).height(boundy),
     341    var $img2 = $('<div />'),
    332342
    333343        $img_holder = $('<div />')
    334         .width(pct(100)).height(pct(100)).css({
     344        .width('100%').height('100%').css({
    335345          zIndex: 310,
    336346          position: 'absolute',
    337347          overflow: 'hidden'
    338         }).append($img2),
     348        }),
    339349
    340350        $hdl_holder = $('<div />')
    341         .width(pct(100)).height(pct(100)).css('zIndex', 320),
     351        .width('100%').height('100%').css('zIndex', 320),
    342352
    343353        $sel = $('<div />')
    344354        .css({
    345355          position: 'absolute',
    346           zIndex: 300
     356          zIndex: 600
     357        }).dblclick(function(){
     358          var c = Coords.getFixed();
     359          options.onDblClick.call(api,c);
    347360        }).insertBefore($img).append($img_holder, $hdl_holder);
     361
     362    if (img_mode) {
     363
     364      $img2 = $('<img />')
     365          .attr('src', $img.attr('src')).css(img_css).width(boundx).height(boundy),
     366
     367      $img_holder.append($img2);
     368
     369    }
    348370
    349371    if (ie6mode) {
     
    363385    /* }}} */
    364386    // Set more variables {{{
    365     var bgopacity = options.bgOpacity,
     387    var bgcolor = options.bgColor,
     388        bgopacity = options.bgOpacity,
    366389        xlimit, ylimit, xmin, ymin, xscale, yscale, enabled = true,
    367390        btndown, animating, shift_down;
     
    517540            rha = Math.abs(rh),
    518541            real_ratio = rwa / rha,
    519             xx, yy;
     542            xx, yy, w, h;
    520543
    521544        if (max_x === 0) {
     
    631654          yb = y1;
    632655        }
    633         return [Math.round(xa), Math.round(ya), Math.round(xb), Math.round(yb)];
     656        return [xa, ya, xb, yb];
    634657      }
    635658      //}}}
     
    719742
    720743    //}}}
     744    // Shade Module {{{
     745    var Shade = (function() {
     746      var enabled = false,
     747          holder = $('<div />').css({
     748            position: 'absolute',
     749            zIndex: 240,
     750            opacity: 0
     751          }),
     752          shades = {
     753            top: createShade(),
     754            left: createShade().height(boundy),
     755            right: createShade().height(boundy),
     756            bottom: createShade()
     757          };
     758
     759      function resizeShades(w,h) {
     760        shades.left.css({ height: px(h) });
     761        shades.right.css({ height: px(h) });
     762      }
     763      function updateAuto()
     764      {
     765        return updateShade(Coords.getFixed());
     766      }
     767      function updateShade(c)
     768      {
     769        shades.top.css({
     770          left: px(c.x),
     771          width: px(c.w),
     772          height: px(c.y)
     773        });
     774        shades.bottom.css({
     775          top: px(c.y2),
     776          left: px(c.x),
     777          width: px(c.w),
     778          height: px(boundy-c.y2)
     779        });
     780        shades.right.css({
     781          left: px(c.x2),
     782          width: px(boundx-c.x2)
     783        });
     784        shades.left.css({
     785          width: px(c.x)
     786        });
     787      }
     788      function createShade() {
     789        return $('<div />').css({
     790          position: 'absolute',
     791          backgroundColor: options.shadeColor||options.bgColor
     792        }).appendTo(holder);
     793      }
     794      function enableShade() {
     795        if (!enabled) {
     796          enabled = true;
     797          holder.insertBefore($img);
     798          updateAuto();
     799          Selection.setBgOpacity(1,0,1);
     800          $img2.hide();
     801
     802          setBgColor(options.shadeColor||options.bgColor,1);
     803          if (Selection.isAwake())
     804          {
     805            setOpacity(options.bgOpacity,1);
     806          }
     807            else setOpacity(1,1);
     808        }
     809      }
     810      function setBgColor(color,now) {
     811        colorChangeMacro(getShades(),color,now);
     812      }
     813      function disableShade() {
     814        if (enabled) {
     815          holder.remove();
     816          $img2.show();
     817          enabled = false;
     818          if (Selection.isAwake()) {
     819            Selection.setBgOpacity(options.bgOpacity,1,1);
     820          } else {
     821            Selection.setBgOpacity(1,1,1);
     822            Selection.disableHandles();
     823          }
     824          colorChangeMacro($div,0,1);
     825        }
     826      }
     827      function setOpacity(opacity,now) {
     828        if (enabled) {
     829          if (options.bgFade && !now) {
     830            holder.animate({
     831              opacity: 1-opacity
     832            },{
     833              queue: false,
     834              duration: options.fadeTime
     835            });
     836          }
     837          else holder.css({opacity:1-opacity});
     838        }
     839      }
     840      function refreshAll() {
     841        options.shade ? enableShade() : disableShade();
     842        if (Selection.isAwake()) setOpacity(options.bgOpacity);
     843      }
     844      function getShades() {
     845        return holder.children();
     846      }
     847
     848      return {
     849        update: updateAuto,
     850        updateRaw: updateShade,
     851        getShades: getShades,
     852        setBgColor: setBgColor,
     853        enable: enableShade,
     854        disable: disableShade,
     855        resize: resizeShades,
     856        refresh: refreshAll,
     857        opacity: setOpacity
     858      };
     859    }());
     860    // }}}
    721861    // Selection Module {{{
    722862    var Selection = (function () {
    723       var awake, hdep = 370;
    724       var borders = {};
    725       var handle = {};
    726       var seehandles = false;
    727       var hhs = options.handleOffset;
     863      var awake,
     864          hdep = 370,
     865          borders = {},
     866          handle = {},
     867          dragbar = {},
     868          seehandles = false;
    728869
    729870      // Private Methods
     
    744885          position: 'absolute',
    745886          zIndex: zi
    746         });
     887        }).addClass('ord-'+ord);
    747888
    748889        if (Touch.support) {
    749           jq.bind('touchstart', Touch.createDragger(ord));
     890          jq.bind('touchstart.jcrop', Touch.createDragger(ord));
    750891        }
    751892
     
    756897      function insertHandle(ord) //{{{
    757898      {
     899        var hs = options.handleSize;
    758900        return dragDiv(ord, hdep++).css({
    759           top: px(-hhs + 1),
    760           left: px(-hhs + 1),
    761901          opacity: options.handleOpacity
    762         }).addClass(cssClass('handle'));
     902        }).width(hs).height(hs).addClass(cssClass('handle'));
    763903      }
    764904      //}}}
    765905      function insertDragbar(ord) //{{{
    766906      {
    767         var s = options.handleSize,
    768             h = s,
    769             w = s,
    770             t = hhs,
    771             l = hhs;
    772 
    773         switch (ord) {
    774         case 'n':
    775         case 's':
    776           w = pct(100);
    777           break;
    778         case 'e':
    779         case 'w':
    780           h = pct(100);
    781           break;
    782         }
    783 
    784         return dragDiv(ord, hdep++).width(w).height(h).css({
    785           top: px(-t + 1),
    786           left: px(-l + 1)
    787         });
     907        return dragDiv(ord, hdep++).addClass('jcrop-dragbar');
     908      }
     909      //}}}
     910      function createDragbars(li) //{{{
     911      {
     912        var i;
     913        for (i = 0; i < li.length; i++) {
     914          dragbar[li[i]] = insertDragbar(li[i]);
     915        }
     916      }
     917      //}}}
     918      function createBorders(li) //{{{
     919      {
     920        var cl,i;
     921        for (i = 0; i < li.length; i++) {
     922          switch(li[i]){
     923            case'n': cl='hline'; break;
     924            case's': cl='hline bottom'; break;
     925            case'e': cl='vline right'; break;
     926            case'w': cl='vline'; break;
     927          }
     928          borders[li[i]] = insertBorder(cl);
     929        }
    788930      }
    789931      //}}}
     
    796938      }
    797939      //}}}
    798       function moveHandles(c) //{{{
    799       {
    800         var midvert = Math.round((c.h / 2) - hhs),
    801             midhoriz = Math.round((c.w / 2) - hhs),
    802             north = -hhs + 1,
    803             west = -hhs + 1,
    804             east = c.w - hhs,
    805             south = c.h - hhs,
    806             x, y;
    807 
    808         if (handle.e) {
    809           handle.e.css({
    810             top: px(midvert),
    811             left: px(east)
     940      function moveto(x, y) //{{{
     941      {
     942        if (!options.shade) {
     943          $img2.css({
     944            top: px(-y),
     945            left: px(-x)
    812946          });
    813           handle.w.css({
    814             top: px(midvert)
    815           });
    816           handle.s.css({
    817             top: px(south),
    818             left: px(midhoriz)
    819           });
    820           handle.n.css({
    821             left: px(midhoriz)
    822           });
    823         }
    824         if (handle.ne) {
    825           handle.ne.css({
    826             left: px(east)
    827           });
    828           handle.se.css({
    829             top: px(south),
    830             left: px(east)
    831           });
    832           handle.sw.css({
    833             top: px(south)
    834           });
    835         }
    836         if (handle.b) {
    837           handle.b.css({
    838             top: px(south)
    839           });
    840           handle.r.css({
    841             left: px(east)
    842           });
    843         }
    844       }
    845       //}}}
    846       function moveto(x, y) //{{{
    847       {
    848         $img2.css({
    849           top: px(-y),
    850           left: px(-x)
    851         });
     947        }
    852948        $sel.css({
    853949          top: px(y),
     
    873969
    874970      // Internal Methods
    875       function updateVisible() //{{{
     971      function updateVisible(select) //{{{
    876972      {
    877973        if (awake) {
    878           return update();
    879         }
    880       }
    881       //}}}
    882       function update() //{{{
     974          return update(select);
     975        }
     976      }
     977      //}}}
     978      function update(select) //{{{
    883979      {
    884980        var c = Coords.getFixed();
     
    886982        resize(c.w, c.h);
    887983        moveto(c.x, c.y);
    888 
    889 /*
    890                         options.drawBorders &&
    891                                 borders.right.css({ left: px(c.w-1) }) &&
    892                                         borders.bottom.css({ top: px(c.h-1) });
    893       */
    894 
    895         if (seehandles) {
    896           moveHandles(c);
    897         }
    898         if (!awake) {
    899           show();
    900         }
    901 
    902         options.onChange.call(api, unscale(c));
     984        if (options.shade) Shade.updateRaw(c);
     985
     986        awake || show();
     987
     988        if (select) {
     989          options.onSelect.call(api, unscale(c));
     990        } else {
     991          options.onChange.call(api, unscale(c));
     992        }
     993      }
     994      //}}}
     995      function setBgOpacity(opacity,force,now) //{{{
     996      {
     997        if (!awake && !force) return;
     998        if (options.bgFade && !now) {
     999          $img.animate({
     1000            opacity: opacity
     1001          },{
     1002            queue: false,
     1003            duration: options.fadeTime
     1004          });
     1005        } else {
     1006          $img.css('opacity', opacity);
     1007        }
    9031008      }
    9041009      //}}}
     
    9071012        $sel.show();
    9081013
    909         if (options.bgFade) {
    910           $img.fadeTo(options.fadeTime, bgopacity);
    911         } else {
    912           $img.css('opacity', bgopacity);
    913         }
     1014        if (options.shade) Shade.opacity(bgopacity);
     1015          else setBgOpacity(bgopacity,true);
    9141016
    9151017        awake = true;
     
    9211023        $sel.hide();
    9221024
    923         if (options.bgFade) {
    924           $img.fadeTo(options.fadeTime, 1);
    925         } else {
    926           $img.css('opacity', 1);
    927         }
     1025        if (options.shade) Shade.opacity(1);
     1026          else setBgOpacity(1);
    9281027
    9291028        awake = false;
     
    9341033      {
    9351034        if (seehandles) {
    936           moveHandles(Coords.getFixed());
    9371035          $hdl_holder.show();
    9381036        }
     
    9431041        seehandles = true;
    9441042        if (options.allowResize) {
    945           moveHandles(Coords.getFixed());
    9461043          $hdl_holder.show();
    9471044          return true;
     
    9701067      }
    9711068      //}}}
    972       /* Insert draggable elements {{{*/
    973 
     1069      // Insert draggable elements {{{
    9741070      // Insert border divs for outline
    975       if (options.drawBorders) {
    976         borders = {
    977           top: insertBorder('hline'),
    978           bottom: insertBorder('hline bottom'),
    979           left: insertBorder('vline'),
    980           right: insertBorder('vline right')
    981         };
    982       }
    983 
    984       // Insert handles on edges
    985       if (options.dragEdges) {
    986         handle.t = insertDragbar('n');
    987         handle.b = insertDragbar('s');
    988         handle.r = insertDragbar('e');
    989         handle.l = insertDragbar('w');
    990       }
    991 
    992       // Insert side and corner handles
    993       if (options.sideHandles) {
    994         createHandles(['n', 's', 'e', 'w']);
    995       }
    996       if (options.cornerHandles) {
    997         createHandles(['sw', 'nw', 'ne', 'se']);
    998       }
    999 
    1000      
    1001       //}}}
     1071
     1072      if (options.dragEdges && $.isArray(options.createDragbars))
     1073        createDragbars(options.createDragbars);
     1074
     1075      if ($.isArray(options.createHandles))
     1076        createHandles(options.createHandles);
     1077
     1078      if (options.drawBorders && $.isArray(options.createBorders))
     1079        createBorders(options.createBorders);
     1080
     1081      //}}}
     1082
     1083      // This is a hack for iOS5 to support drag/move touch functionality
     1084      $(document).bind('touchstart.jcrop-ios',function(e) {
     1085        if ($(e.currentTarget).hasClass('jcrop-tracker')) e.stopPropagation();
     1086      });
    10021087
    10031088      var $track = newTracker().mousedown(createDragger('move')).css({
     
    10321117        disableHandles: disableHandles,
    10331118        animMode: animMode,
     1119        setBgOpacity: setBgOpacity,
    10341120        done: done
    10351121      };
     
    10481134          zIndex: 450
    10491135        });
     1136        if (Touch.support) {
     1137          $(document)
     1138            .bind('touchmove.jcrop', trackTouchMove)
     1139            .bind('touchend.jcrop', trackTouchEnd);
     1140        }
    10501141        if (trackDoc) {
    10511142          $(document)
    1052             .bind('mousemove',trackMove)
    1053             .bind('mouseup',trackUp);
     1143            .bind('mousemove.jcrop',trackMove)
     1144            .bind('mouseup.jcrop',trackUp);
    10541145        }
    10551146      }
     
    10601151          zIndex: 290
    10611152        });
    1062         if (trackDoc) {
    1063           $(document)
    1064             .unbind('mousemove', trackMove)
    1065             .unbind('mouseup', trackUp);
    1066         }
     1153        $(document).unbind('.jcrop');
    10671154      }
    10681155      //}}}
     
    11231210      }
    11241211      //}}}
    1125 
    1126       if (Touch.support) {
    1127         $(document)
    1128           .bind('touchmove', trackTouchMove)
    1129           .bind('touchend', trackTouchEnd);
    1130       }
    11311212
    11321213      if (!trackDoc) {
     
    11701251        if (options.allowMove) {
    11711252          Coords.moveOffset([x, y]);
    1172           Selection.updateVisible();
     1253          Selection.updateVisible(true);
    11731254        }
    11741255        e.preventDefault();
     
    11781259      function parseKey(e) //{{{
    11791260      {
    1180         if (e.ctrlKey) {
     1261        if (e.ctrlKey || e.metaKey) {
    11811262          return true;
    11821263        }
     
    11981279          break;
    11991280        case 27:
    1200           Selection.release();
     1281          if (options.allowSelect) Selection.release();
    12011282          break;
    12021283        case 9:
     
    12361317    function animateTo(a, callback) //{{{
    12371318    {
    1238       var x1 = parseInt(a[0], 10) / xscale,
    1239           y1 = parseInt(a[1], 10) / yscale,
    1240           x2 = parseInt(a[2], 10) / xscale,
    1241           y2 = parseInt(a[3], 10) / yscale;
     1319      var x1 = a[0] / xscale,
     1320          y1 = a[1] / yscale,
     1321          x2 = a[2] / xscale,
     1322          y2 = a[3] / yscale;
    12421323
    12431324      if (animating) {
     
    12961377    function setSelect(rect) //{{{
    12971378    {
    1298       setSelectRaw([
    1299       parseInt(rect[0], 10) / xscale, parseInt(rect[1], 10) / yscale, parseInt(rect[2], 10) / xscale, parseInt(rect[3], 10) / yscale]);
     1379      setSelectRaw([rect[0] / xscale, rect[1] / yscale, rect[2] / xscale, rect[3] / yscale]);
     1380      options.onSelect.call(api, unscale(Coords.getFixed()));
     1381      Selection.enableHandles();
    13001382    }
    13011383    //}}}
     
    13691451        $trk.width(boundx + (bound * 2)).height(boundy + (bound * 2));
    13701452        $div.width(boundx).height(boundy);
     1453        Shade.resize(boundx,boundy);
    13711454        enableCrop();
    13721455
     
    13781461    }
    13791462    //}}}
     1463    function colorChangeMacro($obj,color,now) {
     1464      var mycolor = color || options.bgColor;
     1465      if (options.bgFade && supportsColorFade() && options.fadeTime && !now) {
     1466        $obj.animate({
     1467          backgroundColor: mycolor
     1468        }, {
     1469          queue: false,
     1470          duration: options.fadeTime
     1471        });
     1472      } else {
     1473        $obj.css('backgroundColor', mycolor);
     1474      }
     1475    }
    13801476    function interfaceUpdate(alt) //{{{
    13811477    // This method tweaks the interface based on options object.
     
    13951491      Selection.setCursor(options.allowMove ? 'move' : 'default');
    13961492
     1493      if (options.hasOwnProperty('trueSize')) {
     1494        xscale = options.trueSize[0] / boundx;
     1495        yscale = options.trueSize[1] / boundy;
     1496      }
    13971497
    13981498      if (options.hasOwnProperty('setSelect')) {
     
    14021502      }
    14031503
    1404       if (options.hasOwnProperty('trueSize')) {
    1405         xscale = options.trueSize[0] / boundx;
    1406         yscale = options.trueSize[1] / boundy;
    1407       }
    1408       if (options.hasOwnProperty('bgColor')) {
    1409 
    1410         if (supportsColorFade() && options.fadeTime) {
    1411           $div.animate({
    1412             backgroundColor: options.bgColor
    1413           }, {
    1414             queue: false,
    1415             duration: options.fadeTime
    1416           });
    1417         } else {
    1418           $div.css('backgroundColor', options.bgColor);
    1419         }
    1420 
    1421         delete(options.bgColor);
    1422       }
    1423       if (options.hasOwnProperty('bgOpacity')) {
     1504      Shade.refresh();
     1505
     1506      if (options.bgColor != bgcolor) {
     1507        colorChangeMacro(
     1508          options.shade? Shade.getShades(): $div,
     1509          options.shade?
     1510            (options.shadeColor || options.bgColor):
     1511            options.bgColor
     1512        );
     1513        bgcolor = options.bgColor;
     1514      }
     1515
     1516      if (bgopacity != options.bgOpacity) {
    14241517        bgopacity = options.bgOpacity;
    1425 
    1426         if (Selection.isAwake()) {
    1427           if (options.fadeTime) {
    1428             $img.fadeTo(options.fadeTime, bgopacity);
    1429           } else {
    1430             $div.css('opacity', options.opacity);
    1431           }
    1432         }
    1433         delete(options.bgOpacity);
     1518        if (options.shade) Shade.refresh();
     1519          else Selection.setBgOpacity(bgopacity);
    14341520      }
    14351521
     
    14491535    //}}}
    14501536
    1451     if (Touch.support) {
    1452       $trk.bind('touchstart', Touch.newSelection);
    1453     }
     1537    if (Touch.support) $trk.bind('touchstart.jcrop', Touch.newSelection);
    14541538
    14551539    $hdl_holder.hide();
     
    14821566        return [xscale, yscale];
    14831567      },
     1568      getOptions: function() {
     1569        // careful: internal values are returned
     1570        return options;
     1571      },
    14841572
    14851573      ui: {
     
    14891577    };
    14901578
    1491     if ($.browser.msie) {
    1492       $div.bind('selectstart', function () {
    1493         return false;
    1494       });
    1495     }
     1579    if ($.browser.msie)
     1580      $div.bind('selectstart', function () { return false; });
    14961581
    14971582    $origimg.data('Jcrop', api);
     
    15001585  $.fn.Jcrop = function (options, callback) //{{{
    15011586  {
    1502 
    1503     function attachWhenDone(from) //{{{
    1504     {
    1505       var opt = (typeof(options) === 'object') ? options : {};
    1506       var loadsrc = opt.useImg || from.src;
    1507       var img = new Image();
    1508       img.onload = function () {
    1509         function attachJcrop() {
    1510           var api = $.Jcrop(from, opt);
    1511           if (typeof(callback) === 'function') {
    1512             callback.call(api);
    1513           }
    1514         }
    1515 
    1516         function attachAttempt() {
    1517           if (!img.width || !img.height) {
    1518             window.setTimeout(attachAttempt, 50);
    1519           } else {
    1520             attachJcrop();
    1521           }
    1522         }
    1523         window.setTimeout(attachAttempt, 50);
    1524       };
    1525       img.src = loadsrc;
    1526     }
    1527     //}}}
    1528 
     1587    var api;
    15291588    // Iterate over each object, attach Jcrop
    15301589    this.each(function () {
     
    15321591      if ($(this).data('Jcrop')) {
    15331592        // The API can be requested this way (undocumented)
    1534         if (options === 'api') {
    1535           return $(this).data('Jcrop');
    1536         }
     1593        if (options === 'api') return $(this).data('Jcrop');
    15371594        // Otherwise, we just reset the options...
    1538         else {
    1539           $(this).data('Jcrop').setOptions(options);
    1540         }
     1595        else $(this).data('Jcrop').setOptions(options);
    15411596      }
    15421597      // If we haven't been attached, preload and attach
    15431598      else {
    1544         attachWhenDone(this);
     1599        if (this.tagName == 'IMG')
     1600          $.Jcrop.Loader(this,function(){
     1601            $(this).css({display:'block',visibility:'hidden'});
     1602            api = $.Jcrop(this, options);
     1603            if ($.isFunction(callback)) callback.call(api);
     1604          });
     1605        else {
     1606          $(this).css({display:'block',visibility:'hidden'});
     1607          api = $.Jcrop(this, options);
     1608          if ($.isFunction(callback)) callback.call(api);
     1609        }
    15451610      }
    15461611    });
     
    15491614    return this;
    15501615  };
     1616  //}}}
     1617  // $.Jcrop.Loader - basic image loader {{{
     1618
     1619  $.Jcrop.Loader = function(imgobj,success,error){
     1620    var $img = $(imgobj), img = $img[0];
     1621
     1622    function completeCheck(){
     1623      if (img.complete) {
     1624        $img.unbind('.jcloader');
     1625        if ($.isFunction(success)) success.call(img);
     1626      }
     1627      else window.setTimeout(completeCheck,50);
     1628    }
     1629
     1630    $img
     1631      .bind('load.jcloader',completeCheck)
     1632      .bind('error.jcloader',function(e){
     1633        $img.unbind('.jcloader');
     1634        if ($.isFunction(error)) error.call(img);
     1635      });
     1636
     1637    if (img.complete && $.isFunction(success)){
     1638      $img.unbind('.jcloader');
     1639      success.call(img);
     1640    }
     1641  };
     1642
    15511643  //}}}
    15521644  // Global Defaults {{{
     
    15681660    borderOpacity: 0.4,
    15691661    handleOpacity: 0.5,
    1570     handleSize: 9,
    1571     handleOffset: 5,
     1662    handleSize: 7,
    15721663
    15731664    aspectRatio: 0,
    15741665    keySupport: true,
    1575     cornerHandles: true,
    1576     sideHandles: true,
     1666    createHandles: ['n','s','e','w','nw','ne','se','sw'],
     1667    createDragbars: ['n','s','e','w'],
     1668    createBorders: ['n','s','e','w'],
    15771669    drawBorders: true,
    15781670    dragEdges: true,
    15791671    fixedSupport: true,
    15801672    touchSupport: null,
     1673
     1674    shade: null,
    15811675
    15821676    boxWidth: 0,
     
    15941688    onChange: function () {},
    15951689    onSelect: function () {},
     1690    onDblClick: function () {},
    15961691    onRelease: function () {}
    15971692  };
Note: See TracChangeset for help on using the changeset viewer.