From 091e96b27c63421983928001e4e838bdad723657 Mon Sep 17 00:00:00 2001 From: azaozz Date: Sun, 15 May 2011 18:03:51 +0000 Subject: [PATCH] Update imgareaselect Jquery plugin, props duck_, fixes #17446 git-svn-id: http://svn.automattic.com/wordpress/trunk@17934 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../imgareaselect/jquery.imgareaselect.dev.js | 217 ++++++++++-------- .../js/imgareaselect/jquery.imgareaselect.js | 2 +- wp-includes/script-loader.php | 2 +- 3 files changed, 126 insertions(+), 95 deletions(-) diff --git a/wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js b/wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js index aa3ff78c57..5fc41c7b57 100644 --- a/wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js +++ b/wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js @@ -1,8 +1,8 @@ /* * imgAreaSelect jQuery plugin - * version 0.9.1 + * version 0.9.6 * - * Copyright (c) 2008-2009 Michal Wojciechowski (odyniec.net) + * Copyright (c) 2008-2011 Michal Wojciechowski (odyniec.net) * * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. @@ -39,13 +39,13 @@ $.imgAreaSelect = function (img, options) { left, top, - imgOfs, + imgOfs = { left: 0, top: 0 }, imgWidth, imgHeight, $parent, - parOfs, + parOfs = { left: 0, top: 0 }, zIndex = 0, @@ -59,6 +59,8 @@ $.imgAreaSelect = function (img, options) { resize, + minWidth, minHeight, maxWidth, maxHeight, + aspectRatio, shown, @@ -67,6 +69,8 @@ $.imgAreaSelect = function (img, options) { selection = { x1: 0, y1: 0, x2: 0, y2: 0, width: 0, height: 0 }, + docElem = document.documentElement, + $p, d, i, o, w, h, adjusted; function viewX(x) { @@ -108,14 +112,14 @@ $.imgAreaSelect = function (img, options) { var sx = noScale || scaleX, sy = noScale || scaleY; selection = { - x1: round(x1 / sx), - y1: round(y1 / sy), - x2: round(x2 / sx), - y2: round(y2 / sy) + x1: round(x1 / sx || 0), + y1: round(y1 / sy || 0), + x2: round(x2 / sx || 0), + y2: round(y2 / sy || 0) }; - selection.width = (x2 = viewX(selection.x2)) - (x1 = viewX(selection.x1)); - selection.height = (y2 = viewX(selection.y2)) - (y1 = viewX(selection.y1)); + selection.width = selection.x2 - selection.x1; + selection.height = selection.y2 - selection.y1; } function adjust() { @@ -124,13 +128,22 @@ $.imgAreaSelect = function (img, options) { imgOfs = { left: round($img.offset().left), top: round($img.offset().top) }; - imgWidth = $img.width(); - imgHeight = $img.height(); + imgWidth = $img.innerWidth(); + imgHeight = $img.innerHeight(); - if ($().jquery == '1.3.2' && $.browser.safari && position == 'fixed') { - imgOfs.top += max(document.documentElement.scrollTop, $('body').scrollTop()); + imgOfs.top += ($img.outerHeight() - imgHeight) >> 1; + imgOfs.left += ($img.outerWidth() - imgWidth) >> 1; - imgOfs.left += max(document.documentElement.scrollLeft, $('body').scrollLeft()); + minWidth = options.minWidth || 0; + minHeight = options.minHeight || 0; + maxWidth = min(options.maxWidth || 1<<24, imgWidth); + maxHeight = min(options.maxHeight || 1<<24, imgHeight); + + if ($().jquery == '1.3.2' && position == 'fixed' && + !docElem['getBoundingClientRect']) + { + imgOfs.top += max(document.body.scrollTop, docElem.scrollTop); + imgOfs.left += max(document.body.scrollLeft, docElem.scrollLeft); } parOfs = $.inArray($parent.css('position'), ['absolute', 'relative']) + 1 ? @@ -142,6 +155,9 @@ $.imgAreaSelect = function (img, options) { left = viewX(0); top = viewY(0); + + if (selection.x2 > imgWidth || selection.y2 > imgHeight) + doResize(); } function update(resetKeyPress) { @@ -170,10 +186,10 @@ $.imgAreaSelect = function (img, options) { switch ($handles.length) { case 8: - $($handles[4]).css({ left: w / 2 }); - $($handles[5]).css({ left: w, top: h / 2 }); - $($handles[6]).css({ left: w / 2, top: h }); - $($handles[7]).css({ top: h / 2 }); + $($handles[4]).css({ left: w >> 1 }); + $($handles[5]).css({ left: w, top: h >> 1 }); + $($handles[6]).css({ left: w >> 1, top: h }); + $($handles[7]).css({ top: h >> 1 }); case 4: $handles.slice(1,3).css({ left: w }); $handles.slice(2,4).css({ top: h }); @@ -221,13 +237,13 @@ $.imgAreaSelect = function (img, options) { resize = ''; if (options.resizable) { - if (y <= resizeMargin) + if (y <= options.resizeMargin) resize = 'n'; - else if (y >= selection.height - resizeMargin) + else if (y >= selection.height - options.resizeMargin) resize = 's'; - if (x <= resizeMargin) + if (x <= options.resizeMargin) resize += 'w'; - else if (x >= selection.width - resizeMargin) + else if (x >= selection.width - options.resizeMargin) resize += 'e'; } @@ -239,14 +255,13 @@ $.imgAreaSelect = function (img, options) { function docMouseUp(event) { $('body').css('cursor', ''); - if (options.autoHide || selection.width * selection.height == 0) hide($box.add($outer), function () { $(this).hide(); }); - options.onSelectEnd(img, getSelection()); - $(document).unbind('mousemove', selectingMouseMove); $box.mousemove(areaMouseMove); + + options.onSelectEnd(img, getSelection()); } function areaMouseDown(event) { @@ -284,59 +299,60 @@ $.imgAreaSelect = function (img, options) { return false; } - function aspectRatioXY() { - x2 = max(left, min(left + imgWidth, - x1 + abs(y2 - y1) * aspectRatio * (x2 > x1 || -1))); + function fixAspectRatio(xFirst) { + if (aspectRatio) + if (xFirst) { + x2 = max(left, min(left + imgWidth, + x1 + abs(y2 - y1) * aspectRatio * (x2 > x1 || -1))); - y2 = round(max(top, min(top + imgHeight, - y1 + abs(x2 - x1) / aspectRatio * (y2 > y1 || -1)))); - x2 = round(x2); - } - - function aspectRatioYX() { - y2 = max(top, min(top + imgHeight, - y1 + abs(x2 - x1) / aspectRatio * (y2 > y1 || -1))); - x2 = round(max(left, min(left + imgWidth, - x1 + abs(y2 - y1) * aspectRatio * (x2 > x1 || -1)))); - y2 = round(y2); + y2 = round(max(top, min(top + imgHeight, + y1 + abs(x2 - x1) / aspectRatio * (y2 > y1 || -1)))); + x2 = round(x2); + } + else { + y2 = max(top, min(top + imgHeight, + y1 + abs(x2 - x1) / aspectRatio * (y2 > y1 || -1))); + x2 = round(max(left, min(left + imgWidth, + x1 + abs(y2 - y1) * aspectRatio * (x2 > x1 || -1)))); + y2 = round(y2); + } } function doResize() { - if (abs(x2 - x1) < options.minWidth) { - x2 = x1 - options.minWidth * (x2 < x1 || -1); + x1 = min(x1, left + imgWidth); + y1 = min(y1, top + imgHeight); + + if (abs(x2 - x1) < minWidth) { + x2 = x1 - minWidth * (x2 < x1 || -1); if (x2 < left) - x1 = left + options.minWidth; + x1 = left + minWidth; else if (x2 > left + imgWidth) - x1 = left + imgWidth - options.minWidth; + x1 = left + imgWidth - minWidth; } - if (abs(y2 - y1) < options.minHeight) { - y2 = y1 - options.minHeight * (y2 < y1 || -1); + if (abs(y2 - y1) < minHeight) { + y2 = y1 - minHeight * (y2 < y1 || -1); if (y2 < top) - y1 = top + options.minHeight; + y1 = top + minHeight; else if (y2 > top + imgHeight) - y1 = top + imgHeight - options.minHeight; + y1 = top + imgHeight - minHeight; } x2 = max(left, min(x2, left + imgWidth)); y2 = max(top, min(y2, top + imgHeight)); - if (aspectRatio) - if (abs(x2 - x1) / aspectRatio > abs(y2 - y1)) - aspectRatioYX(); - else - aspectRatioXY(); + fixAspectRatio(abs(x2 - x1) < abs(y2 - y1) * aspectRatio); - if (abs(x2 - x1) > options.maxWidth) { - x2 = x1 - options.maxWidth * (x2 < x1 || -1); - if (aspectRatio) aspectRatioYX(); + if (abs(x2 - x1) > maxWidth) { + x2 = x1 - maxWidth * (x2 < x1 || -1); + fixAspectRatio(); } - if (abs(y2 - y1) > options.maxHeight) { - y2 = y1 - options.maxHeight * (y2 < y1 || -1); - if (aspectRatio) aspectRatioXY(); + if (abs(y2 - y1) > maxHeight) { + y2 = y1 - maxHeight * (y2 < y1 || -1); + fixAspectRatio(true); } selection = { x1: selX(min(x1, x2)), x2: selX(max(x1, x2)), @@ -362,8 +378,8 @@ $.imgAreaSelect = function (img, options) { x2 = (x1 = newX1) + selection.width; y2 = (y1 = newY1) + selection.height; - selection = $.extend(selection, { x1: selX(x1), y1: selY(y1), - x2: selX(x2), y2: selY(y2) }); + $.extend(selection, { x1: selX(x1), y1: selY(y1), x2: selX(x2), + y2: selY(y2) }); update(); @@ -382,6 +398,7 @@ $.imgAreaSelect = function (img, options) { } function startSelection() { + $(document).unbind('mousemove', startSelection); adjust(); x2 = x1; @@ -404,11 +421,11 @@ $.imgAreaSelect = function (img, options) { } function cancelSelection() { - $(document).unbind('mousemove', startSelection); + $(document).unbind('mousemove', startSelection) + .unbind('mouseup', cancelSelection); hide($box.add($outer)); - selection = { x1: selX(x1), y1: selY(y1), x2: selX(x1), y2: selY(y1), - width: 0, height: 0 }; + setSelection(selX(x1), selY(y1), selX(x1), selY(y1)); options.onSelectChange(img, getSelection()); options.onSelectEnd(img, getSelection()); @@ -421,13 +438,12 @@ $.imgAreaSelect = function (img, options) { startX = x1 = evX(event); startY = y1 = evY(event); - $(document).one('mousemove', startSelection) - .one('mouseup', cancelSelection); + $(document).mousemove(startSelection).mouseup(cancelSelection); return false; } - function parentScroll() { + function windowResize() { doUpdate(false); } @@ -437,8 +453,9 @@ $.imgAreaSelect = function (img, options) { setOptions(options = $.extend({ classPrefix: 'imgareaselect', movable: true, - resizable: true, parent: 'body', + resizable: true, + resizeMargin: 10, onInit: function () {}, onSelectStart: function () {}, onSelectChange: function () {}, @@ -458,7 +475,7 @@ $.imgAreaSelect = function (img, options) { } var docKeyPress = function(event) { - var k = options.keys, d, t, key = event.keyCode || event.which; + var k = options.keys, d, t, key = event.keyCode; d = !isNaN(k.alt) && (event.altKey || event.originalEvent.altKey) ? k.alt : !isNaN(k.ctrl) && event.ctrlKey ? k.ctrl : @@ -476,7 +493,7 @@ $.imgAreaSelect = function (img, options) { t = max(x1, x2); x1 = min(x1, x2); x2 = max(t + d, x1); - if (aspectRatio) aspectRatioYX(); + fixAspectRatio(); break; case 38: d = -d; @@ -484,7 +501,7 @@ $.imgAreaSelect = function (img, options) { t = max(y1, y2); y1 = min(y1, y2); y2 = max(t + d, y1); - if (aspectRatio) aspectRatioXY(); + fixAspectRatio(true); break; default: return; @@ -527,7 +544,7 @@ $.imgAreaSelect = function (img, options) { if (newOptions.parent) ($parent = $(newOptions.parent)).append($box.add($outer)); - options = $.extend(options, newOptions); + $.extend(options, newOptions); adjust(); @@ -546,7 +563,7 @@ $.imgAreaSelect = function (img, options) { zIndex: zIndex + 1 || 1 }); - if (!parseInt($handles.css('width'))) + if (!parseInt($handles.css('width')) >= 0) $handles.width(5).height(5); if (o = options.borderWidth) @@ -562,7 +579,7 @@ $.imgAreaSelect = function (img, options) { if (newOptions.x1 != null) { setSelection(newOptions.x1, newOptions.y1, newOptions.x2, - newOptions.y2); + newOptions.y2); newOptions.show = !newOptions.hide; } @@ -586,7 +603,7 @@ $.imgAreaSelect = function (img, options) { if (o = options.borderColor2) $($border[1]).css({ borderStyle: 'dashed', borderColor: o }); - $box.append($area.add($border).add($handles).add($areaOpera)); + $box.append($area.add($border).add($areaOpera).add($handles)); if ($.browser.msie) { if (o = $outer.css('filter').match(/opacity=([0-9]+)/)) @@ -605,25 +622,32 @@ $.imgAreaSelect = function (img, options) { aspectRatio = (d = (options.aspectRatio || '').split(/:/))[0] / d[1]; + $img.add($outer).unbind('mousedown', imgMouseDown); + if (options.disable || options.enable === false) { $box.unbind('mousemove', areaMouseMove).unbind('mousedown', areaMouseDown); - $img.add($outer).unbind('mousedown', imgMouseDown); - $(window).unbind('resize', parentScroll); - $img.add($img.parents()).unbind('scroll', parentScroll); + $(window).unbind('resize', windowResize); } - else if (options.enable || options.disable === false) { - if (options.resizable || options.movable) - $box.mousemove(areaMouseMove).mousedown(areaMouseDown); + else { + if (options.enable || options.disable === false) { + if (options.resizable || options.movable) + $box.mousemove(areaMouseMove).mousedown(areaMouseDown); + + $(window).resize(windowResize); + } if (!options.persistent) $img.add($outer).mousedown(imgMouseDown); - $(window).resize(parentScroll); - $img.add($img.parents()).scroll(parentScroll); } options.enable = options.disable = undefined; } + this.remove = function () { + setOptions({ disable: true }); + $box.add($outer).remove(); + }; + this.getOptions = function () { return options; }; this.setOptions = setOptions; @@ -636,17 +660,16 @@ $.imgAreaSelect = function (img, options) { $p = $img; - while ($p.length && !$p.is('body')) { - if (!isNaN($p.css('z-index')) && $p.css('z-index') > zIndex) - zIndex = $p.css('z-index'); + while ($p.length) { + zIndex = max(zIndex, + !isNaN($p.css('z-index')) ? $p.css('z-index') : zIndex); if ($p.css('position') == 'fixed') position = 'fixed'; - $p = $p.parent(); + $p = $p.parent(':not(body)'); } - if (!isNaN(options.zIndex)) - zIndex = options.zIndex; + zIndex = options.zIndex || zIndex; if ($.browser.msie) $img.attr('unselectable', 'on'); @@ -661,20 +684,28 @@ $.imgAreaSelect = function (img, options) { $box.add($outer).css({ visibility: 'hidden', position: position, overflow: 'hidden', zIndex: zIndex || '0' }); $box.css({ zIndex: zIndex + 2 || 2 }); - $area.add($border).css({ position: 'absolute' }); + $area.add($border).css({ position: 'absolute', fontSize: 0 }); img.complete || img.readyState == 'complete' || !$img.is('img') ? imgLoad() : $img.one('load', imgLoad); + if ($.browser.msie && $.browser.version >= 9) + img.src = img.src; }; $.fn.imgAreaSelect = function (options) { options = options || {}; this.each(function () { - if ($(this).data('imgAreaSelect')) - $(this).data('imgAreaSelect').setOptions(options); - else { + if ($(this).data('imgAreaSelect')) { + if (options.remove) { + $(this).data('imgAreaSelect').remove(); + $(this).removeData('imgAreaSelect'); + } + else + $(this).data('imgAreaSelect').setOptions(options); + } + else if (!options.remove) { if (options.enable === undefined && options.disable === undefined) options.enable = true; diff --git a/wp-includes/js/imgareaselect/jquery.imgareaselect.js b/wp-includes/js/imgareaselect/jquery.imgareaselect.js index 9f2aee24a7..a29d6678f6 100644 --- a/wp-includes/js/imgareaselect/jquery.imgareaselect.js +++ b/wp-includes/js/imgareaselect/jquery.imgareaselect.js @@ -1 +1 @@ -(function(e){var b=Math.abs,a=Math.max,d=Math.min,c=Math.round;function f(){return e("
")}e.imgAreaSelect=function(q,S){var aw=e(q),U,ar=f(),af=f(),H=f().add(f()).add(f()).add(f()),Y=f().add(f()).add(f()).add(f()),L=e([]),R,n,p,az,N,j,A,M,B=0,ad="absolute",Q,P,aa,Z,V=10,I,T,K,y,aA,x,ay,v={x1:0,y1:0,x2:0,y2:0,width:0,height:0},l,aq,am,ag,ac,an,u;function G(h){return h+az.left-M.left}function F(h){return h+az.top-M.top}function E(h){return h-az.left+M.left}function z(h){return h-az.top+M.top}function ak(h){return h.pageX-M.left}function ai(h){return h.pageY-M.top}function D(h){var o=h||aa,i=h||Z;return{x1:c(v.x1*o),y1:c(v.y1*i),x2:c(v.x2*o),y2:c(v.y2*i),width:c(v.x2*o)-c(v.x1*o),height:c(v.y2*i)-c(v.y1*i)}}function ae(i,w,h,o,aB){var aD=aB||aa,aC=aB||Z;v={x1:c(i/aD),y1:c(w/aC),x2:c(h/aD),y2:c(o/aC)};v.width=(h=G(v.x2))-(i=G(v.x1));v.height=(o=G(v.y2))-(w=G(v.y1))}function ao(){if(!aw.width()){return}az={left:c(aw.offset().left),top:c(aw.offset().top)};N=aw.width();j=aw.height();if(e().jquery=="1.3.2"&&e.browser.safari&&ad=="fixed"){az.top+=a(document.documentElement.scrollTop,e("body").scrollTop());az.left+=a(document.documentElement.scrollLeft,e("body").scrollLeft())}M=e.inArray(A.css("position"),["absolute","relative"])+1?{left:c(A.offset().left)-A.scrollLeft(),top:c(A.offset().top)-A.scrollTop()}:ad=="fixed"?{left:e(document).scrollLeft(),top:e(document).scrollTop()}:{left:0,top:0};n=G(0);p=F(0)}function X(h){if(!K){return}ar.css({left:G(v.x1),top:F(v.y1)}).add(af).width(ac=v.width).height(an=v.height);af.add(H).add(L).css({left:0,top:0});H.width(a(ac-H.outerWidth()+H.innerWidth(),0)).height(a(an-H.outerHeight()+H.innerHeight(),0));e(Y[0]).css({left:n,top:p,width:v.x1,height:j});e(Y[1]).css({left:n+v.x1,top:p,width:ac,height:v.y1});e(Y[2]).css({left:n+v.x2,top:p,width:N-v.x2,height:j});e(Y[3]).css({left:n+v.x1,top:p+v.y2,width:ac,height:j-v.y2});ac-=L.outerWidth();an-=L.outerHeight();switch(L.length){case 8:e(L[4]).css({left:ac/2});e(L[5]).css({left:ac,top:an/2});e(L[6]).css({left:ac/2,top:an});e(L[7]).css({top:an/2});case 4:L.slice(1,3).css({left:ac});L.slice(2,4).css({top:an})}if(h!==false){if(e.imgAreaSelect.keyPress!=at){e(document).unbind(e.imgAreaSelect.keyPress,e.imgAreaSelect.onKeyPress)}if(S.keys){e(document)[e.imgAreaSelect.keyPress](e.imgAreaSelect.onKeyPress=at)}}if(e.browser.msie&&H.outerWidth()-H.innerWidth()==2){H.css("margin",0);setTimeout(function(){H.css("margin","auto")},0)}}function t(h){ao();X(h);y=G(v.x1);aA=F(v.y1);x=G(v.x2);ay=F(v.y2)}function ah(h,i){S.fadeSpeed?h.fadeOut(S.fadeSpeed,i):h.hide()}function C(i){var h=E(ak(i))-v.x1,o=z(ai(i))-v.y1;if(!u){ao();u=true;ar.one("mouseout",function(){u=false})}I="";if(S.resizable){if(o<=V){I="n"}else{if(o>=v.height-V){I="s"}}if(h<=V){I+="w"}else{if(h>=v.width-V){I+="e"}}}ar.css("cursor",I?I+"-resize":S.movable?"move":"");if(R){R.toggle()}}function aj(h){e("body").css("cursor","");if(S.autoHide||v.width*v.height==0){ah(ar.add(Y),function(){e(this).hide()})}S.onSelectEnd(q,D());e(document).unbind("mousemove",ab);ar.mousemove(C)}function s(h){if(h.which!=1){return false}ao();if(I){e("body").css("cursor",I+"-resize");y=G(v[/w/.test(I)?"x2":"x1"]);aA=F(v[/n/.test(I)?"y2":"y1"]);e(document).mousemove(ab).one("mouseup",aj);ar.unbind("mousemove",C)}else{if(S.movable){Q=n+v.x1-ak(h);P=p+v.y1-ai(h);ar.unbind("mousemove",C);e(document).mousemove(g).one("mouseup",function(){S.onSelectEnd(q,D());e(document).unbind("mousemove",g);ar.mousemove(C)})}else{aw.mousedown(h)}}return false}function r(){x=a(n,d(n+N,y+b(ay-aA)*T*(x>y||-1)));ay=c(a(p,d(p+j,aA+b(x-y)/T*(ay>aA||-1))));x=c(x)}function al(){ay=a(p,d(p+j,aA+b(x-y)/T*(ay>aA||-1)));x=c(a(n,d(n+N,y+b(ay-aA)*T*(x>y||-1))));ay=c(ay)}function av(){if(b(x-y)n+N){y=n+N-S.minWidth}}}if(b(ay-aA)p+j){aA=p+j-S.minHeight}}}x=a(n,d(x,n+N));ay=a(p,d(ay,p+j));if(T){if(b(x-y)/T>b(ay-aA)){al()}else{r()}}if(b(x-y)>S.maxWidth){x=y-S.maxWidth*(xS.maxHeight){ay=aA-S.maxHeight*(ayB){B=l.css("z-index")}if(l.css("position")=="fixed"){ad="fixed"}l=l.parent()}if(!isNaN(S.zIndex)){B=S.zIndex}if(e.browser.msie){aw.attr("unselectable","on")}e.imgAreaSelect.keyPress=e.browser.msie||e.browser.safari?"keydown":"keypress";if(e.browser.opera){R=f().css({width:"100%",height:"100%",position:"absolute",zIndex:B+2||2})}ar.add(Y).css({visibility:"hidden",position:ad,overflow:"hidden",zIndex:B||"0"});ar.css({zIndex:B+2||2});af.add(H).css({position:"absolute"});q.complete||q.readyState=="complete"||!aw.is("img")?au():aw.one("load",au)};e.fn.imgAreaSelect=function(g){g=g||{};this.each(function(){if(e(this).data("imgAreaSelect")){e(this).data("imgAreaSelect").setOptions(g)}else{if(g.enable===undefined&&g.disable===undefined){g.enable=true}e(this).data("imgAreaSelect",new e.imgAreaSelect(this,g))}});if(g.instance){return e(this).data("imgAreaSelect")}return this}})(jQuery); \ No newline at end of file +(function(e){var b=Math.abs,a=Math.max,d=Math.min,c=Math.round;function f(){return e("
")}e.imgAreaSelect=function(Q,ad){var M=e(Q),u,B=f(),E=f(),ap=f().add(f()).add(f()).add(f()),v=f().add(f()).add(f()).add(f()),ax=e([]),aj,T,ao,ay={left:0,top:0},S,aA,p,V={left:0,top:0},g=0,ak="absolute",an,am,ab,aa,az=10,t,q,al,k,x,aE,ah,D,n,C,l,aC={x1:0,y1:0,x2:0,y2:0,width:0,height:0},F=document.documentElement,Z,R,O,N,K,P,I;function Y(h){return h+ay.left-V.left}function X(h){return h+ay.top-V.top}function au(h){return h-ay.left+V.left}function at(h){return h-ay.top+V.top}function A(h){return h.pageX-V.left}function z(h){return h.pageY-V.top}function ar(h){var o=h||ab,i=h||aa;return{x1:c(aC.x1*o),y1:c(aC.y1*i),x2:c(aC.x2*o),y2:c(aC.y2*i),width:c(aC.x2*o)-c(aC.x1*o),height:c(aC.y2*i)-c(aC.y1*i)}}function aq(i,w,h,o,aF){var aH=aF||ab,aG=aF||aa;aC={x1:c(i/aH||0),y1:c(w/aG||0),x2:c(h/aH||0),y2:c(o/aG||0)};aC.width=aC.x2-aC.x1;aC.height=aC.y2-aC.y1}function m(){if(!M.width()){return}ay={left:c(M.offset().left),top:c(M.offset().top)};S=M.innerWidth();aA=M.innerHeight();ay.top+=(M.outerHeight()-aA)>>1;ay.left+=(M.outerWidth()-S)>>1;q=ad.minWidth||0;al=ad.minHeight||0;k=d(ad.maxWidth||1<<24,S);x=d(ad.maxHeight||1<<24,aA);if(e().jquery=="1.3.2"&&ak=="fixed"&&!F.getBoundingClientRect){ay.top+=a(document.body.scrollTop,F.scrollTop);ay.left+=a(document.body.scrollLeft,F.scrollLeft)}V=e.inArray(p.css("position"),["absolute","relative"])+1?{left:c(p.offset().left)-p.scrollLeft(),top:c(p.offset().top)-p.scrollTop()}:ak=="fixed"?{left:e(document).scrollLeft(),top:e(document).scrollTop()}:{left:0,top:0};T=Y(0);ao=X(0);if(aC.x2>S||aC.y2>aA){aB()}}function J(h){if(!ah){return}B.css({left:Y(aC.x1),top:X(aC.y1)}).add(E).width(K=aC.width).height(P=aC.height);E.add(ap).add(ax).css({left:0,top:0});ap.width(a(K-ap.outerWidth()+ap.innerWidth(),0)).height(a(P-ap.outerHeight()+ap.innerHeight(),0));e(v[0]).css({left:T,top:ao,width:aC.x1,height:aA});e(v[1]).css({left:T+aC.x1,top:ao,width:K,height:aC.y1});e(v[2]).css({left:T+aC.x2,top:ao,width:S-aC.x2,height:aA});e(v[3]).css({left:T+aC.x1,top:ao+aC.y2,width:K,height:aA-aC.y2});K-=ax.outerWidth();P-=ax.outerHeight();switch(ax.length){case 8:e(ax[4]).css({left:K>>1});e(ax[5]).css({left:K,top:P>>1});e(ax[6]).css({left:K>>1,top:P});e(ax[7]).css({top:P>>1});case 4:ax.slice(1,3).css({left:K});ax.slice(2,4).css({top:P})}if(h!==false){if(e.imgAreaSelect.keyPress!=av){e(document).unbind(e.imgAreaSelect.keyPress,e.imgAreaSelect.onKeyPress)}if(ad.keys){e(document)[e.imgAreaSelect.keyPress](e.imgAreaSelect.onKeyPress=av)}}if(e.browser.msie&&ap.outerWidth()-ap.innerWidth()==2){ap.css("margin",0);setTimeout(function(){ap.css("margin","auto")},0)}}function y(h){m();J(h);D=Y(aC.x1);n=X(aC.y1);C=Y(aC.x2);l=X(aC.y2)}function ag(h,i){ad.fadeSpeed?h.fadeOut(ad.fadeSpeed,i):h.hide()}function H(i){var h=au(A(i))-aC.x1,o=at(z(i))-aC.y1;if(!I){m();I=true;B.one("mouseout",function(){I=false})}t="";if(ad.resizable){if(o<=ad.resizeMargin){t="n"}else{if(o>=aC.height-ad.resizeMargin){t="s"}}if(h<=ad.resizeMargin){t+="w"}else{if(h>=aC.width-ad.resizeMargin){t+="e"}}}B.css("cursor",t?t+"-resize":ad.movable?"move":"");if(aj){aj.toggle()}}function j(h){e("body").css("cursor","");if(ad.autoHide||aC.width*aC.height==0){ag(B.add(v),function(){e(this).hide()})}e(document).unbind("mousemove",ae);B.mousemove(H);ad.onSelectEnd(Q,ar())}function aw(h){if(h.which!=1){return false}m();if(t){e("body").css("cursor",t+"-resize");D=Y(aC[/w/.test(t)?"x2":"x1"]);n=X(aC[/n/.test(t)?"y2":"y1"]);e(document).mousemove(ae).one("mouseup",j);B.unbind("mousemove",H)}else{if(ad.movable){an=T+aC.x1-A(h);am=ao+aC.y1-z(h);B.unbind("mousemove",H);e(document).mousemove(ac).one("mouseup",function(){ad.onSelectEnd(Q,ar());e(document).unbind("mousemove",ac);B.mousemove(H)})}else{M.mousedown(h)}}return false}function L(h){if(aE){if(h){C=a(T,d(T+S,D+b(l-n)*aE*(C>D||-1)));l=c(a(ao,d(ao+aA,n+b(C-D)/aE*(l>n||-1))));C=c(C)}else{l=a(ao,d(ao+aA,n+b(C-D)/aE*(l>n||-1)));C=c(a(T,d(T+S,D+b(l-n)*aE*(C>D||-1))));l=c(l)}}}function aB(){D=d(D,T+S);n=d(n,ao+aA);if(b(C-D)T+S){D=T+S-q}}}if(b(l-n)ao+aA){n=ao+aA-al}}}C=a(T,d(C,T+S));l=a(ao,d(l,ao+aA));L(b(C-D)k){C=D-k*(Cx){l=n-x*(l=0){ax.width(5).height(5)}if(N=ad.borderWidth){ax.css({borderWidth:N,borderStyle:"solid"})}G(ax,{borderColor1:"border-color",borderColor2:"background-color",borderOpacity:"opacity"})}ab=ad.imageWidth/S||1;aa=ad.imageHeight/aA||1;if(h.x1!=null){aq(h.x1,h.y1,h.x2,h.y2);h.show=!h.hide}if(h.keys){ad.keys=e.extend({shift:1,ctrl:"resize"},h.keys)}v.addClass(ad.classPrefix+"-outer");E.addClass(ad.classPrefix+"-selection");for(O=0;O++<4;){e(ap[O-1]).addClass(ad.classPrefix+"-border"+O)}G(E,{selectionColor:"background-color",selectionOpacity:"opacity"});G(ap,{borderOpacity:"opacity",borderWidth:"border-width"});G(v,{outerColor:"background-color",outerOpacity:"opacity"});if(N=ad.borderColor1){e(ap[0]).css({borderStyle:"solid",borderColor:N})}if(N=ad.borderColor2){e(ap[1]).css({borderStyle:"dashed",borderColor:N})}B.append(E.add(ap).add(aj).add(ax));if(e.browser.msie){if(N=v.css("filter").match(/opacity=([0-9]+)/)){v.css("opacity",N[1]/100)}if(N=ap.css("filter").match(/opacity=([0-9]+)/)){ap.css("opacity",N[1]/100)}}if(h.hide){ag(B.add(v))}else{if(h.show&&u){ah=true;B.add(v).fadeIn(ad.fadeSpeed||0);y()}}aE=(R=(ad.aspectRatio||"").split(/:/))[0]/R[1];M.add(v).unbind("mousedown",aD);if(ad.disable||ad.enable===false){B.unbind("mousemove",H).unbind("mousedown",aw);e(window).unbind("resize",ai)}else{if(ad.enable||ad.disable===false){if(ad.resizable||ad.movable){B.mousemove(H).mousedown(aw)}e(window).resize(ai)}if(!ad.persistent){M.add(v).mousedown(aD)}}ad.enable=ad.disable=undefined}this.remove=function(){af({disable:true});B.add(v).remove()};this.getOptions=function(){return ad};this.setOptions=af;this.getSelection=ar;this.setSelection=aq;this.update=y;Z=M;while(Z.length){g=a(g,!isNaN(Z.css("z-index"))?Z.css("z-index"):g);if(Z.css("position")=="fixed"){ak="fixed"}Z=Z.parent(":not(body)")}g=ad.zIndex||g;if(e.browser.msie){M.attr("unselectable","on")}e.imgAreaSelect.keyPress=e.browser.msie||e.browser.safari?"keydown":"keypress";if(e.browser.opera){aj=f().css({width:"100%",height:"100%",position:"absolute",zIndex:g+2||2})}B.add(v).css({visibility:"hidden",position:ak,overflow:"hidden",zIndex:g||"0"});B.css({zIndex:g+2||2});E.add(ap).css({position:"absolute",fontSize:0});Q.complete||Q.readyState=="complete"||!M.is("img")?s():M.one("load",s);if(e.browser.msie&&e.browser.version>=9){Q.src=Q.src}};e.fn.imgAreaSelect=function(g){g=g||{};this.each(function(){if(e(this).data("imgAreaSelect")){if(g.remove){e(this).data("imgAreaSelect").remove();e(this).removeData("imgAreaSelect")}else{e(this).data("imgAreaSelect").setOptions(g)}}else{if(!g.remove){if(g.enable===undefined&&g.disable===undefined){g.enable=true}e(this).data("imgAreaSelect",new e.imgAreaSelect(this,g))}}});if(g.instance){return e(this).data("imgAreaSelect")}return this}})(jQuery); \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 24bee69913..ef8c08c31c 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -250,7 +250,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", false, '2011-02-23'); - $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.1-20110113' ); + $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.6-20110515' ); $scripts->add_data( 'imgareaselect', 'group', 1 ); $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20101027' );