978 _mouseDrag: function(/* event */) {}, |
1039 _mouseDrag: function(/* event */) {}, |
979 _mouseStop: function(/* event */) {}, |
1040 _mouseStop: function(/* event */) {}, |
980 _mouseCapture: function(/* event */) { return true; } |
1041 _mouseCapture: function(/* event */) { return true; } |
981 }); |
1042 }); |
982 |
1043 |
983 })(jQuery); |
|
984 |
|
985 (function( $, undefined ) { |
|
986 |
|
987 $.widget("ui.draggable", $.ui.mouse, { |
|
988 version: "1.10.3", |
|
989 widgetEventPrefix: "drag", |
|
990 options: { |
|
991 addClasses: true, |
|
992 appendTo: "parent", |
|
993 axis: false, |
|
994 connectToSortable: false, |
|
995 containment: false, |
|
996 cursor: "auto", |
|
997 cursorAt: false, |
|
998 grid: false, |
|
999 handle: false, |
|
1000 helper: "original", |
|
1001 iframeFix: false, |
|
1002 opacity: false, |
|
1003 refreshPositions: false, |
|
1004 revert: false, |
|
1005 revertDuration: 500, |
|
1006 scope: "default", |
|
1007 scroll: true, |
|
1008 scrollSensitivity: 20, |
|
1009 scrollSpeed: 20, |
|
1010 snap: false, |
|
1011 snapMode: "both", |
|
1012 snapTolerance: 20, |
|
1013 stack: false, |
|
1014 zIndex: false, |
|
1015 |
|
1016 // callbacks |
|
1017 drag: null, |
|
1018 start: null, |
|
1019 stop: null |
|
1020 }, |
|
1021 _create: function() { |
|
1022 |
|
1023 if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) { |
|
1024 this.element[0].style.position = "relative"; |
|
1025 } |
|
1026 if (this.options.addClasses){ |
|
1027 this.element.addClass("ui-draggable"); |
|
1028 } |
|
1029 if (this.options.disabled){ |
|
1030 this.element.addClass("ui-draggable-disabled"); |
|
1031 } |
|
1032 |
|
1033 this._mouseInit(); |
|
1034 |
|
1035 }, |
|
1036 |
|
1037 _destroy: function() { |
|
1038 this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ); |
|
1039 this._mouseDestroy(); |
|
1040 }, |
|
1041 |
|
1042 _mouseCapture: function(event) { |
|
1043 |
|
1044 var o = this.options; |
|
1045 |
|
1046 // among others, prevent a drag on a resizable-handle |
|
1047 if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) { |
|
1048 return false; |
|
1049 } |
|
1050 |
|
1051 //Quit if we're not on a valid handle |
|
1052 this.handle = this._getHandle(event); |
|
1053 if (!this.handle) { |
|
1054 return false; |
|
1055 } |
|
1056 |
|
1057 $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { |
|
1058 $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>") |
|
1059 .css({ |
|
1060 width: this.offsetWidth+"px", height: this.offsetHeight+"px", |
|
1061 position: "absolute", opacity: "0.001", zIndex: 1000 |
|
1062 }) |
|
1063 .css($(this).offset()) |
|
1064 .appendTo("body"); |
|
1065 }); |
|
1066 |
|
1067 return true; |
|
1068 |
|
1069 }, |
|
1070 |
|
1071 _mouseStart: function(event) { |
|
1072 |
|
1073 var o = this.options; |
|
1074 |
|
1075 //Create and append the visible helper |
|
1076 this.helper = this._createHelper(event); |
|
1077 |
|
1078 this.helper.addClass("ui-draggable-dragging"); |
|
1079 |
|
1080 //Cache the helper size |
|
1081 this._cacheHelperProportions(); |
|
1082 |
|
1083 //If ddmanager is used for droppables, set the global draggable |
|
1084 if($.ui.ddmanager) { |
|
1085 $.ui.ddmanager.current = this; |
|
1086 } |
|
1087 |
|
1088 /* |
|
1089 * - Position generation - |
|
1090 * This block generates everything position related - it's the core of draggables. |
|
1091 */ |
|
1092 |
|
1093 //Cache the margins of the original element |
|
1094 this._cacheMargins(); |
|
1095 |
|
1096 //Store the helper's css position |
|
1097 this.cssPosition = this.helper.css( "position" ); |
|
1098 this.scrollParent = this.helper.scrollParent(); |
|
1099 this.offsetParent = this.helper.offsetParent(); |
|
1100 this.offsetParentCssPosition = this.offsetParent.css( "position" ); |
|
1101 |
|
1102 //The element's absolute position on the page minus margins |
|
1103 this.offset = this.positionAbs = this.element.offset(); |
|
1104 this.offset = { |
|
1105 top: this.offset.top - this.margins.top, |
|
1106 left: this.offset.left - this.margins.left |
|
1107 }; |
|
1108 |
|
1109 //Reset scroll cache |
|
1110 this.offset.scroll = false; |
|
1111 |
|
1112 $.extend(this.offset, { |
|
1113 click: { //Where the click happened, relative to the element |
|
1114 left: event.pageX - this.offset.left, |
|
1115 top: event.pageY - this.offset.top |
|
1116 }, |
|
1117 parent: this._getParentOffset(), |
|
1118 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper |
|
1119 }); |
|
1120 |
|
1121 //Generate the original position |
|
1122 this.originalPosition = this.position = this._generatePosition(event); |
|
1123 this.originalPageX = event.pageX; |
|
1124 this.originalPageY = event.pageY; |
|
1125 |
|
1126 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied |
|
1127 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); |
|
1128 |
|
1129 //Set a containment if given in the options |
|
1130 this._setContainment(); |
|
1131 |
|
1132 //Trigger event + callbacks |
|
1133 if(this._trigger("start", event) === false) { |
|
1134 this._clear(); |
|
1135 return false; |
|
1136 } |
|
1137 |
|
1138 //Recache the helper size |
|
1139 this._cacheHelperProportions(); |
|
1140 |
|
1141 //Prepare the droppable offsets |
|
1142 if ($.ui.ddmanager && !o.dropBehaviour) { |
|
1143 $.ui.ddmanager.prepareOffsets(this, event); |
|
1144 } |
|
1145 |
|
1146 |
|
1147 this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
|
1148 |
|
1149 //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) |
|
1150 if ( $.ui.ddmanager ) { |
|
1151 $.ui.ddmanager.dragStart(this, event); |
|
1152 } |
|
1153 |
|
1154 return true; |
|
1155 }, |
|
1156 |
|
1157 _mouseDrag: function(event, noPropagation) { |
|
1158 // reset any necessary cached properties (see #5009) |
|
1159 if ( this.offsetParentCssPosition === "fixed" ) { |
|
1160 this.offset.parent = this._getParentOffset(); |
|
1161 } |
|
1162 |
|
1163 //Compute the helpers position |
|
1164 this.position = this._generatePosition(event); |
|
1165 this.positionAbs = this._convertPositionTo("absolute"); |
|
1166 |
|
1167 //Call plugins and callbacks and use the resulting position if something is returned |
|
1168 if (!noPropagation) { |
|
1169 var ui = this._uiHash(); |
|
1170 if(this._trigger("drag", event, ui) === false) { |
|
1171 this._mouseUp({}); |
|
1172 return false; |
|
1173 } |
|
1174 this.position = ui.position; |
|
1175 } |
|
1176 |
|
1177 if(!this.options.axis || this.options.axis !== "y") { |
|
1178 this.helper[0].style.left = this.position.left+"px"; |
|
1179 } |
|
1180 if(!this.options.axis || this.options.axis !== "x") { |
|
1181 this.helper[0].style.top = this.position.top+"px"; |
|
1182 } |
|
1183 if($.ui.ddmanager) { |
|
1184 $.ui.ddmanager.drag(this, event); |
|
1185 } |
|
1186 |
|
1187 return false; |
|
1188 }, |
|
1189 |
|
1190 _mouseStop: function(event) { |
|
1191 |
|
1192 //If we are using droppables, inform the manager about the drop |
|
1193 var that = this, |
|
1194 dropped = false; |
|
1195 if ($.ui.ddmanager && !this.options.dropBehaviour) { |
|
1196 dropped = $.ui.ddmanager.drop(this, event); |
|
1197 } |
|
1198 |
|
1199 //if a drop comes from outside (a sortable) |
|
1200 if(this.dropped) { |
|
1201 dropped = this.dropped; |
|
1202 this.dropped = false; |
|
1203 } |
|
1204 |
|
1205 //if the original element is no longer in the DOM don't bother to continue (see #8269) |
|
1206 if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) { |
|
1207 return false; |
|
1208 } |
|
1209 |
|
1210 if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { |
|
1211 $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { |
|
1212 if(that._trigger("stop", event) !== false) { |
|
1213 that._clear(); |
|
1214 } |
|
1215 }); |
|
1216 } else { |
|
1217 if(this._trigger("stop", event) !== false) { |
|
1218 this._clear(); |
|
1219 } |
|
1220 } |
|
1221 |
|
1222 return false; |
|
1223 }, |
|
1224 |
|
1225 _mouseUp: function(event) { |
|
1226 //Remove frame helpers |
|
1227 $("div.ui-draggable-iframeFix").each(function() { |
|
1228 this.parentNode.removeChild(this); |
|
1229 }); |
|
1230 |
|
1231 //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) |
|
1232 if( $.ui.ddmanager ) { |
|
1233 $.ui.ddmanager.dragStop(this, event); |
|
1234 } |
|
1235 |
|
1236 return $.ui.mouse.prototype._mouseUp.call(this, event); |
|
1237 }, |
|
1238 |
|
1239 cancel: function() { |
|
1240 |
|
1241 if(this.helper.is(".ui-draggable-dragging")) { |
|
1242 this._mouseUp({}); |
|
1243 } else { |
|
1244 this._clear(); |
|
1245 } |
|
1246 |
|
1247 return this; |
|
1248 |
|
1249 }, |
|
1250 |
|
1251 _getHandle: function(event) { |
|
1252 return this.options.handle ? |
|
1253 !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : |
|
1254 true; |
|
1255 }, |
|
1256 |
|
1257 _createHelper: function(event) { |
|
1258 |
|
1259 var o = this.options, |
|
1260 helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element); |
|
1261 |
|
1262 if(!helper.parents("body").length) { |
|
1263 helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo)); |
|
1264 } |
|
1265 |
|
1266 if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) { |
|
1267 helper.css("position", "absolute"); |
|
1268 } |
|
1269 |
|
1270 return helper; |
|
1271 |
|
1272 }, |
|
1273 |
|
1274 _adjustOffsetFromHelper: function(obj) { |
|
1275 if (typeof obj === "string") { |
|
1276 obj = obj.split(" "); |
|
1277 } |
|
1278 if ($.isArray(obj)) { |
|
1279 obj = {left: +obj[0], top: +obj[1] || 0}; |
|
1280 } |
|
1281 if ("left" in obj) { |
|
1282 this.offset.click.left = obj.left + this.margins.left; |
|
1283 } |
|
1284 if ("right" in obj) { |
|
1285 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
|
1286 } |
|
1287 if ("top" in obj) { |
|
1288 this.offset.click.top = obj.top + this.margins.top; |
|
1289 } |
|
1290 if ("bottom" in obj) { |
|
1291 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
|
1292 } |
|
1293 }, |
|
1294 |
|
1295 _getParentOffset: function() { |
|
1296 |
|
1297 //Get the offsetParent and cache its position |
|
1298 var po = this.offsetParent.offset(); |
|
1299 |
|
1300 // This is a special case where we need to modify a offset calculated on start, since the following happened: |
|
1301 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
|
1302 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
|
1303 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
|
1304 if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) { |
|
1305 po.left += this.scrollParent.scrollLeft(); |
|
1306 po.top += this.scrollParent.scrollTop(); |
|
1307 } |
|
1308 |
|
1309 //This needs to be actually done for all browsers, since pageX/pageY includes this information |
|
1310 //Ugly IE fix |
|
1311 if((this.offsetParent[0] === document.body) || |
|
1312 (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) { |
|
1313 po = { top: 0, left: 0 }; |
|
1314 } |
|
1315 |
|
1316 return { |
|
1317 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
|
1318 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
|
1319 }; |
|
1320 |
|
1321 }, |
|
1322 |
|
1323 _getRelativeOffset: function() { |
|
1324 |
|
1325 if(this.cssPosition === "relative") { |
|
1326 var p = this.element.position(); |
|
1327 return { |
|
1328 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
|
1329 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() |
|
1330 }; |
|
1331 } else { |
|
1332 return { top: 0, left: 0 }; |
|
1333 } |
|
1334 |
|
1335 }, |
|
1336 |
|
1337 _cacheMargins: function() { |
|
1338 this.margins = { |
|
1339 left: (parseInt(this.element.css("marginLeft"),10) || 0), |
|
1340 top: (parseInt(this.element.css("marginTop"),10) || 0), |
|
1341 right: (parseInt(this.element.css("marginRight"),10) || 0), |
|
1342 bottom: (parseInt(this.element.css("marginBottom"),10) || 0) |
|
1343 }; |
|
1344 }, |
|
1345 |
|
1346 _cacheHelperProportions: function() { |
|
1347 this.helperProportions = { |
|
1348 width: this.helper.outerWidth(), |
|
1349 height: this.helper.outerHeight() |
|
1350 }; |
|
1351 }, |
|
1352 |
|
1353 _setContainment: function() { |
|
1354 |
|
1355 var over, c, ce, |
|
1356 o = this.options; |
|
1357 |
|
1358 if ( !o.containment ) { |
|
1359 this.containment = null; |
|
1360 return; |
|
1361 } |
|
1362 |
|
1363 if ( o.containment === "window" ) { |
|
1364 this.containment = [ |
|
1365 $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left, |
|
1366 $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top, |
|
1367 $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left, |
|
1368 $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top |
|
1369 ]; |
|
1370 return; |
|
1371 } |
|
1372 |
|
1373 if ( o.containment === "document") { |
|
1374 this.containment = [ |
|
1375 0, |
|
1376 0, |
|
1377 $( document ).width() - this.helperProportions.width - this.margins.left, |
|
1378 ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top |
|
1379 ]; |
|
1380 return; |
|
1381 } |
|
1382 |
|
1383 if ( o.containment.constructor === Array ) { |
|
1384 this.containment = o.containment; |
|
1385 return; |
|
1386 } |
|
1387 |
|
1388 if ( o.containment === "parent" ) { |
|
1389 o.containment = this.helper[ 0 ].parentNode; |
|
1390 } |
|
1391 |
|
1392 c = $( o.containment ); |
|
1393 ce = c[ 0 ]; |
|
1394 |
|
1395 if( !ce ) { |
|
1396 return; |
|
1397 } |
|
1398 |
|
1399 over = c.css( "overflow" ) !== "hidden"; |
|
1400 |
|
1401 this.containment = [ |
|
1402 ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), |
|
1403 ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) , |
|
1404 ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right, |
|
1405 ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom |
|
1406 ]; |
|
1407 this.relative_container = c; |
|
1408 }, |
|
1409 |
|
1410 _convertPositionTo: function(d, pos) { |
|
1411 |
|
1412 if(!pos) { |
|
1413 pos = this.position; |
|
1414 } |
|
1415 |
|
1416 var mod = d === "absolute" ? 1 : -1, |
|
1417 scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent; |
|
1418 |
|
1419 //Cache the scroll |
|
1420 if (!this.offset.scroll) { |
|
1421 this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()}; |
|
1422 } |
|
1423 |
|
1424 return { |
|
1425 top: ( |
|
1426 pos.top + // The absolute mouse position |
|
1427 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent |
|
1428 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) |
|
1429 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod ) |
|
1430 ), |
|
1431 left: ( |
|
1432 pos.left + // The absolute mouse position |
|
1433 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent |
|
1434 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) |
|
1435 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod ) |
|
1436 ) |
|
1437 }; |
|
1438 |
|
1439 }, |
|
1440 |
|
1441 _generatePosition: function(event) { |
|
1442 |
|
1443 var containment, co, top, left, |
|
1444 o = this.options, |
|
1445 scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent, |
|
1446 pageX = event.pageX, |
|
1447 pageY = event.pageY; |
|
1448 |
|
1449 //Cache the scroll |
|
1450 if (!this.offset.scroll) { |
|
1451 this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()}; |
|
1452 } |
|
1453 |
|
1454 /* |
|
1455 * - Position constraining - |
|
1456 * Constrain the position to a mix of grid, containment. |
|
1457 */ |
|
1458 |
|
1459 // If we are not dragging yet, we won't check for options |
|
1460 if ( this.originalPosition ) { |
|
1461 if ( this.containment ) { |
|
1462 if ( this.relative_container ){ |
|
1463 co = this.relative_container.offset(); |
|
1464 containment = [ |
|
1465 this.containment[ 0 ] + co.left, |
|
1466 this.containment[ 1 ] + co.top, |
|
1467 this.containment[ 2 ] + co.left, |
|
1468 this.containment[ 3 ] + co.top |
|
1469 ]; |
|
1470 } |
|
1471 else { |
|
1472 containment = this.containment; |
|
1473 } |
|
1474 |
|
1475 if(event.pageX - this.offset.click.left < containment[0]) { |
|
1476 pageX = containment[0] + this.offset.click.left; |
|
1477 } |
|
1478 if(event.pageY - this.offset.click.top < containment[1]) { |
|
1479 pageY = containment[1] + this.offset.click.top; |
|
1480 } |
|
1481 if(event.pageX - this.offset.click.left > containment[2]) { |
|
1482 pageX = containment[2] + this.offset.click.left; |
|
1483 } |
|
1484 if(event.pageY - this.offset.click.top > containment[3]) { |
|
1485 pageY = containment[3] + this.offset.click.top; |
|
1486 } |
|
1487 } |
|
1488 |
|
1489 if(o.grid) { |
|
1490 //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) |
|
1491 top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY; |
|
1492 pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
1493 |
|
1494 left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX; |
|
1495 pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; |
|
1496 } |
|
1497 |
|
1498 } |
|
1499 |
|
1500 return { |
|
1501 top: ( |
|
1502 pageY - // The absolute mouse position |
|
1503 this.offset.click.top - // Click offset (relative to the element) |
|
1504 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent |
|
1505 this.offset.parent.top + // The offsetParent's offset without borders (offset + border) |
|
1506 ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) |
|
1507 ), |
|
1508 left: ( |
|
1509 pageX - // The absolute mouse position |
|
1510 this.offset.click.left - // Click offset (relative to the element) |
|
1511 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent |
|
1512 this.offset.parent.left + // The offsetParent's offset without borders (offset + border) |
|
1513 ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) |
|
1514 ) |
|
1515 }; |
|
1516 |
|
1517 }, |
|
1518 |
|
1519 _clear: function() { |
|
1520 this.helper.removeClass("ui-draggable-dragging"); |
|
1521 if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) { |
|
1522 this.helper.remove(); |
|
1523 } |
|
1524 this.helper = null; |
|
1525 this.cancelHelperRemoval = false; |
|
1526 }, |
|
1527 |
|
1528 // From now on bulk stuff - mainly helpers |
|
1529 |
|
1530 _trigger: function(type, event, ui) { |
|
1531 ui = ui || this._uiHash(); |
|
1532 $.ui.plugin.call(this, type, [event, ui]); |
|
1533 //The absolute position has to be recalculated after plugins |
|
1534 if(type === "drag") { |
|
1535 this.positionAbs = this._convertPositionTo("absolute"); |
|
1536 } |
|
1537 return $.Widget.prototype._trigger.call(this, type, event, ui); |
|
1538 }, |
|
1539 |
|
1540 plugins: {}, |
|
1541 |
|
1542 _uiHash: function() { |
|
1543 return { |
|
1544 helper: this.helper, |
|
1545 position: this.position, |
|
1546 originalPosition: this.originalPosition, |
|
1547 offset: this.positionAbs |
|
1548 }; |
|
1549 } |
|
1550 |
|
1551 }); |
|
1552 |
|
1553 $.ui.plugin.add("draggable", "connectToSortable", { |
|
1554 start: function(event, ui) { |
|
1555 |
|
1556 var inst = $(this).data("ui-draggable"), o = inst.options, |
|
1557 uiSortable = $.extend({}, ui, { item: inst.element }); |
|
1558 inst.sortables = []; |
|
1559 $(o.connectToSortable).each(function() { |
|
1560 var sortable = $.data(this, "ui-sortable"); |
|
1561 if (sortable && !sortable.options.disabled) { |
|
1562 inst.sortables.push({ |
|
1563 instance: sortable, |
|
1564 shouldRevert: sortable.options.revert |
|
1565 }); |
|
1566 sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page). |
|
1567 sortable._trigger("activate", event, uiSortable); |
|
1568 } |
|
1569 }); |
|
1570 |
|
1571 }, |
|
1572 stop: function(event, ui) { |
|
1573 |
|
1574 //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper |
|
1575 var inst = $(this).data("ui-draggable"), |
|
1576 uiSortable = $.extend({}, ui, { item: inst.element }); |
|
1577 |
|
1578 $.each(inst.sortables, function() { |
|
1579 if(this.instance.isOver) { |
|
1580 |
|
1581 this.instance.isOver = 0; |
|
1582 |
|
1583 inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance |
|
1584 this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) |
|
1585 |
|
1586 //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid" |
|
1587 if(this.shouldRevert) { |
|
1588 this.instance.options.revert = this.shouldRevert; |
|
1589 } |
|
1590 |
|
1591 //Trigger the stop of the sortable |
|
1592 this.instance._mouseStop(event); |
|
1593 |
|
1594 this.instance.options.helper = this.instance.options._helper; |
|
1595 |
|
1596 //If the helper has been the original item, restore properties in the sortable |
|
1597 if(inst.options.helper === "original") { |
|
1598 this.instance.currentItem.css({ top: "auto", left: "auto" }); |
|
1599 } |
|
1600 |
|
1601 } else { |
|
1602 this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance |
|
1603 this.instance._trigger("deactivate", event, uiSortable); |
|
1604 } |
|
1605 |
|
1606 }); |
|
1607 |
|
1608 }, |
|
1609 drag: function(event, ui) { |
|
1610 |
|
1611 var inst = $(this).data("ui-draggable"), that = this; |
|
1612 |
|
1613 $.each(inst.sortables, function() { |
|
1614 |
|
1615 var innermostIntersecting = false, |
|
1616 thisSortable = this; |
|
1617 |
|
1618 //Copy over some variables to allow calling the sortable's native _intersectsWith |
|
1619 this.instance.positionAbs = inst.positionAbs; |
|
1620 this.instance.helperProportions = inst.helperProportions; |
|
1621 this.instance.offset.click = inst.offset.click; |
|
1622 |
|
1623 if(this.instance._intersectsWith(this.instance.containerCache)) { |
|
1624 innermostIntersecting = true; |
|
1625 $.each(inst.sortables, function () { |
|
1626 this.instance.positionAbs = inst.positionAbs; |
|
1627 this.instance.helperProportions = inst.helperProportions; |
|
1628 this.instance.offset.click = inst.offset.click; |
|
1629 if (this !== thisSortable && |
|
1630 this.instance._intersectsWith(this.instance.containerCache) && |
|
1631 $.contains(thisSortable.instance.element[0], this.instance.element[0]) |
|
1632 ) { |
|
1633 innermostIntersecting = false; |
|
1634 } |
|
1635 return innermostIntersecting; |
|
1636 }); |
|
1637 } |
|
1638 |
|
1639 |
|
1640 if(innermostIntersecting) { |
|
1641 //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once |
|
1642 if(!this.instance.isOver) { |
|
1643 |
|
1644 this.instance.isOver = 1; |
|
1645 //Now we fake the start of dragging for the sortable instance, |
|
1646 //by cloning the list group item, appending it to the sortable and using it as inst.currentItem |
|
1647 //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one) |
|
1648 this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true); |
|
1649 this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it |
|
1650 this.instance.options.helper = function() { return ui.helper[0]; }; |
|
1651 |
|
1652 event.target = this.instance.currentItem[0]; |
|
1653 this.instance._mouseCapture(event, true); |
|
1654 this.instance._mouseStart(event, true, true); |
|
1655 |
|
1656 //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes |
|
1657 this.instance.offset.click.top = inst.offset.click.top; |
|
1658 this.instance.offset.click.left = inst.offset.click.left; |
|
1659 this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; |
|
1660 this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; |
|
1661 |
|
1662 inst._trigger("toSortable", event); |
|
1663 inst.dropped = this.instance.element; //draggable revert needs that |
|
1664 //hack so receive/update callbacks work (mostly) |
|
1665 inst.currentItem = inst.element; |
|
1666 this.instance.fromOutside = inst; |
|
1667 |
|
1668 } |
|
1669 |
|
1670 //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable |
|
1671 if(this.instance.currentItem) { |
|
1672 this.instance._mouseDrag(event); |
|
1673 } |
|
1674 |
|
1675 } else { |
|
1676 |
|
1677 //If it doesn't intersect with the sortable, and it intersected before, |
|
1678 //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval |
|
1679 if(this.instance.isOver) { |
|
1680 |
|
1681 this.instance.isOver = 0; |
|
1682 this.instance.cancelHelperRemoval = true; |
|
1683 |
|
1684 //Prevent reverting on this forced stop |
|
1685 this.instance.options.revert = false; |
|
1686 |
|
1687 // The out event needs to be triggered independently |
|
1688 this.instance._trigger("out", event, this.instance._uiHash(this.instance)); |
|
1689 |
|
1690 this.instance._mouseStop(event, true); |
|
1691 this.instance.options.helper = this.instance.options._helper; |
|
1692 |
|
1693 //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size |
|
1694 this.instance.currentItem.remove(); |
|
1695 if(this.instance.placeholder) { |
|
1696 this.instance.placeholder.remove(); |
|
1697 } |
|
1698 |
|
1699 inst._trigger("fromSortable", event); |
|
1700 inst.dropped = false; //draggable revert needs that |
|
1701 } |
|
1702 |
|
1703 } |
|
1704 |
|
1705 }); |
|
1706 |
|
1707 } |
|
1708 }); |
|
1709 |
|
1710 $.ui.plugin.add("draggable", "cursor", { |
|
1711 start: function() { |
|
1712 var t = $("body"), o = $(this).data("ui-draggable").options; |
|
1713 if (t.css("cursor")) { |
|
1714 o._cursor = t.css("cursor"); |
|
1715 } |
|
1716 t.css("cursor", o.cursor); |
|
1717 }, |
|
1718 stop: function() { |
|
1719 var o = $(this).data("ui-draggable").options; |
|
1720 if (o._cursor) { |
|
1721 $("body").css("cursor", o._cursor); |
|
1722 } |
|
1723 } |
|
1724 }); |
|
1725 |
|
1726 $.ui.plugin.add("draggable", "opacity", { |
|
1727 start: function(event, ui) { |
|
1728 var t = $(ui.helper), o = $(this).data("ui-draggable").options; |
|
1729 if(t.css("opacity")) { |
|
1730 o._opacity = t.css("opacity"); |
|
1731 } |
|
1732 t.css("opacity", o.opacity); |
|
1733 }, |
|
1734 stop: function(event, ui) { |
|
1735 var o = $(this).data("ui-draggable").options; |
|
1736 if(o._opacity) { |
|
1737 $(ui.helper).css("opacity", o._opacity); |
|
1738 } |
|
1739 } |
|
1740 }); |
|
1741 |
|
1742 $.ui.plugin.add("draggable", "scroll", { |
|
1743 start: function() { |
|
1744 var i = $(this).data("ui-draggable"); |
|
1745 if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") { |
|
1746 i.overflowOffset = i.scrollParent.offset(); |
|
1747 } |
|
1748 }, |
|
1749 drag: function( event ) { |
|
1750 |
|
1751 var i = $(this).data("ui-draggable"), o = i.options, scrolled = false; |
|
1752 |
|
1753 if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") { |
|
1754 |
|
1755 if(!o.axis || o.axis !== "x") { |
|
1756 if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) { |
|
1757 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed; |
|
1758 } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) { |
|
1759 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed; |
|
1760 } |
|
1761 } |
|
1762 |
|
1763 if(!o.axis || o.axis !== "y") { |
|
1764 if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) { |
|
1765 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed; |
|
1766 } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) { |
|
1767 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed; |
|
1768 } |
|
1769 } |
|
1770 |
|
1771 } else { |
|
1772 |
|
1773 if(!o.axis || o.axis !== "x") { |
|
1774 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) { |
|
1775 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
|
1776 } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) { |
|
1777 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
|
1778 } |
|
1779 } |
|
1780 |
|
1781 if(!o.axis || o.axis !== "y") { |
|
1782 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) { |
|
1783 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
|
1784 } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) { |
|
1785 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
|
1786 } |
|
1787 } |
|
1788 |
|
1789 } |
|
1790 |
|
1791 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { |
|
1792 $.ui.ddmanager.prepareOffsets(i, event); |
|
1793 } |
|
1794 |
|
1795 } |
|
1796 }); |
|
1797 |
|
1798 $.ui.plugin.add("draggable", "snap", { |
|
1799 start: function() { |
|
1800 |
|
1801 var i = $(this).data("ui-draggable"), |
|
1802 o = i.options; |
|
1803 |
|
1804 i.snapElements = []; |
|
1805 |
|
1806 $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() { |
|
1807 var $t = $(this), |
|
1808 $o = $t.offset(); |
|
1809 if(this !== i.element[0]) { |
|
1810 i.snapElements.push({ |
|
1811 item: this, |
|
1812 width: $t.outerWidth(), height: $t.outerHeight(), |
|
1813 top: $o.top, left: $o.left |
|
1814 }); |
|
1815 } |
|
1816 }); |
|
1817 |
|
1818 }, |
|
1819 drag: function(event, ui) { |
|
1820 |
|
1821 var ts, bs, ls, rs, l, r, t, b, i, first, |
|
1822 inst = $(this).data("ui-draggable"), |
|
1823 o = inst.options, |
|
1824 d = o.snapTolerance, |
|
1825 x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, |
|
1826 y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; |
|
1827 |
|
1828 for (i = inst.snapElements.length - 1; i >= 0; i--){ |
|
1829 |
|
1830 l = inst.snapElements[i].left; |
|
1831 r = l + inst.snapElements[i].width; |
|
1832 t = inst.snapElements[i].top; |
|
1833 b = t + inst.snapElements[i].height; |
|
1834 |
|
1835 if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) { |
|
1836 if(inst.snapElements[i].snapping) { |
|
1837 (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
1838 } |
|
1839 inst.snapElements[i].snapping = false; |
|
1840 continue; |
|
1841 } |
|
1842 |
|
1843 if(o.snapMode !== "inner") { |
|
1844 ts = Math.abs(t - y2) <= d; |
|
1845 bs = Math.abs(b - y1) <= d; |
|
1846 ls = Math.abs(l - x2) <= d; |
|
1847 rs = Math.abs(r - x1) <= d; |
|
1848 if(ts) { |
|
1849 ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
1850 } |
|
1851 if(bs) { |
|
1852 ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top; |
|
1853 } |
|
1854 if(ls) { |
|
1855 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left; |
|
1856 } |
|
1857 if(rs) { |
|
1858 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left; |
|
1859 } |
|
1860 } |
|
1861 |
|
1862 first = (ts || bs || ls || rs); |
|
1863 |
|
1864 if(o.snapMode !== "outer") { |
|
1865 ts = Math.abs(t - y1) <= d; |
|
1866 bs = Math.abs(b - y2) <= d; |
|
1867 ls = Math.abs(l - x1) <= d; |
|
1868 rs = Math.abs(r - x2) <= d; |
|
1869 if(ts) { |
|
1870 ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top; |
|
1871 } |
|
1872 if(bs) { |
|
1873 ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
1874 } |
|
1875 if(ls) { |
|
1876 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left; |
|
1877 } |
|
1878 if(rs) { |
|
1879 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left; |
|
1880 } |
|
1881 } |
|
1882 |
|
1883 if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) { |
|
1884 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
1885 } |
|
1886 inst.snapElements[i].snapping = (ts || bs || ls || rs || first); |
|
1887 |
|
1888 } |
|
1889 |
|
1890 } |
|
1891 }); |
|
1892 |
|
1893 $.ui.plugin.add("draggable", "stack", { |
|
1894 start: function() { |
|
1895 var min, |
|
1896 o = this.data("ui-draggable").options, |
|
1897 group = $.makeArray($(o.stack)).sort(function(a,b) { |
|
1898 return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); |
|
1899 }); |
|
1900 |
|
1901 if (!group.length) { return; } |
|
1902 |
|
1903 min = parseInt($(group[0]).css("zIndex"), 10) || 0; |
|
1904 $(group).each(function(i) { |
|
1905 $(this).css("zIndex", min + i); |
|
1906 }); |
|
1907 this.css("zIndex", (min + group.length)); |
|
1908 } |
|
1909 }); |
|
1910 |
|
1911 $.ui.plugin.add("draggable", "zIndex", { |
|
1912 start: function(event, ui) { |
|
1913 var t = $(ui.helper), o = $(this).data("ui-draggable").options; |
|
1914 if(t.css("zIndex")) { |
|
1915 o._zIndex = t.css("zIndex"); |
|
1916 } |
|
1917 t.css("zIndex", o.zIndex); |
|
1918 }, |
|
1919 stop: function(event, ui) { |
|
1920 var o = $(this).data("ui-draggable").options; |
|
1921 if(o._zIndex) { |
|
1922 $(ui.helper).css("zIndex", o._zIndex); |
|
1923 } |
|
1924 } |
|
1925 }); |
|
1926 |
|
1927 })(jQuery); |
|
1928 |
|
1929 (function( $, undefined ) { |
|
1930 |
|
1931 function isOverAxis( x, reference, size ) { |
|
1932 return ( x > reference ) && ( x < ( reference + size ) ); |
|
1933 } |
|
1934 |
|
1935 $.widget("ui.droppable", { |
|
1936 version: "1.10.3", |
|
1937 widgetEventPrefix: "drop", |
|
1938 options: { |
|
1939 accept: "*", |
|
1940 activeClass: false, |
|
1941 addClasses: true, |
|
1942 greedy: false, |
|
1943 hoverClass: false, |
|
1944 scope: "default", |
|
1945 tolerance: "intersect", |
|
1946 |
|
1947 // callbacks |
|
1948 activate: null, |
|
1949 deactivate: null, |
|
1950 drop: null, |
|
1951 out: null, |
|
1952 over: null |
|
1953 }, |
|
1954 _create: function() { |
|
1955 |
|
1956 var o = this.options, |
|
1957 accept = o.accept; |
|
1958 |
|
1959 this.isover = false; |
|
1960 this.isout = true; |
|
1961 |
|
1962 this.accept = $.isFunction(accept) ? accept : function(d) { |
|
1963 return d.is(accept); |
|
1964 }; |
|
1965 |
|
1966 //Store the droppable's proportions |
|
1967 this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight }; |
|
1968 |
|
1969 // Add the reference and positions to the manager |
|
1970 $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || []; |
|
1971 $.ui.ddmanager.droppables[o.scope].push(this); |
|
1972 |
|
1973 (o.addClasses && this.element.addClass("ui-droppable")); |
|
1974 |
|
1975 }, |
|
1976 |
|
1977 _destroy: function() { |
|
1978 var i = 0, |
|
1979 drop = $.ui.ddmanager.droppables[this.options.scope]; |
|
1980 |
|
1981 for ( ; i < drop.length; i++ ) { |
|
1982 if ( drop[i] === this ) { |
|
1983 drop.splice(i, 1); |
|
1984 } |
|
1985 } |
|
1986 |
|
1987 this.element.removeClass("ui-droppable ui-droppable-disabled"); |
|
1988 }, |
|
1989 |
|
1990 _setOption: function(key, value) { |
|
1991 |
|
1992 if(key === "accept") { |
|
1993 this.accept = $.isFunction(value) ? value : function(d) { |
|
1994 return d.is(value); |
|
1995 }; |
|
1996 } |
|
1997 $.Widget.prototype._setOption.apply(this, arguments); |
|
1998 }, |
|
1999 |
|
2000 _activate: function(event) { |
|
2001 var draggable = $.ui.ddmanager.current; |
|
2002 if(this.options.activeClass) { |
|
2003 this.element.addClass(this.options.activeClass); |
|
2004 } |
|
2005 if(draggable){ |
|
2006 this._trigger("activate", event, this.ui(draggable)); |
|
2007 } |
|
2008 }, |
|
2009 |
|
2010 _deactivate: function(event) { |
|
2011 var draggable = $.ui.ddmanager.current; |
|
2012 if(this.options.activeClass) { |
|
2013 this.element.removeClass(this.options.activeClass); |
|
2014 } |
|
2015 if(draggable){ |
|
2016 this._trigger("deactivate", event, this.ui(draggable)); |
|
2017 } |
|
2018 }, |
|
2019 |
|
2020 _over: function(event) { |
|
2021 |
|
2022 var draggable = $.ui.ddmanager.current; |
|
2023 |
|
2024 // Bail if draggable and droppable are same element |
|
2025 if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) { |
|
2026 return; |
|
2027 } |
|
2028 |
|
2029 if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
2030 if(this.options.hoverClass) { |
|
2031 this.element.addClass(this.options.hoverClass); |
|
2032 } |
|
2033 this._trigger("over", event, this.ui(draggable)); |
|
2034 } |
|
2035 |
|
2036 }, |
|
2037 |
|
2038 _out: function(event) { |
|
2039 |
|
2040 var draggable = $.ui.ddmanager.current; |
|
2041 |
|
2042 // Bail if draggable and droppable are same element |
|
2043 if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) { |
|
2044 return; |
|
2045 } |
|
2046 |
|
2047 if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
2048 if(this.options.hoverClass) { |
|
2049 this.element.removeClass(this.options.hoverClass); |
|
2050 } |
|
2051 this._trigger("out", event, this.ui(draggable)); |
|
2052 } |
|
2053 |
|
2054 }, |
|
2055 |
|
2056 _drop: function(event,custom) { |
|
2057 |
|
2058 var draggable = custom || $.ui.ddmanager.current, |
|
2059 childrenIntersection = false; |
|
2060 |
|
2061 // Bail if draggable and droppable are same element |
|
2062 if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) { |
|
2063 return false; |
|
2064 } |
|
2065 |
|
2066 this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() { |
|
2067 var inst = $.data(this, "ui-droppable"); |
|
2068 if( |
|
2069 inst.options.greedy && |
|
2070 !inst.options.disabled && |
|
2071 inst.options.scope === draggable.options.scope && |
|
2072 inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) && |
|
2073 $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance) |
|
2074 ) { childrenIntersection = true; return false; } |
|
2075 }); |
|
2076 if(childrenIntersection) { |
|
2077 return false; |
|
2078 } |
|
2079 |
|
2080 if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
2081 if(this.options.activeClass) { |
|
2082 this.element.removeClass(this.options.activeClass); |
|
2083 } |
|
2084 if(this.options.hoverClass) { |
|
2085 this.element.removeClass(this.options.hoverClass); |
|
2086 } |
|
2087 this._trigger("drop", event, this.ui(draggable)); |
|
2088 return this.element; |
|
2089 } |
|
2090 |
|
2091 return false; |
|
2092 |
|
2093 }, |
|
2094 |
|
2095 ui: function(c) { |
|
2096 return { |
|
2097 draggable: (c.currentItem || c.element), |
|
2098 helper: c.helper, |
|
2099 position: c.position, |
|
2100 offset: c.positionAbs |
|
2101 }; |
|
2102 } |
|
2103 |
|
2104 }); |
|
2105 |
|
2106 $.ui.intersect = function(draggable, droppable, toleranceMode) { |
|
2107 |
|
2108 if (!droppable.offset) { |
|
2109 return false; |
|
2110 } |
|
2111 |
|
2112 var draggableLeft, draggableTop, |
|
2113 x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width, |
|
2114 y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height, |
|
2115 l = droppable.offset.left, r = l + droppable.proportions.width, |
|
2116 t = droppable.offset.top, b = t + droppable.proportions.height; |
|
2117 |
|
2118 switch (toleranceMode) { |
|
2119 case "fit": |
|
2120 return (l <= x1 && x2 <= r && t <= y1 && y2 <= b); |
|
2121 case "intersect": |
|
2122 return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half |
|
2123 x2 - (draggable.helperProportions.width / 2) < r && // Left Half |
|
2124 t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half |
|
2125 y2 - (draggable.helperProportions.height / 2) < b ); // Top Half |
|
2126 case "pointer": |
|
2127 draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left); |
|
2128 draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top); |
|
2129 return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width ); |
|
2130 case "touch": |
|
2131 return ( |
|
2132 (y1 >= t && y1 <= b) || // Top edge touching |
|
2133 (y2 >= t && y2 <= b) || // Bottom edge touching |
|
2134 (y1 < t && y2 > b) // Surrounded vertically |
|
2135 ) && ( |
|
2136 (x1 >= l && x1 <= r) || // Left edge touching |
|
2137 (x2 >= l && x2 <= r) || // Right edge touching |
|
2138 (x1 < l && x2 > r) // Surrounded horizontally |
|
2139 ); |
|
2140 default: |
|
2141 return false; |
|
2142 } |
|
2143 |
|
2144 }; |
|
2145 |
|
2146 /* |
|
2147 This manager tracks offsets of draggables and droppables |
|
2148 */ |
|
2149 $.ui.ddmanager = { |
|
2150 current: null, |
|
2151 droppables: { "default": [] }, |
|
2152 prepareOffsets: function(t, event) { |
|
2153 |
|
2154 var i, j, |
|
2155 m = $.ui.ddmanager.droppables[t.options.scope] || [], |
|
2156 type = event ? event.type : null, // workaround for #2317 |
|
2157 list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack(); |
|
2158 |
|
2159 droppablesLoop: for (i = 0; i < m.length; i++) { |
|
2160 |
|
2161 //No disabled and non-accepted |
|
2162 if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) { |
|
2163 continue; |
|
2164 } |
|
2165 |
|
2166 // Filter out elements in the current dragged item |
|
2167 for (j=0; j < list.length; j++) { |
|
2168 if(list[j] === m[i].element[0]) { |
|
2169 m[i].proportions.height = 0; |
|
2170 continue droppablesLoop; |
|
2171 } |
|
2172 } |
|
2173 |
|
2174 m[i].visible = m[i].element.css("display") !== "none"; |
|
2175 if(!m[i].visible) { |
|
2176 continue; |
|
2177 } |
|
2178 |
|
2179 //Activate the droppable if used directly from draggables |
|
2180 if(type === "mousedown") { |
|
2181 m[i]._activate.call(m[i], event); |
|
2182 } |
|
2183 |
|
2184 m[i].offset = m[i].element.offset(); |
|
2185 m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight }; |
|
2186 |
|
2187 } |
|
2188 |
|
2189 }, |
|
2190 drop: function(draggable, event) { |
|
2191 |
|
2192 var dropped = false; |
|
2193 // Create a copy of the droppables in case the list changes during the drop (#9116) |
|
2194 $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() { |
|
2195 |
|
2196 if(!this.options) { |
|
2197 return; |
|
2198 } |
|
2199 if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) { |
|
2200 dropped = this._drop.call(this, event) || dropped; |
|
2201 } |
|
2202 |
|
2203 if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
2204 this.isout = true; |
|
2205 this.isover = false; |
|
2206 this._deactivate.call(this, event); |
|
2207 } |
|
2208 |
|
2209 }); |
|
2210 return dropped; |
|
2211 |
|
2212 }, |
|
2213 dragStart: function( draggable, event ) { |
|
2214 //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003) |
|
2215 draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() { |
|
2216 if( !draggable.options.refreshPositions ) { |
|
2217 $.ui.ddmanager.prepareOffsets( draggable, event ); |
|
2218 } |
|
2219 }); |
|
2220 }, |
|
2221 drag: function(draggable, event) { |
|
2222 |
|
2223 //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. |
|
2224 if(draggable.options.refreshPositions) { |
|
2225 $.ui.ddmanager.prepareOffsets(draggable, event); |
|
2226 } |
|
2227 |
|
2228 //Run through all droppables and check their positions based on specific tolerance options |
|
2229 $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() { |
|
2230 |
|
2231 if(this.options.disabled || this.greedyChild || !this.visible) { |
|
2232 return; |
|
2233 } |
|
2234 |
|
2235 var parentInstance, scope, parent, |
|
2236 intersects = $.ui.intersect(draggable, this, this.options.tolerance), |
|
2237 c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null); |
|
2238 if(!c) { |
|
2239 return; |
|
2240 } |
|
2241 |
|
2242 if (this.options.greedy) { |
|
2243 // find droppable parents with same scope |
|
2244 scope = this.options.scope; |
|
2245 parent = this.element.parents(":data(ui-droppable)").filter(function () { |
|
2246 return $.data(this, "ui-droppable").options.scope === scope; |
|
2247 }); |
|
2248 |
|
2249 if (parent.length) { |
|
2250 parentInstance = $.data(parent[0], "ui-droppable"); |
|
2251 parentInstance.greedyChild = (c === "isover"); |
|
2252 } |
|
2253 } |
|
2254 |
|
2255 // we just moved into a greedy child |
|
2256 if (parentInstance && c === "isover") { |
|
2257 parentInstance.isover = false; |
|
2258 parentInstance.isout = true; |
|
2259 parentInstance._out.call(parentInstance, event); |
|
2260 } |
|
2261 |
|
2262 this[c] = true; |
|
2263 this[c === "isout" ? "isover" : "isout"] = false; |
|
2264 this[c === "isover" ? "_over" : "_out"].call(this, event); |
|
2265 |
|
2266 // we just moved out of a greedy child |
|
2267 if (parentInstance && c === "isout") { |
|
2268 parentInstance.isout = false; |
|
2269 parentInstance.isover = true; |
|
2270 parentInstance._over.call(parentInstance, event); |
|
2271 } |
|
2272 }); |
|
2273 |
|
2274 }, |
|
2275 dragStop: function( draggable, event ) { |
|
2276 draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" ); |
|
2277 //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003) |
|
2278 if( !draggable.options.refreshPositions ) { |
|
2279 $.ui.ddmanager.prepareOffsets( draggable, event ); |
|
2280 } |
|
2281 } |
|
2282 }; |
|
2283 |
|
2284 })(jQuery); |
|
2285 |
|
2286 (function( $, undefined ) { |
|
2287 |
|
2288 function num(v) { |
|
2289 return parseInt(v, 10) || 0; |
|
2290 } |
|
2291 |
|
2292 function isNumber(value) { |
|
2293 return !isNaN(parseInt(value, 10)); |
|
2294 } |
|
2295 |
|
2296 $.widget("ui.resizable", $.ui.mouse, { |
|
2297 version: "1.10.3", |
|
2298 widgetEventPrefix: "resize", |
|
2299 options: { |
|
2300 alsoResize: false, |
|
2301 animate: false, |
|
2302 animateDuration: "slow", |
|
2303 animateEasing: "swing", |
|
2304 aspectRatio: false, |
|
2305 autoHide: false, |
|
2306 containment: false, |
|
2307 ghost: false, |
|
2308 grid: false, |
|
2309 handles: "e,s,se", |
|
2310 helper: false, |
|
2311 maxHeight: null, |
|
2312 maxWidth: null, |
|
2313 minHeight: 10, |
|
2314 minWidth: 10, |
|
2315 // See #7960 |
|
2316 zIndex: 90, |
|
2317 |
|
2318 // callbacks |
|
2319 resize: null, |
|
2320 start: null, |
|
2321 stop: null |
|
2322 }, |
|
2323 _create: function() { |
|
2324 |
|
2325 var n, i, handle, axis, hname, |
|
2326 that = this, |
|
2327 o = this.options; |
|
2328 this.element.addClass("ui-resizable"); |
|
2329 |
|
2330 $.extend(this, { |
|
2331 _aspectRatio: !!(o.aspectRatio), |
|
2332 aspectRatio: o.aspectRatio, |
|
2333 originalElement: this.element, |
|
2334 _proportionallyResizeElements: [], |
|
2335 _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null |
|
2336 }); |
|
2337 |
|
2338 //Wrap the element if it cannot hold child nodes |
|
2339 if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) { |
|
2340 |
|
2341 //Create a wrapper element and set the wrapper to the new current internal element |
|
2342 this.element.wrap( |
|
2343 $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({ |
|
2344 position: this.element.css("position"), |
|
2345 width: this.element.outerWidth(), |
|
2346 height: this.element.outerHeight(), |
|
2347 top: this.element.css("top"), |
|
2348 left: this.element.css("left") |
|
2349 }) |
|
2350 ); |
|
2351 |
|
2352 //Overwrite the original this.element |
|
2353 this.element = this.element.parent().data( |
|
2354 "ui-resizable", this.element.data("ui-resizable") |
|
2355 ); |
|
2356 |
|
2357 this.elementIsWrapper = true; |
|
2358 |
|
2359 //Move margins to the wrapper |
|
2360 this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") }); |
|
2361 this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); |
|
2362 |
|
2363 //Prevent Safari textarea resize |
|
2364 this.originalResizeStyle = this.originalElement.css("resize"); |
|
2365 this.originalElement.css("resize", "none"); |
|
2366 |
|
2367 //Push the actual element to our proportionallyResize internal array |
|
2368 this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" })); |
|
2369 |
|
2370 // avoid IE jump (hard set the margin) |
|
2371 this.originalElement.css({ margin: this.originalElement.css("margin") }); |
|
2372 |
|
2373 // fix handlers offset |
|
2374 this._proportionallyResize(); |
|
2375 |
|
2376 } |
|
2377 |
|
2378 this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : { n: ".ui-resizable-n", e: ".ui-resizable-e", s: ".ui-resizable-s", w: ".ui-resizable-w", se: ".ui-resizable-se", sw: ".ui-resizable-sw", ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" }); |
|
2379 if(this.handles.constructor === String) { |
|
2380 |
|
2381 if ( this.handles === "all") { |
|
2382 this.handles = "n,e,s,w,se,sw,ne,nw"; |
|
2383 } |
|
2384 |
|
2385 n = this.handles.split(","); |
|
2386 this.handles = {}; |
|
2387 |
|
2388 for(i = 0; i < n.length; i++) { |
|
2389 |
|
2390 handle = $.trim(n[i]); |
|
2391 hname = "ui-resizable-"+handle; |
|
2392 axis = $("<div class='ui-resizable-handle " + hname + "'></div>"); |
|
2393 |
|
2394 // Apply zIndex to all handles - see #7960 |
|
2395 axis.css({ zIndex: o.zIndex }); |
|
2396 |
|
2397 //TODO : What's going on here? |
|
2398 if ("se" === handle) { |
|
2399 axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se"); |
|
2400 } |
|
2401 |
|
2402 //Insert into internal handles object and append to element |
|
2403 this.handles[handle] = ".ui-resizable-"+handle; |
|
2404 this.element.append(axis); |
|
2405 } |
|
2406 |
|
2407 } |
|
2408 |
|
2409 this._renderAxis = function(target) { |
|
2410 |
|
2411 var i, axis, padPos, padWrapper; |
|
2412 |
|
2413 target = target || this.element; |
|
2414 |
|
2415 for(i in this.handles) { |
|
2416 |
|
2417 if(this.handles[i].constructor === String) { |
|
2418 this.handles[i] = $(this.handles[i], this.element).show(); |
|
2419 } |
|
2420 |
|
2421 //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) |
|
2422 if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) { |
|
2423 |
|
2424 axis = $(this.handles[i], this.element); |
|
2425 |
|
2426 //Checking the correct pad and border |
|
2427 padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); |
|
2428 |
|
2429 //The padding type i have to apply... |
|
2430 padPos = [ "padding", |
|
2431 /ne|nw|n/.test(i) ? "Top" : |
|
2432 /se|sw|s/.test(i) ? "Bottom" : |
|
2433 /^e$/.test(i) ? "Right" : "Left" ].join(""); |
|
2434 |
|
2435 target.css(padPos, padWrapper); |
|
2436 |
|
2437 this._proportionallyResize(); |
|
2438 |
|
2439 } |
|
2440 |
|
2441 //TODO: What's that good for? There's not anything to be executed left |
|
2442 if(!$(this.handles[i]).length) { |
|
2443 continue; |
|
2444 } |
|
2445 } |
|
2446 }; |
|
2447 |
|
2448 //TODO: make renderAxis a prototype function |
|
2449 this._renderAxis(this.element); |
|
2450 |
|
2451 this._handles = $(".ui-resizable-handle", this.element) |
|
2452 .disableSelection(); |
|
2453 |
|
2454 //Matching axis name |
|
2455 this._handles.mouseover(function() { |
|
2456 if (!that.resizing) { |
|
2457 if (this.className) { |
|
2458 axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); |
|
2459 } |
|
2460 //Axis, default = se |
|
2461 that.axis = axis && axis[1] ? axis[1] : "se"; |
|
2462 } |
|
2463 }); |
|
2464 |
|
2465 //If we want to auto hide the elements |
|
2466 if (o.autoHide) { |
|
2467 this._handles.hide(); |
|
2468 $(this.element) |
|
2469 .addClass("ui-resizable-autohide") |
|
2470 .mouseenter(function() { |
|
2471 if (o.disabled) { |
|
2472 return; |
|
2473 } |
|
2474 $(this).removeClass("ui-resizable-autohide"); |
|
2475 that._handles.show(); |
|
2476 }) |
|
2477 .mouseleave(function(){ |
|
2478 if (o.disabled) { |
|
2479 return; |
|
2480 } |
|
2481 if (!that.resizing) { |
|
2482 $(this).addClass("ui-resizable-autohide"); |
|
2483 that._handles.hide(); |
|
2484 } |
|
2485 }); |
|
2486 } |
|
2487 |
|
2488 //Initialize the mouse interaction |
|
2489 this._mouseInit(); |
|
2490 |
|
2491 }, |
|
2492 |
|
2493 _destroy: function() { |
|
2494 |
|
2495 this._mouseDestroy(); |
|
2496 |
|
2497 var wrapper, |
|
2498 _destroy = function(exp) { |
|
2499 $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing") |
|
2500 .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove(); |
|
2501 }; |
|
2502 |
|
2503 //TODO: Unwrap at same DOM position |
|
2504 if (this.elementIsWrapper) { |
|
2505 _destroy(this.element); |
|
2506 wrapper = this.element; |
|
2507 this.originalElement.css({ |
|
2508 position: wrapper.css("position"), |
|
2509 width: wrapper.outerWidth(), |
|
2510 height: wrapper.outerHeight(), |
|
2511 top: wrapper.css("top"), |
|
2512 left: wrapper.css("left") |
|
2513 }).insertAfter( wrapper ); |
|
2514 wrapper.remove(); |
|
2515 } |
|
2516 |
|
2517 this.originalElement.css("resize", this.originalResizeStyle); |
|
2518 _destroy(this.originalElement); |
|
2519 |
|
2520 return this; |
|
2521 }, |
|
2522 |
|
2523 _mouseCapture: function(event) { |
|
2524 var i, handle, |
|
2525 capture = false; |
|
2526 |
|
2527 for (i in this.handles) { |
|
2528 handle = $(this.handles[i])[0]; |
|
2529 if (handle === event.target || $.contains(handle, event.target)) { |
|
2530 capture = true; |
|
2531 } |
|
2532 } |
|
2533 |
|
2534 return !this.options.disabled && capture; |
|
2535 }, |
|
2536 |
|
2537 _mouseStart: function(event) { |
|
2538 |
|
2539 var curleft, curtop, cursor, |
|
2540 o = this.options, |
|
2541 iniPos = this.element.position(), |
|
2542 el = this.element; |
|
2543 |
|
2544 this.resizing = true; |
|
2545 |
|
2546 // bugfix for http://dev.jquery.com/ticket/1749 |
|
2547 if ( (/absolute/).test( el.css("position") ) ) { |
|
2548 el.css({ position: "absolute", top: el.css("top"), left: el.css("left") }); |
|
2549 } else if (el.is(".ui-draggable")) { |
|
2550 el.css({ position: "absolute", top: iniPos.top, left: iniPos.left }); |
|
2551 } |
|
2552 |
|
2553 this._renderProxy(); |
|
2554 |
|
2555 curleft = num(this.helper.css("left")); |
|
2556 curtop = num(this.helper.css("top")); |
|
2557 |
|
2558 if (o.containment) { |
|
2559 curleft += $(o.containment).scrollLeft() || 0; |
|
2560 curtop += $(o.containment).scrollTop() || 0; |
|
2561 } |
|
2562 |
|
2563 //Store needed variables |
|
2564 this.offset = this.helper.offset(); |
|
2565 this.position = { left: curleft, top: curtop }; |
|
2566 this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; |
|
2567 this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; |
|
2568 this.originalPosition = { left: curleft, top: curtop }; |
|
2569 this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; |
|
2570 this.originalMousePosition = { left: event.pageX, top: event.pageY }; |
|
2571 |
|
2572 //Aspect Ratio |
|
2573 this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1); |
|
2574 |
|
2575 cursor = $(".ui-resizable-" + this.axis).css("cursor"); |
|
2576 $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor); |
|
2577 |
|
2578 el.addClass("ui-resizable-resizing"); |
|
2579 this._propagate("start", event); |
|
2580 return true; |
|
2581 }, |
|
2582 |
|
2583 _mouseDrag: function(event) { |
|
2584 |
|
2585 //Increase performance, avoid regex |
|
2586 var data, |
|
2587 el = this.helper, props = {}, |
|
2588 smp = this.originalMousePosition, |
|
2589 a = this.axis, |
|
2590 prevTop = this.position.top, |
|
2591 prevLeft = this.position.left, |
|
2592 prevWidth = this.size.width, |
|
2593 prevHeight = this.size.height, |
|
2594 dx = (event.pageX-smp.left)||0, |
|
2595 dy = (event.pageY-smp.top)||0, |
|
2596 trigger = this._change[a]; |
|
2597 |
|
2598 if (!trigger) { |
|
2599 return false; |
|
2600 } |
|
2601 |
|
2602 // Calculate the attrs that will be change |
|
2603 data = trigger.apply(this, [event, dx, dy]); |
|
2604 |
|
2605 // Put this in the mouseDrag handler since the user can start pressing shift while resizing |
|
2606 this._updateVirtualBoundaries(event.shiftKey); |
|
2607 if (this._aspectRatio || event.shiftKey) { |
|
2608 data = this._updateRatio(data, event); |
|
2609 } |
|
2610 |
|
2611 data = this._respectSize(data, event); |
|
2612 |
|
2613 this._updateCache(data); |
|
2614 |
|
2615 // plugins callbacks need to be called first |
|
2616 this._propagate("resize", event); |
|
2617 |
|
2618 if (this.position.top !== prevTop) { |
|
2619 props.top = this.position.top + "px"; |
|
2620 } |
|
2621 if (this.position.left !== prevLeft) { |
|
2622 props.left = this.position.left + "px"; |
|
2623 } |
|
2624 if (this.size.width !== prevWidth) { |
|
2625 props.width = this.size.width + "px"; |
|
2626 } |
|
2627 if (this.size.height !== prevHeight) { |
|
2628 props.height = this.size.height + "px"; |
|
2629 } |
|
2630 el.css(props); |
|
2631 |
|
2632 if (!this._helper && this._proportionallyResizeElements.length) { |
|
2633 this._proportionallyResize(); |
|
2634 } |
|
2635 |
|
2636 // Call the user callback if the element was resized |
|
2637 if ( ! $.isEmptyObject(props) ) { |
|
2638 this._trigger("resize", event, this.ui()); |
|
2639 } |
|
2640 |
|
2641 return false; |
|
2642 }, |
|
2643 |
|
2644 _mouseStop: function(event) { |
|
2645 |
|
2646 this.resizing = false; |
|
2647 var pr, ista, soffseth, soffsetw, s, left, top, |
|
2648 o = this.options, that = this; |
|
2649 |
|
2650 if(this._helper) { |
|
2651 |
|
2652 pr = this._proportionallyResizeElements; |
|
2653 ista = pr.length && (/textarea/i).test(pr[0].nodeName); |
|
2654 soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height; |
|
2655 soffsetw = ista ? 0 : that.sizeDiff.width; |
|
2656 |
|
2657 s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) }; |
|
2658 left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null; |
|
2659 top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null; |
|
2660 |
|
2661 if (!o.animate) { |
|
2662 this.element.css($.extend(s, { top: top, left: left })); |
|
2663 } |
|
2664 |
|
2665 that.helper.height(that.size.height); |
|
2666 that.helper.width(that.size.width); |
|
2667 |
|
2668 if (this._helper && !o.animate) { |
|
2669 this._proportionallyResize(); |
|
2670 } |
|
2671 } |
|
2672 |
|
2673 $("body").css("cursor", "auto"); |
|
2674 |
|
2675 this.element.removeClass("ui-resizable-resizing"); |
|
2676 |
|
2677 this._propagate("stop", event); |
|
2678 |
|
2679 if (this._helper) { |
|
2680 this.helper.remove(); |
|
2681 } |
|
2682 |
|
2683 return false; |
|
2684 |
|
2685 }, |
|
2686 |
|
2687 _updateVirtualBoundaries: function(forceAspectRatio) { |
|
2688 var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b, |
|
2689 o = this.options; |
|
2690 |
|
2691 b = { |
|
2692 minWidth: isNumber(o.minWidth) ? o.minWidth : 0, |
|
2693 maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity, |
|
2694 minHeight: isNumber(o.minHeight) ? o.minHeight : 0, |
|
2695 maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity |
|
2696 }; |
|
2697 |
|
2698 if(this._aspectRatio || forceAspectRatio) { |
|
2699 // We want to create an enclosing box whose aspect ration is the requested one |
|
2700 // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension |
|
2701 pMinWidth = b.minHeight * this.aspectRatio; |
|
2702 pMinHeight = b.minWidth / this.aspectRatio; |
|
2703 pMaxWidth = b.maxHeight * this.aspectRatio; |
|
2704 pMaxHeight = b.maxWidth / this.aspectRatio; |
|
2705 |
|
2706 if(pMinWidth > b.minWidth) { |
|
2707 b.minWidth = pMinWidth; |
|
2708 } |
|
2709 if(pMinHeight > b.minHeight) { |
|
2710 b.minHeight = pMinHeight; |
|
2711 } |
|
2712 if(pMaxWidth < b.maxWidth) { |
|
2713 b.maxWidth = pMaxWidth; |
|
2714 } |
|
2715 if(pMaxHeight < b.maxHeight) { |
|
2716 b.maxHeight = pMaxHeight; |
|
2717 } |
|
2718 } |
|
2719 this._vBoundaries = b; |
|
2720 }, |
|
2721 |
|
2722 _updateCache: function(data) { |
|
2723 this.offset = this.helper.offset(); |
|
2724 if (isNumber(data.left)) { |
|
2725 this.position.left = data.left; |
|
2726 } |
|
2727 if (isNumber(data.top)) { |
|
2728 this.position.top = data.top; |
|
2729 } |
|
2730 if (isNumber(data.height)) { |
|
2731 this.size.height = data.height; |
|
2732 } |
|
2733 if (isNumber(data.width)) { |
|
2734 this.size.width = data.width; |
|
2735 } |
|
2736 }, |
|
2737 |
|
2738 _updateRatio: function( data ) { |
|
2739 |
|
2740 var cpos = this.position, |
|
2741 csize = this.size, |
|
2742 a = this.axis; |
|
2743 |
|
2744 if (isNumber(data.height)) { |
|
2745 data.width = (data.height * this.aspectRatio); |
|
2746 } else if (isNumber(data.width)) { |
|
2747 data.height = (data.width / this.aspectRatio); |
|
2748 } |
|
2749 |
|
2750 if (a === "sw") { |
|
2751 data.left = cpos.left + (csize.width - data.width); |
|
2752 data.top = null; |
|
2753 } |
|
2754 if (a === "nw") { |
|
2755 data.top = cpos.top + (csize.height - data.height); |
|
2756 data.left = cpos.left + (csize.width - data.width); |
|
2757 } |
|
2758 |
|
2759 return data; |
|
2760 }, |
|
2761 |
|
2762 _respectSize: function( data ) { |
|
2763 |
|
2764 var o = this._vBoundaries, |
|
2765 a = this.axis, |
|
2766 ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), |
|
2767 isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height), |
|
2768 dw = this.originalPosition.left + this.originalSize.width, |
|
2769 dh = this.position.top + this.size.height, |
|
2770 cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); |
|
2771 if (isminw) { |
|
2772 data.width = o.minWidth; |
|
2773 } |
|
2774 if (isminh) { |
|
2775 data.height = o.minHeight; |
|
2776 } |
|
2777 if (ismaxw) { |
|
2778 data.width = o.maxWidth; |
|
2779 } |
|
2780 if (ismaxh) { |
|
2781 data.height = o.maxHeight; |
|
2782 } |
|
2783 |
|
2784 if (isminw && cw) { |
|
2785 data.left = dw - o.minWidth; |
|
2786 } |
|
2787 if (ismaxw && cw) { |
|
2788 data.left = dw - o.maxWidth; |
|
2789 } |
|
2790 if (isminh && ch) { |
|
2791 data.top = dh - o.minHeight; |
|
2792 } |
|
2793 if (ismaxh && ch) { |
|
2794 data.top = dh - o.maxHeight; |
|
2795 } |
|
2796 |
|
2797 // fixing jump error on top/left - bug #2330 |
|
2798 if (!data.width && !data.height && !data.left && data.top) { |
|
2799 data.top = null; |
|
2800 } else if (!data.width && !data.height && !data.top && data.left) { |
|
2801 data.left = null; |
|
2802 } |
|
2803 |
|
2804 return data; |
|
2805 }, |
|
2806 |
|
2807 _proportionallyResize: function() { |
|
2808 |
|
2809 if (!this._proportionallyResizeElements.length) { |
|
2810 return; |
|
2811 } |
|
2812 |
|
2813 var i, j, borders, paddings, prel, |
|
2814 element = this.helper || this.element; |
|
2815 |
|
2816 for ( i=0; i < this._proportionallyResizeElements.length; i++) { |
|
2817 |
|
2818 prel = this._proportionallyResizeElements[i]; |
|
2819 |
|
2820 if (!this.borderDif) { |
|
2821 this.borderDif = []; |
|
2822 borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")]; |
|
2823 paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")]; |
|
2824 |
|
2825 for ( j = 0; j < borders.length; j++ ) { |
|
2826 this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 ); |
|
2827 } |
|
2828 } |
|
2829 |
|
2830 prel.css({ |
|
2831 height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0, |
|
2832 width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0 |
|
2833 }); |
|
2834 |
|
2835 } |
|
2836 |
|
2837 }, |
|
2838 |
|
2839 _renderProxy: function() { |
|
2840 |
|
2841 var el = this.element, o = this.options; |
|
2842 this.elementOffset = el.offset(); |
|
2843 |
|
2844 if(this._helper) { |
|
2845 |
|
2846 this.helper = this.helper || $("<div style='overflow:hidden;'></div>"); |
|
2847 |
|
2848 this.helper.addClass(this._helper).css({ |
|
2849 width: this.element.outerWidth() - 1, |
|
2850 height: this.element.outerHeight() - 1, |
|
2851 position: "absolute", |
|
2852 left: this.elementOffset.left +"px", |
|
2853 top: this.elementOffset.top +"px", |
|
2854 zIndex: ++o.zIndex //TODO: Don't modify option |
|
2855 }); |
|
2856 |
|
2857 this.helper |
|
2858 .appendTo("body") |
|
2859 .disableSelection(); |
|
2860 |
|
2861 } else { |
|
2862 this.helper = this.element; |
|
2863 } |
|
2864 |
|
2865 }, |
|
2866 |
|
2867 _change: { |
|
2868 e: function(event, dx) { |
|
2869 return { width: this.originalSize.width + dx }; |
|
2870 }, |
|
2871 w: function(event, dx) { |
|
2872 var cs = this.originalSize, sp = this.originalPosition; |
|
2873 return { left: sp.left + dx, width: cs.width - dx }; |
|
2874 }, |
|
2875 n: function(event, dx, dy) { |
|
2876 var cs = this.originalSize, sp = this.originalPosition; |
|
2877 return { top: sp.top + dy, height: cs.height - dy }; |
|
2878 }, |
|
2879 s: function(event, dx, dy) { |
|
2880 return { height: this.originalSize.height + dy }; |
|
2881 }, |
|
2882 se: function(event, dx, dy) { |
|
2883 return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); |
|
2884 }, |
|
2885 sw: function(event, dx, dy) { |
|
2886 return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); |
|
2887 }, |
|
2888 ne: function(event, dx, dy) { |
|
2889 return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); |
|
2890 }, |
|
2891 nw: function(event, dx, dy) { |
|
2892 return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); |
|
2893 } |
|
2894 }, |
|
2895 |
|
2896 _propagate: function(n, event) { |
|
2897 $.ui.plugin.call(this, n, [event, this.ui()]); |
|
2898 (n !== "resize" && this._trigger(n, event, this.ui())); |
|
2899 }, |
|
2900 |
|
2901 plugins: {}, |
|
2902 |
|
2903 ui: function() { |
|
2904 return { |
|
2905 originalElement: this.originalElement, |
|
2906 element: this.element, |
|
2907 helper: this.helper, |
|
2908 position: this.position, |
|
2909 size: this.size, |
|
2910 originalSize: this.originalSize, |
|
2911 originalPosition: this.originalPosition |
|
2912 }; |
|
2913 } |
|
2914 |
|
2915 }); |
|
2916 |
|
2917 /* |
|
2918 * Resizable Extensions |
|
2919 */ |
|
2920 |
|
2921 $.ui.plugin.add("resizable", "animate", { |
|
2922 |
|
2923 stop: function( event ) { |
|
2924 var that = $(this).data("ui-resizable"), |
|
2925 o = that.options, |
|
2926 pr = that._proportionallyResizeElements, |
|
2927 ista = pr.length && (/textarea/i).test(pr[0].nodeName), |
|
2928 soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height, |
|
2929 soffsetw = ista ? 0 : that.sizeDiff.width, |
|
2930 style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) }, |
|
2931 left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null, |
|
2932 top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null; |
|
2933 |
|
2934 that.element.animate( |
|
2935 $.extend(style, top && left ? { top: top, left: left } : {}), { |
|
2936 duration: o.animateDuration, |
|
2937 easing: o.animateEasing, |
|
2938 step: function() { |
|
2939 |
|
2940 var data = { |
|
2941 width: parseInt(that.element.css("width"), 10), |
|
2942 height: parseInt(that.element.css("height"), 10), |
|
2943 top: parseInt(that.element.css("top"), 10), |
|
2944 left: parseInt(that.element.css("left"), 10) |
|
2945 }; |
|
2946 |
|
2947 if (pr && pr.length) { |
|
2948 $(pr[0]).css({ width: data.width, height: data.height }); |
|
2949 } |
|
2950 |
|
2951 // propagating resize, and updating values for each animation step |
|
2952 that._updateCache(data); |
|
2953 that._propagate("resize", event); |
|
2954 |
|
2955 } |
|
2956 } |
|
2957 ); |
|
2958 } |
|
2959 |
|
2960 }); |
|
2961 |
|
2962 $.ui.plugin.add("resizable", "containment", { |
|
2963 |
|
2964 start: function() { |
|
2965 var element, p, co, ch, cw, width, height, |
|
2966 that = $(this).data("ui-resizable"), |
|
2967 o = that.options, |
|
2968 el = that.element, |
|
2969 oc = o.containment, |
|
2970 ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; |
|
2971 |
|
2972 if (!ce) { |
|
2973 return; |
|
2974 } |
|
2975 |
|
2976 that.containerElement = $(ce); |
|
2977 |
|
2978 if (/document/.test(oc) || oc === document) { |
|
2979 that.containerOffset = { left: 0, top: 0 }; |
|
2980 that.containerPosition = { left: 0, top: 0 }; |
|
2981 |
|
2982 that.parentData = { |
|
2983 element: $(document), left: 0, top: 0, |
|
2984 width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight |
|
2985 }; |
|
2986 } |
|
2987 |
|
2988 // i'm a node, so compute top, left, right, bottom |
|
2989 else { |
|
2990 element = $(ce); |
|
2991 p = []; |
|
2992 $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); }); |
|
2993 |
|
2994 that.containerOffset = element.offset(); |
|
2995 that.containerPosition = element.position(); |
|
2996 that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) }; |
|
2997 |
|
2998 co = that.containerOffset; |
|
2999 ch = that.containerSize.height; |
|
3000 cw = that.containerSize.width; |
|
3001 width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ); |
|
3002 height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); |
|
3003 |
|
3004 that.parentData = { |
|
3005 element: ce, left: co.left, top: co.top, width: width, height: height |
|
3006 }; |
|
3007 } |
|
3008 }, |
|
3009 |
|
3010 resize: function( event ) { |
|
3011 var woset, hoset, isParent, isOffsetRelative, |
|
3012 that = $(this).data("ui-resizable"), |
|
3013 o = that.options, |
|
3014 co = that.containerOffset, cp = that.position, |
|
3015 pRatio = that._aspectRatio || event.shiftKey, |
|
3016 cop = { top:0, left:0 }, ce = that.containerElement; |
|
3017 |
|
3018 if (ce[0] !== document && (/static/).test(ce.css("position"))) { |
|
3019 cop = co; |
|
3020 } |
|
3021 |
|
3022 if (cp.left < (that._helper ? co.left : 0)) { |
|
3023 that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left)); |
|
3024 if (pRatio) { |
|
3025 that.size.height = that.size.width / that.aspectRatio; |
|
3026 } |
|
3027 that.position.left = o.helper ? co.left : 0; |
|
3028 } |
|
3029 |
|
3030 if (cp.top < (that._helper ? co.top : 0)) { |
|
3031 that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top); |
|
3032 if (pRatio) { |
|
3033 that.size.width = that.size.height * that.aspectRatio; |
|
3034 } |
|
3035 that.position.top = that._helper ? co.top : 0; |
|
3036 } |
|
3037 |
|
3038 that.offset.left = that.parentData.left+that.position.left; |
|
3039 that.offset.top = that.parentData.top+that.position.top; |
|
3040 |
|
3041 woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width ); |
|
3042 hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height ); |
|
3043 |
|
3044 isParent = that.containerElement.get(0) === that.element.parent().get(0); |
|
3045 isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position")); |
|
3046 |
|
3047 if(isParent && isOffsetRelative) { |
|
3048 woset -= that.parentData.left; |
|
3049 } |
|
3050 |
|
3051 if (woset + that.size.width >= that.parentData.width) { |
|
3052 that.size.width = that.parentData.width - woset; |
|
3053 if (pRatio) { |
|
3054 that.size.height = that.size.width / that.aspectRatio; |
|
3055 } |
|
3056 } |
|
3057 |
|
3058 if (hoset + that.size.height >= that.parentData.height) { |
|
3059 that.size.height = that.parentData.height - hoset; |
|
3060 if (pRatio) { |
|
3061 that.size.width = that.size.height * that.aspectRatio; |
|
3062 } |
|
3063 } |
|
3064 }, |
|
3065 |
|
3066 stop: function(){ |
|
3067 var that = $(this).data("ui-resizable"), |
|
3068 o = that.options, |
|
3069 co = that.containerOffset, |
|
3070 cop = that.containerPosition, |
|
3071 ce = that.containerElement, |
|
3072 helper = $(that.helper), |
|
3073 ho = helper.offset(), |
|
3074 w = helper.outerWidth() - that.sizeDiff.width, |
|
3075 h = helper.outerHeight() - that.sizeDiff.height; |
|
3076 |
|
3077 if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) { |
|
3078 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
|
3079 } |
|
3080 |
|
3081 if (that._helper && !o.animate && (/static/).test(ce.css("position"))) { |
|
3082 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
|
3083 } |
|
3084 |
|
3085 } |
|
3086 }); |
|
3087 |
|
3088 $.ui.plugin.add("resizable", "alsoResize", { |
|
3089 |
|
3090 start: function () { |
|
3091 var that = $(this).data("ui-resizable"), |
|
3092 o = that.options, |
|
3093 _store = function (exp) { |
|
3094 $(exp).each(function() { |
|
3095 var el = $(this); |
|
3096 el.data("ui-resizable-alsoresize", { |
|
3097 width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), |
|
3098 left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10) |
|
3099 }); |
|
3100 }); |
|
3101 }; |
|
3102 |
|
3103 if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) { |
|
3104 if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } |
|
3105 else { $.each(o.alsoResize, function (exp) { _store(exp); }); } |
|
3106 }else{ |
|
3107 _store(o.alsoResize); |
|
3108 } |
|
3109 }, |
|
3110 |
|
3111 resize: function (event, ui) { |
|
3112 var that = $(this).data("ui-resizable"), |
|
3113 o = that.options, |
|
3114 os = that.originalSize, |
|
3115 op = that.originalPosition, |
|
3116 delta = { |
|
3117 height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0, |
|
3118 top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0 |
|
3119 }, |
|
3120 |
|
3121 _alsoResize = function (exp, c) { |
|
3122 $(exp).each(function() { |
|
3123 var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {}, |
|
3124 css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"]; |
|
3125 |
|
3126 $.each(css, function (i, prop) { |
|
3127 var sum = (start[prop]||0) + (delta[prop]||0); |
|
3128 if (sum && sum >= 0) { |
|
3129 style[prop] = sum || null; |
|
3130 } |
|
3131 }); |
|
3132 |
|
3133 el.css(style); |
|
3134 }); |
|
3135 }; |
|
3136 |
|
3137 if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) { |
|
3138 $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); }); |
|
3139 }else{ |
|
3140 _alsoResize(o.alsoResize); |
|
3141 } |
|
3142 }, |
|
3143 |
|
3144 stop: function () { |
|
3145 $(this).removeData("resizable-alsoresize"); |
|
3146 } |
|
3147 }); |
|
3148 |
|
3149 $.ui.plugin.add("resizable", "ghost", { |
|
3150 |
|
3151 start: function() { |
|
3152 |
|
3153 var that = $(this).data("ui-resizable"), o = that.options, cs = that.size; |
|
3154 |
|
3155 that.ghost = that.originalElement.clone(); |
|
3156 that.ghost |
|
3157 .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }) |
|
3158 .addClass("ui-resizable-ghost") |
|
3159 .addClass(typeof o.ghost === "string" ? o.ghost : ""); |
|
3160 |
|
3161 that.ghost.appendTo(that.helper); |
|
3162 |
|
3163 }, |
|
3164 |
|
3165 resize: function(){ |
|
3166 var that = $(this).data("ui-resizable"); |
|
3167 if (that.ghost) { |
|
3168 that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width }); |
|
3169 } |
|
3170 }, |
|
3171 |
|
3172 stop: function() { |
|
3173 var that = $(this).data("ui-resizable"); |
|
3174 if (that.ghost && that.helper) { |
|
3175 that.helper.get(0).removeChild(that.ghost.get(0)); |
|
3176 } |
|
3177 } |
|
3178 |
|
3179 }); |
|
3180 |
|
3181 $.ui.plugin.add("resizable", "grid", { |
|
3182 |
|
3183 resize: function() { |
|
3184 var that = $(this).data("ui-resizable"), |
|
3185 o = that.options, |
|
3186 cs = that.size, |
|
3187 os = that.originalSize, |
|
3188 op = that.originalPosition, |
|
3189 a = that.axis, |
|
3190 grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid, |
|
3191 gridX = (grid[0]||1), |
|
3192 gridY = (grid[1]||1), |
|
3193 ox = Math.round((cs.width - os.width) / gridX) * gridX, |
|
3194 oy = Math.round((cs.height - os.height) / gridY) * gridY, |
|
3195 newWidth = os.width + ox, |
|
3196 newHeight = os.height + oy, |
|
3197 isMaxWidth = o.maxWidth && (o.maxWidth < newWidth), |
|
3198 isMaxHeight = o.maxHeight && (o.maxHeight < newHeight), |
|
3199 isMinWidth = o.minWidth && (o.minWidth > newWidth), |
|
3200 isMinHeight = o.minHeight && (o.minHeight > newHeight); |
|
3201 |
|
3202 o.grid = grid; |
|
3203 |
|
3204 if (isMinWidth) { |
|
3205 newWidth = newWidth + gridX; |
|
3206 } |
|
3207 if (isMinHeight) { |
|
3208 newHeight = newHeight + gridY; |
|
3209 } |
|
3210 if (isMaxWidth) { |
|
3211 newWidth = newWidth - gridX; |
|
3212 } |
|
3213 if (isMaxHeight) { |
|
3214 newHeight = newHeight - gridY; |
|
3215 } |
|
3216 |
|
3217 if (/^(se|s|e)$/.test(a)) { |
|
3218 that.size.width = newWidth; |
|
3219 that.size.height = newHeight; |
|
3220 } else if (/^(ne)$/.test(a)) { |
|
3221 that.size.width = newWidth; |
|
3222 that.size.height = newHeight; |
|
3223 that.position.top = op.top - oy; |
|
3224 } else if (/^(sw)$/.test(a)) { |
|
3225 that.size.width = newWidth; |
|
3226 that.size.height = newHeight; |
|
3227 that.position.left = op.left - ox; |
|
3228 } else { |
|
3229 that.size.width = newWidth; |
|
3230 that.size.height = newHeight; |
|
3231 that.position.top = op.top - oy; |
|
3232 that.position.left = op.left - ox; |
|
3233 } |
|
3234 } |
|
3235 |
|
3236 }); |
|
3237 |
|
3238 })(jQuery); |
|
3239 |
|
3240 (function( $, undefined ) { |
|
3241 |
|
3242 $.widget("ui.selectable", $.ui.mouse, { |
|
3243 version: "1.10.3", |
|
3244 options: { |
|
3245 appendTo: "body", |
|
3246 autoRefresh: true, |
|
3247 distance: 0, |
|
3248 filter: "*", |
|
3249 tolerance: "touch", |
|
3250 |
|
3251 // callbacks |
|
3252 selected: null, |
|
3253 selecting: null, |
|
3254 start: null, |
|
3255 stop: null, |
|
3256 unselected: null, |
|
3257 unselecting: null |
|
3258 }, |
|
3259 _create: function() { |
|
3260 var selectees, |
|
3261 that = this; |
|
3262 |
|
3263 this.element.addClass("ui-selectable"); |
|
3264 |
|
3265 this.dragged = false; |
|
3266 |
|
3267 // cache selectee children based on filter |
|
3268 this.refresh = function() { |
|
3269 selectees = $(that.options.filter, that.element[0]); |
|
3270 selectees.addClass("ui-selectee"); |
|
3271 selectees.each(function() { |
|
3272 var $this = $(this), |
|
3273 pos = $this.offset(); |
|
3274 $.data(this, "selectable-item", { |
|
3275 element: this, |
|
3276 $element: $this, |
|
3277 left: pos.left, |
|
3278 top: pos.top, |
|
3279 right: pos.left + $this.outerWidth(), |
|
3280 bottom: pos.top + $this.outerHeight(), |
|
3281 startselected: false, |
|
3282 selected: $this.hasClass("ui-selected"), |
|
3283 selecting: $this.hasClass("ui-selecting"), |
|
3284 unselecting: $this.hasClass("ui-unselecting") |
|
3285 }); |
|
3286 }); |
|
3287 }; |
|
3288 this.refresh(); |
|
3289 |
|
3290 this.selectees = selectees.addClass("ui-selectee"); |
|
3291 |
|
3292 this._mouseInit(); |
|
3293 |
|
3294 this.helper = $("<div class='ui-selectable-helper'></div>"); |
|
3295 }, |
|
3296 |
|
3297 _destroy: function() { |
|
3298 this.selectees |
|
3299 .removeClass("ui-selectee") |
|
3300 .removeData("selectable-item"); |
|
3301 this.element |
|
3302 .removeClass("ui-selectable ui-selectable-disabled"); |
|
3303 this._mouseDestroy(); |
|
3304 }, |
|
3305 |
|
3306 _mouseStart: function(event) { |
|
3307 var that = this, |
|
3308 options = this.options; |
|
3309 |
|
3310 this.opos = [event.pageX, event.pageY]; |
|
3311 |
|
3312 if (this.options.disabled) { |
|
3313 return; |
|
3314 } |
|
3315 |
|
3316 this.selectees = $(options.filter, this.element[0]); |
|
3317 |
|
3318 this._trigger("start", event); |
|
3319 |
|
3320 $(options.appendTo).append(this.helper); |
|
3321 // position helper (lasso) |
|
3322 this.helper.css({ |
|
3323 "left": event.pageX, |
|
3324 "top": event.pageY, |
|
3325 "width": 0, |
|
3326 "height": 0 |
|
3327 }); |
|
3328 |
|
3329 if (options.autoRefresh) { |
|
3330 this.refresh(); |
|
3331 } |
|
3332 |
|
3333 this.selectees.filter(".ui-selected").each(function() { |
|
3334 var selectee = $.data(this, "selectable-item"); |
|
3335 selectee.startselected = true; |
|
3336 if (!event.metaKey && !event.ctrlKey) { |
|
3337 selectee.$element.removeClass("ui-selected"); |
|
3338 selectee.selected = false; |
|
3339 selectee.$element.addClass("ui-unselecting"); |
|
3340 selectee.unselecting = true; |
|
3341 // selectable UNSELECTING callback |
|
3342 that._trigger("unselecting", event, { |
|
3343 unselecting: selectee.element |
|
3344 }); |
|
3345 } |
|
3346 }); |
|
3347 |
|
3348 $(event.target).parents().addBack().each(function() { |
|
3349 var doSelect, |
|
3350 selectee = $.data(this, "selectable-item"); |
|
3351 if (selectee) { |
|
3352 doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected"); |
|
3353 selectee.$element |
|
3354 .removeClass(doSelect ? "ui-unselecting" : "ui-selected") |
|
3355 .addClass(doSelect ? "ui-selecting" : "ui-unselecting"); |
|
3356 selectee.unselecting = !doSelect; |
|
3357 selectee.selecting = doSelect; |
|
3358 selectee.selected = doSelect; |
|
3359 // selectable (UN)SELECTING callback |
|
3360 if (doSelect) { |
|
3361 that._trigger("selecting", event, { |
|
3362 selecting: selectee.element |
|
3363 }); |
|
3364 } else { |
|
3365 that._trigger("unselecting", event, { |
|
3366 unselecting: selectee.element |
|
3367 }); |
|
3368 } |
|
3369 return false; |
|
3370 } |
|
3371 }); |
|
3372 |
|
3373 }, |
|
3374 |
|
3375 _mouseDrag: function(event) { |
|
3376 |
|
3377 this.dragged = true; |
|
3378 |
|
3379 if (this.options.disabled) { |
|
3380 return; |
|
3381 } |
|
3382 |
|
3383 var tmp, |
|
3384 that = this, |
|
3385 options = this.options, |
|
3386 x1 = this.opos[0], |
|
3387 y1 = this.opos[1], |
|
3388 x2 = event.pageX, |
|
3389 y2 = event.pageY; |
|
3390 |
|
3391 if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; } |
|
3392 if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; } |
|
3393 this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1}); |
|
3394 |
|
3395 this.selectees.each(function() { |
|
3396 var selectee = $.data(this, "selectable-item"), |
|
3397 hit = false; |
|
3398 |
|
3399 //prevent helper from being selected if appendTo: selectable |
|
3400 if (!selectee || selectee.element === that.element[0]) { |
|
3401 return; |
|
3402 } |
|
3403 |
|
3404 if (options.tolerance === "touch") { |
|
3405 hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) ); |
|
3406 } else if (options.tolerance === "fit") { |
|
3407 hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2); |
|
3408 } |
|
3409 |
|
3410 if (hit) { |
|
3411 // SELECT |
|
3412 if (selectee.selected) { |
|
3413 selectee.$element.removeClass("ui-selected"); |
|
3414 selectee.selected = false; |
|
3415 } |
|
3416 if (selectee.unselecting) { |
|
3417 selectee.$element.removeClass("ui-unselecting"); |
|
3418 selectee.unselecting = false; |
|
3419 } |
|
3420 if (!selectee.selecting) { |
|
3421 selectee.$element.addClass("ui-selecting"); |
|
3422 selectee.selecting = true; |
|
3423 // selectable SELECTING callback |
|
3424 that._trigger("selecting", event, { |
|
3425 selecting: selectee.element |
|
3426 }); |
|
3427 } |
|
3428 } else { |
|
3429 // UNSELECT |
|
3430 if (selectee.selecting) { |
|
3431 if ((event.metaKey || event.ctrlKey) && selectee.startselected) { |
|
3432 selectee.$element.removeClass("ui-selecting"); |
|
3433 selectee.selecting = false; |
|
3434 selectee.$element.addClass("ui-selected"); |
|
3435 selectee.selected = true; |
|
3436 } else { |
|
3437 selectee.$element.removeClass("ui-selecting"); |
|
3438 selectee.selecting = false; |
|
3439 if (selectee.startselected) { |
|
3440 selectee.$element.addClass("ui-unselecting"); |
|
3441 selectee.unselecting = true; |
|
3442 } |
|
3443 // selectable UNSELECTING callback |
|
3444 that._trigger("unselecting", event, { |
|
3445 unselecting: selectee.element |
|
3446 }); |
|
3447 } |
|
3448 } |
|
3449 if (selectee.selected) { |
|
3450 if (!event.metaKey && !event.ctrlKey && !selectee.startselected) { |
|
3451 selectee.$element.removeClass("ui-selected"); |
|
3452 selectee.selected = false; |
|
3453 |
|
3454 selectee.$element.addClass("ui-unselecting"); |
|
3455 selectee.unselecting = true; |
|
3456 // selectable UNSELECTING callback |
|
3457 that._trigger("unselecting", event, { |
|
3458 unselecting: selectee.element |
|
3459 }); |
|
3460 } |
|
3461 } |
|
3462 } |
|
3463 }); |
|
3464 |
|
3465 return false; |
|
3466 }, |
|
3467 |
|
3468 _mouseStop: function(event) { |
|
3469 var that = this; |
|
3470 |
|
3471 this.dragged = false; |
|
3472 |
|
3473 $(".ui-unselecting", this.element[0]).each(function() { |
|
3474 var selectee = $.data(this, "selectable-item"); |
|
3475 selectee.$element.removeClass("ui-unselecting"); |
|
3476 selectee.unselecting = false; |
|
3477 selectee.startselected = false; |
|
3478 that._trigger("unselected", event, { |
|
3479 unselected: selectee.element |
|
3480 }); |
|
3481 }); |
|
3482 $(".ui-selecting", this.element[0]).each(function() { |
|
3483 var selectee = $.data(this, "selectable-item"); |
|
3484 selectee.$element.removeClass("ui-selecting").addClass("ui-selected"); |
|
3485 selectee.selecting = false; |
|
3486 selectee.selected = true; |
|
3487 selectee.startselected = true; |
|
3488 that._trigger("selected", event, { |
|
3489 selected: selectee.element |
|
3490 }); |
|
3491 }); |
|
3492 this._trigger("stop", event); |
|
3493 |
|
3494 this.helper.remove(); |
|
3495 |
|
3496 return false; |
|
3497 } |
|
3498 |
|
3499 }); |
|
3500 |
|
3501 })(jQuery); |
|
3502 |
|
3503 (function( $, undefined ) { |
|
3504 |
|
3505 /*jshint loopfunc: true */ |
|
3506 |
|
3507 function isOverAxis( x, reference, size ) { |
|
3508 return ( x > reference ) && ( x < ( reference + size ) ); |
|
3509 } |
|
3510 |
|
3511 function isFloating(item) { |
|
3512 return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display")); |
|
3513 } |
|
3514 |
|
3515 $.widget("ui.sortable", $.ui.mouse, { |
|
3516 version: "1.10.3", |
|
3517 widgetEventPrefix: "sort", |
|
3518 ready: false, |
|
3519 options: { |
|
3520 appendTo: "parent", |
|
3521 axis: false, |
|
3522 connectWith: false, |
|
3523 containment: false, |
|
3524 cursor: "auto", |
|
3525 cursorAt: false, |
|
3526 dropOnEmpty: true, |
|
3527 forcePlaceholderSize: false, |
|
3528 forceHelperSize: false, |
|
3529 grid: false, |
|
3530 handle: false, |
|
3531 helper: "original", |
|
3532 items: "> *", |
|
3533 opacity: false, |
|
3534 placeholder: false, |
|
3535 revert: false, |
|
3536 scroll: true, |
|
3537 scrollSensitivity: 20, |
|
3538 scrollSpeed: 20, |
|
3539 scope: "default", |
|
3540 tolerance: "intersect", |
|
3541 zIndex: 1000, |
|
3542 |
|
3543 // callbacks |
|
3544 activate: null, |
|
3545 beforeStop: null, |
|
3546 change: null, |
|
3547 deactivate: null, |
|
3548 out: null, |
|
3549 over: null, |
|
3550 receive: null, |
|
3551 remove: null, |
|
3552 sort: null, |
|
3553 start: null, |
|
3554 stop: null, |
|
3555 update: null |
|
3556 }, |
|
3557 _create: function() { |
|
3558 |
|
3559 var o = this.options; |
|
3560 this.containerCache = {}; |
|
3561 this.element.addClass("ui-sortable"); |
|
3562 |
|
3563 //Get the items |
|
3564 this.refresh(); |
|
3565 |
|
3566 //Let's determine if the items are being displayed horizontally |
|
3567 this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false; |
|
3568 |
|
3569 //Let's determine the parent's offset |
|
3570 this.offset = this.element.offset(); |
|
3571 |
|
3572 //Initialize mouse events for interaction |
|
3573 this._mouseInit(); |
|
3574 |
|
3575 //We're ready to go |
|
3576 this.ready = true; |
|
3577 |
|
3578 }, |
|
3579 |
|
3580 _destroy: function() { |
|
3581 this.element |
|
3582 .removeClass("ui-sortable ui-sortable-disabled"); |
|
3583 this._mouseDestroy(); |
|
3584 |
|
3585 for ( var i = this.items.length - 1; i >= 0; i-- ) { |
|
3586 this.items[i].item.removeData(this.widgetName + "-item"); |
|
3587 } |
|
3588 |
|
3589 return this; |
|
3590 }, |
|
3591 |
|
3592 _setOption: function(key, value){ |
|
3593 if ( key === "disabled" ) { |
|
3594 this.options[ key ] = value; |
|
3595 |
|
3596 this.widget().toggleClass( "ui-sortable-disabled", !!value ); |
|
3597 } else { |
|
3598 // Don't call widget base _setOption for disable as it adds ui-state-disabled class |
|
3599 $.Widget.prototype._setOption.apply(this, arguments); |
|
3600 } |
|
3601 }, |
|
3602 |
|
3603 _mouseCapture: function(event, overrideHandle) { |
|
3604 var currentItem = null, |
|
3605 validHandle = false, |
|
3606 that = this; |
|
3607 |
|
3608 if (this.reverting) { |
|
3609 return false; |
|
3610 } |
|
3611 |
|
3612 if(this.options.disabled || this.options.type === "static") { |
|
3613 return false; |
|
3614 } |
|
3615 |
|
3616 //We have to refresh the items data once first |
|
3617 this._refreshItems(event); |
|
3618 |
|
3619 //Find out if the clicked node (or one of its parents) is a actual item in this.items |
|
3620 $(event.target).parents().each(function() { |
|
3621 if($.data(this, that.widgetName + "-item") === that) { |
|
3622 currentItem = $(this); |
|
3623 return false; |
|
3624 } |
|
3625 }); |
|
3626 if($.data(event.target, that.widgetName + "-item") === that) { |
|
3627 currentItem = $(event.target); |
|
3628 } |
|
3629 |
|
3630 if(!currentItem) { |
|
3631 return false; |
|
3632 } |
|
3633 if(this.options.handle && !overrideHandle) { |
|
3634 $(this.options.handle, currentItem).find("*").addBack().each(function() { |
|
3635 if(this === event.target) { |
|
3636 validHandle = true; |
|
3637 } |
|
3638 }); |
|
3639 if(!validHandle) { |
|
3640 return false; |
|
3641 } |
|
3642 } |
|
3643 |
|
3644 this.currentItem = currentItem; |
|
3645 this._removeCurrentsFromItems(); |
|
3646 return true; |
|
3647 |
|
3648 }, |
|
3649 |
|
3650 _mouseStart: function(event, overrideHandle, noActivation) { |
|
3651 |
|
3652 var i, body, |
|
3653 o = this.options; |
|
3654 |
|
3655 this.currentContainer = this; |
|
3656 |
|
3657 //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture |
|
3658 this.refreshPositions(); |
|
3659 |
|
3660 //Create and append the visible helper |
|
3661 this.helper = this._createHelper(event); |
|
3662 |
|
3663 //Cache the helper size |
|
3664 this._cacheHelperProportions(); |
|
3665 |
|
3666 /* |
|
3667 * - Position generation - |
|
3668 * This block generates everything position related - it's the core of draggables. |
|
3669 */ |
|
3670 |
|
3671 //Cache the margins of the original element |
|
3672 this._cacheMargins(); |
|
3673 |
|
3674 //Get the next scrolling parent |
|
3675 this.scrollParent = this.helper.scrollParent(); |
|
3676 |
|
3677 //The element's absolute position on the page minus margins |
|
3678 this.offset = this.currentItem.offset(); |
|
3679 this.offset = { |
|
3680 top: this.offset.top - this.margins.top, |
|
3681 left: this.offset.left - this.margins.left |
|
3682 }; |
|
3683 |
|
3684 $.extend(this.offset, { |
|
3685 click: { //Where the click happened, relative to the element |
|
3686 left: event.pageX - this.offset.left, |
|
3687 top: event.pageY - this.offset.top |
|
3688 }, |
|
3689 parent: this._getParentOffset(), |
|
3690 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper |
|
3691 }); |
|
3692 |
|
3693 // Only after we got the offset, we can change the helper's position to absolute |
|
3694 // TODO: Still need to figure out a way to make relative sorting possible |
|
3695 this.helper.css("position", "absolute"); |
|
3696 this.cssPosition = this.helper.css("position"); |
|
3697 |
|
3698 //Generate the original position |
|
3699 this.originalPosition = this._generatePosition(event); |
|
3700 this.originalPageX = event.pageX; |
|
3701 this.originalPageY = event.pageY; |
|
3702 |
|
3703 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied |
|
3704 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); |
|
3705 |
|
3706 //Cache the former DOM position |
|
3707 this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; |
|
3708 |
|
3709 //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way |
|
3710 if(this.helper[0] !== this.currentItem[0]) { |
|
3711 this.currentItem.hide(); |
|
3712 } |
|
3713 |
|
3714 //Create the placeholder |
|
3715 this._createPlaceholder(); |
|
3716 |
|
3717 //Set a containment if given in the options |
|
3718 if(o.containment) { |
|
3719 this._setContainment(); |
|
3720 } |
|
3721 |
|
3722 if( o.cursor && o.cursor !== "auto" ) { // cursor option |
|
3723 body = this.document.find( "body" ); |
|
3724 |
|
3725 // support: IE |
|
3726 this.storedCursor = body.css( "cursor" ); |
|
3727 body.css( "cursor", o.cursor ); |
|
3728 |
|
3729 this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body ); |
|
3730 } |
|
3731 |
|
3732 if(o.opacity) { // opacity option |
|
3733 if (this.helper.css("opacity")) { |
|
3734 this._storedOpacity = this.helper.css("opacity"); |
|
3735 } |
|
3736 this.helper.css("opacity", o.opacity); |
|
3737 } |
|
3738 |
|
3739 if(o.zIndex) { // zIndex option |
|
3740 if (this.helper.css("zIndex")) { |
|
3741 this._storedZIndex = this.helper.css("zIndex"); |
|
3742 } |
|
3743 this.helper.css("zIndex", o.zIndex); |
|
3744 } |
|
3745 |
|
3746 //Prepare scrolling |
|
3747 if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") { |
|
3748 this.overflowOffset = this.scrollParent.offset(); |
|
3749 } |
|
3750 |
|
3751 //Call callbacks |
|
3752 this._trigger("start", event, this._uiHash()); |
|
3753 |
|
3754 //Recache the helper size |
|
3755 if(!this._preserveHelperProportions) { |
|
3756 this._cacheHelperProportions(); |
|
3757 } |
|
3758 |
|
3759 |
|
3760 //Post "activate" events to possible containers |
|
3761 if( !noActivation ) { |
|
3762 for ( i = this.containers.length - 1; i >= 0; i-- ) { |
|
3763 this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); |
|
3764 } |
|
3765 } |
|
3766 |
|
3767 //Prepare possible droppables |
|
3768 if($.ui.ddmanager) { |
|
3769 $.ui.ddmanager.current = this; |
|
3770 } |
|
3771 |
|
3772 if ($.ui.ddmanager && !o.dropBehaviour) { |
|
3773 $.ui.ddmanager.prepareOffsets(this, event); |
|
3774 } |
|
3775 |
|
3776 this.dragging = true; |
|
3777 |
|
3778 this.helper.addClass("ui-sortable-helper"); |
|
3779 this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
|
3780 return true; |
|
3781 |
|
3782 }, |
|
3783 |
|
3784 _mouseDrag: function(event) { |
|
3785 var i, item, itemElement, intersection, |
|
3786 o = this.options, |
|
3787 scrolled = false; |
|
3788 |
|
3789 //Compute the helpers position |
|
3790 this.position = this._generatePosition(event); |
|
3791 this.positionAbs = this._convertPositionTo("absolute"); |
|
3792 |
|
3793 if (!this.lastPositionAbs) { |
|
3794 this.lastPositionAbs = this.positionAbs; |
|
3795 } |
|
3796 |
|
3797 //Do scrolling |
|
3798 if(this.options.scroll) { |
|
3799 if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") { |
|
3800 |
|
3801 if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) { |
|
3802 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; |
|
3803 } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) { |
|
3804 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; |
|
3805 } |
|
3806 |
|
3807 if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) { |
|
3808 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; |
|
3809 } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) { |
|
3810 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; |
|
3811 } |
|
3812 |
|
3813 } else { |
|
3814 |
|
3815 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) { |
|
3816 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
|
3817 } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) { |
|
3818 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
|
3819 } |
|
3820 |
|
3821 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) { |
|
3822 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
|
3823 } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) { |
|
3824 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
|
3825 } |
|
3826 |
|
3827 } |
|
3828 |
|
3829 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { |
|
3830 $.ui.ddmanager.prepareOffsets(this, event); |
|
3831 } |
|
3832 } |
|
3833 |
|
3834 //Regenerate the absolute position used for position checks |
|
3835 this.positionAbs = this._convertPositionTo("absolute"); |
|
3836 |
|
3837 //Set the helper position |
|
3838 if(!this.options.axis || this.options.axis !== "y") { |
|
3839 this.helper[0].style.left = this.position.left+"px"; |
|
3840 } |
|
3841 if(!this.options.axis || this.options.axis !== "x") { |
|
3842 this.helper[0].style.top = this.position.top+"px"; |
|
3843 } |
|
3844 |
|
3845 //Rearrange |
|
3846 for (i = this.items.length - 1; i >= 0; i--) { |
|
3847 |
|
3848 //Cache variables and intersection, continue if no intersection |
|
3849 item = this.items[i]; |
|
3850 itemElement = item.item[0]; |
|
3851 intersection = this._intersectsWithPointer(item); |
|
3852 if (!intersection) { |
|
3853 continue; |
|
3854 } |
|
3855 |
|
3856 // Only put the placeholder inside the current Container, skip all |
|
3857 // items form other containers. This works because when moving |
|
3858 // an item from one container to another the |
|
3859 // currentContainer is switched before the placeholder is moved. |
|
3860 // |
|
3861 // Without this moving items in "sub-sortables" can cause the placeholder to jitter |
|
3862 // beetween the outer and inner container. |
|
3863 if (item.instance !== this.currentContainer) { |
|
3864 continue; |
|
3865 } |
|
3866 |
|
3867 // cannot intersect with itself |
|
3868 // no useless actions that have been done before |
|
3869 // no action if the item moved is the parent of the item checked |
|
3870 if (itemElement !== this.currentItem[0] && |
|
3871 this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement && |
|
3872 !$.contains(this.placeholder[0], itemElement) && |
|
3873 (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true) |
|
3874 ) { |
|
3875 |
|
3876 this.direction = intersection === 1 ? "down" : "up"; |
|
3877 |
|
3878 if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) { |
|
3879 this._rearrange(event, item); |
|
3880 } else { |
|
3881 break; |
|
3882 } |
|
3883 |
|
3884 this._trigger("change", event, this._uiHash()); |
|
3885 break; |
|
3886 } |
|
3887 } |
|
3888 |
|
3889 //Post events to containers |
|
3890 this._contactContainers(event); |
|
3891 |
|
3892 //Interconnect with droppables |
|
3893 if($.ui.ddmanager) { |
|
3894 $.ui.ddmanager.drag(this, event); |
|
3895 } |
|
3896 |
|
3897 //Call callbacks |
|
3898 this._trigger("sort", event, this._uiHash()); |
|
3899 |
|
3900 this.lastPositionAbs = this.positionAbs; |
|
3901 return false; |
|
3902 |
|
3903 }, |
|
3904 |
|
3905 _mouseStop: function(event, noPropagation) { |
|
3906 |
|
3907 if(!event) { |
|
3908 return; |
|
3909 } |
|
3910 |
|
3911 //If we are using droppables, inform the manager about the drop |
|
3912 if ($.ui.ddmanager && !this.options.dropBehaviour) { |
|
3913 $.ui.ddmanager.drop(this, event); |
|
3914 } |
|
3915 |
|
3916 if(this.options.revert) { |
|
3917 var that = this, |
|
3918 cur = this.placeholder.offset(), |
|
3919 axis = this.options.axis, |
|
3920 animation = {}; |
|
3921 |
|
3922 if ( !axis || axis === "x" ) { |
|
3923 animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft); |
|
3924 } |
|
3925 if ( !axis || axis === "y" ) { |
|
3926 animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop); |
|
3927 } |
|
3928 this.reverting = true; |
|
3929 $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() { |
|
3930 that._clear(event); |
|
3931 }); |
|
3932 } else { |
|
3933 this._clear(event, noPropagation); |
|
3934 } |
|
3935 |
|
3936 return false; |
|
3937 |
|
3938 }, |
|
3939 |
|
3940 cancel: function() { |
|
3941 |
|
3942 if(this.dragging) { |
|
3943 |
|
3944 this._mouseUp({ target: null }); |
|
3945 |
|
3946 if(this.options.helper === "original") { |
|
3947 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); |
|
3948 } else { |
|
3949 this.currentItem.show(); |
|
3950 } |
|
3951 |
|
3952 //Post deactivating events to containers |
|
3953 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3954 this.containers[i]._trigger("deactivate", null, this._uiHash(this)); |
|
3955 if(this.containers[i].containerCache.over) { |
|
3956 this.containers[i]._trigger("out", null, this._uiHash(this)); |
|
3957 this.containers[i].containerCache.over = 0; |
|
3958 } |
|
3959 } |
|
3960 |
|
3961 } |
|
3962 |
|
3963 if (this.placeholder) { |
|
3964 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
|
3965 if(this.placeholder[0].parentNode) { |
|
3966 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
|
3967 } |
|
3968 if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) { |
|
3969 this.helper.remove(); |
|
3970 } |
|
3971 |
|
3972 $.extend(this, { |
|
3973 helper: null, |
|
3974 dragging: false, |
|
3975 reverting: false, |
|
3976 _noFinalSort: null |
|
3977 }); |
|
3978 |
|
3979 if(this.domPosition.prev) { |
|
3980 $(this.domPosition.prev).after(this.currentItem); |
|
3981 } else { |
|
3982 $(this.domPosition.parent).prepend(this.currentItem); |
|
3983 } |
|
3984 } |
|
3985 |
|
3986 return this; |
|
3987 |
|
3988 }, |
|
3989 |
|
3990 serialize: function(o) { |
|
3991 |
|
3992 var items = this._getItemsAsjQuery(o && o.connected), |
|
3993 str = []; |
|
3994 o = o || {}; |
|
3995 |
|
3996 $(items).each(function() { |
|
3997 var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/)); |
|
3998 if (res) { |
|
3999 str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2])); |
|
4000 } |
|
4001 }); |
|
4002 |
|
4003 if(!str.length && o.key) { |
|
4004 str.push(o.key + "="); |
|
4005 } |
|
4006 |
|
4007 return str.join("&"); |
|
4008 |
|
4009 }, |
|
4010 |
|
4011 toArray: function(o) { |
|
4012 |
|
4013 var items = this._getItemsAsjQuery(o && o.connected), |
|
4014 ret = []; |
|
4015 |
|
4016 o = o || {}; |
|
4017 |
|
4018 items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); }); |
|
4019 return ret; |
|
4020 |
|
4021 }, |
|
4022 |
|
4023 /* Be careful with the following core functions */ |
|
4024 _intersectsWith: function(item) { |
|
4025 |
|
4026 var x1 = this.positionAbs.left, |
|
4027 x2 = x1 + this.helperProportions.width, |
|
4028 y1 = this.positionAbs.top, |
|
4029 y2 = y1 + this.helperProportions.height, |
|
4030 l = item.left, |
|
4031 r = l + item.width, |
|
4032 t = item.top, |
|
4033 b = t + item.height, |
|
4034 dyClick = this.offset.click.top, |
|
4035 dxClick = this.offset.click.left, |
|
4036 isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ), |
|
4037 isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ), |
|
4038 isOverElement = isOverElementHeight && isOverElementWidth; |
|
4039 |
|
4040 if ( this.options.tolerance === "pointer" || |
|
4041 this.options.forcePointerForContainers || |
|
4042 (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"]) |
|
4043 ) { |
|
4044 return isOverElement; |
|
4045 } else { |
|
4046 |
|
4047 return (l < x1 + (this.helperProportions.width / 2) && // Right Half |
|
4048 x2 - (this.helperProportions.width / 2) < r && // Left Half |
|
4049 t < y1 + (this.helperProportions.height / 2) && // Bottom Half |
|
4050 y2 - (this.helperProportions.height / 2) < b ); // Top Half |
|
4051 |
|
4052 } |
|
4053 }, |
|
4054 |
|
4055 _intersectsWithPointer: function(item) { |
|
4056 |
|
4057 var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), |
|
4058 isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), |
|
4059 isOverElement = isOverElementHeight && isOverElementWidth, |
|
4060 verticalDirection = this._getDragVerticalDirection(), |
|
4061 horizontalDirection = this._getDragHorizontalDirection(); |
|
4062 |
|
4063 if (!isOverElement) { |
|
4064 return false; |
|
4065 } |
|
4066 |
|
4067 return this.floating ? |
|
4068 ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 ) |
|
4069 : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) ); |
|
4070 |
|
4071 }, |
|
4072 |
|
4073 _intersectsWithSides: function(item) { |
|
4074 |
|
4075 var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), |
|
4076 isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), |
|
4077 verticalDirection = this._getDragVerticalDirection(), |
|
4078 horizontalDirection = this._getDragHorizontalDirection(); |
|
4079 |
|
4080 if (this.floating && horizontalDirection) { |
|
4081 return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf)); |
|
4082 } else { |
|
4083 return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf)); |
|
4084 } |
|
4085 |
|
4086 }, |
|
4087 |
|
4088 _getDragVerticalDirection: function() { |
|
4089 var delta = this.positionAbs.top - this.lastPositionAbs.top; |
|
4090 return delta !== 0 && (delta > 0 ? "down" : "up"); |
|
4091 }, |
|
4092 |
|
4093 _getDragHorizontalDirection: function() { |
|
4094 var delta = this.positionAbs.left - this.lastPositionAbs.left; |
|
4095 return delta !== 0 && (delta > 0 ? "right" : "left"); |
|
4096 }, |
|
4097 |
|
4098 refresh: function(event) { |
|
4099 this._refreshItems(event); |
|
4100 this.refreshPositions(); |
|
4101 return this; |
|
4102 }, |
|
4103 |
|
4104 _connectWith: function() { |
|
4105 var options = this.options; |
|
4106 return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith; |
|
4107 }, |
|
4108 |
|
4109 _getItemsAsjQuery: function(connected) { |
|
4110 |
|
4111 var i, j, cur, inst, |
|
4112 items = [], |
|
4113 queries = [], |
|
4114 connectWith = this._connectWith(); |
|
4115 |
|
4116 if(connectWith && connected) { |
|
4117 for (i = connectWith.length - 1; i >= 0; i--){ |
|
4118 cur = $(connectWith[i]); |
|
4119 for ( j = cur.length - 1; j >= 0; j--){ |
|
4120 inst = $.data(cur[j], this.widgetFullName); |
|
4121 if(inst && inst !== this && !inst.options.disabled) { |
|
4122 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]); |
|
4123 } |
|
4124 } |
|
4125 } |
|
4126 } |
|
4127 |
|
4128 queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]); |
|
4129 |
|
4130 for (i = queries.length - 1; i >= 0; i--){ |
|
4131 queries[i][0].each(function() { |
|
4132 items.push(this); |
|
4133 }); |
|
4134 } |
|
4135 |
|
4136 return $(items); |
|
4137 |
|
4138 }, |
|
4139 |
|
4140 _removeCurrentsFromItems: function() { |
|
4141 |
|
4142 var list = this.currentItem.find(":data(" + this.widgetName + "-item)"); |
|
4143 |
|
4144 this.items = $.grep(this.items, function (item) { |
|
4145 for (var j=0; j < list.length; j++) { |
|
4146 if(list[j] === item.item[0]) { |
|
4147 return false; |
|
4148 } |
|
4149 } |
|
4150 return true; |
|
4151 }); |
|
4152 |
|
4153 }, |
|
4154 |
|
4155 _refreshItems: function(event) { |
|
4156 |
|
4157 this.items = []; |
|
4158 this.containers = [this]; |
|
4159 |
|
4160 var i, j, cur, inst, targetData, _queries, item, queriesLength, |
|
4161 items = this.items, |
|
4162 queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]], |
|
4163 connectWith = this._connectWith(); |
|
4164 |
|
4165 if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down |
|
4166 for (i = connectWith.length - 1; i >= 0; i--){ |
|
4167 cur = $(connectWith[i]); |
|
4168 for (j = cur.length - 1; j >= 0; j--){ |
|
4169 inst = $.data(cur[j], this.widgetFullName); |
|
4170 if(inst && inst !== this && !inst.options.disabled) { |
|
4171 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); |
|
4172 this.containers.push(inst); |
|
4173 } |
|
4174 } |
|
4175 } |
|
4176 } |
|
4177 |
|
4178 for (i = queries.length - 1; i >= 0; i--) { |
|
4179 targetData = queries[i][1]; |
|
4180 _queries = queries[i][0]; |
|
4181 |
|
4182 for (j=0, queriesLength = _queries.length; j < queriesLength; j++) { |
|
4183 item = $(_queries[j]); |
|
4184 |
|
4185 item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager) |
|
4186 |
|
4187 items.push({ |
|
4188 item: item, |
|
4189 instance: targetData, |
|
4190 width: 0, height: 0, |
|
4191 left: 0, top: 0 |
|
4192 }); |
|
4193 } |
|
4194 } |
|
4195 |
|
4196 }, |
|
4197 |
|
4198 refreshPositions: function(fast) { |
|
4199 |
|
4200 //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change |
|
4201 if(this.offsetParent && this.helper) { |
|
4202 this.offset.parent = this._getParentOffset(); |
|
4203 } |
|
4204 |
|
4205 var i, item, t, p; |
|
4206 |
|
4207 for (i = this.items.length - 1; i >= 0; i--){ |
|
4208 item = this.items[i]; |
|
4209 |
|
4210 //We ignore calculating positions of all connected containers when we're not over them |
|
4211 if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) { |
|
4212 continue; |
|
4213 } |
|
4214 |
|
4215 t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; |
|
4216 |
|
4217 if (!fast) { |
|
4218 item.width = t.outerWidth(); |
|
4219 item.height = t.outerHeight(); |
|
4220 } |
|
4221 |
|
4222 p = t.offset(); |
|
4223 item.left = p.left; |
|
4224 item.top = p.top; |
|
4225 } |
|
4226 |
|
4227 if(this.options.custom && this.options.custom.refreshContainers) { |
|
4228 this.options.custom.refreshContainers.call(this); |
|
4229 } else { |
|
4230 for (i = this.containers.length - 1; i >= 0; i--){ |
|
4231 p = this.containers[i].element.offset(); |
|
4232 this.containers[i].containerCache.left = p.left; |
|
4233 this.containers[i].containerCache.top = p.top; |
|
4234 this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); |
|
4235 this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); |
|
4236 } |
|
4237 } |
|
4238 |
|
4239 return this; |
|
4240 }, |
|
4241 |
|
4242 _createPlaceholder: function(that) { |
|
4243 that = that || this; |
|
4244 var className, |
|
4245 o = that.options; |
|
4246 |
|
4247 if(!o.placeholder || o.placeholder.constructor === String) { |
|
4248 className = o.placeholder; |
|
4249 o.placeholder = { |
|
4250 element: function() { |
|
4251 |
|
4252 var nodeName = that.currentItem[0].nodeName.toLowerCase(), |
|
4253 element = $( "<" + nodeName + ">", that.document[0] ) |
|
4254 .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") |
|
4255 .removeClass("ui-sortable-helper"); |
|
4256 |
|
4257 if ( nodeName === "tr" ) { |
|
4258 that.currentItem.children().each(function() { |
|
4259 $( "<td> </td>", that.document[0] ) |
|
4260 .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) |
|
4261 .appendTo( element ); |
|
4262 }); |
|
4263 } else if ( nodeName === "img" ) { |
|
4264 element.attr( "src", that.currentItem.attr( "src" ) ); |
|
4265 } |
|
4266 |
|
4267 if ( !className ) { |
|
4268 element.css( "visibility", "hidden" ); |
|
4269 } |
|
4270 |
|
4271 return element; |
|
4272 }, |
|
4273 update: function(container, p) { |
|
4274 |
|
4275 // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that |
|
4276 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified |
|
4277 if(className && !o.forcePlaceholderSize) { |
|
4278 return; |
|
4279 } |
|
4280 |
|
4281 //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item |
|
4282 if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); } |
|
4283 if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); } |
|
4284 } |
|
4285 }; |
|
4286 } |
|
4287 |
|
4288 //Create the placeholder |
|
4289 that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem)); |
|
4290 |
|
4291 //Append it after the actual current item |
|
4292 that.currentItem.after(that.placeholder); |
|
4293 |
|
4294 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) |
|
4295 o.placeholder.update(that, that.placeholder); |
|
4296 |
|
4297 }, |
|
4298 |
|
4299 _contactContainers: function(event) { |
|
4300 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating, |
|
4301 innermostContainer = null, |
|
4302 innermostIndex = null; |
|
4303 |
|
4304 // get innermost container that intersects with item |
|
4305 for (i = this.containers.length - 1; i >= 0; i--) { |
|
4306 |
|
4307 // never consider a container that's located within the item itself |
|
4308 if($.contains(this.currentItem[0], this.containers[i].element[0])) { |
|
4309 continue; |
|
4310 } |
|
4311 |
|
4312 if(this._intersectsWith(this.containers[i].containerCache)) { |
|
4313 |
|
4314 // if we've already found a container and it's more "inner" than this, then continue |
|
4315 if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) { |
|
4316 continue; |
|
4317 } |
|
4318 |
|
4319 innermostContainer = this.containers[i]; |
|
4320 innermostIndex = i; |
|
4321 |
|
4322 } else { |
|
4323 // container doesn't intersect. trigger "out" event if necessary |
|
4324 if(this.containers[i].containerCache.over) { |
|
4325 this.containers[i]._trigger("out", event, this._uiHash(this)); |
|
4326 this.containers[i].containerCache.over = 0; |
|
4327 } |
|
4328 } |
|
4329 |
|
4330 } |
|
4331 |
|
4332 // if no intersecting containers found, return |
|
4333 if(!innermostContainer) { |
|
4334 return; |
|
4335 } |
|
4336 |
|
4337 // move the item into the container if it's not there already |
|
4338 if(this.containers.length === 1) { |
|
4339 if (!this.containers[innermostIndex].containerCache.over) { |
|
4340 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); |
|
4341 this.containers[innermostIndex].containerCache.over = 1; |
|
4342 } |
|
4343 } else { |
|
4344 |
|
4345 //When entering a new container, we will find the item with the least distance and append our item near it |
|
4346 dist = 10000; |
|
4347 itemWithLeastDistance = null; |
|
4348 floating = innermostContainer.floating || isFloating(this.currentItem); |
|
4349 posProperty = floating ? "left" : "top"; |
|
4350 sizeProperty = floating ? "width" : "height"; |
|
4351 base = this.positionAbs[posProperty] + this.offset.click[posProperty]; |
|
4352 for (j = this.items.length - 1; j >= 0; j--) { |
|
4353 if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) { |
|
4354 continue; |
|
4355 } |
|
4356 if(this.items[j].item[0] === this.currentItem[0]) { |
|
4357 continue; |
|
4358 } |
|
4359 if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) { |
|
4360 continue; |
|
4361 } |
|
4362 cur = this.items[j].item.offset()[posProperty]; |
|
4363 nearBottom = false; |
|
4364 if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){ |
|
4365 nearBottom = true; |
|
4366 cur += this.items[j][sizeProperty]; |
|
4367 } |
|
4368 |
|
4369 if(Math.abs(cur - base) < dist) { |
|
4370 dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; |
|
4371 this.direction = nearBottom ? "up": "down"; |
|
4372 } |
|
4373 } |
|
4374 |
|
4375 //Check if dropOnEmpty is enabled |
|
4376 if(!itemWithLeastDistance && !this.options.dropOnEmpty) { |
|
4377 return; |
|
4378 } |
|
4379 |
|
4380 if(this.currentContainer === this.containers[innermostIndex]) { |
|
4381 return; |
|
4382 } |
|
4383 |
|
4384 itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); |
|
4385 this._trigger("change", event, this._uiHash()); |
|
4386 this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); |
|
4387 this.currentContainer = this.containers[innermostIndex]; |
|
4388 |
|
4389 //Update the placeholder |
|
4390 this.options.placeholder.update(this.currentContainer, this.placeholder); |
|
4391 |
|
4392 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); |
|
4393 this.containers[innermostIndex].containerCache.over = 1; |
|
4394 } |
|
4395 |
|
4396 |
|
4397 }, |
|
4398 |
|
4399 _createHelper: function(event) { |
|
4400 |
|
4401 var o = this.options, |
|
4402 helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem); |
|
4403 |
|
4404 //Add the helper to the DOM if that didn't happen already |
|
4405 if(!helper.parents("body").length) { |
|
4406 $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); |
|
4407 } |
|
4408 |
|
4409 if(helper[0] === this.currentItem[0]) { |
|
4410 this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") }; |
|
4411 } |
|
4412 |
|
4413 if(!helper[0].style.width || o.forceHelperSize) { |
|
4414 helper.width(this.currentItem.width()); |
|
4415 } |
|
4416 if(!helper[0].style.height || o.forceHelperSize) { |
|
4417 helper.height(this.currentItem.height()); |
|
4418 } |
|
4419 |
|
4420 return helper; |
|
4421 |
|
4422 }, |
|
4423 |
|
4424 _adjustOffsetFromHelper: function(obj) { |
|
4425 if (typeof obj === "string") { |
|
4426 obj = obj.split(" "); |
|
4427 } |
|
4428 if ($.isArray(obj)) { |
|
4429 obj = {left: +obj[0], top: +obj[1] || 0}; |
|
4430 } |
|
4431 if ("left" in obj) { |
|
4432 this.offset.click.left = obj.left + this.margins.left; |
|
4433 } |
|
4434 if ("right" in obj) { |
|
4435 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
|
4436 } |
|
4437 if ("top" in obj) { |
|
4438 this.offset.click.top = obj.top + this.margins.top; |
|
4439 } |
|
4440 if ("bottom" in obj) { |
|
4441 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
|
4442 } |
|
4443 }, |
|
4444 |
|
4445 _getParentOffset: function() { |
|
4446 |
|
4447 |
|
4448 //Get the offsetParent and cache its position |
|
4449 this.offsetParent = this.helper.offsetParent(); |
|
4450 var po = this.offsetParent.offset(); |
|
4451 |
|
4452 // This is a special case where we need to modify a offset calculated on start, since the following happened: |
|
4453 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
|
4454 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
|
4455 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
|
4456 if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) { |
|
4457 po.left += this.scrollParent.scrollLeft(); |
|
4458 po.top += this.scrollParent.scrollTop(); |
|
4459 } |
|
4460 |
|
4461 // This needs to be actually done for all browsers, since pageX/pageY includes this information |
|
4462 // with an ugly IE fix |
|
4463 if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) { |
|
4464 po = { top: 0, left: 0 }; |
|
4465 } |
|
4466 |
|
4467 return { |
|
4468 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
|
4469 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
|
4470 }; |
|
4471 |
|
4472 }, |
|
4473 |
|
4474 _getRelativeOffset: function() { |
|
4475 |
|
4476 if(this.cssPosition === "relative") { |
|
4477 var p = this.currentItem.position(); |
|
4478 return { |
|
4479 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
|
4480 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() |
|
4481 }; |
|
4482 } else { |
|
4483 return { top: 0, left: 0 }; |
|
4484 } |
|
4485 |
|
4486 }, |
|
4487 |
|
4488 _cacheMargins: function() { |
|
4489 this.margins = { |
|
4490 left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), |
|
4491 top: (parseInt(this.currentItem.css("marginTop"),10) || 0) |
|
4492 }; |
|
4493 }, |
|
4494 |
|
4495 _cacheHelperProportions: function() { |
|
4496 this.helperProportions = { |
|
4497 width: this.helper.outerWidth(), |
|
4498 height: this.helper.outerHeight() |
|
4499 }; |
|
4500 }, |
|
4501 |
|
4502 _setContainment: function() { |
|
4503 |
|
4504 var ce, co, over, |
|
4505 o = this.options; |
|
4506 if(o.containment === "parent") { |
|
4507 o.containment = this.helper[0].parentNode; |
|
4508 } |
|
4509 if(o.containment === "document" || o.containment === "window") { |
|
4510 this.containment = [ |
|
4511 0 - this.offset.relative.left - this.offset.parent.left, |
|
4512 0 - this.offset.relative.top - this.offset.parent.top, |
|
4513 $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left, |
|
4514 ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top |
|
4515 ]; |
|
4516 } |
|
4517 |
|
4518 if(!(/^(document|window|parent)$/).test(o.containment)) { |
|
4519 ce = $(o.containment)[0]; |
|
4520 co = $(o.containment).offset(); |
|
4521 over = ($(ce).css("overflow") !== "hidden"); |
|
4522 |
|
4523 this.containment = [ |
|
4524 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, |
|
4525 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, |
|
4526 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, |
|
4527 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top |
|
4528 ]; |
|
4529 } |
|
4530 |
|
4531 }, |
|
4532 |
|
4533 _convertPositionTo: function(d, pos) { |
|
4534 |
|
4535 if(!pos) { |
|
4536 pos = this.position; |
|
4537 } |
|
4538 var mod = d === "absolute" ? 1 : -1, |
|
4539 scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, |
|
4540 scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
4541 |
|
4542 return { |
|
4543 top: ( |
|
4544 pos.top + // The absolute mouse position |
|
4545 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent |
|
4546 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) |
|
4547 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) |
|
4548 ), |
|
4549 left: ( |
|
4550 pos.left + // The absolute mouse position |
|
4551 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent |
|
4552 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) |
|
4553 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) |
|
4554 ) |
|
4555 }; |
|
4556 |
|
4557 }, |
|
4558 |
|
4559 _generatePosition: function(event) { |
|
4560 |
|
4561 var top, left, |
|
4562 o = this.options, |
|
4563 pageX = event.pageX, |
|
4564 pageY = event.pageY, |
|
4565 scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
4566 |
|
4567 // This is another very weird special case that only happens for relative elements: |
|
4568 // 1. If the css position is relative |
|
4569 // 2. and the scroll parent is the document or similar to the offset parent |
|
4570 // we have to refresh the relative offset during the scroll so there are no jumps |
|
4571 if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) { |
|
4572 this.offset.relative = this._getRelativeOffset(); |
|
4573 } |
|
4574 |
|
4575 /* |
|
4576 * - Position constraining - |
|
4577 * Constrain the position to a mix of grid, containment. |
|
4578 */ |
|
4579 |
|
4580 if(this.originalPosition) { //If we are not dragging yet, we won't check for options |
|
4581 |
|
4582 if(this.containment) { |
|
4583 if(event.pageX - this.offset.click.left < this.containment[0]) { |
|
4584 pageX = this.containment[0] + this.offset.click.left; |
|
4585 } |
|
4586 if(event.pageY - this.offset.click.top < this.containment[1]) { |
|
4587 pageY = this.containment[1] + this.offset.click.top; |
|
4588 } |
|
4589 if(event.pageX - this.offset.click.left > this.containment[2]) { |
|
4590 pageX = this.containment[2] + this.offset.click.left; |
|
4591 } |
|
4592 if(event.pageY - this.offset.click.top > this.containment[3]) { |
|
4593 pageY = this.containment[3] + this.offset.click.top; |
|
4594 } |
|
4595 } |
|
4596 |
|
4597 if(o.grid) { |
|
4598 top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; |
|
4599 pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
4600 |
|
4601 left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; |
|
4602 pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; |
|
4603 } |
|
4604 |
|
4605 } |
|
4606 |
|
4607 return { |
|
4608 top: ( |
|
4609 pageY - // The absolute mouse position |
|
4610 this.offset.click.top - // Click offset (relative to the element) |
|
4611 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent |
|
4612 this.offset.parent.top + // The offsetParent's offset without borders (offset + border) |
|
4613 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) |
|
4614 ), |
|
4615 left: ( |
|
4616 pageX - // The absolute mouse position |
|
4617 this.offset.click.left - // Click offset (relative to the element) |
|
4618 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent |
|
4619 this.offset.parent.left + // The offsetParent's offset without borders (offset + border) |
|
4620 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) |
|
4621 ) |
|
4622 }; |
|
4623 |
|
4624 }, |
|
4625 |
|
4626 _rearrange: function(event, i, a, hardRefresh) { |
|
4627 |
|
4628 a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling)); |
|
4629 |
|
4630 //Various things done here to improve the performance: |
|
4631 // 1. we create a setTimeout, that calls refreshPositions |
|
4632 // 2. on the instance, we have a counter variable, that get's higher after every append |
|
4633 // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same |
|
4634 // 4. this lets only the last addition to the timeout stack through |
|
4635 this.counter = this.counter ? ++this.counter : 1; |
|
4636 var counter = this.counter; |
|
4637 |
|
4638 this._delay(function() { |
|
4639 if(counter === this.counter) { |
|
4640 this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove |
|
4641 } |
|
4642 }); |
|
4643 |
|
4644 }, |
|
4645 |
|
4646 _clear: function(event, noPropagation) { |
|
4647 |
|
4648 this.reverting = false; |
|
4649 // We delay all events that have to be triggered to after the point where the placeholder has been removed and |
|
4650 // everything else normalized again |
|
4651 var i, |
|
4652 delayedTriggers = []; |
|
4653 |
|
4654 // We first have to update the dom position of the actual currentItem |
|
4655 // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) |
|
4656 if(!this._noFinalSort && this.currentItem.parent().length) { |
|
4657 this.placeholder.before(this.currentItem); |
|
4658 } |
|
4659 this._noFinalSort = null; |
|
4660 |
|
4661 if(this.helper[0] === this.currentItem[0]) { |
|
4662 for(i in this._storedCSS) { |
|
4663 if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") { |
|
4664 this._storedCSS[i] = ""; |
|
4665 } |
|
4666 } |
|
4667 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); |
|
4668 } else { |
|
4669 this.currentItem.show(); |
|
4670 } |
|
4671 |
|
4672 if(this.fromOutside && !noPropagation) { |
|
4673 delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); }); |
|
4674 } |
|
4675 if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) { |
|
4676 delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed |
|
4677 } |
|
4678 |
|
4679 // Check if the items Container has Changed and trigger appropriate |
|
4680 // events. |
|
4681 if (this !== this.currentContainer) { |
|
4682 if(!noPropagation) { |
|
4683 delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); }); |
|
4684 delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); |
|
4685 delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); |
|
4686 } |
|
4687 } |
|
4688 |
|
4689 |
|
4690 //Post events to containers |
|
4691 for (i = this.containers.length - 1; i >= 0; i--){ |
|
4692 if(!noPropagation) { |
|
4693 delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
4694 } |
|
4695 if(this.containers[i].containerCache.over) { |
|
4696 delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
4697 this.containers[i].containerCache.over = 0; |
|
4698 } |
|
4699 } |
|
4700 |
|
4701 //Do what was originally in plugins |
|
4702 if ( this.storedCursor ) { |
|
4703 this.document.find( "body" ).css( "cursor", this.storedCursor ); |
|
4704 this.storedStylesheet.remove(); |
|
4705 } |
|
4706 if(this._storedOpacity) { |
|
4707 this.helper.css("opacity", this._storedOpacity); |
|
4708 } |
|
4709 if(this._storedZIndex) { |
|
4710 this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex); |
|
4711 } |
|
4712 |
|
4713 this.dragging = false; |
|
4714 if(this.cancelHelperRemoval) { |
|
4715 if(!noPropagation) { |
|
4716 this._trigger("beforeStop", event, this._uiHash()); |
|
4717 for (i=0; i < delayedTriggers.length; i++) { |
|
4718 delayedTriggers[i].call(this, event); |
|
4719 } //Trigger all delayed events |
|
4720 this._trigger("stop", event, this._uiHash()); |
|
4721 } |
|
4722 |
|
4723 this.fromOutside = false; |
|
4724 return false; |
|
4725 } |
|
4726 |
|
4727 if(!noPropagation) { |
|
4728 this._trigger("beforeStop", event, this._uiHash()); |
|
4729 } |
|
4730 |
|
4731 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
|
4732 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
|
4733 |
|
4734 if(this.helper[0] !== this.currentItem[0]) { |
|
4735 this.helper.remove(); |
|
4736 } |
|
4737 this.helper = null; |
|
4738 |
|
4739 if(!noPropagation) { |
|
4740 for (i=0; i < delayedTriggers.length; i++) { |
|
4741 delayedTriggers[i].call(this, event); |
|
4742 } //Trigger all delayed events |
|
4743 this._trigger("stop", event, this._uiHash()); |
|
4744 } |
|
4745 |
|
4746 this.fromOutside = false; |
|
4747 return true; |
|
4748 |
|
4749 }, |
|
4750 |
|
4751 _trigger: function() { |
|
4752 if ($.Widget.prototype._trigger.apply(this, arguments) === false) { |
|
4753 this.cancel(); |
|
4754 } |
|
4755 }, |
|
4756 |
|
4757 _uiHash: function(_inst) { |
|
4758 var inst = _inst || this; |
|
4759 return { |
|
4760 helper: inst.helper, |
|
4761 placeholder: inst.placeholder || $([]), |
|
4762 position: inst.position, |
|
4763 originalPosition: inst.originalPosition, |
|
4764 offset: inst.positionAbs, |
|
4765 item: inst.currentItem, |
|
4766 sender: _inst ? _inst.element : null |
|
4767 }; |
|
4768 } |
|
4769 |
|
4770 }); |
|
4771 |
|
4772 })(jQuery); |
|
4773 |
|
4774 (function($, undefined) { |
|
4775 |
|
4776 var dataSpace = "ui-effects-"; |
|
4777 |
|
4778 $.effects = { |
|
4779 effect: {} |
|
4780 }; |
|
4781 |
1044 |
4782 /*! |
1045 /*! |
4783 * jQuery Color Animations v2.1.2 |
1046 * jQuery UI Position 1.11.4 |
4784 * https://github.com/jquery/jquery-color |
1047 * http://jqueryui.com |
4785 * |
1048 * |
4786 * Copyright 2013 jQuery Foundation and other contributors |
1049 * Copyright jQuery Foundation and other contributors |
4787 * Released under the MIT license. |
1050 * Released under the MIT license. |
4788 * http://jquery.org/license |
1051 * http://jquery.org/license |
4789 * |
1052 * |
4790 * Date: Wed Jan 16 08:47:09 2013 -0600 |
1053 * http://api.jqueryui.com/position/ |
4791 */ |
1054 */ |
4792 (function( jQuery, undefined ) { |
1055 |
4793 |
1056 (function() { |
4794 var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", |
1057 |
4795 |
1058 $.ui = $.ui || {}; |
4796 // plusequals test for += 100 -= 100 |
1059 |
4797 rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, |
1060 var cachedScrollbarWidth, supportsOffsetFractions, |
4798 // a set of RE's that can match strings and generate color tuples. |
1061 max = Math.max, |
4799 stringParsers = [{ |
1062 abs = Math.abs, |
4800 re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, |
1063 round = Math.round, |
4801 parse: function( execResult ) { |
1064 rhorizontal = /left|center|right/, |
4802 return [ |
1065 rvertical = /top|center|bottom/, |
4803 execResult[ 1 ], |
1066 roffset = /[\+\-]\d+(\.[\d]+)?%?/, |
4804 execResult[ 2 ], |
1067 rposition = /^\w+/, |
4805 execResult[ 3 ], |
1068 rpercent = /%$/, |
4806 execResult[ 4 ] |
1069 _position = $.fn.position; |
4807 ]; |
1070 |
4808 } |
1071 function getOffsets( offsets, width, height ) { |
4809 }, { |
1072 return [ |
4810 re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, |
1073 parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), |
4811 parse: function( execResult ) { |
1074 parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) |
4812 return [ |
1075 ]; |
4813 execResult[ 1 ] * 2.55, |
1076 } |
4814 execResult[ 2 ] * 2.55, |
1077 |
4815 execResult[ 3 ] * 2.55, |
1078 function parseCss( element, property ) { |
4816 execResult[ 4 ] |
1079 return parseInt( $.css( element, property ), 10 ) || 0; |
4817 ]; |
1080 } |
4818 } |
1081 |
4819 }, { |
1082 function getDimensions( elem ) { |
4820 // this regex ignores A-F because it's compared against an already lowercased string |
1083 var raw = elem[0]; |
4821 re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, |
1084 if ( raw.nodeType === 9 ) { |
4822 parse: function( execResult ) { |
1085 return { |
4823 return [ |
1086 width: elem.width(), |
4824 parseInt( execResult[ 1 ], 16 ), |
1087 height: elem.height(), |
4825 parseInt( execResult[ 2 ], 16 ), |
1088 offset: { top: 0, left: 0 } |
4826 parseInt( execResult[ 3 ], 16 ) |
1089 }; |
4827 ]; |
1090 } |
4828 } |
1091 if ( $.isWindow( raw ) ) { |
4829 }, { |
1092 return { |
4830 // this regex ignores A-F because it's compared against an already lowercased string |
1093 width: elem.width(), |
4831 re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, |
1094 height: elem.height(), |
4832 parse: function( execResult ) { |
1095 offset: { top: elem.scrollTop(), left: elem.scrollLeft() } |
4833 return [ |
1096 }; |
4834 parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), |
1097 } |
4835 parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), |
1098 if ( raw.preventDefault ) { |
4836 parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) |
1099 return { |
4837 ]; |
1100 width: 0, |
4838 } |
1101 height: 0, |
4839 }, { |
1102 offset: { top: raw.pageY, left: raw.pageX } |
4840 re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, |
1103 }; |
4841 space: "hsla", |
1104 } |
4842 parse: function( execResult ) { |
1105 return { |
4843 return [ |
1106 width: elem.outerWidth(), |
4844 execResult[ 1 ], |
1107 height: elem.outerHeight(), |
4845 execResult[ 2 ] / 100, |
1108 offset: elem.offset() |
4846 execResult[ 3 ] / 100, |
|
4847 execResult[ 4 ] |
|
4848 ]; |
|
4849 } |
|
4850 }], |
|
4851 |
|
4852 // jQuery.Color( ) |
|
4853 color = jQuery.Color = function( color, green, blue, alpha ) { |
|
4854 return new jQuery.Color.fn.parse( color, green, blue, alpha ); |
|
4855 }, |
|
4856 spaces = { |
|
4857 rgba: { |
|
4858 props: { |
|
4859 red: { |
|
4860 idx: 0, |
|
4861 type: "byte" |
|
4862 }, |
|
4863 green: { |
|
4864 idx: 1, |
|
4865 type: "byte" |
|
4866 }, |
|
4867 blue: { |
|
4868 idx: 2, |
|
4869 type: "byte" |
|
4870 } |
|
4871 } |
|
4872 }, |
|
4873 |
|
4874 hsla: { |
|
4875 props: { |
|
4876 hue: { |
|
4877 idx: 0, |
|
4878 type: "degrees" |
|
4879 }, |
|
4880 saturation: { |
|
4881 idx: 1, |
|
4882 type: "percent" |
|
4883 }, |
|
4884 lightness: { |
|
4885 idx: 2, |
|
4886 type: "percent" |
|
4887 } |
|
4888 } |
|
4889 } |
|
4890 }, |
|
4891 propTypes = { |
|
4892 "byte": { |
|
4893 floor: true, |
|
4894 max: 255 |
|
4895 }, |
|
4896 "percent": { |
|
4897 max: 1 |
|
4898 }, |
|
4899 "degrees": { |
|
4900 mod: 360, |
|
4901 floor: true |
|
4902 } |
|
4903 }, |
|
4904 support = color.support = {}, |
|
4905 |
|
4906 // element for support tests |
|
4907 supportElem = jQuery( "<p>" )[ 0 ], |
|
4908 |
|
4909 // colors = jQuery.Color.names |
|
4910 colors, |
|
4911 |
|
4912 // local aliases of functions called often |
|
4913 each = jQuery.each; |
|
4914 |
|
4915 // determine rgba support immediately |
|
4916 supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; |
|
4917 support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; |
|
4918 |
|
4919 // define cache name and alpha properties |
|
4920 // for rgba and hsla spaces |
|
4921 each( spaces, function( spaceName, space ) { |
|
4922 space.cache = "_" + spaceName; |
|
4923 space.props.alpha = { |
|
4924 idx: 3, |
|
4925 type: "percent", |
|
4926 def: 1 |
|
4927 }; |
1109 }; |
4928 }); |
|
4929 |
|
4930 function clamp( value, prop, allowEmpty ) { |
|
4931 var type = propTypes[ prop.type ] || {}; |
|
4932 |
|
4933 if ( value == null ) { |
|
4934 return (allowEmpty || !prop.def) ? null : prop.def; |
|
4935 } |
|
4936 |
|
4937 // ~~ is an short way of doing floor for positive numbers |
|
4938 value = type.floor ? ~~value : parseFloat( value ); |
|
4939 |
|
4940 // IE will pass in empty strings as value for alpha, |
|
4941 // which will hit this case |
|
4942 if ( isNaN( value ) ) { |
|
4943 return prop.def; |
|
4944 } |
|
4945 |
|
4946 if ( type.mod ) { |
|
4947 // we add mod before modding to make sure that negatives values |
|
4948 // get converted properly: -10 -> 350 |
|
4949 return (value + type.mod) % type.mod; |
|
4950 } |
|
4951 |
|
4952 // for now all property types without mod have min and max |
|
4953 return 0 > value ? 0 : type.max < value ? type.max : value; |
|
4954 } |
1110 } |
4955 |
1111 |
4956 function stringParse( string ) { |
1112 $.position = { |
4957 var inst = color(), |
1113 scrollbarWidth: function() { |
4958 rgba = inst._rgba = []; |
1114 if ( cachedScrollbarWidth !== undefined ) { |
4959 |
1115 return cachedScrollbarWidth; |
4960 string = string.toLowerCase(); |
1116 } |
4961 |
1117 var w1, w2, |
4962 each( stringParsers, function( i, parser ) { |
1118 div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ), |
4963 var parsed, |
1119 innerDiv = div.children()[0]; |
4964 match = parser.re.exec( string ), |
1120 |
4965 values = match && parser.parse( match ), |
1121 $( "body" ).append( div ); |
4966 spaceName = parser.space || "rgba"; |
1122 w1 = innerDiv.offsetWidth; |
4967 |
1123 div.css( "overflow", "scroll" ); |
4968 if ( values ) { |
1124 |
4969 parsed = inst[ spaceName ]( values ); |
1125 w2 = innerDiv.offsetWidth; |
4970 |
1126 |
4971 // if this was an rgba parse the assignment might happen twice |
1127 if ( w1 === w2 ) { |
4972 // oh well.... |
1128 w2 = div[0].clientWidth; |
4973 inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; |
1129 } |
4974 rgba = inst._rgba = parsed._rgba; |
1130 |
4975 |
1131 div.remove(); |
4976 // exit each( stringParsers ) here because we matched |
1132 |
4977 return false; |
1133 return (cachedScrollbarWidth = w1 - w2); |
4978 } |
1134 }, |
4979 }); |
1135 getScrollInfo: function( within ) { |
4980 |
1136 var overflowX = within.isWindow || within.isDocument ? "" : |
4981 // Found a stringParser that handled it |
1137 within.element.css( "overflow-x" ), |
4982 if ( rgba.length ) { |
1138 overflowY = within.isWindow || within.isDocument ? "" : |
4983 |
1139 within.element.css( "overflow-y" ), |
4984 // if this came from a parsed string, force "transparent" when alpha is 0 |
1140 hasOverflowX = overflowX === "scroll" || |
4985 // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) |
1141 ( overflowX === "auto" && within.width < within.element[0].scrollWidth ), |
4986 if ( rgba.join() === "0,0,0,0" ) { |
1142 hasOverflowY = overflowY === "scroll" || |
4987 jQuery.extend( rgba, colors.transparent ); |
1143 ( overflowY === "auto" && within.height < within.element[0].scrollHeight ); |
4988 } |
1144 return { |
4989 return inst; |
1145 width: hasOverflowY ? $.position.scrollbarWidth() : 0, |
4990 } |
1146 height: hasOverflowX ? $.position.scrollbarWidth() : 0 |
4991 |
|
4992 // named colors |
|
4993 return colors[ string ]; |
|
4994 } |
|
4995 |
|
4996 color.fn = jQuery.extend( color.prototype, { |
|
4997 parse: function( red, green, blue, alpha ) { |
|
4998 if ( red === undefined ) { |
|
4999 this._rgba = [ null, null, null, null ]; |
|
5000 return this; |
|
5001 } |
|
5002 if ( red.jquery || red.nodeType ) { |
|
5003 red = jQuery( red ).css( green ); |
|
5004 green = undefined; |
|
5005 } |
|
5006 |
|
5007 var inst = this, |
|
5008 type = jQuery.type( red ), |
|
5009 rgba = this._rgba = []; |
|
5010 |
|
5011 // more than 1 argument specified - assume ( red, green, blue, alpha ) |
|
5012 if ( green !== undefined ) { |
|
5013 red = [ red, green, blue, alpha ]; |
|
5014 type = "array"; |
|
5015 } |
|
5016 |
|
5017 if ( type === "string" ) { |
|
5018 return this.parse( stringParse( red ) || colors._default ); |
|
5019 } |
|
5020 |
|
5021 if ( type === "array" ) { |
|
5022 each( spaces.rgba.props, function( key, prop ) { |
|
5023 rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); |
|
5024 }); |
|
5025 return this; |
|
5026 } |
|
5027 |
|
5028 if ( type === "object" ) { |
|
5029 if ( red instanceof color ) { |
|
5030 each( spaces, function( spaceName, space ) { |
|
5031 if ( red[ space.cache ] ) { |
|
5032 inst[ space.cache ] = red[ space.cache ].slice(); |
|
5033 } |
|
5034 }); |
|
5035 } else { |
|
5036 each( spaces, function( spaceName, space ) { |
|
5037 var cache = space.cache; |
|
5038 each( space.props, function( key, prop ) { |
|
5039 |
|
5040 // if the cache doesn't exist, and we know how to convert |
|
5041 if ( !inst[ cache ] && space.to ) { |
|
5042 |
|
5043 // if the value was null, we don't need to copy it |
|
5044 // if the key was alpha, we don't need to copy it either |
|
5045 if ( key === "alpha" || red[ key ] == null ) { |
|
5046 return; |
|
5047 } |
|
5048 inst[ cache ] = space.to( inst._rgba ); |
|
5049 } |
|
5050 |
|
5051 // this is the only case where we allow nulls for ALL properties. |
|
5052 // call clamp with alwaysAllowEmpty |
|
5053 inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); |
|
5054 }); |
|
5055 |
|
5056 // everything defined but alpha? |
|
5057 if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { |
|
5058 // use the default of 1 |
|
5059 inst[ cache ][ 3 ] = 1; |
|
5060 if ( space.from ) { |
|
5061 inst._rgba = space.from( inst[ cache ] ); |
|
5062 } |
|
5063 } |
|
5064 }); |
|
5065 } |
|
5066 return this; |
|
5067 } |
|
5068 }, |
|
5069 is: function( compare ) { |
|
5070 var is = color( compare ), |
|
5071 same = true, |
|
5072 inst = this; |
|
5073 |
|
5074 each( spaces, function( _, space ) { |
|
5075 var localCache, |
|
5076 isCache = is[ space.cache ]; |
|
5077 if (isCache) { |
|
5078 localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; |
|
5079 each( space.props, function( _, prop ) { |
|
5080 if ( isCache[ prop.idx ] != null ) { |
|
5081 same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); |
|
5082 return same; |
|
5083 } |
|
5084 }); |
|
5085 } |
|
5086 return same; |
|
5087 }); |
|
5088 return same; |
|
5089 }, |
|
5090 _space: function() { |
|
5091 var used = [], |
|
5092 inst = this; |
|
5093 each( spaces, function( spaceName, space ) { |
|
5094 if ( inst[ space.cache ] ) { |
|
5095 used.push( spaceName ); |
|
5096 } |
|
5097 }); |
|
5098 return used.pop(); |
|
5099 }, |
|
5100 transition: function( other, distance ) { |
|
5101 var end = color( other ), |
|
5102 spaceName = end._space(), |
|
5103 space = spaces[ spaceName ], |
|
5104 startColor = this.alpha() === 0 ? color( "transparent" ) : this, |
|
5105 start = startColor[ space.cache ] || space.to( startColor._rgba ), |
|
5106 result = start.slice(); |
|
5107 |
|
5108 end = end[ space.cache ]; |
|
5109 each( space.props, function( key, prop ) { |
|
5110 var index = prop.idx, |
|
5111 startValue = start[ index ], |
|
5112 endValue = end[ index ], |
|
5113 type = propTypes[ prop.type ] || {}; |
|
5114 |
|
5115 // if null, don't override start value |
|
5116 if ( endValue === null ) { |
|
5117 return; |
|
5118 } |
|
5119 // if null - use end |
|
5120 if ( startValue === null ) { |
|
5121 result[ index ] = endValue; |
|
5122 } else { |
|
5123 if ( type.mod ) { |
|
5124 if ( endValue - startValue > type.mod / 2 ) { |
|
5125 startValue += type.mod; |
|
5126 } else if ( startValue - endValue > type.mod / 2 ) { |
|
5127 startValue -= type.mod; |
|
5128 } |
|
5129 } |
|
5130 result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); |
|
5131 } |
|
5132 }); |
|
5133 return this[ spaceName ]( result ); |
|
5134 }, |
|
5135 blend: function( opaque ) { |
|
5136 // if we are already opaque - return ourself |
|
5137 if ( this._rgba[ 3 ] === 1 ) { |
|
5138 return this; |
|
5139 } |
|
5140 |
|
5141 var rgb = this._rgba.slice(), |
|
5142 a = rgb.pop(), |
|
5143 blend = color( opaque )._rgba; |
|
5144 |
|
5145 return color( jQuery.map( rgb, function( v, i ) { |
|
5146 return ( 1 - a ) * blend[ i ] + a * v; |
|
5147 })); |
|
5148 }, |
|
5149 toRgbaString: function() { |
|
5150 var prefix = "rgba(", |
|
5151 rgba = jQuery.map( this._rgba, function( v, i ) { |
|
5152 return v == null ? ( i > 2 ? 1 : 0 ) : v; |
|
5153 }); |
|
5154 |
|
5155 if ( rgba[ 3 ] === 1 ) { |
|
5156 rgba.pop(); |
|
5157 prefix = "rgb("; |
|
5158 } |
|
5159 |
|
5160 return prefix + rgba.join() + ")"; |
|
5161 }, |
|
5162 toHslaString: function() { |
|
5163 var prefix = "hsla(", |
|
5164 hsla = jQuery.map( this.hsla(), function( v, i ) { |
|
5165 if ( v == null ) { |
|
5166 v = i > 2 ? 1 : 0; |
|
5167 } |
|
5168 |
|
5169 // catch 1 and 2 |
|
5170 if ( i && i < 3 ) { |
|
5171 v = Math.round( v * 100 ) + "%"; |
|
5172 } |
|
5173 return v; |
|
5174 }); |
|
5175 |
|
5176 if ( hsla[ 3 ] === 1 ) { |
|
5177 hsla.pop(); |
|
5178 prefix = "hsl("; |
|
5179 } |
|
5180 return prefix + hsla.join() + ")"; |
|
5181 }, |
|
5182 toHexString: function( includeAlpha ) { |
|
5183 var rgba = this._rgba.slice(), |
|
5184 alpha = rgba.pop(); |
|
5185 |
|
5186 if ( includeAlpha ) { |
|
5187 rgba.push( ~~( alpha * 255 ) ); |
|
5188 } |
|
5189 |
|
5190 return "#" + jQuery.map( rgba, function( v ) { |
|
5191 |
|
5192 // default to 0 when nulls exist |
|
5193 v = ( v || 0 ).toString( 16 ); |
|
5194 return v.length === 1 ? "0" + v : v; |
|
5195 }).join(""); |
|
5196 }, |
|
5197 toString: function() { |
|
5198 return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); |
|
5199 } |
|
5200 }); |
|
5201 color.fn.parse.prototype = color.fn; |
|
5202 |
|
5203 // hsla conversions adapted from: |
|
5204 // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 |
|
5205 |
|
5206 function hue2rgb( p, q, h ) { |
|
5207 h = ( h + 1 ) % 1; |
|
5208 if ( h * 6 < 1 ) { |
|
5209 return p + (q - p) * h * 6; |
|
5210 } |
|
5211 if ( h * 2 < 1) { |
|
5212 return q; |
|
5213 } |
|
5214 if ( h * 3 < 2 ) { |
|
5215 return p + (q - p) * ((2/3) - h) * 6; |
|
5216 } |
|
5217 return p; |
|
5218 } |
|
5219 |
|
5220 spaces.hsla.to = function ( rgba ) { |
|
5221 if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { |
|
5222 return [ null, null, null, rgba[ 3 ] ]; |
|
5223 } |
|
5224 var r = rgba[ 0 ] / 255, |
|
5225 g = rgba[ 1 ] / 255, |
|
5226 b = rgba[ 2 ] / 255, |
|
5227 a = rgba[ 3 ], |
|
5228 max = Math.max( r, g, b ), |
|
5229 min = Math.min( r, g, b ), |
|
5230 diff = max - min, |
|
5231 add = max + min, |
|
5232 l = add * 0.5, |
|
5233 h, s; |
|
5234 |
|
5235 if ( min === max ) { |
|
5236 h = 0; |
|
5237 } else if ( r === max ) { |
|
5238 h = ( 60 * ( g - b ) / diff ) + 360; |
|
5239 } else if ( g === max ) { |
|
5240 h = ( 60 * ( b - r ) / diff ) + 120; |
|
5241 } else { |
|
5242 h = ( 60 * ( r - g ) / diff ) + 240; |
|
5243 } |
|
5244 |
|
5245 // chroma (diff) == 0 means greyscale which, by definition, saturation = 0% |
|
5246 // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) |
|
5247 if ( diff === 0 ) { |
|
5248 s = 0; |
|
5249 } else if ( l <= 0.5 ) { |
|
5250 s = diff / add; |
|
5251 } else { |
|
5252 s = diff / ( 2 - add ); |
|
5253 } |
|
5254 return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; |
|
5255 }; |
|
5256 |
|
5257 spaces.hsla.from = function ( hsla ) { |
|
5258 if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { |
|
5259 return [ null, null, null, hsla[ 3 ] ]; |
|
5260 } |
|
5261 var h = hsla[ 0 ] / 360, |
|
5262 s = hsla[ 1 ], |
|
5263 l = hsla[ 2 ], |
|
5264 a = hsla[ 3 ], |
|
5265 q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, |
|
5266 p = 2 * l - q; |
|
5267 |
|
5268 return [ |
|
5269 Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), |
|
5270 Math.round( hue2rgb( p, q, h ) * 255 ), |
|
5271 Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), |
|
5272 a |
|
5273 ]; |
|
5274 }; |
|
5275 |
|
5276 |
|
5277 each( spaces, function( spaceName, space ) { |
|
5278 var props = space.props, |
|
5279 cache = space.cache, |
|
5280 to = space.to, |
|
5281 from = space.from; |
|
5282 |
|
5283 // makes rgba() and hsla() |
|
5284 color.fn[ spaceName ] = function( value ) { |
|
5285 |
|
5286 // generate a cache for this space if it doesn't exist |
|
5287 if ( to && !this[ cache ] ) { |
|
5288 this[ cache ] = to( this._rgba ); |
|
5289 } |
|
5290 if ( value === undefined ) { |
|
5291 return this[ cache ].slice(); |
|
5292 } |
|
5293 |
|
5294 var ret, |
|
5295 type = jQuery.type( value ), |
|
5296 arr = ( type === "array" || type === "object" ) ? value : arguments, |
|
5297 local = this[ cache ].slice(); |
|
5298 |
|
5299 each( props, function( key, prop ) { |
|
5300 var val = arr[ type === "object" ? key : prop.idx ]; |
|
5301 if ( val == null ) { |
|
5302 val = local[ prop.idx ]; |
|
5303 } |
|
5304 local[ prop.idx ] = clamp( val, prop ); |
|
5305 }); |
|
5306 |
|
5307 if ( from ) { |
|
5308 ret = color( from( local ) ); |
|
5309 ret[ cache ] = local; |
|
5310 return ret; |
|
5311 } else { |
|
5312 return color( local ); |
|
5313 } |
|
5314 }; |
|
5315 |
|
5316 // makes red() green() blue() alpha() hue() saturation() lightness() |
|
5317 each( props, function( key, prop ) { |
|
5318 // alpha is included in more than one space |
|
5319 if ( color.fn[ key ] ) { |
|
5320 return; |
|
5321 } |
|
5322 color.fn[ key ] = function( value ) { |
|
5323 var vtype = jQuery.type( value ), |
|
5324 fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), |
|
5325 local = this[ fn ](), |
|
5326 cur = local[ prop.idx ], |
|
5327 match; |
|
5328 |
|
5329 if ( vtype === "undefined" ) { |
|
5330 return cur; |
|
5331 } |
|
5332 |
|
5333 if ( vtype === "function" ) { |
|
5334 value = value.call( this, cur ); |
|
5335 vtype = jQuery.type( value ); |
|
5336 } |
|
5337 if ( value == null && prop.empty ) { |
|
5338 return this; |
|
5339 } |
|
5340 if ( vtype === "string" ) { |
|
5341 match = rplusequals.exec( value ); |
|
5342 if ( match ) { |
|
5343 value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); |
|
5344 } |
|
5345 } |
|
5346 local[ prop.idx ] = value; |
|
5347 return this[ fn ]( local ); |
|
5348 }; |
1147 }; |
5349 }); |
1148 }, |
5350 }); |
1149 getWithinInfo: function( element ) { |
5351 |
1150 var withinElement = $( element || window ), |
5352 // add cssHook and .fx.step function for each named hook. |
1151 isWindow = $.isWindow( withinElement[0] ), |
5353 // accept a space separated string of properties |
1152 isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9; |
5354 color.hook = function( hook ) { |
1153 return { |
5355 var hooks = hook.split( " " ); |
1154 element: withinElement, |
5356 each( hooks, function( i, hook ) { |
1155 isWindow: isWindow, |
5357 jQuery.cssHooks[ hook ] = { |
1156 isDocument: isDocument, |
5358 set: function( elem, value ) { |
1157 offset: withinElement.offset() || { left: 0, top: 0 }, |
5359 var parsed, curElem, |
1158 scrollLeft: withinElement.scrollLeft(), |
5360 backgroundColor = ""; |
1159 scrollTop: withinElement.scrollTop(), |
5361 |
1160 |
5362 if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) { |
1161 // support: jQuery 1.6.x |
5363 value = color( parsed || value ); |
1162 // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows |
5364 if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { |
1163 width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(), |
5365 curElem = hook === "backgroundColor" ? elem.parentNode : elem; |
1164 height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight() |
5366 while ( |
|
5367 (backgroundColor === "" || backgroundColor === "transparent") && |
|
5368 curElem && curElem.style |
|
5369 ) { |
|
5370 try { |
|
5371 backgroundColor = jQuery.css( curElem, "backgroundColor" ); |
|
5372 curElem = curElem.parentNode; |
|
5373 } catch ( e ) { |
|
5374 } |
|
5375 } |
|
5376 |
|
5377 value = value.blend( backgroundColor && backgroundColor !== "transparent" ? |
|
5378 backgroundColor : |
|
5379 "_default" ); |
|
5380 } |
|
5381 |
|
5382 value = value.toRgbaString(); |
|
5383 } |
|
5384 try { |
|
5385 elem.style[ hook ] = value; |
|
5386 } catch( e ) { |
|
5387 // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' |
|
5388 } |
|
5389 } |
|
5390 }; |
1165 }; |
5391 jQuery.fx.step[ hook ] = function( fx ) { |
|
5392 if ( !fx.colorInit ) { |
|
5393 fx.start = color( fx.elem, hook ); |
|
5394 fx.end = color( fx.end ); |
|
5395 fx.colorInit = true; |
|
5396 } |
|
5397 jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); |
|
5398 }; |
|
5399 }); |
|
5400 |
|
5401 }; |
|
5402 |
|
5403 color.hook( stepHooks ); |
|
5404 |
|
5405 jQuery.cssHooks.borderColor = { |
|
5406 expand: function( value ) { |
|
5407 var expanded = {}; |
|
5408 |
|
5409 each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { |
|
5410 expanded[ "border" + part + "Color" ] = value; |
|
5411 }); |
|
5412 return expanded; |
|
5413 } |
1166 } |
5414 }; |
1167 }; |
5415 |
1168 |
5416 // Basic color names only. |
1169 $.fn.position = function( options ) { |
5417 // Usage of any of the other color names requires adding yourself or including |
1170 if ( !options || !options.of ) { |
5418 // jquery.color.svg-names.js. |
1171 return _position.apply( this, arguments ); |
5419 colors = jQuery.Color.names = { |
|
5420 // 4.1. Basic color keywords |
|
5421 aqua: "#00ffff", |
|
5422 black: "#000000", |
|
5423 blue: "#0000ff", |
|
5424 fuchsia: "#ff00ff", |
|
5425 gray: "#808080", |
|
5426 green: "#008000", |
|
5427 lime: "#00ff00", |
|
5428 maroon: "#800000", |
|
5429 navy: "#000080", |
|
5430 olive: "#808000", |
|
5431 purple: "#800080", |
|
5432 red: "#ff0000", |
|
5433 silver: "#c0c0c0", |
|
5434 teal: "#008080", |
|
5435 white: "#ffffff", |
|
5436 yellow: "#ffff00", |
|
5437 |
|
5438 // 4.2.3. "transparent" color keyword |
|
5439 transparent: [ null, null, null, 0 ], |
|
5440 |
|
5441 _default: "#ffffff" |
|
5442 }; |
|
5443 |
|
5444 })( jQuery ); |
|
5445 |
|
5446 |
|
5447 /******************************************************************************/ |
|
5448 /****************************** CLASS ANIMATIONS ******************************/ |
|
5449 /******************************************************************************/ |
|
5450 (function() { |
|
5451 |
|
5452 var classAnimationActions = [ "add", "remove", "toggle" ], |
|
5453 shorthandStyles = { |
|
5454 border: 1, |
|
5455 borderBottom: 1, |
|
5456 borderColor: 1, |
|
5457 borderLeft: 1, |
|
5458 borderRight: 1, |
|
5459 borderTop: 1, |
|
5460 borderWidth: 1, |
|
5461 margin: 1, |
|
5462 padding: 1 |
|
5463 }; |
|
5464 |
|
5465 $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { |
|
5466 $.fx.step[ prop ] = function( fx ) { |
|
5467 if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { |
|
5468 jQuery.style( fx.elem, prop, fx.end ); |
|
5469 fx.setAttr = true; |
|
5470 } |
|
5471 }; |
|
5472 }); |
|
5473 |
|
5474 function getElementStyles( elem ) { |
|
5475 var key, len, |
|
5476 style = elem.ownerDocument.defaultView ? |
|
5477 elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : |
|
5478 elem.currentStyle, |
|
5479 styles = {}; |
|
5480 |
|
5481 if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { |
|
5482 len = style.length; |
|
5483 while ( len-- ) { |
|
5484 key = style[ len ]; |
|
5485 if ( typeof style[ key ] === "string" ) { |
|
5486 styles[ $.camelCase( key ) ] = style[ key ]; |
|
5487 } |
|
5488 } |
|
5489 // support: Opera, IE <9 |
|
5490 } else { |
|
5491 for ( key in style ) { |
|
5492 if ( typeof style[ key ] === "string" ) { |
|
5493 styles[ key ] = style[ key ]; |
|
5494 } |
|
5495 } |
|
5496 } |
1172 } |
5497 |
1173 |
5498 return styles; |
1174 // make a copy, we don't want to modify arguments |
5499 } |
1175 options = $.extend( {}, options ); |
5500 |
1176 |
5501 |
1177 var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, |
5502 function styleDifference( oldStyle, newStyle ) { |
1178 target = $( options.of ), |
5503 var diff = {}, |
1179 within = $.position.getWithinInfo( options.within ), |
5504 name, value; |
1180 scrollInfo = $.position.getScrollInfo( within ), |
5505 |
1181 collision = ( options.collision || "flip" ).split( " " ), |
5506 for ( name in newStyle ) { |
1182 offsets = {}; |
5507 value = newStyle[ name ]; |
1183 |
5508 if ( oldStyle[ name ] !== value ) { |
1184 dimensions = getDimensions( target ); |
5509 if ( !shorthandStyles[ name ] ) { |
1185 if ( target[0].preventDefault ) { |
5510 if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { |
1186 // force left top to allow flipping |
5511 diff[ name ] = value; |
1187 options.at = "left top"; |
5512 } |
|
5513 } |
|
5514 } |
|
5515 } |
1188 } |
5516 |
1189 targetWidth = dimensions.width; |
5517 return diff; |
1190 targetHeight = dimensions.height; |
5518 } |
1191 targetOffset = dimensions.offset; |
5519 |
1192 // clone to reuse original targetOffset later |
5520 // support: jQuery <1.8 |
1193 basePosition = $.extend( {}, targetOffset ); |
5521 if ( !$.fn.addBack ) { |
1194 |
5522 $.fn.addBack = function( selector ) { |
1195 // force my and at to have valid horizontal and vertical positions |
5523 return this.add( selector == null ? |
1196 // if a value is missing or invalid, it will be converted to center |
5524 this.prevObject : this.prevObject.filter( selector ) |
1197 $.each( [ "my", "at" ], function() { |
5525 ); |
1198 var pos = ( options[ this ] || "" ).split( " " ), |
5526 }; |
1199 horizontalOffset, |
5527 } |
1200 verticalOffset; |
5528 |
1201 |
5529 $.effects.animateClass = function( value, duration, easing, callback ) { |
1202 if ( pos.length === 1) { |
5530 var o = $.speed( duration, easing, callback ); |
1203 pos = rhorizontal.test( pos[ 0 ] ) ? |
5531 |
1204 pos.concat( [ "center" ] ) : |
5532 return this.queue( function() { |
1205 rvertical.test( pos[ 0 ] ) ? |
5533 var animated = $( this ), |
1206 [ "center" ].concat( pos ) : |
5534 baseClass = animated.attr( "class" ) || "", |
1207 [ "center", "center" ]; |
5535 applyClassChange, |
1208 } |
5536 allAnimations = o.children ? animated.find( "*" ).addBack() : animated; |
1209 pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; |
5537 |
1210 pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; |
5538 // map the animated objects to store the original styles. |
1211 |
5539 allAnimations = allAnimations.map(function() { |
1212 // calculate offsets |
5540 var el = $( this ); |
1213 horizontalOffset = roffset.exec( pos[ 0 ] ); |
5541 return { |
1214 verticalOffset = roffset.exec( pos[ 1 ] ); |
5542 el: el, |
1215 offsets[ this ] = [ |
5543 start: getElementStyles( this ) |
1216 horizontalOffset ? horizontalOffset[ 0 ] : 0, |
|
1217 verticalOffset ? verticalOffset[ 0 ] : 0 |
|
1218 ]; |
|
1219 |
|
1220 // reduce to just the positions without the offsets |
|
1221 options[ this ] = [ |
|
1222 rposition.exec( pos[ 0 ] )[ 0 ], |
|
1223 rposition.exec( pos[ 1 ] )[ 0 ] |
|
1224 ]; |
|
1225 }); |
|
1226 |
|
1227 // normalize collision option |
|
1228 if ( collision.length === 1 ) { |
|
1229 collision[ 1 ] = collision[ 0 ]; |
|
1230 } |
|
1231 |
|
1232 if ( options.at[ 0 ] === "right" ) { |
|
1233 basePosition.left += targetWidth; |
|
1234 } else if ( options.at[ 0 ] === "center" ) { |
|
1235 basePosition.left += targetWidth / 2; |
|
1236 } |
|
1237 |
|
1238 if ( options.at[ 1 ] === "bottom" ) { |
|
1239 basePosition.top += targetHeight; |
|
1240 } else if ( options.at[ 1 ] === "center" ) { |
|
1241 basePosition.top += targetHeight / 2; |
|
1242 } |
|
1243 |
|
1244 atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); |
|
1245 basePosition.left += atOffset[ 0 ]; |
|
1246 basePosition.top += atOffset[ 1 ]; |
|
1247 |
|
1248 return this.each(function() { |
|
1249 var collisionPosition, using, |
|
1250 elem = $( this ), |
|
1251 elemWidth = elem.outerWidth(), |
|
1252 elemHeight = elem.outerHeight(), |
|
1253 marginLeft = parseCss( this, "marginLeft" ), |
|
1254 marginTop = parseCss( this, "marginTop" ), |
|
1255 collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width, |
|
1256 collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height, |
|
1257 position = $.extend( {}, basePosition ), |
|
1258 myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); |
|
1259 |
|
1260 if ( options.my[ 0 ] === "right" ) { |
|
1261 position.left -= elemWidth; |
|
1262 } else if ( options.my[ 0 ] === "center" ) { |
|
1263 position.left -= elemWidth / 2; |
|
1264 } |
|
1265 |
|
1266 if ( options.my[ 1 ] === "bottom" ) { |
|
1267 position.top -= elemHeight; |
|
1268 } else if ( options.my[ 1 ] === "center" ) { |
|
1269 position.top -= elemHeight / 2; |
|
1270 } |
|
1271 |
|
1272 position.left += myOffset[ 0 ]; |
|
1273 position.top += myOffset[ 1 ]; |
|
1274 |
|
1275 // if the browser doesn't support fractions, then round for consistent results |
|
1276 if ( !supportsOffsetFractions ) { |
|
1277 position.left = round( position.left ); |
|
1278 position.top = round( position.top ); |
|
1279 } |
|
1280 |
|
1281 collisionPosition = { |
|
1282 marginLeft: marginLeft, |
|
1283 marginTop: marginTop |
|
1284 }; |
|
1285 |
|
1286 $.each( [ "left", "top" ], function( i, dir ) { |
|
1287 if ( $.ui.position[ collision[ i ] ] ) { |
|
1288 $.ui.position[ collision[ i ] ][ dir ]( position, { |
|
1289 targetWidth: targetWidth, |
|
1290 targetHeight: targetHeight, |
|
1291 elemWidth: elemWidth, |
|
1292 elemHeight: elemHeight, |
|
1293 collisionPosition: collisionPosition, |
|
1294 collisionWidth: collisionWidth, |
|
1295 collisionHeight: collisionHeight, |
|
1296 offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], |
|
1297 my: options.my, |
|
1298 at: options.at, |
|
1299 within: within, |
|
1300 elem: elem |
|
1301 }); |
|
1302 } |
|
1303 }); |
|
1304 |
|
1305 if ( options.using ) { |
|
1306 // adds feedback as second argument to using callback, if present |
|
1307 using = function( props ) { |
|
1308 var left = targetOffset.left - position.left, |
|
1309 right = left + targetWidth - elemWidth, |
|
1310 top = targetOffset.top - position.top, |
|
1311 bottom = top + targetHeight - elemHeight, |
|
1312 feedback = { |
|
1313 target: { |
|
1314 element: target, |
|
1315 left: targetOffset.left, |
|
1316 top: targetOffset.top, |
|
1317 width: targetWidth, |
|
1318 height: targetHeight |
|
1319 }, |
|
1320 element: { |
|
1321 element: elem, |
|
1322 left: position.left, |
|
1323 top: position.top, |
|
1324 width: elemWidth, |
|
1325 height: elemHeight |
|
1326 }, |
|
1327 horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", |
|
1328 vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" |
|
1329 }; |
|
1330 if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { |
|
1331 feedback.horizontal = "center"; |
|
1332 } |
|
1333 if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { |
|
1334 feedback.vertical = "middle"; |
|
1335 } |
|
1336 if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { |
|
1337 feedback.important = "horizontal"; |
|
1338 } else { |
|
1339 feedback.important = "vertical"; |
|
1340 } |
|
1341 options.using.call( this, props, feedback ); |
5544 }; |
1342 }; |
5545 }); |
1343 } |
5546 |
1344 |
5547 // apply class change |
1345 elem.offset( $.extend( position, { using: using } ) ); |
5548 applyClassChange = function() { |
|
5549 $.each( classAnimationActions, function(i, action) { |
|
5550 if ( value[ action ] ) { |
|
5551 animated[ action + "Class" ]( value[ action ] ); |
|
5552 } |
|
5553 }); |
|
5554 }; |
|
5555 applyClassChange(); |
|
5556 |
|
5557 // map all animated objects again - calculate new styles and diff |
|
5558 allAnimations = allAnimations.map(function() { |
|
5559 this.end = getElementStyles( this.el[ 0 ] ); |
|
5560 this.diff = styleDifference( this.start, this.end ); |
|
5561 return this; |
|
5562 }); |
|
5563 |
|
5564 // apply original class |
|
5565 animated.attr( "class", baseClass ); |
|
5566 |
|
5567 // map all animated objects again - this time collecting a promise |
|
5568 allAnimations = allAnimations.map(function() { |
|
5569 var styleInfo = this, |
|
5570 dfd = $.Deferred(), |
|
5571 opts = $.extend({}, o, { |
|
5572 queue: false, |
|
5573 complete: function() { |
|
5574 dfd.resolve( styleInfo ); |
|
5575 } |
|
5576 }); |
|
5577 |
|
5578 this.el.animate( this.diff, opts ); |
|
5579 return dfd.promise(); |
|
5580 }); |
|
5581 |
|
5582 // once all animations have completed: |
|
5583 $.when.apply( $, allAnimations.get() ).done(function() { |
|
5584 |
|
5585 // set the final class |
|
5586 applyClassChange(); |
|
5587 |
|
5588 // for each animated element, |
|
5589 // clear all css properties that were animated |
|
5590 $.each( arguments, function() { |
|
5591 var el = this.el; |
|
5592 $.each( this.diff, function(key) { |
|
5593 el.css( key, "" ); |
|
5594 }); |
|
5595 }); |
|
5596 |
|
5597 // this is guarnteed to be there if you use jQuery.speed() |
|
5598 // it also handles dequeuing the next anim... |
|
5599 o.complete.call( animated[ 0 ] ); |
|
5600 }); |
|
5601 }); |
1346 }); |
5602 }; |
1347 }; |
5603 |
1348 |
5604 $.fn.extend({ |
1349 $.ui.position = { |
5605 addClass: (function( orig ) { |
1350 fit: { |
5606 return function( classNames, speed, easing, callback ) { |
1351 left: function( position, data ) { |
5607 return speed ? |
1352 var within = data.within, |
5608 $.effects.animateClass.call( this, |
1353 withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, |
5609 { add: classNames }, speed, easing, callback ) : |
1354 outerWidth = within.width, |
5610 orig.apply( this, arguments ); |
1355 collisionPosLeft = position.left - data.collisionPosition.marginLeft, |
5611 }; |
1356 overLeft = withinOffset - collisionPosLeft, |
5612 })( $.fn.addClass ), |
1357 overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, |
5613 |
1358 newOverRight; |
5614 removeClass: (function( orig ) { |
1359 |
5615 return function( classNames, speed, easing, callback ) { |
1360 // element is wider than within |
5616 return arguments.length > 1 ? |
1361 if ( data.collisionWidth > outerWidth ) { |
5617 $.effects.animateClass.call( this, |
1362 // element is initially over the left side of within |
5618 { remove: classNames }, speed, easing, callback ) : |
1363 if ( overLeft > 0 && overRight <= 0 ) { |
5619 orig.apply( this, arguments ); |
1364 newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset; |
5620 }; |
1365 position.left += overLeft - newOverRight; |
5621 })( $.fn.removeClass ), |
1366 // element is initially over right side of within |
5622 |
1367 } else if ( overRight > 0 && overLeft <= 0 ) { |
5623 toggleClass: (function( orig ) { |
1368 position.left = withinOffset; |
5624 return function( classNames, force, speed, easing, callback ) { |
1369 // element is initially over both left and right sides of within |
5625 if ( typeof force === "boolean" || force === undefined ) { |
|
5626 if ( !speed ) { |
|
5627 // without speed parameter |
|
5628 return orig.apply( this, arguments ); |
|
5629 } else { |
1370 } else { |
5630 return $.effects.animateClass.call( this, |
1371 if ( overLeft > overRight ) { |
5631 (force ? { add: classNames } : { remove: classNames }), |
1372 position.left = withinOffset + outerWidth - data.collisionWidth; |
5632 speed, easing, callback ); |
1373 } else { |
5633 } |
1374 position.left = withinOffset; |
|
1375 } |
|
1376 } |
|
1377 // too far left -> align with left edge |
|
1378 } else if ( overLeft > 0 ) { |
|
1379 position.left += overLeft; |
|
1380 // too far right -> align with right edge |
|
1381 } else if ( overRight > 0 ) { |
|
1382 position.left -= overRight; |
|
1383 // adjust based on position and margin |
5634 } else { |
1384 } else { |
5635 // without force parameter |
1385 position.left = max( position.left - collisionPosLeft, position.left ); |
5636 return $.effects.animateClass.call( this, |
1386 } |
5637 { toggle: classNames }, force, speed, easing ); |
1387 }, |
5638 } |
1388 top: function( position, data ) { |
5639 }; |
1389 var within = data.within, |
5640 })( $.fn.toggleClass ), |
1390 withinOffset = within.isWindow ? within.scrollTop : within.offset.top, |
5641 |
1391 outerHeight = data.within.height, |
5642 switchClass: function( remove, add, speed, easing, callback) { |
1392 collisionPosTop = position.top - data.collisionPosition.marginTop, |
5643 return $.effects.animateClass.call( this, { |
1393 overTop = withinOffset - collisionPosTop, |
5644 add: add, |
1394 overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, |
5645 remove: remove |
1395 newOverBottom; |
5646 }, speed, easing, callback ); |
1396 |
|
1397 // element is taller than within |
|
1398 if ( data.collisionHeight > outerHeight ) { |
|
1399 // element is initially over the top of within |
|
1400 if ( overTop > 0 && overBottom <= 0 ) { |
|
1401 newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset; |
|
1402 position.top += overTop - newOverBottom; |
|
1403 // element is initially over bottom of within |
|
1404 } else if ( overBottom > 0 && overTop <= 0 ) { |
|
1405 position.top = withinOffset; |
|
1406 // element is initially over both top and bottom of within |
|
1407 } else { |
|
1408 if ( overTop > overBottom ) { |
|
1409 position.top = withinOffset + outerHeight - data.collisionHeight; |
|
1410 } else { |
|
1411 position.top = withinOffset; |
|
1412 } |
|
1413 } |
|
1414 // too far up -> align with top |
|
1415 } else if ( overTop > 0 ) { |
|
1416 position.top += overTop; |
|
1417 // too far down -> align with bottom edge |
|
1418 } else if ( overBottom > 0 ) { |
|
1419 position.top -= overBottom; |
|
1420 // adjust based on position and margin |
|
1421 } else { |
|
1422 position.top = max( position.top - collisionPosTop, position.top ); |
|
1423 } |
|
1424 } |
|
1425 }, |
|
1426 flip: { |
|
1427 left: function( position, data ) { |
|
1428 var within = data.within, |
|
1429 withinOffset = within.offset.left + within.scrollLeft, |
|
1430 outerWidth = within.width, |
|
1431 offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, |
|
1432 collisionPosLeft = position.left - data.collisionPosition.marginLeft, |
|
1433 overLeft = collisionPosLeft - offsetLeft, |
|
1434 overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, |
|
1435 myOffset = data.my[ 0 ] === "left" ? |
|
1436 -data.elemWidth : |
|
1437 data.my[ 0 ] === "right" ? |
|
1438 data.elemWidth : |
|
1439 0, |
|
1440 atOffset = data.at[ 0 ] === "left" ? |
|
1441 data.targetWidth : |
|
1442 data.at[ 0 ] === "right" ? |
|
1443 -data.targetWidth : |
|
1444 0, |
|
1445 offset = -2 * data.offset[ 0 ], |
|
1446 newOverRight, |
|
1447 newOverLeft; |
|
1448 |
|
1449 if ( overLeft < 0 ) { |
|
1450 newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; |
|
1451 if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { |
|
1452 position.left += myOffset + atOffset + offset; |
|
1453 } |
|
1454 } else if ( overRight > 0 ) { |
|
1455 newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft; |
|
1456 if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { |
|
1457 position.left += myOffset + atOffset + offset; |
|
1458 } |
|
1459 } |
|
1460 }, |
|
1461 top: function( position, data ) { |
|
1462 var within = data.within, |
|
1463 withinOffset = within.offset.top + within.scrollTop, |
|
1464 outerHeight = within.height, |
|
1465 offsetTop = within.isWindow ? within.scrollTop : within.offset.top, |
|
1466 collisionPosTop = position.top - data.collisionPosition.marginTop, |
|
1467 overTop = collisionPosTop - offsetTop, |
|
1468 overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, |
|
1469 top = data.my[ 1 ] === "top", |
|
1470 myOffset = top ? |
|
1471 -data.elemHeight : |
|
1472 data.my[ 1 ] === "bottom" ? |
|
1473 data.elemHeight : |
|
1474 0, |
|
1475 atOffset = data.at[ 1 ] === "top" ? |
|
1476 data.targetHeight : |
|
1477 data.at[ 1 ] === "bottom" ? |
|
1478 -data.targetHeight : |
|
1479 0, |
|
1480 offset = -2 * data.offset[ 1 ], |
|
1481 newOverTop, |
|
1482 newOverBottom; |
|
1483 if ( overTop < 0 ) { |
|
1484 newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; |
|
1485 if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { |
|
1486 position.top += myOffset + atOffset + offset; |
|
1487 } |
|
1488 } else if ( overBottom > 0 ) { |
|
1489 newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; |
|
1490 if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { |
|
1491 position.top += myOffset + atOffset + offset; |
|
1492 } |
|
1493 } |
|
1494 } |
|
1495 }, |
|
1496 flipfit: { |
|
1497 left: function() { |
|
1498 $.ui.position.flip.left.apply( this, arguments ); |
|
1499 $.ui.position.fit.left.apply( this, arguments ); |
|
1500 }, |
|
1501 top: function() { |
|
1502 $.ui.position.flip.top.apply( this, arguments ); |
|
1503 $.ui.position.fit.top.apply( this, arguments ); |
|
1504 } |
5647 } |
1505 } |
5648 }); |
1506 }; |
5649 |
1507 |
|
1508 // fraction support test |
|
1509 (function() { |
|
1510 var testElement, testElementParent, testElementStyle, offsetLeft, i, |
|
1511 body = document.getElementsByTagName( "body" )[ 0 ], |
|
1512 div = document.createElement( "div" ); |
|
1513 |
|
1514 //Create a "fake body" for testing based on method used in jQuery.support |
|
1515 testElement = document.createElement( body ? "div" : "body" ); |
|
1516 testElementStyle = { |
|
1517 visibility: "hidden", |
|
1518 width: 0, |
|
1519 height: 0, |
|
1520 border: 0, |
|
1521 margin: 0, |
|
1522 background: "none" |
|
1523 }; |
|
1524 if ( body ) { |
|
1525 $.extend( testElementStyle, { |
|
1526 position: "absolute", |
|
1527 left: "-1000px", |
|
1528 top: "-1000px" |
|
1529 }); |
|
1530 } |
|
1531 for ( i in testElementStyle ) { |
|
1532 testElement.style[ i ] = testElementStyle[ i ]; |
|
1533 } |
|
1534 testElement.appendChild( div ); |
|
1535 testElementParent = body || document.documentElement; |
|
1536 testElementParent.insertBefore( testElement, testElementParent.firstChild ); |
|
1537 |
|
1538 div.style.cssText = "position: absolute; left: 10.7432222px;"; |
|
1539 |
|
1540 offsetLeft = $( div ).offset().left; |
|
1541 supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11; |
|
1542 |
|
1543 testElement.innerHTML = ""; |
|
1544 testElementParent.removeChild( testElement ); |
5650 })(); |
1545 })(); |
5651 |
1546 |
5652 /******************************************************************************/ |
|
5653 /*********************************** EFFECTS **********************************/ |
|
5654 /******************************************************************************/ |
|
5655 |
|
5656 (function() { |
|
5657 |
|
5658 $.extend( $.effects, { |
|
5659 version: "1.10.3", |
|
5660 |
|
5661 // Saves a set of properties in a data storage |
|
5662 save: function( element, set ) { |
|
5663 for( var i=0; i < set.length; i++ ) { |
|
5664 if ( set[ i ] !== null ) { |
|
5665 element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); |
|
5666 } |
|
5667 } |
|
5668 }, |
|
5669 |
|
5670 // Restores a set of previously saved properties from a data storage |
|
5671 restore: function( element, set ) { |
|
5672 var val, i; |
|
5673 for( i=0; i < set.length; i++ ) { |
|
5674 if ( set[ i ] !== null ) { |
|
5675 val = element.data( dataSpace + set[ i ] ); |
|
5676 // support: jQuery 1.6.2 |
|
5677 // http://bugs.jquery.com/ticket/9917 |
|
5678 // jQuery 1.6.2 incorrectly returns undefined for any falsy value. |
|
5679 // We can't differentiate between "" and 0 here, so we just assume |
|
5680 // empty string since it's likely to be a more common value... |
|
5681 if ( val === undefined ) { |
|
5682 val = ""; |
|
5683 } |
|
5684 element.css( set[ i ], val ); |
|
5685 } |
|
5686 } |
|
5687 }, |
|
5688 |
|
5689 setMode: function( el, mode ) { |
|
5690 if (mode === "toggle") { |
|
5691 mode = el.is( ":hidden" ) ? "show" : "hide"; |
|
5692 } |
|
5693 return mode; |
|
5694 }, |
|
5695 |
|
5696 // Translates a [top,left] array into a baseline value |
|
5697 // this should be a little more flexible in the future to handle a string & hash |
|
5698 getBaseline: function( origin, original ) { |
|
5699 var y, x; |
|
5700 switch ( origin[ 0 ] ) { |
|
5701 case "top": y = 0; break; |
|
5702 case "middle": y = 0.5; break; |
|
5703 case "bottom": y = 1; break; |
|
5704 default: y = origin[ 0 ] / original.height; |
|
5705 } |
|
5706 switch ( origin[ 1 ] ) { |
|
5707 case "left": x = 0; break; |
|
5708 case "center": x = 0.5; break; |
|
5709 case "right": x = 1; break; |
|
5710 default: x = origin[ 1 ] / original.width; |
|
5711 } |
|
5712 return { |
|
5713 x: x, |
|
5714 y: y |
|
5715 }; |
|
5716 }, |
|
5717 |
|
5718 // Wraps the element around a wrapper that copies position properties |
|
5719 createWrapper: function( element ) { |
|
5720 |
|
5721 // if the element is already wrapped, return it |
|
5722 if ( element.parent().is( ".ui-effects-wrapper" )) { |
|
5723 return element.parent(); |
|
5724 } |
|
5725 |
|
5726 // wrap the element |
|
5727 var props = { |
|
5728 width: element.outerWidth(true), |
|
5729 height: element.outerHeight(true), |
|
5730 "float": element.css( "float" ) |
|
5731 }, |
|
5732 wrapper = $( "<div></div>" ) |
|
5733 .addClass( "ui-effects-wrapper" ) |
|
5734 .css({ |
|
5735 fontSize: "100%", |
|
5736 background: "transparent", |
|
5737 border: "none", |
|
5738 margin: 0, |
|
5739 padding: 0 |
|
5740 }), |
|
5741 // Store the size in case width/height are defined in % - Fixes #5245 |
|
5742 size = { |
|
5743 width: element.width(), |
|
5744 height: element.height() |
|
5745 }, |
|
5746 active = document.activeElement; |
|
5747 |
|
5748 // support: Firefox |
|
5749 // Firefox incorrectly exposes anonymous content |
|
5750 // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 |
|
5751 try { |
|
5752 active.id; |
|
5753 } catch( e ) { |
|
5754 active = document.body; |
|
5755 } |
|
5756 |
|
5757 element.wrap( wrapper ); |
|
5758 |
|
5759 // Fixes #7595 - Elements lose focus when wrapped. |
|
5760 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { |
|
5761 $( active ).focus(); |
|
5762 } |
|
5763 |
|
5764 wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element |
|
5765 |
|
5766 // transfer positioning properties to the wrapper |
|
5767 if ( element.css( "position" ) === "static" ) { |
|
5768 wrapper.css({ position: "relative" }); |
|
5769 element.css({ position: "relative" }); |
|
5770 } else { |
|
5771 $.extend( props, { |
|
5772 position: element.css( "position" ), |
|
5773 zIndex: element.css( "z-index" ) |
|
5774 }); |
|
5775 $.each([ "top", "left", "bottom", "right" ], function(i, pos) { |
|
5776 props[ pos ] = element.css( pos ); |
|
5777 if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { |
|
5778 props[ pos ] = "auto"; |
|
5779 } |
|
5780 }); |
|
5781 element.css({ |
|
5782 position: "relative", |
|
5783 top: 0, |
|
5784 left: 0, |
|
5785 right: "auto", |
|
5786 bottom: "auto" |
|
5787 }); |
|
5788 } |
|
5789 element.css(size); |
|
5790 |
|
5791 return wrapper.css( props ).show(); |
|
5792 }, |
|
5793 |
|
5794 removeWrapper: function( element ) { |
|
5795 var active = document.activeElement; |
|
5796 |
|
5797 if ( element.parent().is( ".ui-effects-wrapper" ) ) { |
|
5798 element.parent().replaceWith( element ); |
|
5799 |
|
5800 // Fixes #7595 - Elements lose focus when wrapped. |
|
5801 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { |
|
5802 $( active ).focus(); |
|
5803 } |
|
5804 } |
|
5805 |
|
5806 |
|
5807 return element; |
|
5808 }, |
|
5809 |
|
5810 setTransition: function( element, list, factor, value ) { |
|
5811 value = value || {}; |
|
5812 $.each( list, function( i, x ) { |
|
5813 var unit = element.cssUnit( x ); |
|
5814 if ( unit[ 0 ] > 0 ) { |
|
5815 value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; |
|
5816 } |
|
5817 }); |
|
5818 return value; |
|
5819 } |
|
5820 }); |
|
5821 |
|
5822 // return an effect options object for the given parameters: |
|
5823 function _normalizeArguments( effect, options, speed, callback ) { |
|
5824 |
|
5825 // allow passing all options as the first parameter |
|
5826 if ( $.isPlainObject( effect ) ) { |
|
5827 options = effect; |
|
5828 effect = effect.effect; |
|
5829 } |
|
5830 |
|
5831 // convert to an object |
|
5832 effect = { effect: effect }; |
|
5833 |
|
5834 // catch (effect, null, ...) |
|
5835 if ( options == null ) { |
|
5836 options = {}; |
|
5837 } |
|
5838 |
|
5839 // catch (effect, callback) |
|
5840 if ( $.isFunction( options ) ) { |
|
5841 callback = options; |
|
5842 speed = null; |
|
5843 options = {}; |
|
5844 } |
|
5845 |
|
5846 // catch (effect, speed, ?) |
|
5847 if ( typeof options === "number" || $.fx.speeds[ options ] ) { |
|
5848 callback = speed; |
|
5849 speed = options; |
|
5850 options = {}; |
|
5851 } |
|
5852 |
|
5853 // catch (effect, options, callback) |
|
5854 if ( $.isFunction( speed ) ) { |
|
5855 callback = speed; |
|
5856 speed = null; |
|
5857 } |
|
5858 |
|
5859 // add options to effect |
|
5860 if ( options ) { |
|
5861 $.extend( effect, options ); |
|
5862 } |
|
5863 |
|
5864 speed = speed || options.duration; |
|
5865 effect.duration = $.fx.off ? 0 : |
|
5866 typeof speed === "number" ? speed : |
|
5867 speed in $.fx.speeds ? $.fx.speeds[ speed ] : |
|
5868 $.fx.speeds._default; |
|
5869 |
|
5870 effect.complete = callback || options.complete; |
|
5871 |
|
5872 return effect; |
|
5873 } |
|
5874 |
|
5875 function standardAnimationOption( option ) { |
|
5876 // Valid standard speeds (nothing, number, named speed) |
|
5877 if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { |
|
5878 return true; |
|
5879 } |
|
5880 |
|
5881 // Invalid strings - treat as "normal" speed |
|
5882 if ( typeof option === "string" && !$.effects.effect[ option ] ) { |
|
5883 return true; |
|
5884 } |
|
5885 |
|
5886 // Complete callback |
|
5887 if ( $.isFunction( option ) ) { |
|
5888 return true; |
|
5889 } |
|
5890 |
|
5891 // Options hash (but not naming an effect) |
|
5892 if ( typeof option === "object" && !option.effect ) { |
|
5893 return true; |
|
5894 } |
|
5895 |
|
5896 // Didn't match any standard API |
|
5897 return false; |
|
5898 } |
|
5899 |
|
5900 $.fn.extend({ |
|
5901 effect: function( /* effect, options, speed, callback */ ) { |
|
5902 var args = _normalizeArguments.apply( this, arguments ), |
|
5903 mode = args.mode, |
|
5904 queue = args.queue, |
|
5905 effectMethod = $.effects.effect[ args.effect ]; |
|
5906 |
|
5907 if ( $.fx.off || !effectMethod ) { |
|
5908 // delegate to the original method (e.g., .show()) if possible |
|
5909 if ( mode ) { |
|
5910 return this[ mode ]( args.duration, args.complete ); |
|
5911 } else { |
|
5912 return this.each( function() { |
|
5913 if ( args.complete ) { |
|
5914 args.complete.call( this ); |
|
5915 } |
|
5916 }); |
|
5917 } |
|
5918 } |
|
5919 |
|
5920 function run( next ) { |
|
5921 var elem = $( this ), |
|
5922 complete = args.complete, |
|
5923 mode = args.mode; |
|
5924 |
|
5925 function done() { |
|
5926 if ( $.isFunction( complete ) ) { |
|
5927 complete.call( elem[0] ); |
|
5928 } |
|
5929 if ( $.isFunction( next ) ) { |
|
5930 next(); |
|
5931 } |
|
5932 } |
|
5933 |
|
5934 // If the element already has the correct final state, delegate to |
|
5935 // the core methods so the internal tracking of "olddisplay" works. |
|
5936 if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { |
|
5937 elem[ mode ](); |
|
5938 done(); |
|
5939 } else { |
|
5940 effectMethod.call( elem[0], args, done ); |
|
5941 } |
|
5942 } |
|
5943 |
|
5944 return queue === false ? this.each( run ) : this.queue( queue || "fx", run ); |
|
5945 }, |
|
5946 |
|
5947 show: (function( orig ) { |
|
5948 return function( option ) { |
|
5949 if ( standardAnimationOption( option ) ) { |
|
5950 return orig.apply( this, arguments ); |
|
5951 } else { |
|
5952 var args = _normalizeArguments.apply( this, arguments ); |
|
5953 args.mode = "show"; |
|
5954 return this.effect.call( this, args ); |
|
5955 } |
|
5956 }; |
|
5957 })( $.fn.show ), |
|
5958 |
|
5959 hide: (function( orig ) { |
|
5960 return function( option ) { |
|
5961 if ( standardAnimationOption( option ) ) { |
|
5962 return orig.apply( this, arguments ); |
|
5963 } else { |
|
5964 var args = _normalizeArguments.apply( this, arguments ); |
|
5965 args.mode = "hide"; |
|
5966 return this.effect.call( this, args ); |
|
5967 } |
|
5968 }; |
|
5969 })( $.fn.hide ), |
|
5970 |
|
5971 toggle: (function( orig ) { |
|
5972 return function( option ) { |
|
5973 if ( standardAnimationOption( option ) || typeof option === "boolean" ) { |
|
5974 return orig.apply( this, arguments ); |
|
5975 } else { |
|
5976 var args = _normalizeArguments.apply( this, arguments ); |
|
5977 args.mode = "toggle"; |
|
5978 return this.effect.call( this, args ); |
|
5979 } |
|
5980 }; |
|
5981 })( $.fn.toggle ), |
|
5982 |
|
5983 // helper functions |
|
5984 cssUnit: function(key) { |
|
5985 var style = this.css( key ), |
|
5986 val = []; |
|
5987 |
|
5988 $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { |
|
5989 if ( style.indexOf( unit ) > 0 ) { |
|
5990 val = [ parseFloat( style ), unit ]; |
|
5991 } |
|
5992 }); |
|
5993 return val; |
|
5994 } |
|
5995 }); |
|
5996 |
|
5997 })(); |
1547 })(); |
5998 |
1548 |
5999 /******************************************************************************/ |
1549 var position = $.ui.position; |
6000 /*********************************** EASING ***********************************/ |
1550 |
6001 /******************************************************************************/ |
1551 |
6002 |
1552 /*! |
6003 (function() { |
1553 * jQuery UI Accordion 1.11.4 |
6004 |
1554 * http://jqueryui.com |
6005 // based on easing equations from Robert Penner (http://www.robertpenner.com/easing) |
1555 * |
6006 |
1556 * Copyright jQuery Foundation and other contributors |
6007 var baseEasings = {}; |
1557 * Released under the MIT license. |
6008 |
1558 * http://jquery.org/license |
6009 $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { |
1559 * |
6010 baseEasings[ name ] = function( p ) { |
1560 * http://api.jqueryui.com/accordion/ |
6011 return Math.pow( p, i + 2 ); |
1561 */ |
6012 }; |
1562 |
6013 }); |
1563 |
6014 |
1564 var accordion = $.widget( "ui.accordion", { |
6015 $.extend( baseEasings, { |
1565 version: "1.11.4", |
6016 Sine: function ( p ) { |
|
6017 return 1 - Math.cos( p * Math.PI / 2 ); |
|
6018 }, |
|
6019 Circ: function ( p ) { |
|
6020 return 1 - Math.sqrt( 1 - p * p ); |
|
6021 }, |
|
6022 Elastic: function( p ) { |
|
6023 return p === 0 || p === 1 ? p : |
|
6024 -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 ); |
|
6025 }, |
|
6026 Back: function( p ) { |
|
6027 return p * p * ( 3 * p - 2 ); |
|
6028 }, |
|
6029 Bounce: function ( p ) { |
|
6030 var pow2, |
|
6031 bounce = 4; |
|
6032 |
|
6033 while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} |
|
6034 return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); |
|
6035 } |
|
6036 }); |
|
6037 |
|
6038 $.each( baseEasings, function( name, easeIn ) { |
|
6039 $.easing[ "easeIn" + name ] = easeIn; |
|
6040 $.easing[ "easeOut" + name ] = function( p ) { |
|
6041 return 1 - easeIn( 1 - p ); |
|
6042 }; |
|
6043 $.easing[ "easeInOut" + name ] = function( p ) { |
|
6044 return p < 0.5 ? |
|
6045 easeIn( p * 2 ) / 2 : |
|
6046 1 - easeIn( p * -2 + 2 ) / 2; |
|
6047 }; |
|
6048 }); |
|
6049 |
|
6050 })(); |
|
6051 |
|
6052 })(jQuery); |
|
6053 |
|
6054 (function( $, undefined ) { |
|
6055 |
|
6056 var uid = 0, |
|
6057 hideProps = {}, |
|
6058 showProps = {}; |
|
6059 |
|
6060 hideProps.height = hideProps.paddingTop = hideProps.paddingBottom = |
|
6061 hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide"; |
|
6062 showProps.height = showProps.paddingTop = showProps.paddingBottom = |
|
6063 showProps.borderTopWidth = showProps.borderBottomWidth = "show"; |
|
6064 |
|
6065 $.widget( "ui.accordion", { |
|
6066 version: "1.10.3", |
|
6067 options: { |
1566 options: { |
6068 active: 0, |
1567 active: 0, |
6069 animate: {}, |
1568 animate: {}, |
6070 collapsible: false, |
1569 collapsible: false, |
6071 event: "click", |
1570 event: "click", |
9631 }; |
5829 }; |
9632 |
5830 |
9633 $.datepicker = new Datepicker(); // singleton instance |
5831 $.datepicker = new Datepicker(); // singleton instance |
9634 $.datepicker.initialized = false; |
5832 $.datepicker.initialized = false; |
9635 $.datepicker.uuid = new Date().getTime(); |
5833 $.datepicker.uuid = new Date().getTime(); |
9636 $.datepicker.version = "1.10.3"; |
5834 $.datepicker.version = "1.11.4"; |
9637 |
5835 |
9638 })(jQuery); |
5836 var datepicker = $.datepicker; |
9639 |
5837 |
9640 (function( $, undefined ) { |
5838 |
9641 |
5839 /*! |
9642 var sizeRelatedOptions = { |
5840 * jQuery UI Draggable 1.11.4 |
9643 buttons: true, |
5841 * http://jqueryui.com |
9644 height: true, |
5842 * |
9645 maxHeight: true, |
5843 * Copyright jQuery Foundation and other contributors |
9646 maxWidth: true, |
5844 * Released under the MIT license. |
9647 minHeight: true, |
5845 * http://jquery.org/license |
9648 minWidth: true, |
5846 * |
9649 width: true |
5847 * http://api.jqueryui.com/draggable/ |
9650 }, |
5848 */ |
9651 resizableRelatedOptions = { |
5849 |
9652 maxHeight: true, |
5850 |
9653 maxWidth: true, |
5851 $.widget("ui.draggable", $.ui.mouse, { |
9654 minHeight: true, |
5852 version: "1.11.4", |
9655 minWidth: true |
5853 widgetEventPrefix: "drag", |
9656 }; |
5854 options: { |
9657 |
5855 addClasses: true, |
9658 $.widget( "ui.dialog", { |
5856 appendTo: "parent", |
9659 version: "1.10.3", |
5857 axis: false, |
|
5858 connectToSortable: false, |
|
5859 containment: false, |
|
5860 cursor: "auto", |
|
5861 cursorAt: false, |
|
5862 grid: false, |
|
5863 handle: false, |
|
5864 helper: "original", |
|
5865 iframeFix: false, |
|
5866 opacity: false, |
|
5867 refreshPositions: false, |
|
5868 revert: false, |
|
5869 revertDuration: 500, |
|
5870 scope: "default", |
|
5871 scroll: true, |
|
5872 scrollSensitivity: 20, |
|
5873 scrollSpeed: 20, |
|
5874 snap: false, |
|
5875 snapMode: "both", |
|
5876 snapTolerance: 20, |
|
5877 stack: false, |
|
5878 zIndex: false, |
|
5879 |
|
5880 // callbacks |
|
5881 drag: null, |
|
5882 start: null, |
|
5883 stop: null |
|
5884 }, |
|
5885 _create: function() { |
|
5886 |
|
5887 if ( this.options.helper === "original" ) { |
|
5888 this._setPositionRelative(); |
|
5889 } |
|
5890 if (this.options.addClasses){ |
|
5891 this.element.addClass("ui-draggable"); |
|
5892 } |
|
5893 if (this.options.disabled){ |
|
5894 this.element.addClass("ui-draggable-disabled"); |
|
5895 } |
|
5896 this._setHandleClassName(); |
|
5897 |
|
5898 this._mouseInit(); |
|
5899 }, |
|
5900 |
|
5901 _setOption: function( key, value ) { |
|
5902 this._super( key, value ); |
|
5903 if ( key === "handle" ) { |
|
5904 this._removeHandleClassName(); |
|
5905 this._setHandleClassName(); |
|
5906 } |
|
5907 }, |
|
5908 |
|
5909 _destroy: function() { |
|
5910 if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) { |
|
5911 this.destroyOnClear = true; |
|
5912 return; |
|
5913 } |
|
5914 this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ); |
|
5915 this._removeHandleClassName(); |
|
5916 this._mouseDestroy(); |
|
5917 }, |
|
5918 |
|
5919 _mouseCapture: function(event) { |
|
5920 var o = this.options; |
|
5921 |
|
5922 this._blurActiveElement( event ); |
|
5923 |
|
5924 // among others, prevent a drag on a resizable-handle |
|
5925 if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) { |
|
5926 return false; |
|
5927 } |
|
5928 |
|
5929 //Quit if we're not on a valid handle |
|
5930 this.handle = this._getHandle(event); |
|
5931 if (!this.handle) { |
|
5932 return false; |
|
5933 } |
|
5934 |
|
5935 this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix ); |
|
5936 |
|
5937 return true; |
|
5938 |
|
5939 }, |
|
5940 |
|
5941 _blockFrames: function( selector ) { |
|
5942 this.iframeBlocks = this.document.find( selector ).map(function() { |
|
5943 var iframe = $( this ); |
|
5944 |
|
5945 return $( "<div>" ) |
|
5946 .css( "position", "absolute" ) |
|
5947 .appendTo( iframe.parent() ) |
|
5948 .outerWidth( iframe.outerWidth() ) |
|
5949 .outerHeight( iframe.outerHeight() ) |
|
5950 .offset( iframe.offset() )[ 0 ]; |
|
5951 }); |
|
5952 }, |
|
5953 |
|
5954 _unblockFrames: function() { |
|
5955 if ( this.iframeBlocks ) { |
|
5956 this.iframeBlocks.remove(); |
|
5957 delete this.iframeBlocks; |
|
5958 } |
|
5959 }, |
|
5960 |
|
5961 _blurActiveElement: function( event ) { |
|
5962 var document = this.document[ 0 ]; |
|
5963 |
|
5964 // Only need to blur if the event occurred on the draggable itself, see #10527 |
|
5965 if ( !this.handleElement.is( event.target ) ) { |
|
5966 return; |
|
5967 } |
|
5968 |
|
5969 // support: IE9 |
|
5970 // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> |
|
5971 try { |
|
5972 |
|
5973 // Support: IE9, IE10 |
|
5974 // If the <body> is blurred, IE will switch windows, see #9520 |
|
5975 if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) { |
|
5976 |
|
5977 // Blur any element that currently has focus, see #4261 |
|
5978 $( document.activeElement ).blur(); |
|
5979 } |
|
5980 } catch ( error ) {} |
|
5981 }, |
|
5982 |
|
5983 _mouseStart: function(event) { |
|
5984 |
|
5985 var o = this.options; |
|
5986 |
|
5987 //Create and append the visible helper |
|
5988 this.helper = this._createHelper(event); |
|
5989 |
|
5990 this.helper.addClass("ui-draggable-dragging"); |
|
5991 |
|
5992 //Cache the helper size |
|
5993 this._cacheHelperProportions(); |
|
5994 |
|
5995 //If ddmanager is used for droppables, set the global draggable |
|
5996 if ($.ui.ddmanager) { |
|
5997 $.ui.ddmanager.current = this; |
|
5998 } |
|
5999 |
|
6000 /* |
|
6001 * - Position generation - |
|
6002 * This block generates everything position related - it's the core of draggables. |
|
6003 */ |
|
6004 |
|
6005 //Cache the margins of the original element |
|
6006 this._cacheMargins(); |
|
6007 |
|
6008 //Store the helper's css position |
|
6009 this.cssPosition = this.helper.css( "position" ); |
|
6010 this.scrollParent = this.helper.scrollParent( true ); |
|
6011 this.offsetParent = this.helper.offsetParent(); |
|
6012 this.hasFixedAncestor = this.helper.parents().filter(function() { |
|
6013 return $( this ).css( "position" ) === "fixed"; |
|
6014 }).length > 0; |
|
6015 |
|
6016 //The element's absolute position on the page minus margins |
|
6017 this.positionAbs = this.element.offset(); |
|
6018 this._refreshOffsets( event ); |
|
6019 |
|
6020 //Generate the original position |
|
6021 this.originalPosition = this.position = this._generatePosition( event, false ); |
|
6022 this.originalPageX = event.pageX; |
|
6023 this.originalPageY = event.pageY; |
|
6024 |
|
6025 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied |
|
6026 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); |
|
6027 |
|
6028 //Set a containment if given in the options |
|
6029 this._setContainment(); |
|
6030 |
|
6031 //Trigger event + callbacks |
|
6032 if (this._trigger("start", event) === false) { |
|
6033 this._clear(); |
|
6034 return false; |
|
6035 } |
|
6036 |
|
6037 //Recache the helper size |
|
6038 this._cacheHelperProportions(); |
|
6039 |
|
6040 //Prepare the droppable offsets |
|
6041 if ($.ui.ddmanager && !o.dropBehaviour) { |
|
6042 $.ui.ddmanager.prepareOffsets(this, event); |
|
6043 } |
|
6044 |
|
6045 // Reset helper's right/bottom css if they're set and set explicit width/height instead |
|
6046 // as this prevents resizing of elements with right/bottom set (see #7772) |
|
6047 this._normalizeRightBottom(); |
|
6048 |
|
6049 this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
|
6050 |
|
6051 //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) |
|
6052 if ( $.ui.ddmanager ) { |
|
6053 $.ui.ddmanager.dragStart(this, event); |
|
6054 } |
|
6055 |
|
6056 return true; |
|
6057 }, |
|
6058 |
|
6059 _refreshOffsets: function( event ) { |
|
6060 this.offset = { |
|
6061 top: this.positionAbs.top - this.margins.top, |
|
6062 left: this.positionAbs.left - this.margins.left, |
|
6063 scroll: false, |
|
6064 parent: this._getParentOffset(), |
|
6065 relative: this._getRelativeOffset() |
|
6066 }; |
|
6067 |
|
6068 this.offset.click = { |
|
6069 left: event.pageX - this.offset.left, |
|
6070 top: event.pageY - this.offset.top |
|
6071 }; |
|
6072 }, |
|
6073 |
|
6074 _mouseDrag: function(event, noPropagation) { |
|
6075 // reset any necessary cached properties (see #5009) |
|
6076 if ( this.hasFixedAncestor ) { |
|
6077 this.offset.parent = this._getParentOffset(); |
|
6078 } |
|
6079 |
|
6080 //Compute the helpers position |
|
6081 this.position = this._generatePosition( event, true ); |
|
6082 this.positionAbs = this._convertPositionTo("absolute"); |
|
6083 |
|
6084 //Call plugins and callbacks and use the resulting position if something is returned |
|
6085 if (!noPropagation) { |
|
6086 var ui = this._uiHash(); |
|
6087 if (this._trigger("drag", event, ui) === false) { |
|
6088 this._mouseUp({}); |
|
6089 return false; |
|
6090 } |
|
6091 this.position = ui.position; |
|
6092 } |
|
6093 |
|
6094 this.helper[ 0 ].style.left = this.position.left + "px"; |
|
6095 this.helper[ 0 ].style.top = this.position.top + "px"; |
|
6096 |
|
6097 if ($.ui.ddmanager) { |
|
6098 $.ui.ddmanager.drag(this, event); |
|
6099 } |
|
6100 |
|
6101 return false; |
|
6102 }, |
|
6103 |
|
6104 _mouseStop: function(event) { |
|
6105 |
|
6106 //If we are using droppables, inform the manager about the drop |
|
6107 var that = this, |
|
6108 dropped = false; |
|
6109 if ($.ui.ddmanager && !this.options.dropBehaviour) { |
|
6110 dropped = $.ui.ddmanager.drop(this, event); |
|
6111 } |
|
6112 |
|
6113 //if a drop comes from outside (a sortable) |
|
6114 if (this.dropped) { |
|
6115 dropped = this.dropped; |
|
6116 this.dropped = false; |
|
6117 } |
|
6118 |
|
6119 if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { |
|
6120 $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { |
|
6121 if (that._trigger("stop", event) !== false) { |
|
6122 that._clear(); |
|
6123 } |
|
6124 }); |
|
6125 } else { |
|
6126 if (this._trigger("stop", event) !== false) { |
|
6127 this._clear(); |
|
6128 } |
|
6129 } |
|
6130 |
|
6131 return false; |
|
6132 }, |
|
6133 |
|
6134 _mouseUp: function( event ) { |
|
6135 this._unblockFrames(); |
|
6136 |
|
6137 //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) |
|
6138 if ( $.ui.ddmanager ) { |
|
6139 $.ui.ddmanager.dragStop(this, event); |
|
6140 } |
|
6141 |
|
6142 // Only need to focus if the event occurred on the draggable itself, see #10527 |
|
6143 if ( this.handleElement.is( event.target ) ) { |
|
6144 // The interaction is over; whether or not the click resulted in a drag, focus the element |
|
6145 this.element.focus(); |
|
6146 } |
|
6147 |
|
6148 return $.ui.mouse.prototype._mouseUp.call(this, event); |
|
6149 }, |
|
6150 |
|
6151 cancel: function() { |
|
6152 |
|
6153 if (this.helper.is(".ui-draggable-dragging")) { |
|
6154 this._mouseUp({}); |
|
6155 } else { |
|
6156 this._clear(); |
|
6157 } |
|
6158 |
|
6159 return this; |
|
6160 |
|
6161 }, |
|
6162 |
|
6163 _getHandle: function(event) { |
|
6164 return this.options.handle ? |
|
6165 !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : |
|
6166 true; |
|
6167 }, |
|
6168 |
|
6169 _setHandleClassName: function() { |
|
6170 this.handleElement = this.options.handle ? |
|
6171 this.element.find( this.options.handle ) : this.element; |
|
6172 this.handleElement.addClass( "ui-draggable-handle" ); |
|
6173 }, |
|
6174 |
|
6175 _removeHandleClassName: function() { |
|
6176 this.handleElement.removeClass( "ui-draggable-handle" ); |
|
6177 }, |
|
6178 |
|
6179 _createHelper: function(event) { |
|
6180 |
|
6181 var o = this.options, |
|
6182 helperIsFunction = $.isFunction( o.helper ), |
|
6183 helper = helperIsFunction ? |
|
6184 $( o.helper.apply( this.element[ 0 ], [ event ] ) ) : |
|
6185 ( o.helper === "clone" ? |
|
6186 this.element.clone().removeAttr( "id" ) : |
|
6187 this.element ); |
|
6188 |
|
6189 if (!helper.parents("body").length) { |
|
6190 helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo)); |
|
6191 } |
|
6192 |
|
6193 // http://bugs.jqueryui.com/ticket/9446 |
|
6194 // a helper function can return the original element |
|
6195 // which wouldn't have been set to relative in _create |
|
6196 if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) { |
|
6197 this._setPositionRelative(); |
|
6198 } |
|
6199 |
|
6200 if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) { |
|
6201 helper.css("position", "absolute"); |
|
6202 } |
|
6203 |
|
6204 return helper; |
|
6205 |
|
6206 }, |
|
6207 |
|
6208 _setPositionRelative: function() { |
|
6209 if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) { |
|
6210 this.element[ 0 ].style.position = "relative"; |
|
6211 } |
|
6212 }, |
|
6213 |
|
6214 _adjustOffsetFromHelper: function(obj) { |
|
6215 if (typeof obj === "string") { |
|
6216 obj = obj.split(" "); |
|
6217 } |
|
6218 if ($.isArray(obj)) { |
|
6219 obj = { left: +obj[0], top: +obj[1] || 0 }; |
|
6220 } |
|
6221 if ("left" in obj) { |
|
6222 this.offset.click.left = obj.left + this.margins.left; |
|
6223 } |
|
6224 if ("right" in obj) { |
|
6225 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
|
6226 } |
|
6227 if ("top" in obj) { |
|
6228 this.offset.click.top = obj.top + this.margins.top; |
|
6229 } |
|
6230 if ("bottom" in obj) { |
|
6231 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
|
6232 } |
|
6233 }, |
|
6234 |
|
6235 _isRootNode: function( element ) { |
|
6236 return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ]; |
|
6237 }, |
|
6238 |
|
6239 _getParentOffset: function() { |
|
6240 |
|
6241 //Get the offsetParent and cache its position |
|
6242 var po = this.offsetParent.offset(), |
|
6243 document = this.document[ 0 ]; |
|
6244 |
|
6245 // This is a special case where we need to modify a offset calculated on start, since the following happened: |
|
6246 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
|
6247 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
|
6248 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
|
6249 if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) { |
|
6250 po.left += this.scrollParent.scrollLeft(); |
|
6251 po.top += this.scrollParent.scrollTop(); |
|
6252 } |
|
6253 |
|
6254 if ( this._isRootNode( this.offsetParent[ 0 ] ) ) { |
|
6255 po = { top: 0, left: 0 }; |
|
6256 } |
|
6257 |
|
6258 return { |
|
6259 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0), |
|
6260 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0) |
|
6261 }; |
|
6262 |
|
6263 }, |
|
6264 |
|
6265 _getRelativeOffset: function() { |
|
6266 if ( this.cssPosition !== "relative" ) { |
|
6267 return { top: 0, left: 0 }; |
|
6268 } |
|
6269 |
|
6270 var p = this.element.position(), |
|
6271 scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ); |
|
6272 |
|
6273 return { |
|
6274 top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ), |
|
6275 left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 ) |
|
6276 }; |
|
6277 |
|
6278 }, |
|
6279 |
|
6280 _cacheMargins: function() { |
|
6281 this.margins = { |
|
6282 left: (parseInt(this.element.css("marginLeft"), 10) || 0), |
|
6283 top: (parseInt(this.element.css("marginTop"), 10) || 0), |
|
6284 right: (parseInt(this.element.css("marginRight"), 10) || 0), |
|
6285 bottom: (parseInt(this.element.css("marginBottom"), 10) || 0) |
|
6286 }; |
|
6287 }, |
|
6288 |
|
6289 _cacheHelperProportions: function() { |
|
6290 this.helperProportions = { |
|
6291 width: this.helper.outerWidth(), |
|
6292 height: this.helper.outerHeight() |
|
6293 }; |
|
6294 }, |
|
6295 |
|
6296 _setContainment: function() { |
|
6297 |
|
6298 var isUserScrollable, c, ce, |
|
6299 o = this.options, |
|
6300 document = this.document[ 0 ]; |
|
6301 |
|
6302 this.relativeContainer = null; |
|
6303 |
|
6304 if ( !o.containment ) { |
|
6305 this.containment = null; |
|
6306 return; |
|
6307 } |
|
6308 |
|
6309 if ( o.containment === "window" ) { |
|
6310 this.containment = [ |
|
6311 $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left, |
|
6312 $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top, |
|
6313 $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left, |
|
6314 $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top |
|
6315 ]; |
|
6316 return; |
|
6317 } |
|
6318 |
|
6319 if ( o.containment === "document") { |
|
6320 this.containment = [ |
|
6321 0, |
|
6322 0, |
|
6323 $( document ).width() - this.helperProportions.width - this.margins.left, |
|
6324 ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top |
|
6325 ]; |
|
6326 return; |
|
6327 } |
|
6328 |
|
6329 if ( o.containment.constructor === Array ) { |
|
6330 this.containment = o.containment; |
|
6331 return; |
|
6332 } |
|
6333 |
|
6334 if ( o.containment === "parent" ) { |
|
6335 o.containment = this.helper[ 0 ].parentNode; |
|
6336 } |
|
6337 |
|
6338 c = $( o.containment ); |
|
6339 ce = c[ 0 ]; |
|
6340 |
|
6341 if ( !ce ) { |
|
6342 return; |
|
6343 } |
|
6344 |
|
6345 isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) ); |
|
6346 |
|
6347 this.containment = [ |
|
6348 ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), |
|
6349 ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ), |
|
6350 ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - |
|
6351 ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - |
|
6352 ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - |
|
6353 this.helperProportions.width - |
|
6354 this.margins.left - |
|
6355 this.margins.right, |
|
6356 ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - |
|
6357 ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - |
|
6358 ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - |
|
6359 this.helperProportions.height - |
|
6360 this.margins.top - |
|
6361 this.margins.bottom |
|
6362 ]; |
|
6363 this.relativeContainer = c; |
|
6364 }, |
|
6365 |
|
6366 _convertPositionTo: function(d, pos) { |
|
6367 |
|
6368 if (!pos) { |
|
6369 pos = this.position; |
|
6370 } |
|
6371 |
|
6372 var mod = d === "absolute" ? 1 : -1, |
|
6373 scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ); |
|
6374 |
|
6375 return { |
|
6376 top: ( |
|
6377 pos.top + // The absolute mouse position |
|
6378 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent |
|
6379 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) |
|
6380 ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod) |
|
6381 ), |
|
6382 left: ( |
|
6383 pos.left + // The absolute mouse position |
|
6384 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent |
|
6385 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) |
|
6386 ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod) |
|
6387 ) |
|
6388 }; |
|
6389 |
|
6390 }, |
|
6391 |
|
6392 _generatePosition: function( event, constrainPosition ) { |
|
6393 |
|
6394 var containment, co, top, left, |
|
6395 o = this.options, |
|
6396 scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ), |
|
6397 pageX = event.pageX, |
|
6398 pageY = event.pageY; |
|
6399 |
|
6400 // Cache the scroll |
|
6401 if ( !scrollIsRootNode || !this.offset.scroll ) { |
|
6402 this.offset.scroll = { |
|
6403 top: this.scrollParent.scrollTop(), |
|
6404 left: this.scrollParent.scrollLeft() |
|
6405 }; |
|
6406 } |
|
6407 |
|
6408 /* |
|
6409 * - Position constraining - |
|
6410 * Constrain the position to a mix of grid, containment. |
|
6411 */ |
|
6412 |
|
6413 // If we are not dragging yet, we won't check for options |
|
6414 if ( constrainPosition ) { |
|
6415 if ( this.containment ) { |
|
6416 if ( this.relativeContainer ){ |
|
6417 co = this.relativeContainer.offset(); |
|
6418 containment = [ |
|
6419 this.containment[ 0 ] + co.left, |
|
6420 this.containment[ 1 ] + co.top, |
|
6421 this.containment[ 2 ] + co.left, |
|
6422 this.containment[ 3 ] + co.top |
|
6423 ]; |
|
6424 } else { |
|
6425 containment = this.containment; |
|
6426 } |
|
6427 |
|
6428 if (event.pageX - this.offset.click.left < containment[0]) { |
|
6429 pageX = containment[0] + this.offset.click.left; |
|
6430 } |
|
6431 if (event.pageY - this.offset.click.top < containment[1]) { |
|
6432 pageY = containment[1] + this.offset.click.top; |
|
6433 } |
|
6434 if (event.pageX - this.offset.click.left > containment[2]) { |
|
6435 pageX = containment[2] + this.offset.click.left; |
|
6436 } |
|
6437 if (event.pageY - this.offset.click.top > containment[3]) { |
|
6438 pageY = containment[3] + this.offset.click.top; |
|
6439 } |
|
6440 } |
|
6441 |
|
6442 if (o.grid) { |
|
6443 //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) |
|
6444 top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY; |
|
6445 pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
6446 |
|
6447 left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX; |
|
6448 pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; |
|
6449 } |
|
6450 |
|
6451 if ( o.axis === "y" ) { |
|
6452 pageX = this.originalPageX; |
|
6453 } |
|
6454 |
|
6455 if ( o.axis === "x" ) { |
|
6456 pageY = this.originalPageY; |
|
6457 } |
|
6458 } |
|
6459 |
|
6460 return { |
|
6461 top: ( |
|
6462 pageY - // The absolute mouse position |
|
6463 this.offset.click.top - // Click offset (relative to the element) |
|
6464 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent |
|
6465 this.offset.parent.top + // The offsetParent's offset without borders (offset + border) |
|
6466 ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) |
|
6467 ), |
|
6468 left: ( |
|
6469 pageX - // The absolute mouse position |
|
6470 this.offset.click.left - // Click offset (relative to the element) |
|
6471 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent |
|
6472 this.offset.parent.left + // The offsetParent's offset without borders (offset + border) |
|
6473 ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) |
|
6474 ) |
|
6475 }; |
|
6476 |
|
6477 }, |
|
6478 |
|
6479 _clear: function() { |
|
6480 this.helper.removeClass("ui-draggable-dragging"); |
|
6481 if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) { |
|
6482 this.helper.remove(); |
|
6483 } |
|
6484 this.helper = null; |
|
6485 this.cancelHelperRemoval = false; |
|
6486 if ( this.destroyOnClear ) { |
|
6487 this.destroy(); |
|
6488 } |
|
6489 }, |
|
6490 |
|
6491 _normalizeRightBottom: function() { |
|
6492 if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) { |
|
6493 this.helper.width( this.helper.width() ); |
|
6494 this.helper.css( "right", "auto" ); |
|
6495 } |
|
6496 if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) { |
|
6497 this.helper.height( this.helper.height() ); |
|
6498 this.helper.css( "bottom", "auto" ); |
|
6499 } |
|
6500 }, |
|
6501 |
|
6502 // From now on bulk stuff - mainly helpers |
|
6503 |
|
6504 _trigger: function( type, event, ui ) { |
|
6505 ui = ui || this._uiHash(); |
|
6506 $.ui.plugin.call( this, type, [ event, ui, this ], true ); |
|
6507 |
|
6508 // Absolute position and offset (see #6884 ) have to be recalculated after plugins |
|
6509 if ( /^(drag|start|stop)/.test( type ) ) { |
|
6510 this.positionAbs = this._convertPositionTo( "absolute" ); |
|
6511 ui.offset = this.positionAbs; |
|
6512 } |
|
6513 return $.Widget.prototype._trigger.call( this, type, event, ui ); |
|
6514 }, |
|
6515 |
|
6516 plugins: {}, |
|
6517 |
|
6518 _uiHash: function() { |
|
6519 return { |
|
6520 helper: this.helper, |
|
6521 position: this.position, |
|
6522 originalPosition: this.originalPosition, |
|
6523 offset: this.positionAbs |
|
6524 }; |
|
6525 } |
|
6526 |
|
6527 }); |
|
6528 |
|
6529 $.ui.plugin.add( "draggable", "connectToSortable", { |
|
6530 start: function( event, ui, draggable ) { |
|
6531 var uiSortable = $.extend( {}, ui, { |
|
6532 item: draggable.element |
|
6533 }); |
|
6534 |
|
6535 draggable.sortables = []; |
|
6536 $( draggable.options.connectToSortable ).each(function() { |
|
6537 var sortable = $( this ).sortable( "instance" ); |
|
6538 |
|
6539 if ( sortable && !sortable.options.disabled ) { |
|
6540 draggable.sortables.push( sortable ); |
|
6541 |
|
6542 // refreshPositions is called at drag start to refresh the containerCache |
|
6543 // which is used in drag. This ensures it's initialized and synchronized |
|
6544 // with any changes that might have happened on the page since initialization. |
|
6545 sortable.refreshPositions(); |
|
6546 sortable._trigger("activate", event, uiSortable); |
|
6547 } |
|
6548 }); |
|
6549 }, |
|
6550 stop: function( event, ui, draggable ) { |
|
6551 var uiSortable = $.extend( {}, ui, { |
|
6552 item: draggable.element |
|
6553 }); |
|
6554 |
|
6555 draggable.cancelHelperRemoval = false; |
|
6556 |
|
6557 $.each( draggable.sortables, function() { |
|
6558 var sortable = this; |
|
6559 |
|
6560 if ( sortable.isOver ) { |
|
6561 sortable.isOver = 0; |
|
6562 |
|
6563 // Allow this sortable to handle removing the helper |
|
6564 draggable.cancelHelperRemoval = true; |
|
6565 sortable.cancelHelperRemoval = false; |
|
6566 |
|
6567 // Use _storedCSS To restore properties in the sortable, |
|
6568 // as this also handles revert (#9675) since the draggable |
|
6569 // may have modified them in unexpected ways (#8809) |
|
6570 sortable._storedCSS = { |
|
6571 position: sortable.placeholder.css( "position" ), |
|
6572 top: sortable.placeholder.css( "top" ), |
|
6573 left: sortable.placeholder.css( "left" ) |
|
6574 }; |
|
6575 |
|
6576 sortable._mouseStop(event); |
|
6577 |
|
6578 // Once drag has ended, the sortable should return to using |
|
6579 // its original helper, not the shared helper from draggable |
|
6580 sortable.options.helper = sortable.options._helper; |
|
6581 } else { |
|
6582 // Prevent this Sortable from removing the helper. |
|
6583 // However, don't set the draggable to remove the helper |
|
6584 // either as another connected Sortable may yet handle the removal. |
|
6585 sortable.cancelHelperRemoval = true; |
|
6586 |
|
6587 sortable._trigger( "deactivate", event, uiSortable ); |
|
6588 } |
|
6589 }); |
|
6590 }, |
|
6591 drag: function( event, ui, draggable ) { |
|
6592 $.each( draggable.sortables, function() { |
|
6593 var innermostIntersecting = false, |
|
6594 sortable = this; |
|
6595 |
|
6596 // Copy over variables that sortable's _intersectsWith uses |
|
6597 sortable.positionAbs = draggable.positionAbs; |
|
6598 sortable.helperProportions = draggable.helperProportions; |
|
6599 sortable.offset.click = draggable.offset.click; |
|
6600 |
|
6601 if ( sortable._intersectsWith( sortable.containerCache ) ) { |
|
6602 innermostIntersecting = true; |
|
6603 |
|
6604 $.each( draggable.sortables, function() { |
|
6605 // Copy over variables that sortable's _intersectsWith uses |
|
6606 this.positionAbs = draggable.positionAbs; |
|
6607 this.helperProportions = draggable.helperProportions; |
|
6608 this.offset.click = draggable.offset.click; |
|
6609 |
|
6610 if ( this !== sortable && |
|
6611 this._intersectsWith( this.containerCache ) && |
|
6612 $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) { |
|
6613 innermostIntersecting = false; |
|
6614 } |
|
6615 |
|
6616 return innermostIntersecting; |
|
6617 }); |
|
6618 } |
|
6619 |
|
6620 if ( innermostIntersecting ) { |
|
6621 // If it intersects, we use a little isOver variable and set it once, |
|
6622 // so that the move-in stuff gets fired only once. |
|
6623 if ( !sortable.isOver ) { |
|
6624 sortable.isOver = 1; |
|
6625 |
|
6626 // Store draggable's parent in case we need to reappend to it later. |
|
6627 draggable._parent = ui.helper.parent(); |
|
6628 |
|
6629 sortable.currentItem = ui.helper |
|
6630 .appendTo( sortable.element ) |
|
6631 .data( "ui-sortable-item", true ); |
|
6632 |
|
6633 // Store helper option to later restore it |
|
6634 sortable.options._helper = sortable.options.helper; |
|
6635 |
|
6636 sortable.options.helper = function() { |
|
6637 return ui.helper[ 0 ]; |
|
6638 }; |
|
6639 |
|
6640 // Fire the start events of the sortable with our passed browser event, |
|
6641 // and our own helper (so it doesn't create a new one) |
|
6642 event.target = sortable.currentItem[ 0 ]; |
|
6643 sortable._mouseCapture( event, true ); |
|
6644 sortable._mouseStart( event, true, true ); |
|
6645 |
|
6646 // Because the browser event is way off the new appended portlet, |
|
6647 // modify necessary variables to reflect the changes |
|
6648 sortable.offset.click.top = draggable.offset.click.top; |
|
6649 sortable.offset.click.left = draggable.offset.click.left; |
|
6650 sortable.offset.parent.left -= draggable.offset.parent.left - |
|
6651 sortable.offset.parent.left; |
|
6652 sortable.offset.parent.top -= draggable.offset.parent.top - |
|
6653 sortable.offset.parent.top; |
|
6654 |
|
6655 draggable._trigger( "toSortable", event ); |
|
6656 |
|
6657 // Inform draggable that the helper is in a valid drop zone, |
|
6658 // used solely in the revert option to handle "valid/invalid". |
|
6659 draggable.dropped = sortable.element; |
|
6660 |
|
6661 // Need to refreshPositions of all sortables in the case that |
|
6662 // adding to one sortable changes the location of the other sortables (#9675) |
|
6663 $.each( draggable.sortables, function() { |
|
6664 this.refreshPositions(); |
|
6665 }); |
|
6666 |
|
6667 // hack so receive/update callbacks work (mostly) |
|
6668 draggable.currentItem = draggable.element; |
|
6669 sortable.fromOutside = draggable; |
|
6670 } |
|
6671 |
|
6672 if ( sortable.currentItem ) { |
|
6673 sortable._mouseDrag( event ); |
|
6674 // Copy the sortable's position because the draggable's can potentially reflect |
|
6675 // a relative position, while sortable is always absolute, which the dragged |
|
6676 // element has now become. (#8809) |
|
6677 ui.position = sortable.position; |
|
6678 } |
|
6679 } else { |
|
6680 // If it doesn't intersect with the sortable, and it intersected before, |
|
6681 // we fake the drag stop of the sortable, but make sure it doesn't remove |
|
6682 // the helper by using cancelHelperRemoval. |
|
6683 if ( sortable.isOver ) { |
|
6684 |
|
6685 sortable.isOver = 0; |
|
6686 sortable.cancelHelperRemoval = true; |
|
6687 |
|
6688 // Calling sortable's mouseStop would trigger a revert, |
|
6689 // so revert must be temporarily false until after mouseStop is called. |
|
6690 sortable.options._revert = sortable.options.revert; |
|
6691 sortable.options.revert = false; |
|
6692 |
|
6693 sortable._trigger( "out", event, sortable._uiHash( sortable ) ); |
|
6694 sortable._mouseStop( event, true ); |
|
6695 |
|
6696 // restore sortable behaviors that were modfied |
|
6697 // when the draggable entered the sortable area (#9481) |
|
6698 sortable.options.revert = sortable.options._revert; |
|
6699 sortable.options.helper = sortable.options._helper; |
|
6700 |
|
6701 if ( sortable.placeholder ) { |
|
6702 sortable.placeholder.remove(); |
|
6703 } |
|
6704 |
|
6705 // Restore and recalculate the draggable's offset considering the sortable |
|
6706 // may have modified them in unexpected ways. (#8809, #10669) |
|
6707 ui.helper.appendTo( draggable._parent ); |
|
6708 draggable._refreshOffsets( event ); |
|
6709 ui.position = draggable._generatePosition( event, true ); |
|
6710 |
|
6711 draggable._trigger( "fromSortable", event ); |
|
6712 |
|
6713 // Inform draggable that the helper is no longer in a valid drop zone |
|
6714 draggable.dropped = false; |
|
6715 |
|
6716 // Need to refreshPositions of all sortables just in case removing |
|
6717 // from one sortable changes the location of other sortables (#9675) |
|
6718 $.each( draggable.sortables, function() { |
|
6719 this.refreshPositions(); |
|
6720 }); |
|
6721 } |
|
6722 } |
|
6723 }); |
|
6724 } |
|
6725 }); |
|
6726 |
|
6727 $.ui.plugin.add("draggable", "cursor", { |
|
6728 start: function( event, ui, instance ) { |
|
6729 var t = $( "body" ), |
|
6730 o = instance.options; |
|
6731 |
|
6732 if (t.css("cursor")) { |
|
6733 o._cursor = t.css("cursor"); |
|
6734 } |
|
6735 t.css("cursor", o.cursor); |
|
6736 }, |
|
6737 stop: function( event, ui, instance ) { |
|
6738 var o = instance.options; |
|
6739 if (o._cursor) { |
|
6740 $("body").css("cursor", o._cursor); |
|
6741 } |
|
6742 } |
|
6743 }); |
|
6744 |
|
6745 $.ui.plugin.add("draggable", "opacity", { |
|
6746 start: function( event, ui, instance ) { |
|
6747 var t = $( ui.helper ), |
|
6748 o = instance.options; |
|
6749 if (t.css("opacity")) { |
|
6750 o._opacity = t.css("opacity"); |
|
6751 } |
|
6752 t.css("opacity", o.opacity); |
|
6753 }, |
|
6754 stop: function( event, ui, instance ) { |
|
6755 var o = instance.options; |
|
6756 if (o._opacity) { |
|
6757 $(ui.helper).css("opacity", o._opacity); |
|
6758 } |
|
6759 } |
|
6760 }); |
|
6761 |
|
6762 $.ui.plugin.add("draggable", "scroll", { |
|
6763 start: function( event, ui, i ) { |
|
6764 if ( !i.scrollParentNotHidden ) { |
|
6765 i.scrollParentNotHidden = i.helper.scrollParent( false ); |
|
6766 } |
|
6767 |
|
6768 if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) { |
|
6769 i.overflowOffset = i.scrollParentNotHidden.offset(); |
|
6770 } |
|
6771 }, |
|
6772 drag: function( event, ui, i ) { |
|
6773 |
|
6774 var o = i.options, |
|
6775 scrolled = false, |
|
6776 scrollParent = i.scrollParentNotHidden[ 0 ], |
|
6777 document = i.document[ 0 ]; |
|
6778 |
|
6779 if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) { |
|
6780 if ( !o.axis || o.axis !== "x" ) { |
|
6781 if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) { |
|
6782 scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed; |
|
6783 } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) { |
|
6784 scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed; |
|
6785 } |
|
6786 } |
|
6787 |
|
6788 if ( !o.axis || o.axis !== "y" ) { |
|
6789 if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) { |
|
6790 scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed; |
|
6791 } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) { |
|
6792 scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed; |
|
6793 } |
|
6794 } |
|
6795 |
|
6796 } else { |
|
6797 |
|
6798 if (!o.axis || o.axis !== "x") { |
|
6799 if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) { |
|
6800 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
|
6801 } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) { |
|
6802 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
|
6803 } |
|
6804 } |
|
6805 |
|
6806 if (!o.axis || o.axis !== "y") { |
|
6807 if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) { |
|
6808 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
|
6809 } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) { |
|
6810 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
|
6811 } |
|
6812 } |
|
6813 |
|
6814 } |
|
6815 |
|
6816 if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { |
|
6817 $.ui.ddmanager.prepareOffsets(i, event); |
|
6818 } |
|
6819 |
|
6820 } |
|
6821 }); |
|
6822 |
|
6823 $.ui.plugin.add("draggable", "snap", { |
|
6824 start: function( event, ui, i ) { |
|
6825 |
|
6826 var o = i.options; |
|
6827 |
|
6828 i.snapElements = []; |
|
6829 |
|
6830 $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() { |
|
6831 var $t = $(this), |
|
6832 $o = $t.offset(); |
|
6833 if (this !== i.element[0]) { |
|
6834 i.snapElements.push({ |
|
6835 item: this, |
|
6836 width: $t.outerWidth(), height: $t.outerHeight(), |
|
6837 top: $o.top, left: $o.left |
|
6838 }); |
|
6839 } |
|
6840 }); |
|
6841 |
|
6842 }, |
|
6843 drag: function( event, ui, inst ) { |
|
6844 |
|
6845 var ts, bs, ls, rs, l, r, t, b, i, first, |
|
6846 o = inst.options, |
|
6847 d = o.snapTolerance, |
|
6848 x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, |
|
6849 y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; |
|
6850 |
|
6851 for (i = inst.snapElements.length - 1; i >= 0; i--){ |
|
6852 |
|
6853 l = inst.snapElements[i].left - inst.margins.left; |
|
6854 r = l + inst.snapElements[i].width; |
|
6855 t = inst.snapElements[i].top - inst.margins.top; |
|
6856 b = t + inst.snapElements[i].height; |
|
6857 |
|
6858 if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) { |
|
6859 if (inst.snapElements[i].snapping) { |
|
6860 (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
6861 } |
|
6862 inst.snapElements[i].snapping = false; |
|
6863 continue; |
|
6864 } |
|
6865 |
|
6866 if (o.snapMode !== "inner") { |
|
6867 ts = Math.abs(t - y2) <= d; |
|
6868 bs = Math.abs(b - y1) <= d; |
|
6869 ls = Math.abs(l - x2) <= d; |
|
6870 rs = Math.abs(r - x1) <= d; |
|
6871 if (ts) { |
|
6872 ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top; |
|
6873 } |
|
6874 if (bs) { |
|
6875 ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top; |
|
6876 } |
|
6877 if (ls) { |
|
6878 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left; |
|
6879 } |
|
6880 if (rs) { |
|
6881 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left; |
|
6882 } |
|
6883 } |
|
6884 |
|
6885 first = (ts || bs || ls || rs); |
|
6886 |
|
6887 if (o.snapMode !== "outer") { |
|
6888 ts = Math.abs(t - y1) <= d; |
|
6889 bs = Math.abs(b - y2) <= d; |
|
6890 ls = Math.abs(l - x1) <= d; |
|
6891 rs = Math.abs(r - x2) <= d; |
|
6892 if (ts) { |
|
6893 ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top; |
|
6894 } |
|
6895 if (bs) { |
|
6896 ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top; |
|
6897 } |
|
6898 if (ls) { |
|
6899 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left; |
|
6900 } |
|
6901 if (rs) { |
|
6902 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left; |
|
6903 } |
|
6904 } |
|
6905 |
|
6906 if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) { |
|
6907 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
6908 } |
|
6909 inst.snapElements[i].snapping = (ts || bs || ls || rs || first); |
|
6910 |
|
6911 } |
|
6912 |
|
6913 } |
|
6914 }); |
|
6915 |
|
6916 $.ui.plugin.add("draggable", "stack", { |
|
6917 start: function( event, ui, instance ) { |
|
6918 var min, |
|
6919 o = instance.options, |
|
6920 group = $.makeArray($(o.stack)).sort(function(a, b) { |
|
6921 return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0); |
|
6922 }); |
|
6923 |
|
6924 if (!group.length) { return; } |
|
6925 |
|
6926 min = parseInt($(group[0]).css("zIndex"), 10) || 0; |
|
6927 $(group).each(function(i) { |
|
6928 $(this).css("zIndex", min + i); |
|
6929 }); |
|
6930 this.css("zIndex", (min + group.length)); |
|
6931 } |
|
6932 }); |
|
6933 |
|
6934 $.ui.plugin.add("draggable", "zIndex", { |
|
6935 start: function( event, ui, instance ) { |
|
6936 var t = $( ui.helper ), |
|
6937 o = instance.options; |
|
6938 |
|
6939 if (t.css("zIndex")) { |
|
6940 o._zIndex = t.css("zIndex"); |
|
6941 } |
|
6942 t.css("zIndex", o.zIndex); |
|
6943 }, |
|
6944 stop: function( event, ui, instance ) { |
|
6945 var o = instance.options; |
|
6946 |
|
6947 if (o._zIndex) { |
|
6948 $(ui.helper).css("zIndex", o._zIndex); |
|
6949 } |
|
6950 } |
|
6951 }); |
|
6952 |
|
6953 var draggable = $.ui.draggable; |
|
6954 |
|
6955 |
|
6956 /*! |
|
6957 * jQuery UI Resizable 1.11.4 |
|
6958 * http://jqueryui.com |
|
6959 * |
|
6960 * Copyright jQuery Foundation and other contributors |
|
6961 * Released under the MIT license. |
|
6962 * http://jquery.org/license |
|
6963 * |
|
6964 * http://api.jqueryui.com/resizable/ |
|
6965 */ |
|
6966 |
|
6967 |
|
6968 $.widget("ui.resizable", $.ui.mouse, { |
|
6969 version: "1.11.4", |
|
6970 widgetEventPrefix: "resize", |
|
6971 options: { |
|
6972 alsoResize: false, |
|
6973 animate: false, |
|
6974 animateDuration: "slow", |
|
6975 animateEasing: "swing", |
|
6976 aspectRatio: false, |
|
6977 autoHide: false, |
|
6978 containment: false, |
|
6979 ghost: false, |
|
6980 grid: false, |
|
6981 handles: "e,s,se", |
|
6982 helper: false, |
|
6983 maxHeight: null, |
|
6984 maxWidth: null, |
|
6985 minHeight: 10, |
|
6986 minWidth: 10, |
|
6987 // See #7960 |
|
6988 zIndex: 90, |
|
6989 |
|
6990 // callbacks |
|
6991 resize: null, |
|
6992 start: null, |
|
6993 stop: null |
|
6994 }, |
|
6995 |
|
6996 _num: function( value ) { |
|
6997 return parseInt( value, 10 ) || 0; |
|
6998 }, |
|
6999 |
|
7000 _isNumber: function( value ) { |
|
7001 return !isNaN( parseInt( value, 10 ) ); |
|
7002 }, |
|
7003 |
|
7004 _hasScroll: function( el, a ) { |
|
7005 |
|
7006 if ( $( el ).css( "overflow" ) === "hidden") { |
|
7007 return false; |
|
7008 } |
|
7009 |
|
7010 var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop", |
|
7011 has = false; |
|
7012 |
|
7013 if ( el[ scroll ] > 0 ) { |
|
7014 return true; |
|
7015 } |
|
7016 |
|
7017 // TODO: determine which cases actually cause this to happen |
|
7018 // if the element doesn't have the scroll set, see if it's possible to |
|
7019 // set the scroll |
|
7020 el[ scroll ] = 1; |
|
7021 has = ( el[ scroll ] > 0 ); |
|
7022 el[ scroll ] = 0; |
|
7023 return has; |
|
7024 }, |
|
7025 |
|
7026 _create: function() { |
|
7027 |
|
7028 var n, i, handle, axis, hname, |
|
7029 that = this, |
|
7030 o = this.options; |
|
7031 this.element.addClass("ui-resizable"); |
|
7032 |
|
7033 $.extend(this, { |
|
7034 _aspectRatio: !!(o.aspectRatio), |
|
7035 aspectRatio: o.aspectRatio, |
|
7036 originalElement: this.element, |
|
7037 _proportionallyResizeElements: [], |
|
7038 _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null |
|
7039 }); |
|
7040 |
|
7041 // Wrap the element if it cannot hold child nodes |
|
7042 if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) { |
|
7043 |
|
7044 this.element.wrap( |
|
7045 $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({ |
|
7046 position: this.element.css("position"), |
|
7047 width: this.element.outerWidth(), |
|
7048 height: this.element.outerHeight(), |
|
7049 top: this.element.css("top"), |
|
7050 left: this.element.css("left") |
|
7051 }) |
|
7052 ); |
|
7053 |
|
7054 this.element = this.element.parent().data( |
|
7055 "ui-resizable", this.element.resizable( "instance" ) |
|
7056 ); |
|
7057 |
|
7058 this.elementIsWrapper = true; |
|
7059 |
|
7060 this.element.css({ |
|
7061 marginLeft: this.originalElement.css("marginLeft"), |
|
7062 marginTop: this.originalElement.css("marginTop"), |
|
7063 marginRight: this.originalElement.css("marginRight"), |
|
7064 marginBottom: this.originalElement.css("marginBottom") |
|
7065 }); |
|
7066 this.originalElement.css({ |
|
7067 marginLeft: 0, |
|
7068 marginTop: 0, |
|
7069 marginRight: 0, |
|
7070 marginBottom: 0 |
|
7071 }); |
|
7072 // support: Safari |
|
7073 // Prevent Safari textarea resize |
|
7074 this.originalResizeStyle = this.originalElement.css("resize"); |
|
7075 this.originalElement.css("resize", "none"); |
|
7076 |
|
7077 this._proportionallyResizeElements.push( this.originalElement.css({ |
|
7078 position: "static", |
|
7079 zoom: 1, |
|
7080 display: "block" |
|
7081 }) ); |
|
7082 |
|
7083 // support: IE9 |
|
7084 // avoid IE jump (hard set the margin) |
|
7085 this.originalElement.css({ margin: this.originalElement.css("margin") }); |
|
7086 |
|
7087 this._proportionallyResize(); |
|
7088 } |
|
7089 |
|
7090 this.handles = o.handles || |
|
7091 ( !$(".ui-resizable-handle", this.element).length ? |
|
7092 "e,s,se" : { |
|
7093 n: ".ui-resizable-n", |
|
7094 e: ".ui-resizable-e", |
|
7095 s: ".ui-resizable-s", |
|
7096 w: ".ui-resizable-w", |
|
7097 se: ".ui-resizable-se", |
|
7098 sw: ".ui-resizable-sw", |
|
7099 ne: ".ui-resizable-ne", |
|
7100 nw: ".ui-resizable-nw" |
|
7101 } ); |
|
7102 |
|
7103 this._handles = $(); |
|
7104 if ( this.handles.constructor === String ) { |
|
7105 |
|
7106 if ( this.handles === "all") { |
|
7107 this.handles = "n,e,s,w,se,sw,ne,nw"; |
|
7108 } |
|
7109 |
|
7110 n = this.handles.split(","); |
|
7111 this.handles = {}; |
|
7112 |
|
7113 for (i = 0; i < n.length; i++) { |
|
7114 |
|
7115 handle = $.trim(n[i]); |
|
7116 hname = "ui-resizable-" + handle; |
|
7117 axis = $("<div class='ui-resizable-handle " + hname + "'></div>"); |
|
7118 |
|
7119 axis.css({ zIndex: o.zIndex }); |
|
7120 |
|
7121 // TODO : What's going on here? |
|
7122 if ("se" === handle) { |
|
7123 axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se"); |
|
7124 } |
|
7125 |
|
7126 this.handles[handle] = ".ui-resizable-" + handle; |
|
7127 this.element.append(axis); |
|
7128 } |
|
7129 |
|
7130 } |
|
7131 |
|
7132 this._renderAxis = function(target) { |
|
7133 |
|
7134 var i, axis, padPos, padWrapper; |
|
7135 |
|
7136 target = target || this.element; |
|
7137 |
|
7138 for (i in this.handles) { |
|
7139 |
|
7140 if (this.handles[i].constructor === String) { |
|
7141 this.handles[i] = this.element.children( this.handles[ i ] ).first().show(); |
|
7142 } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) { |
|
7143 this.handles[ i ] = $( this.handles[ i ] ); |
|
7144 this._on( this.handles[ i ], { "mousedown": that._mouseDown }); |
|
7145 } |
|
7146 |
|
7147 if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) { |
|
7148 |
|
7149 axis = $(this.handles[i], this.element); |
|
7150 |
|
7151 padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); |
|
7152 |
|
7153 padPos = [ "padding", |
|
7154 /ne|nw|n/.test(i) ? "Top" : |
|
7155 /se|sw|s/.test(i) ? "Bottom" : |
|
7156 /^e$/.test(i) ? "Right" : "Left" ].join(""); |
|
7157 |
|
7158 target.css(padPos, padWrapper); |
|
7159 |
|
7160 this._proportionallyResize(); |
|
7161 } |
|
7162 |
|
7163 this._handles = this._handles.add( this.handles[ i ] ); |
|
7164 } |
|
7165 }; |
|
7166 |
|
7167 // TODO: make renderAxis a prototype function |
|
7168 this._renderAxis(this.element); |
|
7169 |
|
7170 this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) ); |
|
7171 this._handles.disableSelection(); |
|
7172 |
|
7173 this._handles.mouseover(function() { |
|
7174 if (!that.resizing) { |
|
7175 if (this.className) { |
|
7176 axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); |
|
7177 } |
|
7178 that.axis = axis && axis[1] ? axis[1] : "se"; |
|
7179 } |
|
7180 }); |
|
7181 |
|
7182 if (o.autoHide) { |
|
7183 this._handles.hide(); |
|
7184 $(this.element) |
|
7185 .addClass("ui-resizable-autohide") |
|
7186 .mouseenter(function() { |
|
7187 if (o.disabled) { |
|
7188 return; |
|
7189 } |
|
7190 $(this).removeClass("ui-resizable-autohide"); |
|
7191 that._handles.show(); |
|
7192 }) |
|
7193 .mouseleave(function() { |
|
7194 if (o.disabled) { |
|
7195 return; |
|
7196 } |
|
7197 if (!that.resizing) { |
|
7198 $(this).addClass("ui-resizable-autohide"); |
|
7199 that._handles.hide(); |
|
7200 } |
|
7201 }); |
|
7202 } |
|
7203 |
|
7204 this._mouseInit(); |
|
7205 }, |
|
7206 |
|
7207 _destroy: function() { |
|
7208 |
|
7209 this._mouseDestroy(); |
|
7210 |
|
7211 var wrapper, |
|
7212 _destroy = function(exp) { |
|
7213 $(exp) |
|
7214 .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing") |
|
7215 .removeData("resizable") |
|
7216 .removeData("ui-resizable") |
|
7217 .unbind(".resizable") |
|
7218 .find(".ui-resizable-handle") |
|
7219 .remove(); |
|
7220 }; |
|
7221 |
|
7222 // TODO: Unwrap at same DOM position |
|
7223 if (this.elementIsWrapper) { |
|
7224 _destroy(this.element); |
|
7225 wrapper = this.element; |
|
7226 this.originalElement.css({ |
|
7227 position: wrapper.css("position"), |
|
7228 width: wrapper.outerWidth(), |
|
7229 height: wrapper.outerHeight(), |
|
7230 top: wrapper.css("top"), |
|
7231 left: wrapper.css("left") |
|
7232 }).insertAfter( wrapper ); |
|
7233 wrapper.remove(); |
|
7234 } |
|
7235 |
|
7236 this.originalElement.css("resize", this.originalResizeStyle); |
|
7237 _destroy(this.originalElement); |
|
7238 |
|
7239 return this; |
|
7240 }, |
|
7241 |
|
7242 _mouseCapture: function(event) { |
|
7243 var i, handle, |
|
7244 capture = false; |
|
7245 |
|
7246 for (i in this.handles) { |
|
7247 handle = $(this.handles[i])[0]; |
|
7248 if (handle === event.target || $.contains(handle, event.target)) { |
|
7249 capture = true; |
|
7250 } |
|
7251 } |
|
7252 |
|
7253 return !this.options.disabled && capture; |
|
7254 }, |
|
7255 |
|
7256 _mouseStart: function(event) { |
|
7257 |
|
7258 var curleft, curtop, cursor, |
|
7259 o = this.options, |
|
7260 el = this.element; |
|
7261 |
|
7262 this.resizing = true; |
|
7263 |
|
7264 this._renderProxy(); |
|
7265 |
|
7266 curleft = this._num(this.helper.css("left")); |
|
7267 curtop = this._num(this.helper.css("top")); |
|
7268 |
|
7269 if (o.containment) { |
|
7270 curleft += $(o.containment).scrollLeft() || 0; |
|
7271 curtop += $(o.containment).scrollTop() || 0; |
|
7272 } |
|
7273 |
|
7274 this.offset = this.helper.offset(); |
|
7275 this.position = { left: curleft, top: curtop }; |
|
7276 |
|
7277 this.size = this._helper ? { |
|
7278 width: this.helper.width(), |
|
7279 height: this.helper.height() |
|
7280 } : { |
|
7281 width: el.width(), |
|
7282 height: el.height() |
|
7283 }; |
|
7284 |
|
7285 this.originalSize = this._helper ? { |
|
7286 width: el.outerWidth(), |
|
7287 height: el.outerHeight() |
|
7288 } : { |
|
7289 width: el.width(), |
|
7290 height: el.height() |
|
7291 }; |
|
7292 |
|
7293 this.sizeDiff = { |
|
7294 width: el.outerWidth() - el.width(), |
|
7295 height: el.outerHeight() - el.height() |
|
7296 }; |
|
7297 |
|
7298 this.originalPosition = { left: curleft, top: curtop }; |
|
7299 this.originalMousePosition = { left: event.pageX, top: event.pageY }; |
|
7300 |
|
7301 this.aspectRatio = (typeof o.aspectRatio === "number") ? |
|
7302 o.aspectRatio : |
|
7303 ((this.originalSize.width / this.originalSize.height) || 1); |
|
7304 |
|
7305 cursor = $(".ui-resizable-" + this.axis).css("cursor"); |
|
7306 $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor); |
|
7307 |
|
7308 el.addClass("ui-resizable-resizing"); |
|
7309 this._propagate("start", event); |
|
7310 return true; |
|
7311 }, |
|
7312 |
|
7313 _mouseDrag: function(event) { |
|
7314 |
|
7315 var data, props, |
|
7316 smp = this.originalMousePosition, |
|
7317 a = this.axis, |
|
7318 dx = (event.pageX - smp.left) || 0, |
|
7319 dy = (event.pageY - smp.top) || 0, |
|
7320 trigger = this._change[a]; |
|
7321 |
|
7322 this._updatePrevProperties(); |
|
7323 |
|
7324 if (!trigger) { |
|
7325 return false; |
|
7326 } |
|
7327 |
|
7328 data = trigger.apply(this, [ event, dx, dy ]); |
|
7329 |
|
7330 this._updateVirtualBoundaries(event.shiftKey); |
|
7331 if (this._aspectRatio || event.shiftKey) { |
|
7332 data = this._updateRatio(data, event); |
|
7333 } |
|
7334 |
|
7335 data = this._respectSize(data, event); |
|
7336 |
|
7337 this._updateCache(data); |
|
7338 |
|
7339 this._propagate("resize", event); |
|
7340 |
|
7341 props = this._applyChanges(); |
|
7342 |
|
7343 if ( !this._helper && this._proportionallyResizeElements.length ) { |
|
7344 this._proportionallyResize(); |
|
7345 } |
|
7346 |
|
7347 if ( !$.isEmptyObject( props ) ) { |
|
7348 this._updatePrevProperties(); |
|
7349 this._trigger( "resize", event, this.ui() ); |
|
7350 this._applyChanges(); |
|
7351 } |
|
7352 |
|
7353 return false; |
|
7354 }, |
|
7355 |
|
7356 _mouseStop: function(event) { |
|
7357 |
|
7358 this.resizing = false; |
|
7359 var pr, ista, soffseth, soffsetw, s, left, top, |
|
7360 o = this.options, that = this; |
|
7361 |
|
7362 if (this._helper) { |
|
7363 |
|
7364 pr = this._proportionallyResizeElements; |
|
7365 ista = pr.length && (/textarea/i).test(pr[0].nodeName); |
|
7366 soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height; |
|
7367 soffsetw = ista ? 0 : that.sizeDiff.width; |
|
7368 |
|
7369 s = { |
|
7370 width: (that.helper.width() - soffsetw), |
|
7371 height: (that.helper.height() - soffseth) |
|
7372 }; |
|
7373 left = (parseInt(that.element.css("left"), 10) + |
|
7374 (that.position.left - that.originalPosition.left)) || null; |
|
7375 top = (parseInt(that.element.css("top"), 10) + |
|
7376 (that.position.top - that.originalPosition.top)) || null; |
|
7377 |
|
7378 if (!o.animate) { |
|
7379 this.element.css($.extend(s, { top: top, left: left })); |
|
7380 } |
|
7381 |
|
7382 that.helper.height(that.size.height); |
|
7383 that.helper.width(that.size.width); |
|
7384 |
|
7385 if (this._helper && !o.animate) { |
|
7386 this._proportionallyResize(); |
|
7387 } |
|
7388 } |
|
7389 |
|
7390 $("body").css("cursor", "auto"); |
|
7391 |
|
7392 this.element.removeClass("ui-resizable-resizing"); |
|
7393 |
|
7394 this._propagate("stop", event); |
|
7395 |
|
7396 if (this._helper) { |
|
7397 this.helper.remove(); |
|
7398 } |
|
7399 |
|
7400 return false; |
|
7401 |
|
7402 }, |
|
7403 |
|
7404 _updatePrevProperties: function() { |
|
7405 this.prevPosition = { |
|
7406 top: this.position.top, |
|
7407 left: this.position.left |
|
7408 }; |
|
7409 this.prevSize = { |
|
7410 width: this.size.width, |
|
7411 height: this.size.height |
|
7412 }; |
|
7413 }, |
|
7414 |
|
7415 _applyChanges: function() { |
|
7416 var props = {}; |
|
7417 |
|
7418 if ( this.position.top !== this.prevPosition.top ) { |
|
7419 props.top = this.position.top + "px"; |
|
7420 } |
|
7421 if ( this.position.left !== this.prevPosition.left ) { |
|
7422 props.left = this.position.left + "px"; |
|
7423 } |
|
7424 if ( this.size.width !== this.prevSize.width ) { |
|
7425 props.width = this.size.width + "px"; |
|
7426 } |
|
7427 if ( this.size.height !== this.prevSize.height ) { |
|
7428 props.height = this.size.height + "px"; |
|
7429 } |
|
7430 |
|
7431 this.helper.css( props ); |
|
7432 |
|
7433 return props; |
|
7434 }, |
|
7435 |
|
7436 _updateVirtualBoundaries: function(forceAspectRatio) { |
|
7437 var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b, |
|
7438 o = this.options; |
|
7439 |
|
7440 b = { |
|
7441 minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0, |
|
7442 maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity, |
|
7443 minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0, |
|
7444 maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity |
|
7445 }; |
|
7446 |
|
7447 if (this._aspectRatio || forceAspectRatio) { |
|
7448 pMinWidth = b.minHeight * this.aspectRatio; |
|
7449 pMinHeight = b.minWidth / this.aspectRatio; |
|
7450 pMaxWidth = b.maxHeight * this.aspectRatio; |
|
7451 pMaxHeight = b.maxWidth / this.aspectRatio; |
|
7452 |
|
7453 if (pMinWidth > b.minWidth) { |
|
7454 b.minWidth = pMinWidth; |
|
7455 } |
|
7456 if (pMinHeight > b.minHeight) { |
|
7457 b.minHeight = pMinHeight; |
|
7458 } |
|
7459 if (pMaxWidth < b.maxWidth) { |
|
7460 b.maxWidth = pMaxWidth; |
|
7461 } |
|
7462 if (pMaxHeight < b.maxHeight) { |
|
7463 b.maxHeight = pMaxHeight; |
|
7464 } |
|
7465 } |
|
7466 this._vBoundaries = b; |
|
7467 }, |
|
7468 |
|
7469 _updateCache: function(data) { |
|
7470 this.offset = this.helper.offset(); |
|
7471 if (this._isNumber(data.left)) { |
|
7472 this.position.left = data.left; |
|
7473 } |
|
7474 if (this._isNumber(data.top)) { |
|
7475 this.position.top = data.top; |
|
7476 } |
|
7477 if (this._isNumber(data.height)) { |
|
7478 this.size.height = data.height; |
|
7479 } |
|
7480 if (this._isNumber(data.width)) { |
|
7481 this.size.width = data.width; |
|
7482 } |
|
7483 }, |
|
7484 |
|
7485 _updateRatio: function( data ) { |
|
7486 |
|
7487 var cpos = this.position, |
|
7488 csize = this.size, |
|
7489 a = this.axis; |
|
7490 |
|
7491 if (this._isNumber(data.height)) { |
|
7492 data.width = (data.height * this.aspectRatio); |
|
7493 } else if (this._isNumber(data.width)) { |
|
7494 data.height = (data.width / this.aspectRatio); |
|
7495 } |
|
7496 |
|
7497 if (a === "sw") { |
|
7498 data.left = cpos.left + (csize.width - data.width); |
|
7499 data.top = null; |
|
7500 } |
|
7501 if (a === "nw") { |
|
7502 data.top = cpos.top + (csize.height - data.height); |
|
7503 data.left = cpos.left + (csize.width - data.width); |
|
7504 } |
|
7505 |
|
7506 return data; |
|
7507 }, |
|
7508 |
|
7509 _respectSize: function( data ) { |
|
7510 |
|
7511 var o = this._vBoundaries, |
|
7512 a = this.axis, |
|
7513 ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), |
|
7514 ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), |
|
7515 isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width), |
|
7516 isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height), |
|
7517 dw = this.originalPosition.left + this.originalSize.width, |
|
7518 dh = this.position.top + this.size.height, |
|
7519 cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); |
|
7520 if (isminw) { |
|
7521 data.width = o.minWidth; |
|
7522 } |
|
7523 if (isminh) { |
|
7524 data.height = o.minHeight; |
|
7525 } |
|
7526 if (ismaxw) { |
|
7527 data.width = o.maxWidth; |
|
7528 } |
|
7529 if (ismaxh) { |
|
7530 data.height = o.maxHeight; |
|
7531 } |
|
7532 |
|
7533 if (isminw && cw) { |
|
7534 data.left = dw - o.minWidth; |
|
7535 } |
|
7536 if (ismaxw && cw) { |
|
7537 data.left = dw - o.maxWidth; |
|
7538 } |
|
7539 if (isminh && ch) { |
|
7540 data.top = dh - o.minHeight; |
|
7541 } |
|
7542 if (ismaxh && ch) { |
|
7543 data.top = dh - o.maxHeight; |
|
7544 } |
|
7545 |
|
7546 // Fixing jump error on top/left - bug #2330 |
|
7547 if (!data.width && !data.height && !data.left && data.top) { |
|
7548 data.top = null; |
|
7549 } else if (!data.width && !data.height && !data.top && data.left) { |
|
7550 data.left = null; |
|
7551 } |
|
7552 |
|
7553 return data; |
|
7554 }, |
|
7555 |
|
7556 _getPaddingPlusBorderDimensions: function( element ) { |
|
7557 var i = 0, |
|
7558 widths = [], |
|
7559 borders = [ |
|
7560 element.css( "borderTopWidth" ), |
|
7561 element.css( "borderRightWidth" ), |
|
7562 element.css( "borderBottomWidth" ), |
|
7563 element.css( "borderLeftWidth" ) |
|
7564 ], |
|
7565 paddings = [ |
|
7566 element.css( "paddingTop" ), |
|
7567 element.css( "paddingRight" ), |
|
7568 element.css( "paddingBottom" ), |
|
7569 element.css( "paddingLeft" ) |
|
7570 ]; |
|
7571 |
|
7572 for ( ; i < 4; i++ ) { |
|
7573 widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 ); |
|
7574 widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 ); |
|
7575 } |
|
7576 |
|
7577 return { |
|
7578 height: widths[ 0 ] + widths[ 2 ], |
|
7579 width: widths[ 1 ] + widths[ 3 ] |
|
7580 }; |
|
7581 }, |
|
7582 |
|
7583 _proportionallyResize: function() { |
|
7584 |
|
7585 if (!this._proportionallyResizeElements.length) { |
|
7586 return; |
|
7587 } |
|
7588 |
|
7589 var prel, |
|
7590 i = 0, |
|
7591 element = this.helper || this.element; |
|
7592 |
|
7593 for ( ; i < this._proportionallyResizeElements.length; i++) { |
|
7594 |
|
7595 prel = this._proportionallyResizeElements[i]; |
|
7596 |
|
7597 // TODO: Seems like a bug to cache this.outerDimensions |
|
7598 // considering that we are in a loop. |
|
7599 if (!this.outerDimensions) { |
|
7600 this.outerDimensions = this._getPaddingPlusBorderDimensions( prel ); |
|
7601 } |
|
7602 |
|
7603 prel.css({ |
|
7604 height: (element.height() - this.outerDimensions.height) || 0, |
|
7605 width: (element.width() - this.outerDimensions.width) || 0 |
|
7606 }); |
|
7607 |
|
7608 } |
|
7609 |
|
7610 }, |
|
7611 |
|
7612 _renderProxy: function() { |
|
7613 |
|
7614 var el = this.element, o = this.options; |
|
7615 this.elementOffset = el.offset(); |
|
7616 |
|
7617 if (this._helper) { |
|
7618 |
|
7619 this.helper = this.helper || $("<div style='overflow:hidden;'></div>"); |
|
7620 |
|
7621 this.helper.addClass(this._helper).css({ |
|
7622 width: this.element.outerWidth() - 1, |
|
7623 height: this.element.outerHeight() - 1, |
|
7624 position: "absolute", |
|
7625 left: this.elementOffset.left + "px", |
|
7626 top: this.elementOffset.top + "px", |
|
7627 zIndex: ++o.zIndex //TODO: Don't modify option |
|
7628 }); |
|
7629 |
|
7630 this.helper |
|
7631 .appendTo("body") |
|
7632 .disableSelection(); |
|
7633 |
|
7634 } else { |
|
7635 this.helper = this.element; |
|
7636 } |
|
7637 |
|
7638 }, |
|
7639 |
|
7640 _change: { |
|
7641 e: function(event, dx) { |
|
7642 return { width: this.originalSize.width + dx }; |
|
7643 }, |
|
7644 w: function(event, dx) { |
|
7645 var cs = this.originalSize, sp = this.originalPosition; |
|
7646 return { left: sp.left + dx, width: cs.width - dx }; |
|
7647 }, |
|
7648 n: function(event, dx, dy) { |
|
7649 var cs = this.originalSize, sp = this.originalPosition; |
|
7650 return { top: sp.top + dy, height: cs.height - dy }; |
|
7651 }, |
|
7652 s: function(event, dx, dy) { |
|
7653 return { height: this.originalSize.height + dy }; |
|
7654 }, |
|
7655 se: function(event, dx, dy) { |
|
7656 return $.extend(this._change.s.apply(this, arguments), |
|
7657 this._change.e.apply(this, [ event, dx, dy ])); |
|
7658 }, |
|
7659 sw: function(event, dx, dy) { |
|
7660 return $.extend(this._change.s.apply(this, arguments), |
|
7661 this._change.w.apply(this, [ event, dx, dy ])); |
|
7662 }, |
|
7663 ne: function(event, dx, dy) { |
|
7664 return $.extend(this._change.n.apply(this, arguments), |
|
7665 this._change.e.apply(this, [ event, dx, dy ])); |
|
7666 }, |
|
7667 nw: function(event, dx, dy) { |
|
7668 return $.extend(this._change.n.apply(this, arguments), |
|
7669 this._change.w.apply(this, [ event, dx, dy ])); |
|
7670 } |
|
7671 }, |
|
7672 |
|
7673 _propagate: function(n, event) { |
|
7674 $.ui.plugin.call(this, n, [ event, this.ui() ]); |
|
7675 (n !== "resize" && this._trigger(n, event, this.ui())); |
|
7676 }, |
|
7677 |
|
7678 plugins: {}, |
|
7679 |
|
7680 ui: function() { |
|
7681 return { |
|
7682 originalElement: this.originalElement, |
|
7683 element: this.element, |
|
7684 helper: this.helper, |
|
7685 position: this.position, |
|
7686 size: this.size, |
|
7687 originalSize: this.originalSize, |
|
7688 originalPosition: this.originalPosition |
|
7689 }; |
|
7690 } |
|
7691 |
|
7692 }); |
|
7693 |
|
7694 /* |
|
7695 * Resizable Extensions |
|
7696 */ |
|
7697 |
|
7698 $.ui.plugin.add("resizable", "animate", { |
|
7699 |
|
7700 stop: function( event ) { |
|
7701 var that = $(this).resizable( "instance" ), |
|
7702 o = that.options, |
|
7703 pr = that._proportionallyResizeElements, |
|
7704 ista = pr.length && (/textarea/i).test(pr[0].nodeName), |
|
7705 soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height, |
|
7706 soffsetw = ista ? 0 : that.sizeDiff.width, |
|
7707 style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) }, |
|
7708 left = (parseInt(that.element.css("left"), 10) + |
|
7709 (that.position.left - that.originalPosition.left)) || null, |
|
7710 top = (parseInt(that.element.css("top"), 10) + |
|
7711 (that.position.top - that.originalPosition.top)) || null; |
|
7712 |
|
7713 that.element.animate( |
|
7714 $.extend(style, top && left ? { top: top, left: left } : {}), { |
|
7715 duration: o.animateDuration, |
|
7716 easing: o.animateEasing, |
|
7717 step: function() { |
|
7718 |
|
7719 var data = { |
|
7720 width: parseInt(that.element.css("width"), 10), |
|
7721 height: parseInt(that.element.css("height"), 10), |
|
7722 top: parseInt(that.element.css("top"), 10), |
|
7723 left: parseInt(that.element.css("left"), 10) |
|
7724 }; |
|
7725 |
|
7726 if (pr && pr.length) { |
|
7727 $(pr[0]).css({ width: data.width, height: data.height }); |
|
7728 } |
|
7729 |
|
7730 // propagating resize, and updating values for each animation step |
|
7731 that._updateCache(data); |
|
7732 that._propagate("resize", event); |
|
7733 |
|
7734 } |
|
7735 } |
|
7736 ); |
|
7737 } |
|
7738 |
|
7739 }); |
|
7740 |
|
7741 $.ui.plugin.add( "resizable", "containment", { |
|
7742 |
|
7743 start: function() { |
|
7744 var element, p, co, ch, cw, width, height, |
|
7745 that = $( this ).resizable( "instance" ), |
|
7746 o = that.options, |
|
7747 el = that.element, |
|
7748 oc = o.containment, |
|
7749 ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc; |
|
7750 |
|
7751 if ( !ce ) { |
|
7752 return; |
|
7753 } |
|
7754 |
|
7755 that.containerElement = $( ce ); |
|
7756 |
|
7757 if ( /document/.test( oc ) || oc === document ) { |
|
7758 that.containerOffset = { |
|
7759 left: 0, |
|
7760 top: 0 |
|
7761 }; |
|
7762 that.containerPosition = { |
|
7763 left: 0, |
|
7764 top: 0 |
|
7765 }; |
|
7766 |
|
7767 that.parentData = { |
|
7768 element: $( document ), |
|
7769 left: 0, |
|
7770 top: 0, |
|
7771 width: $( document ).width(), |
|
7772 height: $( document ).height() || document.body.parentNode.scrollHeight |
|
7773 }; |
|
7774 } else { |
|
7775 element = $( ce ); |
|
7776 p = []; |
|
7777 $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) { |
|
7778 p[ i ] = that._num( element.css( "padding" + name ) ); |
|
7779 }); |
|
7780 |
|
7781 that.containerOffset = element.offset(); |
|
7782 that.containerPosition = element.position(); |
|
7783 that.containerSize = { |
|
7784 height: ( element.innerHeight() - p[ 3 ] ), |
|
7785 width: ( element.innerWidth() - p[ 1 ] ) |
|
7786 }; |
|
7787 |
|
7788 co = that.containerOffset; |
|
7789 ch = that.containerSize.height; |
|
7790 cw = that.containerSize.width; |
|
7791 width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw ); |
|
7792 height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ; |
|
7793 |
|
7794 that.parentData = { |
|
7795 element: ce, |
|
7796 left: co.left, |
|
7797 top: co.top, |
|
7798 width: width, |
|
7799 height: height |
|
7800 }; |
|
7801 } |
|
7802 }, |
|
7803 |
|
7804 resize: function( event ) { |
|
7805 var woset, hoset, isParent, isOffsetRelative, |
|
7806 that = $( this ).resizable( "instance" ), |
|
7807 o = that.options, |
|
7808 co = that.containerOffset, |
|
7809 cp = that.position, |
|
7810 pRatio = that._aspectRatio || event.shiftKey, |
|
7811 cop = { |
|
7812 top: 0, |
|
7813 left: 0 |
|
7814 }, |
|
7815 ce = that.containerElement, |
|
7816 continueResize = true; |
|
7817 |
|
7818 if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) { |
|
7819 cop = co; |
|
7820 } |
|
7821 |
|
7822 if ( cp.left < ( that._helper ? co.left : 0 ) ) { |
|
7823 that.size.width = that.size.width + |
|
7824 ( that._helper ? |
|
7825 ( that.position.left - co.left ) : |
|
7826 ( that.position.left - cop.left ) ); |
|
7827 |
|
7828 if ( pRatio ) { |
|
7829 that.size.height = that.size.width / that.aspectRatio; |
|
7830 continueResize = false; |
|
7831 } |
|
7832 that.position.left = o.helper ? co.left : 0; |
|
7833 } |
|
7834 |
|
7835 if ( cp.top < ( that._helper ? co.top : 0 ) ) { |
|
7836 that.size.height = that.size.height + |
|
7837 ( that._helper ? |
|
7838 ( that.position.top - co.top ) : |
|
7839 that.position.top ); |
|
7840 |
|
7841 if ( pRatio ) { |
|
7842 that.size.width = that.size.height * that.aspectRatio; |
|
7843 continueResize = false; |
|
7844 } |
|
7845 that.position.top = that._helper ? co.top : 0; |
|
7846 } |
|
7847 |
|
7848 isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 ); |
|
7849 isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) ); |
|
7850 |
|
7851 if ( isParent && isOffsetRelative ) { |
|
7852 that.offset.left = that.parentData.left + that.position.left; |
|
7853 that.offset.top = that.parentData.top + that.position.top; |
|
7854 } else { |
|
7855 that.offset.left = that.element.offset().left; |
|
7856 that.offset.top = that.element.offset().top; |
|
7857 } |
|
7858 |
|
7859 woset = Math.abs( that.sizeDiff.width + |
|
7860 (that._helper ? |
|
7861 that.offset.left - cop.left : |
|
7862 (that.offset.left - co.left)) ); |
|
7863 |
|
7864 hoset = Math.abs( that.sizeDiff.height + |
|
7865 (that._helper ? |
|
7866 that.offset.top - cop.top : |
|
7867 (that.offset.top - co.top)) ); |
|
7868 |
|
7869 if ( woset + that.size.width >= that.parentData.width ) { |
|
7870 that.size.width = that.parentData.width - woset; |
|
7871 if ( pRatio ) { |
|
7872 that.size.height = that.size.width / that.aspectRatio; |
|
7873 continueResize = false; |
|
7874 } |
|
7875 } |
|
7876 |
|
7877 if ( hoset + that.size.height >= that.parentData.height ) { |
|
7878 that.size.height = that.parentData.height - hoset; |
|
7879 if ( pRatio ) { |
|
7880 that.size.width = that.size.height * that.aspectRatio; |
|
7881 continueResize = false; |
|
7882 } |
|
7883 } |
|
7884 |
|
7885 if ( !continueResize ) { |
|
7886 that.position.left = that.prevPosition.left; |
|
7887 that.position.top = that.prevPosition.top; |
|
7888 that.size.width = that.prevSize.width; |
|
7889 that.size.height = that.prevSize.height; |
|
7890 } |
|
7891 }, |
|
7892 |
|
7893 stop: function() { |
|
7894 var that = $( this ).resizable( "instance" ), |
|
7895 o = that.options, |
|
7896 co = that.containerOffset, |
|
7897 cop = that.containerPosition, |
|
7898 ce = that.containerElement, |
|
7899 helper = $( that.helper ), |
|
7900 ho = helper.offset(), |
|
7901 w = helper.outerWidth() - that.sizeDiff.width, |
|
7902 h = helper.outerHeight() - that.sizeDiff.height; |
|
7903 |
|
7904 if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) { |
|
7905 $( this ).css({ |
|
7906 left: ho.left - cop.left - co.left, |
|
7907 width: w, |
|
7908 height: h |
|
7909 }); |
|
7910 } |
|
7911 |
|
7912 if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) { |
|
7913 $( this ).css({ |
|
7914 left: ho.left - cop.left - co.left, |
|
7915 width: w, |
|
7916 height: h |
|
7917 }); |
|
7918 } |
|
7919 } |
|
7920 }); |
|
7921 |
|
7922 $.ui.plugin.add("resizable", "alsoResize", { |
|
7923 |
|
7924 start: function() { |
|
7925 var that = $(this).resizable( "instance" ), |
|
7926 o = that.options; |
|
7927 |
|
7928 $(o.alsoResize).each(function() { |
|
7929 var el = $(this); |
|
7930 el.data("ui-resizable-alsoresize", { |
|
7931 width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), |
|
7932 left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10) |
|
7933 }); |
|
7934 }); |
|
7935 }, |
|
7936 |
|
7937 resize: function(event, ui) { |
|
7938 var that = $(this).resizable( "instance" ), |
|
7939 o = that.options, |
|
7940 os = that.originalSize, |
|
7941 op = that.originalPosition, |
|
7942 delta = { |
|
7943 height: (that.size.height - os.height) || 0, |
|
7944 width: (that.size.width - os.width) || 0, |
|
7945 top: (that.position.top - op.top) || 0, |
|
7946 left: (that.position.left - op.left) || 0 |
|
7947 }; |
|
7948 |
|
7949 $(o.alsoResize).each(function() { |
|
7950 var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {}, |
|
7951 css = el.parents(ui.originalElement[0]).length ? |
|
7952 [ "width", "height" ] : |
|
7953 [ "width", "height", "top", "left" ]; |
|
7954 |
|
7955 $.each(css, function(i, prop) { |
|
7956 var sum = (start[prop] || 0) + (delta[prop] || 0); |
|
7957 if (sum && sum >= 0) { |
|
7958 style[prop] = sum || null; |
|
7959 } |
|
7960 }); |
|
7961 |
|
7962 el.css(style); |
|
7963 }); |
|
7964 }, |
|
7965 |
|
7966 stop: function() { |
|
7967 $(this).removeData("resizable-alsoresize"); |
|
7968 } |
|
7969 }); |
|
7970 |
|
7971 $.ui.plugin.add("resizable", "ghost", { |
|
7972 |
|
7973 start: function() { |
|
7974 |
|
7975 var that = $(this).resizable( "instance" ), o = that.options, cs = that.size; |
|
7976 |
|
7977 that.ghost = that.originalElement.clone(); |
|
7978 that.ghost |
|
7979 .css({ |
|
7980 opacity: 0.25, |
|
7981 display: "block", |
|
7982 position: "relative", |
|
7983 height: cs.height, |
|
7984 width: cs.width, |
|
7985 margin: 0, |
|
7986 left: 0, |
|
7987 top: 0 |
|
7988 }) |
|
7989 .addClass("ui-resizable-ghost") |
|
7990 .addClass(typeof o.ghost === "string" ? o.ghost : ""); |
|
7991 |
|
7992 that.ghost.appendTo(that.helper); |
|
7993 |
|
7994 }, |
|
7995 |
|
7996 resize: function() { |
|
7997 var that = $(this).resizable( "instance" ); |
|
7998 if (that.ghost) { |
|
7999 that.ghost.css({ |
|
8000 position: "relative", |
|
8001 height: that.size.height, |
|
8002 width: that.size.width |
|
8003 }); |
|
8004 } |
|
8005 }, |
|
8006 |
|
8007 stop: function() { |
|
8008 var that = $(this).resizable( "instance" ); |
|
8009 if (that.ghost && that.helper) { |
|
8010 that.helper.get(0).removeChild(that.ghost.get(0)); |
|
8011 } |
|
8012 } |
|
8013 |
|
8014 }); |
|
8015 |
|
8016 $.ui.plugin.add("resizable", "grid", { |
|
8017 |
|
8018 resize: function() { |
|
8019 var outerDimensions, |
|
8020 that = $(this).resizable( "instance" ), |
|
8021 o = that.options, |
|
8022 cs = that.size, |
|
8023 os = that.originalSize, |
|
8024 op = that.originalPosition, |
|
8025 a = that.axis, |
|
8026 grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid, |
|
8027 gridX = (grid[0] || 1), |
|
8028 gridY = (grid[1] || 1), |
|
8029 ox = Math.round((cs.width - os.width) / gridX) * gridX, |
|
8030 oy = Math.round((cs.height - os.height) / gridY) * gridY, |
|
8031 newWidth = os.width + ox, |
|
8032 newHeight = os.height + oy, |
|
8033 isMaxWidth = o.maxWidth && (o.maxWidth < newWidth), |
|
8034 isMaxHeight = o.maxHeight && (o.maxHeight < newHeight), |
|
8035 isMinWidth = o.minWidth && (o.minWidth > newWidth), |
|
8036 isMinHeight = o.minHeight && (o.minHeight > newHeight); |
|
8037 |
|
8038 o.grid = grid; |
|
8039 |
|
8040 if (isMinWidth) { |
|
8041 newWidth += gridX; |
|
8042 } |
|
8043 if (isMinHeight) { |
|
8044 newHeight += gridY; |
|
8045 } |
|
8046 if (isMaxWidth) { |
|
8047 newWidth -= gridX; |
|
8048 } |
|
8049 if (isMaxHeight) { |
|
8050 newHeight -= gridY; |
|
8051 } |
|
8052 |
|
8053 if (/^(se|s|e)$/.test(a)) { |
|
8054 that.size.width = newWidth; |
|
8055 that.size.height = newHeight; |
|
8056 } else if (/^(ne)$/.test(a)) { |
|
8057 that.size.width = newWidth; |
|
8058 that.size.height = newHeight; |
|
8059 that.position.top = op.top - oy; |
|
8060 } else if (/^(sw)$/.test(a)) { |
|
8061 that.size.width = newWidth; |
|
8062 that.size.height = newHeight; |
|
8063 that.position.left = op.left - ox; |
|
8064 } else { |
|
8065 if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) { |
|
8066 outerDimensions = that._getPaddingPlusBorderDimensions( this ); |
|
8067 } |
|
8068 |
|
8069 if ( newHeight - gridY > 0 ) { |
|
8070 that.size.height = newHeight; |
|
8071 that.position.top = op.top - oy; |
|
8072 } else { |
|
8073 newHeight = gridY - outerDimensions.height; |
|
8074 that.size.height = newHeight; |
|
8075 that.position.top = op.top + os.height - newHeight; |
|
8076 } |
|
8077 if ( newWidth - gridX > 0 ) { |
|
8078 that.size.width = newWidth; |
|
8079 that.position.left = op.left - ox; |
|
8080 } else { |
|
8081 newWidth = gridX - outerDimensions.width; |
|
8082 that.size.width = newWidth; |
|
8083 that.position.left = op.left + os.width - newWidth; |
|
8084 } |
|
8085 } |
|
8086 } |
|
8087 |
|
8088 }); |
|
8089 |
|
8090 var resizable = $.ui.resizable; |
|
8091 |
|
8092 |
|
8093 /*! |
|
8094 * jQuery UI Dialog 1.11.4 |
|
8095 * http://jqueryui.com |
|
8096 * |
|
8097 * Copyright jQuery Foundation and other contributors |
|
8098 * Released under the MIT license. |
|
8099 * http://jquery.org/license |
|
8100 * |
|
8101 * http://api.jqueryui.com/dialog/ |
|
8102 */ |
|
8103 |
|
8104 |
|
8105 var dialog = $.widget( "ui.dialog", { |
|
8106 version: "1.11.4", |
9660 options: { |
8107 options: { |
9661 appendTo: "body", |
8108 appendTo: "body", |
9662 autoOpen: true, |
8109 autoOpen: true, |
9663 buttons: [], |
8110 buttons: [], |
9664 closeOnEscape: true, |
8111 closeOnEscape: true, |
9665 closeText: "close", |
8112 closeText: "Close", |
9666 dialogClass: "", |
8113 dialogClass: "", |
9667 draggable: true, |
8114 draggable: true, |
9668 hide: null, |
8115 hide: null, |
9669 height: "auto", |
8116 height: "auto", |
9670 maxHeight: null, |
8117 maxHeight: null, |
10311 delete this.iframeBlocks; |
8872 delete this.iframeBlocks; |
10312 } |
8873 } |
10313 }, |
8874 }, |
10314 |
8875 |
10315 _allowInteraction: function( event ) { |
8876 _allowInteraction: function( event ) { |
10316 if ( $( event.target ).closest(".ui-dialog").length ) { |
8877 if ( $( event.target ).closest( ".ui-dialog" ).length ) { |
10317 return true; |
8878 return true; |
10318 } |
8879 } |
10319 |
8880 |
10320 // TODO: Remove hack when datepicker implements |
8881 // TODO: Remove hack when datepicker implements |
10321 // the .ui-front logic (#8989) |
8882 // the .ui-front logic (#8989) |
10322 return !!$( event.target ).closest(".ui-datepicker").length; |
8883 return !!$( event.target ).closest( ".ui-datepicker" ).length; |
10323 }, |
8884 }, |
10324 |
8885 |
10325 _createOverlay: function() { |
8886 _createOverlay: function() { |
10326 if ( !this.options.modal ) { |
8887 if ( !this.options.modal ) { |
10327 return; |
8888 return; |
10328 } |
8889 } |
10329 |
8890 |
10330 var that = this, |
8891 // We use a delay in case the overlay is created from an |
10331 widgetFullName = this.widgetFullName; |
8892 // event that we're going to be cancelling (#2804) |
10332 if ( !$.ui.dialog.overlayInstances ) { |
8893 var isOpening = true; |
10333 // Prevent use of anchors and inputs. |
8894 this._delay(function() { |
10334 // We use a delay in case the overlay is created from an |
8895 isOpening = false; |
10335 // event that we're going to be cancelling. (#2804) |
8896 }); |
10336 this._delay(function() { |
8897 |
10337 // Handle .dialog().dialog("close") (#4065) |
8898 if ( !this.document.data( "ui-dialog-overlays" ) ) { |
10338 if ( $.ui.dialog.overlayInstances ) { |
8899 |
10339 this.document.bind( "focusin.dialog", function( event ) { |
8900 // Prevent use of anchors and inputs |
10340 if ( !that._allowInteraction( event ) ) { |
8901 // Using _on() for an event handler shared across many instances is |
10341 event.preventDefault(); |
8902 // safe because the dialogs stack and must be closed in reverse order |
10342 $(".ui-dialog:visible:last .ui-dialog-content") |
8903 this._on( this.document, { |
10343 .data( widgetFullName )._focusTabbable(); |
8904 focusin: function( event ) { |
10344 } |
8905 if ( isOpening ) { |
10345 }); |
8906 return; |
|
8907 } |
|
8908 |
|
8909 if ( !this._allowInteraction( event ) ) { |
|
8910 event.preventDefault(); |
|
8911 this._trackingInstances()[ 0 ]._focusTabbable(); |
|
8912 } |
10346 } |
8913 } |
10347 }); |
8914 }); |
10348 } |
8915 } |
10349 |
8916 |
10350 this.overlay = $("<div>") |
8917 this.overlay = $( "<div>" ) |
10351 .addClass("ui-widget-overlay ui-front") |
8918 .addClass( "ui-widget-overlay ui-front" ) |
10352 .appendTo( this._appendTo() ); |
8919 .appendTo( this._appendTo() ); |
10353 this._on( this.overlay, { |
8920 this._on( this.overlay, { |
10354 mousedown: "_keepFocus" |
8921 mousedown: "_keepFocus" |
10355 }); |
8922 }); |
10356 $.ui.dialog.overlayInstances++; |
8923 this.document.data( "ui-dialog-overlays", |
|
8924 (this.document.data( "ui-dialog-overlays" ) || 0) + 1 ); |
10357 }, |
8925 }, |
10358 |
8926 |
10359 _destroyOverlay: function() { |
8927 _destroyOverlay: function() { |
10360 if ( !this.options.modal ) { |
8928 if ( !this.options.modal ) { |
10361 return; |
8929 return; |
10362 } |
8930 } |
10363 |
8931 |
10364 if ( this.overlay ) { |
8932 if ( this.overlay ) { |
10365 $.ui.dialog.overlayInstances--; |
8933 var overlays = this.document.data( "ui-dialog-overlays" ) - 1; |
10366 |
8934 |
10367 if ( !$.ui.dialog.overlayInstances ) { |
8935 if ( !overlays ) { |
10368 this.document.unbind( "focusin.dialog" ); |
8936 this.document |
10369 } |
8937 .unbind( "focusin" ) |
|
8938 .removeData( "ui-dialog-overlays" ); |
|
8939 } else { |
|
8940 this.document.data( "ui-dialog-overlays", overlays ); |
|
8941 } |
|
8942 |
10370 this.overlay.remove(); |
8943 this.overlay.remove(); |
10371 this.overlay = null; |
8944 this.overlay = null; |
10372 } |
8945 } |
10373 } |
8946 } |
10374 }); |
8947 }); |
10375 |
8948 |
10376 $.ui.dialog.overlayInstances = 0; |
8949 |
10377 |
8950 /*! |
10378 // DEPRECATED |
8951 * jQuery UI Droppable 1.11.4 |
10379 if ( $.uiBackCompat !== false ) { |
8952 * http://jqueryui.com |
10380 // position option with array notation |
8953 * |
10381 // just override with old implementation |
8954 * Copyright jQuery Foundation and other contributors |
10382 $.widget( "ui.dialog", $.ui.dialog, { |
8955 * Released under the MIT license. |
10383 _position: function() { |
8956 * http://jquery.org/license |
10384 var position = this.options.position, |
8957 * |
10385 myAt = [], |
8958 * http://api.jqueryui.com/droppable/ |
10386 offset = [ 0, 0 ], |
8959 */ |
10387 isVisible; |
8960 |
10388 |
8961 |
10389 if ( position ) { |
8962 $.widget( "ui.droppable", { |
10390 if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) { |
8963 version: "1.11.4", |
10391 myAt = position.split ? position.split(" ") : [ position[0], position[1] ]; |
8964 widgetEventPrefix: "drop", |
10392 if ( myAt.length === 1 ) { |
8965 options: { |
10393 myAt[1] = myAt[0]; |
8966 accept: "*", |
|
8967 activeClass: false, |
|
8968 addClasses: true, |
|
8969 greedy: false, |
|
8970 hoverClass: false, |
|
8971 scope: "default", |
|
8972 tolerance: "intersect", |
|
8973 |
|
8974 // callbacks |
|
8975 activate: null, |
|
8976 deactivate: null, |
|
8977 drop: null, |
|
8978 out: null, |
|
8979 over: null |
|
8980 }, |
|
8981 _create: function() { |
|
8982 |
|
8983 var proportions, |
|
8984 o = this.options, |
|
8985 accept = o.accept; |
|
8986 |
|
8987 this.isover = false; |
|
8988 this.isout = true; |
|
8989 |
|
8990 this.accept = $.isFunction( accept ) ? accept : function( d ) { |
|
8991 return d.is( accept ); |
|
8992 }; |
|
8993 |
|
8994 this.proportions = function( /* valueToWrite */ ) { |
|
8995 if ( arguments.length ) { |
|
8996 // Store the droppable's proportions |
|
8997 proportions = arguments[ 0 ]; |
|
8998 } else { |
|
8999 // Retrieve or derive the droppable's proportions |
|
9000 return proportions ? |
|
9001 proportions : |
|
9002 proportions = { |
|
9003 width: this.element[ 0 ].offsetWidth, |
|
9004 height: this.element[ 0 ].offsetHeight |
|
9005 }; |
|
9006 } |
|
9007 }; |
|
9008 |
|
9009 this._addToManager( o.scope ); |
|
9010 |
|
9011 o.addClasses && this.element.addClass( "ui-droppable" ); |
|
9012 |
|
9013 }, |
|
9014 |
|
9015 _addToManager: function( scope ) { |
|
9016 // Add the reference and positions to the manager |
|
9017 $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || []; |
|
9018 $.ui.ddmanager.droppables[ scope ].push( this ); |
|
9019 }, |
|
9020 |
|
9021 _splice: function( drop ) { |
|
9022 var i = 0; |
|
9023 for ( ; i < drop.length; i++ ) { |
|
9024 if ( drop[ i ] === this ) { |
|
9025 drop.splice( i, 1 ); |
|
9026 } |
|
9027 } |
|
9028 }, |
|
9029 |
|
9030 _destroy: function() { |
|
9031 var drop = $.ui.ddmanager.droppables[ this.options.scope ]; |
|
9032 |
|
9033 this._splice( drop ); |
|
9034 |
|
9035 this.element.removeClass( "ui-droppable ui-droppable-disabled" ); |
|
9036 }, |
|
9037 |
|
9038 _setOption: function( key, value ) { |
|
9039 |
|
9040 if ( key === "accept" ) { |
|
9041 this.accept = $.isFunction( value ) ? value : function( d ) { |
|
9042 return d.is( value ); |
|
9043 }; |
|
9044 } else if ( key === "scope" ) { |
|
9045 var drop = $.ui.ddmanager.droppables[ this.options.scope ]; |
|
9046 |
|
9047 this._splice( drop ); |
|
9048 this._addToManager( value ); |
|
9049 } |
|
9050 |
|
9051 this._super( key, value ); |
|
9052 }, |
|
9053 |
|
9054 _activate: function( event ) { |
|
9055 var draggable = $.ui.ddmanager.current; |
|
9056 if ( this.options.activeClass ) { |
|
9057 this.element.addClass( this.options.activeClass ); |
|
9058 } |
|
9059 if ( draggable ){ |
|
9060 this._trigger( "activate", event, this.ui( draggable ) ); |
|
9061 } |
|
9062 }, |
|
9063 |
|
9064 _deactivate: function( event ) { |
|
9065 var draggable = $.ui.ddmanager.current; |
|
9066 if ( this.options.activeClass ) { |
|
9067 this.element.removeClass( this.options.activeClass ); |
|
9068 } |
|
9069 if ( draggable ){ |
|
9070 this._trigger( "deactivate", event, this.ui( draggable ) ); |
|
9071 } |
|
9072 }, |
|
9073 |
|
9074 _over: function( event ) { |
|
9075 |
|
9076 var draggable = $.ui.ddmanager.current; |
|
9077 |
|
9078 // Bail if draggable and droppable are same element |
|
9079 if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) { |
|
9080 return; |
|
9081 } |
|
9082 |
|
9083 if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { |
|
9084 if ( this.options.hoverClass ) { |
|
9085 this.element.addClass( this.options.hoverClass ); |
|
9086 } |
|
9087 this._trigger( "over", event, this.ui( draggable ) ); |
|
9088 } |
|
9089 |
|
9090 }, |
|
9091 |
|
9092 _out: function( event ) { |
|
9093 |
|
9094 var draggable = $.ui.ddmanager.current; |
|
9095 |
|
9096 // Bail if draggable and droppable are same element |
|
9097 if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) { |
|
9098 return; |
|
9099 } |
|
9100 |
|
9101 if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { |
|
9102 if ( this.options.hoverClass ) { |
|
9103 this.element.removeClass( this.options.hoverClass ); |
|
9104 } |
|
9105 this._trigger( "out", event, this.ui( draggable ) ); |
|
9106 } |
|
9107 |
|
9108 }, |
|
9109 |
|
9110 _drop: function( event, custom ) { |
|
9111 |
|
9112 var draggable = custom || $.ui.ddmanager.current, |
|
9113 childrenIntersection = false; |
|
9114 |
|
9115 // Bail if draggable and droppable are same element |
|
9116 if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) { |
|
9117 return false; |
|
9118 } |
|
9119 |
|
9120 this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() { |
|
9121 var inst = $( this ).droppable( "instance" ); |
|
9122 if ( |
|
9123 inst.options.greedy && |
|
9124 !inst.options.disabled && |
|
9125 inst.options.scope === draggable.options.scope && |
|
9126 inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) && |
|
9127 $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event ) |
|
9128 ) { childrenIntersection = true; return false; } |
|
9129 }); |
|
9130 if ( childrenIntersection ) { |
|
9131 return false; |
|
9132 } |
|
9133 |
|
9134 if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { |
|
9135 if ( this.options.activeClass ) { |
|
9136 this.element.removeClass( this.options.activeClass ); |
|
9137 } |
|
9138 if ( this.options.hoverClass ) { |
|
9139 this.element.removeClass( this.options.hoverClass ); |
|
9140 } |
|
9141 this._trigger( "drop", event, this.ui( draggable ) ); |
|
9142 return this.element; |
|
9143 } |
|
9144 |
|
9145 return false; |
|
9146 |
|
9147 }, |
|
9148 |
|
9149 ui: function( c ) { |
|
9150 return { |
|
9151 draggable: ( c.currentItem || c.element ), |
|
9152 helper: c.helper, |
|
9153 position: c.position, |
|
9154 offset: c.positionAbs |
|
9155 }; |
|
9156 } |
|
9157 |
|
9158 }); |
|
9159 |
|
9160 $.ui.intersect = (function() { |
|
9161 function isOverAxis( x, reference, size ) { |
|
9162 return ( x >= reference ) && ( x < ( reference + size ) ); |
|
9163 } |
|
9164 |
|
9165 return function( draggable, droppable, toleranceMode, event ) { |
|
9166 |
|
9167 if ( !droppable.offset ) { |
|
9168 return false; |
|
9169 } |
|
9170 |
|
9171 var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left, |
|
9172 y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top, |
|
9173 x2 = x1 + draggable.helperProportions.width, |
|
9174 y2 = y1 + draggable.helperProportions.height, |
|
9175 l = droppable.offset.left, |
|
9176 t = droppable.offset.top, |
|
9177 r = l + droppable.proportions().width, |
|
9178 b = t + droppable.proportions().height; |
|
9179 |
|
9180 switch ( toleranceMode ) { |
|
9181 case "fit": |
|
9182 return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b ); |
|
9183 case "intersect": |
|
9184 return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half |
|
9185 x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half |
|
9186 t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half |
|
9187 y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half |
|
9188 case "pointer": |
|
9189 return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width ); |
|
9190 case "touch": |
|
9191 return ( |
|
9192 ( y1 >= t && y1 <= b ) || // Top edge touching |
|
9193 ( y2 >= t && y2 <= b ) || // Bottom edge touching |
|
9194 ( y1 < t && y2 > b ) // Surrounded vertically |
|
9195 ) && ( |
|
9196 ( x1 >= l && x1 <= r ) || // Left edge touching |
|
9197 ( x2 >= l && x2 <= r ) || // Right edge touching |
|
9198 ( x1 < l && x2 > r ) // Surrounded horizontally |
|
9199 ); |
|
9200 default: |
|
9201 return false; |
|
9202 } |
|
9203 }; |
|
9204 })(); |
|
9205 |
|
9206 /* |
|
9207 This manager tracks offsets of draggables and droppables |
|
9208 */ |
|
9209 $.ui.ddmanager = { |
|
9210 current: null, |
|
9211 droppables: { "default": [] }, |
|
9212 prepareOffsets: function( t, event ) { |
|
9213 |
|
9214 var i, j, |
|
9215 m = $.ui.ddmanager.droppables[ t.options.scope ] || [], |
|
9216 type = event ? event.type : null, // workaround for #2317 |
|
9217 list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack(); |
|
9218 |
|
9219 droppablesLoop: for ( i = 0; i < m.length; i++ ) { |
|
9220 |
|
9221 // No disabled and non-accepted |
|
9222 if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) { |
|
9223 continue; |
|
9224 } |
|
9225 |
|
9226 // Filter out elements in the current dragged item |
|
9227 for ( j = 0; j < list.length; j++ ) { |
|
9228 if ( list[ j ] === m[ i ].element[ 0 ] ) { |
|
9229 m[ i ].proportions().height = 0; |
|
9230 continue droppablesLoop; |
|
9231 } |
|
9232 } |
|
9233 |
|
9234 m[ i ].visible = m[ i ].element.css( "display" ) !== "none"; |
|
9235 if ( !m[ i ].visible ) { |
|
9236 continue; |
|
9237 } |
|
9238 |
|
9239 // Activate the droppable if used directly from draggables |
|
9240 if ( type === "mousedown" ) { |
|
9241 m[ i ]._activate.call( m[ i ], event ); |
|
9242 } |
|
9243 |
|
9244 m[ i ].offset = m[ i ].element.offset(); |
|
9245 m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight }); |
|
9246 |
|
9247 } |
|
9248 |
|
9249 }, |
|
9250 drop: function( draggable, event ) { |
|
9251 |
|
9252 var dropped = false; |
|
9253 // Create a copy of the droppables in case the list changes during the drop (#9116) |
|
9254 $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() { |
|
9255 |
|
9256 if ( !this.options ) { |
|
9257 return; |
|
9258 } |
|
9259 if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) { |
|
9260 dropped = this._drop.call( this, event ) || dropped; |
|
9261 } |
|
9262 |
|
9263 if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { |
|
9264 this.isout = true; |
|
9265 this.isover = false; |
|
9266 this._deactivate.call( this, event ); |
|
9267 } |
|
9268 |
|
9269 }); |
|
9270 return dropped; |
|
9271 |
|
9272 }, |
|
9273 dragStart: function( draggable, event ) { |
|
9274 // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003) |
|
9275 draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() { |
|
9276 if ( !draggable.options.refreshPositions ) { |
|
9277 $.ui.ddmanager.prepareOffsets( draggable, event ); |
|
9278 } |
|
9279 }); |
|
9280 }, |
|
9281 drag: function( draggable, event ) { |
|
9282 |
|
9283 // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. |
|
9284 if ( draggable.options.refreshPositions ) { |
|
9285 $.ui.ddmanager.prepareOffsets( draggable, event ); |
|
9286 } |
|
9287 |
|
9288 // Run through all droppables and check their positions based on specific tolerance options |
|
9289 $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() { |
|
9290 |
|
9291 if ( this.options.disabled || this.greedyChild || !this.visible ) { |
|
9292 return; |
|
9293 } |
|
9294 |
|
9295 var parentInstance, scope, parent, |
|
9296 intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ), |
|
9297 c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null ); |
|
9298 if ( !c ) { |
|
9299 return; |
|
9300 } |
|
9301 |
|
9302 if ( this.options.greedy ) { |
|
9303 // find droppable parents with same scope |
|
9304 scope = this.options.scope; |
|
9305 parent = this.element.parents( ":data(ui-droppable)" ).filter(function() { |
|
9306 return $( this ).droppable( "instance" ).options.scope === scope; |
|
9307 }); |
|
9308 |
|
9309 if ( parent.length ) { |
|
9310 parentInstance = $( parent[ 0 ] ).droppable( "instance" ); |
|
9311 parentInstance.greedyChild = ( c === "isover" ); |
|
9312 } |
|
9313 } |
|
9314 |
|
9315 // we just moved into a greedy child |
|
9316 if ( parentInstance && c === "isover" ) { |
|
9317 parentInstance.isover = false; |
|
9318 parentInstance.isout = true; |
|
9319 parentInstance._out.call( parentInstance, event ); |
|
9320 } |
|
9321 |
|
9322 this[ c ] = true; |
|
9323 this[c === "isout" ? "isover" : "isout"] = false; |
|
9324 this[c === "isover" ? "_over" : "_out"].call( this, event ); |
|
9325 |
|
9326 // we just moved out of a greedy child |
|
9327 if ( parentInstance && c === "isout" ) { |
|
9328 parentInstance.isout = false; |
|
9329 parentInstance.isover = true; |
|
9330 parentInstance._over.call( parentInstance, event ); |
|
9331 } |
|
9332 }); |
|
9333 |
|
9334 }, |
|
9335 dragStop: function( draggable, event ) { |
|
9336 draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" ); |
|
9337 // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003) |
|
9338 if ( !draggable.options.refreshPositions ) { |
|
9339 $.ui.ddmanager.prepareOffsets( draggable, event ); |
|
9340 } |
|
9341 } |
|
9342 }; |
|
9343 |
|
9344 var droppable = $.ui.droppable; |
|
9345 |
|
9346 |
|
9347 /*! |
|
9348 * jQuery UI Effects 1.11.4 |
|
9349 * http://jqueryui.com |
|
9350 * |
|
9351 * Copyright jQuery Foundation and other contributors |
|
9352 * Released under the MIT license. |
|
9353 * http://jquery.org/license |
|
9354 * |
|
9355 * http://api.jqueryui.com/category/effects-core/ |
|
9356 */ |
|
9357 |
|
9358 |
|
9359 var dataSpace = "ui-effects-", |
|
9360 |
|
9361 // Create a local jQuery because jQuery Color relies on it and the |
|
9362 // global may not exist with AMD and a custom build (#10199) |
|
9363 jQuery = $; |
|
9364 |
|
9365 $.effects = { |
|
9366 effect: {} |
|
9367 }; |
|
9368 |
|
9369 /*! |
|
9370 * jQuery Color Animations v2.1.2 |
|
9371 * https://github.com/jquery/jquery-color |
|
9372 * |
|
9373 * Copyright 2014 jQuery Foundation and other contributors |
|
9374 * Released under the MIT license. |
|
9375 * http://jquery.org/license |
|
9376 * |
|
9377 * Date: Wed Jan 16 08:47:09 2013 -0600 |
|
9378 */ |
|
9379 (function( jQuery, undefined ) { |
|
9380 |
|
9381 var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", |
|
9382 |
|
9383 // plusequals test for += 100 -= 100 |
|
9384 rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, |
|
9385 // a set of RE's that can match strings and generate color tuples. |
|
9386 stringParsers = [ { |
|
9387 re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, |
|
9388 parse: function( execResult ) { |
|
9389 return [ |
|
9390 execResult[ 1 ], |
|
9391 execResult[ 2 ], |
|
9392 execResult[ 3 ], |
|
9393 execResult[ 4 ] |
|
9394 ]; |
|
9395 } |
|
9396 }, { |
|
9397 re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, |
|
9398 parse: function( execResult ) { |
|
9399 return [ |
|
9400 execResult[ 1 ] * 2.55, |
|
9401 execResult[ 2 ] * 2.55, |
|
9402 execResult[ 3 ] * 2.55, |
|
9403 execResult[ 4 ] |
|
9404 ]; |
|
9405 } |
|
9406 }, { |
|
9407 // this regex ignores A-F because it's compared against an already lowercased string |
|
9408 re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, |
|
9409 parse: function( execResult ) { |
|
9410 return [ |
|
9411 parseInt( execResult[ 1 ], 16 ), |
|
9412 parseInt( execResult[ 2 ], 16 ), |
|
9413 parseInt( execResult[ 3 ], 16 ) |
|
9414 ]; |
|
9415 } |
|
9416 }, { |
|
9417 // this regex ignores A-F because it's compared against an already lowercased string |
|
9418 re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, |
|
9419 parse: function( execResult ) { |
|
9420 return [ |
|
9421 parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), |
|
9422 parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), |
|
9423 parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) |
|
9424 ]; |
|
9425 } |
|
9426 }, { |
|
9427 re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, |
|
9428 space: "hsla", |
|
9429 parse: function( execResult ) { |
|
9430 return [ |
|
9431 execResult[ 1 ], |
|
9432 execResult[ 2 ] / 100, |
|
9433 execResult[ 3 ] / 100, |
|
9434 execResult[ 4 ] |
|
9435 ]; |
|
9436 } |
|
9437 } ], |
|
9438 |
|
9439 // jQuery.Color( ) |
|
9440 color = jQuery.Color = function( color, green, blue, alpha ) { |
|
9441 return new jQuery.Color.fn.parse( color, green, blue, alpha ); |
|
9442 }, |
|
9443 spaces = { |
|
9444 rgba: { |
|
9445 props: { |
|
9446 red: { |
|
9447 idx: 0, |
|
9448 type: "byte" |
|
9449 }, |
|
9450 green: { |
|
9451 idx: 1, |
|
9452 type: "byte" |
|
9453 }, |
|
9454 blue: { |
|
9455 idx: 2, |
|
9456 type: "byte" |
|
9457 } |
|
9458 } |
|
9459 }, |
|
9460 |
|
9461 hsla: { |
|
9462 props: { |
|
9463 hue: { |
|
9464 idx: 0, |
|
9465 type: "degrees" |
|
9466 }, |
|
9467 saturation: { |
|
9468 idx: 1, |
|
9469 type: "percent" |
|
9470 }, |
|
9471 lightness: { |
|
9472 idx: 2, |
|
9473 type: "percent" |
|
9474 } |
|
9475 } |
|
9476 } |
|
9477 }, |
|
9478 propTypes = { |
|
9479 "byte": { |
|
9480 floor: true, |
|
9481 max: 255 |
|
9482 }, |
|
9483 "percent": { |
|
9484 max: 1 |
|
9485 }, |
|
9486 "degrees": { |
|
9487 mod: 360, |
|
9488 floor: true |
|
9489 } |
|
9490 }, |
|
9491 support = color.support = {}, |
|
9492 |
|
9493 // element for support tests |
|
9494 supportElem = jQuery( "<p>" )[ 0 ], |
|
9495 |
|
9496 // colors = jQuery.Color.names |
|
9497 colors, |
|
9498 |
|
9499 // local aliases of functions called often |
|
9500 each = jQuery.each; |
|
9501 |
|
9502 // determine rgba support immediately |
|
9503 supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; |
|
9504 support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; |
|
9505 |
|
9506 // define cache name and alpha properties |
|
9507 // for rgba and hsla spaces |
|
9508 each( spaces, function( spaceName, space ) { |
|
9509 space.cache = "_" + spaceName; |
|
9510 space.props.alpha = { |
|
9511 idx: 3, |
|
9512 type: "percent", |
|
9513 def: 1 |
|
9514 }; |
|
9515 }); |
|
9516 |
|
9517 function clamp( value, prop, allowEmpty ) { |
|
9518 var type = propTypes[ prop.type ] || {}; |
|
9519 |
|
9520 if ( value == null ) { |
|
9521 return (allowEmpty || !prop.def) ? null : prop.def; |
|
9522 } |
|
9523 |
|
9524 // ~~ is an short way of doing floor for positive numbers |
|
9525 value = type.floor ? ~~value : parseFloat( value ); |
|
9526 |
|
9527 // IE will pass in empty strings as value for alpha, |
|
9528 // which will hit this case |
|
9529 if ( isNaN( value ) ) { |
|
9530 return prop.def; |
|
9531 } |
|
9532 |
|
9533 if ( type.mod ) { |
|
9534 // we add mod before modding to make sure that negatives values |
|
9535 // get converted properly: -10 -> 350 |
|
9536 return (value + type.mod) % type.mod; |
|
9537 } |
|
9538 |
|
9539 // for now all property types without mod have min and max |
|
9540 return 0 > value ? 0 : type.max < value ? type.max : value; |
|
9541 } |
|
9542 |
|
9543 function stringParse( string ) { |
|
9544 var inst = color(), |
|
9545 rgba = inst._rgba = []; |
|
9546 |
|
9547 string = string.toLowerCase(); |
|
9548 |
|
9549 each( stringParsers, function( i, parser ) { |
|
9550 var parsed, |
|
9551 match = parser.re.exec( string ), |
|
9552 values = match && parser.parse( match ), |
|
9553 spaceName = parser.space || "rgba"; |
|
9554 |
|
9555 if ( values ) { |
|
9556 parsed = inst[ spaceName ]( values ); |
|
9557 |
|
9558 // if this was an rgba parse the assignment might happen twice |
|
9559 // oh well.... |
|
9560 inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; |
|
9561 rgba = inst._rgba = parsed._rgba; |
|
9562 |
|
9563 // exit each( stringParsers ) here because we matched |
|
9564 return false; |
|
9565 } |
|
9566 }); |
|
9567 |
|
9568 // Found a stringParser that handled it |
|
9569 if ( rgba.length ) { |
|
9570 |
|
9571 // if this came from a parsed string, force "transparent" when alpha is 0 |
|
9572 // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) |
|
9573 if ( rgba.join() === "0,0,0,0" ) { |
|
9574 jQuery.extend( rgba, colors.transparent ); |
|
9575 } |
|
9576 return inst; |
|
9577 } |
|
9578 |
|
9579 // named colors |
|
9580 return colors[ string ]; |
|
9581 } |
|
9582 |
|
9583 color.fn = jQuery.extend( color.prototype, { |
|
9584 parse: function( red, green, blue, alpha ) { |
|
9585 if ( red === undefined ) { |
|
9586 this._rgba = [ null, null, null, null ]; |
|
9587 return this; |
|
9588 } |
|
9589 if ( red.jquery || red.nodeType ) { |
|
9590 red = jQuery( red ).css( green ); |
|
9591 green = undefined; |
|
9592 } |
|
9593 |
|
9594 var inst = this, |
|
9595 type = jQuery.type( red ), |
|
9596 rgba = this._rgba = []; |
|
9597 |
|
9598 // more than 1 argument specified - assume ( red, green, blue, alpha ) |
|
9599 if ( green !== undefined ) { |
|
9600 red = [ red, green, blue, alpha ]; |
|
9601 type = "array"; |
|
9602 } |
|
9603 |
|
9604 if ( type === "string" ) { |
|
9605 return this.parse( stringParse( red ) || colors._default ); |
|
9606 } |
|
9607 |
|
9608 if ( type === "array" ) { |
|
9609 each( spaces.rgba.props, function( key, prop ) { |
|
9610 rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); |
|
9611 }); |
|
9612 return this; |
|
9613 } |
|
9614 |
|
9615 if ( type === "object" ) { |
|
9616 if ( red instanceof color ) { |
|
9617 each( spaces, function( spaceName, space ) { |
|
9618 if ( red[ space.cache ] ) { |
|
9619 inst[ space.cache ] = red[ space.cache ].slice(); |
10394 } |
9620 } |
10395 |
9621 }); |
10396 $.each( [ "left", "top" ], function( i, offsetPosition ) { |
9622 } else { |
10397 if ( +myAt[ i ] === myAt[ i ] ) { |
9623 each( spaces, function( spaceName, space ) { |
10398 offset[ i ] = myAt[ i ]; |
9624 var cache = space.cache; |
10399 myAt[ i ] = offsetPosition; |
9625 each( space.props, function( key, prop ) { |
|
9626 |
|
9627 // if the cache doesn't exist, and we know how to convert |
|
9628 if ( !inst[ cache ] && space.to ) { |
|
9629 |
|
9630 // if the value was null, we don't need to copy it |
|
9631 // if the key was alpha, we don't need to copy it either |
|
9632 if ( key === "alpha" || red[ key ] == null ) { |
|
9633 return; |
|
9634 } |
|
9635 inst[ cache ] = space.to( inst._rgba ); |
10400 } |
9636 } |
|
9637 |
|
9638 // this is the only case where we allow nulls for ALL properties. |
|
9639 // call clamp with alwaysAllowEmpty |
|
9640 inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); |
10401 }); |
9641 }); |
10402 |
9642 |
10403 position = { |
9643 // everything defined but alpha? |
10404 my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " + |
9644 if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { |
10405 myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]), |
9645 // use the default of 1 |
10406 at: myAt.join(" ") |
9646 inst[ cache ][ 3 ] = 1; |
10407 }; |
9647 if ( space.from ) { |
10408 } |
9648 inst._rgba = space.from( inst[ cache ] ); |
10409 |
9649 } |
10410 position = $.extend( {}, $.ui.dialog.prototype.options.position, position ); |
9650 } |
|
9651 }); |
|
9652 } |
|
9653 return this; |
|
9654 } |
|
9655 }, |
|
9656 is: function( compare ) { |
|
9657 var is = color( compare ), |
|
9658 same = true, |
|
9659 inst = this; |
|
9660 |
|
9661 each( spaces, function( _, space ) { |
|
9662 var localCache, |
|
9663 isCache = is[ space.cache ]; |
|
9664 if (isCache) { |
|
9665 localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; |
|
9666 each( space.props, function( _, prop ) { |
|
9667 if ( isCache[ prop.idx ] != null ) { |
|
9668 same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); |
|
9669 return same; |
|
9670 } |
|
9671 }); |
|
9672 } |
|
9673 return same; |
|
9674 }); |
|
9675 return same; |
|
9676 }, |
|
9677 _space: function() { |
|
9678 var used = [], |
|
9679 inst = this; |
|
9680 each( spaces, function( spaceName, space ) { |
|
9681 if ( inst[ space.cache ] ) { |
|
9682 used.push( spaceName ); |
|
9683 } |
|
9684 }); |
|
9685 return used.pop(); |
|
9686 }, |
|
9687 transition: function( other, distance ) { |
|
9688 var end = color( other ), |
|
9689 spaceName = end._space(), |
|
9690 space = spaces[ spaceName ], |
|
9691 startColor = this.alpha() === 0 ? color( "transparent" ) : this, |
|
9692 start = startColor[ space.cache ] || space.to( startColor._rgba ), |
|
9693 result = start.slice(); |
|
9694 |
|
9695 end = end[ space.cache ]; |
|
9696 each( space.props, function( key, prop ) { |
|
9697 var index = prop.idx, |
|
9698 startValue = start[ index ], |
|
9699 endValue = end[ index ], |
|
9700 type = propTypes[ prop.type ] || {}; |
|
9701 |
|
9702 // if null, don't override start value |
|
9703 if ( endValue === null ) { |
|
9704 return; |
|
9705 } |
|
9706 // if null - use end |
|
9707 if ( startValue === null ) { |
|
9708 result[ index ] = endValue; |
10411 } else { |
9709 } else { |
10412 position = $.ui.dialog.prototype.options.position; |
9710 if ( type.mod ) { |
10413 } |
9711 if ( endValue - startValue > type.mod / 2 ) { |
10414 |
9712 startValue += type.mod; |
10415 // need to show the dialog to get the actual offset in the position plugin |
9713 } else if ( startValue - endValue > type.mod / 2 ) { |
10416 isVisible = this.uiDialog.is(":visible"); |
9714 startValue -= type.mod; |
10417 if ( !isVisible ) { |
9715 } |
10418 this.uiDialog.show(); |
9716 } |
10419 } |
9717 result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); |
10420 this.uiDialog.position( position ); |
9718 } |
10421 if ( !isVisible ) { |
9719 }); |
10422 this.uiDialog.hide(); |
9720 return this[ spaceName ]( result ); |
10423 } |
9721 }, |
10424 } |
9722 blend: function( opaque ) { |
|
9723 // if we are already opaque - return ourself |
|
9724 if ( this._rgba[ 3 ] === 1 ) { |
|
9725 return this; |
|
9726 } |
|
9727 |
|
9728 var rgb = this._rgba.slice(), |
|
9729 a = rgb.pop(), |
|
9730 blend = color( opaque )._rgba; |
|
9731 |
|
9732 return color( jQuery.map( rgb, function( v, i ) { |
|
9733 return ( 1 - a ) * blend[ i ] + a * v; |
|
9734 })); |
|
9735 }, |
|
9736 toRgbaString: function() { |
|
9737 var prefix = "rgba(", |
|
9738 rgba = jQuery.map( this._rgba, function( v, i ) { |
|
9739 return v == null ? ( i > 2 ? 1 : 0 ) : v; |
|
9740 }); |
|
9741 |
|
9742 if ( rgba[ 3 ] === 1 ) { |
|
9743 rgba.pop(); |
|
9744 prefix = "rgb("; |
|
9745 } |
|
9746 |
|
9747 return prefix + rgba.join() + ")"; |
|
9748 }, |
|
9749 toHslaString: function() { |
|
9750 var prefix = "hsla(", |
|
9751 hsla = jQuery.map( this.hsla(), function( v, i ) { |
|
9752 if ( v == null ) { |
|
9753 v = i > 2 ? 1 : 0; |
|
9754 } |
|
9755 |
|
9756 // catch 1 and 2 |
|
9757 if ( i && i < 3 ) { |
|
9758 v = Math.round( v * 100 ) + "%"; |
|
9759 } |
|
9760 return v; |
|
9761 }); |
|
9762 |
|
9763 if ( hsla[ 3 ] === 1 ) { |
|
9764 hsla.pop(); |
|
9765 prefix = "hsl("; |
|
9766 } |
|
9767 return prefix + hsla.join() + ")"; |
|
9768 }, |
|
9769 toHexString: function( includeAlpha ) { |
|
9770 var rgba = this._rgba.slice(), |
|
9771 alpha = rgba.pop(); |
|
9772 |
|
9773 if ( includeAlpha ) { |
|
9774 rgba.push( ~~( alpha * 255 ) ); |
|
9775 } |
|
9776 |
|
9777 return "#" + jQuery.map( rgba, function( v ) { |
|
9778 |
|
9779 // default to 0 when nulls exist |
|
9780 v = ( v || 0 ).toString( 16 ); |
|
9781 return v.length === 1 ? "0" + v : v; |
|
9782 }).join(""); |
|
9783 }, |
|
9784 toString: function() { |
|
9785 return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); |
|
9786 } |
|
9787 }); |
|
9788 color.fn.parse.prototype = color.fn; |
|
9789 |
|
9790 // hsla conversions adapted from: |
|
9791 // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 |
|
9792 |
|
9793 function hue2rgb( p, q, h ) { |
|
9794 h = ( h + 1 ) % 1; |
|
9795 if ( h * 6 < 1 ) { |
|
9796 return p + ( q - p ) * h * 6; |
|
9797 } |
|
9798 if ( h * 2 < 1) { |
|
9799 return q; |
|
9800 } |
|
9801 if ( h * 3 < 2 ) { |
|
9802 return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6; |
|
9803 } |
|
9804 return p; |
|
9805 } |
|
9806 |
|
9807 spaces.hsla.to = function( rgba ) { |
|
9808 if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { |
|
9809 return [ null, null, null, rgba[ 3 ] ]; |
|
9810 } |
|
9811 var r = rgba[ 0 ] / 255, |
|
9812 g = rgba[ 1 ] / 255, |
|
9813 b = rgba[ 2 ] / 255, |
|
9814 a = rgba[ 3 ], |
|
9815 max = Math.max( r, g, b ), |
|
9816 min = Math.min( r, g, b ), |
|
9817 diff = max - min, |
|
9818 add = max + min, |
|
9819 l = add * 0.5, |
|
9820 h, s; |
|
9821 |
|
9822 if ( min === max ) { |
|
9823 h = 0; |
|
9824 } else if ( r === max ) { |
|
9825 h = ( 60 * ( g - b ) / diff ) + 360; |
|
9826 } else if ( g === max ) { |
|
9827 h = ( 60 * ( b - r ) / diff ) + 120; |
|
9828 } else { |
|
9829 h = ( 60 * ( r - g ) / diff ) + 240; |
|
9830 } |
|
9831 |
|
9832 // chroma (diff) == 0 means greyscale which, by definition, saturation = 0% |
|
9833 // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) |
|
9834 if ( diff === 0 ) { |
|
9835 s = 0; |
|
9836 } else if ( l <= 0.5 ) { |
|
9837 s = diff / add; |
|
9838 } else { |
|
9839 s = diff / ( 2 - add ); |
|
9840 } |
|
9841 return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; |
|
9842 }; |
|
9843 |
|
9844 spaces.hsla.from = function( hsla ) { |
|
9845 if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { |
|
9846 return [ null, null, null, hsla[ 3 ] ]; |
|
9847 } |
|
9848 var h = hsla[ 0 ] / 360, |
|
9849 s = hsla[ 1 ], |
|
9850 l = hsla[ 2 ], |
|
9851 a = hsla[ 3 ], |
|
9852 q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, |
|
9853 p = 2 * l - q; |
|
9854 |
|
9855 return [ |
|
9856 Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), |
|
9857 Math.round( hue2rgb( p, q, h ) * 255 ), |
|
9858 Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), |
|
9859 a |
|
9860 ]; |
|
9861 }; |
|
9862 |
|
9863 each( spaces, function( spaceName, space ) { |
|
9864 var props = space.props, |
|
9865 cache = space.cache, |
|
9866 to = space.to, |
|
9867 from = space.from; |
|
9868 |
|
9869 // makes rgba() and hsla() |
|
9870 color.fn[ spaceName ] = function( value ) { |
|
9871 |
|
9872 // generate a cache for this space if it doesn't exist |
|
9873 if ( to && !this[ cache ] ) { |
|
9874 this[ cache ] = to( this._rgba ); |
|
9875 } |
|
9876 if ( value === undefined ) { |
|
9877 return this[ cache ].slice(); |
|
9878 } |
|
9879 |
|
9880 var ret, |
|
9881 type = jQuery.type( value ), |
|
9882 arr = ( type === "array" || type === "object" ) ? value : arguments, |
|
9883 local = this[ cache ].slice(); |
|
9884 |
|
9885 each( props, function( key, prop ) { |
|
9886 var val = arr[ type === "object" ? key : prop.idx ]; |
|
9887 if ( val == null ) { |
|
9888 val = local[ prop.idx ]; |
|
9889 } |
|
9890 local[ prop.idx ] = clamp( val, prop ); |
|
9891 }); |
|
9892 |
|
9893 if ( from ) { |
|
9894 ret = color( from( local ) ); |
|
9895 ret[ cache ] = local; |
|
9896 return ret; |
|
9897 } else { |
|
9898 return color( local ); |
|
9899 } |
|
9900 }; |
|
9901 |
|
9902 // makes red() green() blue() alpha() hue() saturation() lightness() |
|
9903 each( props, function( key, prop ) { |
|
9904 // alpha is included in more than one space |
|
9905 if ( color.fn[ key ] ) { |
|
9906 return; |
|
9907 } |
|
9908 color.fn[ key ] = function( value ) { |
|
9909 var vtype = jQuery.type( value ), |
|
9910 fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), |
|
9911 local = this[ fn ](), |
|
9912 cur = local[ prop.idx ], |
|
9913 match; |
|
9914 |
|
9915 if ( vtype === "undefined" ) { |
|
9916 return cur; |
|
9917 } |
|
9918 |
|
9919 if ( vtype === "function" ) { |
|
9920 value = value.call( this, cur ); |
|
9921 vtype = jQuery.type( value ); |
|
9922 } |
|
9923 if ( value == null && prop.empty ) { |
|
9924 return this; |
|
9925 } |
|
9926 if ( vtype === "string" ) { |
|
9927 match = rplusequals.exec( value ); |
|
9928 if ( match ) { |
|
9929 value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); |
|
9930 } |
|
9931 } |
|
9932 local[ prop.idx ] = value; |
|
9933 return this[ fn ]( local ); |
|
9934 }; |
10425 }); |
9935 }); |
|
9936 }); |
|
9937 |
|
9938 // add cssHook and .fx.step function for each named hook. |
|
9939 // accept a space separated string of properties |
|
9940 color.hook = function( hook ) { |
|
9941 var hooks = hook.split( " " ); |
|
9942 each( hooks, function( i, hook ) { |
|
9943 jQuery.cssHooks[ hook ] = { |
|
9944 set: function( elem, value ) { |
|
9945 var parsed, curElem, |
|
9946 backgroundColor = ""; |
|
9947 |
|
9948 if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) { |
|
9949 value = color( parsed || value ); |
|
9950 if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { |
|
9951 curElem = hook === "backgroundColor" ? elem.parentNode : elem; |
|
9952 while ( |
|
9953 (backgroundColor === "" || backgroundColor === "transparent") && |
|
9954 curElem && curElem.style |
|
9955 ) { |
|
9956 try { |
|
9957 backgroundColor = jQuery.css( curElem, "backgroundColor" ); |
|
9958 curElem = curElem.parentNode; |
|
9959 } catch ( e ) { |
|
9960 } |
|
9961 } |
|
9962 |
|
9963 value = value.blend( backgroundColor && backgroundColor !== "transparent" ? |
|
9964 backgroundColor : |
|
9965 "_default" ); |
|
9966 } |
|
9967 |
|
9968 value = value.toRgbaString(); |
|
9969 } |
|
9970 try { |
|
9971 elem.style[ hook ] = value; |
|
9972 } catch ( e ) { |
|
9973 // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' |
|
9974 } |
|
9975 } |
|
9976 }; |
|
9977 jQuery.fx.step[ hook ] = function( fx ) { |
|
9978 if ( !fx.colorInit ) { |
|
9979 fx.start = color( fx.elem, hook ); |
|
9980 fx.end = color( fx.end ); |
|
9981 fx.colorInit = true; |
|
9982 } |
|
9983 jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); |
|
9984 }; |
|
9985 }); |
|
9986 |
|
9987 }; |
|
9988 |
|
9989 color.hook( stepHooks ); |
|
9990 |
|
9991 jQuery.cssHooks.borderColor = { |
|
9992 expand: function( value ) { |
|
9993 var expanded = {}; |
|
9994 |
|
9995 each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { |
|
9996 expanded[ "border" + part + "Color" ] = value; |
|
9997 }); |
|
9998 return expanded; |
|
9999 } |
|
10000 }; |
|
10001 |
|
10002 // Basic color names only. |
|
10003 // Usage of any of the other color names requires adding yourself or including |
|
10004 // jquery.color.svg-names.js. |
|
10005 colors = jQuery.Color.names = { |
|
10006 // 4.1. Basic color keywords |
|
10007 aqua: "#00ffff", |
|
10008 black: "#000000", |
|
10009 blue: "#0000ff", |
|
10010 fuchsia: "#ff00ff", |
|
10011 gray: "#808080", |
|
10012 green: "#008000", |
|
10013 lime: "#00ff00", |
|
10014 maroon: "#800000", |
|
10015 navy: "#000080", |
|
10016 olive: "#808000", |
|
10017 purple: "#800080", |
|
10018 red: "#ff0000", |
|
10019 silver: "#c0c0c0", |
|
10020 teal: "#008080", |
|
10021 white: "#ffffff", |
|
10022 yellow: "#ffff00", |
|
10023 |
|
10024 // 4.2.3. "transparent" color keyword |
|
10025 transparent: [ null, null, null, 0 ], |
|
10026 |
|
10027 _default: "#ffffff" |
|
10028 }; |
|
10029 |
|
10030 })( jQuery ); |
|
10031 |
|
10032 /******************************************************************************/ |
|
10033 /****************************** CLASS ANIMATIONS ******************************/ |
|
10034 /******************************************************************************/ |
|
10035 (function() { |
|
10036 |
|
10037 var classAnimationActions = [ "add", "remove", "toggle" ], |
|
10038 shorthandStyles = { |
|
10039 border: 1, |
|
10040 borderBottom: 1, |
|
10041 borderColor: 1, |
|
10042 borderLeft: 1, |
|
10043 borderRight: 1, |
|
10044 borderTop: 1, |
|
10045 borderWidth: 1, |
|
10046 margin: 1, |
|
10047 padding: 1 |
|
10048 }; |
|
10049 |
|
10050 $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { |
|
10051 $.fx.step[ prop ] = function( fx ) { |
|
10052 if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { |
|
10053 jQuery.style( fx.elem, prop, fx.end ); |
|
10054 fx.setAttr = true; |
|
10055 } |
|
10056 }; |
|
10057 }); |
|
10058 |
|
10059 function getElementStyles( elem ) { |
|
10060 var key, len, |
|
10061 style = elem.ownerDocument.defaultView ? |
|
10062 elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : |
|
10063 elem.currentStyle, |
|
10064 styles = {}; |
|
10065 |
|
10066 if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { |
|
10067 len = style.length; |
|
10068 while ( len-- ) { |
|
10069 key = style[ len ]; |
|
10070 if ( typeof style[ key ] === "string" ) { |
|
10071 styles[ $.camelCase( key ) ] = style[ key ]; |
|
10072 } |
|
10073 } |
|
10074 // support: Opera, IE <9 |
|
10075 } else { |
|
10076 for ( key in style ) { |
|
10077 if ( typeof style[ key ] === "string" ) { |
|
10078 styles[ key ] = style[ key ]; |
|
10079 } |
|
10080 } |
|
10081 } |
|
10082 |
|
10083 return styles; |
10426 } |
10084 } |
10427 |
10085 |
10428 }( jQuery ) ); |
10086 function styleDifference( oldStyle, newStyle ) { |
10429 |
10087 var diff = {}, |
10430 (function( $, undefined ) { |
10088 name, value; |
10431 |
10089 |
10432 var rvertical = /up|down|vertical/, |
10090 for ( name in newStyle ) { |
10433 rpositivemotion = /up|left|vertical|horizontal/; |
10091 value = newStyle[ name ]; |
10434 |
10092 if ( oldStyle[ name ] !== value ) { |
10435 $.effects.effect.blind = function( o, done ) { |
10093 if ( !shorthandStyles[ name ] ) { |
|
10094 if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { |
|
10095 diff[ name ] = value; |
|
10096 } |
|
10097 } |
|
10098 } |
|
10099 } |
|
10100 |
|
10101 return diff; |
|
10102 } |
|
10103 |
|
10104 // support: jQuery <1.8 |
|
10105 if ( !$.fn.addBack ) { |
|
10106 $.fn.addBack = function( selector ) { |
|
10107 return this.add( selector == null ? |
|
10108 this.prevObject : this.prevObject.filter( selector ) |
|
10109 ); |
|
10110 }; |
|
10111 } |
|
10112 |
|
10113 $.effects.animateClass = function( value, duration, easing, callback ) { |
|
10114 var o = $.speed( duration, easing, callback ); |
|
10115 |
|
10116 return this.queue( function() { |
|
10117 var animated = $( this ), |
|
10118 baseClass = animated.attr( "class" ) || "", |
|
10119 applyClassChange, |
|
10120 allAnimations = o.children ? animated.find( "*" ).addBack() : animated; |
|
10121 |
|
10122 // map the animated objects to store the original styles. |
|
10123 allAnimations = allAnimations.map(function() { |
|
10124 var el = $( this ); |
|
10125 return { |
|
10126 el: el, |
|
10127 start: getElementStyles( this ) |
|
10128 }; |
|
10129 }); |
|
10130 |
|
10131 // apply class change |
|
10132 applyClassChange = function() { |
|
10133 $.each( classAnimationActions, function(i, action) { |
|
10134 if ( value[ action ] ) { |
|
10135 animated[ action + "Class" ]( value[ action ] ); |
|
10136 } |
|
10137 }); |
|
10138 }; |
|
10139 applyClassChange(); |
|
10140 |
|
10141 // map all animated objects again - calculate new styles and diff |
|
10142 allAnimations = allAnimations.map(function() { |
|
10143 this.end = getElementStyles( this.el[ 0 ] ); |
|
10144 this.diff = styleDifference( this.start, this.end ); |
|
10145 return this; |
|
10146 }); |
|
10147 |
|
10148 // apply original class |
|
10149 animated.attr( "class", baseClass ); |
|
10150 |
|
10151 // map all animated objects again - this time collecting a promise |
|
10152 allAnimations = allAnimations.map(function() { |
|
10153 var styleInfo = this, |
|
10154 dfd = $.Deferred(), |
|
10155 opts = $.extend({}, o, { |
|
10156 queue: false, |
|
10157 complete: function() { |
|
10158 dfd.resolve( styleInfo ); |
|
10159 } |
|
10160 }); |
|
10161 |
|
10162 this.el.animate( this.diff, opts ); |
|
10163 return dfd.promise(); |
|
10164 }); |
|
10165 |
|
10166 // once all animations have completed: |
|
10167 $.when.apply( $, allAnimations.get() ).done(function() { |
|
10168 |
|
10169 // set the final class |
|
10170 applyClassChange(); |
|
10171 |
|
10172 // for each animated element, |
|
10173 // clear all css properties that were animated |
|
10174 $.each( arguments, function() { |
|
10175 var el = this.el; |
|
10176 $.each( this.diff, function(key) { |
|
10177 el.css( key, "" ); |
|
10178 }); |
|
10179 }); |
|
10180 |
|
10181 // this is guarnteed to be there if you use jQuery.speed() |
|
10182 // it also handles dequeuing the next anim... |
|
10183 o.complete.call( animated[ 0 ] ); |
|
10184 }); |
|
10185 }); |
|
10186 }; |
|
10187 |
|
10188 $.fn.extend({ |
|
10189 addClass: (function( orig ) { |
|
10190 return function( classNames, speed, easing, callback ) { |
|
10191 return speed ? |
|
10192 $.effects.animateClass.call( this, |
|
10193 { add: classNames }, speed, easing, callback ) : |
|
10194 orig.apply( this, arguments ); |
|
10195 }; |
|
10196 })( $.fn.addClass ), |
|
10197 |
|
10198 removeClass: (function( orig ) { |
|
10199 return function( classNames, speed, easing, callback ) { |
|
10200 return arguments.length > 1 ? |
|
10201 $.effects.animateClass.call( this, |
|
10202 { remove: classNames }, speed, easing, callback ) : |
|
10203 orig.apply( this, arguments ); |
|
10204 }; |
|
10205 })( $.fn.removeClass ), |
|
10206 |
|
10207 toggleClass: (function( orig ) { |
|
10208 return function( classNames, force, speed, easing, callback ) { |
|
10209 if ( typeof force === "boolean" || force === undefined ) { |
|
10210 if ( !speed ) { |
|
10211 // without speed parameter |
|
10212 return orig.apply( this, arguments ); |
|
10213 } else { |
|
10214 return $.effects.animateClass.call( this, |
|
10215 (force ? { add: classNames } : { remove: classNames }), |
|
10216 speed, easing, callback ); |
|
10217 } |
|
10218 } else { |
|
10219 // without force parameter |
|
10220 return $.effects.animateClass.call( this, |
|
10221 { toggle: classNames }, force, speed, easing ); |
|
10222 } |
|
10223 }; |
|
10224 })( $.fn.toggleClass ), |
|
10225 |
|
10226 switchClass: function( remove, add, speed, easing, callback) { |
|
10227 return $.effects.animateClass.call( this, { |
|
10228 add: add, |
|
10229 remove: remove |
|
10230 }, speed, easing, callback ); |
|
10231 } |
|
10232 }); |
|
10233 |
|
10234 })(); |
|
10235 |
|
10236 /******************************************************************************/ |
|
10237 /*********************************** EFFECTS **********************************/ |
|
10238 /******************************************************************************/ |
|
10239 |
|
10240 (function() { |
|
10241 |
|
10242 $.extend( $.effects, { |
|
10243 version: "1.11.4", |
|
10244 |
|
10245 // Saves a set of properties in a data storage |
|
10246 save: function( element, set ) { |
|
10247 for ( var i = 0; i < set.length; i++ ) { |
|
10248 if ( set[ i ] !== null ) { |
|
10249 element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); |
|
10250 } |
|
10251 } |
|
10252 }, |
|
10253 |
|
10254 // Restores a set of previously saved properties from a data storage |
|
10255 restore: function( element, set ) { |
|
10256 var val, i; |
|
10257 for ( i = 0; i < set.length; i++ ) { |
|
10258 if ( set[ i ] !== null ) { |
|
10259 val = element.data( dataSpace + set[ i ] ); |
|
10260 // support: jQuery 1.6.2 |
|
10261 // http://bugs.jquery.com/ticket/9917 |
|
10262 // jQuery 1.6.2 incorrectly returns undefined for any falsy value. |
|
10263 // We can't differentiate between "" and 0 here, so we just assume |
|
10264 // empty string since it's likely to be a more common value... |
|
10265 if ( val === undefined ) { |
|
10266 val = ""; |
|
10267 } |
|
10268 element.css( set[ i ], val ); |
|
10269 } |
|
10270 } |
|
10271 }, |
|
10272 |
|
10273 setMode: function( el, mode ) { |
|
10274 if (mode === "toggle") { |
|
10275 mode = el.is( ":hidden" ) ? "show" : "hide"; |
|
10276 } |
|
10277 return mode; |
|
10278 }, |
|
10279 |
|
10280 // Translates a [top,left] array into a baseline value |
|
10281 // this should be a little more flexible in the future to handle a string & hash |
|
10282 getBaseline: function( origin, original ) { |
|
10283 var y, x; |
|
10284 switch ( origin[ 0 ] ) { |
|
10285 case "top": y = 0; break; |
|
10286 case "middle": y = 0.5; break; |
|
10287 case "bottom": y = 1; break; |
|
10288 default: y = origin[ 0 ] / original.height; |
|
10289 } |
|
10290 switch ( origin[ 1 ] ) { |
|
10291 case "left": x = 0; break; |
|
10292 case "center": x = 0.5; break; |
|
10293 case "right": x = 1; break; |
|
10294 default: x = origin[ 1 ] / original.width; |
|
10295 } |
|
10296 return { |
|
10297 x: x, |
|
10298 y: y |
|
10299 }; |
|
10300 }, |
|
10301 |
|
10302 // Wraps the element around a wrapper that copies position properties |
|
10303 createWrapper: function( element ) { |
|
10304 |
|
10305 // if the element is already wrapped, return it |
|
10306 if ( element.parent().is( ".ui-effects-wrapper" )) { |
|
10307 return element.parent(); |
|
10308 } |
|
10309 |
|
10310 // wrap the element |
|
10311 var props = { |
|
10312 width: element.outerWidth(true), |
|
10313 height: element.outerHeight(true), |
|
10314 "float": element.css( "float" ) |
|
10315 }, |
|
10316 wrapper = $( "<div></div>" ) |
|
10317 .addClass( "ui-effects-wrapper" ) |
|
10318 .css({ |
|
10319 fontSize: "100%", |
|
10320 background: "transparent", |
|
10321 border: "none", |
|
10322 margin: 0, |
|
10323 padding: 0 |
|
10324 }), |
|
10325 // Store the size in case width/height are defined in % - Fixes #5245 |
|
10326 size = { |
|
10327 width: element.width(), |
|
10328 height: element.height() |
|
10329 }, |
|
10330 active = document.activeElement; |
|
10331 |
|
10332 // support: Firefox |
|
10333 // Firefox incorrectly exposes anonymous content |
|
10334 // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 |
|
10335 try { |
|
10336 active.id; |
|
10337 } catch ( e ) { |
|
10338 active = document.body; |
|
10339 } |
|
10340 |
|
10341 element.wrap( wrapper ); |
|
10342 |
|
10343 // Fixes #7595 - Elements lose focus when wrapped. |
|
10344 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { |
|
10345 $( active ).focus(); |
|
10346 } |
|
10347 |
|
10348 wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element |
|
10349 |
|
10350 // transfer positioning properties to the wrapper |
|
10351 if ( element.css( "position" ) === "static" ) { |
|
10352 wrapper.css({ position: "relative" }); |
|
10353 element.css({ position: "relative" }); |
|
10354 } else { |
|
10355 $.extend( props, { |
|
10356 position: element.css( "position" ), |
|
10357 zIndex: element.css( "z-index" ) |
|
10358 }); |
|
10359 $.each([ "top", "left", "bottom", "right" ], function(i, pos) { |
|
10360 props[ pos ] = element.css( pos ); |
|
10361 if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { |
|
10362 props[ pos ] = "auto"; |
|
10363 } |
|
10364 }); |
|
10365 element.css({ |
|
10366 position: "relative", |
|
10367 top: 0, |
|
10368 left: 0, |
|
10369 right: "auto", |
|
10370 bottom: "auto" |
|
10371 }); |
|
10372 } |
|
10373 element.css(size); |
|
10374 |
|
10375 return wrapper.css( props ).show(); |
|
10376 }, |
|
10377 |
|
10378 removeWrapper: function( element ) { |
|
10379 var active = document.activeElement; |
|
10380 |
|
10381 if ( element.parent().is( ".ui-effects-wrapper" ) ) { |
|
10382 element.parent().replaceWith( element ); |
|
10383 |
|
10384 // Fixes #7595 - Elements lose focus when wrapped. |
|
10385 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { |
|
10386 $( active ).focus(); |
|
10387 } |
|
10388 } |
|
10389 |
|
10390 return element; |
|
10391 }, |
|
10392 |
|
10393 setTransition: function( element, list, factor, value ) { |
|
10394 value = value || {}; |
|
10395 $.each( list, function( i, x ) { |
|
10396 var unit = element.cssUnit( x ); |
|
10397 if ( unit[ 0 ] > 0 ) { |
|
10398 value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; |
|
10399 } |
|
10400 }); |
|
10401 return value; |
|
10402 } |
|
10403 }); |
|
10404 |
|
10405 // return an effect options object for the given parameters: |
|
10406 function _normalizeArguments( effect, options, speed, callback ) { |
|
10407 |
|
10408 // allow passing all options as the first parameter |
|
10409 if ( $.isPlainObject( effect ) ) { |
|
10410 options = effect; |
|
10411 effect = effect.effect; |
|
10412 } |
|
10413 |
|
10414 // convert to an object |
|
10415 effect = { effect: effect }; |
|
10416 |
|
10417 // catch (effect, null, ...) |
|
10418 if ( options == null ) { |
|
10419 options = {}; |
|
10420 } |
|
10421 |
|
10422 // catch (effect, callback) |
|
10423 if ( $.isFunction( options ) ) { |
|
10424 callback = options; |
|
10425 speed = null; |
|
10426 options = {}; |
|
10427 } |
|
10428 |
|
10429 // catch (effect, speed, ?) |
|
10430 if ( typeof options === "number" || $.fx.speeds[ options ] ) { |
|
10431 callback = speed; |
|
10432 speed = options; |
|
10433 options = {}; |
|
10434 } |
|
10435 |
|
10436 // catch (effect, options, callback) |
|
10437 if ( $.isFunction( speed ) ) { |
|
10438 callback = speed; |
|
10439 speed = null; |
|
10440 } |
|
10441 |
|
10442 // add options to effect |
|
10443 if ( options ) { |
|
10444 $.extend( effect, options ); |
|
10445 } |
|
10446 |
|
10447 speed = speed || options.duration; |
|
10448 effect.duration = $.fx.off ? 0 : |
|
10449 typeof speed === "number" ? speed : |
|
10450 speed in $.fx.speeds ? $.fx.speeds[ speed ] : |
|
10451 $.fx.speeds._default; |
|
10452 |
|
10453 effect.complete = callback || options.complete; |
|
10454 |
|
10455 return effect; |
|
10456 } |
|
10457 |
|
10458 function standardAnimationOption( option ) { |
|
10459 // Valid standard speeds (nothing, number, named speed) |
|
10460 if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { |
|
10461 return true; |
|
10462 } |
|
10463 |
|
10464 // Invalid strings - treat as "normal" speed |
|
10465 if ( typeof option === "string" && !$.effects.effect[ option ] ) { |
|
10466 return true; |
|
10467 } |
|
10468 |
|
10469 // Complete callback |
|
10470 if ( $.isFunction( option ) ) { |
|
10471 return true; |
|
10472 } |
|
10473 |
|
10474 // Options hash (but not naming an effect) |
|
10475 if ( typeof option === "object" && !option.effect ) { |
|
10476 return true; |
|
10477 } |
|
10478 |
|
10479 // Didn't match any standard API |
|
10480 return false; |
|
10481 } |
|
10482 |
|
10483 $.fn.extend({ |
|
10484 effect: function( /* effect, options, speed, callback */ ) { |
|
10485 var args = _normalizeArguments.apply( this, arguments ), |
|
10486 mode = args.mode, |
|
10487 queue = args.queue, |
|
10488 effectMethod = $.effects.effect[ args.effect ]; |
|
10489 |
|
10490 if ( $.fx.off || !effectMethod ) { |
|
10491 // delegate to the original method (e.g., .show()) if possible |
|
10492 if ( mode ) { |
|
10493 return this[ mode ]( args.duration, args.complete ); |
|
10494 } else { |
|
10495 return this.each( function() { |
|
10496 if ( args.complete ) { |
|
10497 args.complete.call( this ); |
|
10498 } |
|
10499 }); |
|
10500 } |
|
10501 } |
|
10502 |
|
10503 function run( next ) { |
|
10504 var elem = $( this ), |
|
10505 complete = args.complete, |
|
10506 mode = args.mode; |
|
10507 |
|
10508 function done() { |
|
10509 if ( $.isFunction( complete ) ) { |
|
10510 complete.call( elem[0] ); |
|
10511 } |
|
10512 if ( $.isFunction( next ) ) { |
|
10513 next(); |
|
10514 } |
|
10515 } |
|
10516 |
|
10517 // If the element already has the correct final state, delegate to |
|
10518 // the core methods so the internal tracking of "olddisplay" works. |
|
10519 if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { |
|
10520 elem[ mode ](); |
|
10521 done(); |
|
10522 } else { |
|
10523 effectMethod.call( elem[0], args, done ); |
|
10524 } |
|
10525 } |
|
10526 |
|
10527 return queue === false ? this.each( run ) : this.queue( queue || "fx", run ); |
|
10528 }, |
|
10529 |
|
10530 show: (function( orig ) { |
|
10531 return function( option ) { |
|
10532 if ( standardAnimationOption( option ) ) { |
|
10533 return orig.apply( this, arguments ); |
|
10534 } else { |
|
10535 var args = _normalizeArguments.apply( this, arguments ); |
|
10536 args.mode = "show"; |
|
10537 return this.effect.call( this, args ); |
|
10538 } |
|
10539 }; |
|
10540 })( $.fn.show ), |
|
10541 |
|
10542 hide: (function( orig ) { |
|
10543 return function( option ) { |
|
10544 if ( standardAnimationOption( option ) ) { |
|
10545 return orig.apply( this, arguments ); |
|
10546 } else { |
|
10547 var args = _normalizeArguments.apply( this, arguments ); |
|
10548 args.mode = "hide"; |
|
10549 return this.effect.call( this, args ); |
|
10550 } |
|
10551 }; |
|
10552 })( $.fn.hide ), |
|
10553 |
|
10554 toggle: (function( orig ) { |
|
10555 return function( option ) { |
|
10556 if ( standardAnimationOption( option ) || typeof option === "boolean" ) { |
|
10557 return orig.apply( this, arguments ); |
|
10558 } else { |
|
10559 var args = _normalizeArguments.apply( this, arguments ); |
|
10560 args.mode = "toggle"; |
|
10561 return this.effect.call( this, args ); |
|
10562 } |
|
10563 }; |
|
10564 })( $.fn.toggle ), |
|
10565 |
|
10566 // helper functions |
|
10567 cssUnit: function(key) { |
|
10568 var style = this.css( key ), |
|
10569 val = []; |
|
10570 |
|
10571 $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { |
|
10572 if ( style.indexOf( unit ) > 0 ) { |
|
10573 val = [ parseFloat( style ), unit ]; |
|
10574 } |
|
10575 }); |
|
10576 return val; |
|
10577 } |
|
10578 }); |
|
10579 |
|
10580 })(); |
|
10581 |
|
10582 /******************************************************************************/ |
|
10583 /*********************************** EASING ***********************************/ |
|
10584 /******************************************************************************/ |
|
10585 |
|
10586 (function() { |
|
10587 |
|
10588 // based on easing equations from Robert Penner (http://www.robertpenner.com/easing) |
|
10589 |
|
10590 var baseEasings = {}; |
|
10591 |
|
10592 $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { |
|
10593 baseEasings[ name ] = function( p ) { |
|
10594 return Math.pow( p, i + 2 ); |
|
10595 }; |
|
10596 }); |
|
10597 |
|
10598 $.extend( baseEasings, { |
|
10599 Sine: function( p ) { |
|
10600 return 1 - Math.cos( p * Math.PI / 2 ); |
|
10601 }, |
|
10602 Circ: function( p ) { |
|
10603 return 1 - Math.sqrt( 1 - p * p ); |
|
10604 }, |
|
10605 Elastic: function( p ) { |
|
10606 return p === 0 || p === 1 ? p : |
|
10607 -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 ); |
|
10608 }, |
|
10609 Back: function( p ) { |
|
10610 return p * p * ( 3 * p - 2 ); |
|
10611 }, |
|
10612 Bounce: function( p ) { |
|
10613 var pow2, |
|
10614 bounce = 4; |
|
10615 |
|
10616 while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} |
|
10617 return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); |
|
10618 } |
|
10619 }); |
|
10620 |
|
10621 $.each( baseEasings, function( name, easeIn ) { |
|
10622 $.easing[ "easeIn" + name ] = easeIn; |
|
10623 $.easing[ "easeOut" + name ] = function( p ) { |
|
10624 return 1 - easeIn( 1 - p ); |
|
10625 }; |
|
10626 $.easing[ "easeInOut" + name ] = function( p ) { |
|
10627 return p < 0.5 ? |
|
10628 easeIn( p * 2 ) / 2 : |
|
10629 1 - easeIn( p * -2 + 2 ) / 2; |
|
10630 }; |
|
10631 }); |
|
10632 |
|
10633 })(); |
|
10634 |
|
10635 var effect = $.effects; |
|
10636 |
|
10637 |
|
10638 /*! |
|
10639 * jQuery UI Effects Blind 1.11.4 |
|
10640 * http://jqueryui.com |
|
10641 * |
|
10642 * Copyright jQuery Foundation and other contributors |
|
10643 * Released under the MIT license. |
|
10644 * http://jquery.org/license |
|
10645 * |
|
10646 * http://api.jqueryui.com/blind-effect/ |
|
10647 */ |
|
10648 |
|
10649 |
|
10650 var effectBlind = $.effects.effect.blind = function( o, done ) { |
10436 // Create element |
10651 // Create element |
10437 var el = $( this ), |
10652 var el = $( this ), |
|
10653 rvertical = /up|down|vertical/, |
|
10654 rpositivemotion = /up|left|vertical|horizontal/, |
10438 props = [ "position", "top", "bottom", "left", "right", "height", "width" ], |
10655 props = [ "position", "top", "bottom", "left", "right", "height", "width" ], |
10439 mode = $.effects.setMode( el, o.mode || "hide" ), |
10656 mode = $.effects.setMode( el, o.mode || "hide" ), |
10440 direction = o.direction || "up", |
10657 direction = o.direction || "up", |
10441 vertical = rvertical.test( direction ), |
10658 vertical = rvertical.test( direction ), |
10442 ref = vertical ? "height" : "width", |
10659 ref = vertical ? "height" : "width", |
11378 done(); |
11719 done(); |
11379 } |
11720 } |
11380 }); |
11721 }); |
11381 }; |
11722 }; |
11382 |
11723 |
11383 })(jQuery); |
11724 |
11384 |
11725 /*! |
11385 (function( $, undefined ) { |
11726 * jQuery UI Effects Transfer 1.11.4 |
11386 |
11727 * http://jqueryui.com |
11387 $.effects.effect.transfer = function( o, done ) { |
11728 * |
|
11729 * Copyright jQuery Foundation and other contributors |
|
11730 * Released under the MIT license. |
|
11731 * http://jquery.org/license |
|
11732 * |
|
11733 * http://api.jqueryui.com/transfer-effect/ |
|
11734 */ |
|
11735 |
|
11736 |
|
11737 var effectTransfer = $.effects.effect.transfer = function( o, done ) { |
11388 var elem = $( this ), |
11738 var elem = $( this ), |
11389 target = $( o.to ), |
11739 target = $( o.to ), |
11390 targetFixed = target.css( "position" ) === "fixed", |
11740 targetFixed = target.css( "position" ) === "fixed", |
11391 body = $("body"), |
11741 body = $("body"), |
11392 fixTop = targetFixed ? body.scrollTop() : 0, |
11742 fixTop = targetFixed ? body.scrollTop() : 0, |
11393 fixLeft = targetFixed ? body.scrollLeft() : 0, |
11743 fixLeft = targetFixed ? body.scrollLeft() : 0, |
11394 endPosition = target.offset(), |
11744 endPosition = target.offset(), |
11395 animation = { |
11745 animation = { |
11396 top: endPosition.top - fixTop , |
11746 top: endPosition.top - fixTop, |
11397 left: endPosition.left - fixLeft , |
11747 left: endPosition.left - fixLeft, |
11398 height: target.innerHeight(), |
11748 height: target.innerHeight(), |
11399 width: target.innerWidth() |
11749 width: target.innerWidth() |
11400 }, |
11750 }, |
11401 startPosition = elem.offset(), |
11751 startPosition = elem.offset(), |
11402 transfer = $( "<div class='ui-effects-transfer'></div>" ) |
11752 transfer = $( "<div class='ui-effects-transfer'></div>" ) |
11403 .appendTo( document.body ) |
11753 .appendTo( document.body ) |
11404 .addClass( o.className ) |
11754 .addClass( o.className ) |
11405 .css({ |
11755 .css({ |
11406 top: startPosition.top - fixTop , |
11756 top: startPosition.top - fixTop, |
11407 left: startPosition.left - fixLeft , |
11757 left: startPosition.left - fixLeft, |
11408 height: elem.innerHeight(), |
11758 height: elem.innerHeight(), |
11409 width: elem.innerWidth(), |
11759 width: elem.innerWidth(), |
11410 position: targetFixed ? "fixed" : "absolute" |
11760 position: targetFixed ? "fixed" : "absolute" |
11411 }) |
11761 }) |
11412 .animate( animation, o.duration, o.easing, function() { |
11762 .animate( animation, o.duration, o.easing, function() { |
11413 transfer.remove(); |
11763 transfer.remove(); |
11414 done(); |
11764 done(); |
11415 }); |
11765 }); |
11416 }; |
11766 }; |
11417 |
11767 |
11418 })(jQuery); |
11768 |
11419 |
11769 /*! |
11420 (function( $, undefined ) { |
11770 * jQuery UI Progressbar 1.11.4 |
11421 |
11771 * http://jqueryui.com |
11422 $.widget( "ui.menu", { |
11772 * |
11423 version: "1.10.3", |
11773 * Copyright jQuery Foundation and other contributors |
11424 defaultElement: "<ul>", |
11774 * Released under the MIT license. |
11425 delay: 300, |
11775 * http://jquery.org/license |
11426 options: { |
11776 * |
11427 icons: { |
11777 * http://api.jqueryui.com/progressbar/ |
11428 submenu: "ui-icon-carat-1-e" |
11778 */ |
11429 }, |
11779 |
11430 menus: "ul", |
11780 |
11431 position: { |
11781 var progressbar = $.widget( "ui.progressbar", { |
11432 my: "left top", |
11782 version: "1.11.4", |
11433 at: "right top" |
|
11434 }, |
|
11435 role: "menu", |
|
11436 |
|
11437 // callbacks |
|
11438 blur: null, |
|
11439 focus: null, |
|
11440 select: null |
|
11441 }, |
|
11442 |
|
11443 _create: function() { |
|
11444 this.activeMenu = this.element; |
|
11445 // flag used to prevent firing of the click handler |
|
11446 // as the event bubbles up through nested menus |
|
11447 this.mouseHandled = false; |
|
11448 this.element |
|
11449 .uniqueId() |
|
11450 .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) |
|
11451 .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length ) |
|
11452 .attr({ |
|
11453 role: this.options.role, |
|
11454 tabIndex: 0 |
|
11455 }) |
|
11456 // need to catch all clicks on disabled menu |
|
11457 // not possible through _on |
|
11458 .bind( "click" + this.eventNamespace, $.proxy(function( event ) { |
|
11459 if ( this.options.disabled ) { |
|
11460 event.preventDefault(); |
|
11461 } |
|
11462 }, this )); |
|
11463 |
|
11464 if ( this.options.disabled ) { |
|
11465 this.element |
|
11466 .addClass( "ui-state-disabled" ) |
|
11467 .attr( "aria-disabled", "true" ); |
|
11468 } |
|
11469 |
|
11470 this._on({ |
|
11471 // Prevent focus from sticking to links inside menu after clicking |
|
11472 // them (focus should always stay on UL during navigation). |
|
11473 "mousedown .ui-menu-item > a": function( event ) { |
|
11474 event.preventDefault(); |
|
11475 }, |
|
11476 "click .ui-state-disabled > a": function( event ) { |
|
11477 event.preventDefault(); |
|
11478 }, |
|
11479 "click .ui-menu-item:has(a)": function( event ) { |
|
11480 var target = $( event.target ).closest( ".ui-menu-item" ); |
|
11481 if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) { |
|
11482 this.mouseHandled = true; |
|
11483 |
|
11484 this.select( event ); |
|
11485 // Open submenu on click |
|
11486 if ( target.has( ".ui-menu" ).length ) { |
|
11487 this.expand( event ); |
|
11488 } else if ( !this.element.is( ":focus" ) ) { |
|
11489 // Redirect focus to the menu |
|
11490 this.element.trigger( "focus", [ true ] ); |
|
11491 |
|
11492 // If the active item is on the top level, let it stay active. |
|
11493 // Otherwise, blur the active item since it is no longer visible. |
|
11494 if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) { |
|
11495 clearTimeout( this.timer ); |
|
11496 } |
|
11497 } |
|
11498 } |
|
11499 }, |
|
11500 "mouseenter .ui-menu-item": function( event ) { |
|
11501 var target = $( event.currentTarget ); |
|
11502 // Remove ui-state-active class from siblings of the newly focused menu item |
|
11503 // to avoid a jump caused by adjacent elements both having a class with a border |
|
11504 target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" ); |
|
11505 this.focus( event, target ); |
|
11506 }, |
|
11507 mouseleave: "collapseAll", |
|
11508 "mouseleave .ui-menu": "collapseAll", |
|
11509 focus: function( event, keepActiveItem ) { |
|
11510 // If there's already an active item, keep it active |
|
11511 // If not, activate the first item |
|
11512 var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 ); |
|
11513 |
|
11514 if ( !keepActiveItem ) { |
|
11515 this.focus( event, item ); |
|
11516 } |
|
11517 }, |
|
11518 blur: function( event ) { |
|
11519 this._delay(function() { |
|
11520 if ( !$.contains( this.element[0], this.document[0].activeElement ) ) { |
|
11521 this.collapseAll( event ); |
|
11522 } |
|
11523 }); |
|
11524 }, |
|
11525 keydown: "_keydown" |
|
11526 }); |
|
11527 |
|
11528 this.refresh(); |
|
11529 |
|
11530 // Clicks outside of a menu collapse any open menus |
|
11531 this._on( this.document, { |
|
11532 click: function( event ) { |
|
11533 if ( !$( event.target ).closest( ".ui-menu" ).length ) { |
|
11534 this.collapseAll( event ); |
|
11535 } |
|
11536 |
|
11537 // Reset the mouseHandled flag |
|
11538 this.mouseHandled = false; |
|
11539 } |
|
11540 }); |
|
11541 }, |
|
11542 |
|
11543 _destroy: function() { |
|
11544 // Destroy (sub)menus |
|
11545 this.element |
|
11546 .removeAttr( "aria-activedescendant" ) |
|
11547 .find( ".ui-menu" ).addBack() |
|
11548 .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" ) |
|
11549 .removeAttr( "role" ) |
|
11550 .removeAttr( "tabIndex" ) |
|
11551 .removeAttr( "aria-labelledby" ) |
|
11552 .removeAttr( "aria-expanded" ) |
|
11553 .removeAttr( "aria-hidden" ) |
|
11554 .removeAttr( "aria-disabled" ) |
|
11555 .removeUniqueId() |
|
11556 .show(); |
|
11557 |
|
11558 // Destroy menu items |
|
11559 this.element.find( ".ui-menu-item" ) |
|
11560 .removeClass( "ui-menu-item" ) |
|
11561 .removeAttr( "role" ) |
|
11562 .removeAttr( "aria-disabled" ) |
|
11563 .children( "a" ) |
|
11564 .removeUniqueId() |
|
11565 .removeClass( "ui-corner-all ui-state-hover" ) |
|
11566 .removeAttr( "tabIndex" ) |
|
11567 .removeAttr( "role" ) |
|
11568 .removeAttr( "aria-haspopup" ) |
|
11569 .children().each( function() { |
|
11570 var elem = $( this ); |
|
11571 if ( elem.data( "ui-menu-submenu-carat" ) ) { |
|
11572 elem.remove(); |
|
11573 } |
|
11574 }); |
|
11575 |
|
11576 // Destroy menu dividers |
|
11577 this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" ); |
|
11578 }, |
|
11579 |
|
11580 _keydown: function( event ) { |
|
11581 /*jshint maxcomplexity:20*/ |
|
11582 var match, prev, character, skip, regex, |
|
11583 preventDefault = true; |
|
11584 |
|
11585 function escape( value ) { |
|
11586 return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ); |
|
11587 } |
|
11588 |
|
11589 switch ( event.keyCode ) { |
|
11590 case $.ui.keyCode.PAGE_UP: |
|
11591 this.previousPage( event ); |
|
11592 break; |
|
11593 case $.ui.keyCode.PAGE_DOWN: |
|
11594 this.nextPage( event ); |
|
11595 break; |
|
11596 case $.ui.keyCode.HOME: |
|
11597 this._move( "first", "first", event ); |
|
11598 break; |
|
11599 case $.ui.keyCode.END: |
|
11600 this._move( "last", "last", event ); |
|
11601 break; |
|
11602 case $.ui.keyCode.UP: |
|
11603 this.previous( event ); |
|
11604 break; |
|
11605 case $.ui.keyCode.DOWN: |
|
11606 this.next( event ); |
|
11607 break; |
|
11608 case $.ui.keyCode.LEFT: |
|
11609 this.collapse( event ); |
|
11610 break; |
|
11611 case $.ui.keyCode.RIGHT: |
|
11612 if ( this.active && !this.active.is( ".ui-state-disabled" ) ) { |
|
11613 this.expand( event ); |
|
11614 } |
|
11615 break; |
|
11616 case $.ui.keyCode.ENTER: |
|
11617 case $.ui.keyCode.SPACE: |
|
11618 this._activate( event ); |
|
11619 break; |
|
11620 case $.ui.keyCode.ESCAPE: |
|
11621 this.collapse( event ); |
|
11622 break; |
|
11623 default: |
|
11624 preventDefault = false; |
|
11625 prev = this.previousFilter || ""; |
|
11626 character = String.fromCharCode( event.keyCode ); |
|
11627 skip = false; |
|
11628 |
|
11629 clearTimeout( this.filterTimer ); |
|
11630 |
|
11631 if ( character === prev ) { |
|
11632 skip = true; |
|
11633 } else { |
|
11634 character = prev + character; |
|
11635 } |
|
11636 |
|
11637 regex = new RegExp( "^" + escape( character ), "i" ); |
|
11638 match = this.activeMenu.children( ".ui-menu-item" ).filter(function() { |
|
11639 return regex.test( $( this ).children( "a" ).text() ); |
|
11640 }); |
|
11641 match = skip && match.index( this.active.next() ) !== -1 ? |
|
11642 this.active.nextAll( ".ui-menu-item" ) : |
|
11643 match; |
|
11644 |
|
11645 // If no matches on the current filter, reset to the last character pressed |
|
11646 // to move down the menu to the first item that starts with that character |
|
11647 if ( !match.length ) { |
|
11648 character = String.fromCharCode( event.keyCode ); |
|
11649 regex = new RegExp( "^" + escape( character ), "i" ); |
|
11650 match = this.activeMenu.children( ".ui-menu-item" ).filter(function() { |
|
11651 return regex.test( $( this ).children( "a" ).text() ); |
|
11652 }); |
|
11653 } |
|
11654 |
|
11655 if ( match.length ) { |
|
11656 this.focus( event, match ); |
|
11657 if ( match.length > 1 ) { |
|
11658 this.previousFilter = character; |
|
11659 this.filterTimer = this._delay(function() { |
|
11660 delete this.previousFilter; |
|
11661 }, 1000 ); |
|
11662 } else { |
|
11663 delete this.previousFilter; |
|
11664 } |
|
11665 } else { |
|
11666 delete this.previousFilter; |
|
11667 } |
|
11668 } |
|
11669 |
|
11670 if ( preventDefault ) { |
|
11671 event.preventDefault(); |
|
11672 } |
|
11673 }, |
|
11674 |
|
11675 _activate: function( event ) { |
|
11676 if ( !this.active.is( ".ui-state-disabled" ) ) { |
|
11677 if ( this.active.children( "a[aria-haspopup='true']" ).length ) { |
|
11678 this.expand( event ); |
|
11679 } else { |
|
11680 this.select( event ); |
|
11681 } |
|
11682 } |
|
11683 }, |
|
11684 |
|
11685 refresh: function() { |
|
11686 var menus, |
|
11687 icon = this.options.icons.submenu, |
|
11688 submenus = this.element.find( this.options.menus ); |
|
11689 |
|
11690 // Initialize nested menus |
|
11691 submenus.filter( ":not(.ui-menu)" ) |
|
11692 .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) |
|
11693 .hide() |
|
11694 .attr({ |
|
11695 role: this.options.role, |
|
11696 "aria-hidden": "true", |
|
11697 "aria-expanded": "false" |
|
11698 }) |
|
11699 .each(function() { |
|
11700 var menu = $( this ), |
|
11701 item = menu.prev( "a" ), |
|
11702 submenuCarat = $( "<span>" ) |
|
11703 .addClass( "ui-menu-icon ui-icon " + icon ) |
|
11704 .data( "ui-menu-submenu-carat", true ); |
|
11705 |
|
11706 item |
|
11707 .attr( "aria-haspopup", "true" ) |
|
11708 .prepend( submenuCarat ); |
|
11709 menu.attr( "aria-labelledby", item.attr( "id" ) ); |
|
11710 }); |
|
11711 |
|
11712 menus = submenus.add( this.element ); |
|
11713 |
|
11714 // Don't refresh list items that are already adapted |
|
11715 menus.children( ":not(.ui-menu-item):has(a)" ) |
|
11716 .addClass( "ui-menu-item" ) |
|
11717 .attr( "role", "presentation" ) |
|
11718 .children( "a" ) |
|
11719 .uniqueId() |
|
11720 .addClass( "ui-corner-all" ) |
|
11721 .attr({ |
|
11722 tabIndex: -1, |
|
11723 role: this._itemRole() |
|
11724 }); |
|
11725 |
|
11726 // Initialize unlinked menu-items containing spaces and/or dashes only as dividers |
|
11727 menus.children( ":not(.ui-menu-item)" ).each(function() { |
|
11728 var item = $( this ); |
|
11729 // hyphen, em dash, en dash |
|
11730 if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) { |
|
11731 item.addClass( "ui-widget-content ui-menu-divider" ); |
|
11732 } |
|
11733 }); |
|
11734 |
|
11735 // Add aria-disabled attribute to any disabled menu item |
|
11736 menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" ); |
|
11737 |
|
11738 // If the active item has been removed, blur the menu |
|
11739 if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { |
|
11740 this.blur(); |
|
11741 } |
|
11742 }, |
|
11743 |
|
11744 _itemRole: function() { |
|
11745 return { |
|
11746 menu: "menuitem", |
|
11747 listbox: "option" |
|
11748 }[ this.options.role ]; |
|
11749 }, |
|
11750 |
|
11751 _setOption: function( key, value ) { |
|
11752 if ( key === "icons" ) { |
|
11753 this.element.find( ".ui-menu-icon" ) |
|
11754 .removeClass( this.options.icons.submenu ) |
|
11755 .addClass( value.submenu ); |
|
11756 } |
|
11757 this._super( key, value ); |
|
11758 }, |
|
11759 |
|
11760 focus: function( event, item ) { |
|
11761 var nested, focused; |
|
11762 this.blur( event, event && event.type === "focus" ); |
|
11763 |
|
11764 this._scrollIntoView( item ); |
|
11765 |
|
11766 this.active = item.first(); |
|
11767 focused = this.active.children( "a" ).addClass( "ui-state-focus" ); |
|
11768 // Only update aria-activedescendant if there's a role |
|
11769 // otherwise we assume focus is managed elsewhere |
|
11770 if ( this.options.role ) { |
|
11771 this.element.attr( "aria-activedescendant", focused.attr( "id" ) ); |
|
11772 } |
|
11773 |
|
11774 // Highlight active parent menu item, if any |
|
11775 this.active |
|
11776 .parent() |
|
11777 .closest( ".ui-menu-item" ) |
|
11778 .children( "a:first" ) |
|
11779 .addClass( "ui-state-active" ); |
|
11780 |
|
11781 if ( event && event.type === "keydown" ) { |
|
11782 this._close(); |
|
11783 } else { |
|
11784 this.timer = this._delay(function() { |
|
11785 this._close(); |
|
11786 }, this.delay ); |
|
11787 } |
|
11788 |
|
11789 nested = item.children( ".ui-menu" ); |
|
11790 if ( nested.length && ( /^mouse/.test( event.type ) ) ) { |
|
11791 this._startOpening(nested); |
|
11792 } |
|
11793 this.activeMenu = item.parent(); |
|
11794 |
|
11795 this._trigger( "focus", event, { item: item } ); |
|
11796 }, |
|
11797 |
|
11798 _scrollIntoView: function( item ) { |
|
11799 var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight; |
|
11800 if ( this._hasScroll() ) { |
|
11801 borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0; |
|
11802 paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0; |
|
11803 offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop; |
|
11804 scroll = this.activeMenu.scrollTop(); |
|
11805 elementHeight = this.activeMenu.height(); |
|
11806 itemHeight = item.height(); |
|
11807 |
|
11808 if ( offset < 0 ) { |
|
11809 this.activeMenu.scrollTop( scroll + offset ); |
|
11810 } else if ( offset + itemHeight > elementHeight ) { |
|
11811 this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight ); |
|
11812 } |
|
11813 } |
|
11814 }, |
|
11815 |
|
11816 blur: function( event, fromFocus ) { |
|
11817 if ( !fromFocus ) { |
|
11818 clearTimeout( this.timer ); |
|
11819 } |
|
11820 |
|
11821 if ( !this.active ) { |
|
11822 return; |
|
11823 } |
|
11824 |
|
11825 this.active.children( "a" ).removeClass( "ui-state-focus" ); |
|
11826 this.active = null; |
|
11827 |
|
11828 this._trigger( "blur", event, { item: this.active } ); |
|
11829 }, |
|
11830 |
|
11831 _startOpening: function( submenu ) { |
|
11832 clearTimeout( this.timer ); |
|
11833 |
|
11834 // Don't open if already open fixes a Firefox bug that caused a .5 pixel |
|
11835 // shift in the submenu position when mousing over the carat icon |
|
11836 if ( submenu.attr( "aria-hidden" ) !== "true" ) { |
|
11837 return; |
|
11838 } |
|
11839 |
|
11840 this.timer = this._delay(function() { |
|
11841 this._close(); |
|
11842 this._open( submenu ); |
|
11843 }, this.delay ); |
|
11844 }, |
|
11845 |
|
11846 _open: function( submenu ) { |
|
11847 var position = $.extend({ |
|
11848 of: this.active |
|
11849 }, this.options.position ); |
|
11850 |
|
11851 clearTimeout( this.timer ); |
|
11852 this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) ) |
|
11853 .hide() |
|
11854 .attr( "aria-hidden", "true" ); |
|
11855 |
|
11856 submenu |
|
11857 .show() |
|
11858 .removeAttr( "aria-hidden" ) |
|
11859 .attr( "aria-expanded", "true" ) |
|
11860 .position( position ); |
|
11861 }, |
|
11862 |
|
11863 collapseAll: function( event, all ) { |
|
11864 clearTimeout( this.timer ); |
|
11865 this.timer = this._delay(function() { |
|
11866 // If we were passed an event, look for the submenu that contains the event |
|
11867 var currentMenu = all ? this.element : |
|
11868 $( event && event.target ).closest( this.element.find( ".ui-menu" ) ); |
|
11869 |
|
11870 // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway |
|
11871 if ( !currentMenu.length ) { |
|
11872 currentMenu = this.element; |
|
11873 } |
|
11874 |
|
11875 this._close( currentMenu ); |
|
11876 |
|
11877 this.blur( event ); |
|
11878 this.activeMenu = currentMenu; |
|
11879 }, this.delay ); |
|
11880 }, |
|
11881 |
|
11882 // With no arguments, closes the currently active menu - if nothing is active |
|
11883 // it closes all menus. If passed an argument, it will search for menus BELOW |
|
11884 _close: function( startMenu ) { |
|
11885 if ( !startMenu ) { |
|
11886 startMenu = this.active ? this.active.parent() : this.element; |
|
11887 } |
|
11888 |
|
11889 startMenu |
|
11890 .find( ".ui-menu" ) |
|
11891 .hide() |
|
11892 .attr( "aria-hidden", "true" ) |
|
11893 .attr( "aria-expanded", "false" ) |
|
11894 .end() |
|
11895 .find( "a.ui-state-active" ) |
|
11896 .removeClass( "ui-state-active" ); |
|
11897 }, |
|
11898 |
|
11899 collapse: function( event ) { |
|
11900 var newItem = this.active && |
|
11901 this.active.parent().closest( ".ui-menu-item", this.element ); |
|
11902 if ( newItem && newItem.length ) { |
|
11903 this._close(); |
|
11904 this.focus( event, newItem ); |
|
11905 } |
|
11906 }, |
|
11907 |
|
11908 expand: function( event ) { |
|
11909 var newItem = this.active && |
|
11910 this.active |
|
11911 .children( ".ui-menu " ) |
|
11912 .children( ".ui-menu-item" ) |
|
11913 .first(); |
|
11914 |
|
11915 if ( newItem && newItem.length ) { |
|
11916 this._open( newItem.parent() ); |
|
11917 |
|
11918 // Delay so Firefox will not hide activedescendant change in expanding submenu from AT |
|
11919 this._delay(function() { |
|
11920 this.focus( event, newItem ); |
|
11921 }); |
|
11922 } |
|
11923 }, |
|
11924 |
|
11925 next: function( event ) { |
|
11926 this._move( "next", "first", event ); |
|
11927 }, |
|
11928 |
|
11929 previous: function( event ) { |
|
11930 this._move( "prev", "last", event ); |
|
11931 }, |
|
11932 |
|
11933 isFirstItem: function() { |
|
11934 return this.active && !this.active.prevAll( ".ui-menu-item" ).length; |
|
11935 }, |
|
11936 |
|
11937 isLastItem: function() { |
|
11938 return this.active && !this.active.nextAll( ".ui-menu-item" ).length; |
|
11939 }, |
|
11940 |
|
11941 _move: function( direction, filter, event ) { |
|
11942 var next; |
|
11943 if ( this.active ) { |
|
11944 if ( direction === "first" || direction === "last" ) { |
|
11945 next = this.active |
|
11946 [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" ) |
|
11947 .eq( -1 ); |
|
11948 } else { |
|
11949 next = this.active |
|
11950 [ direction + "All" ]( ".ui-menu-item" ) |
|
11951 .eq( 0 ); |
|
11952 } |
|
11953 } |
|
11954 if ( !next || !next.length || !this.active ) { |
|
11955 next = this.activeMenu.children( ".ui-menu-item" )[ filter ](); |
|
11956 } |
|
11957 |
|
11958 this.focus( event, next ); |
|
11959 }, |
|
11960 |
|
11961 nextPage: function( event ) { |
|
11962 var item, base, height; |
|
11963 |
|
11964 if ( !this.active ) { |
|
11965 this.next( event ); |
|
11966 return; |
|
11967 } |
|
11968 if ( this.isLastItem() ) { |
|
11969 return; |
|
11970 } |
|
11971 if ( this._hasScroll() ) { |
|
11972 base = this.active.offset().top; |
|
11973 height = this.element.height(); |
|
11974 this.active.nextAll( ".ui-menu-item" ).each(function() { |
|
11975 item = $( this ); |
|
11976 return item.offset().top - base - height < 0; |
|
11977 }); |
|
11978 |
|
11979 this.focus( event, item ); |
|
11980 } else { |
|
11981 this.focus( event, this.activeMenu.children( ".ui-menu-item" ) |
|
11982 [ !this.active ? "first" : "last" ]() ); |
|
11983 } |
|
11984 }, |
|
11985 |
|
11986 previousPage: function( event ) { |
|
11987 var item, base, height; |
|
11988 if ( !this.active ) { |
|
11989 this.next( event ); |
|
11990 return; |
|
11991 } |
|
11992 if ( this.isFirstItem() ) { |
|
11993 return; |
|
11994 } |
|
11995 if ( this._hasScroll() ) { |
|
11996 base = this.active.offset().top; |
|
11997 height = this.element.height(); |
|
11998 this.active.prevAll( ".ui-menu-item" ).each(function() { |
|
11999 item = $( this ); |
|
12000 return item.offset().top - base + height > 0; |
|
12001 }); |
|
12002 |
|
12003 this.focus( event, item ); |
|
12004 } else { |
|
12005 this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() ); |
|
12006 } |
|
12007 }, |
|
12008 |
|
12009 _hasScroll: function() { |
|
12010 return this.element.outerHeight() < this.element.prop( "scrollHeight" ); |
|
12011 }, |
|
12012 |
|
12013 select: function( event ) { |
|
12014 // TODO: It should never be possible to not have an active item at this |
|
12015 // point, but the tests don't trigger mouseenter before click. |
|
12016 this.active = this.active || $( event.target ).closest( ".ui-menu-item" ); |
|
12017 var ui = { item: this.active }; |
|
12018 if ( !this.active.has( ".ui-menu" ).length ) { |
|
12019 this.collapseAll( event, true ); |
|
12020 } |
|
12021 this._trigger( "select", event, ui ); |
|
12022 } |
|
12023 }); |
|
12024 |
|
12025 }( jQuery )); |
|
12026 |
|
12027 (function( $, undefined ) { |
|
12028 |
|
12029 $.ui = $.ui || {}; |
|
12030 |
|
12031 var cachedScrollbarWidth, |
|
12032 max = Math.max, |
|
12033 abs = Math.abs, |
|
12034 round = Math.round, |
|
12035 rhorizontal = /left|center|right/, |
|
12036 rvertical = /top|center|bottom/, |
|
12037 roffset = /[\+\-]\d+(\.[\d]+)?%?/, |
|
12038 rposition = /^\w+/, |
|
12039 rpercent = /%$/, |
|
12040 _position = $.fn.position; |
|
12041 |
|
12042 function getOffsets( offsets, width, height ) { |
|
12043 return [ |
|
12044 parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), |
|
12045 parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) |
|
12046 ]; |
|
12047 } |
|
12048 |
|
12049 function parseCss( element, property ) { |
|
12050 return parseInt( $.css( element, property ), 10 ) || 0; |
|
12051 } |
|
12052 |
|
12053 function getDimensions( elem ) { |
|
12054 var raw = elem[0]; |
|
12055 if ( raw.nodeType === 9 ) { |
|
12056 return { |
|
12057 width: elem.width(), |
|
12058 height: elem.height(), |
|
12059 offset: { top: 0, left: 0 } |
|
12060 }; |
|
12061 } |
|
12062 if ( $.isWindow( raw ) ) { |
|
12063 return { |
|
12064 width: elem.width(), |
|
12065 height: elem.height(), |
|
12066 offset: { top: elem.scrollTop(), left: elem.scrollLeft() } |
|
12067 }; |
|
12068 } |
|
12069 if ( raw.preventDefault ) { |
|
12070 return { |
|
12071 width: 0, |
|
12072 height: 0, |
|
12073 offset: { top: raw.pageY, left: raw.pageX } |
|
12074 }; |
|
12075 } |
|
12076 return { |
|
12077 width: elem.outerWidth(), |
|
12078 height: elem.outerHeight(), |
|
12079 offset: elem.offset() |
|
12080 }; |
|
12081 } |
|
12082 |
|
12083 $.position = { |
|
12084 scrollbarWidth: function() { |
|
12085 if ( cachedScrollbarWidth !== undefined ) { |
|
12086 return cachedScrollbarWidth; |
|
12087 } |
|
12088 var w1, w2, |
|
12089 div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ), |
|
12090 innerDiv = div.children()[0]; |
|
12091 |
|
12092 $( "body" ).append( div ); |
|
12093 w1 = innerDiv.offsetWidth; |
|
12094 div.css( "overflow", "scroll" ); |
|
12095 |
|
12096 w2 = innerDiv.offsetWidth; |
|
12097 |
|
12098 if ( w1 === w2 ) { |
|
12099 w2 = div[0].clientWidth; |
|
12100 } |
|
12101 |
|
12102 div.remove(); |
|
12103 |
|
12104 return (cachedScrollbarWidth = w1 - w2); |
|
12105 }, |
|
12106 getScrollInfo: function( within ) { |
|
12107 var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ), |
|
12108 overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ), |
|
12109 hasOverflowX = overflowX === "scroll" || |
|
12110 ( overflowX === "auto" && within.width < within.element[0].scrollWidth ), |
|
12111 hasOverflowY = overflowY === "scroll" || |
|
12112 ( overflowY === "auto" && within.height < within.element[0].scrollHeight ); |
|
12113 return { |
|
12114 width: hasOverflowY ? $.position.scrollbarWidth() : 0, |
|
12115 height: hasOverflowX ? $.position.scrollbarWidth() : 0 |
|
12116 }; |
|
12117 }, |
|
12118 getWithinInfo: function( element ) { |
|
12119 var withinElement = $( element || window ), |
|
12120 isWindow = $.isWindow( withinElement[0] ); |
|
12121 return { |
|
12122 element: withinElement, |
|
12123 isWindow: isWindow, |
|
12124 offset: withinElement.offset() || { left: 0, top: 0 }, |
|
12125 scrollLeft: withinElement.scrollLeft(), |
|
12126 scrollTop: withinElement.scrollTop(), |
|
12127 width: isWindow ? withinElement.width() : withinElement.outerWidth(), |
|
12128 height: isWindow ? withinElement.height() : withinElement.outerHeight() |
|
12129 }; |
|
12130 } |
|
12131 }; |
|
12132 |
|
12133 $.fn.position = function( options ) { |
|
12134 if ( !options || !options.of ) { |
|
12135 return _position.apply( this, arguments ); |
|
12136 } |
|
12137 |
|
12138 // make a copy, we don't want to modify arguments |
|
12139 options = $.extend( {}, options ); |
|
12140 |
|
12141 var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, |
|
12142 target = $( options.of ), |
|
12143 within = $.position.getWithinInfo( options.within ), |
|
12144 scrollInfo = $.position.getScrollInfo( within ), |
|
12145 collision = ( options.collision || "flip" ).split( " " ), |
|
12146 offsets = {}; |
|
12147 |
|
12148 dimensions = getDimensions( target ); |
|
12149 if ( target[0].preventDefault ) { |
|
12150 // force left top to allow flipping |
|
12151 options.at = "left top"; |
|
12152 } |
|
12153 targetWidth = dimensions.width; |
|
12154 targetHeight = dimensions.height; |
|
12155 targetOffset = dimensions.offset; |
|
12156 // clone to reuse original targetOffset later |
|
12157 basePosition = $.extend( {}, targetOffset ); |
|
12158 |
|
12159 // force my and at to have valid horizontal and vertical positions |
|
12160 // if a value is missing or invalid, it will be converted to center |
|
12161 $.each( [ "my", "at" ], function() { |
|
12162 var pos = ( options[ this ] || "" ).split( " " ), |
|
12163 horizontalOffset, |
|
12164 verticalOffset; |
|
12165 |
|
12166 if ( pos.length === 1) { |
|
12167 pos = rhorizontal.test( pos[ 0 ] ) ? |
|
12168 pos.concat( [ "center" ] ) : |
|
12169 rvertical.test( pos[ 0 ] ) ? |
|
12170 [ "center" ].concat( pos ) : |
|
12171 [ "center", "center" ]; |
|
12172 } |
|
12173 pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; |
|
12174 pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; |
|
12175 |
|
12176 // calculate offsets |
|
12177 horizontalOffset = roffset.exec( pos[ 0 ] ); |
|
12178 verticalOffset = roffset.exec( pos[ 1 ] ); |
|
12179 offsets[ this ] = [ |
|
12180 horizontalOffset ? horizontalOffset[ 0 ] : 0, |
|
12181 verticalOffset ? verticalOffset[ 0 ] : 0 |
|
12182 ]; |
|
12183 |
|
12184 // reduce to just the positions without the offsets |
|
12185 options[ this ] = [ |
|
12186 rposition.exec( pos[ 0 ] )[ 0 ], |
|
12187 rposition.exec( pos[ 1 ] )[ 0 ] |
|
12188 ]; |
|
12189 }); |
|
12190 |
|
12191 // normalize collision option |
|
12192 if ( collision.length === 1 ) { |
|
12193 collision[ 1 ] = collision[ 0 ]; |
|
12194 } |
|
12195 |
|
12196 if ( options.at[ 0 ] === "right" ) { |
|
12197 basePosition.left += targetWidth; |
|
12198 } else if ( options.at[ 0 ] === "center" ) { |
|
12199 basePosition.left += targetWidth / 2; |
|
12200 } |
|
12201 |
|
12202 if ( options.at[ 1 ] === "bottom" ) { |
|
12203 basePosition.top += targetHeight; |
|
12204 } else if ( options.at[ 1 ] === "center" ) { |
|
12205 basePosition.top += targetHeight / 2; |
|
12206 } |
|
12207 |
|
12208 atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); |
|
12209 basePosition.left += atOffset[ 0 ]; |
|
12210 basePosition.top += atOffset[ 1 ]; |
|
12211 |
|
12212 return this.each(function() { |
|
12213 var collisionPosition, using, |
|
12214 elem = $( this ), |
|
12215 elemWidth = elem.outerWidth(), |
|
12216 elemHeight = elem.outerHeight(), |
|
12217 marginLeft = parseCss( this, "marginLeft" ), |
|
12218 marginTop = parseCss( this, "marginTop" ), |
|
12219 collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width, |
|
12220 collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height, |
|
12221 position = $.extend( {}, basePosition ), |
|
12222 myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); |
|
12223 |
|
12224 if ( options.my[ 0 ] === "right" ) { |
|
12225 position.left -= elemWidth; |
|
12226 } else if ( options.my[ 0 ] === "center" ) { |
|
12227 position.left -= elemWidth / 2; |
|
12228 } |
|
12229 |
|
12230 if ( options.my[ 1 ] === "bottom" ) { |
|
12231 position.top -= elemHeight; |
|
12232 } else if ( options.my[ 1 ] === "center" ) { |
|
12233 position.top -= elemHeight / 2; |
|
12234 } |
|
12235 |
|
12236 position.left += myOffset[ 0 ]; |
|
12237 position.top += myOffset[ 1 ]; |
|
12238 |
|
12239 // if the browser doesn't support fractions, then round for consistent results |
|
12240 if ( !$.support.offsetFractions ) { |
|
12241 position.left = round( position.left ); |
|
12242 position.top = round( position.top ); |
|
12243 } |
|
12244 |
|
12245 collisionPosition = { |
|
12246 marginLeft: marginLeft, |
|
12247 marginTop: marginTop |
|
12248 }; |
|
12249 |
|
12250 $.each( [ "left", "top" ], function( i, dir ) { |
|
12251 if ( $.ui.position[ collision[ i ] ] ) { |
|
12252 $.ui.position[ collision[ i ] ][ dir ]( position, { |
|
12253 targetWidth: targetWidth, |
|
12254 targetHeight: targetHeight, |
|
12255 elemWidth: elemWidth, |
|
12256 elemHeight: elemHeight, |
|
12257 collisionPosition: collisionPosition, |
|
12258 collisionWidth: collisionWidth, |
|
12259 collisionHeight: collisionHeight, |
|
12260 offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], |
|
12261 my: options.my, |
|
12262 at: options.at, |
|
12263 within: within, |
|
12264 elem : elem |
|
12265 }); |
|
12266 } |
|
12267 }); |
|
12268 |
|
12269 if ( options.using ) { |
|
12270 // adds feedback as second argument to using callback, if present |
|
12271 using = function( props ) { |
|
12272 var left = targetOffset.left - position.left, |
|
12273 right = left + targetWidth - elemWidth, |
|
12274 top = targetOffset.top - position.top, |
|
12275 bottom = top + targetHeight - elemHeight, |
|
12276 feedback = { |
|
12277 target: { |
|
12278 element: target, |
|
12279 left: targetOffset.left, |
|
12280 top: targetOffset.top, |
|
12281 width: targetWidth, |
|
12282 height: targetHeight |
|
12283 }, |
|
12284 element: { |
|
12285 element: elem, |
|
12286 left: position.left, |
|
12287 top: position.top, |
|
12288 width: elemWidth, |
|
12289 height: elemHeight |
|
12290 }, |
|
12291 horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", |
|
12292 vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" |
|
12293 }; |
|
12294 if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { |
|
12295 feedback.horizontal = "center"; |
|
12296 } |
|
12297 if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { |
|
12298 feedback.vertical = "middle"; |
|
12299 } |
|
12300 if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { |
|
12301 feedback.important = "horizontal"; |
|
12302 } else { |
|
12303 feedback.important = "vertical"; |
|
12304 } |
|
12305 options.using.call( this, props, feedback ); |
|
12306 }; |
|
12307 } |
|
12308 |
|
12309 elem.offset( $.extend( position, { using: using } ) ); |
|
12310 }); |
|
12311 }; |
|
12312 |
|
12313 $.ui.position = { |
|
12314 fit: { |
|
12315 left: function( position, data ) { |
|
12316 var within = data.within, |
|
12317 withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, |
|
12318 outerWidth = within.width, |
|
12319 collisionPosLeft = position.left - data.collisionPosition.marginLeft, |
|
12320 overLeft = withinOffset - collisionPosLeft, |
|
12321 overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, |
|
12322 newOverRight; |
|
12323 |
|
12324 // element is wider than within |
|
12325 if ( data.collisionWidth > outerWidth ) { |
|
12326 // element is initially over the left side of within |
|
12327 if ( overLeft > 0 && overRight <= 0 ) { |
|
12328 newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset; |
|
12329 position.left += overLeft - newOverRight; |
|
12330 // element is initially over right side of within |
|
12331 } else if ( overRight > 0 && overLeft <= 0 ) { |
|
12332 position.left = withinOffset; |
|
12333 // element is initially over both left and right sides of within |
|
12334 } else { |
|
12335 if ( overLeft > overRight ) { |
|
12336 position.left = withinOffset + outerWidth - data.collisionWidth; |
|
12337 } else { |
|
12338 position.left = withinOffset; |
|
12339 } |
|
12340 } |
|
12341 // too far left -> align with left edge |
|
12342 } else if ( overLeft > 0 ) { |
|
12343 position.left += overLeft; |
|
12344 // too far right -> align with right edge |
|
12345 } else if ( overRight > 0 ) { |
|
12346 position.left -= overRight; |
|
12347 // adjust based on position and margin |
|
12348 } else { |
|
12349 position.left = max( position.left - collisionPosLeft, position.left ); |
|
12350 } |
|
12351 }, |
|
12352 top: function( position, data ) { |
|
12353 var within = data.within, |
|
12354 withinOffset = within.isWindow ? within.scrollTop : within.offset.top, |
|
12355 outerHeight = data.within.height, |
|
12356 collisionPosTop = position.top - data.collisionPosition.marginTop, |
|
12357 overTop = withinOffset - collisionPosTop, |
|
12358 overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, |
|
12359 newOverBottom; |
|
12360 |
|
12361 // element is taller than within |
|
12362 if ( data.collisionHeight > outerHeight ) { |
|
12363 // element is initially over the top of within |
|
12364 if ( overTop > 0 && overBottom <= 0 ) { |
|
12365 newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset; |
|
12366 position.top += overTop - newOverBottom; |
|
12367 // element is initially over bottom of within |
|
12368 } else if ( overBottom > 0 && overTop <= 0 ) { |
|
12369 position.top = withinOffset; |
|
12370 // element is initially over both top and bottom of within |
|
12371 } else { |
|
12372 if ( overTop > overBottom ) { |
|
12373 position.top = withinOffset + outerHeight - data.collisionHeight; |
|
12374 } else { |
|
12375 position.top = withinOffset; |
|
12376 } |
|
12377 } |
|
12378 // too far up -> align with top |
|
12379 } else if ( overTop > 0 ) { |
|
12380 position.top += overTop; |
|
12381 // too far down -> align with bottom edge |
|
12382 } else if ( overBottom > 0 ) { |
|
12383 position.top -= overBottom; |
|
12384 // adjust based on position and margin |
|
12385 } else { |
|
12386 position.top = max( position.top - collisionPosTop, position.top ); |
|
12387 } |
|
12388 } |
|
12389 }, |
|
12390 flip: { |
|
12391 left: function( position, data ) { |
|
12392 var within = data.within, |
|
12393 withinOffset = within.offset.left + within.scrollLeft, |
|
12394 outerWidth = within.width, |
|
12395 offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, |
|
12396 collisionPosLeft = position.left - data.collisionPosition.marginLeft, |
|
12397 overLeft = collisionPosLeft - offsetLeft, |
|
12398 overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, |
|
12399 myOffset = data.my[ 0 ] === "left" ? |
|
12400 -data.elemWidth : |
|
12401 data.my[ 0 ] === "right" ? |
|
12402 data.elemWidth : |
|
12403 0, |
|
12404 atOffset = data.at[ 0 ] === "left" ? |
|
12405 data.targetWidth : |
|
12406 data.at[ 0 ] === "right" ? |
|
12407 -data.targetWidth : |
|
12408 0, |
|
12409 offset = -2 * data.offset[ 0 ], |
|
12410 newOverRight, |
|
12411 newOverLeft; |
|
12412 |
|
12413 if ( overLeft < 0 ) { |
|
12414 newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; |
|
12415 if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { |
|
12416 position.left += myOffset + atOffset + offset; |
|
12417 } |
|
12418 } |
|
12419 else if ( overRight > 0 ) { |
|
12420 newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft; |
|
12421 if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { |
|
12422 position.left += myOffset + atOffset + offset; |
|
12423 } |
|
12424 } |
|
12425 }, |
|
12426 top: function( position, data ) { |
|
12427 var within = data.within, |
|
12428 withinOffset = within.offset.top + within.scrollTop, |
|
12429 outerHeight = within.height, |
|
12430 offsetTop = within.isWindow ? within.scrollTop : within.offset.top, |
|
12431 collisionPosTop = position.top - data.collisionPosition.marginTop, |
|
12432 overTop = collisionPosTop - offsetTop, |
|
12433 overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, |
|
12434 top = data.my[ 1 ] === "top", |
|
12435 myOffset = top ? |
|
12436 -data.elemHeight : |
|
12437 data.my[ 1 ] === "bottom" ? |
|
12438 data.elemHeight : |
|
12439 0, |
|
12440 atOffset = data.at[ 1 ] === "top" ? |
|
12441 data.targetHeight : |
|
12442 data.at[ 1 ] === "bottom" ? |
|
12443 -data.targetHeight : |
|
12444 0, |
|
12445 offset = -2 * data.offset[ 1 ], |
|
12446 newOverTop, |
|
12447 newOverBottom; |
|
12448 if ( overTop < 0 ) { |
|
12449 newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; |
|
12450 if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) { |
|
12451 position.top += myOffset + atOffset + offset; |
|
12452 } |
|
12453 } |
|
12454 else if ( overBottom > 0 ) { |
|
12455 newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; |
|
12456 if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) { |
|
12457 position.top += myOffset + atOffset + offset; |
|
12458 } |
|
12459 } |
|
12460 } |
|
12461 }, |
|
12462 flipfit: { |
|
12463 left: function() { |
|
12464 $.ui.position.flip.left.apply( this, arguments ); |
|
12465 $.ui.position.fit.left.apply( this, arguments ); |
|
12466 }, |
|
12467 top: function() { |
|
12468 $.ui.position.flip.top.apply( this, arguments ); |
|
12469 $.ui.position.fit.top.apply( this, arguments ); |
|
12470 } |
|
12471 } |
|
12472 }; |
|
12473 |
|
12474 // fraction support test |
|
12475 (function () { |
|
12476 var testElement, testElementParent, testElementStyle, offsetLeft, i, |
|
12477 body = document.getElementsByTagName( "body" )[ 0 ], |
|
12478 div = document.createElement( "div" ); |
|
12479 |
|
12480 //Create a "fake body" for testing based on method used in jQuery.support |
|
12481 testElement = document.createElement( body ? "div" : "body" ); |
|
12482 testElementStyle = { |
|
12483 visibility: "hidden", |
|
12484 width: 0, |
|
12485 height: 0, |
|
12486 border: 0, |
|
12487 margin: 0, |
|
12488 background: "none" |
|
12489 }; |
|
12490 if ( body ) { |
|
12491 $.extend( testElementStyle, { |
|
12492 position: "absolute", |
|
12493 left: "-1000px", |
|
12494 top: "-1000px" |
|
12495 }); |
|
12496 } |
|
12497 for ( i in testElementStyle ) { |
|
12498 testElement.style[ i ] = testElementStyle[ i ]; |
|
12499 } |
|
12500 testElement.appendChild( div ); |
|
12501 testElementParent = body || document.documentElement; |
|
12502 testElementParent.insertBefore( testElement, testElementParent.firstChild ); |
|
12503 |
|
12504 div.style.cssText = "position: absolute; left: 10.7432222px;"; |
|
12505 |
|
12506 offsetLeft = $( div ).offset().left; |
|
12507 $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11; |
|
12508 |
|
12509 testElement.innerHTML = ""; |
|
12510 testElementParent.removeChild( testElement ); |
|
12511 })(); |
|
12512 |
|
12513 }( jQuery ) ); |
|
12514 |
|
12515 (function( $, undefined ) { |
|
12516 |
|
12517 $.widget( "ui.progressbar", { |
|
12518 version: "1.10.3", |
|
12519 options: { |
11783 options: { |
12520 max: 100, |
11784 max: 100, |
12521 value: 0, |
11785 value: 0, |
12522 |
11786 |
12523 change: null, |
11787 change: null, |
13295 this._change( event, index ); |
13479 this._change( event, index ); |
13296 $( event.target ).removeClass( "ui-state-active" ); |
13480 $( event.target ).removeClass( "ui-state-active" ); |
13297 } |
13481 } |
13298 } |
13482 } |
13299 } |
13483 } |
13300 |
|
13301 }); |
13484 }); |
13302 |
13485 |
13303 }(jQuery)); |
13486 |
13304 |
13487 /*! |
13305 (function( $ ) { |
13488 * jQuery UI Sortable 1.11.4 |
13306 |
13489 * http://jqueryui.com |
13307 function modifier( fn ) { |
13490 * |
|
13491 * Copyright jQuery Foundation and other contributors |
|
13492 * Released under the MIT license. |
|
13493 * http://jquery.org/license |
|
13494 * |
|
13495 * http://api.jqueryui.com/sortable/ |
|
13496 */ |
|
13497 |
|
13498 |
|
13499 var sortable = $.widget("ui.sortable", $.ui.mouse, { |
|
13500 version: "1.11.4", |
|
13501 widgetEventPrefix: "sort", |
|
13502 ready: false, |
|
13503 options: { |
|
13504 appendTo: "parent", |
|
13505 axis: false, |
|
13506 connectWith: false, |
|
13507 containment: false, |
|
13508 cursor: "auto", |
|
13509 cursorAt: false, |
|
13510 dropOnEmpty: true, |
|
13511 forcePlaceholderSize: false, |
|
13512 forceHelperSize: false, |
|
13513 grid: false, |
|
13514 handle: false, |
|
13515 helper: "original", |
|
13516 items: "> *", |
|
13517 opacity: false, |
|
13518 placeholder: false, |
|
13519 revert: false, |
|
13520 scroll: true, |
|
13521 scrollSensitivity: 20, |
|
13522 scrollSpeed: 20, |
|
13523 scope: "default", |
|
13524 tolerance: "intersect", |
|
13525 zIndex: 1000, |
|
13526 |
|
13527 // callbacks |
|
13528 activate: null, |
|
13529 beforeStop: null, |
|
13530 change: null, |
|
13531 deactivate: null, |
|
13532 out: null, |
|
13533 over: null, |
|
13534 receive: null, |
|
13535 remove: null, |
|
13536 sort: null, |
|
13537 start: null, |
|
13538 stop: null, |
|
13539 update: null |
|
13540 }, |
|
13541 |
|
13542 _isOverAxis: function( x, reference, size ) { |
|
13543 return ( x >= reference ) && ( x < ( reference + size ) ); |
|
13544 }, |
|
13545 |
|
13546 _isFloating: function( item ) { |
|
13547 return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display")); |
|
13548 }, |
|
13549 |
|
13550 _create: function() { |
|
13551 this.containerCache = {}; |
|
13552 this.element.addClass("ui-sortable"); |
|
13553 |
|
13554 //Get the items |
|
13555 this.refresh(); |
|
13556 |
|
13557 //Let's determine the parent's offset |
|
13558 this.offset = this.element.offset(); |
|
13559 |
|
13560 //Initialize mouse events for interaction |
|
13561 this._mouseInit(); |
|
13562 |
|
13563 this._setHandleClassName(); |
|
13564 |
|
13565 //We're ready to go |
|
13566 this.ready = true; |
|
13567 |
|
13568 }, |
|
13569 |
|
13570 _setOption: function( key, value ) { |
|
13571 this._super( key, value ); |
|
13572 |
|
13573 if ( key === "handle" ) { |
|
13574 this._setHandleClassName(); |
|
13575 } |
|
13576 }, |
|
13577 |
|
13578 _setHandleClassName: function() { |
|
13579 this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" ); |
|
13580 $.each( this.items, function() { |
|
13581 ( this.instance.options.handle ? |
|
13582 this.item.find( this.instance.options.handle ) : this.item ) |
|
13583 .addClass( "ui-sortable-handle" ); |
|
13584 }); |
|
13585 }, |
|
13586 |
|
13587 _destroy: function() { |
|
13588 this.element |
|
13589 .removeClass( "ui-sortable ui-sortable-disabled" ) |
|
13590 .find( ".ui-sortable-handle" ) |
|
13591 .removeClass( "ui-sortable-handle" ); |
|
13592 this._mouseDestroy(); |
|
13593 |
|
13594 for ( var i = this.items.length - 1; i >= 0; i-- ) { |
|
13595 this.items[i].item.removeData(this.widgetName + "-item"); |
|
13596 } |
|
13597 |
|
13598 return this; |
|
13599 }, |
|
13600 |
|
13601 _mouseCapture: function(event, overrideHandle) { |
|
13602 var currentItem = null, |
|
13603 validHandle = false, |
|
13604 that = this; |
|
13605 |
|
13606 if (this.reverting) { |
|
13607 return false; |
|
13608 } |
|
13609 |
|
13610 if(this.options.disabled || this.options.type === "static") { |
|
13611 return false; |
|
13612 } |
|
13613 |
|
13614 //We have to refresh the items data once first |
|
13615 this._refreshItems(event); |
|
13616 |
|
13617 //Find out if the clicked node (or one of its parents) is a actual item in this.items |
|
13618 $(event.target).parents().each(function() { |
|
13619 if($.data(this, that.widgetName + "-item") === that) { |
|
13620 currentItem = $(this); |
|
13621 return false; |
|
13622 } |
|
13623 }); |
|
13624 if($.data(event.target, that.widgetName + "-item") === that) { |
|
13625 currentItem = $(event.target); |
|
13626 } |
|
13627 |
|
13628 if(!currentItem) { |
|
13629 return false; |
|
13630 } |
|
13631 if(this.options.handle && !overrideHandle) { |
|
13632 $(this.options.handle, currentItem).find("*").addBack().each(function() { |
|
13633 if(this === event.target) { |
|
13634 validHandle = true; |
|
13635 } |
|
13636 }); |
|
13637 if(!validHandle) { |
|
13638 return false; |
|
13639 } |
|
13640 } |
|
13641 |
|
13642 this.currentItem = currentItem; |
|
13643 this._removeCurrentsFromItems(); |
|
13644 return true; |
|
13645 |
|
13646 }, |
|
13647 |
|
13648 _mouseStart: function(event, overrideHandle, noActivation) { |
|
13649 |
|
13650 var i, body, |
|
13651 o = this.options; |
|
13652 |
|
13653 this.currentContainer = this; |
|
13654 |
|
13655 //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture |
|
13656 this.refreshPositions(); |
|
13657 |
|
13658 //Create and append the visible helper |
|
13659 this.helper = this._createHelper(event); |
|
13660 |
|
13661 //Cache the helper size |
|
13662 this._cacheHelperProportions(); |
|
13663 |
|
13664 /* |
|
13665 * - Position generation - |
|
13666 * This block generates everything position related - it's the core of draggables. |
|
13667 */ |
|
13668 |
|
13669 //Cache the margins of the original element |
|
13670 this._cacheMargins(); |
|
13671 |
|
13672 //Get the next scrolling parent |
|
13673 this.scrollParent = this.helper.scrollParent(); |
|
13674 |
|
13675 //The element's absolute position on the page minus margins |
|
13676 this.offset = this.currentItem.offset(); |
|
13677 this.offset = { |
|
13678 top: this.offset.top - this.margins.top, |
|
13679 left: this.offset.left - this.margins.left |
|
13680 }; |
|
13681 |
|
13682 $.extend(this.offset, { |
|
13683 click: { //Where the click happened, relative to the element |
|
13684 left: event.pageX - this.offset.left, |
|
13685 top: event.pageY - this.offset.top |
|
13686 }, |
|
13687 parent: this._getParentOffset(), |
|
13688 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper |
|
13689 }); |
|
13690 |
|
13691 // Only after we got the offset, we can change the helper's position to absolute |
|
13692 // TODO: Still need to figure out a way to make relative sorting possible |
|
13693 this.helper.css("position", "absolute"); |
|
13694 this.cssPosition = this.helper.css("position"); |
|
13695 |
|
13696 //Generate the original position |
|
13697 this.originalPosition = this._generatePosition(event); |
|
13698 this.originalPageX = event.pageX; |
|
13699 this.originalPageY = event.pageY; |
|
13700 |
|
13701 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied |
|
13702 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); |
|
13703 |
|
13704 //Cache the former DOM position |
|
13705 this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; |
|
13706 |
|
13707 //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way |
|
13708 if(this.helper[0] !== this.currentItem[0]) { |
|
13709 this.currentItem.hide(); |
|
13710 } |
|
13711 |
|
13712 //Create the placeholder |
|
13713 this._createPlaceholder(); |
|
13714 |
|
13715 //Set a containment if given in the options |
|
13716 if(o.containment) { |
|
13717 this._setContainment(); |
|
13718 } |
|
13719 |
|
13720 if( o.cursor && o.cursor !== "auto" ) { // cursor option |
|
13721 body = this.document.find( "body" ); |
|
13722 |
|
13723 // support: IE |
|
13724 this.storedCursor = body.css( "cursor" ); |
|
13725 body.css( "cursor", o.cursor ); |
|
13726 |
|
13727 this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body ); |
|
13728 } |
|
13729 |
|
13730 if(o.opacity) { // opacity option |
|
13731 if (this.helper.css("opacity")) { |
|
13732 this._storedOpacity = this.helper.css("opacity"); |
|
13733 } |
|
13734 this.helper.css("opacity", o.opacity); |
|
13735 } |
|
13736 |
|
13737 if(o.zIndex) { // zIndex option |
|
13738 if (this.helper.css("zIndex")) { |
|
13739 this._storedZIndex = this.helper.css("zIndex"); |
|
13740 } |
|
13741 this.helper.css("zIndex", o.zIndex); |
|
13742 } |
|
13743 |
|
13744 //Prepare scrolling |
|
13745 if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") { |
|
13746 this.overflowOffset = this.scrollParent.offset(); |
|
13747 } |
|
13748 |
|
13749 //Call callbacks |
|
13750 this._trigger("start", event, this._uiHash()); |
|
13751 |
|
13752 //Recache the helper size |
|
13753 if(!this._preserveHelperProportions) { |
|
13754 this._cacheHelperProportions(); |
|
13755 } |
|
13756 |
|
13757 |
|
13758 //Post "activate" events to possible containers |
|
13759 if( !noActivation ) { |
|
13760 for ( i = this.containers.length - 1; i >= 0; i-- ) { |
|
13761 this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); |
|
13762 } |
|
13763 } |
|
13764 |
|
13765 //Prepare possible droppables |
|
13766 if($.ui.ddmanager) { |
|
13767 $.ui.ddmanager.current = this; |
|
13768 } |
|
13769 |
|
13770 if ($.ui.ddmanager && !o.dropBehaviour) { |
|
13771 $.ui.ddmanager.prepareOffsets(this, event); |
|
13772 } |
|
13773 |
|
13774 this.dragging = true; |
|
13775 |
|
13776 this.helper.addClass("ui-sortable-helper"); |
|
13777 this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
|
13778 return true; |
|
13779 |
|
13780 }, |
|
13781 |
|
13782 _mouseDrag: function(event) { |
|
13783 var i, item, itemElement, intersection, |
|
13784 o = this.options, |
|
13785 scrolled = false; |
|
13786 |
|
13787 //Compute the helpers position |
|
13788 this.position = this._generatePosition(event); |
|
13789 this.positionAbs = this._convertPositionTo("absolute"); |
|
13790 |
|
13791 if (!this.lastPositionAbs) { |
|
13792 this.lastPositionAbs = this.positionAbs; |
|
13793 } |
|
13794 |
|
13795 //Do scrolling |
|
13796 if(this.options.scroll) { |
|
13797 if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") { |
|
13798 |
|
13799 if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) { |
|
13800 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; |
|
13801 } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) { |
|
13802 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; |
|
13803 } |
|
13804 |
|
13805 if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) { |
|
13806 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; |
|
13807 } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) { |
|
13808 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; |
|
13809 } |
|
13810 |
|
13811 } else { |
|
13812 |
|
13813 if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) { |
|
13814 scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed); |
|
13815 } else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) { |
|
13816 scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed); |
|
13817 } |
|
13818 |
|
13819 if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) { |
|
13820 scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed); |
|
13821 } else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) { |
|
13822 scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed); |
|
13823 } |
|
13824 |
|
13825 } |
|
13826 |
|
13827 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { |
|
13828 $.ui.ddmanager.prepareOffsets(this, event); |
|
13829 } |
|
13830 } |
|
13831 |
|
13832 //Regenerate the absolute position used for position checks |
|
13833 this.positionAbs = this._convertPositionTo("absolute"); |
|
13834 |
|
13835 //Set the helper position |
|
13836 if(!this.options.axis || this.options.axis !== "y") { |
|
13837 this.helper[0].style.left = this.position.left+"px"; |
|
13838 } |
|
13839 if(!this.options.axis || this.options.axis !== "x") { |
|
13840 this.helper[0].style.top = this.position.top+"px"; |
|
13841 } |
|
13842 |
|
13843 //Rearrange |
|
13844 for (i = this.items.length - 1; i >= 0; i--) { |
|
13845 |
|
13846 //Cache variables and intersection, continue if no intersection |
|
13847 item = this.items[i]; |
|
13848 itemElement = item.item[0]; |
|
13849 intersection = this._intersectsWithPointer(item); |
|
13850 if (!intersection) { |
|
13851 continue; |
|
13852 } |
|
13853 |
|
13854 // Only put the placeholder inside the current Container, skip all |
|
13855 // items from other containers. This works because when moving |
|
13856 // an item from one container to another the |
|
13857 // currentContainer is switched before the placeholder is moved. |
|
13858 // |
|
13859 // Without this, moving items in "sub-sortables" can cause |
|
13860 // the placeholder to jitter between the outer and inner container. |
|
13861 if (item.instance !== this.currentContainer) { |
|
13862 continue; |
|
13863 } |
|
13864 |
|
13865 // cannot intersect with itself |
|
13866 // no useless actions that have been done before |
|
13867 // no action if the item moved is the parent of the item checked |
|
13868 if (itemElement !== this.currentItem[0] && |
|
13869 this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement && |
|
13870 !$.contains(this.placeholder[0], itemElement) && |
|
13871 (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true) |
|
13872 ) { |
|
13873 |
|
13874 this.direction = intersection === 1 ? "down" : "up"; |
|
13875 |
|
13876 if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) { |
|
13877 this._rearrange(event, item); |
|
13878 } else { |
|
13879 break; |
|
13880 } |
|
13881 |
|
13882 this._trigger("change", event, this._uiHash()); |
|
13883 break; |
|
13884 } |
|
13885 } |
|
13886 |
|
13887 //Post events to containers |
|
13888 this._contactContainers(event); |
|
13889 |
|
13890 //Interconnect with droppables |
|
13891 if($.ui.ddmanager) { |
|
13892 $.ui.ddmanager.drag(this, event); |
|
13893 } |
|
13894 |
|
13895 //Call callbacks |
|
13896 this._trigger("sort", event, this._uiHash()); |
|
13897 |
|
13898 this.lastPositionAbs = this.positionAbs; |
|
13899 return false; |
|
13900 |
|
13901 }, |
|
13902 |
|
13903 _mouseStop: function(event, noPropagation) { |
|
13904 |
|
13905 if(!event) { |
|
13906 return; |
|
13907 } |
|
13908 |
|
13909 //If we are using droppables, inform the manager about the drop |
|
13910 if ($.ui.ddmanager && !this.options.dropBehaviour) { |
|
13911 $.ui.ddmanager.drop(this, event); |
|
13912 } |
|
13913 |
|
13914 if(this.options.revert) { |
|
13915 var that = this, |
|
13916 cur = this.placeholder.offset(), |
|
13917 axis = this.options.axis, |
|
13918 animation = {}; |
|
13919 |
|
13920 if ( !axis || axis === "x" ) { |
|
13921 animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft); |
|
13922 } |
|
13923 if ( !axis || axis === "y" ) { |
|
13924 animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop); |
|
13925 } |
|
13926 this.reverting = true; |
|
13927 $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() { |
|
13928 that._clear(event); |
|
13929 }); |
|
13930 } else { |
|
13931 this._clear(event, noPropagation); |
|
13932 } |
|
13933 |
|
13934 return false; |
|
13935 |
|
13936 }, |
|
13937 |
|
13938 cancel: function() { |
|
13939 |
|
13940 if(this.dragging) { |
|
13941 |
|
13942 this._mouseUp({ target: null }); |
|
13943 |
|
13944 if(this.options.helper === "original") { |
|
13945 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); |
|
13946 } else { |
|
13947 this.currentItem.show(); |
|
13948 } |
|
13949 |
|
13950 //Post deactivating events to containers |
|
13951 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
13952 this.containers[i]._trigger("deactivate", null, this._uiHash(this)); |
|
13953 if(this.containers[i].containerCache.over) { |
|
13954 this.containers[i]._trigger("out", null, this._uiHash(this)); |
|
13955 this.containers[i].containerCache.over = 0; |
|
13956 } |
|
13957 } |
|
13958 |
|
13959 } |
|
13960 |
|
13961 if (this.placeholder) { |
|
13962 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
|
13963 if(this.placeholder[0].parentNode) { |
|
13964 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
|
13965 } |
|
13966 if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) { |
|
13967 this.helper.remove(); |
|
13968 } |
|
13969 |
|
13970 $.extend(this, { |
|
13971 helper: null, |
|
13972 dragging: false, |
|
13973 reverting: false, |
|
13974 _noFinalSort: null |
|
13975 }); |
|
13976 |
|
13977 if(this.domPosition.prev) { |
|
13978 $(this.domPosition.prev).after(this.currentItem); |
|
13979 } else { |
|
13980 $(this.domPosition.parent).prepend(this.currentItem); |
|
13981 } |
|
13982 } |
|
13983 |
|
13984 return this; |
|
13985 |
|
13986 }, |
|
13987 |
|
13988 serialize: function(o) { |
|
13989 |
|
13990 var items = this._getItemsAsjQuery(o && o.connected), |
|
13991 str = []; |
|
13992 o = o || {}; |
|
13993 |
|
13994 $(items).each(function() { |
|
13995 var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/)); |
|
13996 if (res) { |
|
13997 str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2])); |
|
13998 } |
|
13999 }); |
|
14000 |
|
14001 if(!str.length && o.key) { |
|
14002 str.push(o.key + "="); |
|
14003 } |
|
14004 |
|
14005 return str.join("&"); |
|
14006 |
|
14007 }, |
|
14008 |
|
14009 toArray: function(o) { |
|
14010 |
|
14011 var items = this._getItemsAsjQuery(o && o.connected), |
|
14012 ret = []; |
|
14013 |
|
14014 o = o || {}; |
|
14015 |
|
14016 items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); }); |
|
14017 return ret; |
|
14018 |
|
14019 }, |
|
14020 |
|
14021 /* Be careful with the following core functions */ |
|
14022 _intersectsWith: function(item) { |
|
14023 |
|
14024 var x1 = this.positionAbs.left, |
|
14025 x2 = x1 + this.helperProportions.width, |
|
14026 y1 = this.positionAbs.top, |
|
14027 y2 = y1 + this.helperProportions.height, |
|
14028 l = item.left, |
|
14029 r = l + item.width, |
|
14030 t = item.top, |
|
14031 b = t + item.height, |
|
14032 dyClick = this.offset.click.top, |
|
14033 dxClick = this.offset.click.left, |
|
14034 isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ), |
|
14035 isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ), |
|
14036 isOverElement = isOverElementHeight && isOverElementWidth; |
|
14037 |
|
14038 if ( this.options.tolerance === "pointer" || |
|
14039 this.options.forcePointerForContainers || |
|
14040 (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"]) |
|
14041 ) { |
|
14042 return isOverElement; |
|
14043 } else { |
|
14044 |
|
14045 return (l < x1 + (this.helperProportions.width / 2) && // Right Half |
|
14046 x2 - (this.helperProportions.width / 2) < r && // Left Half |
|
14047 t < y1 + (this.helperProportions.height / 2) && // Bottom Half |
|
14048 y2 - (this.helperProportions.height / 2) < b ); // Top Half |
|
14049 |
|
14050 } |
|
14051 }, |
|
14052 |
|
14053 _intersectsWithPointer: function(item) { |
|
14054 |
|
14055 var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), |
|
14056 isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), |
|
14057 isOverElement = isOverElementHeight && isOverElementWidth, |
|
14058 verticalDirection = this._getDragVerticalDirection(), |
|
14059 horizontalDirection = this._getDragHorizontalDirection(); |
|
14060 |
|
14061 if (!isOverElement) { |
|
14062 return false; |
|
14063 } |
|
14064 |
|
14065 return this.floating ? |
|
14066 ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 ) |
|
14067 : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) ); |
|
14068 |
|
14069 }, |
|
14070 |
|
14071 _intersectsWithSides: function(item) { |
|
14072 |
|
14073 var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), |
|
14074 isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), |
|
14075 verticalDirection = this._getDragVerticalDirection(), |
|
14076 horizontalDirection = this._getDragHorizontalDirection(); |
|
14077 |
|
14078 if (this.floating && horizontalDirection) { |
|
14079 return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf)); |
|
14080 } else { |
|
14081 return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf)); |
|
14082 } |
|
14083 |
|
14084 }, |
|
14085 |
|
14086 _getDragVerticalDirection: function() { |
|
14087 var delta = this.positionAbs.top - this.lastPositionAbs.top; |
|
14088 return delta !== 0 && (delta > 0 ? "down" : "up"); |
|
14089 }, |
|
14090 |
|
14091 _getDragHorizontalDirection: function() { |
|
14092 var delta = this.positionAbs.left - this.lastPositionAbs.left; |
|
14093 return delta !== 0 && (delta > 0 ? "right" : "left"); |
|
14094 }, |
|
14095 |
|
14096 refresh: function(event) { |
|
14097 this._refreshItems(event); |
|
14098 this._setHandleClassName(); |
|
14099 this.refreshPositions(); |
|
14100 return this; |
|
14101 }, |
|
14102 |
|
14103 _connectWith: function() { |
|
14104 var options = this.options; |
|
14105 return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith; |
|
14106 }, |
|
14107 |
|
14108 _getItemsAsjQuery: function(connected) { |
|
14109 |
|
14110 var i, j, cur, inst, |
|
14111 items = [], |
|
14112 queries = [], |
|
14113 connectWith = this._connectWith(); |
|
14114 |
|
14115 if(connectWith && connected) { |
|
14116 for (i = connectWith.length - 1; i >= 0; i--){ |
|
14117 cur = $(connectWith[i], this.document[0]); |
|
14118 for ( j = cur.length - 1; j >= 0; j--){ |
|
14119 inst = $.data(cur[j], this.widgetFullName); |
|
14120 if(inst && inst !== this && !inst.options.disabled) { |
|
14121 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]); |
|
14122 } |
|
14123 } |
|
14124 } |
|
14125 } |
|
14126 |
|
14127 queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]); |
|
14128 |
|
14129 function addItems() { |
|
14130 items.push( this ); |
|
14131 } |
|
14132 for (i = queries.length - 1; i >= 0; i--){ |
|
14133 queries[i][0].each( addItems ); |
|
14134 } |
|
14135 |
|
14136 return $(items); |
|
14137 |
|
14138 }, |
|
14139 |
|
14140 _removeCurrentsFromItems: function() { |
|
14141 |
|
14142 var list = this.currentItem.find(":data(" + this.widgetName + "-item)"); |
|
14143 |
|
14144 this.items = $.grep(this.items, function (item) { |
|
14145 for (var j=0; j < list.length; j++) { |
|
14146 if(list[j] === item.item[0]) { |
|
14147 return false; |
|
14148 } |
|
14149 } |
|
14150 return true; |
|
14151 }); |
|
14152 |
|
14153 }, |
|
14154 |
|
14155 _refreshItems: function(event) { |
|
14156 |
|
14157 this.items = []; |
|
14158 this.containers = [this]; |
|
14159 |
|
14160 var i, j, cur, inst, targetData, _queries, item, queriesLength, |
|
14161 items = this.items, |
|
14162 queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]], |
|
14163 connectWith = this._connectWith(); |
|
14164 |
|
14165 if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down |
|
14166 for (i = connectWith.length - 1; i >= 0; i--){ |
|
14167 cur = $(connectWith[i], this.document[0]); |
|
14168 for (j = cur.length - 1; j >= 0; j--){ |
|
14169 inst = $.data(cur[j], this.widgetFullName); |
|
14170 if(inst && inst !== this && !inst.options.disabled) { |
|
14171 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); |
|
14172 this.containers.push(inst); |
|
14173 } |
|
14174 } |
|
14175 } |
|
14176 } |
|
14177 |
|
14178 for (i = queries.length - 1; i >= 0; i--) { |
|
14179 targetData = queries[i][1]; |
|
14180 _queries = queries[i][0]; |
|
14181 |
|
14182 for (j=0, queriesLength = _queries.length; j < queriesLength; j++) { |
|
14183 item = $(_queries[j]); |
|
14184 |
|
14185 item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager) |
|
14186 |
|
14187 items.push({ |
|
14188 item: item, |
|
14189 instance: targetData, |
|
14190 width: 0, height: 0, |
|
14191 left: 0, top: 0 |
|
14192 }); |
|
14193 } |
|
14194 } |
|
14195 |
|
14196 }, |
|
14197 |
|
14198 refreshPositions: function(fast) { |
|
14199 |
|
14200 // Determine whether items are being displayed horizontally |
|
14201 this.floating = this.items.length ? |
|
14202 this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) : |
|
14203 false; |
|
14204 |
|
14205 //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change |
|
14206 if(this.offsetParent && this.helper) { |
|
14207 this.offset.parent = this._getParentOffset(); |
|
14208 } |
|
14209 |
|
14210 var i, item, t, p; |
|
14211 |
|
14212 for (i = this.items.length - 1; i >= 0; i--){ |
|
14213 item = this.items[i]; |
|
14214 |
|
14215 //We ignore calculating positions of all connected containers when we're not over them |
|
14216 if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) { |
|
14217 continue; |
|
14218 } |
|
14219 |
|
14220 t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; |
|
14221 |
|
14222 if (!fast) { |
|
14223 item.width = t.outerWidth(); |
|
14224 item.height = t.outerHeight(); |
|
14225 } |
|
14226 |
|
14227 p = t.offset(); |
|
14228 item.left = p.left; |
|
14229 item.top = p.top; |
|
14230 } |
|
14231 |
|
14232 if(this.options.custom && this.options.custom.refreshContainers) { |
|
14233 this.options.custom.refreshContainers.call(this); |
|
14234 } else { |
|
14235 for (i = this.containers.length - 1; i >= 0; i--){ |
|
14236 p = this.containers[i].element.offset(); |
|
14237 this.containers[i].containerCache.left = p.left; |
|
14238 this.containers[i].containerCache.top = p.top; |
|
14239 this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); |
|
14240 this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); |
|
14241 } |
|
14242 } |
|
14243 |
|
14244 return this; |
|
14245 }, |
|
14246 |
|
14247 _createPlaceholder: function(that) { |
|
14248 that = that || this; |
|
14249 var className, |
|
14250 o = that.options; |
|
14251 |
|
14252 if(!o.placeholder || o.placeholder.constructor === String) { |
|
14253 className = o.placeholder; |
|
14254 o.placeholder = { |
|
14255 element: function() { |
|
14256 |
|
14257 var nodeName = that.currentItem[0].nodeName.toLowerCase(), |
|
14258 element = $( "<" + nodeName + ">", that.document[0] ) |
|
14259 .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") |
|
14260 .removeClass("ui-sortable-helper"); |
|
14261 |
|
14262 if ( nodeName === "tbody" ) { |
|
14263 that._createTrPlaceholder( |
|
14264 that.currentItem.find( "tr" ).eq( 0 ), |
|
14265 $( "<tr>", that.document[ 0 ] ).appendTo( element ) |
|
14266 ); |
|
14267 } else if ( nodeName === "tr" ) { |
|
14268 that._createTrPlaceholder( that.currentItem, element ); |
|
14269 } else if ( nodeName === "img" ) { |
|
14270 element.attr( "src", that.currentItem.attr( "src" ) ); |
|
14271 } |
|
14272 |
|
14273 if ( !className ) { |
|
14274 element.css( "visibility", "hidden" ); |
|
14275 } |
|
14276 |
|
14277 return element; |
|
14278 }, |
|
14279 update: function(container, p) { |
|
14280 |
|
14281 // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that |
|
14282 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified |
|
14283 if(className && !o.forcePlaceholderSize) { |
|
14284 return; |
|
14285 } |
|
14286 |
|
14287 //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item |
|
14288 if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); } |
|
14289 if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); } |
|
14290 } |
|
14291 }; |
|
14292 } |
|
14293 |
|
14294 //Create the placeholder |
|
14295 that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem)); |
|
14296 |
|
14297 //Append it after the actual current item |
|
14298 that.currentItem.after(that.placeholder); |
|
14299 |
|
14300 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) |
|
14301 o.placeholder.update(that, that.placeholder); |
|
14302 |
|
14303 }, |
|
14304 |
|
14305 _createTrPlaceholder: function( sourceTr, targetTr ) { |
|
14306 var that = this; |
|
14307 |
|
14308 sourceTr.children().each(function() { |
|
14309 $( "<td> </td>", that.document[ 0 ] ) |
|
14310 .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) |
|
14311 .appendTo( targetTr ); |
|
14312 }); |
|
14313 }, |
|
14314 |
|
14315 _contactContainers: function(event) { |
|
14316 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis, |
|
14317 innermostContainer = null, |
|
14318 innermostIndex = null; |
|
14319 |
|
14320 // get innermost container that intersects with item |
|
14321 for (i = this.containers.length - 1; i >= 0; i--) { |
|
14322 |
|
14323 // never consider a container that's located within the item itself |
|
14324 if($.contains(this.currentItem[0], this.containers[i].element[0])) { |
|
14325 continue; |
|
14326 } |
|
14327 |
|
14328 if(this._intersectsWith(this.containers[i].containerCache)) { |
|
14329 |
|
14330 // if we've already found a container and it's more "inner" than this, then continue |
|
14331 if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) { |
|
14332 continue; |
|
14333 } |
|
14334 |
|
14335 innermostContainer = this.containers[i]; |
|
14336 innermostIndex = i; |
|
14337 |
|
14338 } else { |
|
14339 // container doesn't intersect. trigger "out" event if necessary |
|
14340 if(this.containers[i].containerCache.over) { |
|
14341 this.containers[i]._trigger("out", event, this._uiHash(this)); |
|
14342 this.containers[i].containerCache.over = 0; |
|
14343 } |
|
14344 } |
|
14345 |
|
14346 } |
|
14347 |
|
14348 // if no intersecting containers found, return |
|
14349 if(!innermostContainer) { |
|
14350 return; |
|
14351 } |
|
14352 |
|
14353 // move the item into the container if it's not there already |
|
14354 if(this.containers.length === 1) { |
|
14355 if (!this.containers[innermostIndex].containerCache.over) { |
|
14356 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); |
|
14357 this.containers[innermostIndex].containerCache.over = 1; |
|
14358 } |
|
14359 } else { |
|
14360 |
|
14361 //When entering a new container, we will find the item with the least distance and append our item near it |
|
14362 dist = 10000; |
|
14363 itemWithLeastDistance = null; |
|
14364 floating = innermostContainer.floating || this._isFloating(this.currentItem); |
|
14365 posProperty = floating ? "left" : "top"; |
|
14366 sizeProperty = floating ? "width" : "height"; |
|
14367 axis = floating ? "clientX" : "clientY"; |
|
14368 |
|
14369 for (j = this.items.length - 1; j >= 0; j--) { |
|
14370 if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) { |
|
14371 continue; |
|
14372 } |
|
14373 if(this.items[j].item[0] === this.currentItem[0]) { |
|
14374 continue; |
|
14375 } |
|
14376 |
|
14377 cur = this.items[j].item.offset()[posProperty]; |
|
14378 nearBottom = false; |
|
14379 if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) { |
|
14380 nearBottom = true; |
|
14381 } |
|
14382 |
|
14383 if ( Math.abs( event[ axis ] - cur ) < dist ) { |
|
14384 dist = Math.abs( event[ axis ] - cur ); |
|
14385 itemWithLeastDistance = this.items[ j ]; |
|
14386 this.direction = nearBottom ? "up": "down"; |
|
14387 } |
|
14388 } |
|
14389 |
|
14390 //Check if dropOnEmpty is enabled |
|
14391 if(!itemWithLeastDistance && !this.options.dropOnEmpty) { |
|
14392 return; |
|
14393 } |
|
14394 |
|
14395 if(this.currentContainer === this.containers[innermostIndex]) { |
|
14396 if ( !this.currentContainer.containerCache.over ) { |
|
14397 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() ); |
|
14398 this.currentContainer.containerCache.over = 1; |
|
14399 } |
|
14400 return; |
|
14401 } |
|
14402 |
|
14403 itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); |
|
14404 this._trigger("change", event, this._uiHash()); |
|
14405 this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); |
|
14406 this.currentContainer = this.containers[innermostIndex]; |
|
14407 |
|
14408 //Update the placeholder |
|
14409 this.options.placeholder.update(this.currentContainer, this.placeholder); |
|
14410 |
|
14411 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); |
|
14412 this.containers[innermostIndex].containerCache.over = 1; |
|
14413 } |
|
14414 |
|
14415 |
|
14416 }, |
|
14417 |
|
14418 _createHelper: function(event) { |
|
14419 |
|
14420 var o = this.options, |
|
14421 helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem); |
|
14422 |
|
14423 //Add the helper to the DOM if that didn't happen already |
|
14424 if(!helper.parents("body").length) { |
|
14425 $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); |
|
14426 } |
|
14427 |
|
14428 if(helper[0] === this.currentItem[0]) { |
|
14429 this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") }; |
|
14430 } |
|
14431 |
|
14432 if(!helper[0].style.width || o.forceHelperSize) { |
|
14433 helper.width(this.currentItem.width()); |
|
14434 } |
|
14435 if(!helper[0].style.height || o.forceHelperSize) { |
|
14436 helper.height(this.currentItem.height()); |
|
14437 } |
|
14438 |
|
14439 return helper; |
|
14440 |
|
14441 }, |
|
14442 |
|
14443 _adjustOffsetFromHelper: function(obj) { |
|
14444 if (typeof obj === "string") { |
|
14445 obj = obj.split(" "); |
|
14446 } |
|
14447 if ($.isArray(obj)) { |
|
14448 obj = {left: +obj[0], top: +obj[1] || 0}; |
|
14449 } |
|
14450 if ("left" in obj) { |
|
14451 this.offset.click.left = obj.left + this.margins.left; |
|
14452 } |
|
14453 if ("right" in obj) { |
|
14454 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
|
14455 } |
|
14456 if ("top" in obj) { |
|
14457 this.offset.click.top = obj.top + this.margins.top; |
|
14458 } |
|
14459 if ("bottom" in obj) { |
|
14460 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
|
14461 } |
|
14462 }, |
|
14463 |
|
14464 _getParentOffset: function() { |
|
14465 |
|
14466 |
|
14467 //Get the offsetParent and cache its position |
|
14468 this.offsetParent = this.helper.offsetParent(); |
|
14469 var po = this.offsetParent.offset(); |
|
14470 |
|
14471 // This is a special case where we need to modify a offset calculated on start, since the following happened: |
|
14472 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
|
14473 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
|
14474 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
|
14475 if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) { |
|
14476 po.left += this.scrollParent.scrollLeft(); |
|
14477 po.top += this.scrollParent.scrollTop(); |
|
14478 } |
|
14479 |
|
14480 // This needs to be actually done for all browsers, since pageX/pageY includes this information |
|
14481 // with an ugly IE fix |
|
14482 if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) { |
|
14483 po = { top: 0, left: 0 }; |
|
14484 } |
|
14485 |
|
14486 return { |
|
14487 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
|
14488 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
|
14489 }; |
|
14490 |
|
14491 }, |
|
14492 |
|
14493 _getRelativeOffset: function() { |
|
14494 |
|
14495 if(this.cssPosition === "relative") { |
|
14496 var p = this.currentItem.position(); |
|
14497 return { |
|
14498 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
|
14499 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() |
|
14500 }; |
|
14501 } else { |
|
14502 return { top: 0, left: 0 }; |
|
14503 } |
|
14504 |
|
14505 }, |
|
14506 |
|
14507 _cacheMargins: function() { |
|
14508 this.margins = { |
|
14509 left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), |
|
14510 top: (parseInt(this.currentItem.css("marginTop"),10) || 0) |
|
14511 }; |
|
14512 }, |
|
14513 |
|
14514 _cacheHelperProportions: function() { |
|
14515 this.helperProportions = { |
|
14516 width: this.helper.outerWidth(), |
|
14517 height: this.helper.outerHeight() |
|
14518 }; |
|
14519 }, |
|
14520 |
|
14521 _setContainment: function() { |
|
14522 |
|
14523 var ce, co, over, |
|
14524 o = this.options; |
|
14525 if(o.containment === "parent") { |
|
14526 o.containment = this.helper[0].parentNode; |
|
14527 } |
|
14528 if(o.containment === "document" || o.containment === "window") { |
|
14529 this.containment = [ |
|
14530 0 - this.offset.relative.left - this.offset.parent.left, |
|
14531 0 - this.offset.relative.top - this.offset.parent.top, |
|
14532 o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left, |
|
14533 (o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top |
|
14534 ]; |
|
14535 } |
|
14536 |
|
14537 if(!(/^(document|window|parent)$/).test(o.containment)) { |
|
14538 ce = $(o.containment)[0]; |
|
14539 co = $(o.containment).offset(); |
|
14540 over = ($(ce).css("overflow") !== "hidden"); |
|
14541 |
|
14542 this.containment = [ |
|
14543 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, |
|
14544 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, |
|
14545 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, |
|
14546 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top |
|
14547 ]; |
|
14548 } |
|
14549 |
|
14550 }, |
|
14551 |
|
14552 _convertPositionTo: function(d, pos) { |
|
14553 |
|
14554 if(!pos) { |
|
14555 pos = this.position; |
|
14556 } |
|
14557 var mod = d === "absolute" ? 1 : -1, |
|
14558 scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, |
|
14559 scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
14560 |
|
14561 return { |
|
14562 top: ( |
|
14563 pos.top + // The absolute mouse position |
|
14564 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent |
|
14565 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) |
|
14566 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) |
|
14567 ), |
|
14568 left: ( |
|
14569 pos.left + // The absolute mouse position |
|
14570 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent |
|
14571 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) |
|
14572 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) |
|
14573 ) |
|
14574 }; |
|
14575 |
|
14576 }, |
|
14577 |
|
14578 _generatePosition: function(event) { |
|
14579 |
|
14580 var top, left, |
|
14581 o = this.options, |
|
14582 pageX = event.pageX, |
|
14583 pageY = event.pageY, |
|
14584 scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
14585 |
|
14586 // This is another very weird special case that only happens for relative elements: |
|
14587 // 1. If the css position is relative |
|
14588 // 2. and the scroll parent is the document or similar to the offset parent |
|
14589 // we have to refresh the relative offset during the scroll so there are no jumps |
|
14590 if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) { |
|
14591 this.offset.relative = this._getRelativeOffset(); |
|
14592 } |
|
14593 |
|
14594 /* |
|
14595 * - Position constraining - |
|
14596 * Constrain the position to a mix of grid, containment. |
|
14597 */ |
|
14598 |
|
14599 if(this.originalPosition) { //If we are not dragging yet, we won't check for options |
|
14600 |
|
14601 if(this.containment) { |
|
14602 if(event.pageX - this.offset.click.left < this.containment[0]) { |
|
14603 pageX = this.containment[0] + this.offset.click.left; |
|
14604 } |
|
14605 if(event.pageY - this.offset.click.top < this.containment[1]) { |
|
14606 pageY = this.containment[1] + this.offset.click.top; |
|
14607 } |
|
14608 if(event.pageX - this.offset.click.left > this.containment[2]) { |
|
14609 pageX = this.containment[2] + this.offset.click.left; |
|
14610 } |
|
14611 if(event.pageY - this.offset.click.top > this.containment[3]) { |
|
14612 pageY = this.containment[3] + this.offset.click.top; |
|
14613 } |
|
14614 } |
|
14615 |
|
14616 if(o.grid) { |
|
14617 top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; |
|
14618 pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
14619 |
|
14620 left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; |
|
14621 pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; |
|
14622 } |
|
14623 |
|
14624 } |
|
14625 |
|
14626 return { |
|
14627 top: ( |
|
14628 pageY - // The absolute mouse position |
|
14629 this.offset.click.top - // Click offset (relative to the element) |
|
14630 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent |
|
14631 this.offset.parent.top + // The offsetParent's offset without borders (offset + border) |
|
14632 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) |
|
14633 ), |
|
14634 left: ( |
|
14635 pageX - // The absolute mouse position |
|
14636 this.offset.click.left - // Click offset (relative to the element) |
|
14637 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent |
|
14638 this.offset.parent.left + // The offsetParent's offset without borders (offset + border) |
|
14639 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) |
|
14640 ) |
|
14641 }; |
|
14642 |
|
14643 }, |
|
14644 |
|
14645 _rearrange: function(event, i, a, hardRefresh) { |
|
14646 |
|
14647 a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling)); |
|
14648 |
|
14649 //Various things done here to improve the performance: |
|
14650 // 1. we create a setTimeout, that calls refreshPositions |
|
14651 // 2. on the instance, we have a counter variable, that get's higher after every append |
|
14652 // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same |
|
14653 // 4. this lets only the last addition to the timeout stack through |
|
14654 this.counter = this.counter ? ++this.counter : 1; |
|
14655 var counter = this.counter; |
|
14656 |
|
14657 this._delay(function() { |
|
14658 if(counter === this.counter) { |
|
14659 this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove |
|
14660 } |
|
14661 }); |
|
14662 |
|
14663 }, |
|
14664 |
|
14665 _clear: function(event, noPropagation) { |
|
14666 |
|
14667 this.reverting = false; |
|
14668 // We delay all events that have to be triggered to after the point where the placeholder has been removed and |
|
14669 // everything else normalized again |
|
14670 var i, |
|
14671 delayedTriggers = []; |
|
14672 |
|
14673 // We first have to update the dom position of the actual currentItem |
|
14674 // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) |
|
14675 if(!this._noFinalSort && this.currentItem.parent().length) { |
|
14676 this.placeholder.before(this.currentItem); |
|
14677 } |
|
14678 this._noFinalSort = null; |
|
14679 |
|
14680 if(this.helper[0] === this.currentItem[0]) { |
|
14681 for(i in this._storedCSS) { |
|
14682 if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") { |
|
14683 this._storedCSS[i] = ""; |
|
14684 } |
|
14685 } |
|
14686 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); |
|
14687 } else { |
|
14688 this.currentItem.show(); |
|
14689 } |
|
14690 |
|
14691 if(this.fromOutside && !noPropagation) { |
|
14692 delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); }); |
|
14693 } |
|
14694 if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) { |
|
14695 delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed |
|
14696 } |
|
14697 |
|
14698 // Check if the items Container has Changed and trigger appropriate |
|
14699 // events. |
|
14700 if (this !== this.currentContainer) { |
|
14701 if(!noPropagation) { |
|
14702 delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); }); |
|
14703 delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); |
|
14704 delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); |
|
14705 } |
|
14706 } |
|
14707 |
|
14708 |
|
14709 //Post events to containers |
|
14710 function delayEvent( type, instance, container ) { |
|
14711 return function( event ) { |
|
14712 container._trigger( type, event, instance._uiHash( instance ) ); |
|
14713 }; |
|
14714 } |
|
14715 for (i = this.containers.length - 1; i >= 0; i--){ |
|
14716 if (!noPropagation) { |
|
14717 delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) ); |
|
14718 } |
|
14719 if(this.containers[i].containerCache.over) { |
|
14720 delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) ); |
|
14721 this.containers[i].containerCache.over = 0; |
|
14722 } |
|
14723 } |
|
14724 |
|
14725 //Do what was originally in plugins |
|
14726 if ( this.storedCursor ) { |
|
14727 this.document.find( "body" ).css( "cursor", this.storedCursor ); |
|
14728 this.storedStylesheet.remove(); |
|
14729 } |
|
14730 if(this._storedOpacity) { |
|
14731 this.helper.css("opacity", this._storedOpacity); |
|
14732 } |
|
14733 if(this._storedZIndex) { |
|
14734 this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex); |
|
14735 } |
|
14736 |
|
14737 this.dragging = false; |
|
14738 |
|
14739 if(!noPropagation) { |
|
14740 this._trigger("beforeStop", event, this._uiHash()); |
|
14741 } |
|
14742 |
|
14743 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
|
14744 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
|
14745 |
|
14746 if ( !this.cancelHelperRemoval ) { |
|
14747 if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { |
|
14748 this.helper.remove(); |
|
14749 } |
|
14750 this.helper = null; |
|
14751 } |
|
14752 |
|
14753 if(!noPropagation) { |
|
14754 for (i=0; i < delayedTriggers.length; i++) { |
|
14755 delayedTriggers[i].call(this, event); |
|
14756 } //Trigger all delayed events |
|
14757 this._trigger("stop", event, this._uiHash()); |
|
14758 } |
|
14759 |
|
14760 this.fromOutside = false; |
|
14761 return !this.cancelHelperRemoval; |
|
14762 |
|
14763 }, |
|
14764 |
|
14765 _trigger: function() { |
|
14766 if ($.Widget.prototype._trigger.apply(this, arguments) === false) { |
|
14767 this.cancel(); |
|
14768 } |
|
14769 }, |
|
14770 |
|
14771 _uiHash: function(_inst) { |
|
14772 var inst = _inst || this; |
|
14773 return { |
|
14774 helper: inst.helper, |
|
14775 placeholder: inst.placeholder || $([]), |
|
14776 position: inst.position, |
|
14777 originalPosition: inst.originalPosition, |
|
14778 offset: inst.positionAbs, |
|
14779 item: inst.currentItem, |
|
14780 sender: _inst ? _inst.element : null |
|
14781 }; |
|
14782 } |
|
14783 |
|
14784 }); |
|
14785 |
|
14786 |
|
14787 /*! |
|
14788 * jQuery UI Spinner 1.11.4 |
|
14789 * http://jqueryui.com |
|
14790 * |
|
14791 * Copyright jQuery Foundation and other contributors |
|
14792 * Released under the MIT license. |
|
14793 * http://jquery.org/license |
|
14794 * |
|
14795 * http://api.jqueryui.com/spinner/ |
|
14796 */ |
|
14797 |
|
14798 |
|
14799 function spinner_modifier( fn ) { |
13308 return function() { |
14800 return function() { |
13309 var previous = this.element.val(); |
14801 var previous = this.element.val(); |
13310 fn.apply( this, arguments ); |
14802 fn.apply( this, arguments ); |
13311 this._refresh(); |
14803 this._refresh(); |
13312 if ( previous !== this.element.val() ) { |
14804 if ( previous !== this.element.val() ) { |
13313 this._trigger( "change" ); |
14805 this._trigger( "change" ); |
13314 } |
14806 } |
13315 }; |
14807 }; |
13316 } |
14808 } |
13317 |
14809 |
13318 $.widget( "ui.spinner", { |
14810 var spinner = $.widget( "ui.spinner", { |
13319 version: "1.10.3", |
14811 version: "1.11.4", |
13320 defaultElement: "<input>", |
14812 defaultElement: "<input>", |
13321 widgetEventPrefix: "spin", |
14813 widgetEventPrefix: "spin", |
13322 options: { |
14814 options: { |
13323 culture: null, |
14815 culture: null, |
13324 icons: { |
14816 icons: { |