Edit File by line
/home/barbar84/www/wp-inclu.../js/imgareas...
File: jquery.imgareaselect.js
}
[1000] Fix | Delete
[1001] Fix | Delete
if (newOptions.hide)
[1002] Fix | Delete
hide($box.add($outer));
[1003] Fix | Delete
else if (newOptions.show && imgLoaded) {
[1004] Fix | Delete
shown = true;
[1005] Fix | Delete
$box.add($outer).fadeIn(options.fadeSpeed||0);
[1006] Fix | Delete
doUpdate();
[1007] Fix | Delete
}
[1008] Fix | Delete
[1009] Fix | Delete
/* Calculate the aspect ratio factor */
[1010] Fix | Delete
aspectRatio = (d = (options.aspectRatio || '').split(/:/))[0] / d[1];
[1011] Fix | Delete
[1012] Fix | Delete
$img.add($outer).off('mousedown', imgMouseDown);
[1013] Fix | Delete
[1014] Fix | Delete
if (options.disable || options.enable === false) {
[1015] Fix | Delete
/* Disable the plugin */
[1016] Fix | Delete
$box.off({ 'mousemove touchmove': areaMouseMove,
[1017] Fix | Delete
'mousedown touchstart': areaMouseDown });
[1018] Fix | Delete
$(window).off('resize', windowResize);
[1019] Fix | Delete
}
[1020] Fix | Delete
else {
[1021] Fix | Delete
if (options.enable || options.disable === false) {
[1022] Fix | Delete
/* Enable the plugin */
[1023] Fix | Delete
if (options.resizable || options.movable)
[1024] Fix | Delete
$box.on({ 'mousemove touchmove': areaMouseMove,
[1025] Fix | Delete
'mousedown touchstart': areaMouseDown });
[1026] Fix | Delete
[1027] Fix | Delete
$(window).on( 'resize', windowResize);
[1028] Fix | Delete
}
[1029] Fix | Delete
[1030] Fix | Delete
if (!options.persistent)
[1031] Fix | Delete
$img.add($outer).on('mousedown touchstart', imgMouseDown);
[1032] Fix | Delete
}
[1033] Fix | Delete
[1034] Fix | Delete
options.enable = options.disable = undefined;
[1035] Fix | Delete
}
[1036] Fix | Delete
[1037] Fix | Delete
/**
[1038] Fix | Delete
* Remove plugin completely
[1039] Fix | Delete
*/
[1040] Fix | Delete
this.remove = function () {
[1041] Fix | Delete
/*
[1042] Fix | Delete
* Call setOptions with { disable: true } to unbind the event handlers
[1043] Fix | Delete
*/
[1044] Fix | Delete
setOptions({ disable: true });
[1045] Fix | Delete
$box.add($outer).remove();
[1046] Fix | Delete
};
[1047] Fix | Delete
[1048] Fix | Delete
/*
[1049] Fix | Delete
* Public API
[1050] Fix | Delete
*/
[1051] Fix | Delete
[1052] Fix | Delete
/**
[1053] Fix | Delete
* Get current options
[1054] Fix | Delete
*
[1055] Fix | Delete
* @return An object containing the set of options currently in use
[1056] Fix | Delete
*/
[1057] Fix | Delete
this.getOptions = function () { return options; };
[1058] Fix | Delete
[1059] Fix | Delete
/**
[1060] Fix | Delete
* Set plugin options
[1061] Fix | Delete
*
[1062] Fix | Delete
* @param newOptions
[1063] Fix | Delete
* The new options object
[1064] Fix | Delete
*/
[1065] Fix | Delete
this.setOptions = setOptions;
[1066] Fix | Delete
[1067] Fix | Delete
/**
[1068] Fix | Delete
* Get the current selection
[1069] Fix | Delete
*
[1070] Fix | Delete
* @param noScale
[1071] Fix | Delete
* If set to <code>true</code>, scaling is not applied to the
[1072] Fix | Delete
* returned selection
[1073] Fix | Delete
* @return Selection object
[1074] Fix | Delete
*/
[1075] Fix | Delete
this.getSelection = getSelection;
[1076] Fix | Delete
[1077] Fix | Delete
/**
[1078] Fix | Delete
* Set the current selection
[1079] Fix | Delete
*
[1080] Fix | Delete
* @param x1
[1081] Fix | Delete
* X coordinate of the upper left corner of the selection area
[1082] Fix | Delete
* @param y1
[1083] Fix | Delete
* Y coordinate of the upper left corner of the selection area
[1084] Fix | Delete
* @param x2
[1085] Fix | Delete
* X coordinate of the lower right corner of the selection area
[1086] Fix | Delete
* @param y2
[1087] Fix | Delete
* Y coordinate of the lower right corner of the selection area
[1088] Fix | Delete
* @param noScale
[1089] Fix | Delete
* If set to <code>true</code>, scaling is not applied to the
[1090] Fix | Delete
* new selection
[1091] Fix | Delete
*/
[1092] Fix | Delete
this.setSelection = setSelection;
[1093] Fix | Delete
[1094] Fix | Delete
/**
[1095] Fix | Delete
* Cancel selection
[1096] Fix | Delete
*/
[1097] Fix | Delete
this.cancelSelection = cancelSelection;
[1098] Fix | Delete
[1099] Fix | Delete
/**
[1100] Fix | Delete
* Update plugin elements
[1101] Fix | Delete
*
[1102] Fix | Delete
* @param resetKeyPress
[1103] Fix | Delete
* If set to <code>false</code>, this instance's keypress
[1104] Fix | Delete
* event handler is not activated
[1105] Fix | Delete
*/
[1106] Fix | Delete
this.update = doUpdate;
[1107] Fix | Delete
[1108] Fix | Delete
/* Do the dreaded browser detection */
[1109] Fix | Delete
var msie = (/msie ([\w.]+)/i.exec(ua)||[])[1],
[1110] Fix | Delete
opera = /opera/i.test(ua),
[1111] Fix | Delete
safari = /webkit/i.test(ua) && !/chrome/i.test(ua);
[1112] Fix | Delete
[1113] Fix | Delete
/*
[1114] Fix | Delete
* Traverse the image's parent elements (up to <body>) and find the
[1115] Fix | Delete
* highest z-index
[1116] Fix | Delete
*/
[1117] Fix | Delete
$p = $img;
[1118] Fix | Delete
[1119] Fix | Delete
while ($p.length) {
[1120] Fix | Delete
zIndex = max(zIndex,
[1121] Fix | Delete
!isNaN($p.css('z-index')) ? $p.css('z-index') : zIndex);
[1122] Fix | Delete
/* Also check if any of the ancestor elements has fixed position */
[1123] Fix | Delete
if ($p.css('position') == 'fixed')
[1124] Fix | Delete
position = 'fixed';
[1125] Fix | Delete
[1126] Fix | Delete
$p = $p.parent(':not(body)');
[1127] Fix | Delete
}
[1128] Fix | Delete
[1129] Fix | Delete
/*
[1130] Fix | Delete
* If z-index is given as an option, it overrides the one found by the
[1131] Fix | Delete
* above loop
[1132] Fix | Delete
*/
[1133] Fix | Delete
zIndex = options.zIndex || zIndex;
[1134] Fix | Delete
[1135] Fix | Delete
if (msie)
[1136] Fix | Delete
$img.attr('unselectable', 'on');
[1137] Fix | Delete
[1138] Fix | Delete
/*
[1139] Fix | Delete
* In MSIE and WebKit, we need to use the keydown event instead of keypress
[1140] Fix | Delete
*/
[1141] Fix | Delete
$.imgAreaSelect.keyPress = msie || safari ? 'keydown' : 'keypress';
[1142] Fix | Delete
[1143] Fix | Delete
/*
[1144] Fix | Delete
* There is a bug affecting the CSS cursor property in Opera (observed in
[1145] Fix | Delete
* versions up to 10.00) that prevents the cursor from being updated unless
[1146] Fix | Delete
* the mouse leaves and enters the element again. To trigger the mouseover
[1147] Fix | Delete
* event, we're adding an additional div to $box and we're going to toggle
[1148] Fix | Delete
* it when mouse moves inside the selection area.
[1149] Fix | Delete
*/
[1150] Fix | Delete
if (opera)
[1151] Fix | Delete
$areaOpera = div().css({ width: '100%', height: '100%',
[1152] Fix | Delete
position: 'absolute', zIndex: zIndex + 2 || 2 });
[1153] Fix | Delete
[1154] Fix | Delete
/*
[1155] Fix | Delete
* We initially set visibility to "hidden" as a workaround for a weird
[1156] Fix | Delete
* behaviour observed in Google Chrome 1.0.154.53 (on Windows XP). Normally
[1157] Fix | Delete
* we would just set display to "none", but, for some reason, if we do so
[1158] Fix | Delete
* then Chrome refuses to later display the element with .show() or
[1159] Fix | Delete
* .fadeIn().
[1160] Fix | Delete
*/
[1161] Fix | Delete
$box.add($outer).css({ visibility: 'hidden', position: position,
[1162] Fix | Delete
overflow: 'hidden', zIndex: zIndex || '0' });
[1163] Fix | Delete
$box.css({ zIndex: zIndex + 2 || 2 });
[1164] Fix | Delete
$area.add($border).css({ position: 'absolute', fontSize: '0' });
[1165] Fix | Delete
[1166] Fix | Delete
/*
[1167] Fix | Delete
* If the image has been fully loaded, or if it is not really an image (eg.
[1168] Fix | Delete
* a div), call imgLoad() immediately; otherwise, bind it to be called once
[1169] Fix | Delete
* on image load event.
[1170] Fix | Delete
*/
[1171] Fix | Delete
img.complete || img.readyState == 'complete' || !$img.is('img') ?
[1172] Fix | Delete
imgLoad() : $img.one('load', imgLoad);
[1173] Fix | Delete
[1174] Fix | Delete
/*
[1175] Fix | Delete
* MSIE 9.0 doesn't always fire the image load event -- resetting the src
[1176] Fix | Delete
* attribute seems to trigger it. The check is for version 7 and above to
[1177] Fix | Delete
* accommodate for MSIE 9 running in compatibility mode.
[1178] Fix | Delete
*/
[1179] Fix | Delete
if (!imgLoaded && msie && msie >= 7)
[1180] Fix | Delete
img.src = img.src;
[1181] Fix | Delete
};
[1182] Fix | Delete
[1183] Fix | Delete
/**
[1184] Fix | Delete
* Invoke imgAreaSelect on a jQuery object containing the image(s)
[1185] Fix | Delete
*
[1186] Fix | Delete
* @param options
[1187] Fix | Delete
* Options object
[1188] Fix | Delete
* @return The jQuery object or a reference to imgAreaSelect instance (if the
[1189] Fix | Delete
* <code>instance</code> option was specified)
[1190] Fix | Delete
*/
[1191] Fix | Delete
$.fn.imgAreaSelect = function (options) {
[1192] Fix | Delete
options = options || {};
[1193] Fix | Delete
[1194] Fix | Delete
this.each(function () {
[1195] Fix | Delete
/* Is there already an imgAreaSelect instance bound to this element? */
[1196] Fix | Delete
if ($(this).data('imgAreaSelect')) {
[1197] Fix | Delete
/* Yes there is -- is it supposed to be removed? */
[1198] Fix | Delete
if (options.remove) {
[1199] Fix | Delete
/* Remove the plugin */
[1200] Fix | Delete
$(this).data('imgAreaSelect').remove();
[1201] Fix | Delete
$(this).removeData('imgAreaSelect');
[1202] Fix | Delete
}
[1203] Fix | Delete
else
[1204] Fix | Delete
/* Reset options */
[1205] Fix | Delete
$(this).data('imgAreaSelect').setOptions(options);
[1206] Fix | Delete
}
[1207] Fix | Delete
else if (!options.remove) {
[1208] Fix | Delete
/* No exising instance -- create a new one */
[1209] Fix | Delete
[1210] Fix | Delete
/*
[1211] Fix | Delete
* If neither the "enable" nor the "disable" option is present, add
[1212] Fix | Delete
* "enable" as the default
[1213] Fix | Delete
*/
[1214] Fix | Delete
if (options.enable === undefined && options.disable === undefined)
[1215] Fix | Delete
options.enable = true;
[1216] Fix | Delete
[1217] Fix | Delete
$(this).data('imgAreaSelect', new $.imgAreaSelect(this, options));
[1218] Fix | Delete
}
[1219] Fix | Delete
});
[1220] Fix | Delete
[1221] Fix | Delete
if (options.instance)
[1222] Fix | Delete
/*
[1223] Fix | Delete
* Return the imgAreaSelect instance bound to the first element in the
[1224] Fix | Delete
* set
[1225] Fix | Delete
*/
[1226] Fix | Delete
return $(this).data('imgAreaSelect');
[1227] Fix | Delete
[1228] Fix | Delete
return this;
[1229] Fix | Delete
};
[1230] Fix | Delete
[1231] Fix | Delete
})(jQuery);
[1232] Fix | Delete
[1233] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function