Changeset 10160
- Timestamp:
- 12/10/2008 12:05:41 AM (17 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/jquery/ui.sortable.js
r10019 r10160 1 /* 2 * jQuery UI Sortable 3 * 4 * Copyright (c) 2008 Paul Bakaus 5 * Dual licensed under the MIT (MIT-LICENSE.txt) 6 * and GPL (GPL-LICENSE.txt) licenses. 7 * 8 * http://docs.jquery.com/UI/Sortables 9 * 10 * Depends: 11 * ui.core.js 12 */ 13 (function($) { 14 15 function contains(a, b) { 16 var safari2 = $.browser.safari && $.browser.version < 522; 17 if (a.contains && !safari2) { 18 return a.contains(b); 19 } 20 if (a.compareDocumentPosition) 21 return !!(a.compareDocumentPosition(b) & 16); 22 while (b = b.parentNode) 23 if (b == a) return true; 24 return false; 25 }; 26 27 $.widget("ui.sortable", $.extend({}, $.ui.mouse, { 28 init: function() { 29 30 var o = this.options; 31 this.containerCache = {}; 32 this.element.addClass("ui-sortable"); 33 34 //Get the items 35 this.refresh(); 36 37 //Let's determine if the items are floating 38 this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false; 39 40 //Let's determine the parent's offset 41 if(!(/(relative|absolute|fixed)/).test(this.element.css('position'))) this.element.css('position', 'relative'); 42 this.offset = this.element.offset(); 43 44 //Initialize mouse events for interaction 45 this.mouseInit(); 46 47 }, 48 plugins: {}, 49 ui: function(inst) { 50 return { 51 helper: (inst || this)["helper"], 52 placeholder: (inst || this)["placeholder"] || $([]), 53 position: (inst || this)["position"], 54 absolutePosition: (inst || this)["positionAbs"], 55 options: this.options, 56 element: this.element, 57 item: (inst || this)["currentItem"], 58 sender: inst ? inst.element : null 59 }; 60 }, 61 propagate: function(n,e,inst, noPropagation) { 62 $.ui.plugin.call(this, n, [e, this.ui(inst)]); 63 if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]); 64 }, 65 serialize: function(o) { 66 67 var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself 68 var str = []; o = o || {}; 69 70 items.each(function() { 71 var res = ($(this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); 72 if(res) str.push((o.key || res[1])+'[]='+(o.key && o.expression ? res[1] : res[2])); 73 }); 74 75 return str.join('&'); 76 77 }, 78 toArray: function(attr) { 79 80 var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself 81 var ret = []; 82 83 items.each(function() { ret.push($(this).attr(attr || 'id')); }); 84 return ret; 85 86 }, 87 /* Be careful with the following core functions */ 88 intersectsWith: function(item) { 89 90 var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width, 91 y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height; 92 var l = item.left, r = l + item.width, 93 t = item.top, b = t + item.height; 94 95 if(this.options.tolerance == "pointer" || this.options.forcePointerForContainers || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) { 96 return (y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r); 97 } else { 98 99 return (l < x1 + (this.helperProportions.width / 2) // Right Half 100 && x2 - (this.helperProportions.width / 2) < r // Left Half 101 && t < y1 + (this.helperProportions.height / 2) // Bottom Half 102 && y2 - (this.helperProportions.height / 2) < b ); // Top Half 103 104 } 105 106 }, 107 intersectsWithEdge: function(item) { 108 var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width, 109 y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height; 110 var l = item.left, r = l + item.width, 111 t = item.top, b = t + item.height; 112 113 if(this.options.toleranceMove == "pointer" || (this.options.toleranceMove == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) { 114 115 if(!(y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r)) return false; 116 117 if(this.floating) { 118 if(x1 + this.offset.click.left > l && x1 + this.offset.click.left < l + item.width/2) return 2; 119 if(x1 + this.offset.click.left > l+item.width/2 && x1 + this.offset.click.left < r) return 1; 120 } else { 121 if(y1 + this.offset.click.top > t && y1 + this.offset.click.top < t + item.height/2) return 2; 122 if(y1 + this.offset.click.top > t+item.height/2 && y1 + this.offset.click.top < b) return 1; 123 } 124 125 } else { 126 127 if (!(l < x1 + (this.helperProportions.width / 2) // Right Half 128 && x2 - (this.helperProportions.width / 2) < r // Left Half 129 && t < y1 + (this.helperProportions.height / 2) // Bottom Half 130 && y2 - (this.helperProportions.height / 2) < b )) return false; // Top Half 131 132 if(this.floating) { 133 if(x2 > l && x1 < l) return 2; //Crosses left edge 134 if(x1 < r && x2 > r) return 1; //Crosses right edge 135 } else { 136 if(y2 > t && y1 < t) return 1; //Crosses top edge 137 if(y1 < b && y2 > b) return 2; //Crosses bottom edge 138 } 139 140 } 141 142 return false; 143 144 }, 145 refresh: function() { 146 this.refreshItems(); 147 this.refreshPositions(); 148 }, 149 refreshItems: function() { 150 151 this.items = []; 152 this.containers = [this]; 153 var items = this.items; 154 var self = this; 155 var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element), this]]; 156 157 if(this.options.connectWith) { 158 for (var i = this.options.connectWith.length - 1; i >= 0; i--){ 159 var cur = $(this.options.connectWith[i]); 160 for (var j = cur.length - 1; j >= 0; j--){ 161 var inst = $.data(cur[j], 'sortable'); 162 if(inst && !inst.options.disabled) { 163 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element), inst]); 164 this.containers.push(inst); 165 } 166 }; 167 }; 168 } 169 170 for (var i = queries.length - 1; i >= 0; i--){ 171 queries[i][0].each(function() { 172 $.data(this, 'sortable-item', queries[i][1]); // Data for target checking (mouse manager) 173 items.push({ 174 item: $(this), 175 instance: queries[i][1], 176 width: 0, height: 0, 177 left: 0, top: 0 178 }); 179 }); 180 }; 181 182 }, 183 refreshPositions: function(fast) { 184 185 //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change 186 if(this.offsetParent) { 187 var po = this.offsetParent.offset(); 188 this.offset.parent = { top: po.top + this.offsetParentBorders.top, left: po.left + this.offsetParentBorders.left }; 189 } 190 191 for (var i = this.items.length - 1; i >= 0; i--){ 192 193 //We ignore calculating positions of all connected containers when we're not over them 194 if(this.items[i].instance != this.currentContainer && this.currentContainer && this.items[i].item[0] != this.currentItem[0]) 195 continue; 196 197 var t = this.options.toleranceElement ? $(this.options.toleranceElement, this.items[i].item) : this.items[i].item; 198 199 if(!fast) { 200 this.items[i].width = t[0].offsetWidth; 201 this.items[i].height = t[0].offsetHeight; 202 } 203 204 var p = t.offset(); 205 this.items[i].left = p.left; 206 this.items[i].top = p.top; 207 208 }; 209 210 if(this.options.custom && this.options.custom.refreshContainers) { 211 this.options.custom.refreshContainers.call(this); 212 } else { 213 for (var i = this.containers.length - 1; i >= 0; i--){ 214 var p =this.containers[i].element.offset(); 215 this.containers[i].containerCache.left = p.left; 216 this.containers[i].containerCache.top = p.top; 217 this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); 218 this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); 219 }; 220 } 221 222 }, 223 destroy: function() { 224 this.element 225 .removeClass("ui-sortable ui-sortable-disabled") 226 .removeData("sortable") 227 .unbind(".sortable"); 228 this.mouseDestroy(); 229 230 for ( var i = this.items.length - 1; i >= 0; i-- ) 231 this.items[i].item.removeData("sortable-item"); 232 }, 233 createPlaceholder: function(that) { 234 235 var self = that || this, o = self.options; 236 237 if(o.placeholder.constructor == String) { 238 var className = o.placeholder; 239 o.placeholder = { 240 element: function() { 241 return $('<div></div>').addClass(className)[0]; 242 }, 243 update: function(i, p) { 244 p.css(i.offset()).css({ width: i.outerWidth(), height: i.outerHeight() }); 245 } 246 }; 247 } 248 249 self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem)).appendTo('body').css({ position: 'absolute' }); 250 o.placeholder.update.call(self.element, self.currentItem, self.placeholder); 251 }, 252 contactContainers: function(e) { 253 for (var i = this.containers.length - 1; i >= 0; i--){ 254 255 if(this.intersectsWith(this.containers[i].containerCache)) { 256 if(!this.containers[i].containerCache.over) { 257 258 259 if(this.currentContainer != this.containers[i]) { 260 261 //When entering a new container, we will find the item with the least distance and append our item near it 262 var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[i].floating ? 'left' : 'top']; 263 for (var j = this.items.length - 1; j >= 0; j--) { 264 if(!contains(this.containers[i].element[0], this.items[j].item[0])) continue; 265 var cur = this.items[j][this.containers[i].floating ? 'left' : 'top']; 266 if(Math.abs(cur - base) < dist) { 267 dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; 268 } 269 } 270 271 if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled 272 continue; 273 274 //We also need to exchange the placeholder 275 if(this.placeholder) this.placeholder.remove(); 276 if(this.containers[i].options.placeholder) { 277 this.containers[i].createPlaceholder(this); 278 } else { 279 this.placeholder = null;; 280 } 281 282 this.currentContainer = this.containers[i]; 283 itemWithLeastDistance ? this.rearrange(e, itemWithLeastDistance, null, true) : this.rearrange(e, null, this.containers[i].element, true); 284 this.propagate("change", e); //Call plugins and callbacks 285 this.containers[i].propagate("change", e, this); //Call plugins and callbacks 286 287 } 288 289 this.containers[i].propagate("over", e, this); 290 this.containers[i].containerCache.over = 1; 291 } 292 } else { 293 if(this.containers[i].containerCache.over) { 294 this.containers[i].propagate("out", e, this); 295 this.containers[i].containerCache.over = 0; 296 } 297 } 298 299 }; 300 }, 301 mouseCapture: function(e, overrideHandle) { 302 303 if(this.options.disabled || this.options.type == 'static') return false; 304 305 //We have to refresh the items data once first 306 this.refreshItems(); 307 308 //Find out if the clicked node (or one of its parents) is a actual item in this.items 309 var currentItem = null, self = this, nodes = $(e.target).parents().each(function() { 310 if($.data(this, 'sortable-item') == self) { 311 currentItem = $(this); 312 return false; 313 } 314 }); 315 if($.data(e.target, 'sortable-item') == self) currentItem = $(e.target); 316 317 if(!currentItem) return false; 318 if(this.options.handle && !overrideHandle) { 319 var validHandle = false; 320 321 $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == e.target) validHandle = true; }); 322 if(!validHandle) return false; 323 } 324 325 this.currentItem = currentItem; 326 return true; 327 328 }, 329 mouseStart: function(e, overrideHandle, noActivation) { 330 331 var o = this.options; 332 this.currentContainer = this; 333 334 //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture 335 this.refreshPositions(); 336 337 //Create and append the visible helper 338 this.helper = typeof o.helper == 'function' ? $(o.helper.apply(this.element[0], [e, this.currentItem])) : this.currentItem.clone(); 339 if (!this.helper.parents('body').length) $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(this.helper[0]); //Add the helper to the DOM if that didn't happen already 340 this.helper.css({ position: 'absolute', clear: 'both' }).addClass('ui-sortable-helper'); //Position it absolutely and add a helper class 341 342 /* 343 * - Position generation - 344 * This block generates everything position related - it's the core of draggables. 345 */ 346 347 this.margins = { //Cache the margins 348 left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), 349 top: (parseInt(this.currentItem.css("marginTop"),10) || 0) 350 }; 351 352 this.offset = this.currentItem.offset(); //The element's absolute position on the page 353 this.offset = { //Substract the margins from the element's absolute offset 354 top: this.offset.top - this.margins.top, 355 left: this.offset.left - this.margins.left 356 }; 357 358 this.offset.click = { //Where the click happened, relative to the element 359 left: e.pageX - this.offset.left, 360 top: e.pageY - this.offset.top 361 }; 362 363 this.offsetParent = this.helper.offsetParent(); //Get the offsetParent and cache its position 364 var po = this.offsetParent.offset(); 365 366 this.offsetParentBorders = { 367 top: (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), 368 left: (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) 369 }; 370 this.offset.parent = { //Store its position plus border 371 top: po.top + this.offsetParentBorders.top, 372 left: po.left + this.offsetParentBorders.left 373 }; 374 375 this.originalPosition = this.generatePosition(e); //Generate the original position 376 this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; //Cache the former DOM position 377 378 //If o.placeholder is used, create a new element at the given position with the class 379 this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size 380 if(o.placeholder) this.createPlaceholder(); 381 382 //Call plugins and callbacks 383 this.propagate("start", e); 384 this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size 385 386 if(o.cursorAt) { 387 if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left; 388 if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right; 389 if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top; 390 if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom; 391 } 392 393 /* 394 * - Position constraining - 395 * Here we prepare position constraining like grid and containment. 396 */ 397 398 if(o.containment) { 399 if(o.containment == 'parent') o.containment = this.helper[0].parentNode; 400 if(o.containment == 'document' || o.containment == 'window') this.containment = [ 401 0 - this.offset.parent.left, 402 0 - this.offset.parent.top, 403 $(o.containment == 'document' ? document : window).width() - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0), 404 ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0) 405 ]; 406 407 if(!(/^(document|window|parent)$/).test(o.containment)) { 408 var ce = $(o.containment)[0]; 409 var co = $(o.containment).offset(); 410 411 this.containment = [ 412 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left, 413 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top, 414 co.left+Math.max(ce.scrollWidth,ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0), 415 co.top+Math.max(ce.scrollHeight,ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0) 416 ]; 417 } 418 } 419 420 //Set the original element visibility to hidden to still fill out the white space 421 if(this.options.placeholder != 'clone') 422 this.currentItem.css('visibility', 'hidden'); 423 424 //Post 'activate' events to possible containers 425 if(!noActivation) { 426 for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i].propagate("activate", e, this); } 427 } 428 429 //Prepare possible droppables 430 if($.ui.ddmanager) $.ui.ddmanager.current = this; 431 if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e); 432 433 this.dragging = true; 434 435 this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position 436 return true; 437 438 439 }, 440 convertPositionTo: function(d, pos) { 441 if(!pos) pos = this.position; 442 var mod = d == "absolute" ? 1 : -1; 443 return { 444 top: ( 445 pos.top // the calculated relative position 446 + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) 447 - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) * mod // The offsetParent's scroll position 448 + this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods) 449 ), 450 left: ( 451 pos.left // the calculated relative position 452 + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) 453 - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position 454 + this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods) 455 ) 456 }; 457 }, 458 generatePosition: function(e) { 459 460 var o = this.options; 461 var position = { 462 top: ( 463 e.pageY // The absolute mouse position 464 - this.offset.click.top // Click offset (relative to the element) 465 - this.offset.parent.top // The offsetParent's offset without borders (offset + border) 466 + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed 467 ), 468 left: ( 469 e.pageX // The absolute mouse position 470 - this.offset.click.left // Click offset (relative to the element) 471 - this.offset.parent.left // The offsetParent's offset without borders (offset + border) 472 + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed 473 ) 474 }; 475 476 if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options 477 478 /* 479 * - Position constraining - 480 * Constrain the position to a mix of grid, containment. 481 */ 482 if(this.containment) { 483 if(position.left < this.containment[0]) position.left = this.containment[0]; 484 if(position.top < this.containment[1]) position.top = this.containment[1]; 485 if(position.left > this.containment[2]) position.left = this.containment[2]; 486 if(position.top > this.containment[3]) position.top = this.containment[3]; 487 } 488 489 if(o.grid) { 490 var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1]; 491 position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; 492 493 var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0]; 494 position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; 495 } 496 497 return position; 498 }, 499 mouseDrag: function(e) { 500 501 //Compute the helpers position 502 this.position = this.generatePosition(e); 503 this.positionAbs = this.convertPositionTo("absolute"); 504 505 //Call the internal plugins 506 $.ui.plugin.call(this, "sort", [e, this.ui()]); 507 508 //Regenerate the absolute position used for position checks 509 this.positionAbs = this.convertPositionTo("absolute"); 510 511 //Set the helper's position 512 this.helper[0].style.left = this.position.left+'px'; 513 this.helper[0].style.top = this.position.top+'px'; 514 515 //Rearrange 516 for (var i = this.items.length - 1; i >= 0; i--) { 517 var intersection = this.intersectsWithEdge(this.items[i]); 518 if(!intersection) continue; 519 520 if(this.items[i].item[0] != this.currentItem[0] //cannot intersect with itself 521 && this.currentItem[intersection == 1 ? "next" : "prev"]()[0] != this.items[i].item[0] //no useless actions that have been done before 522 && !contains(this.currentItem[0], this.items[i].item[0]) //no action if the item moved is the parent of the item checked 523 && (this.options.type == 'semi-dynamic' ? !contains(this.element[0], this.items[i].item[0]) : true) 524 ) { 525 526 this.direction = intersection == 1 ? "down" : "up"; 527 this.rearrange(e, this.items[i]); 528 this.propagate("change", e); //Call plugins and callbacks 529 break; 530 } 531 } 532 533 //Post events to containers 534 this.contactContainers(e); 535 536 //Interconnect with droppables 537 if($.ui.ddmanager) $.ui.ddmanager.drag(this, e); 538 539 //Call callbacks 540 this.element.triggerHandler("sort", [e, this.ui()], this.options["sort"]); 541 542 return false; 543 544 }, 545 rearrange: function(e, i, a, hardRefresh) { 546 a ? a[0].appendChild(this.currentItem[0]) : i.item[0].parentNode.insertBefore(this.currentItem[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextSibling)); 547 548 //Various things done here to improve the performance: 549 // 1. we create a setTimeout, that calls refreshPositions 550 // 2. on the instance, we have a counter variable, that get's higher after every append 551 // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same 552 // 4. this lets only the last addition to the timeout stack through 553 this.counter = this.counter ? ++this.counter : 1; 554 var self = this, counter = this.counter; 555 556 window.setTimeout(function() { 557 if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove 558 },0); 559 560 if(this.options.placeholder) 561 this.options.placeholder.update.call(this.element, this.currentItem, this.placeholder); 562 }, 563 mouseStop: function(e, noPropagation) { 564 565 //If we are using droppables, inform the manager about the drop 566 if ($.ui.ddmanager && !this.options.dropBehaviour) 567 $.ui.ddmanager.drop(this, e); 568 569 if(this.options.revert) { 570 var self = this; 571 var cur = self.currentItem.offset(); 572 573 //Also animate the placeholder if we have one 574 if(self.placeholder) self.placeholder.animate({ opacity: 'hide' }, (parseInt(this.options.revert, 10) || 500)-50); 575 576 $(this.helper).animate({ 577 left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft), 578 top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) 579 }, parseInt(this.options.revert, 10) || 500, function() { 580 self.clear(e); 581 }); 582 } else { 583 this.clear(e, noPropagation); 584 } 585 586 return false; 587 588 }, 589 clear: function(e, noPropagation) { 590 591 if(this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) this.propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed 592 if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element 593 this.propagate("remove", e, null, noPropagation); 594 for (var i = this.containers.length - 1; i >= 0; i--){ 595 if(contains(this.containers[i].element[0], this.currentItem[0])) { 596 this.containers[i].propagate("update", e, this, noPropagation); 597 this.containers[i].propagate("receive", e, this, noPropagation); 598 } 599 }; 600 }; 601 602 //Post events to containers 603 for (var i = this.containers.length - 1; i >= 0; i--){ 604 this.containers[i].propagate("deactivate", e, this, noPropagation); 605 if(this.containers[i].containerCache.over) { 606 this.containers[i].propagate("out", e, this); 607 this.containers[i].containerCache.over = 0; 608 } 609 } 610 611 this.dragging = false; 612 if(this.cancelHelperRemoval) { 613 this.propagate("stop", e, null, noPropagation); 614 return false; 615 } 616 617 $(this.currentItem).css('visibility', ''); 618 if(this.placeholder) this.placeholder.remove(); 619 this.helper.remove(); this.helper = null; 620 this.propagate("stop", e, null, noPropagation); 621 622 return true; 623 624 } 625 })); 626 627 $.extend($.ui.sortable, { 628 getter: "serialize toArray", 629 defaults: { 630 helper: "clone", 631 tolerance: "guess", 632 toleranceMove: "guess", 633 distance: 1, 634 delay: 0, 635 scroll: true, 636 scrollSensitivity: 20, 637 scrollSpeed: 20, 638 cancel: ":input", 639 items: '> *', 640 zIndex: 1000, 641 dropOnEmpty: true, 642 appendTo: "parent" 643 } 644 }); 645 646 /* 647 * Sortable Extensions 648 */ 649 650 $.ui.plugin.add("sortable", "cursor", { 651 start: function(e, ui) { 652 var t = $('body'); 653 if (t.css("cursor")) ui.options._cursor = t.css("cursor"); 654 t.css("cursor", ui.options.cursor); 655 }, 656 stop: function(e, ui) { 657 if (ui.options._cursor) $('body').css("cursor", ui.options._cursor); 658 } 659 }); 660 661 $.ui.plugin.add("sortable", "zIndex", { 662 start: function(e, ui) { 663 var t = ui.helper; 664 if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex"); 665 t.css('zIndex', ui.options.zIndex); 666 }, 667 stop: function(e, ui) { 668 if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex); 669 } 670 }); 671 672 $.ui.plugin.add("sortable", "opacity", { 673 start: function(e, ui) { 674 var t = ui.helper; 675 if(t.css("opacity")) ui.options._opacity = t.css("opacity"); 676 t.css('opacity', ui.options.opacity); 677 }, 678 stop: function(e, ui) { 679 if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity); 680 } 681 }); 682 683 $.ui.plugin.add("sortable", "scroll", { 684 start: function(e, ui) { 685 var o = ui.options; 686 var i = $(this).data("sortable"); 687 688 i.overflowY = function(el) { 689 do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode); 690 return $(document); 691 }(i.currentItem); 692 i.overflowX = function(el) { 693 do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode); 694 return $(document); 695 }(i.currentItem); 696 697 if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') i.overflowYOffset = i.overflowY.offset(); 698 if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') i.overflowXOffset = i.overflowX.offset(); 699 700 }, 701 sort: function(e, ui) { 702 703 var o = ui.options; 704 var i = $(this).data("sortable"); 705 706 if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') { 707 if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity) 708 i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed; 709 if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity) 710 i.overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed; 711 } else { 712 if(e.pageY - $(document).scrollTop() < o.scrollSensitivity) 713 $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); 714 if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity) 715 $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); 716 } 717 718 if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') { 719 if((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity) 720 i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed; 721 if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity) 722 i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed; 723 } else { 724 if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity) 725 $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); 726 if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity) 727 $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); 728 } 729 730 } 731 }); 732 733 $.ui.plugin.add("sortable", "axis", { 734 sort: function(e, ui) { 735 736 var i = $(this).data("sortable"); 737 738 if(ui.options.axis == "y") i.position.left = i.originalPosition.left; 739 if(ui.options.axis == "x") i.position.top = i.originalPosition.top; 740 741 } 742 }); 743 744 })(jQuery); 1 (function(B){function A(E,D){var C=B.browser.safari&&B.browser.version<522;if(E.contains&&!C){return E.contains(D)}if(E.compareDocumentPosition){return !!(E.compareDocumentPosition(D)&16)}while(D=D.parentNode){if(D==E){return true}}return false}B.widget("ui.sortable",B.extend({},B.ui.mouse,{init:function(){var C=this.options;this.containerCache={};this.element.addClass("ui-sortable");this.refresh();this.floating=this.items.length?(/left|right/).test(this.items[0].item.css("float")):false;if(!(/(relative|absolute|fixed)/).test(this.element.css("position"))){this.element.css("position","relative")}this.offset=this.element.offset();this.mouseInit()},plugins:{},ui:function(C){return{helper:(C||this)["helper"],placeholder:(C||this)["placeholder"]||B([]),position:(C||this)["position"],absolutePosition:(C||this)["positionAbs"],options:this.options,element:this.element,item:(C||this)["currentItem"],sender:C?C.element:null}},propagate:function(F,E,C,D){B.ui.plugin.call(this,F,[E,this.ui(C)]);if(!D){this.element.triggerHandler(F=="sort"?F:"sort"+F,[E,this.ui(C)],this.options[F])}},serialize:function(E){var C=(B.isFunction(this.options.items)?this.options.items.call(this.element):B(this.options.items,this.element)).not(".ui-sortable-helper");var D=[];E=E||{};C.each(function(){var F=(B(this).attr(E.attribute||"id")||"").match(E.expression||(/(.+)[-=_](.+)/));if(F){D.push((E.key||F[1])+"[]="+(E.key&&E.expression?F[1]:F[2]))}});return D.join("&")},toArray:function(C){var D=(B.isFunction(this.options.items)?this.options.items.call(this.element):B(this.options.items,this.element)).not(".ui-sortable-helper");var E=[];D.each(function(){E.push(B(this).attr(C||"id"))});return E},intersectsWith:function(J){var E=this.positionAbs.left,D=E+this.helperProportions.width,I=this.positionAbs.top,H=I+this.helperProportions.height;var F=J.left,C=F+J.width,K=J.top,G=K+J.height;if(this.options.tolerance=="pointer"||this.options.forcePointerForContainers||(this.options.tolerance=="guess"&&this.helperProportions[this.floating?"width":"height"]>J[this.floating?"width":"height"])){return(I+this.offset.click.top>K&&I+this.offset.click.top<G&&E+this.offset.click.left>F&&E+this.offset.click.left<C)}else{return(F<E+(this.helperProportions.width/2)&&D-(this.helperProportions.width/2)<C&&K<I+(this.helperProportions.height/2)&&H-(this.helperProportions.height/2)<G)}},intersectsWithEdge:function(J){var E=this.positionAbs.left,D=E+this.helperProportions.width,I=this.positionAbs.top,H=I+this.helperProportions.height;var F=J.left,C=F+J.width,K=J.top,G=K+J.height;if(this.options.toleranceMove=="pointer"||(this.options.toleranceMove=="guess"&&this.helperProportions[this.floating?"width":"height"]>J[this.floating?"width":"height"])){if(!(I+this.offset.click.top>K&&I+this.offset.click.top<G&&E+this.offset.click.left>F&&E+this.offset.click.left<C)){return false}if(this.floating){if(E+this.offset.click.left>F&&E+this.offset.click.left<F+J.width/2){return 2}if(E+this.offset.click.left>F+J.width/2&&E+this.offset.click.left<C){return 1}}else{if(I+this.offset.click.top>K&&I+this.offset.click.top<K+J.height/2){return 2}if(I+this.offset.click.top>K+J.height/2&&I+this.offset.click.top<G){return 1}}}else{if(!(F<E+(this.helperProportions.width/2)&&D-(this.helperProportions.width/2)<C&&K<I+(this.helperProportions.height/2)&&H-(this.helperProportions.height/2)<G)){return false}if(this.floating){if(D>F&&E<F){return 2}if(E<C&&D>C){return 1}}else{if(H>K&&I<K){return 1}if(I<G&&H>G){return 2}}}return false},refresh:function(){this.refreshItems();this.refreshPositions()},refreshItems:function(){this.items=[];this.containers=[this];var D=this.items;var C=this;var F=[[B.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):B(this.options.items,this.element),this]];if(this.options.connectWith){for(var G=this.options.connectWith.length-1;G>=0;G--){var I=B(this.options.connectWith[G]);for(var E=I.length-1;E>=0;E--){var H=B.data(I[E],"sortable");if(H&&!H.options.disabled){F.push([B.isFunction(H.options.items)?H.options.items.call(H.element):B(H.options.items,H.element),H]);this.containers.push(H)}}}}for(var G=F.length-1;G>=0;G--){F[G][0].each(function(){B.data(this,"sortable-item",F[G][1]);D.push({item:B(this),instance:F[G][1],width:0,height:0,left:0,top:0})})}},refreshPositions:function(D){if(this.offsetParent){var C=this.offsetParent.offset();this.offset.parent={top:C.top+this.offsetParentBorders.top,left:C.left+this.offsetParentBorders.left}}for(var F=this.items.length-1;F>=0;F--){if(this.items[F].instance!=this.currentContainer&&this.currentContainer&&this.items[F].item[0]!=this.currentItem[0]){continue}var E=this.options.toleranceElement?B(this.options.toleranceElement,this.items[F].item):this.items[F].item;if(!D){this.items[F].width=E[0].offsetWidth;this.items[F].height=E[0].offsetHeight}var G=E.offset();this.items[F].left=G.left;this.items[F].top=G.top}if(this.options.custom&&this.options.custom.refreshContainers){this.options.custom.refreshContainers.call(this)}else{for(var F=this.containers.length-1;F>=0;F--){var G=this.containers[F].element.offset();this.containers[F].containerCache.left=G.left;this.containers[F].containerCache.top=G.top;this.containers[F].containerCache.width=this.containers[F].element.outerWidth();this.containers[F].containerCache.height=this.containers[F].element.outerHeight()}}},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this.mouseDestroy();for(var C=this.items.length-1;C>=0;C--){this.items[C].item.removeData("sortable-item")}},createPlaceholder:function(E){var C=E||this,F=C.options;if(F.placeholder.constructor==String){var D=F.placeholder;F.placeholder={element:function(){return B("<div></div>").addClass(D)[0]},update:function(G,H){H.css(G.offset()).css({width:G.outerWidth(),height:G.outerHeight()})}}}C.placeholder=B(F.placeholder.element.call(C.element,C.currentItem)).appendTo("body").css({position:"absolute"});F.placeholder.update.call(C.element,C.currentItem,C.placeholder)},contactContainers:function(F){for(var D=this.containers.length-1;D>=0;D--){if(this.intersectsWith(this.containers[D].containerCache)){if(!this.containers[D].containerCache.over){if(this.currentContainer!=this.containers[D]){var I=10000;var H=null;var E=this.positionAbs[this.containers[D].floating?"left":"top"];for(var C=this.items.length-1;C>=0;C--){if(!A(this.containers[D].element[0],this.items[C].item[0])){continue}var G=this.items[C][this.containers[D].floating?"left":"top"];if(Math.abs(G-E)<I){I=Math.abs(G-E);H=this.items[C]}}if(!H&&!this.options.dropOnEmpty){continue}if(this.placeholder){this.placeholder.remove()}if(this.containers[D].options.placeholder){this.containers[D].createPlaceholder(this)}else{this.placeholder=null}this.currentContainer=this.containers[D];H?this.rearrange(F,H,null,true):this.rearrange(F,null,this.containers[D].element,true);this.propagate("change",F);this.containers[D].propagate("change",F,this)}this.containers[D].propagate("over",F,this);this.containers[D].containerCache.over=1}}else{if(this.containers[D].containerCache.over){this.containers[D].propagate("out",F,this);this.containers[D].containerCache.over=0}}}},mouseCapture:function(G,F){if(this.options.disabled||this.options.type=="static"){return false}this.refreshItems();var E=null,D=this,C=B(G.target).parents().each(function(){if(B.data(this,"sortable-item")==D){E=B(this);return false}});if(B.data(G.target,"sortable-item")==D){E=B(G.target)}if(!E){return false}if(this.options.handle&&!F){var H=false;B(this.options.handle,E).find("*").andSelf().each(function(){if(this==G.target){H=true}});if(!H){return false}}this.currentItem=E;return true},mouseStart:function(H,F,C){var J=this.options;this.currentContainer=this;this.refreshPositions();this.helper=typeof J.helper=="function"?B(J.helper.apply(this.element[0],[H,this.currentItem])):this.currentItem.clone();if(!this.helper.parents("body").length){B(J.appendTo!="parent"?J.appendTo:this.currentItem[0].parentNode)[0].appendChild(this.helper[0])}this.helper.css({position:"absolute",clear:"both"}).addClass("ui-sortable-helper");this.margins={left:(parseInt(this.currentItem.css("marginLeft"),10)||0),top:(parseInt(this.currentItem.css("marginTop"),10)||0)};this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.offset.click={left:H.pageX-this.offset.left,top:H.pageY-this.offset.top};this.offsetParent=this.helper.offsetParent();var D=this.offsetParent.offset();this.offsetParentBorders={top:(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};this.offset.parent={top:D.top+this.offsetParentBorders.top,left:D.left+this.offsetParentBorders.left};this.originalPosition=this.generatePosition(H);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if(J.placeholder){this.createPlaceholder()}this.propagate("start",H);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if(J.cursorAt){if(J.cursorAt.left!=undefined){this.offset.click.left=J.cursorAt.left}if(J.cursorAt.right!=undefined){this.offset.click.left=this.helperProportions.width-J.cursorAt.right}if(J.cursorAt.top!=undefined){this.offset.click.top=J.cursorAt.top}if(J.cursorAt.bottom!=undefined){this.offset.click.top=this.helperProportions.height-J.cursorAt.bottom}}if(J.containment){if(J.containment=="parent"){J.containment=this.helper[0].parentNode}if(J.containment=="document"||J.containment=="window"){this.containment=[0-this.offset.parent.left,0-this.offset.parent.top,B(J.containment=="document"?document:window).width()-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),(B(J.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)]}if(!(/^(document|window|parent)$/).test(J.containment)){var G=B(J.containment)[0];var I=B(J.containment).offset();this.containment=[I.left+(parseInt(B(G).css("borderLeftWidth"),10)||0)-this.offset.parent.left,I.top+(parseInt(B(G).css("borderTopWidth"),10)||0)-this.offset.parent.top,I.left+Math.max(G.scrollWidth,G.offsetWidth)-(parseInt(B(G).css("borderLeftWidth"),10)||0)-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.currentItem.css("marginRight"),10)||0),I.top+Math.max(G.scrollHeight,G.offsetHeight)-(parseInt(B(G).css("borderTopWidth"),10)||0)-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.currentItem.css("marginBottom"),10)||0)]}}if(this.options.placeholder!="clone"){this.currentItem.css("visibility","hidden")}if(!C){for(var E=this.containers.length-1;E>=0;E--){this.containers[E].propagate("activate",H,this)}}if(B.ui.ddmanager){B.ui.ddmanager.current=this}if(B.ui.ddmanager&&!J.dropBehaviour){B.ui.ddmanager.prepareOffsets(this,H)}this.dragging=true;this.mouseDrag(H);return true},convertPositionTo:function(D,E){if(!E){E=this.position}var C=D=="absolute"?1:-1;return{top:(E.top+this.offset.parent.top*C-(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)*C+this.margins.top*C),left:(E.left+this.offset.parent.left*C-(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft)*C+this.margins.left*C)}},generatePosition:function(F){var G=this.options;var C={top:(F.pageY-this.offset.click.top-this.offset.parent.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)),left:(F.pageX-this.offset.click.left-this.offset.parent.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft))};if(!this.originalPosition){return C}if(this.containment){if(C.left<this.containment[0]){C.left=this.containment[0]}if(C.top<this.containment[1]){C.top=this.containment[1]}if(C.left>this.containment[2]){C.left=this.containment[2]}if(C.top>this.containment[3]){C.top=this.containment[3]}}if(G.grid){var E=this.originalPosition.top+Math.round((C.top-this.originalPosition.top)/G.grid[1])*G.grid[1];C.top=this.containment?(!(E<this.containment[1]||E>this.containment[3])?E:(!(E<this.containment[1])?E-G.grid[1]:E+G.grid[1])):E;var D=this.originalPosition.left+Math.round((C.left-this.originalPosition.left)/G.grid[0])*G.grid[0];C.left=this.containment?(!(D<this.containment[0]||D>this.containment[2])?D:(!(D<this.containment[0])?D-G.grid[0]:D+G.grid[0])):D}return C},mouseDrag:function(D){this.position=this.generatePosition(D);this.positionAbs=this.convertPositionTo("absolute");B.ui.plugin.call(this,"sort",[D,this.ui()]);this.positionAbs=this.convertPositionTo("absolute");this.helper[0].style.left=this.position.left+"px";this.helper[0].style.top=this.position.top+"px";for(var C=this.items.length-1;C>=0;C--){var E=this.intersectsWithEdge(this.items[C]);if(!E){continue}if(this.items[C].item[0]!=this.currentItem[0]&&this.currentItem[E==1?"next":"prev"]()[0]!=this.items[C].item[0]&&!A(this.currentItem[0],this.items[C].item[0])&&(this.options.type=="semi-dynamic"?!A(this.element[0],this.items[C].item[0]):true)){this.direction=E==1?"down":"up";this.rearrange(D,this.items[C]);this.propagate("change",D);break}}this.contactContainers(D);if(B.ui.ddmanager){B.ui.ddmanager.drag(this,D)}this.element.triggerHandler("sort",[D,this.ui()],this.options["sort"]);return false},rearrange:function(H,G,D,F){D?D[0].appendChild(this.currentItem[0]):G.item[0].parentNode.insertBefore(this.currentItem[0],(this.direction=="down"?G.item[0]:G.item[0].nextSibling));this.counter=this.counter?++this.counter:1;var E=this,C=this.counter;window.setTimeout(function(){if(C==E.counter){E.refreshPositions(!F)}},0);if(this.options.placeholder){this.options.placeholder.update.call(this.element,this.currentItem,this.placeholder)}},mouseStop:function(E,D){if(B.ui.ddmanager&&!this.options.dropBehaviour){B.ui.ddmanager.drop(this,E)}if(this.options.revert){var C=this;var F=C.currentItem.offset();if(C.placeholder){C.placeholder.animate({opacity:"hide"},(parseInt(this.options.revert,10)||500)-50)}B(this.helper).animate({left:F.left-this.offset.parent.left-C.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:F.top-this.offset.parent.top-C.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){C.clear(E)})}else{this.clear(E,D)}return false},clear:function(E,D){if(this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0]){this.propagate("update",E,null,D)}if(!A(this.element[0],this.currentItem[0])){this.propagate("remove",E,null,D);for(var C=this.containers.length-1;C>=0;C--){if(A(this.containers[C].element[0],this.currentItem[0])){this.containers[C].propagate("update",E,this,D);this.containers[C].propagate("receive",E,this,D)}}}for(var C=this.containers.length-1;C>=0;C--){this.containers[C].propagate("deactivate",E,this,D);if(this.containers[C].containerCache.over){this.containers[C].propagate("out",E,this);this.containers[C].containerCache.over=0}}this.dragging=false;if(this.cancelHelperRemoval){this.propagate("stop",E,null,D);return false}B(this.currentItem).css("visibility","");if(this.placeholder){this.placeholder.remove()}this.helper.remove();this.helper=null;this.propagate("stop",E,null,D);return true}}));B.extend(B.ui.sortable,{getter:"serialize toArray",defaults:{helper:"clone",tolerance:"guess",toleranceMove:"guess",distance:1,delay:0,scroll:true,scrollSensitivity:20,scrollSpeed:20,cancel:":input",items:"> *",zIndex:1000,dropOnEmpty:true,appendTo:"parent"}});B.ui.plugin.add("sortable","cursor",{start:function(E,D){var C=B("body");if(C.css("cursor")){D.options._cursor=C.css("cursor")}C.css("cursor",D.options.cursor)},stop:function(D,C){if(C.options._cursor){B("body").css("cursor",C.options._cursor)}}});B.ui.plugin.add("sortable","zIndex",{start:function(E,D){var C=D.helper;if(C.css("zIndex")){D.options._zIndex=C.css("zIndex")}C.css("zIndex",D.options.zIndex)},stop:function(D,C){if(C.options._zIndex){B(C.helper).css("zIndex",C.options._zIndex)}}});B.ui.plugin.add("sortable","opacity",{start:function(E,D){var C=D.helper;if(C.css("opacity")){D.options._opacity=C.css("opacity")}C.css("opacity",D.options.opacity)},stop:function(D,C){if(C.options._opacity){B(C.helper).css("opacity",C.options._opacity)}}});B.ui.plugin.add("sortable","scroll",{start:function(E,D){var F=D.options;var C=B(this).data("sortable");C.overflowY=function(G){do{if(/auto|scroll/.test(G.css("overflow"))||(/auto|scroll/).test(G.css("overflow-y"))){return G}G=G.parent()}while(G[0].parentNode);return B(document)}(C.currentItem);C.overflowX=function(G){do{if(/auto|scroll/.test(G.css("overflow"))||(/auto|scroll/).test(G.css("overflow-x"))){return G}G=G.parent()}while(G[0].parentNode);return B(document)}(C.currentItem);if(C.overflowY[0]!=document&&C.overflowY[0].tagName!="HTML"){C.overflowYOffset=C.overflowY.offset()}if(C.overflowX[0]!=document&&C.overflowX[0].tagName!="HTML"){C.overflowXOffset=C.overflowX.offset()}},sort:function(E,D){var F=D.options;var C=B(this).data("sortable");if(C.overflowY[0]!=document&&C.overflowY[0].tagName!="HTML"){if((C.overflowYOffset.top+C.overflowY[0].offsetHeight)-E.pageY<F.scrollSensitivity){C.overflowY[0].scrollTop=C.overflowY[0].scrollTop+F.scrollSpeed}if(E.pageY-C.overflowYOffset.top<F.scrollSensitivity){C.overflowY[0].scrollTop=C.overflowY[0].scrollTop-F.scrollSpeed}}else{if(E.pageY-B(document).scrollTop()<F.scrollSensitivity){B(document).scrollTop(B(document).scrollTop()-F.scrollSpeed)}if(B(window).height()-(E.pageY-B(document).scrollTop())<F.scrollSensitivity){B(document).scrollTop(B(document).scrollTop()+F.scrollSpeed)}}if(C.overflowX[0]!=document&&C.overflowX[0].tagName!="HTML"){if((C.overflowXOffset.left+C.overflowX[0].offsetWidth)-E.pageX<F.scrollSensitivity){C.overflowX[0].scrollLeft=C.overflowX[0].scrollLeft+F.scrollSpeed}if(E.pageX-C.overflowXOffset.left<F.scrollSensitivity){C.overflowX[0].scrollLeft=C.overflowX[0].scrollLeft-F.scrollSpeed}}else{if(E.pageX-B(document).scrollLeft()<F.scrollSensitivity){B(document).scrollLeft(B(document).scrollLeft()-F.scrollSpeed)}if(B(window).width()-(E.pageX-B(document).scrollLeft())<F.scrollSensitivity){B(document).scrollLeft(B(document).scrollLeft()+F.scrollSpeed)}}}});B.ui.plugin.add("sortable","axis",{sort:function(E,D){var C=B(this).data("sortable");if(D.options.axis=="y"){C.position.left=C.originalPosition.left}if(D.options.axis=="x"){C.position.top=C.originalPosition.top}}})})(jQuery) -
trunk/wp-includes/script-loader.php
r10158 r10160 136 136 $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.5.2' ); 137 137 $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core'), '1.5.2' ); 138 $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core'), '1.5.2 b' );138 $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core'), '1.5.2c' ); 139 139 $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui.draggable.js', array('jquery-ui-core'), '1.5.2' ); 140 140 $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' );
Note: See TracChangeset
for help on using the changeset viewer.