X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/6c8f14c09105d0afa4c1574215c59b5021040e76..7f1521bf193b382565eb753043c161f4cb3fcda7:/wp-includes/js/imgareaselect/jquery.imgareaselect.js diff --git a/wp-includes/js/imgareaselect/jquery.imgareaselect.js b/wp-includes/js/imgareaselect/jquery.imgareaselect.js index 28860461..cb4b923d 100644 --- a/wp-includes/js/imgareaselect/jquery.imgareaselect.js +++ b/wp-includes/js/imgareaselect/jquery.imgareaselect.js @@ -1,8 +1,8 @@ /* * imgAreaSelect jQuery plugin - * version 0.9.9 + * version 0.9.10 * - * Copyright (c) 2008-2011 Michal Wojciechowski (odyniec.net) + * Copyright (c) 2008-2013 Michal Wojciechowski (odyniec.net) * * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. @@ -117,6 +117,9 @@ $.imgAreaSelect = function (img, options) { /* Document element */ docElem = document.documentElement, + /* User agent */ + ua = navigator.userAgent, + /* Various helper variables used throughout the code */ $p, d, i, o, w, h, adjusted; @@ -253,11 +256,11 @@ $.imgAreaSelect = function (img, options) { */ function adjust() { /* - * Do not adjust if image width is not a positive number. This might - * happen when imgAreaSelect is put on a parent element which is then - * hidden. + * Do not adjust if image has not yet loaded or if width is not a + * positive number. The latter might happen when imgAreaSelect is put + * on a parent element which is then hidden. */ - if (!$img.width()) + if (!imgLoaded || !$img.width()) return; /* @@ -368,7 +371,7 @@ $.imgAreaSelect = function (img, options) { * Need to reset the document keypress event handler -- unbind the * current handler */ - if ($.imgAreaSelect.keyPress != docKeyPress) + if ($.imgAreaSelect.onKeyPress != docKeyPress) $(document).unbind($.imgAreaSelect.keyPress, $.imgAreaSelect.onKeyPress); @@ -393,7 +396,7 @@ $.imgAreaSelect = function (img, options) { * borderOpacity, borderColor1, and borderColor2 options (which are now * deprecated). Borders created with GIF background images are fine. */ - if ($.browser.msie && $border.outerWidth() - $border.innerWidth() == 2) { + if (msie && $border.outerWidth() - $border.innerWidth() == 2) { $border.css('margin', 0); setTimeout(function () { $border.css('margin', 'auto'); }, 0); } @@ -962,12 +965,12 @@ $.imgAreaSelect = function (img, options) { $($border[1]).css({ borderStyle: 'dashed', borderColor: o }); /* Append all the selection area elements to the container box */ - $box.append($area.add($border).add($areaOpera).add($handles)); + $box.append($area.add($border).add($areaOpera)).append($handles); - if ($.browser.msie) { - if (o = $outer.css('filter').match(/opacity=(\d+)/)) + if (msie) { + if (o = ($outer.css('filter')||'').match(/opacity=(\d+)/)) $outer.css('opacity', o[1]/100); - if (o = $border.css('filter').match(/opacity=(\d+)/)) + if (o = ($border.css('filter')||'').match(/opacity=(\d+)/)) $border.css('opacity', o[1]/100); } @@ -1076,6 +1079,11 @@ $.imgAreaSelect = function (img, options) { */ this.update = doUpdate; + /* Do the dreaded browser detection */ + var msie = (/msie ([\w.]+)/i.exec(ua)||[])[1], + opera = /opera/i.test(ua), + safari = /webkit/i.test(ua) && !/chrome/i.test(ua); + /* * Traverse the image's parent elements (up to ) and find the * highest z-index @@ -1098,14 +1106,13 @@ $.imgAreaSelect = function (img, options) { */ zIndex = options.zIndex || zIndex; - if ($.browser.msie) + if (msie) $img.attr('unselectable', 'on'); /* * In MSIE and WebKit, we need to use the keydown event instead of keypress */ - $.imgAreaSelect.keyPress = $.browser.msie || - $.browser.safari ? 'keydown' : 'keypress'; + $.imgAreaSelect.keyPress = msie || safari ? 'keydown' : 'keypress'; /* * There is a bug affecting the CSS cursor property in Opera (observed in @@ -1114,7 +1121,7 @@ $.imgAreaSelect = function (img, options) { * event, we're adding an additional div to $box and we're going to toggle * it when mouse moves inside the selection area. */ - if ($.browser.opera) + if (opera) $areaOpera = div().css({ width: '100%', height: '100%', position: 'absolute', zIndex: zIndex + 2 || 2 }); @@ -1143,7 +1150,7 @@ $.imgAreaSelect = function (img, options) { * attribute seems to trigger it. The check is for version 7 and above to * accommodate for MSIE 9 running in compatibility mode. */ - if (!imgLoaded && $.browser.msie && $.browser.version >= 7) + if (!imgLoaded && msie && msie >= 7) img.src = img.src; };