Changeset 1648:2eee4ee2798e
- Timestamp:
- 08/25/13 20:39:43 (10 years ago)
- Branch:
- Ticket #1604
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/js/jquery/jquery-ui.custom.js
r1048 r1648 1 /*! jQuery UI - v1. 9.2 - 2012-11-291 /*! jQuery UI - v1.10.3 - 2013-08-23 2 2 * http://jqueryui.com 3 * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui. sortable.js, jquery.ui.accordion.js4 * Copyright (c) 2012jQuery Foundation and other contributors Licensed MIT */3 * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.sortable.js, jquery.ui.accordion.js 4 * Copyright 2013 jQuery Foundation and other contributors Licensed MIT */ 5 5 6 6 (function( $, undefined ) { … … 9 9 runiqueId = /^ui-id-\d+$/; 10 10 11 // prevent duplicate loading 12 // this is only a problem because we proxy existing functions 13 // and we don't want to double proxy them 11 // $.ui might exist from components with no dependencies, e.g., $.ui.position 14 12 $.ui = $.ui || {}; 15 if ( $.ui.version ) {16 return;17 }18 13 19 14 $.extend( $.ui, { 20 version: "1. 9.2",15 version: "1.10.3", 21 16 22 17 keyCode: { … … 48 43 // plugins 49 44 $.fn.extend({ 50 _focus: $.fn.focus, 51 focus: function( delay, fn ) { 52 return typeof delay === "number" ? 53 this.each(function() { 54 var elem = this; 55 setTimeout(function() { 56 $( elem ).focus(); 57 if ( fn ) { 58 fn.call( elem ); 59 } 60 }, delay ); 61 }) : 62 this._focus.apply( this, arguments ); 63 }, 45 focus: (function( orig ) { 46 return function( delay, fn ) { 47 return typeof delay === "number" ? 48 this.each(function() { 49 var elem = this; 50 setTimeout(function() { 51 $( elem ).focus(); 52 if ( fn ) { 53 fn.call( elem ); 54 } 55 }, delay ); 56 }) : 57 orig.apply( this, arguments ); 58 }; 59 })( $.fn.focus ), 64 60 65 61 scrollParent: function() { 66 62 var scrollParent; 67 if (($.ui.ie && (/(static|relative)/).test(this.css( 'position'))) || (/absolute/).test(this.css('position'))) {63 if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) { 68 64 scrollParent = this.parents().filter(function() { 69 return (/(relative|absolute|fixed)/).test($.css(this, 'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));65 return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x")); 70 66 }).eq(0); 71 67 } else { 72 68 scrollParent = this.parents().filter(function() { 73 return (/(auto|scroll)/).test($.css(this, 'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));69 return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x")); 74 70 }).eq(0); 75 71 } 76 72 77 return (/fixed/).test(this.css( 'position')) || !scrollParent.length ? $(document) : scrollParent;73 return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent; 78 74 }, 79 75 … … 148 144 function visible( element ) { 149 145 return $.expr.filters.visible( element ) && 150 !$( element ).parents().a ndSelf().filter(function() {146 !$( element ).parents().addBack().filter(function() { 151 147 return $.css( this, "visibility" ) === "hidden"; 152 148 }).length; … … 176 172 }); 177 173 178 // support179 $(function() {180 var body = document.body,181 div = body.appendChild( div = document.createElement( "div" ) );182 183 // access offsetHeight before setting the style to prevent a layout bug184 // in IE 9 which causes the element to continue to take up space even185 // after it is removed from the DOM (#8026)186 div.offsetHeight;187 188 $.extend( div.style, {189 minHeight: "100px",190 height: "auto",191 padding: 0,192 borderWidth: 0193 });194 195 $.support.minHeight = div.offsetHeight === 100;196 $.support.selectstart = "onselectstart" in div;197 198 // set display to none to avoid a layout bug in IE199 // http://dev.jquery.com/ticket/4014200 body.removeChild( div ).style.display = "none";201 });202 203 174 // support: jQuery <1.8 204 175 if ( !$( "<a>" ).outerWidth( 1 ).jquery ) { … … 248 219 } 249 220 221 // support: jQuery <1.8 222 if ( !$.fn.addBack ) { 223 $.fn.addBack = function( selector ) { 224 return this.add( selector == null ? 225 this.prevObject : this.prevObject.filter( selector ) 226 ); 227 }; 228 } 229 250 230 // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413) 251 231 if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { … … 266 246 267 247 // deprecated 268 269 (function() { 270 var uaMatch = /msie ([\w.]+)/.exec( navigator.userAgent.toLowerCase() ) || []; 271 $.ui.ie = uaMatch.length ? true : false; 272 $.ui.ie6 = parseFloat( uaMatch[ 1 ], 10 ) === 6; 273 })(); 274 248 $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); 249 250 $.support.selectstart = "onselectstart" in document.createElement( "div" ); 275 251 $.fn.extend({ 276 252 disableSelection: function() { … … 287 263 288 264 $.extend( $.ui, { 289 // $.ui.plugin is deprecated. Use the proxy patterninstead.265 // $.ui.plugin is deprecated. Use $.widget() extensions instead. 290 266 plugin: { 291 267 add: function( module, option, set ) { … … 312 288 }, 313 289 314 contains: $.contains,315 316 290 // only used by resizable 317 291 hasScroll: function( el, a ) { … … 336 310 el[ scroll ] = 0; 337 311 return has; 338 },339 340 // these are odd functions, fix the API or move into individual plugins341 isOverAxis: function( x, reference, size ) {342 //Determines when x coordinate is over "b" element axis343 return ( x > reference ) && ( x < ( reference + size ) );344 },345 isOver: function( y, x, top, left, height, width ) {346 //Determines when x, y coordinates is over "b" element347 return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );348 312 } 349 313 }); … … 367 331 $.widget = function( name, base, prototype ) { 368 332 var fullName, existingConstructor, constructor, basePrototype, 333 // proxiedPrototype allows the provided prototype to remain unmodified 334 // so that it can be used as a mixin for multiple widgets (#8876) 335 proxiedPrototype = {}, 369 336 namespace = name.split( "." )[ 0 ]; 370 337 … … 413 380 basePrototype.options = $.widget.extend( {}, basePrototype.options ); 414 381 $.each( prototype, function( prop, value ) { 415 if ( $.isFunction( value ) ) { 416 prototype[ prop ] = (function() { 417 var _super = function() { 418 return base.prototype[ prop ].apply( this, arguments ); 419 }, 420 _superApply = function( args ) { 421 return base.prototype[ prop ].apply( this, args ); 422 }; 423 return function() { 424 var __super = this._super, 425 __superApply = this._superApply, 426 returnValue; 427 428 this._super = _super; 429 this._superApply = _superApply; 430 431 returnValue = value.apply( this, arguments ); 432 433 this._super = __super; 434 this._superApply = __superApply; 435 436 return returnValue; 382 if ( !$.isFunction( value ) ) { 383 proxiedPrototype[ prop ] = value; 384 return; 385 } 386 proxiedPrototype[ prop ] = (function() { 387 var _super = function() { 388 return base.prototype[ prop ].apply( this, arguments ); 389 }, 390 _superApply = function( args ) { 391 return base.prototype[ prop ].apply( this, args ); 437 392 }; 438 })(); 439 } 393 return function() { 394 var __super = this._super, 395 __superApply = this._superApply, 396 returnValue; 397 398 this._super = _super; 399 this._superApply = _superApply; 400 401 returnValue = value.apply( this, arguments ); 402 403 this._super = __super; 404 this._superApply = __superApply; 405 406 return returnValue; 407 }; 408 })(); 440 409 }); 441 410 constructor.prototype = $.widget.extend( basePrototype, { … … 444 413 // don't prefix for widgets that aren't DOM-based 445 414 widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name 446 }, pro totype, {415 }, proxiedPrototype, { 447 416 constructor: constructor, 448 417 namespace: namespace, 449 418 widgetName: name, 450 // TODO remove widgetBaseClass, see #8155451 widgetBaseClass: fullName,452 419 widgetFullName: fullName 453 420 }); … … 575 542 576 543 if ( element !== this ) { 577 // 1.9 BC for #7810578 // TODO remove dual storage579 $.data( element, this.widgetName, this );580 544 $.data( element, this.widgetFullName, this ); 581 545 this._on( true, this.element, { … … 844 808 element.delay( options.delay ); 845 809 } 846 if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] )) {810 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { 847 811 element[ method ]( options ); 848 812 } else if ( effectName !== method && element[ effectName ] ) { … … 860 824 }); 861 825 862 // DEPRECATED863 if ( $.uiBackCompat !== false ) {864 $.Widget.prototype._getCreateOptions = function() {865 return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];866 };867 }868 869 826 })( jQuery ); 870 827 (function( $, undefined ) { 871 828 872 829 var mouseHandled = false; 873 $( document ).mouseup( function( e) {830 $( document ).mouseup( function() { 874 831 mouseHandled = false; 875 832 }); 876 833 877 834 $.widget("ui.mouse", { 878 version: "1. 9.2",835 version: "1.10.3", 879 836 options: { 880 cancel: 'input,textarea,button,select,option',837 cancel: "input,textarea,button,select,option", 881 838 distance: 1, 882 839 delay: 0 … … 886 843 887 844 this.element 888 .bind( 'mousedown.'+this.widgetName, function(event) {845 .bind("mousedown."+this.widgetName, function(event) { 889 846 return that._mouseDown(event); 890 847 }) 891 .bind( 'click.'+this.widgetName, function(event) {892 if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {893 $.removeData(event.target, that.widgetName + '.preventClickEvent');848 .bind("click."+this.widgetName, function(event) { 849 if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) { 850 $.removeData(event.target, that.widgetName + ".preventClickEvent"); 894 851 event.stopImmediatePropagation(); 895 852 return false; … … 903 860 // other instances of mouse 904 861 _mouseDestroy: function() { 905 this.element.unbind( '.'+this.widgetName);862 this.element.unbind("."+this.widgetName); 906 863 if ( this._mouseMoveDelegate ) { 907 864 $(document) 908 .unbind( 'mousemove.'+this.widgetName, this._mouseMoveDelegate)909 .unbind( 'mouseup.'+this.widgetName, this._mouseUpDelegate);865 .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate) 866 .unbind("mouseup."+this.widgetName, this._mouseUpDelegate); 910 867 } 911 868 }, … … 945 902 946 903 // Click event may never have fired (Gecko & Opera) 947 if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {948 $.removeData(event.target, this.widgetName + '.preventClickEvent');904 if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) { 905 $.removeData(event.target, this.widgetName + ".preventClickEvent"); 949 906 } 950 907 … … 957 914 }; 958 915 $(document) 959 .bind( 'mousemove.'+this.widgetName, this._mouseMoveDelegate)960 .bind( 'mouseup.'+this.widgetName, this._mouseUpDelegate);916 .bind("mousemove."+this.widgetName, this._mouseMoveDelegate) 917 .bind("mouseup."+this.widgetName, this._mouseUpDelegate); 961 918 962 919 event.preventDefault(); … … 968 925 _mouseMove: function(event) { 969 926 // IE mouseup check - mouseup happened when mouse was out of window 970 if ($.ui.ie && !(document.documentMode >= 9) && !event.button) {927 if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) { 971 928 return this._mouseUp(event); 972 929 } … … 988 945 _mouseUp: function(event) { 989 946 $(document) 990 .unbind( 'mousemove.'+this.widgetName, this._mouseMoveDelegate)991 .unbind( 'mouseup.'+this.widgetName, this._mouseUpDelegate);947 .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate) 948 .unbind("mouseup."+this.widgetName, this._mouseUpDelegate); 992 949 993 950 if (this._mouseStarted) { … … 995 952 996 953 if (event.target === this._mouseDownEvent.target) { 997 $.data(event.target, this.widgetName + '.preventClickEvent', true);954 $.data(event.target, this.widgetName + ".preventClickEvent", true); 998 955 } 999 956 … … 1012 969 }, 1013 970 1014 _mouseDelayMet: function( event) {971 _mouseDelayMet: function(/* event */) { 1015 972 return this.mouseDelayMet; 1016 973 }, 1017 974 1018 975 // These are placeholder methods, to be overriden by extending plugin 1019 _mouseStart: function( event) {},1020 _mouseDrag: function( event) {},1021 _mouseStop: function( event) {},1022 _mouseCapture: function( event) { return true; }976 _mouseStart: function(/* event */) {}, 977 _mouseDrag: function(/* event */) {}, 978 _mouseStop: function(/* event */) {}, 979 _mouseCapture: function(/* event */) { return true; } 1023 980 }); 1024 981 … … 1026 983 (function( $, undefined ) { 1027 984 985 $.widget("ui.draggable", $.ui.mouse, { 986 version: "1.10.3", 987 widgetEventPrefix: "drag", 988 options: { 989 addClasses: true, 990 appendTo: "parent", 991 axis: false, 992 connectToSortable: false, 993 containment: false, 994 cursor: "auto", 995 cursorAt: false, 996 grid: false, 997 handle: false, 998 helper: "original", 999 iframeFix: false, 1000 opacity: false, 1001 refreshPositions: false, 1002 revert: false, 1003 revertDuration: 500, 1004 scope: "default", 1005 scroll: true, 1006 scrollSensitivity: 20, 1007 scrollSpeed: 20, 1008 snap: false, 1009 snapMode: "both", 1010 snapTolerance: 20, 1011 stack: false, 1012 zIndex: false, 1013 1014 // callbacks 1015 drag: null, 1016 start: null, 1017 stop: null 1018 }, 1019 _create: function() { 1020 1021 if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) { 1022 this.element[0].style.position = "relative"; 1023 } 1024 if (this.options.addClasses){ 1025 this.element.addClass("ui-draggable"); 1026 } 1027 if (this.options.disabled){ 1028 this.element.addClass("ui-draggable-disabled"); 1029 } 1030 1031 this._mouseInit(); 1032 1033 }, 1034 1035 _destroy: function() { 1036 this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ); 1037 this._mouseDestroy(); 1038 }, 1039 1040 _mouseCapture: function(event) { 1041 1042 var o = this.options; 1043 1044 // among others, prevent a drag on a resizable-handle 1045 if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) { 1046 return false; 1047 } 1048 1049 //Quit if we're not on a valid handle 1050 this.handle = this._getHandle(event); 1051 if (!this.handle) { 1052 return false; 1053 } 1054 1055 $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { 1056 $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>") 1057 .css({ 1058 width: this.offsetWidth+"px", height: this.offsetHeight+"px", 1059 position: "absolute", opacity: "0.001", zIndex: 1000 1060 }) 1061 .css($(this).offset()) 1062 .appendTo("body"); 1063 }); 1064 1065 return true; 1066 1067 }, 1068 1069 _mouseStart: function(event) { 1070 1071 var o = this.options; 1072 1073 //Create and append the visible helper 1074 this.helper = this._createHelper(event); 1075 1076 this.helper.addClass("ui-draggable-dragging"); 1077 1078 //Cache the helper size 1079 this._cacheHelperProportions(); 1080 1081 //If ddmanager is used for droppables, set the global draggable 1082 if($.ui.ddmanager) { 1083 $.ui.ddmanager.current = this; 1084 } 1085 1086 /* 1087 * - Position generation - 1088 * This block generates everything position related - it's the core of draggables. 1089 */ 1090 1091 //Cache the margins of the original element 1092 this._cacheMargins(); 1093 1094 //Store the helper's css position 1095 this.cssPosition = this.helper.css( "position" ); 1096 this.scrollParent = this.helper.scrollParent(); 1097 this.offsetParent = this.helper.offsetParent(); 1098 this.offsetParentCssPosition = this.offsetParent.css( "position" ); 1099 1100 //The element's absolute position on the page minus margins 1101 this.offset = this.positionAbs = this.element.offset(); 1102 this.offset = { 1103 top: this.offset.top - this.margins.top, 1104 left: this.offset.left - this.margins.left 1105 }; 1106 1107 //Reset scroll cache 1108 this.offset.scroll = false; 1109 1110 $.extend(this.offset, { 1111 click: { //Where the click happened, relative to the element 1112 left: event.pageX - this.offset.left, 1113 top: event.pageY - this.offset.top 1114 }, 1115 parent: this._getParentOffset(), 1116 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper 1117 }); 1118 1119 //Generate the original position 1120 this.originalPosition = this.position = this._generatePosition(event); 1121 this.originalPageX = event.pageX; 1122 this.originalPageY = event.pageY; 1123 1124 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied 1125 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); 1126 1127 //Set a containment if given in the options 1128 this._setContainment(); 1129 1130 //Trigger event + callbacks 1131 if(this._trigger("start", event) === false) { 1132 this._clear(); 1133 return false; 1134 } 1135 1136 //Recache the helper size 1137 this._cacheHelperProportions(); 1138 1139 //Prepare the droppable offsets 1140 if ($.ui.ddmanager && !o.dropBehaviour) { 1141 $.ui.ddmanager.prepareOffsets(this, event); 1142 } 1143 1144 1145 this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position 1146 1147 //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) 1148 if ( $.ui.ddmanager ) { 1149 $.ui.ddmanager.dragStart(this, event); 1150 } 1151 1152 return true; 1153 }, 1154 1155 _mouseDrag: function(event, noPropagation) { 1156 // reset any necessary cached properties (see #5009) 1157 if ( this.offsetParentCssPosition === "fixed" ) { 1158 this.offset.parent = this._getParentOffset(); 1159 } 1160 1161 //Compute the helpers position 1162 this.position = this._generatePosition(event); 1163 this.positionAbs = this._convertPositionTo("absolute"); 1164 1165 //Call plugins and callbacks and use the resulting position if something is returned 1166 if (!noPropagation) { 1167 var ui = this._uiHash(); 1168 if(this._trigger("drag", event, ui) === false) { 1169 this._mouseUp({}); 1170 return false; 1171 } 1172 this.position = ui.position; 1173 } 1174 1175 if(!this.options.axis || this.options.axis !== "y") { 1176 this.helper[0].style.left = this.position.left+"px"; 1177 } 1178 if(!this.options.axis || this.options.axis !== "x") { 1179 this.helper[0].style.top = this.position.top+"px"; 1180 } 1181 if($.ui.ddmanager) { 1182 $.ui.ddmanager.drag(this, event); 1183 } 1184 1185 return false; 1186 }, 1187 1188 _mouseStop: function(event) { 1189 1190 //If we are using droppables, inform the manager about the drop 1191 var that = this, 1192 dropped = false; 1193 if ($.ui.ddmanager && !this.options.dropBehaviour) { 1194 dropped = $.ui.ddmanager.drop(this, event); 1195 } 1196 1197 //if a drop comes from outside (a sortable) 1198 if(this.dropped) { 1199 dropped = this.dropped; 1200 this.dropped = false; 1201 } 1202 1203 //if the original element is no longer in the DOM don't bother to continue (see #8269) 1204 if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) { 1205 return false; 1206 } 1207 1208 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))) { 1209 $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { 1210 if(that._trigger("stop", event) !== false) { 1211 that._clear(); 1212 } 1213 }); 1214 } else { 1215 if(this._trigger("stop", event) !== false) { 1216 this._clear(); 1217 } 1218 } 1219 1220 return false; 1221 }, 1222 1223 _mouseUp: function(event) { 1224 //Remove frame helpers 1225 $("div.ui-draggable-iframeFix").each(function() { 1226 this.parentNode.removeChild(this); 1227 }); 1228 1229 //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) 1230 if( $.ui.ddmanager ) { 1231 $.ui.ddmanager.dragStop(this, event); 1232 } 1233 1234 return $.ui.mouse.prototype._mouseUp.call(this, event); 1235 }, 1236 1237 cancel: function() { 1238 1239 if(this.helper.is(".ui-draggable-dragging")) { 1240 this._mouseUp({}); 1241 } else { 1242 this._clear(); 1243 } 1244 1245 return this; 1246 1247 }, 1248 1249 _getHandle: function(event) { 1250 return this.options.handle ? 1251 !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : 1252 true; 1253 }, 1254 1255 _createHelper: function(event) { 1256 1257 var o = this.options, 1258 helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element); 1259 1260 if(!helper.parents("body").length) { 1261 helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo)); 1262 } 1263 1264 if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) { 1265 helper.css("position", "absolute"); 1266 } 1267 1268 return helper; 1269 1270 }, 1271 1272 _adjustOffsetFromHelper: function(obj) { 1273 if (typeof obj === "string") { 1274 obj = obj.split(" "); 1275 } 1276 if ($.isArray(obj)) { 1277 obj = {left: +obj[0], top: +obj[1] || 0}; 1278 } 1279 if ("left" in obj) { 1280 this.offset.click.left = obj.left + this.margins.left; 1281 } 1282 if ("right" in obj) { 1283 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; 1284 } 1285 if ("top" in obj) { 1286 this.offset.click.top = obj.top + this.margins.top; 1287 } 1288 if ("bottom" in obj) { 1289 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; 1290 } 1291 }, 1292 1293 _getParentOffset: function() { 1294 1295 //Get the offsetParent and cache its position 1296 var po = this.offsetParent.offset(); 1297 1298 // This is a special case where we need to modify a offset calculated on start, since the following happened: 1299 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent 1300 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that 1301 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag 1302 if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) { 1303 po.left += this.scrollParent.scrollLeft(); 1304 po.top += this.scrollParent.scrollTop(); 1305 } 1306 1307 //This needs to be actually done for all browsers, since pageX/pageY includes this information 1308 //Ugly IE fix 1309 if((this.offsetParent[0] === document.body) || 1310 (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) { 1311 po = { top: 0, left: 0 }; 1312 } 1313 1314 return { 1315 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), 1316 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) 1317 }; 1318 1319 }, 1320 1321 _getRelativeOffset: function() { 1322 1323 if(this.cssPosition === "relative") { 1324 var p = this.element.position(); 1325 return { 1326 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), 1327 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() 1328 }; 1329 } else { 1330 return { top: 0, left: 0 }; 1331 } 1332 1333 }, 1334 1335 _cacheMargins: function() { 1336 this.margins = { 1337 left: (parseInt(this.element.css("marginLeft"),10) || 0), 1338 top: (parseInt(this.element.css("marginTop"),10) || 0), 1339 right: (parseInt(this.element.css("marginRight"),10) || 0), 1340 bottom: (parseInt(this.element.css("marginBottom"),10) || 0) 1341 }; 1342 }, 1343 1344 _cacheHelperProportions: function() { 1345 this.helperProportions = { 1346 width: this.helper.outerWidth(), 1347 height: this.helper.outerHeight() 1348 }; 1349 }, 1350 1351 _setContainment: function() { 1352 1353 var over, c, ce, 1354 o = this.options; 1355 1356 if ( !o.containment ) { 1357 this.containment = null; 1358 return; 1359 } 1360 1361 if ( o.containment === "window" ) { 1362 this.containment = [ 1363 $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left, 1364 $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top, 1365 $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left, 1366 $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top 1367 ]; 1368 return; 1369 } 1370 1371 if ( o.containment === "document") { 1372 this.containment = [ 1373 0, 1374 0, 1375 $( document ).width() - this.helperProportions.width - this.margins.left, 1376 ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top 1377 ]; 1378 return; 1379 } 1380 1381 if ( o.containment.constructor === Array ) { 1382 this.containment = o.containment; 1383 return; 1384 } 1385 1386 if ( o.containment === "parent" ) { 1387 o.containment = this.helper[ 0 ].parentNode; 1388 } 1389 1390 c = $( o.containment ); 1391 ce = c[ 0 ]; 1392 1393 if( !ce ) { 1394 return; 1395 } 1396 1397 over = c.css( "overflow" ) !== "hidden"; 1398 1399 this.containment = [ 1400 ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), 1401 ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) , 1402 ( 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, 1403 ( 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 1404 ]; 1405 this.relative_container = c; 1406 }, 1407 1408 _convertPositionTo: function(d, pos) { 1409 1410 if(!pos) { 1411 pos = this.position; 1412 } 1413 1414 var mod = d === "absolute" ? 1 : -1, 1415 scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent; 1416 1417 //Cache the scroll 1418 if (!this.offset.scroll) { 1419 this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()}; 1420 } 1421 1422 return { 1423 top: ( 1424 pos.top + // The absolute mouse position 1425 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent 1426 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) 1427 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod ) 1428 ), 1429 left: ( 1430 pos.left + // The absolute mouse position 1431 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent 1432 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) 1433 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod ) 1434 ) 1435 }; 1436 1437 }, 1438 1439 _generatePosition: function(event) { 1440 1441 var containment, co, top, left, 1442 o = this.options, 1443 scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent, 1444 pageX = event.pageX, 1445 pageY = event.pageY; 1446 1447 //Cache the scroll 1448 if (!this.offset.scroll) { 1449 this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()}; 1450 } 1451 1452 /* 1453 * - Position constraining - 1454 * Constrain the position to a mix of grid, containment. 1455 */ 1456 1457 // If we are not dragging yet, we won't check for options 1458 if ( this.originalPosition ) { 1459 if ( this.containment ) { 1460 if ( this.relative_container ){ 1461 co = this.relative_container.offset(); 1462 containment = [ 1463 this.containment[ 0 ] + co.left, 1464 this.containment[ 1 ] + co.top, 1465 this.containment[ 2 ] + co.left, 1466 this.containment[ 3 ] + co.top 1467 ]; 1468 } 1469 else { 1470 containment = this.containment; 1471 } 1472 1473 if(event.pageX - this.offset.click.left < containment[0]) { 1474 pageX = containment[0] + this.offset.click.left; 1475 } 1476 if(event.pageY - this.offset.click.top < containment[1]) { 1477 pageY = containment[1] + this.offset.click.top; 1478 } 1479 if(event.pageX - this.offset.click.left > containment[2]) { 1480 pageX = containment[2] + this.offset.click.left; 1481 } 1482 if(event.pageY - this.offset.click.top > containment[3]) { 1483 pageY = containment[3] + this.offset.click.top; 1484 } 1485 } 1486 1487 if(o.grid) { 1488 //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) 1489 top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY; 1490 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; 1491 1492 left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX; 1493 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; 1494 } 1495 1496 } 1497 1498 return { 1499 top: ( 1500 pageY - // The absolute mouse position 1501 this.offset.click.top - // Click offset (relative to the element) 1502 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent 1503 this.offset.parent.top + // The offsetParent's offset without borders (offset + border) 1504 ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) 1505 ), 1506 left: ( 1507 pageX - // The absolute mouse position 1508 this.offset.click.left - // Click offset (relative to the element) 1509 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent 1510 this.offset.parent.left + // The offsetParent's offset without borders (offset + border) 1511 ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) 1512 ) 1513 }; 1514 1515 }, 1516 1517 _clear: function() { 1518 this.helper.removeClass("ui-draggable-dragging"); 1519 if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) { 1520 this.helper.remove(); 1521 } 1522 this.helper = null; 1523 this.cancelHelperRemoval = false; 1524 }, 1525 1526 // From now on bulk stuff - mainly helpers 1527 1528 _trigger: function(type, event, ui) { 1529 ui = ui || this._uiHash(); 1530 $.ui.plugin.call(this, type, [event, ui]); 1531 //The absolute position has to be recalculated after plugins 1532 if(type === "drag") { 1533 this.positionAbs = this._convertPositionTo("absolute"); 1534 } 1535 return $.Widget.prototype._trigger.call(this, type, event, ui); 1536 }, 1537 1538 plugins: {}, 1539 1540 _uiHash: function() { 1541 return { 1542 helper: this.helper, 1543 position: this.position, 1544 originalPosition: this.originalPosition, 1545 offset: this.positionAbs 1546 }; 1547 } 1548 1549 }); 1550 1551 $.ui.plugin.add("draggable", "connectToSortable", { 1552 start: function(event, ui) { 1553 1554 var inst = $(this).data("ui-draggable"), o = inst.options, 1555 uiSortable = $.extend({}, ui, { item: inst.element }); 1556 inst.sortables = []; 1557 $(o.connectToSortable).each(function() { 1558 var sortable = $.data(this, "ui-sortable"); 1559 if (sortable && !sortable.options.disabled) { 1560 inst.sortables.push({ 1561 instance: sortable, 1562 shouldRevert: sortable.options.revert 1563 }); 1564 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). 1565 sortable._trigger("activate", event, uiSortable); 1566 } 1567 }); 1568 1569 }, 1570 stop: function(event, ui) { 1571 1572 //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper 1573 var inst = $(this).data("ui-draggable"), 1574 uiSortable = $.extend({}, ui, { item: inst.element }); 1575 1576 $.each(inst.sortables, function() { 1577 if(this.instance.isOver) { 1578 1579 this.instance.isOver = 0; 1580 1581 inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance 1582 this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) 1583 1584 //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid" 1585 if(this.shouldRevert) { 1586 this.instance.options.revert = this.shouldRevert; 1587 } 1588 1589 //Trigger the stop of the sortable 1590 this.instance._mouseStop(event); 1591 1592 this.instance.options.helper = this.instance.options._helper; 1593 1594 //If the helper has been the original item, restore properties in the sortable 1595 if(inst.options.helper === "original") { 1596 this.instance.currentItem.css({ top: "auto", left: "auto" }); 1597 } 1598 1599 } else { 1600 this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance 1601 this.instance._trigger("deactivate", event, uiSortable); 1602 } 1603 1604 }); 1605 1606 }, 1607 drag: function(event, ui) { 1608 1609 var inst = $(this).data("ui-draggable"), that = this; 1610 1611 $.each(inst.sortables, function() { 1612 1613 var innermostIntersecting = false, 1614 thisSortable = this; 1615 1616 //Copy over some variables to allow calling the sortable's native _intersectsWith 1617 this.instance.positionAbs = inst.positionAbs; 1618 this.instance.helperProportions = inst.helperProportions; 1619 this.instance.offset.click = inst.offset.click; 1620 1621 if(this.instance._intersectsWith(this.instance.containerCache)) { 1622 innermostIntersecting = true; 1623 $.each(inst.sortables, function () { 1624 this.instance.positionAbs = inst.positionAbs; 1625 this.instance.helperProportions = inst.helperProportions; 1626 this.instance.offset.click = inst.offset.click; 1627 if (this !== thisSortable && 1628 this.instance._intersectsWith(this.instance.containerCache) && 1629 $.contains(thisSortable.instance.element[0], this.instance.element[0]) 1630 ) { 1631 innermostIntersecting = false; 1632 } 1633 return innermostIntersecting; 1634 }); 1635 } 1636 1637 1638 if(innermostIntersecting) { 1639 //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once 1640 if(!this.instance.isOver) { 1641 1642 this.instance.isOver = 1; 1643 //Now we fake the start of dragging for the sortable instance, 1644 //by cloning the list group item, appending it to the sortable and using it as inst.currentItem 1645 //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) 1646 this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true); 1647 this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it 1648 this.instance.options.helper = function() { return ui.helper[0]; }; 1649 1650 event.target = this.instance.currentItem[0]; 1651 this.instance._mouseCapture(event, true); 1652 this.instance._mouseStart(event, true, true); 1653 1654 //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes 1655 this.instance.offset.click.top = inst.offset.click.top; 1656 this.instance.offset.click.left = inst.offset.click.left; 1657 this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; 1658 this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; 1659 1660 inst._trigger("toSortable", event); 1661 inst.dropped = this.instance.element; //draggable revert needs that 1662 //hack so receive/update callbacks work (mostly) 1663 inst.currentItem = inst.element; 1664 this.instance.fromOutside = inst; 1665 1666 } 1667 1668 //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 1669 if(this.instance.currentItem) { 1670 this.instance._mouseDrag(event); 1671 } 1672 1673 } else { 1674 1675 //If it doesn't intersect with the sortable, and it intersected before, 1676 //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval 1677 if(this.instance.isOver) { 1678 1679 this.instance.isOver = 0; 1680 this.instance.cancelHelperRemoval = true; 1681 1682 //Prevent reverting on this forced stop 1683 this.instance.options.revert = false; 1684 1685 // The out event needs to be triggered independently 1686 this.instance._trigger("out", event, this.instance._uiHash(this.instance)); 1687 1688 this.instance._mouseStop(event, true); 1689 this.instance.options.helper = this.instance.options._helper; 1690 1691 //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size 1692 this.instance.currentItem.remove(); 1693 if(this.instance.placeholder) { 1694 this.instance.placeholder.remove(); 1695 } 1696 1697 inst._trigger("fromSortable", event); 1698 inst.dropped = false; //draggable revert needs that 1699 } 1700 1701 } 1702 1703 }); 1704 1705 } 1706 }); 1707 1708 $.ui.plugin.add("draggable", "cursor", { 1709 start: function() { 1710 var t = $("body"), o = $(this).data("ui-draggable").options; 1711 if (t.css("cursor")) { 1712 o._cursor = t.css("cursor"); 1713 } 1714 t.css("cursor", o.cursor); 1715 }, 1716 stop: function() { 1717 var o = $(this).data("ui-draggable").options; 1718 if (o._cursor) { 1719 $("body").css("cursor", o._cursor); 1720 } 1721 } 1722 }); 1723 1724 $.ui.plugin.add("draggable", "opacity", { 1725 start: function(event, ui) { 1726 var t = $(ui.helper), o = $(this).data("ui-draggable").options; 1727 if(t.css("opacity")) { 1728 o._opacity = t.css("opacity"); 1729 } 1730 t.css("opacity", o.opacity); 1731 }, 1732 stop: function(event, ui) { 1733 var o = $(this).data("ui-draggable").options; 1734 if(o._opacity) { 1735 $(ui.helper).css("opacity", o._opacity); 1736 } 1737 } 1738 }); 1739 1740 $.ui.plugin.add("draggable", "scroll", { 1741 start: function() { 1742 var i = $(this).data("ui-draggable"); 1743 if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") { 1744 i.overflowOffset = i.scrollParent.offset(); 1745 } 1746 }, 1747 drag: function( event ) { 1748 1749 var i = $(this).data("ui-draggable"), o = i.options, scrolled = false; 1750 1751 if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") { 1752 1753 if(!o.axis || o.axis !== "x") { 1754 if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) { 1755 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed; 1756 } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) { 1757 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed; 1758 } 1759 } 1760 1761 if(!o.axis || o.axis !== "y") { 1762 if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) { 1763 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed; 1764 } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) { 1765 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed; 1766 } 1767 } 1768 1769 } else { 1770 1771 if(!o.axis || o.axis !== "x") { 1772 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) { 1773 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); 1774 } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) { 1775 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); 1776 } 1777 } 1778 1779 if(!o.axis || o.axis !== "y") { 1780 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) { 1781 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); 1782 } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) { 1783 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); 1784 } 1785 } 1786 1787 } 1788 1789 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { 1790 $.ui.ddmanager.prepareOffsets(i, event); 1791 } 1792 1793 } 1794 }); 1795 1796 $.ui.plugin.add("draggable", "snap", { 1797 start: function() { 1798 1799 var i = $(this).data("ui-draggable"), 1800 o = i.options; 1801 1802 i.snapElements = []; 1803 1804 $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() { 1805 var $t = $(this), 1806 $o = $t.offset(); 1807 if(this !== i.element[0]) { 1808 i.snapElements.push({ 1809 item: this, 1810 width: $t.outerWidth(), height: $t.outerHeight(), 1811 top: $o.top, left: $o.left 1812 }); 1813 } 1814 }); 1815 1816 }, 1817 drag: function(event, ui) { 1818 1819 var ts, bs, ls, rs, l, r, t, b, i, first, 1820 inst = $(this).data("ui-draggable"), 1821 o = inst.options, 1822 d = o.snapTolerance, 1823 x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, 1824 y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; 1825 1826 for (i = inst.snapElements.length - 1; i >= 0; i--){ 1827 1828 l = inst.snapElements[i].left; 1829 r = l + inst.snapElements[i].width; 1830 t = inst.snapElements[i].top; 1831 b = t + inst.snapElements[i].height; 1832 1833 if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) { 1834 if(inst.snapElements[i].snapping) { 1835 (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); 1836 } 1837 inst.snapElements[i].snapping = false; 1838 continue; 1839 } 1840 1841 if(o.snapMode !== "inner") { 1842 ts = Math.abs(t - y2) <= d; 1843 bs = Math.abs(b - y1) <= d; 1844 ls = Math.abs(l - x2) <= d; 1845 rs = Math.abs(r - x1) <= d; 1846 if(ts) { 1847 ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top; 1848 } 1849 if(bs) { 1850 ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top; 1851 } 1852 if(ls) { 1853 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left; 1854 } 1855 if(rs) { 1856 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left; 1857 } 1858 } 1859 1860 first = (ts || bs || ls || rs); 1861 1862 if(o.snapMode !== "outer") { 1863 ts = Math.abs(t - y1) <= d; 1864 bs = Math.abs(b - y2) <= d; 1865 ls = Math.abs(l - x1) <= d; 1866 rs = Math.abs(r - x2) <= d; 1867 if(ts) { 1868 ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top; 1869 } 1870 if(bs) { 1871 ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top; 1872 } 1873 if(ls) { 1874 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left; 1875 } 1876 if(rs) { 1877 ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left; 1878 } 1879 } 1880 1881 if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) { 1882 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); 1883 } 1884 inst.snapElements[i].snapping = (ts || bs || ls || rs || first); 1885 1886 } 1887 1888 } 1889 }); 1890 1891 $.ui.plugin.add("draggable", "stack", { 1892 start: function() { 1893 var min, 1894 o = this.data("ui-draggable").options, 1895 group = $.makeArray($(o.stack)).sort(function(a,b) { 1896 return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); 1897 }); 1898 1899 if (!group.length) { return; } 1900 1901 min = parseInt($(group[0]).css("zIndex"), 10) || 0; 1902 $(group).each(function(i) { 1903 $(this).css("zIndex", min + i); 1904 }); 1905 this.css("zIndex", (min + group.length)); 1906 } 1907 }); 1908 1909 $.ui.plugin.add("draggable", "zIndex", { 1910 start: function(event, ui) { 1911 var t = $(ui.helper), o = $(this).data("ui-draggable").options; 1912 if(t.css("zIndex")) { 1913 o._zIndex = t.css("zIndex"); 1914 } 1915 t.css("zIndex", o.zIndex); 1916 }, 1917 stop: function(event, ui) { 1918 var o = $(this).data("ui-draggable").options; 1919 if(o._zIndex) { 1920 $(ui.helper).css("zIndex", o._zIndex); 1921 } 1922 } 1923 }); 1924 1925 })(jQuery); 1926 (function( $, undefined ) { 1927 1928 /*jshint loopfunc: true */ 1929 1930 function isOverAxis( x, reference, size ) { 1931 return ( x > reference ) && ( x < ( reference + size ) ); 1932 } 1933 1934 function isFloating(item) { 1935 return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display")); 1936 } 1937 1028 1938 $.widget("ui.sortable", $.ui.mouse, { 1029 version: "1. 9.2",1939 version: "1.10.3", 1030 1940 widgetEventPrefix: "sort", 1031 1941 ready: false, … … 1035 1945 connectWith: false, 1036 1946 containment: false, 1037 cursor: 'auto',1947 cursor: "auto", 1038 1948 cursorAt: false, 1039 1949 dropOnEmpty: true, … … 1043 1953 handle: false, 1044 1954 helper: "original", 1045 items: '> *',1955 items: "> *", 1046 1956 opacity: false, 1047 1957 placeholder: false, … … 1052 1962 scope: "default", 1053 1963 tolerance: "intersect", 1054 zIndex: 1000 1964 zIndex: 1000, 1965 1966 // callbacks 1967 activate: null, 1968 beforeStop: null, 1969 change: null, 1970 deactivate: null, 1971 out: null, 1972 over: null, 1973 receive: null, 1974 remove: null, 1975 sort: null, 1976 start: null, 1977 stop: null, 1978 update: null 1055 1979 }, 1056 1980 _create: function() { … … 1064 1988 1065 1989 //Let's determine if the items are being displayed horizontally 1066 this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false;1990 this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false; 1067 1991 1068 1992 //Let's determine the parent's offset … … 1073 1997 1074 1998 //We're ready to go 1075 this.ready = true 1999 this.ready = true; 1076 2000 1077 2001 }, … … 1082 2006 this._mouseDestroy(); 1083 2007 1084 for ( var i = this.items.length - 1; i >= 0; i-- ) 2008 for ( var i = this.items.length - 1; i >= 0; i-- ) { 1085 2009 this.items[i].item.removeData(this.widgetName + "-item"); 2010 } 1086 2011 1087 2012 return this; … … 1100 2025 1101 2026 _mouseCapture: function(event, overrideHandle) { 1102 var that = this; 2027 var currentItem = null, 2028 validHandle = false, 2029 that = this; 1103 2030 1104 2031 if (this.reverting) { … … 1106 2033 } 1107 2034 1108 if(this.options.disabled || this.options.type == 'static') return false; 2035 if(this.options.disabled || this.options.type === "static") { 2036 return false; 2037 } 1109 2038 1110 2039 //We have to refresh the items data once first … … 1112 2041 1113 2042 //Find out if the clicked node (or one of its parents) is a actual item in this.items 1114 var currentItem = null, nodes =$(event.target).parents().each(function() {1115 if($.data(this, that.widgetName + '-item')== that) {2043 $(event.target).parents().each(function() { 2044 if($.data(this, that.widgetName + "-item") === that) { 1116 2045 currentItem = $(this); 1117 2046 return false; 1118 2047 } 1119 2048 }); 1120 if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target); 1121 1122 if(!currentItem) return false; 2049 if($.data(event.target, that.widgetName + "-item") === that) { 2050 currentItem = $(event.target); 2051 } 2052 2053 if(!currentItem) { 2054 return false; 2055 } 1123 2056 if(this.options.handle && !overrideHandle) { 1124 var validHandle = false; 1125 1126 $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; }); 1127 if(!validHandle) return false; 2057 $(this.options.handle, currentItem).find("*").addBack().each(function() { 2058 if(this === event.target) { 2059 validHandle = true; 2060 } 2061 }); 2062 if(!validHandle) { 2063 return false; 2064 } 1128 2065 } 1129 2066 … … 1136 2073 _mouseStart: function(event, overrideHandle, noActivation) { 1137 2074 1138 var o = this.options; 2075 var i, body, 2076 o = this.options; 2077 1139 2078 this.currentContainer = this; 1140 2079 … … 1185 2124 this.originalPageY = event.pageY; 1186 2125 1187 //Adjust the mouse offset relative to the helper if 'cursorAt'is supplied2126 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied 1188 2127 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); 1189 2128 … … 1192 2131 1193 2132 //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 1194 if(this.helper[0] != this.currentItem[0]) {2133 if(this.helper[0] !== this.currentItem[0]) { 1195 2134 this.currentItem.hide(); 1196 2135 } … … 1200 2139 1201 2140 //Set a containment if given in the options 1202 if(o.containment) 2141 if(o.containment) { 1203 2142 this._setContainment(); 1204 1205 if(o.cursor) { // cursor option 1206 if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor"); 1207 $('body').css("cursor", o.cursor); 2143 } 2144 2145 if( o.cursor && o.cursor !== "auto" ) { // cursor option 2146 body = this.document.find( "body" ); 2147 2148 // support: IE 2149 this.storedCursor = body.css( "cursor" ); 2150 body.css( "cursor", o.cursor ); 2151 2152 this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body ); 1208 2153 } 1209 2154 1210 2155 if(o.opacity) { // opacity option 1211 if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity"); 2156 if (this.helper.css("opacity")) { 2157 this._storedOpacity = this.helper.css("opacity"); 2158 } 1212 2159 this.helper.css("opacity", o.opacity); 1213 2160 } 1214 2161 1215 2162 if(o.zIndex) { // zIndex option 1216 if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex"); 2163 if (this.helper.css("zIndex")) { 2164 this._storedZIndex = this.helper.css("zIndex"); 2165 } 1217 2166 this.helper.css("zIndex", o.zIndex); 1218 2167 } 1219 2168 1220 2169 //Prepare scrolling 1221 if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')2170 if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") { 1222 2171 this.overflowOffset = this.scrollParent.offset(); 2172 } 1223 2173 1224 2174 //Call callbacks … … 1226 2176 1227 2177 //Recache the helper size 1228 if(!this._preserveHelperProportions) 2178 if(!this._preserveHelperProportions) { 1229 2179 this._cacheHelperProportions(); 1230 1231 1232 //Post 'activate' events to possible containers 1233 if(!noActivation) { 1234 for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); } 2180 } 2181 2182 2183 //Post "activate" events to possible containers 2184 if( !noActivation ) { 2185 for ( i = this.containers.length - 1; i >= 0; i-- ) { 2186 this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); 2187 } 1235 2188 } 1236 2189 1237 2190 //Prepare possible droppables 1238 if($.ui.ddmanager) 2191 if($.ui.ddmanager) { 1239 2192 $.ui.ddmanager.current = this; 1240 1241 if ($.ui.ddmanager && !o.dropBehaviour) 2193 } 2194 2195 if ($.ui.ddmanager && !o.dropBehaviour) { 1242 2196 $.ui.ddmanager.prepareOffsets(this, event); 2197 } 1243 2198 1244 2199 this.dragging = true; … … 1251 2206 1252 2207 _mouseDrag: function(event) { 2208 var i, item, itemElement, intersection, 2209 o = this.options, 2210 scrolled = false; 1253 2211 1254 2212 //Compute the helpers position … … 1262 2220 //Do scrolling 1263 2221 if(this.options.scroll) { 1264 var o = this.options, scrolled = false; 1265 if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') { 1266 1267 if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) 2222 if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") { 2223 2224 if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) { 1268 2225 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; 1269 else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)2226 } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) { 1270 2227 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; 1271 1272 if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) 2228 } 2229 2230 if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) { 1273 2231 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; 1274 else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)2232 } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) { 1275 2233 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; 2234 } 1276 2235 1277 2236 } else { 1278 2237 1279 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) 2238 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) { 1280 2239 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); 1281 else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)2240 } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) { 1282 2241 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); 1283 1284 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) 2242 } 2243 2244 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) { 1285 2245 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); 1286 else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)2246 } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) { 1287 2247 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); 1288 1289 } 1290 1291 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) 2248 } 2249 2250 } 2251 2252 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { 1292 2253 $.ui.ddmanager.prepareOffsets(this, event); 2254 } 1293 2255 } 1294 2256 … … 1297 2259 1298 2260 //Set the helper position 1299 if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; 1300 if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; 2261 if(!this.options.axis || this.options.axis !== "y") { 2262 this.helper[0].style.left = this.position.left+"px"; 2263 } 2264 if(!this.options.axis || this.options.axis !== "x") { 2265 this.helper[0].style.top = this.position.top+"px"; 2266 } 1301 2267 1302 2268 //Rearrange 1303 for ( vari = this.items.length - 1; i >= 0; i--) {2269 for (i = this.items.length - 1; i >= 0; i--) { 1304 2270 1305 2271 //Cache variables and intersection, continue if no intersection 1306 var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item); 1307 if (!intersection) continue; 2272 item = this.items[i]; 2273 itemElement = item.item[0]; 2274 intersection = this._intersectsWithPointer(item); 2275 if (!intersection) { 2276 continue; 2277 } 1308 2278 1309 2279 // Only put the placeholder inside the current Container, skip all … … 1314 2284 // Without this moving items in "sub-sortables" can cause the placeholder to jitter 1315 2285 // beetween the outer and inner container. 1316 if (item.instance !== this.currentContainer) continue; 1317 1318 if (itemElement != this.currentItem[0] //cannot intersect with itself 1319 && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before 1320 && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked 1321 && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true) 1322 //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container 2286 if (item.instance !== this.currentContainer) { 2287 continue; 2288 } 2289 2290 // cannot intersect with itself 2291 // no useless actions that have been done before 2292 // no action if the item moved is the parent of the item checked 2293 if (itemElement !== this.currentItem[0] && 2294 this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement && 2295 !$.contains(this.placeholder[0], itemElement) && 2296 (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true) 1323 2297 ) { 1324 2298 1325 this.direction = intersection == 1 ? "down" : "up";1326 1327 if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {2299 this.direction = intersection === 1 ? "down" : "up"; 2300 2301 if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) { 1328 2302 this._rearrange(event, item); 1329 2303 } else { … … 1340 2314 1341 2315 //Interconnect with droppables 1342 if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); 2316 if($.ui.ddmanager) { 2317 $.ui.ddmanager.drag(this, event); 2318 } 1343 2319 1344 2320 //Call callbacks 1345 this._trigger( 'sort', event, this._uiHash());2321 this._trigger("sort", event, this._uiHash()); 1346 2322 1347 2323 this.lastPositionAbs = this.positionAbs; … … 1352 2328 _mouseStop: function(event, noPropagation) { 1353 2329 1354 if(!event) return; 2330 if(!event) { 2331 return; 2332 } 1355 2333 1356 2334 //If we are using droppables, inform the manager about the drop 1357 if ($.ui.ddmanager && !this.options.dropBehaviour) 2335 if ($.ui.ddmanager && !this.options.dropBehaviour) { 1358 2336 $.ui.ddmanager.drop(this, event); 2337 } 1359 2338 1360 2339 if(this.options.revert) { 1361 var that = this; 1362 var cur = this.placeholder.offset(); 1363 2340 var that = this, 2341 cur = this.placeholder.offset(), 2342 axis = this.options.axis, 2343 animation = {}; 2344 2345 if ( !axis || axis === "x" ) { 2346 animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft); 2347 } 2348 if ( !axis || axis === "y" ) { 2349 animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop); 2350 } 1364 2351 this.reverting = true; 1365 1366 $(this.helper).animate({ 1367 left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft), 1368 top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) 1369 }, parseInt(this.options.revert, 10) || 500, function() { 2352 $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() { 1370 2353 that._clear(event); 1371 2354 }); … … 1384 2367 this._mouseUp({ target: null }); 1385 2368 1386 if(this.options.helper == "original")2369 if(this.options.helper === "original") { 1387 2370 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); 1388 else2371 } else { 1389 2372 this.currentItem.show(); 2373 } 1390 2374 1391 2375 //Post deactivating events to containers … … 1402 2386 if (this.placeholder) { 1403 2387 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! 1404 if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]); 1405 if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove(); 2388 if(this.placeholder[0].parentNode) { 2389 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); 2390 } 2391 if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) { 2392 this.helper.remove(); 2393 } 1406 2394 1407 2395 $.extend(this, { … … 1425 2413 serialize: function(o) { 1426 2414 1427 var items = this._getItemsAsjQuery(o && o.connected); 1428 var str = []; o = o || {}; 2415 var items = this._getItemsAsjQuery(o && o.connected), 2416 str = []; 2417 o = o || {}; 1429 2418 1430 2419 $(items).each(function() { 1431 var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); 1432 if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2])); 2420 var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/)); 2421 if (res) { 2422 str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2])); 2423 } 1433 2424 }); 1434 2425 1435 2426 if(!str.length && o.key) { 1436 str.push(o.key + '=');1437 } 1438 1439 return str.join( '&');2427 str.push(o.key + "="); 2428 } 2429 2430 return str.join("&"); 1440 2431 1441 2432 }, … … 1443 2434 toArray: function(o) { 1444 2435 1445 var items = this._getItemsAsjQuery(o && o.connected); 1446 var ret = []; o = o || {}; 1447 1448 items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); }); 2436 var items = this._getItemsAsjQuery(o && o.connected), 2437 ret = []; 2438 2439 o = o || {}; 2440 2441 items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); }); 1449 2442 return ret; 1450 2443 … … 1457 2450 x2 = x1 + this.helperProportions.width, 1458 2451 y1 = this.positionAbs.top, 1459 y2 = y1 + this.helperProportions.height; 1460 1461 var l = item.left, 2452 y2 = y1 + this.helperProportions.height, 2453 l = item.left, 1462 2454 r = l + item.width, 1463 2455 t = item.top, 1464 b = t + item.height ;1465 1466 var dyClick = this.offset.click.top,1467 dxClick = this.offset.click.left;1468 1469 var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;1470 1471 if ( this.options.tolerance == "pointer"1472 || this.options.forcePointerForContainers1473 || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])2456 b = t + item.height, 2457 dyClick = this.offset.click.top, 2458 dxClick = this.offset.click.left, 2459 isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ), 2460 isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ), 2461 isOverElement = isOverElementHeight && isOverElementWidth; 2462 2463 if ( this.options.tolerance === "pointer" || 2464 this.options.forcePointerForContainers || 2465 (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"]) 1474 2466 ) { 1475 2467 return isOverElement; 1476 2468 } else { 1477 2469 1478 return (l < x1 + (this.helperProportions.width / 2) // Right Half1479 && x2 - (this.helperProportions.width / 2) < r// Left Half1480 && t < y1 + (this.helperProportions.height / 2)// Bottom Half1481 &&y2 - (this.helperProportions.height / 2) < b ); // Top Half2470 return (l < x1 + (this.helperProportions.width / 2) && // Right Half 2471 x2 - (this.helperProportions.width / 2) < r && // Left Half 2472 t < y1 + (this.helperProportions.height / 2) && // Bottom Half 2473 y2 - (this.helperProportions.height / 2) < b ); // Top Half 1482 2474 1483 2475 } … … 1486 2478 _intersectsWithPointer: function(item) { 1487 2479 1488 var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),1489 isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),2480 var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), 2481 isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), 1490 2482 isOverElement = isOverElementHeight && isOverElementWidth, 1491 2483 verticalDirection = this._getDragVerticalDirection(), 1492 2484 horizontalDirection = this._getDragHorizontalDirection(); 1493 2485 1494 if (!isOverElement) 2486 if (!isOverElement) { 1495 2487 return false; 2488 } 1496 2489 1497 2490 return this.floating ? 1498 ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection== "down") ? 2 : 1 )1499 : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );2491 ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 ) 2492 : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) ); 1500 2493 1501 2494 }, … … 1503 2496 _intersectsWithSides: function(item) { 1504 2497 1505 var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),1506 isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),2498 var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), 2499 isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), 1507 2500 verticalDirection = this._getDragVerticalDirection(), 1508 2501 horizontalDirection = this._getDragHorizontalDirection(); 1509 2502 1510 2503 if (this.floating && horizontalDirection) { 1511 return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection== "left" && !isOverRightHalf));2504 return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf)); 1512 2505 } else { 1513 return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection== "up" && !isOverBottomHalf));2506 return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf)); 1514 2507 } 1515 2508 … … 1518 2511 _getDragVerticalDirection: function() { 1519 2512 var delta = this.positionAbs.top - this.lastPositionAbs.top; 1520 return delta != 0 && (delta > 0 ? "down" : "up");2513 return delta !== 0 && (delta > 0 ? "down" : "up"); 1521 2514 }, 1522 2515 1523 2516 _getDragHorizontalDirection: function() { 1524 2517 var delta = this.positionAbs.left - this.lastPositionAbs.left; 1525 return delta != 0 && (delta > 0 ? "right" : "left");2518 return delta !== 0 && (delta > 0 ? "right" : "left"); 1526 2519 }, 1527 2520 … … 1534 2527 _connectWith: function() { 1535 2528 var options = this.options; 1536 return options.connectWith.constructor == String 1537 ? [options.connectWith] 1538 : options.connectWith; 2529 return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith; 1539 2530 }, 1540 2531 1541 2532 _getItemsAsjQuery: function(connected) { 1542 2533 1543 var items = []; 1544 var queries = []; 1545 var connectWith = this._connectWith(); 2534 var i, j, cur, inst, 2535 items = [], 2536 queries = [], 2537 connectWith = this._connectWith(); 1546 2538 1547 2539 if(connectWith && connected) { 1548 for ( vari = connectWith.length - 1; i >= 0; i--){1549 varcur = $(connectWith[i]);1550 for ( varj = cur.length - 1; j >= 0; j--){1551 var inst = $.data(cur[j], this.widgetName);1552 if(inst && inst != this && !inst.options.disabled) {1553 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]);2540 for (i = connectWith.length - 1; i >= 0; i--){ 2541 cur = $(connectWith[i]); 2542 for ( j = cur.length - 1; j >= 0; j--){ 2543 inst = $.data(cur[j], this.widgetFullName); 2544 if(inst && inst !== this && !inst.options.disabled) { 2545 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]); 1554 2546 } 1555 } ;1556 } ;1557 } 1558 1559 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]);1560 1561 for ( vari = queries.length - 1; i >= 0; i--){2547 } 2548 } 2549 } 2550 2551 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]); 2552 2553 for (i = queries.length - 1; i >= 0; i--){ 1562 2554 queries[i][0].each(function() { 1563 2555 items.push(this); 1564 2556 }); 1565 } ;2557 } 1566 2558 1567 2559 return $(items); … … 1575 2567 this.items = $.grep(this.items, function (item) { 1576 2568 for (var j=0; j < list.length; j++) { 1577 if(list[j] == item.item[0])2569 if(list[j] === item.item[0]) { 1578 2570 return false; 1579 }; 2571 } 2572 } 1580 2573 return true; 1581 2574 }); … … 1587 2580 this.items = []; 1588 2581 this.containers = [this]; 1589 var items = this.items; 1590 var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]]; 1591 var connectWith = this._connectWith(); 2582 2583 var i, j, cur, inst, targetData, _queries, item, queriesLength, 2584 items = this.items, 2585 queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]], 2586 connectWith = this._connectWith(); 1592 2587 1593 2588 if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down 1594 for ( vari = connectWith.length - 1; i >= 0; i--){1595 varcur = $(connectWith[i]);1596 for ( varj = cur.length - 1; j >= 0; j--){1597 var inst = $.data(cur[j], this.widgetName);1598 if(inst && inst != this && !inst.options.disabled) {2589 for (i = connectWith.length - 1; i >= 0; i--){ 2590 cur = $(connectWith[i]); 2591 for (j = cur.length - 1; j >= 0; j--){ 2592 inst = $.data(cur[j], this.widgetFullName); 2593 if(inst && inst !== this && !inst.options.disabled) { 1599 2594 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); 1600 2595 this.containers.push(inst); 1601 2596 } 1602 } ;1603 } ;1604 } 1605 1606 for ( vari = queries.length - 1; i >= 0; i--) {1607 vartargetData = queries[i][1];1608 var_queries = queries[i][0];1609 1610 for ( varj=0, queriesLength = _queries.length; j < queriesLength; j++) {1611 varitem = $(_queries[j]);1612 1613 item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)2597 } 2598 } 2599 } 2600 2601 for (i = queries.length - 1; i >= 0; i--) { 2602 targetData = queries[i][1]; 2603 _queries = queries[i][0]; 2604 2605 for (j=0, queriesLength = _queries.length; j < queriesLength; j++) { 2606 item = $(_queries[j]); 2607 2608 item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager) 1614 2609 1615 2610 items.push({ … … 1619 2614 left: 0, top: 0 1620 2615 }); 1621 } ;1622 } ;2616 } 2617 } 1623 2618 1624 2619 }, … … 1631 2626 } 1632 2627 1633 for (var i = this.items.length - 1; i >= 0; i--){ 1634 var item = this.items[i]; 2628 var i, item, t, p; 2629 2630 for (i = this.items.length - 1; i >= 0; i--){ 2631 item = this.items[i]; 1635 2632 1636 2633 //We ignore calculating positions of all connected containers when we're not over them 1637 if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])2634 if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) { 1638 2635 continue; 1639 1640 var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; 2636 } 2637 2638 t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; 1641 2639 1642 2640 if (!fast) { … … 1645 2643 } 1646 2644 1647 varp = t.offset();2645 p = t.offset(); 1648 2646 item.left = p.left; 1649 2647 item.top = p.top; 1650 } ;2648 } 1651 2649 1652 2650 if(this.options.custom && this.options.custom.refreshContainers) { 1653 2651 this.options.custom.refreshContainers.call(this); 1654 2652 } else { 1655 for ( vari = this.containers.length - 1; i >= 0; i--){1656 varp = this.containers[i].element.offset();2653 for (i = this.containers.length - 1; i >= 0; i--){ 2654 p = this.containers[i].element.offset(); 1657 2655 this.containers[i].containerCache.left = p.left; 1658 2656 this.containers[i].containerCache.top = p.top; 1659 2657 this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); 1660 2658 this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); 1661 } ;2659 } 1662 2660 } 1663 2661 … … 1667 2665 _createPlaceholder: function(that) { 1668 2666 that = that || this; 1669 var o = that.options; 1670 1671 if(!o.placeholder || o.placeholder.constructor == String) { 1672 var className = o.placeholder; 2667 var className, 2668 o = that.options; 2669 2670 if(!o.placeholder || o.placeholder.constructor === String) { 2671 className = o.placeholder; 1673 2672 o.placeholder = { 1674 2673 element: function() { 1675 2674 1676 var el = $(document.createElement(that.currentItem[0].nodeName)) 1677 .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") 1678 .removeClass("ui-sortable-helper")[0]; 1679 1680 if(!className) 1681 el.style.visibility = "hidden"; 1682 1683 return el; 2675 var nodeName = that.currentItem[0].nodeName.toLowerCase(), 2676 element = $( "<" + nodeName + ">", that.document[0] ) 2677 .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") 2678 .removeClass("ui-sortable-helper"); 2679 2680 if ( nodeName === "tr" ) { 2681 that.currentItem.children().each(function() { 2682 $( "<td> </td>", that.document[0] ) 2683 .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) 2684 .appendTo( element ); 2685 }); 2686 } else if ( nodeName === "img" ) { 2687 element.attr( "src", that.currentItem.attr( "src" ) ); 2688 } 2689 2690 if ( !className ) { 2691 element.css( "visibility", "hidden" ); 2692 } 2693 2694 return element; 1684 2695 }, 1685 2696 update: function(container, p) { … … 1687 2698 // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that 1688 2699 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified 1689 if(className && !o.forcePlaceholderSize) return; 2700 if(className && !o.forcePlaceholderSize) { 2701 return; 2702 } 1690 2703 1691 2704 //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 1692 if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css( 'paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); };1693 if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css( 'paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); };2705 if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); } 2706 if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); } 1694 2707 } 1695 2708 }; … … 1708 2721 1709 2722 _contactContainers: function(event) { 2723 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating, 2724 innermostContainer = null, 2725 innermostIndex = null; 1710 2726 1711 2727 // get innermost container that intersects with item 1712 var innermostContainer = null, innermostIndex = null; 1713 1714 1715 for (var i = this.containers.length - 1; i >= 0; i--){ 2728 for (i = this.containers.length - 1; i >= 0; i--) { 1716 2729 1717 2730 // never consider a container that's located within the item itself 1718 if($.contains(this.currentItem[0], this.containers[i].element[0])) 2731 if($.contains(this.currentItem[0], this.containers[i].element[0])) { 1719 2732 continue; 2733 } 1720 2734 1721 2735 if(this._intersectsWith(this.containers[i].containerCache)) { 1722 2736 1723 2737 // if we've already found a container and it's more "inner" than this, then continue 1724 if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) 2738 if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) { 1725 2739 continue; 2740 } 1726 2741 1727 2742 innermostContainer = this.containers[i]; … … 1739 2754 1740 2755 // if no intersecting containers found, return 1741 if(!innermostContainer) return; 2756 if(!innermostContainer) { 2757 return; 2758 } 1742 2759 1743 2760 // move the item into the container if it's not there already 1744 2761 if(this.containers.length === 1) { 1745 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); 1746 this.containers[innermostIndex].containerCache.over = 1; 2762 if (!this.containers[innermostIndex].containerCache.over) { 2763 this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); 2764 this.containers[innermostIndex].containerCache.over = 1; 2765 } 1747 2766 } else { 1748 2767 1749 2768 //When entering a new container, we will find the item with the least distance and append our item near it 1750 var dist = 10000; var itemWithLeastDistance = null; 1751 var posProperty = this.containers[innermostIndex].floating ? 'left' : 'top'; 1752 var sizeProperty = this.containers[innermostIndex].floating ? 'width' : 'height'; 1753 var base = this.positionAbs[posProperty] + this.offset.click[posProperty]; 1754 for (var j = this.items.length - 1; j >= 0; j--) { 1755 if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue; 1756 if(this.items[j].item[0] == this.currentItem[0]) continue; 1757 var cur = this.items[j].item.offset()[posProperty]; 1758 var nearBottom = false; 2769 dist = 10000; 2770 itemWithLeastDistance = null; 2771 floating = innermostContainer.floating || isFloating(this.currentItem); 2772 posProperty = floating ? "left" : "top"; 2773 sizeProperty = floating ? "width" : "height"; 2774 base = this.positionAbs[posProperty] + this.offset.click[posProperty]; 2775 for (j = this.items.length - 1; j >= 0; j--) { 2776 if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) { 2777 continue; 2778 } 2779 if(this.items[j].item[0] === this.currentItem[0]) { 2780 continue; 2781 } 2782 if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) { 2783 continue; 2784 } 2785 cur = this.items[j].item.offset()[posProperty]; 2786 nearBottom = false; 1759 2787 if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){ 1760 2788 nearBottom = true; … … 1768 2796 } 1769 2797 1770 if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled 2798 //Check if dropOnEmpty is enabled 2799 if(!itemWithLeastDistance && !this.options.dropOnEmpty) { 1771 2800 return; 1772 1773 this.currentContainer = this.containers[innermostIndex]; 2801 } 2802 2803 if(this.currentContainer === this.containers[innermostIndex]) { 2804 return; 2805 } 2806 1774 2807 itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); 1775 2808 this._trigger("change", event, this._uiHash()); 1776 2809 this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); 2810 this.currentContainer = this.containers[innermostIndex]; 1777 2811 1778 2812 //Update the placeholder … … 1788 2822 _createHelper: function(event) { 1789 2823 1790 var o = this.options; 1791 var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem); 1792 1793 if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already 1794 $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); 1795 1796 if(helper[0] == this.currentItem[0]) 2824 var o = this.options, 2825 helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem); 2826 2827 //Add the helper to the DOM if that didn't happen already 2828 if(!helper.parents("body").length) { 2829 $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); 2830 } 2831 2832 if(helper[0] === this.currentItem[0]) { 1797 2833 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") }; 1798 1799 if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width()); 1800 if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height()); 2834 } 2835 2836 if(!helper[0].style.width || o.forceHelperSize) { 2837 helper.width(this.currentItem.width()); 2838 } 2839 if(!helper[0].style.height || o.forceHelperSize) { 2840 helper.height(this.currentItem.height()); 2841 } 1801 2842 1802 2843 return helper; … … 1805 2846 1806 2847 _adjustOffsetFromHelper: function(obj) { 1807 if (typeof obj == 'string') {1808 obj = obj.split( ' ');2848 if (typeof obj === "string") { 2849 obj = obj.split(" "); 1809 2850 } 1810 2851 if ($.isArray(obj)) { 1811 2852 obj = {left: +obj[0], top: +obj[1] || 0}; 1812 2853 } 1813 if ( 'left'in obj) {2854 if ("left" in obj) { 1814 2855 this.offset.click.left = obj.left + this.margins.left; 1815 2856 } 1816 if ( 'right'in obj) {2857 if ("right" in obj) { 1817 2858 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; 1818 2859 } 1819 if ( 'top'in obj) {2860 if ("top" in obj) { 1820 2861 this.offset.click.top = obj.top + this.margins.top; 1821 2862 } 1822 if ( 'bottom'in obj) {2863 if ("bottom" in obj) { 1823 2864 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; 1824 2865 } … … 1836 2877 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that 1837 2878 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag 1838 if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {2879 if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) { 1839 2880 po.left += this.scrollParent.scrollLeft(); 1840 2881 po.top += this.scrollParent.scrollTop(); 1841 2882 } 1842 2883 1843 if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information 1844 || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix 2884 // This needs to be actually done for all browsers, since pageX/pageY includes this information 2885 // with an ugly IE fix 2886 if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) { 1845 2887 po = { top: 0, left: 0 }; 2888 } 1846 2889 1847 2890 return { … … 1854 2897 _getRelativeOffset: function() { 1855 2898 1856 if(this.cssPosition == "relative") {2899 if(this.cssPosition === "relative") { 1857 2900 var p = this.currentItem.position(); 1858 2901 return { … … 1882 2925 _setContainment: function() { 1883 2926 1884 var o = this.options; 1885 if(o.containment == 'parent') o.containment = this.helper[0].parentNode; 1886 if(o.containment == 'document' || o.containment == 'window') this.containment = [ 1887 0 - this.offset.relative.left - this.offset.parent.left, 1888 0 - this.offset.relative.top - this.offset.parent.top, 1889 $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, 1890 ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top 1891 ]; 2927 var ce, co, over, 2928 o = this.options; 2929 if(o.containment === "parent") { 2930 o.containment = this.helper[0].parentNode; 2931 } 2932 if(o.containment === "document" || o.containment === "window") { 2933 this.containment = [ 2934 0 - this.offset.relative.left - this.offset.parent.left, 2935 0 - this.offset.relative.top - this.offset.parent.top, 2936 $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left, 2937 ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top 2938 ]; 2939 } 1892 2940 1893 2941 if(!(/^(document|window|parent)$/).test(o.containment)) { 1894 varce = $(o.containment)[0];1895 varco = $(o.containment).offset();1896 var over = ($(ce).css("overflow") != 'hidden');2942 ce = $(o.containment)[0]; 2943 co = $(o.containment).offset(); 2944 over = ($(ce).css("overflow") !== "hidden"); 1897 2945 1898 2946 this.containment = [ … … 1908 2956 _convertPositionTo: function(d, pos) { 1909 2957 1910 if(!pos) pos = this.position; 1911 var mod = d == "absolute" ? 1 : -1; 1912 var o = this.options, 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); 2958 if(!pos) { 2959 pos = this.position; 2960 } 2961 var mod = d === "absolute" ? 1 : -1, 2962 scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, 2963 scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); 1913 2964 1914 2965 return { 1915 2966 top: ( 1916 pos.top // The absolute mouse position1917 + this.offset.relative.top * mod// Only for relative positioned nodes: Relative offset from element to offset parent1918 + this.offset.parent.top * mod// The offsetParent's offset without borders (offset + border)1919 - ( ( this.cssPosition == 'fixed'? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)2967 pos.top + // The absolute mouse position 2968 this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent 2969 this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) 2970 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) 1920 2971 ), 1921 2972 left: ( 1922 pos.left // The absolute mouse position1923 + this.offset.relative.left * mod// Only for relative positioned nodes: Relative offset from element to offset parent1924 + this.offset.parent.left * mod// The offsetParent's offset without borders (offset + border)1925 - ( ( this.cssPosition == 'fixed'? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)2973 pos.left + // The absolute mouse position 2974 this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent 2975 this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) 2976 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) 1926 2977 ) 1927 2978 }; … … 1931 2982 _generatePosition: function(event) { 1932 2983 1933 var o = this.options, 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); 2984 var top, left, 2985 o = this.options, 2986 pageX = event.pageX, 2987 pageY = event.pageY, 2988 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); 1934 2989 1935 2990 // This is another very weird special case that only happens for relative elements: … … 1937 2992 // 2. and the scroll parent is the document or similar to the offset parent 1938 2993 // we have to refresh the relative offset during the scroll so there are no jumps 1939 if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {2994 if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) { 1940 2995 this.offset.relative = this._getRelativeOffset(); 1941 2996 } 1942 1943 var pageX = event.pageX;1944 var pageY = event.pageY;1945 2997 1946 2998 /* … … 1952 3004 1953 3005 if(this.containment) { 1954 if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; 1955 if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; 1956 if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; 1957 if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; 3006 if(event.pageX - this.offset.click.left < this.containment[0]) { 3007 pageX = this.containment[0] + this.offset.click.left; 3008 } 3009 if(event.pageY - this.offset.click.top < this.containment[1]) { 3010 pageY = this.containment[1] + this.offset.click.top; 3011 } 3012 if(event.pageX - this.offset.click.left > this.containment[2]) { 3013 pageX = this.containment[2] + this.offset.click.left; 3014 } 3015 if(event.pageY - this.offset.click.top > this.containment[3]) { 3016 pageY = this.containment[3] + this.offset.click.top; 3017 } 1958 3018 } 1959 3019 1960 3020 if(o.grid) { 1961 vartop = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];1962 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;1963 1964 varleft = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];1965 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;3021 top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; 3022 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; 3023 3024 left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; 3025 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; 1966 3026 } 1967 3027 … … 1970 3030 return { 1971 3031 top: ( 1972 pageY // The absolute mouse position1973 - this.offset.click.top// Click offset (relative to the element)1974 - this.offset.relative.top// Only for relative positioned nodes: Relative offset from element to offset parent1975 - this.offset.parent.top// The offsetParent's offset without borders (offset + border)1976 + ( ( this.cssPosition == 'fixed'? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))3032 pageY - // The absolute mouse position 3033 this.offset.click.top - // Click offset (relative to the element) 3034 this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent 3035 this.offset.parent.top + // The offsetParent's offset without borders (offset + border) 3036 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) 1977 3037 ), 1978 3038 left: ( 1979 pageX // The absolute mouse position1980 - this.offset.click.left// Click offset (relative to the element)1981 - this.offset.relative.left// Only for relative positioned nodes: Relative offset from element to offset parent1982 - this.offset.parent.left// The offsetParent's offset without borders (offset + border)1983 + ( ( this.cssPosition == 'fixed'? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))3039 pageX - // The absolute mouse position 3040 this.offset.click.left - // Click offset (relative to the element) 3041 this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent 3042 this.offset.parent.left + // The offsetParent's offset without borders (offset + border) 3043 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) 1984 3044 ) 1985 3045 }; … … 1989 3049 _rearrange: function(event, i, a, hardRefresh) { 1990 3050 1991 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));3051 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)); 1992 3052 1993 3053 //Various things done here to improve the performance: … … 2000 3060 2001 3061 this._delay(function() { 2002 if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove 3062 if(counter === this.counter) { 3063 this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove 3064 } 2003 3065 }); 2004 3066 … … 2010 3072 // We delay all events that have to be triggered to after the point where the placeholder has been removed and 2011 3073 // everything else normalized again 2012 var delayedTriggers = []; 3074 var i, 3075 delayedTriggers = []; 2013 3076 2014 3077 // We first have to update the dom position of the actual currentItem 2015 3078 // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) 2016 if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem); 3079 if(!this._noFinalSort && this.currentItem.parent().length) { 3080 this.placeholder.before(this.currentItem); 3081 } 2017 3082 this._noFinalSort = null; 2018 3083 2019 if(this.helper[0] == this.currentItem[0]) { 2020 for(var i in this._storedCSS) { 2021 if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = ''; 3084 if(this.helper[0] === this.currentItem[0]) { 3085 for(i in this._storedCSS) { 3086 if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") { 3087 this._storedCSS[i] = ""; 3088 } 2022 3089 } 2023 3090 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); … … 2026 3093 } 2027 3094 2028 if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); }); 2029 if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed 3095 if(this.fromOutside && !noPropagation) { 3096 delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); }); 3097 } 3098 if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) { 3099 delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed 3100 } 2030 3101 2031 3102 // Check if the items Container has Changed and trigger appropriate … … 2041 3112 2042 3113 //Post events to containers 2043 for (var i = this.containers.length - 1; i >= 0; i--){ 2044 if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i])); 3114 for (i = this.containers.length - 1; i >= 0; i--){ 3115 if(!noPropagation) { 3116 delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i])); 3117 } 2045 3118 if(this.containers[i].containerCache.over) { 2046 3119 delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i])); … … 2050 3123 2051 3124 //Do what was originally in plugins 2052 if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor 2053 if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity 2054 if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index 3125 if ( this.storedCursor ) { 3126 this.document.find( "body" ).css( "cursor", this.storedCursor ); 3127 this.storedStylesheet.remove(); 3128 } 3129 if(this._storedOpacity) { 3130 this.helper.css("opacity", this._storedOpacity); 3131 } 3132 if(this._storedZIndex) { 3133 this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex); 3134 } 2055 3135 2056 3136 this.dragging = false; … … 2058 3138 if(!noPropagation) { 2059 3139 this._trigger("beforeStop", event, this._uiHash()); 2060 for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events 3140 for (i=0; i < delayedTriggers.length; i++) { 3141 delayedTriggers[i].call(this, event); 3142 } //Trigger all delayed events 2061 3143 this._trigger("stop", event, this._uiHash()); 2062 3144 } … … 2066 3148 } 2067 3149 2068 if(!noPropagation) this._trigger("beforeStop", event, this._uiHash()); 3150 if(!noPropagation) { 3151 this._trigger("beforeStop", event, this._uiHash()); 3152 } 2069 3153 2070 3154 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! 2071 3155 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); 2072 3156 2073 if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null; 3157 if(this.helper[0] !== this.currentItem[0]) { 3158 this.helper.remove(); 3159 } 3160 this.helper = null; 2074 3161 2075 3162 if(!noPropagation) { 2076 for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events 3163 for (i=0; i < delayedTriggers.length; i++) { 3164 delayedTriggers[i].call(this, event); 3165 } //Trigger all delayed events 2077 3166 this._trigger("stop", event, this._uiHash()); 2078 3167 } … … 2117 3206 2118 3207 $.widget( "ui.accordion", { 2119 version: "1. 9.2",3208 version: "1.10.3", 2120 3209 options: { 2121 3210 active: 0, … … 2136 3225 2137 3226 _create: function() { 2138 var accordionId = this.accordionId = "ui-accordion-" + 2139 (this.element.attr( "id" ) || ++uid), 2140 options = this.options; 2141 3227 var options = this.options; 2142 3228 this.prevShow = this.prevHide = $(); 2143 this.element.addClass( "ui-accordion ui-widget ui-helper-reset" ); 2144 2145 this.headers = this.element.find( options.header ) 2146 .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" ); 2147 this._hoverable( this.headers ); 2148 this._focusable( this.headers ); 2149 2150 this.headers.next() 2151 .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ) 2152 .hide(); 3229 this.element.addClass( "ui-accordion ui-widget ui-helper-reset" ) 3230 // ARIA 3231 .attr( "role", "tablist" ); 2153 3232 2154 3233 // don't allow collapsible: false and active: false / null … … 2156 3235 options.active = 0; 2157 3236 } 3237 3238 this._processPanels(); 2158 3239 // handle negative values 2159 3240 if ( options.active < 0 ) { 2160 3241 options.active += this.headers.length; 2161 3242 } 2162 this.active = this._findActive( options.active ) 2163 .addClass( "ui-accordion-header-active ui-state-active" ) 2164 .toggleClass( "ui-corner-all ui-corner-top" ); 2165 this.active.next() 2166 .addClass( "ui-accordion-content-active" ) 2167 .show(); 2168 2169 this._createIcons(); 2170 this.refresh(); 2171 2172 // ARIA 2173 this.element.attr( "role", "tablist" ); 2174 2175 this.headers 2176 .attr( "role", "tab" ) 2177 .each(function( i ) { 2178 var header = $( this ), 2179 headerId = header.attr( "id" ), 2180 panel = header.next(), 2181 panelId = panel.attr( "id" ); 2182 if ( !headerId ) { 2183 headerId = accordionId + "-header-" + i; 2184 header.attr( "id", headerId ); 2185 } 2186 if ( !panelId ) { 2187 panelId = accordionId + "-panel-" + i; 2188 panel.attr( "id", panelId ); 2189 } 2190 header.attr( "aria-controls", panelId ); 2191 panel.attr( "aria-labelledby", headerId ); 2192 }) 2193 .next() 2194 .attr( "role", "tabpanel" ); 2195 2196 this.headers 2197 .not( this.active ) 2198 .attr({ 2199 "aria-selected": "false", 2200 tabIndex: -1 2201 }) 2202 .next() 2203 .attr({ 2204 "aria-expanded": "false", 2205 "aria-hidden": "true" 2206 }) 2207 .hide(); 2208 2209 // make sure at least one header is in the tab order 2210 if ( !this.active.length ) { 2211 this.headers.eq( 0 ).attr( "tabIndex", 0 ); 2212 } else { 2213 this.active.attr({ 2214 "aria-selected": "true", 2215 tabIndex: 0 2216 }) 2217 .next() 2218 .attr({ 2219 "aria-expanded": "true", 2220 "aria-hidden": "false" 2221 }); 2222 } 2223 2224 this._on( this.headers, { keydown: "_keydown" }); 2225 this._on( this.headers.next(), { keydown: "_panelKeyDown" }); 2226 this._setupEvents( options.event ); 3243 this._refresh(); 2227 3244 }, 2228 3245 … … 2230 3247 return { 2231 3248 header: this.active, 3249 panel: !this.active.length ? $() : this.active.next(), 2232 3250 content: !this.active.length ? $() : this.active.next() 2233 3251 }; … … 2331 3349 2332 3350 _keydown: function( event ) { 3351 /*jshint maxcomplexity:15*/ 2333 3352 if ( event.altKey || event.ctrlKey ) { 2334 3353 return; … … 2376 3395 2377 3396 refresh: function() { 2378 var maxHeight, overflow, 2379 heightStyle = this.options.heightStyle, 2380 parent = this.element.parent(); 2381 3397 var options = this.options; 3398 this._processPanels(); 3399 3400 // was collapsed or no panel 3401 if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) { 3402 options.active = false; 3403 this.active = $(); 3404 // active false only when collapsible is true 3405 } else if ( options.active === false ) { 3406 this._activate( 0 ); 3407 // was active, but active panel is gone 3408 } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { 3409 // all remaining panel are disabled 3410 if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) { 3411 options.active = false; 3412 this.active = $(); 3413 // activate previous panel 3414 } else { 3415 this._activate( Math.max( 0, options.active - 1 ) ); 3416 } 3417 // was active, active panel still exists 3418 } else { 3419 // make sure active index is correct 3420 options.active = this.headers.index( this.active ); 3421 } 3422 3423 this._destroyIcons(); 3424 3425 this._refresh(); 3426 }, 3427 3428 _processPanels: function() { 3429 this.headers = this.element.find( this.options.header ) 3430 .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" ); 3431 3432 this.headers.next() 3433 .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ) 3434 .filter(":not(.ui-accordion-content-active)") 3435 .hide(); 3436 }, 3437 3438 _refresh: function() { 3439 var maxHeight, 3440 options = this.options, 3441 heightStyle = options.heightStyle, 3442 parent = this.element.parent(), 3443 accordionId = this.accordionId = "ui-accordion-" + 3444 (this.element.attr( "id" ) || ++uid); 3445 3446 this.active = this._findActive( options.active ) 3447 .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" ) 3448 .removeClass( "ui-corner-all" ); 3449 this.active.next() 3450 .addClass( "ui-accordion-content-active" ) 3451 .show(); 3452 3453 this.headers 3454 .attr( "role", "tab" ) 3455 .each(function( i ) { 3456 var header = $( this ), 3457 headerId = header.attr( "id" ), 3458 panel = header.next(), 3459 panelId = panel.attr( "id" ); 3460 if ( !headerId ) { 3461 headerId = accordionId + "-header-" + i; 3462 header.attr( "id", headerId ); 3463 } 3464 if ( !panelId ) { 3465 panelId = accordionId + "-panel-" + i; 3466 panel.attr( "id", panelId ); 3467 } 3468 header.attr( "aria-controls", panelId ); 3469 panel.attr( "aria-labelledby", headerId ); 3470 }) 3471 .next() 3472 .attr( "role", "tabpanel" ); 3473 3474 this.headers 3475 .not( this.active ) 3476 .attr({ 3477 "aria-selected": "false", 3478 tabIndex: -1 3479 }) 3480 .next() 3481 .attr({ 3482 "aria-expanded": "false", 3483 "aria-hidden": "true" 3484 }) 3485 .hide(); 3486 3487 // make sure at least one header is in the tab order 3488 if ( !this.active.length ) { 3489 this.headers.eq( 0 ).attr( "tabIndex", 0 ); 3490 } else { 3491 this.active.attr({ 3492 "aria-selected": "true", 3493 tabIndex: 0 3494 }) 3495 .next() 3496 .attr({ 3497 "aria-expanded": "true", 3498 "aria-hidden": "false" 3499 }); 3500 } 3501 3502 this._createIcons(); 3503 3504 this._setupEvents( options.event ); 2382 3505 2383 3506 if ( heightStyle === "fill" ) { 2384 // IE 6 treats height like minHeight, so we need to turn off overflow2385 // in order to get a reliable height2386 // we use the minHeight support test because we assume that only2387 // browsers that don't support minHeight will treat height as minHeight2388 if ( !$.support.minHeight ) {2389 overflow = parent.css( "overflow" );2390 parent.css( "overflow", "hidden");2391 }2392 3507 maxHeight = parent.height(); 2393 3508 this.element.siblings( ":visible" ).each(function() { … … 2400 3515 maxHeight -= elem.outerHeight( true ); 2401 3516 }); 2402 if ( overflow ) {2403 parent.css( "overflow", overflow );2404 }2405 3517 2406 3518 this.headers.each(function() { … … 2447 3559 2448 3560 _setupEvents: function( event ) { 2449 var events = {}; 2450 if ( !event ) { 2451 return; 2452 } 2453 $.each( event.split(" "), function( index, eventName ) { 2454 events[ eventName ] = "_eventHandler"; 2455 }); 3561 var events = { 3562 keydown: "_keydown" 3563 }; 3564 if ( event ) { 3565 $.each( event.split(" "), function( index, eventName ) { 3566 events[ eventName ] = "_eventHandler"; 3567 }); 3568 } 3569 3570 this._off( this.headers.add( this.headers.next() ) ); 2456 3571 this._on( this.headers, events ); 3572 this._on( this.headers.next(), { keydown: "_panelKeyDown" }); 3573 this._hoverable( this.headers ); 3574 this._focusable( this.headers ); 2457 3575 }, 2458 3576 … … 2633 3751 }); 2634 3752 2635 2636 2637 // DEPRECATED2638 if ( $.uiBackCompat !== false ) {2639 // navigation options2640 (function( $, prototype ) {2641 $.extend( prototype.options, {2642 navigation: false,2643 navigationFilter: function() {2644 return this.href.toLowerCase() === location.href.toLowerCase();2645 }2646 });2647 2648 var _create = prototype._create;2649 prototype._create = function() {2650 if ( this.options.navigation ) {2651 var that = this,2652 headers = this.element.find( this.options.header ),2653 content = headers.next(),2654 current = headers.add( content )2655 .find( "a" )2656 .filter( this.options.navigationFilter )2657 [ 0 ];2658 if ( current ) {2659 headers.add( content ).each( function( index ) {2660 if ( $.contains( this, current ) ) {2661 that.options.active = Math.floor( index / 2 );2662 return false;2663 }2664 });2665 }2666 }2667 _create.call( this );2668 };2669 }( jQuery, jQuery.ui.accordion.prototype ) );2670 2671 // height options2672 (function( $, prototype ) {2673 $.extend( prototype.options, {2674 heightStyle: null, // remove default so we fall back to old values2675 autoHeight: true, // use heightStyle: "auto"2676 clearStyle: false, // use heightStyle: "content"2677 fillSpace: false // use heightStyle: "fill"2678 });2679 2680 var _create = prototype._create,2681 _setOption = prototype._setOption;2682 2683 $.extend( prototype, {2684 _create: function() {2685 this.options.heightStyle = this.options.heightStyle ||2686 this._mergeHeightStyle();2687 2688 _create.call( this );2689 },2690 2691 _setOption: function( key ) {2692 if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {2693 this.options.heightStyle = this._mergeHeightStyle();2694 }2695 _setOption.apply( this, arguments );2696 },2697 2698 _mergeHeightStyle: function() {2699 var options = this.options;2700 2701 if ( options.fillSpace ) {2702 return "fill";2703 }2704 2705 if ( options.clearStyle ) {2706 return "content";2707 }2708 2709 if ( options.autoHeight ) {2710 return "auto";2711 }2712 }2713 });2714 }( jQuery, jQuery.ui.accordion.prototype ) );2715 2716 // icon options2717 (function( $, prototype ) {2718 $.extend( prototype.options.icons, {2719 activeHeader: null, // remove default so we fall back to old values2720 headerSelected: "ui-icon-triangle-1-s"2721 });2722 2723 var _createIcons = prototype._createIcons;2724 prototype._createIcons = function() {2725 if ( this.options.icons ) {2726 this.options.icons.activeHeader = this.options.icons.activeHeader ||2727 this.options.icons.headerSelected;2728 }2729 _createIcons.call( this );2730 };2731 }( jQuery, jQuery.ui.accordion.prototype ) );2732 2733 // expanded active option, activate method2734 (function( $, prototype ) {2735 prototype.activate = prototype._activate;2736 2737 var _findActive = prototype._findActive;2738 prototype._findActive = function( index ) {2739 if ( index === -1 ) {2740 index = false;2741 }2742 if ( index && typeof index !== "number" ) {2743 index = this.headers.index( this.headers.filter( index ) );2744 if ( index === -1 ) {2745 index = false;2746 }2747 }2748 return _findActive.call( this, index );2749 };2750 }( jQuery, jQuery.ui.accordion.prototype ) );2751 2752 // resize method2753 jQuery.ui.accordion.prototype.resize = jQuery.ui.accordion.prototype.refresh;2754 2755 // change events2756 (function( $, prototype ) {2757 $.extend( prototype.options, {2758 change: null,2759 changestart: null2760 });2761 2762 var _trigger = prototype._trigger;2763 prototype._trigger = function( type, event, data ) {2764 var ret = _trigger.apply( this, arguments );2765 if ( !ret ) {2766 return false;2767 }2768 2769 if ( type === "beforeActivate" ) {2770 ret = _trigger.call( this, "changestart", event, {2771 oldHeader: data.oldHeader,2772 oldContent: data.oldPanel,2773 newHeader: data.newHeader,2774 newContent: data.newPanel2775 });2776 } else if ( type === "activate" ) {2777 ret = _trigger.call( this, "change", event, {2778 oldHeader: data.oldHeader,2779 oldContent: data.oldPanel,2780 newHeader: data.newHeader,2781 newContent: data.newPanel2782 });2783 }2784 return ret;2785 };2786 }( jQuery, jQuery.ui.accordion.prototype ) );2787 2788 // animated option2789 // NOTE: this only provides support for "slide", "bounceslide", and easings2790 // not the full $.ui.accordion.animations API2791 (function( $, prototype ) {2792 $.extend( prototype.options, {2793 animate: null,2794 animated: "slide"2795 });2796 2797 var _create = prototype._create;2798 prototype._create = function() {2799 var options = this.options;2800 if ( options.animate === null ) {2801 if ( !options.animated ) {2802 options.animate = false;2803 } else if ( options.animated === "slide" ) {2804 options.animate = 300;2805 } else if ( options.animated === "bounceslide" ) {2806 options.animate = {2807 duration: 200,2808 down: {2809 easing: "easeOutBounce",2810 duration: 10002811 }2812 };2813 } else {2814 options.animate = options.animated;2815 }2816 }2817 2818 _create.call( this );2819 };2820 }( jQuery, jQuery.ui.accordion.prototype ) );2821 }2822 2823 3753 })( jQuery ); -
plugins/widgets/dragdrop.js
r0 r1648 1 ToolMan._coordinatesFactory.inside = function(item,container) { 2 var iTL = this.topLeftOffset(item); 3 var iBR = this.bottomRightOffset(item); 4 var cTL = this.topLeftOffset(container); 5 var cBR = this.bottomRightOffset(container); 1 $(function() { 6 2 7 return (iTL.x >= cTL.x && iTL.x <= cBR.x && iTL.y >= cTL.y && iTL.y <= cBR.y) 8 || (iBR.x >= cTL.x && iBR.x <= cBR.x && iBR.y >= cTL.y && iBR.y <= cBR.y); 9 } 10 11 ToolMan._dragdropFactory = { 12 firstContainer: null, 13 lastContainer: null, 3 // clean 4 $('.js-remove').remove(); 5 $('.js-hide').hide(); 6 $('.widgetSettings').hide(); 14 7 15 makeDragable: function(item) { 16 var group = ToolMan.drag().createSimpleGroup(item); 17 group.register('dragstart',this._onDragStart); 18 group.register('dragmove', this._onDragMove); 19 group.register('dragend', this._onDragEnd); 20 21 item.isOutside = false; 22 item.started = false; 23 24 return group; 25 }, 8 // move 9 $( ".connected" ).sortable({ 10 axis: "y", 11 connectWith: ".connected", 12 cursor: "move", 13 stop: function( event, ui ) { 14 $('.connected').each(function(){ 15 if( $(this).find('li').length == 0 ) { 16 $(this).parents('.widgets').find('.empty-widgets').show(); 17 } else { 18 $(this).parents('.widgets').find('.empty-widgets').hide(); 19 } 20 }); 21 }//, 22 //change: function( event, ui ) { 23 //ui.helper.css('height', $('#dndnav .widget-name').css('height')); 24 //} 25 }); 26 26 27 makeListContainer: function(list,name) { 28 // each container becomes a linked list node 29 if (this.firstContainer == null) { 30 this.firstContainer = this.lastContainer = list; 31 list.previousContainer = null; 32 list.nextContainer = null; 33 } else { 34 list.previousContainer = this.lastContainer; 35 list.nextContainer = null; 36 this.lastContainer.nextContainer = list; 37 this.lastContainer = list; 38 } 39 40 var helpers = ToolMan.helpers(); 41 var coordinates = ToolMan.coordinates(); 42 43 //var children = list.childNodes; 44 var items = new Array(); 45 for (var i=0; i<list.childNodes.length; i++) { 46 if (list.childNodes[i].nodeType == 1 && 47 list.childNodes[i].nodeName.toLowerCase() == name.toLowerCase()) { 48 items.push(list.childNodes[i]); 49 } 50 } 51 52 // these functions are called when an item is draged over 53 // a container or out of a container bounds. onDragOut 54 // is also called when the drag ends with an item having 55 // been added to the container 56 list.onDragOver = new Function(); 57 list.onDragOut = new Function(); 58 list.onDragEnd = new Function(); 59 60 if (list.factory == undefined) { 61 list.factory = false; 62 } 63 64 var This = this; 65 helpers.map(items, function(item) { 66 var dragGroup = This.makeDragable(item); 67 dragGroup.setThreshold(4); 68 }); 69 for (var i = 2, n = arguments.length; i < n; i++) { 70 helpers.map(items, arguments[i]); 71 } 72 }, 27 // add 28 $( "#widgets > li" ).draggable({ 29 connectToSortable: ".connected", 30 helper: "clone", 31 revert: "invalid", 32 cursor: "move", 33 start: function( event, ui ) { 34 ui.helper.css({'width': $('#widgets > li').css('width')}); 35 //ui.helper.css({'min-height': $('#dndnav .widget-name').css('height')}); 36 //ui.helper.find('.form-note').hide(); 37 //ui.helper.find('.widget-name').css({'min-height': $('#dndnav .widget-name').css('height')}); 38 }/*, 39 stop: function( event, ui ) { 40 $('.empty-widgets').css('display', 'none'); 41 }*/ 42 }); 73 43 74 _onDragStart: function(dragEvent) { 75 var container = ToolMan._dragdropFactory.firstContainer; 76 var item = dragEvent.group.element; 77 var coordinates = ToolMan.coordinates(); 78 79 // Factory is a sort of assembly pieces, we want to keep them 80 if (item.parentNode.factory) { 81 var origin = item.cloneNode(true); 82 item.parentNode.insertBefore(origin,item.nextSibling); 83 ToolMan._dragdropFactory.makeDragable(origin); 84 } 85 86 while (container != null) { 87 container.topLeft = coordinates.topLeftOffset(container); 88 container.bottomRight = coordinates.bottomRightOffset(container); 89 container = container.nextContainer; 90 } 91 92 // item starts out over current parent 93 item.started = true; 94 item.parentNode.onDragOver(); 95 }, 44 $( "#widgets, .connected" ).disableSelection(); 96 45 97 _onDragMove: function(dragEvent) { 98 var helpers = ToolMan.helpers(); 99 var coordinates = ToolMan.coordinates(); 100 101 var item = dragEvent.group.element; 102 var xmouse = dragEvent.transformedMouseOffset; 103 var moveTo = null; 104 105 // Check if we are nowhere 106 if (item.isOutside) { 107 var container = ToolMan._dragdropFactory.firstContainer; 108 while (container != null) { 109 if (coordinates.inside(item,container) && !container.factory) { 110 container.onDragOver(); 111 item.isOutside = false; 112 113 // since isOutside was true, the current parent is a 114 // temporary clone of some previous container node and 115 // it needs to be removed from the document 116 var tempParent = item.parentNode; 117 tempParent.removeChild(item); 118 container.appendChild(item); 119 //tempParent.parentNode.removeChild(tempParent); 120 121 break; 122 } 123 container = container.nextContainer; 124 } 125 126 if (this.isOutside) { 127 return; 128 } 129 } 130 // Outside the parent node 131 else if (!coordinates.inside(item,item.parentNode)) { 132 item.parentNode.onDragOut(); 133 item.isOutside = true; 134 var container = ToolMan._dragdropFactory.firstContainer; 135 while (container != null) { 136 if (coordinates.inside(item,container) && !container.factory) { 137 container.onDragOver(); 138 item.isOutside = false; 139 container.appendChild(item); 140 break; 141 } 142 container = container.nextContainer; 143 } 144 // if we're not in any container now, make a temporary clone of 145 // the previous container node and add it to the document 146 if (this.isOutside) { 147 var tempParent = item.parentNode.cloneNode(false); 148 item.parentNode.removeChild(item); 149 tempParent.appendChild(item); 150 document.body.appendChild(tempParent); 151 return; 152 } 153 } 154 155 // if we get here, we're inside some container bounds, so we do 156 // everything the original dragsort script did to swap us into the 157 // correct position 158 159 if (item.parentNode.factory) { 160 return; 161 } 162 163 var moveTo = null 164 165 var previous = helpers.previousItem(item, item.nodeName) 166 while (previous != null) { 167 var bottomRight = coordinates.bottomRightOffset(previous) 168 if (xmouse.y <= bottomRight.y && xmouse.x <= bottomRight.x) { 169 moveTo = previous 170 } 171 previous = helpers.previousItem(previous, item.nodeName) 172 } 173 if (moveTo != null) { 174 helpers.moveBefore(item, moveTo) 175 return 176 } 177 178 var next = helpers.nextItem(item, item.nodeName) 179 while (next != null) { 180 var topLeft = coordinates.topLeftOffset(next) 181 if (topLeft.y <= xmouse.y && topLeft.x <= xmouse.x) { 182 moveTo = next 183 } 184 next = helpers.nextItem(next, item.nodeName) 185 } 186 if (moveTo != null) { 187 helpers.moveBefore(item, helpers.nextItem(moveTo, item.nodeName)) 188 return 189 } 190 }, 191 192 _onDragEnd: function(dragEvent) { 193 var item = dragEvent.group.element; 194 195 if (!item.started) { 196 return; 197 } 198 199 if (item.isOutside || item.parentNode.factory) { 200 item.parentNode.removeChild(item); 201 return; 202 } 203 204 item.parentNode.onDragEnd.call(item); 205 ToolMan.coordinates().create(0, 0).reposition(dragEvent.group.element); 206 } 207 }; 208 209 ToolMan.dragdrop = function() { 210 return ToolMan._dragdropFactory; 211 }; 46 }); -
plugins/widgets/index.php
r1518 r1648 165 165 <?php echo file_get_contents(dirname(__FILE__).'/style.css'); ?> 166 166 </style> 167 <script type="text/javascript" src="js/tool-man/core.js"></script> 168 <script type="text/javascript" src="js/tool-man/events.js"></script> 169 <script type="text/javascript" src="js/tool-man/css.js"></script> 170 <script type="text/javascript" src="js/tool-man/coordinates.js"></script> 171 <script type="text/javascript" src="js/tool-man/drag.js"></script> 167 <script type="text/javascript" src="js/jquery/jquery-ui.custom.js"></script> 168 <script type="text/javascript" src="index.php?pf=widgets/widgets.js"></script> 172 169 <?php 173 170 $core->auth->user_prefs->addWorkspace('accessibility'); … … 177 174 <script type="text/javascript" src="index.php?pf=widgets/dragdrop.js"></script> 178 175 <?php endif; ?> 179 <script type="text/javascript" src="index.php?pf=widgets/widgets.js"></script>180 176 <script type="text/javascript"> 181 177 //<![CDATA[ … … 199 195 '<h3>'.__('Available widgets').'</h3>'. 200 196 '<p>'.__('Move widgets from this list to one of the sidebars.').'</p>'. 201 '< divid="widgets">';197 '<ul id="widgets">'; 202 198 203 199 $j = 0; 204 200 foreach ($__widgets->elements(true) as $w) { 205 201 echo 206 '< div>'.form::hidden(array('w[void][0][id]'),html::escapeHTML($w->id())).202 '<li>'.form::hidden(array('w[void][0][id]'),html::escapeHTML($w->id())). 207 203 '<p class="widget-name">'.form::field(array('w[void][0][order]'),2,3,0,'hideControl').' '. 208 204 $w->name().($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : '').'</p>'. … … 210 206 form::combo(array('addw['.$w->id().']'),$append_combo).'</p>'. 211 207 '<div class="widgetSettings">'.$w->formSettings('w[void][0]',$j).'</div>'. 212 '</ div>';208 '</li>'; 213 209 $j++; 214 210 } 215 211 216 212 echo 217 '</ div>'.218 '<p><input type="submit" class="js-remove" name="append" value="'.__('Add widgets to sidebars').'" />'.219 $core->formNonce().'</p>'.213 '</ul>'. 214 $core->formNonce(). 215 '<p class="js-remove"><input type="submit" name="append" value="'.__('Add widgets to sidebars').'" /></p>'. 220 216 '</form>'; 221 217 … … 316 312 function sidebarWidgets($id,$title,$widgets,$pr,$default_widgets,&$j) 317 313 { 318 $res = '<h3>'.$title.'</h3> <div id="'.$id.'">';314 $res = '<h3>'.$title.'</h3>'; 319 315 320 316 if (!($widgets instanceof dcWidgets)) … … 325 321 if ($widgets->isEmpty()) { 326 322 $res .= '<p class="empty-widgets">'.__('No widget.').'</p>'; 327 } 323 } else { 324 $res .= '<p class="empty-widgets" style="display: none;">'.__('No widget.').'</p>'; 325 } 326 327 $res .= '<ul id="'.$id.'" class="connected">'; 328 328 329 329 $i = 0; … … 333 333 334 334 $res .= 335 '< div>'.form::hidden(array($iname.'[id]'),html::escapeHTML($w->id())).335 '<li>'.form::hidden(array($iname.'[id]'),html::escapeHTML($w->id())). 336 336 '<p class="widget-name">'.form::field(array($iname.'[order]'),2,3,(string) $i,'js-hide','',0,'title="'.__('order').'"').' '. 337 337 $w->name().($w->desc() != '' ? ' <!-- <span class="form-note">'.__($w->desc()).'</span> -->' : '').'</p>'. … … 340 340 '</label></p>'. 341 341 '<div class="widgetSettings">'.$w->formSettings($iname,$j).'</div>'. 342 '</ div>';342 '</li>'; 343 343 344 344 $i++; … … 346 346 } 347 347 348 $res .= '</ div>';348 $res .= '</ul>'; 349 349 350 350 return $res; -
plugins/widgets/style.css
r1526 r1648 6 6 margin: 0 1% 0 0; 7 7 } 8 #widgets > div{8 #widgets > li { 9 9 border: 1px solid #ccc; 10 10 margin-bottom: .5em; … … 12 12 min-height: 3em; 13 13 padding: 0 0 4px 0; 14 list-style: none; 14 15 } 15 16 #widgets .widget-name, #widgets .js-remove { … … 41 42 padding: 1em 0; 42 43 } 43 #dndnav > div, #dndextra > div, #dndcustom > div{44 #dndnav > li, #dndextra > li, #dndcustom > li { 44 45 padding: O; 45 46 border: 1px solid #999; 46 47 margin-bottom: 1em; 48 list-style: none; 47 49 } 50 #dndnav .form-note, #dndextra .form-note, #dndcustom .form-note { 51 display: none; 52 } 53 48 54 49 55 .widget-name { -
plugins/widgets/widgets.js
r665 r1648 1 var dragdrop = ToolMan.dragdrop(); 2 $(function() { 1 dotclear.postExpander = function(line) { 2 var title = $(line).find('.widget-name'); 3 4 var img = document.createElement('img'); 5 img.src = dotclear.img_plus_src; 6 img.alt = dotclear.img_plus_alt; 7 img.className = 'expand'; 8 $(img).css('cursor','pointer'); 9 img.line = line; 10 img.onclick = function() { dotclear.viewPostContent(this.line); }; 11 12 title.prepend(img); 13 }; 14 15 dotclear.viewPostContent = function(line,action) { 16 var action = action || 'toogle'; 17 var img = $(line).find('.expand'); 18 var isopen = img.attr('alt') == dotclear.img_plus_alt; 19 20 if( action == 'close' || ( action == 'toogle' && !isopen ) ) { 21 $(line).find('.widgetSettings').hide(); 22 img.attr('src', dotclear.img_plus_src); 23 img.attr('alt', dotclear.img_plus_alt); 24 } else if ( action == 'open' || ( action == 'toogle' && isopen ) ) { 25 $(line).find('.widgetSettings').show(); 26 img.attr('src', dotclear.img_minus_src); 27 img.attr('alt', dotclear.img_minus_alt); 28 } 29 30 }; 31 32 $(function() { 3 33 $('input[name="wreset"]').click(function() { 4 34 return window.confirm(dotclear.msg.confirm_widgets_reset); 5 35 }); 36 37 $('#dndnav > li, #dndextra > li, #dndcustom > li').each(function() { 38 dotclear.postExpander(this); 39 dotclear.viewPostContent(this, 'close'); 40 }); 41 6 42 }); 7 8 $(function() { 9 var widgets = document.getElementById('widgets'); 43 44 /*var widgets = document.getElementById('widgets'); 10 45 var w_nav = document.getElementById('dndnav'); 11 46 var w_ext = document.getElementById('dndextra'); 12 47 var w_custom = document.getElementById('dndcustom'); 13 48 14 w_nav.className = 'hideControls';15 w_ext.className = 'hideControls';16 w_custom.className = 'hideControls';49 $('#dndnav').addClass('hideControls'); 50 $('#dndextra').addClass('hideControls'); 51 $('#dndcustom').addClass('hideControls'); 17 52 18 53 removeElements(document.getElementById('listWidgets'),'input'); … … 28 63 configControls(w_ext); 29 64 configControls(w_custom); 30 31 dragdrop.makeListContainer(widgets,'div',setHandle);32 if (!document.all) { widgets.factory = true; }33 dragdrop.makeListContainer(w_nav,'div',setHandle);34 w_nav.onDragEnd = navDragEnd;35 dragdrop.makeListContainer(w_ext,'div',setHandle);36 w_ext.onDragEnd = extraDragEnd;37 dragdrop.makeListContainer(w_custom,'div',setHandle);38 w_custom.onDragEnd = customDragEnd;39 65 40 66 // Helper to remove some elements … … 166 192 } 167 193 } 168 169 function setHandle(item) {170 //var handle = item.getElementsByTagName('h4').item(0);171 var handle = $('p.widget-name',item).get(0);172 $(handle).addClass('handler');173 item.toolManDragGroup.setHandle(handle);174 }175 194 }); 176 195 … … 225 244 }); 226 245 }); 227 } 246 }*/
Note: See TracChangeset
for help on using the changeset viewer.