*\r
* Revision: $Id: ui.accordion.js 5656 2008-05-21 19:35:33Z braeker $\r
*/\r
-\r
;(function($) {\r
\r
- $.widget("ui.accordion", {\r
- init: function() {\r
- var options = this.options;\r
- \r
- if ( options.navigation ) {\r
- var current = this.element.find("a").filter(options.navigationFilter);\r
- if ( current.length ) {\r
- if ( current.filter(options.header).length ) {\r
- options.active = current;\r
- } else {\r
- options.active = current.parent().parent().prev();\r
- current.addClass("current");\r
- }\r
- }\r
- }\r
- \r
- // calculate active if not specified, using the first header\r
- options.headers = this.element.find(options.header);\r
- options.active = findActive(options.headers, options.active);\r
- \r
- // IE7-/Win - Extra vertical space in Lists fixed\r
- if ($.browser.msie) {\r
- this.element.find('a').css('zoom', '1');\r
- }\r
- \r
- if (!this.element.hasClass("ui-accordion")) {\r
- this.element.addClass("ui-accordion");\r
- $("<span class='ui-accordion-left'/>").insertBefore(options.headers);\r
- $("<span class='ui-accordion-right'/>").appendTo(options.headers);\r
- options.headers.addClass("ui-accordion-header").attr("tabindex", "0");\r
- }\r
- \r
- var maxHeight;\r
- if ( options.fillSpace ) {\r
- maxHeight = this.element.parent().height();\r
- options.headers.each(function() {\r
- maxHeight -= $(this).outerHeight();\r
- });\r
- var maxPadding = 0;\r
- options.headers.next().each(function() {\r
- maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());\r
- }).height(maxHeight - maxPadding);\r
- } else if ( options.autoHeight ) {\r
- maxHeight = 0;\r
- options.headers.next().each(function() {\r
- maxHeight = Math.max(maxHeight, $(this).outerHeight());\r
- }).height(maxHeight);\r
- }\r
+$.widget("ui.accordion", {\r
+ init: function() {\r
+ var options = this.options;\r
\r
- options.headers\r
- .not(options.active || "")\r
- .next()\r
- .hide();\r
- options.active.parent().andSelf().addClass(options.selectedClass);\r
- \r
- if (options.event) {\r
- this.element.bind((options.event) + ".accordion", clickHandler);\r
- }\r
- },\r
- activate: function(index) {\r
- // call clickHandler with custom event\r
- clickHandler.call(this.element[0], {\r
- target: findActive( this.options.headers, index )[0]\r
- });\r
- },\r
- destroy: function() {\r
- this.options.headers.next().css("display", "");\r
- if ( this.options.fillSpace || this.options.autoHeight ) {\r
- this.options.headers.next().css("height", "");\r
+ if ( options.navigation ) {\r
+ var current = this.element.find("a").filter(options.navigationFilter);\r
+ if ( current.length ) {\r
+ if ( current.filter(options.header).length ) {\r
+ options.active = current;\r
+ } else {\r
+ options.active = current.parent().parent().prev();\r
+ current.addClass("current");\r
+ }\r
}\r
- $.removeData(this.element[0], "accordion");\r
- this.element.removeClass("ui-accordion").unbind(".accordion");\r
}\r
- });\r
- \r
- function scopeCallback(callback, scope) {\r
- return function() {\r
- return callback.apply(scope, arguments);\r
- };\r
- };\r
- \r
- function completed(cancel) {\r
- // if removed while animated data can be empty\r
- if (!$.data(this, "accordion")) {\r
- return;\r
+ \r
+ // calculate active if not specified, using the first header\r
+ options.headers = this.element.find(options.header);\r
+ options.active = findActive(options.headers, options.active);\r
+ \r
+ // IE7-/Win - Extra vertical space in Lists fixed\r
+ if ($.browser.msie) {\r
+ this.element.find('a').css('zoom', '1');\r
}\r
\r
- var instance = $.data(this, "accordion");\r
- var options = instance.options;\r
- options.running = cancel ? 0 : --options.running;\r
- if ( options.running ) {\r
- return;\r
+ if (!this.element.hasClass("ui-accordion")) {\r
+ this.element.addClass("ui-accordion");\r
+ $("<span class='ui-accordion-left'/>").insertBefore(options.headers);\r
+ $("<span class='ui-accordion-right'/>").appendTo(options.headers);\r
+ options.headers.addClass("ui-accordion-header").attr("tabindex", "0");\r
}\r
- if ( options.clearStyle ) {\r
- options.toShow.add(options.toHide).css({\r
- height: "",\r
- overflow: ""\r
+ \r
+ var maxHeight;\r
+ if ( options.fillSpace ) {\r
+ maxHeight = this.element.parent().height();\r
+ options.headers.each(function() {\r
+ maxHeight -= $(this).outerHeight();\r
});\r
+ var maxPadding = 0;\r
+ options.headers.next().each(function() {\r
+ maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());\r
+ }).height(maxHeight - maxPadding);\r
+ } else if ( options.autoHeight ) {\r
+ maxHeight = 0;\r
+ options.headers.next().each(function() {\r
+ maxHeight = Math.max(maxHeight, $(this).outerHeight());\r
+ }).height(maxHeight);\r
}\r
- $(this).triggerHandler("accordionchange", [options.data], options.change);\r
- }\r
\r
- function toggle(toShow, toHide, data, clickedActive, down) {\r
- var options = $.data(this, "accordion").options;\r
- options.toShow = toShow;\r
- options.toHide = toHide;\r
- options.data = data;\r
- var complete = scopeCallback(completed, this);\r
- \r
- // count elements to animate\r
- options.running = toHide.size() === 0 ? toShow.size() : toHide.size();\r
+ options.headers\r
+ .not(options.active || "")\r
+ .next()\r
+ .hide();\r
+ options.active.parent().andSelf().addClass(options.selectedClass);\r
\r
- if ( options.animated ) {\r
- if ( !options.alwaysOpen && clickedActive ) {\r
- $.ui.accordion.animations[options.animated]({\r
- toShow: jQuery([]),\r
- toHide: toHide,\r
- complete: complete,\r
- down: down,\r
- autoHeight: options.autoHeight\r
- });\r
- } else {\r
- $.ui.accordion.animations[options.animated]({\r
- toShow: toShow,\r
- toHide: toHide,\r
- complete: complete,\r
- down: down,\r
- autoHeight: options.autoHeight\r
- });\r
- }\r
- } else {\r
- if ( !options.alwaysOpen && clickedActive ) {\r
- toShow.toggle();\r
- } else {\r
- toHide.hide();\r
- toShow.show();\r
- }\r
- complete(true);\r
+ if (options.event) {\r
+ this.element.bind((options.event) + ".accordion", clickHandler);\r
+ }\r
+ },\r
+ activate: function(index) {\r
+ // call clickHandler with custom event\r
+ clickHandler.call(this.element[0], {\r
+ target: findActive( this.options.headers, index )[0]\r
+ });\r
+ },\r
+ destroy: function() {\r
+ this.options.headers.next().css("display", "");\r
+ if ( this.options.fillSpace || this.options.autoHeight ) {\r
+ this.options.headers.next().css("height", "");\r
}\r
+ $.removeData(this.element[0], "accordion");\r
+ this.element.removeClass("ui-accordion").unbind(".accordion");\r
+ }\r
+});\r
+\r
+function scopeCallback(callback, scope) {\r
+ return function() {\r
+ return callback.apply(scope, arguments);\r
+ };\r
+};\r
+\r
+function completed(cancel) {\r
+ // if removed while animated data can be empty\r
+ if (!$.data(this, "accordion")) {\r
+ return;\r
}\r
\r
- function clickHandler(event) {\r
- var options = $.data(this, "accordion").options;\r
- if (options.disabled) {\r
- return false;\r
- }\r
- \r
- // called only when using activate(false) to close all parts programmatically\r
- if ( !event.target && !options.alwaysOpen ) {\r
- options.active.parent().andSelf().toggleClass(options.selectedClass);\r
- var toHide = options.active.next(),\r
- data = {\r
- instance: this,\r
- options: options,\r
- newHeader: jQuery([]),\r
- oldHeader: options.active,\r
- newContent: jQuery([]),\r
- oldContent: toHide\r
- },\r
- toShow = (options.active = $([]));\r
- toggle.call(this, toShow, toHide, data );\r
- return false;\r
- }\r
- // get the click target\r
- var clicked = $(event.target);\r
- \r
- // due to the event delegation model, we have to check if one\r
- // of the parent elements is our actual header, and find that\r
- if ( clicked.parents(options.header).length ) {\r
- while ( !clicked.is(options.header) ) {\r
- clicked = clicked.parent();\r
- }\r
- }\r
- \r
- var clickedActive = clicked[0] == options.active[0];\r
- \r
- // if animations are still active, or the active header is the target, ignore click\r
- if (options.running || (options.alwaysOpen && clickedActive)) {\r
- return false;\r
+ var instance = $.data(this, "accordion");\r
+ var options = instance.options;\r
+ options.running = cancel ? 0 : --options.running;\r
+ if ( options.running ) {\r
+ return;\r
+ }\r
+ if ( options.clearStyle ) {\r
+ options.toShow.add(options.toHide).css({\r
+ height: "",\r
+ overflow: ""\r
+ });\r
+ }\r
+ $(this).triggerHandler("accordionchange", [options.data], options.change);\r
+}\r
+\r
+function toggle(toShow, toHide, data, clickedActive, down) {\r
+ var options = $.data(this, "accordion").options;\r
+ options.toShow = toShow;\r
+ options.toHide = toHide;\r
+ options.data = data;\r
+ var complete = scopeCallback(completed, this);\r
+ \r
+ // count elements to animate\r
+ options.running = toHide.size() === 0 ? toShow.size() : toHide.size();\r
+ \r
+ if ( options.animated ) {\r
+ if ( !options.alwaysOpen && clickedActive ) {\r
+ $.ui.accordion.animations[options.animated]({\r
+ toShow: jQuery([]),\r
+ toHide: toHide,\r
+ complete: complete,\r
+ down: down,\r
+ autoHeight: options.autoHeight\r
+ });\r
+ } else {\r
+ $.ui.accordion.animations[options.animated]({\r
+ toShow: toShow,\r
+ toHide: toHide,\r
+ complete: complete,\r
+ down: down,\r
+ autoHeight: options.autoHeight\r
+ });\r
}\r
- if (!clicked.is(options.header)) {\r
- return;\r
+ } else {\r
+ if ( !options.alwaysOpen && clickedActive ) {\r
+ toShow.toggle();\r
+ } else {\r
+ toHide.hide();\r
+ toShow.show();\r
}\r
- \r
- // switch classes\r
+ complete(true);\r
+ }\r
+}\r
+\r
+function clickHandler(event) {\r
+ var options = $.data(this, "accordion").options;\r
+ if (options.disabled) {\r
+ return false;\r
+ }\r
+ \r
+ // called only when using activate(false) to close all parts programmatically\r
+ if ( !event.target && !options.alwaysOpen ) {\r
options.active.parent().andSelf().toggleClass(options.selectedClass);\r
- if ( !clickedActive ) {\r
- clicked.parent().andSelf().addClass(options.selectedClass);\r
- }\r
- \r
- // find elements to show and hide\r
- var toShow = clicked.next(),\r
- toHide = options.active.next(),\r
- //data = [clicked, options.active, toShow, toHide],\r
+ var toHide = options.active.next(),\r
data = {\r
instance: this,\r
options: options,\r
- newHeader: clicked,\r
+ newHeader: jQuery([]),\r
oldHeader: options.active,\r
- newContent: toShow,\r
+ newContent: jQuery([]),\r
oldContent: toHide\r
},\r
- down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );\r
- \r
- options.active = clickedActive ? $([]) : clicked;\r
- toggle.call(this, toShow, toHide, data, clickedActive, down );\r
+ toShow = (options.active = $([]));\r
+ toggle.call(this, toShow, toHide, data );\r
+ return false;\r
+ }\r
+ // get the click target\r
+ var clicked = $(event.target);\r
+ \r
+ // due to the event delegation model, we have to check if one\r
+ // of the parent elements is our actual header, and find that\r
+ if ( clicked.parents(options.header).length ) {\r
+ while ( !clicked.is(options.header) ) {\r
+ clicked = clicked.parent();\r
+ }\r
+ }\r
+ \r
+ var clickedActive = clicked[0] == options.active[0];\r
\r
+ // if animations are still active, or the active header is the target, ignore click\r
+ if (options.running || (options.alwaysOpen && clickedActive)) {\r
return false;\r
- };\r
+ }\r
+ if (!clicked.is(options.header)) {\r
+ return;\r
+ }\r
\r
- function findActive(headers, selector) {\r
- return selector != undefined\r
- ? typeof selector == "number"\r
- ? headers.filter(":eq(" + selector + ")")\r
- : headers.not(headers.not(selector))\r
- : selector === false\r
- ? $([])\r
- : headers.filter(":eq(0)");\r
+ // switch classes\r
+ options.active.parent().andSelf().toggleClass(options.selectedClass);\r
+ if ( !clickedActive ) {\r
+ clicked.parent().andSelf().addClass(options.selectedClass);\r
}\r
\r
- $.extend($.ui.accordion, {\r
- defaults: {\r
- selectedClass: "selected",\r
- alwaysOpen: true,\r
- animated: 'slide',\r
- event: "click",\r
- header: "a",\r
- autoHeight: true,\r
- running: 0,\r
- navigationFilter: function() {\r
- return this.href.toLowerCase() == location.href.toLowerCase();\r
- }\r
+ // find elements to show and hide\r
+ var toShow = clicked.next(),\r
+ toHide = options.active.next(),\r
+ //data = [clicked, options.active, toShow, toHide],\r
+ data = {\r
+ instance: this,\r
+ options: options,\r
+ newHeader: clicked,\r
+ oldHeader: options.active,\r
+ newContent: toShow,\r
+ oldContent: toHide\r
},\r
- animations: {\r
- slide: function(options, additions) {\r
- options = $.extend({\r
- easing: "swing",\r
- duration: 300\r
- }, options, additions);\r
- if ( !options.toHide.size() ) {\r
- options.toShow.animate({height: "show"}, options);\r
- return;\r
- }\r
- var hideHeight = options.toHide.height(),\r
- showHeight = options.toShow.height(),\r
- difference = showHeight / hideHeight;\r
- options.toShow.css({ height: 0, overflow: 'hidden' }).show();\r
- options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{\r
- step: function(now) {\r
- var current = (hideHeight - now) * difference;\r
- if ($.browser.msie || $.browser.opera) {\r
- current = Math.ceil(current);\r
- }\r
- options.toShow.height( current );\r
- },\r
- duration: options.duration,\r
- easing: options.easing,\r
- complete: function() {\r
- if ( !options.autoHeight ) {\r
- options.toShow.css("height", "auto");\r
- }\r
- options.complete();\r
- }\r
- });\r
- },\r
- bounceslide: function(options) {\r
- this.slide(options, {\r
- easing: options.down ? "bounceout" : "swing",\r
- duration: options.down ? 1000 : 200\r
- });\r
- },\r
- easeslide: function(options) {\r
- this.slide(options, {\r
- easing: "easeinout",\r
- duration: 700\r
- });\r
+ down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );\r
+ \r
+ options.active = clickedActive ? $([]) : clicked;\r
+ toggle.call(this, toShow, toHide, data, clickedActive, down );\r
+\r
+ return false;\r
+};\r
+\r
+function findActive(headers, selector) {\r
+ return selector != undefined\r
+ ? typeof selector == "number"\r
+ ? headers.filter(":eq(" + selector + ")")\r
+ : headers.not(headers.not(selector))\r
+ : selector === false\r
+ ? $([])\r
+ : headers.filter(":eq(0)");\r
+}\r
+\r
+$.extend($.ui.accordion, {\r
+ defaults: {\r
+ selectedClass: "selected",\r
+ alwaysOpen: true,\r
+ animated: 'slide',\r
+ event: "click",\r
+ header: "a",\r
+ autoHeight: true,\r
+ running: 0,\r
+ navigationFilter: function() {\r
+ return this.href.toLowerCase() == location.href.toLowerCase();\r
+ }\r
+ },\r
+ animations: {\r
+ slide: function(options, additions) {\r
+ options = $.extend({\r
+ easing: "swing",\r
+ duration: 300\r
+ }, options, additions);\r
+ if ( !options.toHide.size() ) {\r
+ options.toShow.animate({height: "show"}, options);\r
+ return;\r
}\r
+ var hideHeight = options.toHide.height(),\r
+ showHeight = options.toShow.height(),\r
+ difference = showHeight / hideHeight;\r
+ options.toShow.css({ height: 0, overflow: 'hidden' }).show();\r
+ options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{\r
+ step: function(now) {\r
+ var current = (hideHeight - now) * difference;\r
+ if ($.browser.msie || $.browser.opera) {\r
+ current = Math.ceil(current);\r
+ }\r
+ options.toShow.height( current );\r
+ },\r
+ duration: options.duration,\r
+ easing: options.easing,\r
+ complete: function() {\r
+ if ( !options.autoHeight ) {\r
+ options.toShow.css("height", "auto");\r
+ }\r
+ options.complete();\r
+ }\r
+ });\r
+ },\r
+ bounceslide: function(options) {\r
+ this.slide(options, {\r
+ easing: options.down ? "bounceout" : "swing",\r
+ duration: options.down ? 1000 : 200\r
+ });\r
+ },\r
+ easeslide: function(options) {\r
+ this.slide(options, {\r
+ easing: "easeinout",\r
+ duration: 700\r
+ });\r
}\r
- });\r
- \r
- // deprecated, use accordion("activate", index) instead\r
- $.fn.activate = function(index) {\r
- return this.accordion("activate", index);\r
- };\r
+ }\r
+});\r
+\r
+// deprecated, use accordion("activate", index) instead\r
+$.fn.activate = function(index) {\r
+ return this.accordion("activate", index);\r
+};\r
\r
})(jQuery);\r
* $Id: ui.core.js 5587 2008-05-13 19:56:42Z scott.gonzalez $\r
*/\r
;(function($) {\r
- \r
- $.ui = {\r
- plugin: {\r
- add: function(module, option, set) {\r
- var proto = $.ui[module].prototype;\r
- for(var i in set) {\r
- proto.plugins[i] = proto.plugins[i] || [];\r
- proto.plugins[i].push([option, set[i]]);\r
- }\r
- },\r
- call: function(instance, name, args) {\r
- var set = instance.plugins[name];\r
- if(!set) { return; }\r
- \r
- for (var i = 0; i < set.length; i++) {\r
- if (instance.options[set[i][0]]) {\r
- set[i][1].apply(instance.element, args);\r
- }\r
- }\r
- } \r
+\r
+$.ui = {\r
+ plugin: {\r
+ add: function(module, option, set) {\r
+ var proto = $.ui[module].prototype;\r
+ for(var i in set) {\r
+ proto.plugins[i] = proto.plugins[i] || [];\r
+ proto.plugins[i].push([option, set[i]]);\r
+ }\r
},\r
- cssCache: {},\r
- css: function(name) {\r
- if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }\r
- var tmp = $('<div class="ui-resizable-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');\r
- \r
- //if (!$.browser.safari)\r
- //tmp.appendTo('body'); \r
+ call: function(instance, name, args) {\r
+ var set = instance.plugins[name];\r
+ if(!set) { return; }\r
\r
- //Opera and Safari set width and height to 0px instead of auto\r
- //Safari returns rgba(0,0,0,0) when bgcolor is not set\r
- $.ui.cssCache[name] = !!(\r
- (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || \r
- !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))\r
- );\r
- try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){}\r
- return $.ui.cssCache[name];\r
- },\r
- disableSelection: function(e) {\r
- e.unselectable = "on";\r
- e.onselectstart = function() { return false; };\r
- if (e.style) { e.style.MozUserSelect = "none"; }\r
- },\r
- enableSelection: function(e) {\r
- e.unselectable = "off";\r
- e.onselectstart = function() { return true; };\r
- if (e.style) { e.style.MozUserSelect = ""; }\r
- },\r
- hasScroll: function(e, a) {\r
- var scroll = /top/.test(a||"top") ? 'scrollTop' : 'scrollLeft', has = false;\r
- if (e[scroll] > 0) return true; e[scroll] = 1;\r
- has = e[scroll] > 0 ? true : false; e[scroll] = 0;\r
- return has;\r
- }\r
- };\r
- \r
+ for (var i = 0; i < set.length; i++) {\r
+ if (instance.options[set[i][0]]) {\r
+ set[i][1].apply(instance.element, args);\r
+ }\r
+ }\r
+ } \r
+ },\r
+ cssCache: {},\r
+ css: function(name) {\r
+ if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }\r
+ var tmp = $('<div class="ui-resizable-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');\r
+ \r
+ //if (!$.browser.safari)\r
+ //tmp.appendTo('body'); \r
+ \r
+ //Opera and Safari set width and height to 0px instead of auto\r
+ //Safari returns rgba(0,0,0,0) when bgcolor is not set\r
+ $.ui.cssCache[name] = !!(\r
+ (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || \r
+ !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))\r
+ );\r
+ try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){}\r
+ return $.ui.cssCache[name];\r
+ },\r
+ disableSelection: function(e) {\r
+ e.unselectable = "on";\r
+ e.onselectstart = function() { return false; };\r
+ if (e.style) { e.style.MozUserSelect = "none"; }\r
+ },\r
+ enableSelection: function(e) {\r
+ e.unselectable = "off";\r
+ e.onselectstart = function() { return true; };\r
+ if (e.style) { e.style.MozUserSelect = ""; }\r
+ },\r
+ hasScroll: function(e, a) {\r
+ var scroll = /top/.test(a||"top") ? 'scrollTop' : 'scrollLeft', has = false;\r
+ if (e[scroll] > 0) return true; e[scroll] = 1;\r
+ has = e[scroll] > 0 ? true : false; e[scroll] = 0;\r
+ return has;\r
+ }\r
+};\r
+\r
+\r
+/** jQuery core modifications and additions **/\r
+\r
+var _remove = $.fn.remove;\r
+$.fn.remove = function() {\r
+ $("*", this).add(this).trigger("remove");\r
+ return _remove.apply(this, arguments );\r
+};\r
+\r
+// $.widget is a factory to create jQuery plugins\r
+// taking some boilerplate code out of the plugin code\r
+// created by Scott González and Jörn Zaefferer\r
+function getter(namespace, plugin, method) {\r
+ var methods = $[namespace][plugin].getter || [];\r
+ methods = (typeof methods == "string" ? methods.split(/,?\s+/) : methods);\r
+ return ($.inArray(method, methods) != -1);\r
+}\r
+\r
+var widgetPrototype = {\r
+ init: function() {},\r
+ destroy: function() {\r
+ this.element.removeData(this.widgetName);\r
+ },\r
\r
- /** jQuery core modifications and additions **/\r
+ getData: function(key) {\r
+ return this.options[key];\r
+ },\r
+ setData: function(key, value) {\r
+ this.options[key] = value;\r
+ },\r
\r
- var _remove = $.fn.remove;\r
- $.fn.remove = function() {\r
- $("*", this).add(this).trigger("remove");\r
- return _remove.apply(this, arguments );\r
- };\r
- \r
- // $.widget is a factory to create jQuery plugins\r
- // taking some boilerplate code out of the plugin code\r
- // created by Scott González and Jörn Zaefferer\r
- function getter(namespace, plugin, method) {\r
- var methods = $[namespace][plugin].getter || [];\r
- methods = (typeof methods == "string" ? methods.split(/,?\s+/) : methods);\r
- return ($.inArray(method, methods) != -1);\r
+ enable: function() {\r
+ this.setData('disabled', false);\r
+ },\r
+ disable: function() {\r
+ this.setData('disabled', true);\r
}\r
- \r
- var widgetPrototype = {\r
- init: function() {},\r
- destroy: function() {\r
- this.element.removeData(this.widgetName);\r
- },\r
+};\r
+\r
+$.widget = function(name, prototype) {\r
+ var namespace = name.split(".")[0];\r
+ name = name.split(".")[1];\r
+ // create plugin method\r
+ $.fn[name] = function(options) {\r
+ var isMethodCall = (typeof options == 'string'),\r
+ args = Array.prototype.slice.call(arguments, 1);\r
\r
- getData: function(key) {\r
- return this.options[key];\r
- },\r
- setData: function(key, value) {\r
- this.options[key] = value;\r
- },\r
- \r
- enable: function() {\r
- this.setData('disabled', false);\r
- },\r
- disable: function() {\r
- this.setData('disabled', true);\r
+ if (isMethodCall && getter(namespace, name, options)) {\r
+ var instance = $.data(this[0], name);\r
+ return (instance ? instance[options].apply(instance, args)\r
+ : undefined);\r
}\r
+ \r
+ return this.each(function() {\r
+ var instance = $.data(this, name);\r
+ if (!instance) {\r
+ $.data(this, name, new $[namespace][name](this, options));\r
+ } else if (isMethodCall) {\r
+ instance[options].apply(instance, args);\r
+ }\r
+ });\r
};\r
\r
- $.widget = function(name, prototype) {\r
- var namespace = name.split(".")[0];\r
- name = name.split(".")[1];\r
- // create plugin method\r
- $.fn[name] = function(options) {\r
- var isMethodCall = (typeof options == 'string'),\r
- args = Array.prototype.slice.call(arguments, 1);\r
- \r
- if (isMethodCall && getter(namespace, name, options)) {\r
- var instance = $.data(this[0], name);\r
- return (instance ? instance[options].apply(instance, args)\r
- : undefined);\r
- }\r
- \r
- return this.each(function() {\r
- var instance = $.data(this, name);\r
- if (!instance) {\r
- $.data(this, name, new $[namespace][name](this, options));\r
- } else if (isMethodCall) {\r
- instance[options].apply(instance, args);\r
- }\r
- });\r
- };\r
+ // create widget constructor\r
+ $[namespace][name] = function(element, options) {\r
+ var self = this;\r
\r
- // create widget constructor\r
- $[namespace][name] = function(element, options) {\r
- var self = this;\r
- \r
- this.widgetName = name;\r
- \r
- this.options = $.extend({}, $[namespace][name].defaults, options);\r
- this.element = $(element)\r
- .bind('setData.' + name, function(e, key, value) {\r
- return self.setData(key, value);\r
- })\r
- .bind('getData.' + name, function(e, key) {\r
- return self.getData(key);\r
- })\r
- .bind('remove', function() {\r
- return self.destroy();\r
- });\r
- this.init();\r
- };\r
+ this.widgetName = name;\r
\r
- // add widget prototype\r
- $[namespace][name].prototype = $.extend({}, widgetPrototype, prototype);\r
+ this.options = $.extend({}, $[namespace][name].defaults, options);\r
+ this.element = $(element)\r
+ .bind('setData.' + name, function(e, key, value) {\r
+ return self.setData(key, value);\r
+ })\r
+ .bind('getData.' + name, function(e, key) {\r
+ return self.getData(key);\r
+ })\r
+ .bind('remove', function() {\r
+ return self.destroy();\r
+ });\r
+ this.init();\r
};\r
\r
+ // add widget prototype\r
+ $[namespace][name].prototype = $.extend({}, widgetPrototype, prototype);\r
+};\r
+\r
+\r
+/** Mouse Interaction Plugin **/\r
+\r
+$.ui.mouse = {\r
+ mouseInit: function() {\r
+ var self = this;\r
\r
- /** Mouse Interaction Plugin **/\r
+ this.element.bind('mousedown.'+this.widgetName, function(e) {\r
+ return self.mouseDown(e);\r
+ });\r
+ \r
+ // Prevent text selection in IE\r
+ if ($.browser.msie) {\r
+ this._mouseUnselectable = this.element.attr('unselectable');\r
+ this.element.attr('unselectable', 'on');\r
+ }\r
+ \r
+ this.started = false;\r
+ },\r
\r
- $.ui.mouse = {\r
- mouseInit: function() {\r
- var self = this;\r
+ // TODO: make sure destroying one instance of mouse doesn't mess with\r
+ // other instances of mouse\r
+ mouseDestroy: function() {\r
+ this.element.unbind('.'+this.widgetName);\r
\r
- this.element.bind('mousedown.'+this.widgetName, function(e) {\r
- return self.mouseDown(e);\r
- });\r
- \r
- // Prevent text selection in IE\r
- if ($.browser.msie) {\r
- this._mouseUnselectable = this.element.attr('unselectable');\r
- this.element.attr('unselectable', 'on');\r
- }\r
- \r
- this.started = false;\r
- },\r
+ // Restore text selection in IE\r
+ ($.browser.msie\r
+ && this.element.attr('unselectable', this._mouseUnselectable));\r
+ },\r
+ \r
+ mouseDown: function(e) {\r
+ // we may have missed mouseup (out of window)\r
+ (this._mouseStarted && this.mouseUp(e));\r
\r
- // TODO: make sure destroying one instance of mouse doesn't mess with\r
- // other instances of mouse\r
- mouseDestroy: function() {\r
- this.element.unbind('.'+this.widgetName);\r
- \r
- // Restore text selection in IE\r
- ($.browser.msie\r
- && this.element.attr('unselectable', this._mouseUnselectable));\r
- },\r
+ this._mouseDownEvent = e;\r
\r
- mouseDown: function(e) {\r
- // we may have missed mouseup (out of window)\r
- (this._mouseStarted && this.mouseUp(e));\r
- \r
- this._mouseDownEvent = e;\r
- \r
- var self = this,\r
- btnIsLeft = (e.which == 1),\r
- elIsCancel = ($(e.target).is(this.options.cancel));\r
- if (!btnIsLeft || elIsCancel) {\r
- return true;\r
- }\r
- \r
- this._mouseDelayMet = !this.options.delay;\r
- if (!this._mouseDelayMet) {\r
- this._mouseDelayTimer = setTimeout(function() {\r
- self._mouseDelayMet = true;\r
- }, this.options.delay);\r
- }\r
- \r
- // these delegates are required to keep context\r
- this._mouseMoveDelegate = function(e) {\r
- return self.mouseMove(e);\r
- };\r
- this._mouseUpDelegate = function(e) {\r
- return self.mouseUp(e);\r
- };\r
- $(document)\r
- .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)\r
- .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);\r
- \r
- return false;\r
- },\r
+ var self = this,\r
+ btnIsLeft = (e.which == 1),\r
+ elIsCancel = ($(e.target).is(this.options.cancel));\r
+ if (!btnIsLeft || elIsCancel) {\r
+ return true;\r
+ }\r
\r
- mouseMove: function(e) {\r
- // IE mouseup check - mouseup happened when mouse was out of window\r
- if ($.browser.msie && !e.button) {\r
- return this.mouseUp(e);\r
- }\r
- \r
- if (this._mouseStarted) {\r
- this.mouseDrag(e);\r
- return false;\r
- }\r
- \r
- if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {\r
- this._mouseStarted =\r
- (this.mouseStart(this._mouseDownEvent, e) !== false);\r
- (this._mouseStarted || this.mouseUp(e));\r
- }\r
- \r
- return !this._mouseStarted;\r
- },\r
+ this._mouseDelayMet = !this.options.delay;\r
+ if (!this._mouseDelayMet) {\r
+ this._mouseDelayTimer = setTimeout(function() {\r
+ self._mouseDelayMet = true;\r
+ }, this.options.delay);\r
+ }\r
\r
- mouseUp: function(e) {\r
- $(document)\r
- .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)\r
- .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);\r
- \r
- if (this._mouseStarted) {\r
- this._mouseStarted = false;\r
- this.mouseStop(e);\r
- }\r
- \r
+ // these delegates are required to keep context\r
+ this._mouseMoveDelegate = function(e) {\r
+ return self.mouseMove(e);\r
+ };\r
+ this._mouseUpDelegate = function(e) {\r
+ return self.mouseUp(e);\r
+ };\r
+ $(document)\r
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)\r
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);\r
+ \r
+ return false;\r
+ },\r
+ \r
+ mouseMove: function(e) {\r
+ // IE mouseup check - mouseup happened when mouse was out of window\r
+ if ($.browser.msie && !e.button) {\r
+ return this.mouseUp(e);\r
+ }\r
+ \r
+ if (this._mouseStarted) {\r
+ this.mouseDrag(e);\r
return false;\r
- },\r
+ }\r
\r
- mouseDistanceMet: function(e) {\r
- return (Math.max(\r
- Math.abs(this._mouseDownEvent.pageX - e.pageX),\r
- Math.abs(this._mouseDownEvent.pageY - e.pageY)\r
- ) >= this.options.distance\r
- );\r
- },\r
+ if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {\r
+ this._mouseStarted =\r
+ (this.mouseStart(this._mouseDownEvent, e) !== false);\r
+ (this._mouseStarted || this.mouseUp(e));\r
+ }\r
\r
- mouseDelayMet: function(e) {\r
- return this._mouseDelayMet;\r
- },\r
+ return !this._mouseStarted;\r
+ },\r
+ \r
+ mouseUp: function(e) {\r
+ $(document)\r
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)\r
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);\r
\r
- // These are placeholder methods, to be overriden by extending plugin\r
- mouseStart: function(e) {},\r
- mouseDrag: function(e) {},\r
- mouseStop: function(e) {}\r
- };\r
+ if (this._mouseStarted) {\r
+ this._mouseStarted = false;\r
+ this.mouseStop(e);\r
+ }\r
+ \r
+ return false;\r
+ },\r
\r
- $.ui.mouse.defaults = {\r
- cancel: null,\r
- distance: 0,\r
- delay: 0\r
- };\r
+ mouseDistanceMet: function(e) {\r
+ return (Math.max(\r
+ Math.abs(this._mouseDownEvent.pageX - e.pageX),\r
+ Math.abs(this._mouseDownEvent.pageY - e.pageY)\r
+ ) >= this.options.distance\r
+ );\r
+ },\r
+ \r
+ mouseDelayMet: function(e) {\r
+ return this._mouseDelayMet;\r
+ },\r
+ \r
+ // These are placeholder methods, to be overriden by extending plugin\r
+ mouseStart: function(e) {},\r
+ mouseDrag: function(e) {},\r
+ mouseStop: function(e) {}\r
+};\r
+\r
+$.ui.mouse.defaults = {\r
+ cancel: null,\r
+ distance: 0,\r
+ delay: 0\r
+};\r
+\r
})(jQuery);\r
.mousedown($.datepicker._checkExternalClick);\r
});\r
\r
-})(jQuery);
\ No newline at end of file
+})(jQuery);\r
* Revision: $Id: ui.dialog.js 5608 2008-05-15 14:41:12Z scott.gonzalez $\r
*/\r
;(function($) {\r
- \r
- var setDataSwitch = {\r
- dragStart: "start.draggable",\r
- drag: "drag.draggable",\r
- dragStop: "stop.draggable",\r
- maxHeight: "maxHeight.resizable",\r
- minHeight: "minHeight.resizable",\r
- maxWidth: "maxWidth.resizable",\r
- minWidth: "minWidth.resizable",\r
- resizeStart: "start.resizable",\r
- resize: "drag.resizable",\r
- resizeStop: "stop.resizable"\r
- };\r
- \r
- $.widget("ui.dialog", {\r
- init: function() {\r
- var self = this;\r
- var options = this.options;\r
- \r
- var uiDialogContent = this.element.addClass('ui-dialog-content');\r
- \r
- if (!uiDialogContent.parent().length) {\r
- uiDialogContent.appendTo('body');\r
- }\r
- uiDialogContent\r
- .wrap(document.createElement('div'))\r
- .wrap(document.createElement('div'));\r
- var uiDialogContainer = uiDialogContent.parent().addClass('ui-dialog-container').css({position: 'relative'});\r
- var uiDialog = (this.uiDialog = uiDialogContainer.parent()).hide()\r
- .addClass('ui-dialog').addClass(options.dialogClass)\r
- .css({position: 'absolute', width: options.width, height: options.height, overflow: 'hidden'}); \r
- \r
- var classNames = uiDialogContent.attr('className').split(' ');\r
- \r
- // Add content classes to dialog, to inherit theme at top level of element\r
- $.each(classNames, function(i, className) {\r
- ((className != 'ui-dialog-content')\r
- && uiDialog.addClass(className));\r
- });\r
- \r
- if ($.fn.resizable) {\r
- uiDialog.append('<div class="ui-resizable-n ui-resizable-handle"></div>')\r
- .append('<div class="ui-resizable-s ui-resizable-handle"></div>')\r
- .append('<div class="ui-resizable-e ui-resizable-handle"></div>')\r
- .append('<div class="ui-resizable-w ui-resizable-handle"></div>')\r
- .append('<div class="ui-resizable-ne ui-resizable-handle"></div>')\r
- .append('<div class="ui-resizable-se ui-resizable-handle"></div>')\r
- .append('<div class="ui-resizable-sw ui-resizable-handle"></div>')\r
- .append('<div class="ui-resizable-nw ui-resizable-handle"></div>');\r
- uiDialog.resizable({\r
- maxWidth: options.maxWidth,\r
- maxHeight: options.maxHeight,\r
- minWidth: options.minWidth,\r
- minHeight: options.minHeight,\r
- start: options.resizeStart,\r
- resize: options.resize,\r
- stop: function(e, ui) {\r
- (options.resizeStop && options.resizeStop.apply(this, arguments));\r
- $.ui.dialog.overlay.resize();\r
- }\r
- });\r
- (!options.resizable && uiDialog.resizable('disable'));\r
- }\r
- \r
- uiDialogContainer.prepend('<div class="ui-dialog-titlebar"></div>');\r
- var uiDialogTitlebar = $('.ui-dialog-titlebar', uiDialogContainer);\r
- this.uiDialogTitlebar = uiDialogTitlebar;\r
- var title = (options.title) ? options.title : (uiDialogContent.attr('title')) ? uiDialogContent.attr('title') : '';\r
- uiDialogTitlebar.append('<span class="ui-dialog-title">' + title + '</span>');\r
- uiDialogTitlebar.append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>');\r
- this.uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar)\r
- .hover(function() { $(this).addClass('ui-dialog-titlebar-close-hover'); }, \r
- function() { $(this).removeClass('ui-dialog-titlebar-close-hover'); }\r
- )\r
- .mousedown(function(ev) {\r
- ev.stopPropagation();\r
- })\r
- .click(function() {\r
- self.close();\r
- return false;\r
- });\r
- \r
- // setting tabindex makes the div focusable\r
- // setting outline to 0 prevents a border on focus in Mozilla\r
- uiDialog.attr('tabindex', -1).css('outline', 0).keydown(function(ev) {\r
- if (options.closeOnEscape) {\r
- var ESC = 27;\r
- (ev.keyCode && ev.keyCode == ESC && self.close());\r
+\r
+var setDataSwitch = {\r
+ dragStart: "start.draggable",\r
+ drag: "drag.draggable",\r
+ dragStop: "stop.draggable",\r
+ maxHeight: "maxHeight.resizable",\r
+ minHeight: "minHeight.resizable",\r
+ maxWidth: "maxWidth.resizable",\r
+ minWidth: "minWidth.resizable",\r
+ resizeStart: "start.resizable",\r
+ resize: "drag.resizable",\r
+ resizeStop: "stop.resizable"\r
+};\r
+\r
+$.widget("ui.dialog", {\r
+ init: function() {\r
+ var self = this;\r
+ var options = this.options;\r
+ \r
+ var uiDialogContent = this.element.addClass('ui-dialog-content');\r
+ \r
+ if (!uiDialogContent.parent().length) {\r
+ uiDialogContent.appendTo('body');\r
+ }\r
+ uiDialogContent\r
+ .wrap(document.createElement('div'))\r
+ .wrap(document.createElement('div'));\r
+ var uiDialogContainer = uiDialogContent.parent().addClass('ui-dialog-container').css({position: 'relative'});\r
+ var uiDialog = (this.uiDialog = uiDialogContainer.parent()).hide()\r
+ .addClass('ui-dialog').addClass(options.dialogClass)\r
+ .css({position: 'absolute', width: options.width, height: options.height, overflow: 'hidden'}); \r
+\r
+ var classNames = uiDialogContent.attr('className').split(' ');\r
+\r
+ // Add content classes to dialog, to inherit theme at top level of element\r
+ $.each(classNames, function(i, className) {\r
+ ((className != 'ui-dialog-content')\r
+ && uiDialog.addClass(className));\r
+ });\r
+\r
+ if ($.fn.resizable) {\r
+ uiDialog.append('<div class="ui-resizable-n ui-resizable-handle"></div>')\r
+ .append('<div class="ui-resizable-s ui-resizable-handle"></div>')\r
+ .append('<div class="ui-resizable-e ui-resizable-handle"></div>')\r
+ .append('<div class="ui-resizable-w ui-resizable-handle"></div>')\r
+ .append('<div class="ui-resizable-ne ui-resizable-handle"></div>')\r
+ .append('<div class="ui-resizable-se ui-resizable-handle"></div>')\r
+ .append('<div class="ui-resizable-sw ui-resizable-handle"></div>')\r
+ .append('<div class="ui-resizable-nw ui-resizable-handle"></div>');\r
+ uiDialog.resizable({\r
+ maxWidth: options.maxWidth,\r
+ maxHeight: options.maxHeight,\r
+ minWidth: options.minWidth,\r
+ minHeight: options.minHeight,\r
+ start: options.resizeStart,\r
+ resize: options.resize,\r
+ stop: function(e, ui) {\r
+ (options.resizeStop && options.resizeStop.apply(this, arguments));\r
+ $.ui.dialog.overlay.resize();\r
}\r
});\r
- \r
- var hasButtons = false;\r
- $.each(options.buttons, function() { return !(hasButtons = true); });\r
- if (hasButtons) {\r
- var uiDialogButtonPane = $('<div class="ui-dialog-buttonpane"/>')\r
- .appendTo(uiDialog);\r
- $.each(options.buttons, function(name, fn) {\r
- $(document.createElement('button'))\r
- .text(name)\r
- .click(function() { fn.apply(self.element, arguments); })\r
- .appendTo(uiDialogButtonPane);\r
- });\r
- }\r
- \r
- if ($.fn.draggable) {\r
- uiDialog.draggable({\r
- handle: '.ui-dialog-titlebar',\r
- start: function(e, ui) {\r
- self.activate();\r
- (options.dragStart && options.dragStart.apply(this, arguments));\r
- },\r
- drag: options.drag,\r
- stop: function(e, ui) {\r
- (options.dragStop && options.dragStop.apply(this, arguments));\r
- $.ui.dialog.overlay.resize();\r
- }\r
- });\r
- (!options.draggable && uiDialog.draggable('disable'));\r
+ (!options.resizable && uiDialog.resizable('disable'));\r
+ }\r
+\r
+ uiDialogContainer.prepend('<div class="ui-dialog-titlebar"></div>');\r
+ var uiDialogTitlebar = $('.ui-dialog-titlebar', uiDialogContainer);\r
+ this.uiDialogTitlebar = uiDialogTitlebar;\r
+ var title = (options.title) ? options.title : (uiDialogContent.attr('title')) ? uiDialogContent.attr('title') : '';\r
+ uiDialogTitlebar.append('<span class="ui-dialog-title">' + title + '</span>');\r
+ uiDialogTitlebar.append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>');\r
+ this.uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar)\r
+ .hover(function() { $(this).addClass('ui-dialog-titlebar-close-hover'); }, \r
+ function() { $(this).removeClass('ui-dialog-titlebar-close-hover'); }\r
+ )\r
+ .mousedown(function(ev) {\r
+ ev.stopPropagation();\r
+ })\r
+ .click(function() {\r
+ self.close();\r
+ return false;\r
+ });\r
+ \r
+ // setting tabindex makes the div focusable\r
+ // setting outline to 0 prevents a border on focus in Mozilla\r
+ uiDialog.attr('tabindex', -1).css('outline', 0).keydown(function(ev) {\r
+ if (options.closeOnEscape) {\r
+ var ESC = 27;\r
+ (ev.keyCode && ev.keyCode == ESC && self.close());\r
}\r
+ });\r
\r
- uiDialog.mousedown(function() {\r
- self.activate();\r
+ var hasButtons = false;\r
+ $.each(options.buttons, function() { return !(hasButtons = true); });\r
+ if (hasButtons) {\r
+ var uiDialogButtonPane = $('<div class="ui-dialog-buttonpane"/>')\r
+ .appendTo(uiDialog);\r
+ $.each(options.buttons, function(name, fn) {\r
+ $(document.createElement('button'))\r
+ .text(name)\r
+ .click(function() { fn.apply(self.element, arguments); })\r
+ .appendTo(uiDialogButtonPane);\r
});\r
- uiDialogTitlebar.click(function() {\r
- self.activate();\r
+ }\r
+ \r
+ if ($.fn.draggable) {\r
+ uiDialog.draggable({\r
+ handle: '.ui-dialog-titlebar',\r
+ start: function(e, ui) {\r
+ self.activate();\r
+ (options.dragStart && options.dragStart.apply(this, arguments));\r
+ },\r
+ drag: options.drag,\r
+ stop: function(e, ui) {\r
+ (options.dragStop && options.dragStop.apply(this, arguments));\r
+ $.ui.dialog.overlay.resize();\r
+ }\r
});\r
- \r
- (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());\r
- \r
- (options.autoOpen && this.open());\r
- },\r
+ (!options.draggable && uiDialog.draggable('disable'));\r
+ }\r
+ \r
+ uiDialog.mousedown(function() {\r
+ self.activate();\r
+ });\r
+ uiDialogTitlebar.click(function() {\r
+ self.activate();\r
+ });\r
\r
- setData: function(key, value){\r
- (setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));\r
- switch (key) {\r
- case "draggable":\r
- this.uiDialog.draggable(value ? 'enable' : 'disable');\r
- break;\r
- case "height":\r
- this.uiDialog.height(value);\r
- break;\r
- case "position":\r
- this.position(value);\r
+ (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());\r
+ \r
+ (options.autoOpen && this.open());\r
+ },\r
+ \r
+ setData: function(key, value){\r
+ (setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));\r
+ switch (key) {\r
+ case "draggable":\r
+ this.uiDialog.draggable(value ? 'enable' : 'disable');\r
+ break;\r
+ case "height":\r
+ this.uiDialog.height(value);\r
+ break;\r
+ case "position":\r
+ this.position(value);\r
+ break;\r
+ case "resizable":\r
+ this.uiDialog.resizable(value ? 'enable' : 'disable');\r
+ break;\r
+ case "title":\r
+ $(".ui-dialog-title", this.uiDialogTitlebar).text(value);\r
+ break;\r
+ case "width":\r
+ this.uiDialog.width(value);\r
+ break;\r
+ }\r
+ this.options[key] = value;\r
+ },\r
+ \r
+ position: function(pos) {\r
+ var wnd = $(window), doc = $(document),\r
+ pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),\r
+ minTop = pTop;\r
+ \r
+ if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {\r
+ pos = [\r
+ pos == 'right' || pos == 'left' ? pos : 'center',\r
+ pos == 'top' || pos == 'bottom' ? pos : 'middle'\r
+ ];\r
+ }\r
+ if (pos.constructor != Array) {\r
+ pos = ['center', 'middle'];\r
+ }\r
+ if (pos[0].constructor == Number) {\r
+ pLeft += pos[0];\r
+ } else {\r
+ switch (pos[0]) {\r
+ case 'left':\r
+ pLeft += 0;\r
break;\r
- case "resizable":\r
- this.uiDialog.resizable(value ? 'enable' : 'disable');\r
+ case 'right':\r
+ pLeft += (wnd.width()) - (this.uiDialog.width());\r
break;\r
- case "title":\r
- $(".ui-dialog-title", this.uiDialogTitlebar).text(value);\r
+ default:\r
+ case 'center':\r
+ pLeft += (wnd.width() / 2) - (this.uiDialog.width() / 2);\r
+ }\r
+ }\r
+ if (pos[1].constructor == Number) {\r
+ pTop += pos[1];\r
+ } else {\r
+ switch (pos[1]) {\r
+ case 'top':\r
+ pTop += 0;\r
break;\r
- case "width":\r
- this.uiDialog.width(value);\r
+ case 'bottom':\r
+ pTop += (wnd.height()) - (this.uiDialog.height());\r
break;\r
+ default:\r
+ case 'middle':\r
+ pTop += (wnd.height() / 2) - (this.uiDialog.height() / 2);\r
}\r
- this.options[key] = value;\r
- },\r
- \r
- position: function(pos) {\r
- var wnd = $(window), doc = $(document),\r
- pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),\r
- minTop = pTop;\r
- \r
- if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {\r
- pos = [\r
- pos == 'right' || pos == 'left' ? pos : 'center',\r
- pos == 'top' || pos == 'bottom' ? pos : 'middle'\r
- ];\r
- }\r
- if (pos.constructor != Array) {\r
- pos = ['center', 'middle'];\r
- }\r
- if (pos[0].constructor == Number) {\r
- pLeft += pos[0];\r
- } else {\r
- switch (pos[0]) {\r
- case 'left':\r
- pLeft += 0;\r
- break;\r
- case 'right':\r
- pLeft += (wnd.width()) - (this.uiDialog.width());\r
- break;\r
- default:\r
- case 'center':\r
- pLeft += (wnd.width() / 2) - (this.uiDialog.width() / 2);\r
- }\r
- }\r
- if (pos[1].constructor == Number) {\r
- pTop += pos[1];\r
- } else {\r
- switch (pos[1]) {\r
- case 'top':\r
- pTop += 0;\r
- break;\r
- case 'bottom':\r
- pTop += (wnd.height()) - (this.uiDialog.height());\r
- break;\r
- default:\r
- case 'middle':\r
- pTop += (wnd.height() / 2) - (this.uiDialog.height() / 2);\r
- }\r
- }\r
- \r
- // prevent the dialog from being too high (make sure the titlebar\r
- // is accessible)\r
- pTop = Math.max(pTop, minTop);\r
- this.uiDialog.css({top: pTop, left: pLeft});\r
- },\r
+ }\r
\r
- open: function() {\r
- this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;\r
- this.uiDialog.appendTo('body');\r
- this.position(this.options.position);\r
- this.uiDialog.show();\r
- this.moveToTop();\r
- this.activate();\r
- \r
- // CALLBACK: open\r
- var openEV = null;\r
- var openUI = {\r
- options: this.options\r
- };\r
- this.uiDialogTitlebarClose.focus();\r
- this.element.triggerHandler("dialogopen", [openEV, openUI], this.options.open);\r
- },\r
+ // prevent the dialog from being too high (make sure the titlebar\r
+ // is accessible)\r
+ pTop = Math.max(pTop, minTop);\r
+ this.uiDialog.css({top: pTop, left: pLeft});\r
+ },\r
\r
- activate: function() {\r
- // Move modeless dialogs to the top when they're activated. Even\r
- // if there is a modal dialog in the window, the modeless dialog\r
- // should be on top because it must have been opened after the modal\r
- // dialog. Modal dialogs don't get moved to the top because that\r
- // would make any modeless dialogs that it spawned unusable until\r
- // the modal dialog is closed.\r
- (!this.options.modal && this.moveToTop());\r
- },\r
- \r
- moveToTop: function() {\r
- var maxZ = this.options.zIndex, options = this.options;\r
- $('.ui-dialog:visible').each(function() {\r
- maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);\r
- });\r
- (this.overlay && this.overlay.$el.css('z-index', ++maxZ));\r
- this.uiDialog.css('z-index', ++maxZ);\r
- },\r
- \r
- close: function() {\r
- (this.overlay && this.overlay.destroy());\r
- this.uiDialog.hide();\r
+ open: function() {\r
+ this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;\r
+ this.uiDialog.appendTo('body');\r
+ this.position(this.options.position);\r
+ this.uiDialog.show();\r
+ this.moveToTop();\r
+ this.activate();\r
+ \r
+ // CALLBACK: open\r
+ var openEV = null;\r
+ var openUI = {\r
+ options: this.options\r
+ };\r
+ this.uiDialogTitlebarClose.focus();\r
+ this.element.triggerHandler("dialogopen", [openEV, openUI], this.options.open);\r
+ },\r
\r
- // CALLBACK: close\r
- var closeEV = null;\r
- var closeUI = {\r
- options: this.options\r
- };\r
- this.element.triggerHandler("dialogclose", [closeEV, closeUI], this.options.close);\r
- $.ui.dialog.overlay.resize();\r
- },\r
+ activate: function() {\r
+ // Move modeless dialogs to the top when they're activated. Even\r
+ // if there is a modal dialog in the window, the modeless dialog\r
+ // should be on top because it must have been opened after the modal\r
+ // dialog. Modal dialogs don't get moved to the top because that\r
+ // would make any modeless dialogs that it spawned unusable until\r
+ // the modal dialog is closed.\r
+ (!this.options.modal && this.moveToTop());\r
+ },\r
\r
- destroy: function() {\r
- (this.overlay && this.overlay.destroy());\r
- this.uiDialog.hide();\r
- this.element\r
- .unbind('.dialog')\r
- .removeData('dialog')\r
- .removeClass('ui-dialog-content')\r
- .hide().appendTo('body');\r
- this.uiDialog.remove();\r
- }\r
- });\r
- \r
- $.extend($.ui.dialog, {\r
- defaults: {\r
- autoOpen: true,\r
- bgiframe: false,\r
- buttons: {},\r
- closeOnEscape: true,\r
- draggable: true,\r
- height: 200,\r
- minHeight: 100,\r
- minWidth: 150,\r
- modal: false,\r
- overlay: {},\r
- position: 'center',\r
- resizable: true,\r
- width: 300,\r
- zIndex: 1000\r
- },\r
+ moveToTop: function() {\r
+ var maxZ = this.options.zIndex, options = this.options;\r
+ $('.ui-dialog:visible').each(function() {\r
+ maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);\r
+ });\r
+ (this.overlay && this.overlay.$el.css('z-index', ++maxZ));\r
+ this.uiDialog.css('z-index', ++maxZ);\r
+ },\r
\r
- overlay: function(dialog) {\r
- this.$el = $.ui.dialog.overlay.create(dialog);\r
- }\r
- });\r
+ close: function() {\r
+ (this.overlay && this.overlay.destroy());\r
+ this.uiDialog.hide();\r
+\r
+ // CALLBACK: close\r
+ var closeEV = null;\r
+ var closeUI = {\r
+ options: this.options\r
+ };\r
+ this.element.triggerHandler("dialogclose", [closeEV, closeUI], this.options.close);\r
+ $.ui.dialog.overlay.resize();\r
+ },\r
\r
- $.extend($.ui.dialog.overlay, {\r
- instances: [],\r
- events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),\r
- function(e) { return e + '.dialog-overlay'; }).join(' '),\r
- create: function(dialog) {\r
- if (this.instances.length === 0) {\r
- // prevent use of anchors and inputs\r
- // we use a setTimeout in case the overlay is created from an\r
- // event that we're going to be cancelling (see #2804)\r
- setTimeout(function() {\r
- $('a, :input').bind($.ui.dialog.overlay.events, function() {\r
- // allow use of the element if inside a dialog and\r
- // - there are no modal dialogs\r
- // - there are modal dialogs, but we are in front of the topmost modal\r
- var allow = false;\r
- var $dialog = $(this).parents('.ui-dialog');\r
- if ($dialog.length) {\r
- var $overlays = $('.ui-dialog-overlay');\r
- if ($overlays.length) {\r
- var maxZ = parseInt($overlays.css('z-index'), 10);\r
- $overlays.each(function() {\r
- maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10));\r
- });\r
- allow = parseInt($dialog.css('z-index'), 10) > maxZ;\r
- } else {\r
- allow = true;\r
- }\r
+ destroy: function() {\r
+ (this.overlay && this.overlay.destroy());\r
+ this.uiDialog.hide();\r
+ this.element\r
+ .unbind('.dialog')\r
+ .removeData('dialog')\r
+ .removeClass('ui-dialog-content')\r
+ .hide().appendTo('body');\r
+ this.uiDialog.remove();\r
+ }\r
+});\r
+\r
+$.extend($.ui.dialog, {\r
+ defaults: {\r
+ autoOpen: true,\r
+ bgiframe: false,\r
+ buttons: {},\r
+ closeOnEscape: true,\r
+ draggable: true,\r
+ height: 200,\r
+ minHeight: 100,\r
+ minWidth: 150,\r
+ modal: false,\r
+ overlay: {},\r
+ position: 'center',\r
+ resizable: true,\r
+ width: 300,\r
+ zIndex: 1000\r
+ },\r
+ \r
+ overlay: function(dialog) {\r
+ this.$el = $.ui.dialog.overlay.create(dialog);\r
+ }\r
+});\r
+\r
+$.extend($.ui.dialog.overlay, {\r
+ instances: [],\r
+ events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),\r
+ function(e) { return e + '.dialog-overlay'; }).join(' '),\r
+ create: function(dialog) {\r
+ if (this.instances.length === 0) {\r
+ // prevent use of anchors and inputs\r
+ // we use a setTimeout in case the overlay is created from an\r
+ // event that we're going to be cancelling (see #2804)\r
+ setTimeout(function() {\r
+ $('a, :input').bind($.ui.dialog.overlay.events, function() {\r
+ // allow use of the element if inside a dialog and\r
+ // - there are no modal dialogs\r
+ // - there are modal dialogs, but we are in front of the topmost modal\r
+ var allow = false;\r
+ var $dialog = $(this).parents('.ui-dialog');\r
+ if ($dialog.length) {\r
+ var $overlays = $('.ui-dialog-overlay');\r
+ if ($overlays.length) {\r
+ var maxZ = parseInt($overlays.css('z-index'), 10);\r
+ $overlays.each(function() {\r
+ maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10));\r
+ });\r
+ allow = parseInt($dialog.css('z-index'), 10) > maxZ;\r
+ } else {\r
+ allow = true;\r
}\r
- return allow;\r
- });\r
- }, 1);\r
- \r
- // allow closing by pressing the escape key\r
- $(document).bind('keydown.dialog-overlay', function(e) {\r
- var ESC = 27;\r
- (e.keyCode && e.keyCode == ESC && dialog.close()); \r
+ }\r
+ return allow;\r
});\r
- \r
- // handle window resize\r
- $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);\r
- }\r
- \r
- var $el = $('<div/>').appendTo(document.body)\r
- .addClass('ui-dialog-overlay').css($.extend({\r
- borderWidth: 0, margin: 0, padding: 0,\r
- position: 'absolute', top: 0, left: 0,\r
- width: this.width(),\r
- height: this.height()\r
- }, dialog.options.overlay));\r
+ }, 1);\r
\r
- (dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());\r
+ // allow closing by pressing the escape key\r
+ $(document).bind('keydown.dialog-overlay', function(e) {\r
+ var ESC = 27;\r
+ (e.keyCode && e.keyCode == ESC && dialog.close()); \r
+ });\r
\r
- this.instances.push($el);\r
- return $el;\r
- },\r
+ // handle window resize\r
+ $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);\r
+ }\r
\r
- destroy: function($el) {\r
- this.instances.splice($.inArray(this.instances, $el), 1);\r
- \r
- if (this.instances.length === 0) {\r
- $('a, :input').add([document, window]).unbind('.dialog-overlay');\r
- }\r
- \r
- $el.remove();\r
- },\r
+ var $el = $('<div/>').appendTo(document.body)\r
+ .addClass('ui-dialog-overlay').css($.extend({\r
+ borderWidth: 0, margin: 0, padding: 0,\r
+ position: 'absolute', top: 0, left: 0,\r
+ width: this.width(),\r
+ height: this.height()\r
+ }, dialog.options.overlay));\r
\r
- height: function() {\r
- if ($.browser.msie && $.browser.version < 7) {\r
- var scrollHeight = Math.max(\r
- document.documentElement.scrollHeight,\r
- document.body.scrollHeight\r
- );\r
- var offsetHeight = Math.max(\r
- document.documentElement.offsetHeight,\r
- document.body.offsetHeight\r
- );\r
- \r
- if (scrollHeight < offsetHeight) {\r
- return $(window).height() + 'px';\r
- } else {\r
- return scrollHeight + 'px';\r
- }\r
- } else {\r
- return $(document).height() + 'px';\r
- }\r
- },\r
+ (dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());\r
\r
- width: function() {\r
- if ($.browser.msie && $.browser.version < 7) {\r
- var scrollWidth = Math.max(\r
- document.documentElement.scrollWidth,\r
- document.body.scrollWidth\r
- );\r
- var offsetWidth = Math.max(\r
- document.documentElement.offsetWidth,\r
- document.body.offsetWidth\r
- );\r
- \r
- if (scrollWidth < offsetWidth) {\r
- return $(window).width() + 'px';\r
- } else {\r
- return scrollWidth + 'px';\r
- }\r
- } else {\r
- return $(document).width() + 'px';\r
- }\r
- },\r
+ this.instances.push($el);\r
+ return $el;\r
+ },\r
+ \r
+ destroy: function($el) {\r
+ this.instances.splice($.inArray(this.instances, $el), 1);\r
\r
- resize: function() {\r
- /* If the dialog is draggable and the user drags it past the\r
- * right edge of the window, the document becomes wider so we\r
- * need to stretch the overlay. If the user then drags the\r
- * dialog back to the left, the document will become narrower,\r
- * so we need to shrink the overlay to the appropriate size.\r
- * This is handled by shrinking the overlay before setting it\r
- * to the full document size.\r
- */\r
- var $overlays = $([]);\r
- $.each($.ui.dialog.overlay.instances, function() {\r
- $overlays = $overlays.add(this);\r
- });\r
+ if (this.instances.length === 0) {\r
+ $('a, :input').add([document, window]).unbind('.dialog-overlay');\r
+ }\r
+ \r
+ $el.remove();\r
+ },\r
+ \r
+ height: function() {\r
+ if ($.browser.msie && $.browser.version < 7) {\r
+ var scrollHeight = Math.max(\r
+ document.documentElement.scrollHeight,\r
+ document.body.scrollHeight\r
+ );\r
+ var offsetHeight = Math.max(\r
+ document.documentElement.offsetHeight,\r
+ document.body.offsetHeight\r
+ );\r
\r
- $overlays.css({\r
- width: 0,\r
- height: 0\r
- }).css({\r
- width: $.ui.dialog.overlay.width(),\r
- height: $.ui.dialog.overlay.height()\r
- });\r
+ if (scrollHeight < offsetHeight) {\r
+ return $(window).height() + 'px';\r
+ } else {\r
+ return scrollHeight + 'px';\r
+ }\r
+ } else {\r
+ return $(document).height() + 'px';\r
}\r
- });\r
+ },\r
\r
- $.extend($.ui.dialog.overlay.prototype, {\r
- destroy: function() {\r
- $.ui.dialog.overlay.destroy(this.$el);\r
+ width: function() {\r
+ if ($.browser.msie && $.browser.version < 7) {\r
+ var scrollWidth = Math.max(\r
+ document.documentElement.scrollWidth,\r
+ document.body.scrollWidth\r
+ );\r
+ var offsetWidth = Math.max(\r
+ document.documentElement.offsetWidth,\r
+ document.body.offsetWidth\r
+ );\r
+ \r
+ if (scrollWidth < offsetWidth) {\r
+ return $(window).width() + 'px';\r
+ } else {\r
+ return scrollWidth + 'px';\r
+ }\r
+ } else {\r
+ return $(document).width() + 'px';\r
}\r
- });\r
+ },\r
+ \r
+ resize: function() {\r
+ /* If the dialog is draggable and the user drags it past the\r
+ * right edge of the window, the document becomes wider so we\r
+ * need to stretch the overlay. If the user then drags the\r
+ * dialog back to the left, the document will become narrower,\r
+ * so we need to shrink the overlay to the appropriate size.\r
+ * This is handled by shrinking the overlay before setting it\r
+ * to the full document size.\r
+ */\r
+ var $overlays = $([]);\r
+ $.each($.ui.dialog.overlay.instances, function() {\r
+ $overlays = $overlays.add(this);\r
+ });\r
+ \r
+ $overlays.css({\r
+ width: 0,\r
+ height: 0\r
+ }).css({\r
+ width: $.ui.dialog.overlay.width(),\r
+ height: $.ui.dialog.overlay.height()\r
+ });\r
+ }\r
+});\r
+\r
+$.extend($.ui.dialog.overlay.prototype, {\r
+ destroy: function() {\r
+ $.ui.dialog.overlay.destroy(this.$el);\r
+ }\r
+});\r
\r
})(jQuery);\r
*\r
* Revision: $Id: ui.draggable.js 5672 2008-05-23 04:11:30Z braeker $\r
*/\r
-\r
;(function($) {\r
- \r
- $.widget("ui.draggable", $.extend($.ui.mouse, {\r
- init: function() {\r
- \r
- //Initialize needed constants\r
- var o = this.options;\r
\r
- //Position the node\r
- if (o.helper == 'original' && !(/(relative|absolute|fixed)/).test(this.element.css('position')))\r
- this.element.css('position', 'relative');\r
+$.widget("ui.draggable", $.extend($.ui.mouse, {\r
+ init: function() {\r
+ \r
+ //Initialize needed constants\r
+ var o = this.options;\r
\r
- this.element.addClass('ui-draggable');\r
- (o.disabled && this.element.addClass('ui-draggable-disabled'));\r
- \r
- this.mouseInit();\r
- \r
- },\r
- setData: function(key, value) {\r
- (key == 'disabled' && this.element[(value ? 'add' : 'remove') + 'Class']('ui-draggable-disabled'));\r
- this.options[key] = value;\r
- },\r
- mouseStart: function(e) {\r
- var o = this.options;\r
- \r
- if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle')) return false;\r
- \r
- var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;\r
- if(!handle) $(this.options.handle, this.element).each(function() {\r
- if(this == e.target) handle = true;\r
- });\r
- if (!handle) return false;\r
- \r
- if($.ui.ddmanager) $.ui.ddmanager.current = this;\r
- \r
- //Create and append the visible helper\r
- this.helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [e])) : (o.helper == 'clone' ? this.element.clone() : this.element);\r
- if(!this.helper.parents('body').length) this.helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));\r
- if(this.helper[0] != this.element[0] && !(/(fixed|absolute)/).test(this.helper.css("position"))) this.helper.css("position", "absolute");\r
- \r
- /*\r
- * - Position generation -\r
- * This block generates everything position related - it's the core of draggables.\r
- */\r
- \r
- this.margins = { //Cache the margins\r
- left: (parseInt(this.element.css("marginLeft"),10) || 0),\r
- top: (parseInt(this.element.css("marginTop"),10) || 0)\r
- }; \r
- \r
- this.cssPosition = this.helper.css("position"); //Store the helper's css position\r
- this.offset = this.element.offset(); //The element's absolute position on the page\r
- this.offset = { //Substract the margins from the element's absolute offset\r
- top: this.offset.top - this.margins.top,\r
- left: this.offset.left - this.margins.left\r
- };\r
- \r
- this.offset.click = { //Where the click happened, relative to the element\r
- left: e.pageX - this.offset.left,\r
- top: e.pageY - this.offset.top\r
- };\r
- \r
- this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position\r
- this.offset.parent = { //Store its position plus border\r
- top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),\r
- left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)\r
- };\r
- \r
- var p = this.element.position(); //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helpers\r
- this.offset.relative = this.cssPosition == "relative" ? {\r
- top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.offsetParent[0].scrollTop,\r
- left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.offsetParent[0].scrollLeft\r
- } : { top: 0, left: 0 };\r
- \r
- this.originalPosition = this.generatePosition(e); //Generate the original position\r
- this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size\r
- \r
- if(o.cursorAt) {\r
- if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left;\r
- if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right;\r
- if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top;\r
- if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom;\r
- }\r
- \r
- \r
- /*\r
- * - Position constraining -\r
- * Here we prepare position constraining like grid and containment.\r
- */ \r
- \r
- if(o.containment) {\r
- if(o.containment == 'parent') o.containment = this.helper[0].parentNode;\r
- if(o.containment == 'document') this.containment = [0,0,$(document).width(), ($(document).height() || document.body.parentNode.scrollHeight)];\r
- if(!(/^(document|window|parent)$/).test(o.containment)) {\r
- var ce = $(o.containment)[0];\r
- var co = $(o.containment).offset();\r
- \r
- this.containment = [\r
- co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left,\r
- co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top,\r
- co.left+Math.max(ce.scrollWidth,ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),\r
- co.top+Math.max(ce.scrollHeight,ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)\r
- ];\r
- }\r
- }\r
- \r
- //Call plugins and callbacks\r
- this.propagate("start", e);\r
- \r
- this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size\r
- if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);\r
- \r
- this.helper.addClass("ui-draggable-dragging");\r
- this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position\r
- return true;\r
- },\r
- convertPositionTo: function(d, pos) {\r
- if(!pos) pos = this.position;\r
- var mod = d == "absolute" ? 1 : -1;\r
- return {\r
- top: (\r
- pos.top // the calculated relative position\r
- + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent\r
- + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)\r
- - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollTop) * mod // The offsetParent's scroll position, not if the element is fixed\r
- + (this.cssPosition == "fixed" ? this.offsetParent[0].scrollTop : 0) * mod\r
- + this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)\r
- ),\r
- left: (\r
- pos.left // the calculated relative position\r
- + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent\r
- + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)\r
- - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position, not if the element is fixed\r
- + (this.cssPosition == "fixed" ? this.offsetParent[0].scrollLeft : 0) * mod\r
- + this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)\r
- )\r
- };\r
- },\r
- generatePosition: function(e) {\r
- \r
- var o = this.options;\r
- var position = {\r
- top: (\r
- e.pageY // The absolute mouse position\r
- - this.offset.click.top // Click offset (relative to the element)\r
- - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent\r
- - this.offset.parent.top // The offsetParent's offset without borders (offset + border)\r
- + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed\r
- - (this.cssPosition == "fixed" ? this.offsetParent[0].scrollTop : 0)\r
- ),\r
- left: (\r
- e.pageX // The absolute mouse position\r
- - this.offset.click.left // Click offset (relative to the element)\r
- - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent\r
- - this.offset.parent.left // The offsetParent's offset without borders (offset + border)\r
- + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed\r
- - (this.cssPosition == "fixed" ? this.offsetParent[0].scrollLeft : 0)\r
- )\r
- };\r
- \r
- if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options\r
- \r
- /*\r
- * - Position constraining -\r
- * Constrain the position to a mix of grid, containment.\r
- */\r
- if(this.containment) {\r
- if(position.left < this.containment[0]) position.left = this.containment[0];\r
- if(position.top < this.containment[1]) position.top = this.containment[1];\r
- if(position.left > this.containment[2]) position.left = this.containment[2];\r
- if(position.top > this.containment[3]) position.top = this.containment[3];\r
- }\r
- \r
- if(o.grid) {\r
- var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];\r
- position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;\r
- \r
- var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];\r
- position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;\r
- }\r
- \r
- return position;\r
- },\r
- mouseDrag: function(e) {\r
- \r
- //Compute the helpers position\r
- this.position = this.generatePosition(e);\r
- this.positionAbs = this.convertPositionTo("absolute");\r
- \r
- //Call plugins and callbacks and use the resulting position if something is returned \r
- this.position = this.propagate("drag", e) || this.position;\r
- \r
- if(!this.options.axis || this.options.axis == "x") this.helper[0].style.left = this.position.left+'px';\r
- if(!this.options.axis || this.options.axis == "y") this.helper[0].style.top = this.position.top+'px';\r
- if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);\r
- \r
- return false;\r
- },\r
- mouseStop: function(e) {\r
- \r
- //If we are using droppables, inform the manager about the drop\r
- if ($.ui.ddmanager && !this.options.dropBehaviour)\r
- $.ui.ddmanager.drop(this, e);\r
+ //Position the node\r
+ if (o.helper == 'original' && !(/(relative|absolute|fixed)/).test(this.element.css('position')))\r
+ this.element.css('position', 'relative');\r
+\r
+ this.element.addClass('ui-draggable');\r
+ (o.disabled && this.element.addClass('ui-draggable-disabled'));\r
+ \r
+ this.mouseInit();\r
+ \r
+ },\r
+ setData: function(key, value) {\r
+ (key == 'disabled' && this.element[(value ? 'add' : 'remove') + 'Class']('ui-draggable-disabled'));\r
+ this.options[key] = value;\r
+ },\r
+ mouseStart: function(e) {\r
+ var o = this.options;\r
+ \r
+ if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle')) return false;\r
+ \r
+ var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;\r
+ if(!handle) $(this.options.handle, this.element).each(function() {\r
+ if(this == e.target) handle = true;\r
+ });\r
+ if (!handle) return false;\r
+ \r
+ if($.ui.ddmanager) $.ui.ddmanager.current = this;\r
+ \r
+ //Create and append the visible helper\r
+ this.helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [e])) : (o.helper == 'clone' ? this.element.clone() : this.element);\r
+ if(!this.helper.parents('body').length) this.helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));\r
+ if(this.helper[0] != this.element[0] && !(/(fixed|absolute)/).test(this.helper.css("position"))) this.helper.css("position", "absolute");\r
+ \r
+ /*\r
+ * - Position generation -\r
+ * This block generates everything position related - it's the core of draggables.\r
+ */\r
+ \r
+ this.margins = { //Cache the margins\r
+ left: (parseInt(this.element.css("marginLeft"),10) || 0),\r
+ top: (parseInt(this.element.css("marginTop"),10) || 0)\r
+ }; \r
+ \r
+ this.cssPosition = this.helper.css("position"); //Store the helper's css position\r
+ this.offset = this.element.offset(); //The element's absolute position on the page\r
+ this.offset = { //Substract the margins from the element's absolute offset\r
+ top: this.offset.top - this.margins.top,\r
+ left: this.offset.left - this.margins.left\r
+ };\r
+ \r
+ this.offset.click = { //Where the click happened, relative to the element\r
+ left: e.pageX - this.offset.left,\r
+ top: e.pageY - this.offset.top\r
+ };\r
+ \r
+ this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position\r
+ this.offset.parent = { //Store its position plus border\r
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),\r
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)\r
+ };\r
+ \r
+ var p = this.element.position(); //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helpers\r
+ this.offset.relative = this.cssPosition == "relative" ? {\r
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.offsetParent[0].scrollTop,\r
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.offsetParent[0].scrollLeft\r
+ } : { top: 0, left: 0 };\r
+ \r
+ this.originalPosition = this.generatePosition(e); //Generate the original position\r
+ this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size\r
+ \r
+ if(o.cursorAt) {\r
+ if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left;\r
+ if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right;\r
+ if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top;\r
+ if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom;\r
+ }\r
+ \r
+ \r
+ /*\r
+ * - Position constraining -\r
+ * Here we prepare position constraining like grid and containment.\r
+ */ \r
+ \r
+ if(o.containment) {\r
+ if(o.containment == 'parent') o.containment = this.helper[0].parentNode;\r
+ if(o.containment == 'document') this.containment = [0,0,$(document).width(), ($(document).height() || document.body.parentNode.scrollHeight)];\r
+ if(!(/^(document|window|parent)$/).test(o.containment)) {\r
+ var ce = $(o.containment)[0];\r
+ var co = $(o.containment).offset();\r
\r
- if(this.options.revert) {\r
- var self = this;\r
- $(this.helper).animate(this.originalPosition, parseInt(this.options.revert, 10) || 500, function() {\r
- self.propagate("stop", e);\r
- self.clear();\r
- });\r
- } else {\r
- this.propagate("stop", e);\r
- this.clear();\r
+ this.containment = [\r
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left,\r
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top,\r
+ co.left+Math.max(ce.scrollWidth,ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),\r
+ co.top+Math.max(ce.scrollHeight,ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)\r
+ ];\r
}\r
- \r
- return false;\r
- },\r
- clear: function() {\r
- this.helper.removeClass("ui-draggable-dragging");\r
- if(this.options.helper != 'original' && !this.cancelHelperRemoval) this.helper.remove();\r
- if($.ui.ddmanager) $.ui.ddmanager.current = null;\r
- this.helper = null;\r
- this.cancelHelperRemoval = false;\r
- },\r
- \r
- // From now on bulk stuff - mainly helpers\r
- plugins: {},\r
- uiHash: function(e) {\r
- return {\r
- helper: this.helper,\r
- position: this.position,\r
- absolutePosition: this.positionAbs,\r
- options: this.options \r
- };\r
- },\r
- propagate: function(n,e) {\r
- $.ui.plugin.call(this, n, [e, this.uiHash()]);\r
- return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [e, this.uiHash()], this.options[n]);\r
- },\r
- destroy: function() {\r
- if(!this.element.data('draggable')) return;\r
- this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable');\r
- this.mouseDestroy();\r
}\r
- }));\r
-\r
- $.extend($.ui.draggable, {\r
- defaults: {\r
- distance: 0,\r
- delay: 0,\r
- cancel: ":input,button",\r
- helper: "original",\r
- appendTo: "parent"\r
+ \r
+ //Call plugins and callbacks\r
+ this.propagate("start", e);\r
+ \r
+ this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size\r
+ if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);\r
+ \r
+ this.helper.addClass("ui-draggable-dragging");\r
+ this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position\r
+ return true;\r
+ },\r
+ convertPositionTo: function(d, pos) {\r
+ if(!pos) pos = this.position;\r
+ var mod = d == "absolute" ? 1 : -1;\r
+ return {\r
+ top: (\r
+ pos.top // the calculated relative position\r
+ + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent\r
+ + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)\r
+ - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollTop) * mod // The offsetParent's scroll position, not if the element is fixed\r
+ + (this.cssPosition == "fixed" ? this.offsetParent[0].scrollTop : 0) * mod\r
+ + this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)\r
+ ),\r
+ left: (\r
+ pos.left // the calculated relative position\r
+ + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent\r
+ + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)\r
+ - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position, not if the element is fixed\r
+ + (this.cssPosition == "fixed" ? this.offsetParent[0].scrollLeft : 0) * mod\r
+ + this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)\r
+ )\r
+ };\r
+ },\r
+ generatePosition: function(e) {\r
+ \r
+ var o = this.options;\r
+ var position = {\r
+ top: (\r
+ e.pageY // The absolute mouse position\r
+ - this.offset.click.top // Click offset (relative to the element)\r
+ - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent\r
+ - this.offset.parent.top // The offsetParent's offset without borders (offset + border)\r
+ + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed\r
+ - (this.cssPosition == "fixed" ? this.offsetParent[0].scrollTop : 0)\r
+ ),\r
+ left: (\r
+ e.pageX // The absolute mouse position\r
+ - this.offset.click.left // Click offset (relative to the element)\r
+ - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent\r
+ - this.offset.parent.left // The offsetParent's offset without borders (offset + border)\r
+ + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed\r
+ - (this.cssPosition == "fixed" ? this.offsetParent[0].scrollLeft : 0)\r
+ )\r
+ };\r
+ \r
+ if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options\r
+ \r
+ /*\r
+ * - Position constraining -\r
+ * Constrain the position to a mix of grid, containment.\r
+ */\r
+ if(this.containment) {\r
+ if(position.left < this.containment[0]) position.left = this.containment[0];\r
+ if(position.top < this.containment[1]) position.top = this.containment[1];\r
+ if(position.left > this.containment[2]) position.left = this.containment[2];\r
+ if(position.top > this.containment[3]) position.top = this.containment[3];\r
}\r
- });\r
-\r
- $.ui.plugin.add("draggable", "cursor", {\r
- start: function(e, ui) {\r
- var t = $('body');\r
- if (t.css("cursor")) ui.options._cursor = t.css("cursor");\r
- t.css("cursor", ui.options.cursor);\r
- },\r
- stop: function(e, ui) {\r
- if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);\r
+ \r
+ if(o.grid) {\r
+ var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];\r
+ position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;\r
+ \r
+ var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];\r
+ position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;\r
}\r
- });\r
- \r
- $.ui.plugin.add("draggable", "zIndex", {\r
- start: function(e, ui) {\r
- var t = $(ui.helper);\r
- if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex");\r
- t.css('zIndex', ui.options.zIndex);\r
- },\r
- stop: function(e, ui) {\r
- if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);\r
+ \r
+ return position;\r
+ },\r
+ mouseDrag: function(e) {\r
+ \r
+ //Compute the helpers position\r
+ this.position = this.generatePosition(e);\r
+ this.positionAbs = this.convertPositionTo("absolute");\r
+ \r
+ //Call plugins and callbacks and use the resulting position if something is returned \r
+ this.position = this.propagate("drag", e) || this.position;\r
+ \r
+ if(!this.options.axis || this.options.axis == "x") this.helper[0].style.left = this.position.left+'px';\r
+ if(!this.options.axis || this.options.axis == "y") this.helper[0].style.top = this.position.top+'px';\r
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);\r
+ \r
+ return false;\r
+ },\r
+ mouseStop: function(e) {\r
+ \r
+ //If we are using droppables, inform the manager about the drop\r
+ if ($.ui.ddmanager && !this.options.dropBehaviour)\r
+ $.ui.ddmanager.drop(this, e);\r
+ \r
+ if(this.options.revert) {\r
+ var self = this;\r
+ $(this.helper).animate(this.originalPosition, parseInt(this.options.revert, 10) || 500, function() {\r
+ self.propagate("stop", e);\r
+ self.clear();\r
+ });\r
+ } else {\r
+ this.propagate("stop", e);\r
+ this.clear();\r
}\r
- });\r
+ \r
+ return false;\r
+ },\r
+ clear: function() {\r
+ this.helper.removeClass("ui-draggable-dragging");\r
+ if(this.options.helper != 'original' && !this.cancelHelperRemoval) this.helper.remove();\r
+ if($.ui.ddmanager) $.ui.ddmanager.current = null;\r
+ this.helper = null;\r
+ this.cancelHelperRemoval = false;\r
+ },\r
\r
- $.ui.plugin.add("draggable", "opacity", {\r
- start: function(e, ui) {\r
- var t = $(ui.helper);\r
- if(t.css("opacity")) ui.options._opacity = t.css("opacity");\r
- t.css('opacity', ui.options.opacity);\r
- },\r
- stop: function(e, ui) {\r
- if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity);\r
+ // From now on bulk stuff - mainly helpers\r
+ plugins: {},\r
+ uiHash: function(e) {\r
+ return {\r
+ helper: this.helper,\r
+ position: this.position,\r
+ absolutePosition: this.positionAbs,\r
+ options: this.options \r
+ };\r
+ },\r
+ propagate: function(n,e) {\r
+ $.ui.plugin.call(this, n, [e, this.uiHash()]);\r
+ return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [e, this.uiHash()], this.options[n]);\r
+ },\r
+ destroy: function() {\r
+ if(!this.element.data('draggable')) return;\r
+ this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable');\r
+ this.mouseDestroy();\r
+ }\r
+}));\r
+\r
+$.extend($.ui.draggable, {\r
+ defaults: {\r
+ distance: 0,\r
+ delay: 0,\r
+ cancel: ":input,button",\r
+ helper: "original",\r
+ appendTo: "parent"\r
+ }\r
+});\r
+\r
+$.ui.plugin.add("draggable", "cursor", {\r
+ start: function(e, ui) {\r
+ var t = $('body');\r
+ if (t.css("cursor")) ui.options._cursor = t.css("cursor");\r
+ t.css("cursor", ui.options.cursor);\r
+ },\r
+ stop: function(e, ui) {\r
+ if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);\r
+ }\r
+});\r
+\r
+$.ui.plugin.add("draggable", "zIndex", {\r
+ start: function(e, ui) {\r
+ var t = $(ui.helper);\r
+ if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex");\r
+ t.css('zIndex', ui.options.zIndex);\r
+ },\r
+ stop: function(e, ui) {\r
+ if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);\r
+ }\r
+});\r
+\r
+$.ui.plugin.add("draggable", "opacity", {\r
+ start: function(e, ui) {\r
+ var t = $(ui.helper);\r
+ if(t.css("opacity")) ui.options._opacity = t.css("opacity");\r
+ t.css('opacity', ui.options.opacity);\r
+ },\r
+ stop: function(e, ui) {\r
+ if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity);\r
+ }\r
+});\r
+\r
+$.ui.plugin.add("draggable", "iframeFix", {\r
+ start: function(e, ui) {\r
+ $(ui.options.iframeFix === true ? "iframe" : ui.options.iframeFix).each(function() { \r
+ $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')\r
+ .css({\r
+ width: this.offsetWidth+"px", height: this.offsetHeight+"px",\r
+ position: "absolute", opacity: "0.001", zIndex: 1000\r
+ })\r
+ .css($(this).offset())\r
+ .appendTo("body");\r
+ });\r
+ },\r
+ stop: function(e, ui) {\r
+ $("div.DragDropIframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers \r
+ }\r
+});\r
+\r
+$.ui.plugin.add("draggable", "scroll", {\r
+ start: function(e, ui) {\r
+ var o = ui.options;\r
+ var i = $(this).data("draggable");\r
+ o.scrollSensitivity = o.scrollSensitivity || 20;\r
+ o.scrollSpeed = o.scrollSpeed || 20;\r
+ \r
+ i.overflowY = function(el) {\r
+ do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);\r
+ return $(document);\r
+ }(this);\r
+ i.overflowX = function(el) {\r
+ do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode);\r
+ return $(document);\r
+ }(this);\r
+ \r
+ if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') i.overflowYOffset = i.overflowY.offset();\r
+ if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') i.overflowXOffset = i.overflowX.offset();\r
+ \r
+ },\r
+ drag: function(e, ui) {\r
+ \r
+ var o = ui.options;\r
+ var i = $(this).data("draggable");\r
+ \r
+ if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {\r
+ if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)\r
+ i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;\r
+ if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity)\r
+ i.overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed;\r
+ \r
+ } else {\r
+ if(e.pageY - $(document).scrollTop() < o.scrollSensitivity)\r
+ $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);\r
+ if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity)\r
+ $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);\r
}\r
- });\r
- \r
- $.ui.plugin.add("draggable", "iframeFix", {\r
- start: function(e, ui) {\r
- $(ui.options.iframeFix === true ? "iframe" : ui.options.iframeFix).each(function() { \r
- $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')\r
- .css({\r
- width: this.offsetWidth+"px", height: this.offsetHeight+"px",\r
- position: "absolute", opacity: "0.001", zIndex: 1000\r
- })\r
- .css($(this).offset())\r
- .appendTo("body");\r
- });\r
- },\r
- stop: function(e, ui) {\r
- $("div.DragDropIframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers \r
+ \r
+ if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {\r
+ if((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity)\r
+ i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed;\r
+ if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity)\r
+ i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed;\r
+ } else {\r
+ if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)\r
+ $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);\r
+ if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)\r
+ $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);\r
}\r
- });\r
- \r
- $.ui.plugin.add("draggable", "scroll", {\r
- start: function(e, ui) {\r
- var o = ui.options;\r
- var i = $(this).data("draggable");\r
- o.scrollSensitivity = o.scrollSensitivity || 20;\r
- o.scrollSpeed = o.scrollSpeed || 20;\r
- \r
- i.overflowY = function(el) {\r
- do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);\r
- return $(document);\r
- }(this);\r
- i.overflowX = function(el) {\r
- do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode);\r
- return $(document);\r
- }(this);\r
- \r
- if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') i.overflowYOffset = i.overflowY.offset();\r
- if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') i.overflowXOffset = i.overflowX.offset();\r
- \r
- },\r
- drag: function(e, ui) {\r
- \r
- var o = ui.options;\r
- var i = $(this).data("draggable");\r
- \r
- if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {\r
- if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)\r
- i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;\r
- if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity)\r
- i.overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed;\r
- \r
- } else {\r
- if(e.pageY - $(document).scrollTop() < o.scrollSensitivity)\r
- $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);\r
- if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity)\r
- $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);\r
+ \r
+ }\r
+});\r
+\r
+$.ui.plugin.add("draggable", "snap", {\r
+ start: function(e, ui) {\r
+ \r
+ var inst = $(this).data("draggable");\r
+ inst.snapElements = [];\r
+ $(ui.options.snap === true ? '.ui-draggable' : ui.options.snap).each(function() {\r
+ var $t = $(this); var $o = $t.offset();\r
+ if(this != inst.element[0]) inst.snapElements.push({\r
+ item: this,\r
+ width: $t.outerWidth(), height: $t.outerHeight(),\r
+ top: $o.top, left: $o.left\r
+ });\r
+ });\r
+ \r
+ },\r
+ drag: function(e, ui) {\r
+ \r
+ var inst = $(this).data("draggable");\r
+ var d = ui.options.snapTolerance || 20;\r
+ var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width,\r
+ y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height;\r
+ \r
+ for (var i = inst.snapElements.length - 1; i >= 0; i--){\r
+ \r
+ var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, \r
+ t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;\r
+ \r
+ //Yes, I know, this is insane ;)\r
+ if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) continue;\r
+ \r
+ if(ui.options.snapMode != 'inner') {\r
+ var ts = Math.abs(t - y2) <= 20;\r
+ var bs = Math.abs(b - y1) <= 20;\r
+ var ls = Math.abs(l - x2) <= 20;\r
+ var rs = Math.abs(r - x1) <= 20;\r
+ if(ts) ui.position.top = inst.convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;\r
+ if(bs) ui.position.top = inst.convertPositionTo("relative", { top: b, left: 0 }).top;\r
+ if(ls) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;\r
+ if(rs) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: r }).left;\r
}\r
\r
- if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {\r
- if((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity)\r
- i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed;\r
- if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity)\r
- i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed;\r
- } else {\r
- if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)\r
- $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);\r
- if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)\r
- $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);\r
+ if(ui.options.snapMode != 'outer') {\r
+ var ts = Math.abs(t - y1) <= 20;\r
+ var bs = Math.abs(b - y2) <= 20;\r
+ var ls = Math.abs(l - x1) <= 20;\r
+ var rs = Math.abs(r - x2) <= 20;\r
+ if(ts) ui.position.top = inst.convertPositionTo("relative", { top: t, left: 0 }).top;\r
+ if(bs) ui.position.top = inst.convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;\r
+ if(ls) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: l }).left;\r
+ if(rs) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;\r
}\r
\r
- }\r
- });\r
+ };\r
+ }\r
+});\r
+\r
+$.ui.plugin.add("draggable", "connectToSortable", {\r
+ start: function(e,ui) {\r
\r
- $.ui.plugin.add("draggable", "snap", {\r
- start: function(e, ui) {\r
- \r
- var inst = $(this).data("draggable");\r
- inst.snapElements = [];\r
- $(ui.options.snap === true ? '.ui-draggable' : ui.options.snap).each(function() {\r
- var $t = $(this); var $o = $t.offset();\r
- if(this != inst.element[0]) inst.snapElements.push({\r
- item: this,\r
- width: $t.outerWidth(), height: $t.outerHeight(),\r
- top: $o.top, left: $o.left\r
+ var inst = $(this).data("draggable");\r
+ inst.sortables = [];\r
+ $(ui.options.connectToSortable).each(function() {\r
+ if($.data(this, 'sortable')) {\r
+ var sortable = $.data(this, 'sortable');\r
+ inst.sortables.push({\r
+ instance: sortable,\r
+ shouldRevert: sortable.options.revert\r
});\r
- });\r
- \r
- },\r
- drag: function(e, ui) {\r
- \r
- var inst = $(this).data("draggable");\r
- var d = ui.options.snapTolerance || 20;\r
- var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width,\r
- y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height;\r
- \r
- for (var i = inst.snapElements.length - 1; i >= 0; i--){\r
+ sortable.refresh(); //Do a one-time refresh at start to refresh the containerCache \r
+ sortable.propagate("activate", e, inst);\r
+ }\r
+ });\r
+\r
+ },\r
+ stop: function(e,ui) {\r
+ \r
+ //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper\r
+ var inst = $(this).data("draggable");\r
+ \r
+ $.each(inst.sortables, function() {\r
+ if(this.instance.isOver) {\r
+ this.instance.isOver = 0;\r
+ inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance\r
+ this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)\r
+ if(this.shouldRevert) this.instance.options.revert = true; //revert here\r
+ this.instance.mouseStop(e);\r
\r
- var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, \r
- t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;\r
+ //Also propagate receive event, since the sortable is actually receiving a element\r
+ this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), { sender: inst.element })], this.instance.options["receive"]);\r
+\r
+ this.instance.options.helper = this.instance.options._helper;\r
+ } else {\r
+ this.instance.propagate("deactivate", e, inst);\r
+ }\r
+\r
+ });\r
+ \r
+ },\r
+ drag: function(e,ui) {\r
+\r
+ var inst = $(this).data("draggable"), self = this;\r
+ \r
+ var checkPos = function(o) {\r
\r
- //Yes, I know, this is insane ;)\r
- if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) continue;\r
+ var l = o.left, r = l + o.width,\r
+ t = o.top, b = t + o.height;\r
+\r
+ return (l < (this.positionAbs.left + this.offset.click.left) && (this.positionAbs.left + this.offset.click.left) < r\r
+ && t < (this.positionAbs.top + this.offset.click.top) && (this.positionAbs.top + this.offset.click.top) < b); \r
+ };\r
+ \r
+ $.each(inst.sortables, function(i) {\r
+\r
+ if(checkPos.call(inst, this.instance.containerCache)) {\r
+\r
+ //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once\r
+ if(!this.instance.isOver) {\r
+ this.instance.isOver = 1;\r
+\r
+ //Now we fake the start of dragging for the sortable instance,\r
+ //by cloning the list group item, appending it to the sortable and using it as inst.currentItem\r
+ //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)\r
+ this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);\r
+ this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it\r
+ this.instance.options.helper = function() { return ui.helper[0]; };\r
\r
- if(ui.options.snapMode != 'inner') {\r
- var ts = Math.abs(t - y2) <= 20;\r
- var bs = Math.abs(b - y1) <= 20;\r
- var ls = Math.abs(l - x2) <= 20;\r
- var rs = Math.abs(r - x1) <= 20;\r
- if(ts) ui.position.top = inst.convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;\r
- if(bs) ui.position.top = inst.convertPositionTo("relative", { top: b, left: 0 }).top;\r
- if(ls) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;\r
- if(rs) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: r }).left;\r
- }\r
+ e.target = this.instance.currentItem[0];\r
+ this.instance.mouseStart(e, true, true);\r
+\r
+ //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes\r
+ this.instance.offset.click.top = inst.offset.click.top;\r
+ this.instance.offset.click.left = inst.offset.click.left;\r
+ this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;\r
+ this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;\r
+ \r
+ inst.propagate("toSortable", e);\r
\r
- if(ui.options.snapMode != 'outer') {\r
- var ts = Math.abs(t - y1) <= 20;\r
- var bs = Math.abs(b - y2) <= 20;\r
- var ls = Math.abs(l - x1) <= 20;\r
- var rs = Math.abs(r - x2) <= 20;\r
- if(ts) ui.position.top = inst.convertPositionTo("relative", { top: t, left: 0 }).top;\r
- if(bs) ui.position.top = inst.convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;\r
- if(ls) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: l }).left;\r
- if(rs) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;\r
}\r
\r
- };\r
- }\r
- });\r
- \r
- $.ui.plugin.add("draggable", "connectToSortable", {\r
- start: function(e,ui) {\r
- \r
- var inst = $(this).data("draggable");\r
- inst.sortables = [];\r
- $(ui.options.connectToSortable).each(function() {\r
- if($.data(this, 'sortable')) {\r
- var sortable = $.data(this, 'sortable');\r
- inst.sortables.push({\r
- instance: sortable,\r
- shouldRevert: sortable.options.revert\r
- });\r
- sortable.refresh(); //Do a one-time refresh at start to refresh the containerCache \r
- sortable.propagate("activate", e, inst);\r
- }\r
- });\r
-\r
- },\r
- stop: function(e,ui) {\r
- \r
- //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper\r
- var inst = $(this).data("draggable");\r
- \r
- $.each(inst.sortables, function() {\r
+ //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\r
+ if(this.instance.currentItem) this.instance.mouseDrag(e);\r
+ \r
+ } else {\r
+ \r
+ //If it doesn't intersect with the sortable, and it intersected before,\r
+ //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval\r
if(this.instance.isOver) {\r
this.instance.isOver = 0;\r
- inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance\r
- this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)\r
- if(this.shouldRevert) this.instance.options.revert = true; //revert here\r
- this.instance.mouseStop(e);\r
- \r
- //Also propagate receive event, since the sortable is actually receiving a element\r
- this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), { sender: inst.element })], this.instance.options["receive"]);\r
-\r
+ this.instance.cancelHelperRemoval = true;\r
+ this.instance.options.revert = false; //No revert here\r
+ this.instance.mouseStop(e, true);\r
this.instance.options.helper = this.instance.options._helper;\r
- } else {\r
- this.instance.propagate("deactivate", e, inst);\r
- }\r
-\r
- });\r
- \r
- },\r
- drag: function(e,ui) {\r
-\r
- var inst = $(this).data("draggable"), self = this;\r
- \r
- var checkPos = function(o) {\r
\r
- var l = o.left, r = l + o.width,\r
- t = o.top, b = t + o.height;\r
- \r
- return (l < (this.positionAbs.left + this.offset.click.left) && (this.positionAbs.left + this.offset.click.left) < r\r
- && t < (this.positionAbs.top + this.offset.click.top) && (this.positionAbs.top + this.offset.click.top) < b); \r
+ //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size\r
+ this.instance.currentItem.remove();\r
+ this.instance.placeholder.remove();\r
+ \r
+ inst.propagate("fromSortable", e);\r
+ }\r
+ \r
};\r
- \r
- $.each(inst.sortables, function(i) {\r
-\r
- if(checkPos.call(inst, this.instance.containerCache)) {\r
-\r
- //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once\r
- if(!this.instance.isOver) {\r
- this.instance.isOver = 1;\r
\r
- //Now we fake the start of dragging for the sortable instance,\r
- //by cloning the list group item, appending it to the sortable and using it as inst.currentItem\r
- //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)\r
- this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);\r
- this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it\r
- this.instance.options.helper = function() { return ui.helper[0]; };\r
- \r
- e.target = this.instance.currentItem[0];\r
- this.instance.mouseStart(e, true, true);\r
+ });\r
\r
- //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes\r
- this.instance.offset.click.top = inst.offset.click.top;\r
- this.instance.offset.click.left = inst.offset.click.left;\r
- this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;\r
- this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;\r
- \r
- inst.propagate("toSortable", e);\r
- \r
- }\r
- \r
- //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\r
- if(this.instance.currentItem) this.instance.mouseDrag(e);\r
- \r
- } else {\r
- \r
- //If it doesn't intersect with the sortable, and it intersected before,\r
- //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval\r
- if(this.instance.isOver) {\r
- this.instance.isOver = 0;\r
- this.instance.cancelHelperRemoval = true;\r
- this.instance.options.revert = false; //No revert here\r
- this.instance.mouseStop(e, true);\r
- this.instance.options.helper = this.instance.options._helper;\r
- \r
- //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size\r
- this.instance.currentItem.remove();\r
- this.instance.placeholder.remove();\r
- \r
- inst.propagate("fromSortable", e);\r
- }\r
- \r
- };\r
+ }\r
+});\r
\r
- });\r
+$.ui.plugin.add("draggable", "stack", {\r
+ start: function(e,ui) {\r
+ var group = $.makeArray($(ui.options.stack.group)).sort(function(a,b) {\r
+ return (parseInt($(a).css("zIndex"),10) || ui.options.stack.min) - (parseInt($(b).css("zIndex"),10) || ui.options.stack.min);\r
+ });\r
+ \r
+ $(group).each(function(i) {\r
+ this.style.zIndex = ui.options.stack.min + i;\r
+ });\r
+ \r
+ this[0].style.zIndex = ui.options.stack.min + group.length;\r
+ }\r
+});\r
\r
- }\r
- });\r
- \r
- $.ui.plugin.add("draggable", "stack", {\r
- start: function(e,ui) {\r
- var group = $.makeArray($(ui.options.stack.group)).sort(function(a,b) {\r
- return (parseInt($(a).css("zIndex"),10) || ui.options.stack.min) - (parseInt($(b).css("zIndex"),10) || ui.options.stack.min);\r
- });\r
- \r
- $(group).each(function(i) {\r
- this.style.zIndex = ui.options.stack.min + i;\r
- });\r
- \r
- this[0].style.zIndex = ui.options.stack.min + group.length;\r
- }\r
- });\r
- \r
})(jQuery);\r
*\r
* Revision: $Id: ui.droppable.js 5568 2008-05-12 15:07:16Z paul.bakaus $\r
*/\r
-\r
;(function($) {\r
\r
- $.widget("ui.droppable", {\r
- init: function() {\r
- \r
- this.element.addClass("ui-droppable");\r
- this.isover = 0; this.isout = 1;\r
- \r
- //Prepare the passed options\r
- var o = this.options, accept = o.accept;\r
- o = $.extend(o, {\r
- accept: o.accept && o.accept.constructor == Function ? o.accept : function(d) {\r
- return $(d).is(accept);\r
- }\r
- });\r
- \r
- //Store the droppable's proportions\r
- this.proportions = { width: this.element.outerWidth(), height: this.element.outerHeight() };\r
- \r
- // Add the reference and positions to the manager\r
- $.ui.ddmanager.droppables.push(this);\r
- \r
- },\r
- plugins: {},\r
- ui: function(c) {\r
- return {\r
- instance: this,\r
- draggable: (c.currentItem || c.element),\r
- helper: c.helper,\r
- position: c.position,\r
- absolutePosition: c.positionAbs,\r
- options: this.options,\r
- element: this.element\r
- };\r
- },\r
- destroy: function() {\r
- var drop = $.ui.ddmanager.droppables;\r
- for ( var i = 0; i < drop.length; i++ )\r
- if ( drop[i] == this )\r
- drop.splice(i, 1);\r
- \r
- this.element\r
- .removeClass("ui-droppable ui-droppable-disabled")\r
- .removeData("droppable")\r
- .unbind(".droppable");\r
- },\r
- enable: function() {\r
- this.element.removeClass("ui-droppable-disabled");\r
- this.options.disabled = false;\r
- },\r
- disable: function() {\r
- this.element.addClass("ui-droppable-disabled");\r
- this.options.disabled = true;\r
- },\r
- over: function(e) {\r
- \r
- var draggable = $.ui.ddmanager.current;\r
- if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element\r
- \r
- if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {\r
- $.ui.plugin.call(this, 'over', [e, this.ui(draggable)]);\r
- this.element.triggerHandler("dropover", [e, this.ui(draggable)], this.options.over);\r
- }\r
- \r
- },\r
- out: function(e) {\r
- \r
- var draggable = $.ui.ddmanager.current;\r
- if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element\r
- \r
- if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {\r
- $.ui.plugin.call(this, 'out', [e, this.ui(draggable)]);\r
- this.element.triggerHandler("dropout", [e, this.ui(draggable)], this.options.out);\r
+$.widget("ui.droppable", {\r
+ init: function() {\r
+\r
+ this.element.addClass("ui-droppable");\r
+ this.isover = 0; this.isout = 1;\r
+ \r
+ //Prepare the passed options\r
+ var o = this.options, accept = o.accept;\r
+ o = $.extend(o, {\r
+ accept: o.accept && o.accept.constructor == Function ? o.accept : function(d) {\r
+ return $(d).is(accept);\r
}\r
- \r
- },\r
- drop: function(e,custom) {\r
- \r
- var draggable = custom || $.ui.ddmanager.current;\r
- if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element\r
- \r
- var childrenIntersection = false;\r
- this.element.find(".ui-droppable").not(".ui-draggable-dragging").each(function() {\r
- var inst = $.data(this, 'droppable');\r
- if(inst.options.greedy && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)) {\r
- childrenIntersection = true; return false;\r
- }\r
- });\r
- if(childrenIntersection) return false;\r
- \r
- if(this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {\r
- $.ui.plugin.call(this, 'drop', [e, this.ui(draggable)]);\r
- this.element.triggerHandler("drop", [e, this.ui(draggable)], this.options.drop);\r
- return true;\r
+ });\r
+ \r
+ //Store the droppable's proportions\r
+ this.proportions = { width: this.element.outerWidth(), height: this.element.outerHeight() };\r
+ \r
+ // Add the reference and positions to the manager\r
+ $.ui.ddmanager.droppables.push(this);\r
+ \r
+ },\r
+ plugins: {},\r
+ ui: function(c) {\r
+ return {\r
+ instance: this,\r
+ draggable: (c.currentItem || c.element),\r
+ helper: c.helper,\r
+ position: c.position,\r
+ absolutePosition: c.positionAbs,\r
+ options: this.options,\r
+ element: this.element\r
+ };\r
+ },\r
+ destroy: function() {\r
+ var drop = $.ui.ddmanager.droppables;\r
+ for ( var i = 0; i < drop.length; i++ )\r
+ if ( drop[i] == this )\r
+ drop.splice(i, 1);\r
+ \r
+ this.element\r
+ .removeClass("ui-droppable ui-droppable-disabled")\r
+ .removeData("droppable")\r
+ .unbind(".droppable");\r
+ },\r
+ enable: function() {\r
+ this.element.removeClass("ui-droppable-disabled");\r
+ this.options.disabled = false;\r
+ },\r
+ disable: function() {\r
+ this.element.addClass("ui-droppable-disabled");\r
+ this.options.disabled = true;\r
+ },\r
+ over: function(e) {\r
+ \r
+ var draggable = $.ui.ddmanager.current;\r
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element\r
+ \r
+ if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {\r
+ $.ui.plugin.call(this, 'over', [e, this.ui(draggable)]);\r
+ this.element.triggerHandler("dropover", [e, this.ui(draggable)], this.options.over);\r
+ }\r
+ \r
+ },\r
+ out: function(e) {\r
+ \r
+ var draggable = $.ui.ddmanager.current;\r
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element\r
+ \r
+ if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {\r
+ $.ui.plugin.call(this, 'out', [e, this.ui(draggable)]);\r
+ this.element.triggerHandler("dropout", [e, this.ui(draggable)], this.options.out);\r
+ }\r
+ \r
+ },\r
+ drop: function(e,custom) {\r
+ \r
+ var draggable = custom || $.ui.ddmanager.current;\r
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element\r
+ \r
+ var childrenIntersection = false;\r
+ this.element.find(".ui-droppable").not(".ui-draggable-dragging").each(function() {\r
+ var inst = $.data(this, 'droppable');\r
+ if(inst.options.greedy && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)) {\r
+ childrenIntersection = true; return false;\r
}\r
- \r
- return false;\r
- \r
- },\r
- activate: function(e) {\r
- \r
- var draggable = $.ui.ddmanager.current;\r
- $.ui.plugin.call(this, 'activate', [e, this.ui(draggable)]);\r
- if(draggable) this.element.triggerHandler("dropactivate", [e, this.ui(draggable)], this.options.activate);\r
- \r
- },\r
- deactivate: function(e) {\r
- \r
- var draggable = $.ui.ddmanager.current;\r
- $.ui.plugin.call(this, 'deactivate', [e, this.ui(draggable)]);\r
- if(draggable) this.element.triggerHandler("dropdeactivate", [e, this.ui(draggable)], this.options.deactivate);\r
- \r
+ });\r
+ if(childrenIntersection) return false;\r
+ \r
+ if(this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {\r
+ $.ui.plugin.call(this, 'drop', [e, this.ui(draggable)]);\r
+ this.element.triggerHandler("drop", [e, this.ui(draggable)], this.options.drop);\r
+ return true;\r
}\r
- });\r
+ \r
+ return false;\r
+ \r
+ },\r
+ activate: function(e) {\r
+ \r
+ var draggable = $.ui.ddmanager.current;\r
+ $.ui.plugin.call(this, 'activate', [e, this.ui(draggable)]);\r
+ if(draggable) this.element.triggerHandler("dropactivate", [e, this.ui(draggable)], this.options.activate);\r
+ \r
+ },\r
+ deactivate: function(e) {\r
+ \r
+ var draggable = $.ui.ddmanager.current;\r
+ $.ui.plugin.call(this, 'deactivate', [e, this.ui(draggable)]);\r
+ if(draggable) this.element.triggerHandler("dropdeactivate", [e, this.ui(draggable)], this.options.deactivate);\r
+ \r
+ }\r
+});\r
+\r
+$.extend($.ui.droppable, {\r
+ defaults: {\r
+ disabled: false,\r
+ tolerance: 'intersect'\r
+ }\r
+});\r
+\r
+$.ui.intersect = function(draggable, droppable, toleranceMode) {\r
+ \r
+ if (!droppable.offset) return false;\r
+ \r
+ var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,\r
+ y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;\r
+ var l = droppable.offset.left, r = l + droppable.proportions.width,\r
+ t = droppable.offset.top, b = t + droppable.proportions.height;\r
\r
- $.extend($.ui.droppable, {\r
- defaults: {\r
- disabled: false,\r
- tolerance: 'intersect'\r
+ switch (toleranceMode) {\r
+ case 'fit':\r
+ return (l < x1 && x2 < r\r
+ && t < y1 && y2 < b);\r
+ break;\r
+ case 'intersect':\r
+ return (l < x1 + (draggable.helperProportions.width / 2) // Right Half\r
+ && x2 - (draggable.helperProportions.width / 2) < r // Left Half\r
+ && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half\r
+ && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half\r
+ break;\r
+ case 'pointer':\r
+ return (l < ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) && ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) < r\r
+ && t < ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) && ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) < b);\r
+ break;\r
+ case 'touch':\r
+ return (\r
+ (y1 >= t && y1 <= b) || // Top edge touching\r
+ (y2 >= t && y2 <= b) || // Bottom edge touching\r
+ (y1 < t && y2 > b) // Surrounded vertically\r
+ ) && (\r
+ (x1 >= l && x1 <= r) || // Left edge touching\r
+ (x2 >= l && x2 <= r) || // Right edge touching\r
+ (x1 < l && x2 > r) // Surrounded horizontally\r
+ );\r
+ break;\r
+ default:\r
+ return false;\r
+ break;\r
}\r
- });\r
\r
- $.ui.intersect = function(draggable, droppable, toleranceMode) {\r
+};\r
+\r
+/*\r
+ This manager tracks offsets of draggables and droppables\r
+*/\r
+$.ui.ddmanager = {\r
+ current: null,\r
+ droppables: [],\r
+ prepareOffsets: function(t, e) {\r
\r
- if (!droppable.offset) return false;\r
+ var m = $.ui.ddmanager.droppables;\r
+ var type = e ? e.type : null; // workaround for #2317\r
+ for (var i = 0; i < m.length; i++) {\r
+ \r
+ if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element,(t.currentItem || t.element)))) continue;\r
+ m[i].visible = m[i].element.is(":visible"); if(!m[i].visible) continue; //If the element is not visible, continue\r
+ m[i].offset = m[i].element.offset();\r
+ m[i].proportions = { width: m[i].element.outerWidth(), height: m[i].element.outerHeight() };\r
+ \r
+ if(type == "dragstart" || type == "sortactivate") m[i].activate.call(m[i], e); //Activate the droppable if used directly from draggables\r
+ }\r
\r
- var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,\r
- y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;\r
- var l = droppable.offset.left, r = l + droppable.proportions.width,\r
- t = droppable.offset.top, b = t + droppable.proportions.height;\r
+ },\r
+ drop: function(draggable, e) {\r
\r
- switch (toleranceMode) {\r
- case 'fit':\r
- return (l < x1 && x2 < r\r
- && t < y1 && y2 < b);\r
- break;\r
- case 'intersect':\r
- return (l < x1 + (draggable.helperProportions.width / 2) // Right Half\r
- && x2 - (draggable.helperProportions.width / 2) < r // Left Half\r
- && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half\r
- && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half\r
- break;\r
- case 'pointer':\r
- return (l < ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) && ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) < r\r
- && t < ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) && ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) < b);\r
- break;\r
- case 'touch':\r
- return (\r
- (y1 >= t && y1 <= b) || // Top edge touching\r
- (y2 >= t && y2 <= b) || // Bottom edge touching\r
- (y1 < t && y2 > b) // Surrounded vertically\r
- ) && (\r
- (x1 >= l && x1 <= r) || // Left edge touching\r
- (x2 >= l && x2 <= r) || // Right edge touching\r
- (x1 < l && x2 > r) // Surrounded horizontally\r
- );\r
- break;\r
- default:\r
- return false;\r
- break;\r
+ var dropped = false;\r
+ $.each($.ui.ddmanager.droppables, function() {\r
+ \r
+ if(!this.options) return;\r
+ if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))\r
+ dropped = this.drop.call(this, e);\r
+ \r
+ if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {\r
+ this.isout = 1; this.isover = 0;\r
+ this.deactivate.call(this, e);\r
}\r
+ \r
+ });\r
+ return dropped;\r
\r
- };\r
- \r
- /*\r
- This manager tracks offsets of draggables and droppables\r
- */\r
- $.ui.ddmanager = {\r
- current: null,\r
- droppables: [],\r
- prepareOffsets: function(t, e) {\r
+ },\r
+ drag: function(draggable, e) {\r
+ \r
+ //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.\r
+ if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, e);\r
+ \r
+ //Run through all droppables and check their positions based on specific tolerance options\r
+ $.each($.ui.ddmanager.droppables, function() {\r
\r
- var m = $.ui.ddmanager.droppables;\r
- var type = e ? e.type : null; // workaround for #2317\r
- for (var i = 0; i < m.length; i++) {\r
- \r
- if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element,(t.currentItem || t.element)))) continue;\r
- m[i].visible = m[i].element.is(":visible"); if(!m[i].visible) continue; //If the element is not visible, continue\r
- m[i].offset = m[i].element.offset();\r
- m[i].proportions = { width: m[i].element.outerWidth(), height: m[i].element.outerHeight() };\r
- \r
- if(type == "dragstart" || type == "sortactivate") m[i].activate.call(m[i], e); //Activate the droppable if used directly from draggables\r
- }\r
+ if(this.disabled || this.greedyChild || !this.visible) return;\r
+ var intersects = $.ui.intersect(draggable, this, this.options.tolerance);\r
\r
- },\r
- drop: function(draggable, e) {\r
+ var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);\r
+ if(!c) return;\r
\r
- var dropped = false;\r
- $.each($.ui.ddmanager.droppables, function() {\r
- \r
- if(!this.options) return;\r
- if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))\r
- dropped = this.drop.call(this, e);\r
- \r
- if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {\r
- this.isout = 1; this.isover = 0;\r
- this.deactivate.call(this, e);\r
+ var parentInstance;\r
+ if (this.options.greedy) {\r
+ var parent = this.element.parents('.ui-droppable:eq(0)');\r
+ if (parent.length) {\r
+ parentInstance = $.data(parent[0], 'droppable');\r
+ parentInstance.greedyChild = (c == 'isover' ? 1 : 0);\r
}\r
- \r
- });\r
- return dropped;\r
+ }\r
\r
- },\r
- drag: function(draggable, e) {\r
+ // we just moved into a greedy child\r
+ if (parentInstance && c == 'isover') {\r
+ parentInstance['isover'] = 0;\r
+ parentInstance['isout'] = 1;\r
+ parentInstance.out.call(parentInstance, e);\r
+ }\r
\r
- //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.\r
- if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, e);\r
+ this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;\r
+ this[c == "isover" ? "over" : "out"].call(this, e);\r
\r
- //Run through all droppables and check their positions based on specific tolerance options\r
- $.each($.ui.ddmanager.droppables, function() {\r
- \r
- if(this.disabled || this.greedyChild || !this.visible) return;\r
- var intersects = $.ui.intersect(draggable, this, this.options.tolerance);\r
- \r
- var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);\r
- if(!c) return;\r
- \r
- var parentInstance;\r
- if (this.options.greedy) {\r
- var parent = this.element.parents('.ui-droppable:eq(0)');\r
- if (parent.length) {\r
- parentInstance = $.data(parent[0], 'droppable');\r
- parentInstance.greedyChild = (c == 'isover' ? 1 : 0);\r
- }\r
- }\r
- \r
- // we just moved into a greedy child\r
- if (parentInstance && c == 'isover') {\r
- parentInstance['isover'] = 0;\r
- parentInstance['isout'] = 1;\r
- parentInstance.out.call(parentInstance, e);\r
- }\r
- \r
- this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;\r
- this[c == "isover" ? "over" : "out"].call(this, e);\r
- \r
- // we just moved out of a greedy child\r
- if (parentInstance && c == 'isout') {\r
- parentInstance['isout'] = 0;\r
- parentInstance['isover'] = 1;\r
- parentInstance.over.call(parentInstance, e);\r
- }\r
- });\r
- \r
- }\r
- };\r
- \r
+ // we just moved out of a greedy child\r
+ if (parentInstance && c == 'isout') {\r
+ parentInstance['isout'] = 0;\r
+ parentInstance['isover'] = 1;\r
+ parentInstance.over.call(parentInstance, e);\r
+ }\r
+ });\r
+ \r
+ }\r
+};\r
+\r
/*\r
* Droppable Extensions\r
*/\r
- \r
- $.ui.plugin.add("droppable", "activeClass", {\r
- activate: function(e, ui) {\r
- $(this).addClass(ui.options.activeClass);\r
- },\r
- deactivate: function(e, ui) {\r
- $(this).removeClass(ui.options.activeClass);\r
- },\r
- drop: function(e, ui) {\r
- $(this).removeClass(ui.options.activeClass);\r
- }\r
- });\r
- \r
- $.ui.plugin.add("droppable", "hoverClass", {\r
- over: function(e, ui) {\r
- $(this).addClass(ui.options.hoverClass);\r
- },\r
- out: function(e, ui) {\r
- $(this).removeClass(ui.options.hoverClass);\r
- },\r
- drop: function(e, ui) {\r
- $(this).removeClass(ui.options.hoverClass);\r
- }\r
- });\r
- \r
+\r
+$.ui.plugin.add("droppable", "activeClass", {\r
+ activate: function(e, ui) {\r
+ $(this).addClass(ui.options.activeClass);\r
+ },\r
+ deactivate: function(e, ui) {\r
+ $(this).removeClass(ui.options.activeClass);\r
+ },\r
+ drop: function(e, ui) {\r
+ $(this).removeClass(ui.options.activeClass);\r
+ }\r
+});\r
+\r
+$.ui.plugin.add("droppable", "hoverClass", {\r
+ over: function(e, ui) {\r
+ $(this).addClass(ui.options.hoverClass);\r
+ },\r
+ out: function(e, ui) {\r
+ $(this).removeClass(ui.options.hoverClass);\r
+ },\r
+ drop: function(e, ui) {\r
+ $(this).removeClass(ui.options.hoverClass);\r
+ }\r
+});\r
+\r
})(jQuery);\r
* Revision: $Id: ui.resizable.js 5668 2008-05-22 18:17:30Z rdworth $\r
*/\r
;(function($) {\r
- \r
- $.widget("ui.resizable", $.extend($.ui.mouse, {\r
- init: function() {\r
\r
- var self = this, o = this.options;\r
+$.widget("ui.resizable", $.extend($.ui.mouse, {\r
+ init: function() {\r
+\r
+ var self = this, o = this.options;\r
\r
- var elpos = this.element.css('position');\r
+ var elpos = this.element.css('position');\r
+ \r
+ // simulate .ui-resizable { position: relative; }\r
+ this.element.addClass("ui-resizable").css({ position: /static/.test(elpos) ? 'relative' : elpos });\r
+ \r
+ $.extend(o, {\r
+ _aspectRatio: !!(o.aspectRatio),\r
+ proxy: o.proxy || o.ghost || o.animate ? o.proxy || 'proxy' : null,\r
+ knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles\r
+ });\r
+ \r
+ //Default Theme\r
+ var aBorder = '1px solid #DEDEDE';\r
+ \r
+ o.defaultTheme = {\r
+ 'ui-resizable': { display: 'block' },\r
+ 'ui-resizable-handle': { position: 'absolute', background: '#F2F2F2', fontSize: '0.1px' },\r
+ 'ui-resizable-n': { cursor: 'n-resize', height: '4px', left: '0px', right: '0px', borderTop: aBorder },\r
+ 'ui-resizable-s': { cursor: 's-resize', height: '4px', left: '0px', right: '0px', borderBottom: aBorder },\r
+ 'ui-resizable-e': { cursor: 'e-resize', width: '4px', top: '0px', bottom: '0px', borderRight: aBorder },\r
+ 'ui-resizable-w': { cursor: 'w-resize', width: '4px', top: '0px', bottom: '0px', borderLeft: aBorder },\r
+ 'ui-resizable-se': { cursor: 'se-resize', width: '4px', height: '4px', borderRight: aBorder, borderBottom: aBorder },\r
+ 'ui-resizable-sw': { cursor: 'sw-resize', width: '4px', height: '4px', borderBottom: aBorder, borderLeft: aBorder },\r
+ 'ui-resizable-ne': { cursor: 'ne-resize', width: '4px', height: '4px', borderRight: aBorder, borderTop: aBorder },\r
+ 'ui-resizable-nw': { cursor: 'nw-resize', width: '4px', height: '4px', borderLeft: aBorder, borderTop: aBorder }\r
+ };\r
+ \r
+ o.knobTheme = {\r
+ 'ui-resizable-handle': { background: '#F2F2F2', border: '1px solid #808080', height: '8px', width: '8px' },\r
+ 'ui-resizable-n': { cursor: 'n-resize', top: '0px', left: '45%' },\r
+ 'ui-resizable-s': { cursor: 's-resize', bottom: '0px', left: '45%' },\r
+ 'ui-resizable-e': { cursor: 'e-resize', right: '0px', top: '45%' },\r
+ 'ui-resizable-w': { cursor: 'w-resize', left: '0px', top: '45%' },\r
+ 'ui-resizable-se': { cursor: 'se-resize', right: '0px', bottom: '0px' },\r
+ 'ui-resizable-sw': { cursor: 'sw-resize', left: '0px', bottom: '0px' },\r
+ 'ui-resizable-nw': { cursor: 'nw-resize', left: '0px', top: '0px' },\r
+ 'ui-resizable-ne': { cursor: 'ne-resize', right: '0px', top: '0px' }\r
+ };\r
+ \r
+ o._nodeName = this.element[0].nodeName;\r
+ \r
+ //Wrap the element if it cannot hold child nodes\r
+ if(o._nodeName.match(/canvas|textarea|input|select|button|img/i)) {\r
+ var el = this.element;\r
\r
- // simulate .ui-resizable { position: relative; }\r
- this.element.addClass("ui-resizable").css({ position: /static/.test(elpos) ? 'relative' : elpos });\r
+ //Opera fixing relative position\r
+ if (/relative/.test(el.css('position')) && $.browser.opera)\r
+ el.css({ position: 'relative', top: 'auto', left: 'auto' });\r
+ \r
+ //Create a wrapper element and set the wrapper to the new current internal element\r
+ el.wrap(\r
+ $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css( {\r
+ position: el.css('position'),\r
+ width: el.outerWidth(),\r
+ height: el.outerHeight(),\r
+ top: el.css('top'),\r
+ left: el.css('left')\r
+ })\r
+ );\r
\r
- $.extend(o, {\r
- _aspectRatio: !!(o.aspectRatio),\r
- proxy: o.proxy || o.ghost || o.animate ? o.proxy || 'proxy' : null,\r
- knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles\r
+ var oel = this.element; this.element = this.element.parent();\r
+ \r
+ //Move margins to the wrapper\r
+ this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"),\r
+ marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom")\r
});\r
\r
- //Default Theme\r
- var aBorder = '1px solid #DEDEDE';\r
+ oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});\r
\r
- o.defaultTheme = {\r
- 'ui-resizable': { display: 'block' },\r
- 'ui-resizable-handle': { position: 'absolute', background: '#F2F2F2', fontSize: '0.1px' },\r
- 'ui-resizable-n': { cursor: 'n-resize', height: '4px', left: '0px', right: '0px', borderTop: aBorder },\r
- 'ui-resizable-s': { cursor: 's-resize', height: '4px', left: '0px', right: '0px', borderBottom: aBorder },\r
- 'ui-resizable-e': { cursor: 'e-resize', width: '4px', top: '0px', bottom: '0px', borderRight: aBorder },\r
- 'ui-resizable-w': { cursor: 'w-resize', width: '4px', top: '0px', bottom: '0px', borderLeft: aBorder },\r
- 'ui-resizable-se': { cursor: 'se-resize', width: '4px', height: '4px', borderRight: aBorder, borderBottom: aBorder },\r
- 'ui-resizable-sw': { cursor: 'sw-resize', width: '4px', height: '4px', borderBottom: aBorder, borderLeft: aBorder },\r
- 'ui-resizable-ne': { cursor: 'ne-resize', width: '4px', height: '4px', borderRight: aBorder, borderTop: aBorder },\r
- 'ui-resizable-nw': { cursor: 'nw-resize', width: '4px', height: '4px', borderLeft: aBorder, borderTop: aBorder }\r
- };\r
+ //Prevent Safari textarea resize\r
+ if ($.browser.safari && o.preventDefault) oel.css('resize', 'none');\r
\r
- o.knobTheme = {\r
- 'ui-resizable-handle': { background: '#F2F2F2', border: '1px solid #808080', height: '8px', width: '8px' },\r
- 'ui-resizable-n': { cursor: 'n-resize', top: '0px', left: '45%' },\r
- 'ui-resizable-s': { cursor: 's-resize', bottom: '0px', left: '45%' },\r
- 'ui-resizable-e': { cursor: 'e-resize', right: '0px', top: '45%' },\r
- 'ui-resizable-w': { cursor: 'w-resize', left: '0px', top: '45%' },\r
- 'ui-resizable-se': { cursor: 'se-resize', right: '0px', bottom: '0px' },\r
- 'ui-resizable-sw': { cursor: 'sw-resize', left: '0px', bottom: '0px' },\r
- 'ui-resizable-nw': { cursor: 'nw-resize', left: '0px', top: '0px' },\r
- 'ui-resizable-ne': { cursor: 'ne-resize', right: '0px', top: '0px' }\r
- };\r
+ o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' });\r
\r
- o._nodeName = this.element[0].nodeName;\r
+ // avoid IE jump\r
+ this.element.css({ margin: oel.css('margin') });\r
\r
- //Wrap the element if it cannot hold child nodes\r
- if(o._nodeName.match(/canvas|textarea|input|select|button|img/i)) {\r
- var el = this.element;\r
- \r
- //Opera fixing relative position\r
- if (/relative/.test(el.css('position')) && $.browser.opera)\r
- el.css({ position: 'relative', top: 'auto', left: 'auto' });\r
- \r
- //Create a wrapper element and set the wrapper to the new current internal element\r
- el.wrap(\r
- $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css( {\r
- position: el.css('position'),\r
- width: el.outerWidth(),\r
- height: el.outerHeight(),\r
- top: el.css('top'),\r
- left: el.css('left')\r
- })\r
- );\r
- \r
- var oel = this.element; this.element = this.element.parent();\r
- \r
- //Move margins to the wrapper\r
- this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"),\r
- marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom")\r
- });\r
- \r
- oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});\r
- \r
- //Prevent Safari textarea resize\r
- if ($.browser.safari && o.preventDefault) oel.css('resize', 'none');\r
+ // fix handlers offset\r
+ this._proportionallyResize();\r
+ }\r
+ \r
+ if(!o.handles) o.handles = !$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' };\r
+ if(o.handles.constructor == String) {\r
+ \r
+ o.zIndex = o.zIndex || 1000;\r
+ \r
+ if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw';\r
+ \r
+ var n = o.handles.split(","); o.handles = {};\r
+ \r
+ // insertions are applied when don't have theme loaded\r
+ var insertionsDefault = {\r
+ handle: 'position: absolute; display: none; overflow:hidden;',\r
+ n: 'top: 0pt; width:100%;',\r
+ e: 'right: 0pt; height:100%;',\r
+ s: 'bottom: 0pt; width:100%;',\r
+ w: 'left: 0pt; height:100%;',\r
+ se: 'bottom: 0pt; right: 0px;',\r
+ sw: 'bottom: 0pt; left: 0px;',\r
+ ne: 'top: 0pt; right: 0px;',\r
+ nw: 'top: 0pt; left: 0px;'\r
+ };\r
+ \r
+ for(var i = 0; i < n.length; i++) {\r
+ var handle = $.trim(n[i]), dt = o.defaultTheme, hname = 'ui-resizable-'+handle, loadDefault = !$.ui.css(hname) && !o.knobHandles, userKnobClass = $.ui.css('ui-resizable-knob-handle'), \r
+ allDefTheme = $.extend(dt[hname], dt['ui-resizable-handle']), allKnobTheme = $.extend(o.knobTheme[hname], !userKnobClass ? o.knobTheme['ui-resizable-handle'] : {});\r
\r
- o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' });\r
+ // increase zIndex of sw, se, ne, nw axis\r
+ var applyZIndex = /sw|se|ne|nw/.test(handle) ? { zIndex: ++o.zIndex } : {};\r
\r
- // avoid IE jump\r
- this.element.css({ margin: oel.css('margin') });\r
+ var defCss = (loadDefault ? insertionsDefault[handle] : ''), \r
+ axis = $(['<div class="ui-resizable-handle ', hname, '" style="', defCss, insertionsDefault.handle, '"></div>'].join('')).css( applyZIndex );\r
+ o.handles[handle] = '.ui-resizable-'+handle;\r
\r
- // fix handlers offset\r
- this._proportionallyResize();\r
+ this.element.append(\r
+ //Theme detection, if not loaded, load o.defaultTheme\r
+ axis.css( loadDefault ? allDefTheme : {} )\r
+ // Load the knobHandle css, fix width, height, top, left...\r
+ .css( o.knobHandles ? allKnobTheme : {} ).addClass(o.knobHandles ? 'ui-resizable-knob-handle' : '').addClass(o.knobHandles)\r
+ );\r
}\r
\r
- if(!o.handles) o.handles = !$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' };\r
- if(o.handles.constructor == String) {\r
- \r
- o.zIndex = o.zIndex || 1000;\r
- \r
- if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw';\r
- \r
- var n = o.handles.split(","); o.handles = {};\r
+ if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} );\r
+ }\r
+ \r
+ this._renderAxis = function(target) {\r
+ target = target || this.element;\r
+ \r
+ for(var i in o.handles) {\r
+ if(o.handles[i].constructor == String) \r
+ o.handles[i] = $(o.handles[i], this.element).show();\r
\r
- // insertions are applied when don't have theme loaded\r
- var insertionsDefault = {\r
- handle: 'position: absolute; display: none; overflow:hidden;',\r
- n: 'top: 0pt; width:100%;',\r
- e: 'right: 0pt; height:100%;',\r
- s: 'bottom: 0pt; width:100%;',\r
- w: 'left: 0pt; height:100%;',\r
- se: 'bottom: 0pt; right: 0px;',\r
- sw: 'bottom: 0pt; left: 0px;',\r
- ne: 'top: 0pt; right: 0px;',\r
- nw: 'top: 0pt; left: 0px;'\r
- };\r
+ if (o.transparent)\r
+ o.handles[i].css({opacity:0});\r
\r
- for(var i = 0; i < n.length; i++) {\r
- var handle = $.trim(n[i]), dt = o.defaultTheme, hname = 'ui-resizable-'+handle, loadDefault = !$.ui.css(hname) && !o.knobHandles, userKnobClass = $.ui.css('ui-resizable-knob-handle'), \r
- allDefTheme = $.extend(dt[hname], dt['ui-resizable-handle']), allKnobTheme = $.extend(o.knobTheme[hname], !userKnobClass ? o.knobTheme['ui-resizable-handle'] : {});\r
+ //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)\r
+ if (this.element.is('.ui-wrapper') && \r
+ o._nodeName.match(/textarea|input|select|button/i)) {\r
\r
- // increase zIndex of sw, se, ne, nw axis\r
- var applyZIndex = /sw|se|ne|nw/.test(handle) ? { zIndex: ++o.zIndex } : {};\r
+ var axis = $(o.handles[i], this.element), padWrapper = 0;\r
\r
- var defCss = (loadDefault ? insertionsDefault[handle] : ''), \r
- axis = $(['<div class="ui-resizable-handle ', hname, '" style="', defCss, insertionsDefault.handle, '"></div>'].join('')).css( applyZIndex );\r
- o.handles[handle] = '.ui-resizable-'+handle;\r
+ //Checking the correct pad and border\r
+ padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();\r
\r
- this.element.append(\r
- //Theme detection, if not loaded, load o.defaultTheme\r
- axis.css( loadDefault ? allDefTheme : {} )\r
- // Load the knobHandle css, fix width, height, top, left...\r
- .css( o.knobHandles ? allKnobTheme : {} ).addClass(o.knobHandles ? 'ui-resizable-knob-handle' : '').addClass(o.knobHandles)\r
- );\r
- }\r
- \r
- if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} );\r
- }\r
- \r
- this._renderAxis = function(target) {\r
- target = target || this.element;\r
- \r
- for(var i in o.handles) {\r
- if(o.handles[i].constructor == String) \r
- o.handles[i] = $(o.handles[i], this.element).show();\r
+ //The padding type i have to apply...\r
+ var padPos = [ 'padding', \r
+ /ne|nw|n/.test(i) ? 'Top' :\r
+ /se|sw|s/.test(i) ? 'Bottom' : \r
+ /^e$/.test(i) ? 'Right' : 'Left' ].join(""); \r
\r
- if (o.transparent)\r
- o.handles[i].css({opacity:0});\r
+ if (!o.transparent)\r
+ target.css(padPos, padWrapper);\r
\r
- //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)\r
- if (this.element.is('.ui-wrapper') && \r
- o._nodeName.match(/textarea|input|select|button/i)) {\r
- \r
- var axis = $(o.handles[i], this.element), padWrapper = 0;\r
- \r
- //Checking the correct pad and border\r
- padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();\r
- \r
- //The padding type i have to apply...\r
- var padPos = [ 'padding', \r
- /ne|nw|n/.test(i) ? 'Top' :\r
- /se|sw|s/.test(i) ? 'Bottom' : \r
- /^e$/.test(i) ? 'Right' : 'Left' ].join(""); \r
- \r
- if (!o.transparent)\r
- target.css(padPos, padWrapper);\r
- \r
- this._proportionallyResize();\r
- }\r
- if(!$(o.handles[i]).length) continue;\r
+ this._proportionallyResize();\r
}\r
- };\r
- \r
- this._renderAxis(this.element);\r
- o._handles = $('.ui-resizable-handle', self.element);\r
- \r
- if (o.disableSelection)\r
- o._handles.each(function(i, e) { $.ui.disableSelection(e); });\r
- \r
- //Matching axis name\r
- o._handles.mouseover(function() {\r
+ if(!$(o.handles[i]).length) continue;\r
+ }\r
+ };\r
+ \r
+ this._renderAxis(this.element);\r
+ o._handles = $('.ui-resizable-handle', self.element);\r
+ \r
+ if (o.disableSelection)\r
+ o._handles.each(function(i, e) { $.ui.disableSelection(e); });\r
+ \r
+ //Matching axis name\r
+ o._handles.mouseover(function() {\r
+ if (!o.resizing) {\r
+ if (this.className) \r
+ var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);\r
+ //Axis, default = se\r
+ self.axis = o.axis = axis && axis[1] ? axis[1] : 'se';\r
+ }\r
+ });\r
+ \r
+ //If we want to auto hide the elements\r
+ if (o.autohide) {\r
+ o._handles.hide();\r
+ $(self.element).addClass("ui-resizable-autohide").hover(function() {\r
+ $(this).removeClass("ui-resizable-autohide");\r
+ o._handles.show();\r
+ },\r
+ function(){\r
if (!o.resizing) {\r
- if (this.className) \r
- var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);\r
- //Axis, default = se\r
- self.axis = o.axis = axis && axis[1] ? axis[1] : 'se';\r
+ $(this).addClass("ui-resizable-autohide");\r
+ o._handles.hide();\r
}\r
});\r
+ }\r
+ \r
+ this.mouseInit();\r
+ },\r
+ plugins: {},\r
+ ui: function() {\r
+ return {\r
+ axis: this.options.axis,\r
+ options: this.options\r
+ };\r
+ },\r
+ propagate: function(n,e) {\r
+ $.ui.plugin.call(this, n, [e, this.ui()]);\r
+ this.element.triggerHandler(n == "resize" ? n : ["resize", n].join(""), [e, this.ui()], this.options[n]);\r
+ },\r
+ destroy: function() {\r
+ var el = this.element, wrapped = el.children(".ui-resizable").get(0);\r
+ \r
+ this.mouseDestroy();\r
+ \r
+ var _destroy = function(exp) {\r
+ $(exp).removeClass("ui-resizable ui-resizable-disabled")\r
+ .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();\r
+ };\r
+ \r
+ _destroy(el);\r
+ \r
+ if (el.is('.ui-wrapper') && wrapped) {\r
+ el.parent().append(\r
+ $(wrapped).css({\r
+ position: el.css('position'),\r
+ width: el.outerWidth(),\r
+ height: el.outerHeight(),\r
+ top: el.css('top'),\r
+ left: el.css('left')\r
+ })\r
+ ).end().remove();\r
+ \r
+ _destroy(wrapped);\r
+ }\r
+ },\r
+ enable: function() {\r
+ this.element.removeClass("ui-resizable-disabled");\r
+ this.options.disabled = false;\r
+ },\r
+ disable: function() {\r
+ this.element.addClass("ui-resizable-disabled");\r
+ this.options.disabled = true;\r
+ },\r
+ mouseStart: function(e) {\r
+ if(this.options.disabled) return false;\r
+ \r
+ var handle = false;\r
+ for(var i in this.options.handles) {\r
+ if($(this.options.handles[i])[0] == e.target) handle = true;\r
+ }\r
+ if (!handle) return false;\r
+ \r
+ var o = this.options, iniPos = this.element.position(), el = this.element, \r
+ num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7;\r
+ o.resizing = true;\r
+ o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };\r
+ \r
+ // bugfix #1749\r
+ if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {\r
\r
- //If we want to auto hide the elements\r
- if (o.autohide) {\r
- o._handles.hide();\r
- $(self.element).addClass("ui-resizable-autohide").hover(function() {\r
- $(this).removeClass("ui-resizable-autohide");\r
- o._handles.show();\r
- },\r
- function(){\r
- if (!o.resizing) {\r
- $(this).addClass("ui-resizable-autohide");\r
- o._handles.hide();\r
- }\r
- });\r
- }\r
- \r
- this.mouseInit();\r
- },\r
- plugins: {},\r
- ui: function() {\r
- return {\r
- axis: this.options.axis,\r
- options: this.options\r
- };\r
- },\r
- propagate: function(n,e) {\r
- $.ui.plugin.call(this, n, [e, this.ui()]);\r
- this.element.triggerHandler(n == "resize" ? n : ["resize", n].join(""), [e, this.ui()], this.options[n]);\r
- },\r
- destroy: function() {\r
- var el = this.element, wrapped = el.children(".ui-resizable").get(0);\r
- \r
- this.mouseDestroy();\r
- \r
- var _destroy = function(exp) {\r
- $(exp).removeClass("ui-resizable ui-resizable-disabled")\r
- .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();\r
- };\r
- \r
- _destroy(el);\r
- \r
- if (el.is('.ui-wrapper') && wrapped) {\r
- el.parent().append(\r
- $(wrapped).css({\r
- position: el.css('position'),\r
- width: el.outerWidth(),\r
- height: el.outerHeight(),\r
- top: el.css('top'),\r
- left: el.css('left')\r
- })\r
- ).end().remove();\r
- \r
- _destroy(wrapped);\r
- }\r
- },\r
- enable: function() {\r
- this.element.removeClass("ui-resizable-disabled");\r
- this.options.disabled = false;\r
- },\r
- disable: function() {\r
- this.element.addClass("ui-resizable-disabled");\r
- this.options.disabled = true;\r
- },\r
- mouseStart: function(e) {\r
- if(this.options.disabled) return false;\r
- \r
- var handle = false;\r
- for(var i in this.options.handles) {\r
- if($(this.options.handles[i])[0] == e.target) handle = true;\r
- }\r
- if (!handle) return false;\r
- \r
- var o = this.options, iniPos = this.element.position(), el = this.element, \r
- num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7;\r
- o.resizing = true;\r
- o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };\r
- \r
- // bugfix #1749\r
- if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {\r
- \r
- // sOffset decides if document scrollOffset will be added to the top/left of the resizable element\r
- var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position'));\r
- var dscrollt = sOffset ? o.documentScroll.top : 0, dscrolll = sOffset ? o.documentScroll.left : 0;\r
- \r
- el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) });\r
- }\r
- \r
- //Opera fixing relative position\r
- if ($.browser.opera && /relative/.test(el.css('position')))\r
- el.css({ position: 'relative', top: 'auto', left: 'auto' });\r
- \r
- this._renderProxy();\r
- \r
- var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));\r
- \r
- //Store needed variables\r
- this.offset = this.helper.offset();\r
- this.position = { left: curleft, top: curtop };\r
- this.size = o.proxy || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };\r
- this.originalSize = o.proxy || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };\r
- this.originalPosition = { left: curleft, top: curtop };\r
- this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };\r
- this.originalMousePosition = { left: e.pageX, top: e.pageY };\r
- \r
- //Aspect Ratio\r
- o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.height / this.originalSize.width)||1);\r
- \r
- if (o.preserveCursor)\r
- $('body').css('cursor', this.axis + '-resize');\r
- \r
- this.propagate("start", e);\r
- return true;\r
- },\r
- mouseDrag: function(e) {\r
- \r
- //Increase performance, avoid regex\r
- var el = this.helper, o = this.options, props = {},\r
- self = this, smp = this.originalMousePosition, a = this.axis;\r
+ // sOffset decides if document scrollOffset will be added to the top/left of the resizable element\r
+ var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position'));\r
+ var dscrollt = sOffset ? o.documentScroll.top : 0, dscrolll = sOffset ? o.documentScroll.left : 0;\r
\r
- var dx = (e.pageX-smp.left)||0, dy = (e.pageY-smp.top)||0;\r
- var trigger = this._change[a];\r
- if (!trigger) return false;\r
+ el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) });\r
+ }\r
+ \r
+ //Opera fixing relative position\r
+ if ($.browser.opera && /relative/.test(el.css('position')))\r
+ el.css({ position: 'relative', top: 'auto', left: 'auto' });\r
+ \r
+ this._renderProxy();\r
+ \r
+ var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));\r
+ \r
+ //Store needed variables\r
+ this.offset = this.helper.offset();\r
+ this.position = { left: curleft, top: curtop };\r
+ this.size = o.proxy || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };\r
+ this.originalSize = o.proxy || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };\r
+ this.originalPosition = { left: curleft, top: curtop };\r
+ this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };\r
+ this.originalMousePosition = { left: e.pageX, top: e.pageY };\r
+ \r
+ //Aspect Ratio\r
+ o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.height / this.originalSize.width)||1);\r
+ \r
+ if (o.preserveCursor)\r
+ $('body').css('cursor', this.axis + '-resize');\r
\r
- // Calculate the attrs that will be change\r
- var data = trigger.apply(this, [e, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;\r
+ this.propagate("start", e);\r
+ return true;\r
+ },\r
+ mouseDrag: function(e) {\r
+ \r
+ //Increase performance, avoid regex\r
+ var el = this.helper, o = this.options, props = {},\r
+ self = this, smp = this.originalMousePosition, a = this.axis;\r
+ \r
+ var dx = (e.pageX-smp.left)||0, dy = (e.pageY-smp.top)||0;\r
+ var trigger = this._change[a];\r
+ if (!trigger) return false;\r
+ \r
+ // Calculate the attrs that will be change\r
+ var data = trigger.apply(this, [e, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;\r
+ \r
+ if (o._aspectRatio || e.shiftKey)\r
+ data = this._updateRatio(data, e);\r
+ \r
+ data = this._respectSize(data, e);\r
+ \r
+ this.propagate("resize", e);\r
+ \r
+ el.css({\r
+ top: this.position.top + "px", left: this.position.left + "px", \r
+ width: this.size.width + "px", height: this.size.height + "px"\r
+ });\r
+ \r
+ if (!o.proxy && o.proportionallyResize)\r
+ this._proportionallyResize();\r
+ \r
+ this._updateCache(data);\r
+ \r
+ return false;\r
+ },\r
+ mouseStop: function(e) {\r
+ \r
+ this.options.resizing = false;\r
+ var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this;\r
+ \r
+ if(o.proxy) {\r
+ var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), \r
+ soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,\r
+ soffsetw = ista ? 0 : self.sizeDiff.width;\r
\r
- if (o._aspectRatio || e.shiftKey)\r
- data = this._updateRatio(data, e);\r
+ var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },\r
+ left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, \r
+ top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;\r
\r
- data = this._respectSize(data, e);\r
+ if (!o.animate)\r
+ this.element.css($.extend(s, { top: top, left: left }));\r
\r
- this.propagate("resize", e);\r
+ if (o.proxy && !o.animate) this._proportionallyResize();\r
+ this.helper.remove();\r
+ }\r
+ \r
+ if (o.preserveCursor)\r
+ $('body').css('cursor', 'auto');\r
+ \r
+ this.propagate("stop", e); \r
+ return false;\r
+ },\r
+ _updateCache: function(data) {\r
+ var o = this.options;\r
+ this.offset = this.helper.offset();\r
+ if (data.left) this.position.left = data.left;\r
+ if (data.top) this.position.top = data.top;\r
+ if (data.height) this.size.height = data.height;\r
+ if (data.width) this.size.width = data.width;\r
+ },\r
+ _updateRatio: function(data, e) {\r
+ var o = this.options, cpos = this.position, csize = this.size, a = this.axis;\r
+ \r
+ if (data.height) data.width = (csize.height / o.aspectRatio);\r
+ else if (data.width) data.height = (csize.width * o.aspectRatio);\r
+ \r
+ if (a == 'sw') {\r
+ data.left = cpos.left + (csize.width - data.width);\r
+ data.top = null;\r
+ }\r
+ if (a == 'nw') { \r
+ data.top = cpos.top + (csize.height - data.height);\r
+ data.left = cpos.left + (csize.width - data.width);\r
+ }\r
+ \r
+ return data;\r
+ },\r
+ _respectSize: function(data, e) {\r
+ \r
+ var el = this.helper, o = this.options, pRatio = o._aspectRatio || e.shiftKey, a = this.axis, \r
+ ismaxw = data.width && o.maxWidth && o.maxWidth < data.width, ismaxh = data.height && o.maxHeight && o.maxHeight < data.height,\r
+ isminw = data.width && o.minWidth && o.minWidth > data.width, isminh = data.height && o.minHeight && o.minHeight > data.height;\r
+ \r
+ if (isminw) data.width = o.minWidth;\r
+ if (isminh) data.height = o.minHeight;\r
+ if (ismaxw) data.width = o.maxWidth;\r
+ if (ismaxh) data.height = o.maxHeight;\r
+ \r
+ var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;\r
+ var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);\r
+ \r
+ if (isminw && cw) data.left = dw - o.minWidth;\r
+ if (ismaxw && cw) data.left = dw - o.maxWidth;\r
+ if (isminh && ch) data.top = dh - o.minHeight;\r
+ if (ismaxh && ch) data.top = dh - o.maxHeight;\r
+ \r
+ // fixing jump error on top/left - bug #2330\r
+ var isNotwh = !data.width && !data.height;\r
+ if (isNotwh && !data.left && data.top) data.top = null;\r
+ else if (isNotwh && !data.top && data.left) data.left = null;\r
+ \r
+ return data;\r
+ },\r
+ _proportionallyResize: function() {\r
+ var o = this.options;\r
+ if (!o.proportionallyResize) return;\r
+ var prel = o.proportionallyResize, el = this.helper || this.element;\r
+ \r
+ if (!o.borderDif) {\r
+ var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],\r
+ p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];\r
\r
- el.css({\r
- top: this.position.top + "px", left: this.position.left + "px", \r
- width: this.size.width + "px", height: this.size.height + "px"\r
+ o.borderDif = $.map(b, function(v, i) {\r
+ var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;\r
+ return border + padding; \r
+ });\r
+ }\r
+ prel.css({\r
+ height: (el.height() - o.borderDif[0] - o.borderDif[2]) + "px",\r
+ width: (el.width() - o.borderDif[1] - o.borderDif[3]) + "px"\r
+ });\r
+ },\r
+ _renderProxy: function() {\r
+ var el = this.element, o = this.options;\r
+ this.elementOffset = el.offset();\r
+ \r
+ if(o.proxy) {\r
+ this.helper = this.helper || $('<div style="overflow:hidden;"></div>');\r
+ \r
+ // fix ie6 offset\r
+ var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),\r
+ pxyoffset = ( ie6 ? 2 : -1 );\r
+ \r
+ this.helper.addClass(o.proxy).css({\r
+ width: el.outerWidth() + pxyoffset,\r
+ height: el.outerHeight() + pxyoffset,\r
+ position: 'absolute',\r
+ left: this.elementOffset.left - ie6offset +'px',\r
+ top: this.elementOffset.top - ie6offset +'px',\r
+ zIndex: ++o.zIndex\r
});\r
\r
- if (!o.proxy && o.proportionallyResize)\r
- this._proportionallyResize();\r
+ this.helper.appendTo("body");\r
\r
- this._updateCache(data);\r
+ if (o.disableSelection)\r
+ $.ui.disableSelection(this.helper.get(0));\r
\r
- return false;\r
+ } else {\r
+ this.helper = el; \r
+ }\r
+ },\r
+ _change: {\r
+ e: function(e, dx, dy) {\r
+ return { width: this.originalSize.width + dx };\r
},\r
- mouseStop: function(e) {\r
- \r
- this.options.resizing = false;\r
- var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this;\r
- \r
- if(o.proxy) {\r
- var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), \r
- soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,\r
- soffsetw = ista ? 0 : self.sizeDiff.width;\r
- \r
- var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },\r
- left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, \r
- top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;\r
- \r
- if (!o.animate)\r
- this.element.css($.extend(s, { top: top, left: left }));\r
- \r
- if (o.proxy && !o.animate) this._proportionallyResize();\r
- this.helper.remove();\r
- }\r
- \r
- if (o.preserveCursor)\r
- $('body').css('cursor', 'auto');\r
- \r
- this.propagate("stop", e); \r
- return false;\r
+ w: function(e, dx, dy) {\r
+ var o = this.options, cs = this.originalSize, sp = this.originalPosition;\r
+ return { left: sp.left + dx, width: cs.width - dx };\r
},\r
- _updateCache: function(data) {\r
- var o = this.options;\r
- this.offset = this.helper.offset();\r
- if (data.left) this.position.left = data.left;\r
- if (data.top) this.position.top = data.top;\r
- if (data.height) this.size.height = data.height;\r
- if (data.width) this.size.width = data.width;\r
+ n: function(e, dx, dy) {\r
+ var o = this.options, cs = this.originalSize, sp = this.originalPosition;\r
+ return { top: sp.top + dy, height: cs.height - dy };\r
},\r
- _updateRatio: function(data, e) {\r
- var o = this.options, cpos = this.position, csize = this.size, a = this.axis;\r
- \r
- if (data.height) data.width = (csize.height / o.aspectRatio);\r
- else if (data.width) data.height = (csize.width * o.aspectRatio);\r
- \r
- if (a == 'sw') {\r
- data.left = cpos.left + (csize.width - data.width);\r
- data.top = null;\r
- }\r
- if (a == 'nw') { \r
- data.top = cpos.top + (csize.height - data.height);\r
- data.left = cpos.left + (csize.width - data.width);\r
- }\r
- \r
- return data;\r
+ s: function(e, dx, dy) {\r
+ return { height: this.originalSize.height + dy };\r
},\r
- _respectSize: function(data, e) {\r
- \r
- var el = this.helper, o = this.options, pRatio = o._aspectRatio || e.shiftKey, a = this.axis, \r
- ismaxw = data.width && o.maxWidth && o.maxWidth < data.width, ismaxh = data.height && o.maxHeight && o.maxHeight < data.height,\r
- isminw = data.width && o.minWidth && o.minWidth > data.width, isminh = data.height && o.minHeight && o.minHeight > data.height;\r
- \r
- if (isminw) data.width = o.minWidth;\r
- if (isminh) data.height = o.minHeight;\r
- if (ismaxw) data.width = o.maxWidth;\r
- if (ismaxh) data.height = o.maxHeight;\r
- \r
- var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;\r
- var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);\r
- \r
- if (isminw && cw) data.left = dw - o.minWidth;\r
- if (ismaxw && cw) data.left = dw - o.maxWidth;\r
- if (isminh && ch) data.top = dh - o.minHeight;\r
- if (ismaxh && ch) data.top = dh - o.maxHeight;\r
- \r
- // fixing jump error on top/left - bug #2330\r
- var isNotwh = !data.width && !data.height;\r
- if (isNotwh && !data.left && data.top) data.top = null;\r
- else if (isNotwh && !data.top && data.left) data.left = null;\r
- \r
- return data;\r
+ se: function(e, dx, dy) {\r
+ return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [e, dx, dy]));\r
},\r
- _proportionallyResize: function() {\r
- var o = this.options;\r
- if (!o.proportionallyResize) return;\r
- var prel = o.proportionallyResize, el = this.helper || this.element;\r
- \r
- if (!o.borderDif) {\r
- var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],\r
- p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];\r
- \r
- o.borderDif = $.map(b, function(v, i) {\r
- var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;\r
- return border + padding; \r
- });\r
- }\r
- prel.css({\r
- height: (el.height() - o.borderDif[0] - o.borderDif[2]) + "px",\r
- width: (el.width() - o.borderDif[1] - o.borderDif[3]) + "px"\r
- });\r
+ sw: function(e, dx, dy) {\r
+ return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [e, dx, dy]));\r
},\r
- _renderProxy: function() {\r
- var el = this.element, o = this.options;\r
- this.elementOffset = el.offset();\r
- \r
- if(o.proxy) {\r
- this.helper = this.helper || $('<div style="overflow:hidden;"></div>');\r
- \r
- // fix ie6 offset\r
- var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),\r
- pxyoffset = ( ie6 ? 2 : -1 );\r
- \r
- this.helper.addClass(o.proxy).css({\r
- width: el.outerWidth() + pxyoffset,\r
- height: el.outerHeight() + pxyoffset,\r
- position: 'absolute',\r
- left: this.elementOffset.left - ie6offset +'px',\r
- top: this.elementOffset.top - ie6offset +'px',\r
- zIndex: ++o.zIndex\r
- });\r
- \r
- this.helper.appendTo("body");\r
- \r
- if (o.disableSelection)\r
- $.ui.disableSelection(this.helper.get(0));\r
- \r
- } else {\r
- this.helper = el; \r
- }\r
+ ne: function(e, dx, dy) {\r
+ return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [e, dx, dy]));\r
},\r
- _change: {\r
- e: function(e, dx, dy) {\r
- return { width: this.originalSize.width + dx };\r
- },\r
- w: function(e, dx, dy) {\r
- var o = this.options, cs = this.originalSize, sp = this.originalPosition;\r
- return { left: sp.left + dx, width: cs.width - dx };\r
- },\r
- n: function(e, dx, dy) {\r
- var o = this.options, cs = this.originalSize, sp = this.originalPosition;\r
- return { top: sp.top + dy, height: cs.height - dy };\r
- },\r
- s: function(e, dx, dy) {\r
- return { height: this.originalSize.height + dy };\r
- },\r
- se: function(e, dx, dy) {\r
- return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [e, dx, dy]));\r
- },\r
- sw: function(e, dx, dy) {\r
- return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [e, dx, dy]));\r
- },\r
- ne: function(e, dx, dy) {\r
- return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [e, dx, dy]));\r
- },\r
- nw: function(e, dx, dy) {\r
- return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [e, dx, dy]));\r
- }\r
+ nw: function(e, dx, dy) {\r
+ return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [e, dx, dy]));\r
}\r
- }));\r
- \r
- $.extend($.ui.resizable, {\r
- defaults: {\r
- cancel: ":input,button",\r
- distance: 0,\r
- delay: 0,\r
- preventDefault: true,\r
- transparent: false,\r
- minWidth: 10,\r
- minHeight: 10,\r
- aspectRatio: false,\r
- disableSelection: true,\r
- preserveCursor: true,\r
- autohide: false,\r
- knobHandles: false\r
- }\r
- });\r
+ }\r
+}));\r
+\r
+$.extend($.ui.resizable, {\r
+ defaults: {\r
+ cancel: ":input,button",\r
+ distance: 0,\r
+ delay: 0,\r
+ preventDefault: true,\r
+ transparent: false,\r
+ minWidth: 10,\r
+ minHeight: 10,\r
+ aspectRatio: false,\r
+ disableSelection: true,\r
+ preserveCursor: true,\r
+ autohide: false,\r
+ knobHandles: false\r
+ }\r
+});\r
\r
/*\r
* Resizable Extensions\r
*/\r
\r
- $.ui.plugin.add("resizable", "containment", {\r
+$.ui.plugin.add("resizable", "containment", {\r
+ \r
+ start: function(e, ui) {\r
+ var o = ui.options, self = $(this).data("resizable"), el = self.element;\r
+ var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;\r
+ if (!ce) return;\r
\r
- start: function(e, ui) {\r
- var o = ui.options, self = $(this).data("resizable"), el = self.element;\r
- var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;\r
- if (!ce) return;\r
- \r
- if (/document/.test(oc) || oc == document) {\r
- self.containerOffset = { left: 0, top: 0 };\r
- \r
- self.parentData = { \r
- element: $(document), left: 0, top: 0, width: $(document).width(),\r
- height: $(document).height() || document.body.parentNode.scrollHeight\r
- };\r
- }\r
- \r
- // i'm a node, so compute top, left, right, bottom\r
- else{\r
- self.containerOffset = $(ce).offset();\r
- self.containerSize = { height: $(ce).innerHeight(), width: $(ce).innerWidth() };\r
+ if (/document/.test(oc) || oc == document) {\r
+ self.containerOffset = { left: 0, top: 0 };\r
\r
- var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, \r
- width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);\r
- \r
- self.parentData = { \r
- element: ce, left: co.left, top: co.top, width: width, height: height\r
- };\r
- }\r
- },\r
+ self.parentData = { \r
+ element: $(document), left: 0, top: 0, width: $(document).width(),\r
+ height: $(document).height() || document.body.parentNode.scrollHeight\r
+ };\r
+ }\r
\r
- resize: function(e, ui) {\r
- var o = ui.options, self = $(this).data("resizable"), ps = self.containerSize, \r
- co = self.containerOffset, cs = self.size, cp = self.position,\r
- pRatio = o._aspectRatio || e.shiftKey;\r
- \r
- if (cp.left < (o.proxy ? co.left : 0)) {\r
- self.size.width = self.size.width + (o.proxy ? (self.position.left - co.left) : self.position.left);\r
- if (pRatio) self.size.height = self.size.width * o.aspectRatio;\r
- self.position.left = o.proxy ? co.left : 0;\r
- }\r
- \r
- if (cp.top < (o.proxy ? co.top : 0)) {\r
- self.size.height = self.size.height + (o.proxy ? (self.position.top - co.top) : self.position.top);\r
- if (pRatio) self.size.width = self.size.height / o.aspectRatio;\r
- self.position.top = o.proxy ? co.top : 0;\r
- }\r
- \r
- var woset = (o.proxy ? self.offset.left - co.left : self.position.left) + self.sizeDiff.width, \r
- hoset = (o.proxy ? self.offset.top - co.top : self.position.top) + self.sizeDiff.height;\r
- \r
- if (woset + self.size.width >= self.parentData.width) {\r
- self.size.width = self.parentData.width - woset;\r
- if (pRatio) self.size.height = self.size.width * o.aspectRatio;\r
- }\r
- \r
- if (hoset + self.size.height >= self.parentData.height) {\r
- self.size.height = self.parentData.height - hoset;\r
- if (pRatio) self.size.width = self.size.height / o.aspectRatio;\r
- }\r
+ // i'm a node, so compute top, left, right, bottom\r
+ else{\r
+ self.containerOffset = $(ce).offset();\r
+ self.containerSize = { height: $(ce).innerHeight(), width: $(ce).innerWidth() };\r
+ \r
+ var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, \r
+ width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);\r
+ \r
+ self.parentData = { \r
+ element: ce, left: co.left, top: co.top, width: width, height: height\r
+ };\r
}\r
- });\r
+ },\r
\r
- $.ui.plugin.add("resizable", "grid", {\r
+ resize: function(e, ui) {\r
+ var o = ui.options, self = $(this).data("resizable"), ps = self.containerSize, \r
+ co = self.containerOffset, cs = self.size, cp = self.position,\r
+ pRatio = o._aspectRatio || e.shiftKey;\r
\r
- resize: function(e, ui) {\r
- var o = ui.options, self = $(this).data("resizable"), cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || e.shiftKey;\r
- o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;\r
- var ox = Math.round((cs.width - os.width) / o.grid[0]) * o.grid[0], oy = Math.round((cs.height - os.height) / o.grid[1]) * o.grid[1];\r
- \r
- if (/^(se|s|e)$/.test(a)) {\r
- self.size.width = os.width + ox;\r
- self.size.height = os.height + oy;\r
- }\r
- else if (/^(ne)$/.test(a)) {\r
- self.size.width = os.width + ox;\r
- self.size.height = os.height + oy;\r
- self.position.top = op.top - oy;\r
- }\r
- else if (/^(sw)$/.test(a)) {\r
- self.size.width = os.width + ox;\r
- self.size.height = os.height + oy;\r
- self.position.left = op.left - ox;\r
- }\r
- else {\r
- self.size.width = os.width + ox;\r
- self.size.height = os.height + oy;\r
- self.position.top = op.top - oy;\r
- self.position.left = op.left - ox;\r
- }\r
+ if (cp.left < (o.proxy ? co.left : 0)) {\r
+ self.size.width = self.size.width + (o.proxy ? (self.position.left - co.left) : self.position.left);\r
+ if (pRatio) self.size.height = self.size.width * o.aspectRatio;\r
+ self.position.left = o.proxy ? co.left : 0;\r
}\r
\r
- });\r
+ if (cp.top < (o.proxy ? co.top : 0)) {\r
+ self.size.height = self.size.height + (o.proxy ? (self.position.top - co.top) : self.position.top);\r
+ if (pRatio) self.size.width = self.size.height / o.aspectRatio;\r
+ self.position.top = o.proxy ? co.top : 0;\r
+ }\r
+ \r
+ var woset = (o.proxy ? self.offset.left - co.left : self.position.left) + self.sizeDiff.width, \r
+ hoset = (o.proxy ? self.offset.top - co.top : self.position.top) + self.sizeDiff.height;\r
+ \r
+ if (woset + self.size.width >= self.parentData.width) {\r
+ self.size.width = self.parentData.width - woset;\r
+ if (pRatio) self.size.height = self.size.width * o.aspectRatio;\r
+ }\r
+ \r
+ if (hoset + self.size.height >= self.parentData.height) {\r
+ self.size.height = self.parentData.height - hoset;\r
+ if (pRatio) self.size.width = self.size.height / o.aspectRatio;\r
+ }\r
+ }\r
+});\r
+\r
+$.ui.plugin.add("resizable", "grid", {\r
\r
- $.ui.plugin.add("resizable", "animate", {\r
+ resize: function(e, ui) {\r
+ var o = ui.options, self = $(this).data("resizable"), cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || e.shiftKey;\r
+ o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;\r
+ var ox = Math.round((cs.width - os.width) / o.grid[0]) * o.grid[0], oy = Math.round((cs.height - os.height) / o.grid[1]) * o.grid[1];\r
\r
- stop: function(e, ui) {\r
- var o = ui.options, self = $(this).data("resizable");\r
- \r
- var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), \r
- soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,\r
- soffsetw = ista ? 0 : self.sizeDiff.width;\r
- \r
- var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },\r
- left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, \r
- top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; \r
- \r
- self.element.animate(\r
- $.extend(style, top && left ? { top: top, left: left } : {}), { \r
- duration: o.animateDuration || "slow", easing: o.animateEasing || "swing", \r
- step: function() {\r
- \r
- var data = {\r
- width: parseInt(self.element.css('width'), 10),\r
- height: parseInt(self.element.css('height'), 10),\r
- top: parseInt(self.element.css('top'), 10),\r
- left: parseInt(self.element.css('left'), 10)\r
- };\r
- \r
- if (pr) pr.css({ width: data.width, height: data.height });\r
- \r
- // propagating resize, and updating values for each animation step\r
- self._updateCache(data);\r
- self.propagate("animate", e);\r
- \r
- }\r
- }\r
- );\r
+ if (/^(se|s|e)$/.test(a)) {\r
+ self.size.width = os.width + ox;\r
+ self.size.height = os.height + oy;\r
+ }\r
+ else if (/^(ne)$/.test(a)) {\r
+ self.size.width = os.width + ox;\r
+ self.size.height = os.height + oy;\r
+ self.position.top = op.top - oy;\r
+ }\r
+ else if (/^(sw)$/.test(a)) {\r
+ self.size.width = os.width + ox;\r
+ self.size.height = os.height + oy;\r
+ self.position.left = op.left - ox;\r
}\r
+ else {\r
+ self.size.width = os.width + ox;\r
+ self.size.height = os.height + oy;\r
+ self.position.top = op.top - oy;\r
+ self.position.left = op.left - ox;\r
+ }\r
+ }\r
+ \r
+});\r
+\r
+$.ui.plugin.add("resizable", "animate", {\r
+ \r
+ stop: function(e, ui) {\r
+ var o = ui.options, self = $(this).data("resizable");\r
\r
- });\r
+ var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), \r
+ soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,\r
+ soffsetw = ista ? 0 : self.sizeDiff.width;\r
+ \r
+ var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },\r
+ left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, \r
+ top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; \r
+ \r
+ self.element.animate(\r
+ $.extend(style, top && left ? { top: top, left: left } : {}), { \r
+ duration: o.animateDuration || "slow", easing: o.animateEasing || "swing", \r
+ step: function() {\r
+ \r
+ var data = {\r
+ width: parseInt(self.element.css('width'), 10),\r
+ height: parseInt(self.element.css('height'), 10),\r
+ top: parseInt(self.element.css('top'), 10),\r
+ left: parseInt(self.element.css('left'), 10)\r
+ };\r
+ \r
+ if (pr) pr.css({ width: data.width, height: data.height });\r
+ \r
+ // propagating resize, and updating values for each animation step\r
+ self._updateCache(data);\r
+ self.propagate("animate", e);\r
+ \r
+ }\r
+ }\r
+ );\r
+ }\r
+ \r
+});\r
+\r
+$.ui.plugin.add("resizable", "ghost", {\r
\r
- $.ui.plugin.add("resizable", "ghost", {\r
+ start: function(e, ui) {\r
+ var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize, cs = self.size;\r
\r
- start: function(e, ui) {\r
- var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize, cs = self.size;\r
- \r
- if (!pr) self.ghost = self.element.clone();\r
- else self.ghost = pr.clone();\r
- \r
- self.ghost.css(\r
- { opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }\r
- )\r
- .addClass('ui-resizable-ghost').addClass(typeof o.ghost == 'string' ? o.ghost : '');\r
- \r
- self.ghost.appendTo(self.helper);\r
- \r
- },\r
+ if (!pr) self.ghost = self.element.clone();\r
+ else self.ghost = pr.clone();\r
\r
- resize: function(e, ui){\r
- var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;\r
- \r
- if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });\r
- \r
- },\r
+ self.ghost.css(\r
+ { opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }\r
+ )\r
+ .addClass('ui-resizable-ghost').addClass(typeof o.ghost == 'string' ? o.ghost : '');\r
\r
- stop: function(e, ui){\r
- var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;\r
- if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));\r
- }\r
+ self.ghost.appendTo(self.helper);\r
\r
- });\r
+ },\r
\r
- $.ui.plugin.add("resizable", "alsoResize", {\r
+ resize: function(e, ui){\r
+ var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;\r
\r
- start: function(e, ui) {\r
- var o = ui.options, self = $(this).data("resizable"), \r
- \r
- _store = function(exp) {\r
- $(exp).each(function() {\r
- $(this).data("resizable-alsoresize", {\r
- width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10),\r
- left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10)\r
- });\r
+ if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });\r
+ \r
+ },\r
+ \r
+ stop: function(e, ui){\r
+ var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;\r
+ if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));\r
+ }\r
+ \r
+});\r
+\r
+$.ui.plugin.add("resizable", "alsoResize", {\r
+ \r
+ start: function(e, ui) {\r
+ var o = ui.options, self = $(this).data("resizable"), \r
+ \r
+ _store = function(exp) {\r
+ $(exp).each(function() {\r
+ $(this).data("resizable-alsoresize", {\r
+ width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10),\r
+ left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10)\r
});\r
- };\r
- \r
- if (typeof(o.alsoResize) == 'object') {\r
- $.each(o.alsoResize, function(exp, c) { _store(exp); });\r
- }else{\r
- _store(o.alsoResize);\r
- } \r
+ });\r
+ };\r
+ \r
+ if (typeof(o.alsoResize) == 'object') {\r
+ $.each(o.alsoResize, function(exp, c) { _store(exp); });\r
+ }else{\r
+ _store(o.alsoResize);\r
+ } \r
+ },\r
+ \r
+ resize: function(e, ui){\r
+ var o = ui.options, self = $(this).data("resizable"), os = self.originalSize, op = self.originalPosition;\r
+ \r
+ var delta = { \r
+ height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,\r
+ top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0\r
},\r
\r
- resize: function(e, ui){\r
- var o = ui.options, self = $(this).data("resizable"), os = self.originalSize, op = self.originalPosition;\r
- \r
- var delta = { \r
- height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,\r
- top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0\r
- },\r
- \r
- _alsoResize = function(exp, c) {\r
- $(exp).each(function() {\r
- var start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left'];\r
- \r
- $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) {\r
- var sum = (start[prop]||0) + (delta[prop]||0);\r
- if (sum && sum >= 0)\r
- style[prop] = sum || null;\r
- });\r
- $(this).css(style);\r
+ _alsoResize = function(exp, c) {\r
+ $(exp).each(function() {\r
+ var start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left'];\r
+ \r
+ $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) {\r
+ var sum = (start[prop]||0) + (delta[prop]||0);\r
+ if (sum && sum >= 0)\r
+ style[prop] = sum || null;\r
});\r
- };\r
- \r
- if (typeof(o.alsoResize) == 'object') {\r
- $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); });\r
- }else{\r
- _alsoResize(o.alsoResize);\r
- }\r
- },\r
+ $(this).css(style);\r
+ });\r
+ };\r
\r
- stop: function(e, ui){\r
- $(this).removeData("resizable-alsoresize-start");\r
+ if (typeof(o.alsoResize) == 'object') {\r
+ $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); });\r
+ }else{\r
+ _alsoResize(o.alsoResize);\r
}\r
- });\r
+ },\r
+ \r
+ stop: function(e, ui){\r
+ $(this).removeData("resizable-alsoresize-start");\r
+ }\r
+});\r
\r
})(jQuery);\r
*/\r
;(function($) {\r
\r
- $.widget("ui.selectable", $.extend($.ui.mouse, {\r
- init: function() {\r
- var self = this;\r
- \r
- this.element.addClass("ui-selectable");\r
- \r
- this.dragged = false;\r
- \r
- // cache selectee children based on filter\r
- var selectees;\r
- this.refresh = function() {\r
- selectees = $(self.options.filter, self.element[0]);\r
- selectees.each(function() {\r
- var $this = $(this);\r
- var pos = $this.offset();\r
- $.data(this, "selectable-item", {\r
- element: this,\r
- $element: $this,\r
- left: pos.left,\r
- top: pos.top,\r
- right: pos.left + $this.width(),\r
- bottom: pos.top + $this.height(),\r
- startselected: false,\r
- selected: $this.hasClass('ui-selected'),\r
- selecting: $this.hasClass('ui-selecting'),\r
- unselecting: $this.hasClass('ui-unselecting')\r
- });\r
+$.widget("ui.selectable", $.extend($.ui.mouse, {\r
+ init: function() {\r
+ var self = this;\r
+ \r
+ this.element.addClass("ui-selectable");\r
+ \r
+ this.dragged = false;\r
+\r
+ // cache selectee children based on filter\r
+ var selectees;\r
+ this.refresh = function() {\r
+ selectees = $(self.options.filter, self.element[0]);\r
+ selectees.each(function() {\r
+ var $this = $(this);\r
+ var pos = $this.offset();\r
+ $.data(this, "selectable-item", {\r
+ element: this,\r
+ $element: $this,\r
+ left: pos.left,\r
+ top: pos.top,\r
+ right: pos.left + $this.width(),\r
+ bottom: pos.top + $this.height(),\r
+ startselected: false,\r
+ selected: $this.hasClass('ui-selected'),\r
+ selecting: $this.hasClass('ui-selecting'),\r
+ unselecting: $this.hasClass('ui-unselecting')\r
});\r
- };\r
- this.refresh();\r
- \r
- this.selectees = selectees.addClass("ui-selectee");\r
- \r
- this.mouseInit();\r
- \r
- this.helper = $(document.createElement('div')).css({border:'1px dotted black'});\r
- },\r
- toggle: function() {\r
- if(this.options.disabled){\r
- this.enable();\r
- } else {\r
- this.disable();\r
- }\r
- },\r
- destroy: function() {\r
- this.element\r
- .removeClass("ui-selectable ui-selectable-disabled")\r
- .removeData("selectable")\r
- .unbind(".selectable");\r
- this.mouseDestroy();\r
- },\r
- enable: function() {\r
- this.element.removeClass("ui-selectable-disabled");\r
- this.options.disabled = false;\r
- },\r
- disable: function() {\r
- this.element.addClass("ui-selectable-disabled");\r
- this.options.disabled = true;\r
- },\r
- mouseStart: function(e) {\r
- var self = this;\r
- \r
- this.opos = [e.pageX, e.pageY];\r
- \r
- if (this.options.disabled)\r
- return;\r
+ });\r
+ };\r
+ this.refresh();\r
\r
- var options = this.options;\r
+ this.selectees = selectees.addClass("ui-selectee");\r
+ \r
+ this.mouseInit();\r
+ \r
+ this.helper = $(document.createElement('div')).css({border:'1px dotted black'});\r
+ },\r
+ toggle: function() {\r
+ if(this.options.disabled){\r
+ this.enable();\r
+ } else {\r
+ this.disable();\r
+ }\r
+ },\r
+ destroy: function() {\r
+ this.element\r
+ .removeClass("ui-selectable ui-selectable-disabled")\r
+ .removeData("selectable")\r
+ .unbind(".selectable");\r
+ this.mouseDestroy();\r
+ },\r
+ enable: function() {\r
+ this.element.removeClass("ui-selectable-disabled");\r
+ this.options.disabled = false;\r
+ },\r
+ disable: function() {\r
+ this.element.addClass("ui-selectable-disabled");\r
+ this.options.disabled = true;\r
+ },\r
+ mouseStart: function(e) {\r
+ var self = this;\r
+ \r
+ this.opos = [e.pageX, e.pageY];\r
+ \r
+ if (this.options.disabled)\r
+ return;\r
\r
- this.selectees = $(options.filter, this.element[0]);\r
+ var options = this.options;\r
\r
- // selectable START callback\r
- this.element.triggerHandler("selectablestart", [e, {\r
- "selectable": this.element[0],\r
- "options": options\r
- }], options.start);\r
+ this.selectees = $(options.filter, this.element[0]);\r
\r
- $('body').append(this.helper);\r
- // position helper (lasso)\r
- this.helper.css({\r
- "z-index": 100,\r
- "position": "absolute",\r
- "left": e.clientX,\r
- "top": e.clientY,\r
- "width": 0,\r
- "height": 0\r
- });\r
+ // selectable START callback\r
+ this.element.triggerHandler("selectablestart", [e, {\r
+ "selectable": this.element[0],\r
+ "options": options\r
+ }], options.start);\r
\r
- if (options.autoRefresh) {\r
- this.refresh();\r
+ $('body').append(this.helper);\r
+ // position helper (lasso)\r
+ this.helper.css({\r
+ "z-index": 100,\r
+ "position": "absolute",\r
+ "left": e.clientX,\r
+ "top": e.clientY,\r
+ "width": 0,\r
+ "height": 0\r
+ });\r
+\r
+ if (options.autoRefresh) {\r
+ this.refresh();\r
+ }\r
+\r
+ this.selectees.filter('.ui-selected').each(function() {\r
+ var selectee = $.data(this, "selectable-item");\r
+ selectee.startselected = true;\r
+ if (!e.ctrlKey) {\r
+ selectee.$element.removeClass('ui-selected');\r
+ selectee.selected = false;\r
+ selectee.$element.addClass('ui-unselecting');\r
+ selectee.unselecting = true;\r
+ // selectable UNSELECTING callback\r
+ self.element.triggerHandler("selectableunselecting", [e, {\r
+ selectable: self.element[0],\r
+ unselecting: selectee.element,\r
+ options: options\r
+ }], options.unselecting);\r
}\r
+ });\r
+ \r
+ var isSelectee = false;\r
+ $(e.target).parents().andSelf().each(function() {\r
+ if($.data(this, "selectable-item")) isSelectee = true;\r
+ });\r
+ return this.options.keyboard ? !isSelectee : true;\r
+ },\r
+ mouseDrag: function(e) {\r
+ var self = this;\r
+ this.dragged = true;\r
+ \r
+ if (this.options.disabled)\r
+ return;\r
+\r
+ var options = this.options;\r
\r
- this.selectees.filter('.ui-selected').each(function() {\r
- var selectee = $.data(this, "selectable-item");\r
- selectee.startselected = true;\r
- if (!e.ctrlKey) {\r
+ var x1 = this.opos[0], y1 = this.opos[1], x2 = e.pageX, y2 = e.pageY;\r
+ if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }\r
+ if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }\r
+ this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});\r
+\r
+ this.selectees.each(function() {\r
+ var selectee = $.data(this, "selectable-item");\r
+ //prevent helper from being selected if appendTo: selectable\r
+ if (!selectee || selectee.element == self.element[0])\r
+ return;\r
+ var hit = false;\r
+ if (options.tolerance == 'touch') {\r
+ hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );\r
+ } else if (options.tolerance == 'fit') {\r
+ hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);\r
+ }\r
+\r
+ if (hit) {\r
+ // SELECT\r
+ if (selectee.selected) {\r
selectee.$element.removeClass('ui-selected');\r
selectee.selected = false;\r
- selectee.$element.addClass('ui-unselecting');\r
- selectee.unselecting = true;\r
- // selectable UNSELECTING callback\r
- self.element.triggerHandler("selectableunselecting", [e, {\r
+ }\r
+ if (selectee.unselecting) {\r
+ selectee.$element.removeClass('ui-unselecting');\r
+ selectee.unselecting = false;\r
+ }\r
+ if (!selectee.selecting) {\r
+ selectee.$element.addClass('ui-selecting');\r
+ selectee.selecting = true;\r
+ // selectable SELECTING callback\r
+ self.element.triggerHandler("selectableselecting", [e, {\r
selectable: self.element[0],\r
- unselecting: selectee.element,\r
+ selecting: selectee.element,\r
options: options\r
- }], options.unselecting);\r
+ }], options.selecting);\r
}\r
- });\r
- \r
- var isSelectee = false;\r
- $(e.target).parents().andSelf().each(function() {\r
- if($.data(this, "selectable-item")) isSelectee = true;\r
- });\r
- return this.options.keyboard ? !isSelectee : true;\r
- },\r
- mouseDrag: function(e) {\r
- var self = this;\r
- this.dragged = true;\r
- \r
- if (this.options.disabled)\r
- return;\r
-\r
- var options = this.options;\r
-\r
- var x1 = this.opos[0], y1 = this.opos[1], x2 = e.pageX, y2 = e.pageY;\r
- if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }\r
- if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }\r
- this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});\r
-\r
- this.selectees.each(function() {\r
- var selectee = $.data(this, "selectable-item");\r
- //prevent helper from being selected if appendTo: selectable\r
- if (!selectee || selectee.element == self.element[0])\r
- return;\r
- var hit = false;\r
- if (options.tolerance == 'touch') {\r
- hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );\r
- } else if (options.tolerance == 'fit') {\r
- hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);\r
+ } else {\r
+ // UNSELECT\r
+ if (selectee.selecting) {\r
+ if (e.ctrlKey && selectee.startselected) {\r
+ selectee.$element.removeClass('ui-selecting');\r
+ selectee.selecting = false;\r
+ selectee.$element.addClass('ui-selected');\r
+ selectee.selected = true;\r
+ } else {\r
+ selectee.$element.removeClass('ui-selecting');\r
+ selectee.selecting = false;\r
+ if (selectee.startselected) {\r
+ selectee.$element.addClass('ui-unselecting');\r
+ selectee.unselecting = true;\r
+ }\r
+ // selectable UNSELECTING callback\r
+ self.element.triggerHandler("selectableunselecting", [e, {\r
+ selectable: self.element[0],\r
+ unselecting: selectee.element,\r
+ options: options\r
+ }], options.unselecting);\r
+ }\r
}\r
-\r
- if (hit) {\r
- // SELECT\r
- if (selectee.selected) {\r
+ if (selectee.selected) {\r
+ if (!e.ctrlKey && !selectee.startselected) {\r
selectee.$element.removeClass('ui-selected');\r
selectee.selected = false;\r
- }\r
- if (selectee.unselecting) {\r
- selectee.$element.removeClass('ui-unselecting');\r
- selectee.unselecting = false;\r
- }\r
- if (!selectee.selecting) {\r
- selectee.$element.addClass('ui-selecting');\r
- selectee.selecting = true;\r
- // selectable SELECTING callback\r
- self.element.triggerHandler("selectableselecting", [e, {\r
+\r
+ selectee.$element.addClass('ui-unselecting');\r
+ selectee.unselecting = true;\r
+ // selectable UNSELECTING callback\r
+ self.element.triggerHandler("selectableunselecting", [e, {\r
selectable: self.element[0],\r
- selecting: selectee.element,\r
+ unselecting: selectee.element,\r
options: options\r
- }], options.selecting);\r
- }\r
- } else {\r
- // UNSELECT\r
- if (selectee.selecting) {\r
- if (e.ctrlKey && selectee.startselected) {\r
- selectee.$element.removeClass('ui-selecting');\r
- selectee.selecting = false;\r
- selectee.$element.addClass('ui-selected');\r
- selectee.selected = true;\r
- } else {\r
- selectee.$element.removeClass('ui-selecting');\r
- selectee.selecting = false;\r
- if (selectee.startselected) {\r
- selectee.$element.addClass('ui-unselecting');\r
- selectee.unselecting = true;\r
- }\r
- // selectable UNSELECTING callback\r
- self.element.triggerHandler("selectableunselecting", [e, {\r
- selectable: self.element[0],\r
- unselecting: selectee.element,\r
- options: options\r
- }], options.unselecting);\r
- }\r
- }\r
- if (selectee.selected) {\r
- if (!e.ctrlKey && !selectee.startselected) {\r
- selectee.$element.removeClass('ui-selected');\r
- selectee.selected = false;\r
-\r
- selectee.$element.addClass('ui-unselecting');\r
- selectee.unselecting = true;\r
- // selectable UNSELECTING callback\r
- self.element.triggerHandler("selectableunselecting", [e, {\r
- selectable: self.element[0],\r
- unselecting: selectee.element,\r
- options: options\r
- }], options.unselecting);\r
- }\r
+ }], options.unselecting);\r
}\r
}\r
- });\r
- \r
- return false;\r
- },\r
- mouseStop: function(e) {\r
- var self = this;\r
- \r
- this.dragged = false;\r
- \r
- var options = this.options;\r
+ }\r
+ });\r
+ \r
+ return false;\r
+ },\r
+ mouseStop: function(e) {\r
+ var self = this;\r
+ \r
+ this.dragged = false;\r
+ \r
+ var options = this.options;\r
\r
- $('.ui-unselecting', this.element[0]).each(function() {\r
- var selectee = $.data(this, "selectable-item");\r
- selectee.$element.removeClass('ui-unselecting');\r
- selectee.unselecting = false;\r
- selectee.startselected = false;\r
- self.element.triggerHandler("selectableunselected", [e, {\r
- selectable: self.element[0],\r
- unselected: selectee.element,\r
- options: options\r
- }], options.unselected);\r
- });\r
- $('.ui-selecting', this.element[0]).each(function() {\r
- var selectee = $.data(this, "selectable-item");\r
- selectee.$element.removeClass('ui-selecting').addClass('ui-selected');\r
- selectee.selecting = false;\r
- selectee.selected = true;\r
- selectee.startselected = true;\r
- self.element.triggerHandler("selectableselected", [e, {\r
- selectable: self.element[0],\r
- selected: selectee.element,\r
- options: options\r
- }], options.selected);\r
- });\r
- this.element.triggerHandler("selectablestop", [e, {\r
+ $('.ui-unselecting', this.element[0]).each(function() {\r
+ var selectee = $.data(this, "selectable-item");\r
+ selectee.$element.removeClass('ui-unselecting');\r
+ selectee.unselecting = false;\r
+ selectee.startselected = false;\r
+ self.element.triggerHandler("selectableunselected", [e, {\r
selectable: self.element[0],\r
- options: this.options\r
- }], this.options.stop);\r
- \r
- this.helper.remove();\r
- \r
- return false;\r
- }\r
- }));\r
- \r
- $.extend($.ui.selectable, {\r
- defaults: {\r
- distance: 0,\r
- delay: 0,\r
- cancel: ":input,button",\r
- appendTo: 'body',\r
- autoRefresh: true,\r
- filter: '*',\r
- tolerance: 'touch'\r
- }\r
- });\r
- \r
+ unselected: selectee.element,\r
+ options: options\r
+ }], options.unselected);\r
+ });\r
+ $('.ui-selecting', this.element[0]).each(function() {\r
+ var selectee = $.data(this, "selectable-item");\r
+ selectee.$element.removeClass('ui-selecting').addClass('ui-selected');\r
+ selectee.selecting = false;\r
+ selectee.selected = true;\r
+ selectee.startselected = true;\r
+ self.element.triggerHandler("selectableselected", [e, {\r
+ selectable: self.element[0],\r
+ selected: selectee.element,\r
+ options: options\r
+ }], options.selected);\r
+ });\r
+ this.element.triggerHandler("selectablestop", [e, {\r
+ selectable: self.element[0],\r
+ options: this.options\r
+ }], this.options.stop);\r
+ \r
+ this.helper.remove();\r
+ \r
+ return false;\r
+ }\r
+}));\r
+\r
+$.extend($.ui.selectable, {\r
+ defaults: {\r
+ distance: 0,\r
+ delay: 0,\r
+ cancel: ":input,button",\r
+ appendTo: 'body',\r
+ autoRefresh: true,\r
+ filter: '*',\r
+ tolerance: 'touch'\r
+ }\r
+});\r
+\r
})(jQuery);\r
*/\r
;(function($) {\r
\r
- $.fn.unwrap = $.fn.unwrap || function(expr) {\r
- return this.each(function(){\r
- $(this).parents(expr).eq(0).after(this).remove();\r
- });\r
- };\r
- \r
+$.fn.unwrap = $.fn.unwrap || function(expr) {\r
+ return this.each(function(){\r
+ $(this).parents(expr).eq(0).after(this).remove();\r
+ });\r
+};\r
\r
- $.widget("ui.slider", {\r
- plugins: {},\r
- ui: function(e) {\r
- return {\r
- instance: this,\r
- options: this.options,\r
- handle: this.currentHandle,\r
- value: this.options.axis != "both" || !this.options.axis ? Math.round(this.value(null,this.options.axis == "vertical" ? "y" : "x")) : {\r
- x: Math.round(this.value(null,"x")),\r
- y: Math.round(this.value(null,"y"))\r
- },\r
- range: this.getRange()\r
- };\r
- },\r
- propagate: function(n,e) {\r
- $.ui.plugin.call(this, n, [e, this.ui()]);\r
- this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]);\r
- },\r
- destroy: function() {\r
- this.element\r
- .removeClass("ui-slider ui-slider-disabled")\r
- .removeData("slider")\r
- .unbind(".slider");\r
- this.handle\r
- .unwrap("a")\r
- .mouse("destroy");\r
- this.generated && this.generated.remove();\r
- },\r
- enable: function() {\r
- this.element.removeClass("ui-slider-disabled");\r
- this.disabled = false;\r
- },\r
- disable: function() {\r
- this.element.addClass("ui-slider-disabled");\r
- this.disabled = true;\r
- },\r
- setData: function(key, value) {\r
- this.options[key] = value;\r
- if (/min|max|steps/.test(key)) {\r
- this.initBoundaries();\r
- }\r
- },\r
\r
- init: function() {\r
- \r
- var self = this;\r
- this.element.addClass("ui-slider");\r
+$.widget("ui.slider", {\r
+ plugins: {},\r
+ ui: function(e) {\r
+ return {\r
+ instance: this,\r
+ options: this.options,\r
+ handle: this.currentHandle,\r
+ value: this.options.axis != "both" || !this.options.axis ? Math.round(this.value(null,this.options.axis == "vertical" ? "y" : "x")) : {\r
+ x: Math.round(this.value(null,"x")),\r
+ y: Math.round(this.value(null,"y"))\r
+ },\r
+ range: this.getRange()\r
+ };\r
+ },\r
+ propagate: function(n,e) {\r
+ $.ui.plugin.call(this, n, [e, this.ui()]);\r
+ this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]);\r
+ },\r
+ destroy: function() {\r
+ this.element\r
+ .removeClass("ui-slider ui-slider-disabled")\r
+ .removeData("slider")\r
+ .unbind(".slider");\r
+ this.handle\r
+ .unwrap("a")\r
+ .mouse("destroy");\r
+ this.generated && this.generated.remove();\r
+ },\r
+ enable: function() {\r
+ this.element.removeClass("ui-slider-disabled");\r
+ this.disabled = false;\r
+ },\r
+ disable: function() {\r
+ this.element.addClass("ui-slider-disabled");\r
+ this.disabled = true;\r
+ },\r
+ setData: function(key, value) {\r
+ this.options[key] = value;\r
+ if (/min|max|steps/.test(key)) {\r
this.initBoundaries();\r
- \r
- // Initialize mouse and key events for interaction\r
- this.handle = $(this.options.handle, this.element);\r
- if (!this.handle.length) {\r
- self.handle = self.generated = $(self.options.handles || [0]).map(function() {\r
- var handle = $("<div/>").addClass("ui-slider-handle").appendTo(self.element);\r
- if (this.id)\r
- handle.attr("id", this.id);\r
- return handle[0];\r
- });\r
- }\r
- \r
- \r
- var handleclass = function(el) {\r
- this.element = $(el);\r
- this.element.data("mouse", this);\r
- this.options = self.options;\r
- \r
- this.element.bind("mousedown", function() {\r
- if(self.currentHandle) this.blur(self.currentHandle);\r
- self.focus(this,1);\r
- });\r
- \r
- this.mouseInit();\r
- };\r
- \r
- $.extend(handleclass.prototype, $.ui.mouse, {\r
- mouseStart: function(e) { return self.start.call(self, e, this.element[0]); },\r
- mouseStop: function(e) { return self.stop.call(self, e, this.element[0]); },\r
- mouseDrag: function(e) { return self.drag.call(self, e, this.element[0]); },\r
- trigger: function(e) { this.mouseDown(e); }\r
- });\r
- \r
- \r
- $(this.handle)\r
- .each(function() {\r
- new handleclass(this);\r
- })\r
- .wrap('<a href="javascript:void(0)" style="cursor:default;"></a>')\r
- .parent()\r
- .bind('focus', function(e) { self.focus(this.firstChild); })\r
- .bind('blur', function(e) { self.blur(this.firstChild); })\r
- .bind('keydown', function(e) { if(!self.options.noKeyboard) self.keydown(e.keyCode, this.firstChild); })\r
- ;\r
- \r
- // Bind the click to the slider itself\r
- this.element.bind('mousedown.slider', function(e) {\r
- self.click.apply(self, [e]);\r
- self.currentHandle.data("mouse").trigger(e);\r
- self.firstValue = self.firstValue + 1; //This is for always triggering the change event\r
- });\r
- \r
- // Move the first handle to the startValue\r
- $.each(this.options.handles || [], function(index, handle) {\r
- self.moveTo(handle.start, index, true);\r
- });\r
- if (!isNaN(this.options.startValue))\r
- this.moveTo(this.options.startValue, 0, true);\r
+ }\r
+ },\r
\r
- this.previousHandle = $(this.handle[0]); //set the previous handle to the first to allow clicking before selecting the handle\r
- if(this.handle.length == 2 && this.options.range) this.createRange();\r
- },\r
- initBoundaries: function() {\r
- \r
- var element = this.element[0], o = this.options;\r
- this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() }; \r
- \r
- $.extend(o, {\r
- axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'),\r
- max: !isNaN(parseInt(o.max,10)) ? { x: parseInt(o.max, 10), y: parseInt(o.max, 10) } : ({ x: o.max && o.max.x || 100, y: o.max && o.max.y || 100 }),\r
- min: !isNaN(parseInt(o.min,10)) ? { x: parseInt(o.min, 10), y: parseInt(o.min, 10) } : ({ x: o.min && o.min.x || 0, y: o.min && o.min.y || 0 })\r
+ init: function() {\r
+ \r
+ var self = this;\r
+ this.element.addClass("ui-slider");\r
+ this.initBoundaries();\r
+ \r
+ // Initialize mouse and key events for interaction\r
+ this.handle = $(this.options.handle, this.element);\r
+ if (!this.handle.length) {\r
+ self.handle = self.generated = $(self.options.handles || [0]).map(function() {\r
+ var handle = $("<div/>").addClass("ui-slider-handle").appendTo(self.element);\r
+ if (this.id)\r
+ handle.attr("id", this.id);\r
+ return handle[0];\r
});\r
- //Prepare the real maxValue\r
- o.realMax = {\r
- x: o.max.x - o.min.x,\r
- y: o.max.y - o.min.y\r
- };\r
- //Calculate stepping based on steps\r
- o.stepping = {\r
- x: o.stepping && o.stepping.x || parseInt(o.stepping, 10) || (o.steps ? o.realMax.x/(o.steps.x || parseInt(o.steps, 10) || o.realMax.x) : 0),\r
- y: o.stepping && o.stepping.y || parseInt(o.stepping, 10) || (o.steps ? o.realMax.y/(o.steps.y || parseInt(o.steps, 10) || o.realMax.y) : 0)\r
- };\r
- },\r
-\r
+ }\r
\r
- keydown: function(keyCode, handle) {\r
- if(/(37|38|39|40)/.test(keyCode)) {\r
- this.moveTo({\r
- x: /(37|39)/.test(keyCode) ? (keyCode == 37 ? '-' : '+') + '=' + this.oneStep("x") : 0,\r
- y: /(38|40)/.test(keyCode) ? (keyCode == 38 ? '-' : '+') + '=' + this.oneStep("y") : 0\r
- }, handle);\r
- }\r
- },\r
- focus: function(handle,hard) {\r
- this.currentHandle = $(handle).addClass('ui-slider-handle-active');\r
- if (hard)\r
- this.currentHandle.parent()[0].focus();\r
- },\r
- blur: function(handle) {\r
- $(handle).removeClass('ui-slider-handle-active');\r
- if(this.currentHandle && this.currentHandle[0] == handle) { this.previousHandle = this.currentHandle; this.currentHandle = null; };\r
- },\r
- click: function(e) {\r
- // This method is only used if:\r
- // - The user didn't click a handle\r
- // - The Slider is not disabled\r
- // - There is a current, or previous selected handle (otherwise we wouldn't know which one to move)\r
- \r
- var pointer = [e.pageX,e.pageY];\r
+ \r
+ var handleclass = function(el) {\r
+ this.element = $(el);\r
+ this.element.data("mouse", this);\r
+ this.options = self.options;\r
\r
- var clickedHandle = false;\r
- this.handle.each(function() {\r
- if(this == e.target)\r
- clickedHandle = true;\r
+ this.element.bind("mousedown", function() {\r
+ if(self.currentHandle) this.blur(self.currentHandle);\r
+ self.focus(this,1);\r
});\r
- if (clickedHandle || this.disabled || !(this.currentHandle || this.previousHandle))\r
- return;\r
-\r
- // If a previous handle was focussed, focus it again\r
- if (!this.currentHandle && this.previousHandle)\r
- this.focus(this.previousHandle, true);\r
\r
- // propagate only for distance > 0, otherwise propagation is done my drag\r
- this.offset = this.element.offset();\r
+ this.mouseInit();\r
+ };\r
+ \r
+ $.extend(handleclass.prototype, $.ui.mouse, {\r
+ mouseStart: function(e) { return self.start.call(self, e, this.element[0]); },\r
+ mouseStop: function(e) { return self.stop.call(self, e, this.element[0]); },\r
+ mouseDrag: function(e) { return self.drag.call(self, e, this.element[0]); },\r
+ trigger: function(e) { this.mouseDown(e); }\r
+ });\r
+ \r
+ \r
+ $(this.handle)\r
+ .each(function() {\r
+ new handleclass(this);\r
+ })\r
+ .wrap('<a href="javascript:void(0)" style="cursor:default;"></a>')\r
+ .parent()\r
+ .bind('focus', function(e) { self.focus(this.firstChild); })\r
+ .bind('blur', function(e) { self.blur(this.firstChild); })\r
+ .bind('keydown', function(e) { if(!self.options.noKeyboard) self.keydown(e.keyCode, this.firstChild); })\r
+ ;\r
+ \r
+ // Bind the click to the slider itself\r
+ this.element.bind('mousedown.slider', function(e) {\r
+ self.click.apply(self, [e]);\r
+ self.currentHandle.data("mouse").trigger(e);\r
+ self.firstValue = self.firstValue + 1; //This is for always triggering the change event\r
+ });\r
+ \r
+ // Move the first handle to the startValue\r
+ $.each(this.options.handles || [], function(index, handle) {\r
+ self.moveTo(handle.start, index, true);\r
+ });\r
+ if (!isNaN(this.options.startValue))\r
+ this.moveTo(this.options.startValue, 0, true);\r
\r
+ this.previousHandle = $(this.handle[0]); //set the previous handle to the first to allow clicking before selecting the handle\r
+ if(this.handle.length == 2 && this.options.range) this.createRange();\r
+ },\r
+ initBoundaries: function() {\r
+ \r
+ var element = this.element[0], o = this.options;\r
+ this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() }; \r
+ \r
+ $.extend(o, {\r
+ axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'),\r
+ max: !isNaN(parseInt(o.max,10)) ? { x: parseInt(o.max, 10), y: parseInt(o.max, 10) } : ({ x: o.max && o.max.x || 100, y: o.max && o.max.y || 100 }),\r
+ min: !isNaN(parseInt(o.min,10)) ? { x: parseInt(o.min, 10), y: parseInt(o.min, 10) } : ({ x: o.min && o.min.x || 0, y: o.min && o.min.y || 0 })\r
+ });\r
+ //Prepare the real maxValue\r
+ o.realMax = {\r
+ x: o.max.x - o.min.x,\r
+ y: o.max.y - o.min.y\r
+ };\r
+ //Calculate stepping based on steps\r
+ o.stepping = {\r
+ x: o.stepping && o.stepping.x || parseInt(o.stepping, 10) || (o.steps ? o.realMax.x/(o.steps.x || parseInt(o.steps, 10) || o.realMax.x) : 0),\r
+ y: o.stepping && o.stepping.y || parseInt(o.stepping, 10) || (o.steps ? o.realMax.y/(o.steps.y || parseInt(o.steps, 10) || o.realMax.y) : 0)\r
+ };\r
+ },\r
+\r
+ \r
+ keydown: function(keyCode, handle) {\r
+ if(/(37|38|39|40)/.test(keyCode)) {\r
this.moveTo({\r
- y: this.convertValue(e.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"),\r
- x: this.convertValue(e.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x")\r
- }, null, !this.options.distance);\r
- },\r
+ x: /(37|39)/.test(keyCode) ? (keyCode == 37 ? '-' : '+') + '=' + this.oneStep("x") : 0,\r
+ y: /(38|40)/.test(keyCode) ? (keyCode == 38 ? '-' : '+') + '=' + this.oneStep("y") : 0\r
+ }, handle);\r
+ }\r
+ },\r
+ focus: function(handle,hard) {\r
+ this.currentHandle = $(handle).addClass('ui-slider-handle-active');\r
+ if (hard)\r
+ this.currentHandle.parent()[0].focus();\r
+ },\r
+ blur: function(handle) {\r
+ $(handle).removeClass('ui-slider-handle-active');\r
+ if(this.currentHandle && this.currentHandle[0] == handle) { this.previousHandle = this.currentHandle; this.currentHandle = null; };\r
+ },\r
+ click: function(e) {\r
+ // This method is only used if:\r
+ // - The user didn't click a handle\r
+ // - The Slider is not disabled\r
+ // - There is a current, or previous selected handle (otherwise we wouldn't know which one to move)\r
+ \r
+ var pointer = [e.pageX,e.pageY];\r
\r
+ var clickedHandle = false;\r
+ this.handle.each(function() {\r
+ if(this == e.target)\r
+ clickedHandle = true;\r
+ });\r
+ if (clickedHandle || this.disabled || !(this.currentHandle || this.previousHandle))\r
+ return;\r
\r
+ // If a previous handle was focussed, focus it again\r
+ if (!this.currentHandle && this.previousHandle)\r
+ this.focus(this.previousHandle, true);\r
+ \r
+ // propagate only for distance > 0, otherwise propagation is done my drag\r
+ this.offset = this.element.offset();\r
+\r
+ this.moveTo({\r
+ y: this.convertValue(e.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"),\r
+ x: this.convertValue(e.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x")\r
+ }, null, !this.options.distance);\r
+ },\r
\r
- createRange: function() {\r
- this.rangeElement = $('<div></div>')\r
- .addClass('ui-slider-range')\r
- .css({ position: 'absolute' })\r
- .appendTo(this.element);\r
- this.updateRange();\r
- },\r
- updateRange: function() {\r
- var prop = this.options.axis == "vertical" ? "top" : "left";\r
- var size = this.options.axis == "vertical" ? "height" : "width";\r
- this.rangeElement.css(prop, parseInt($(this.handle[0]).css(prop),10) + this.handleSize(0, this.options.axis == "vertical" ? "y" : "x")/2);\r
- this.rangeElement.css(size, parseInt($(this.handle[1]).css(prop),10) - parseInt($(this.handle[0]).css(prop),10));\r
- },\r
- getRange: function() {\r
- return this.rangeElement ? this.convertValue(parseInt(this.rangeElement.css(this.options.axis == "vertical" ? "height" : "width"),10), this.options.axis == "vertical" ? "y" : "x") : null;\r
- },\r
\r
- handleIndex: function() {\r
- return this.handle.index(this.currentHandle[0]);\r
- },\r
- value: function(handle, axis) {\r
- if(this.handle.length == 1) this.currentHandle = this.handle;\r
- if(!axis) axis = this.options.axis == "vertical" ? "y" : "x";\r
\r
- var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle);\r
- \r
- if(curHandle.data("mouse").sliderValue) {\r
- return parseInt(curHandle.data("mouse").sliderValue[axis],10);\r
- } else {\r
- return parseInt(((parseInt(curHandle.css(axis == "x" ? "left" : "top"),10) / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(handle,axis))) * this.options.realMax[axis]) + this.options.min[axis],10);\r
- }\r
+ createRange: function() {\r
+ this.rangeElement = $('<div></div>')\r
+ .addClass('ui-slider-range')\r
+ .css({ position: 'absolute' })\r
+ .appendTo(this.element);\r
+ this.updateRange();\r
+ },\r
+ updateRange: function() {\r
+ var prop = this.options.axis == "vertical" ? "top" : "left";\r
+ var size = this.options.axis == "vertical" ? "height" : "width";\r
+ this.rangeElement.css(prop, parseInt($(this.handle[0]).css(prop),10) + this.handleSize(0, this.options.axis == "vertical" ? "y" : "x")/2);\r
+ this.rangeElement.css(size, parseInt($(this.handle[1]).css(prop),10) - parseInt($(this.handle[0]).css(prop),10));\r
+ },\r
+ getRange: function() {\r
+ return this.rangeElement ? this.convertValue(parseInt(this.rangeElement.css(this.options.axis == "vertical" ? "height" : "width"),10), this.options.axis == "vertical" ? "y" : "x") : null;\r
+ },\r
\r
- },\r
- convertValue: function(value,axis) {\r
- return this.options.min[axis] + (value / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis))) * this.options.realMax[axis];\r
- },\r
+ handleIndex: function() {\r
+ return this.handle.index(this.currentHandle[0]);\r
+ },\r
+ value: function(handle, axis) {\r
+ if(this.handle.length == 1) this.currentHandle = this.handle;\r
+ if(!axis) axis = this.options.axis == "vertical" ? "y" : "x";\r
+\r
+ var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle);\r
\r
- translateValue: function(value,axis) {\r
- return ((value - this.options.min[axis]) / this.options.realMax[axis]) * (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis));\r
- },\r
- translateRange: function(value,axis) {\r
- if (this.rangeElement) {\r
- if (this.currentHandle[0] == this.handle[0] && value >= this.translateValue(this.value(1),axis))\r
- value = this.translateValue(this.value(1,axis) - this.oneStep(axis), axis);\r
- if (this.currentHandle[0] == this.handle[1] && value <= this.translateValue(this.value(0),axis))\r
- value = this.translateValue(this.value(0,axis) + this.oneStep(axis), axis);\r
- }\r
- if (this.options.handles) {\r
- var handle = this.options.handles[this.handleIndex()];\r
- if (value < this.translateValue(handle.min,axis)) {\r
- value = this.translateValue(handle.min,axis);\r
- } else if (value > this.translateValue(handle.max,axis)) {\r
- value = this.translateValue(handle.max,axis);\r
- }\r
+ if(curHandle.data("mouse").sliderValue) {\r
+ return parseInt(curHandle.data("mouse").sliderValue[axis],10);\r
+ } else {\r
+ return parseInt(((parseInt(curHandle.css(axis == "x" ? "left" : "top"),10) / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(handle,axis))) * this.options.realMax[axis]) + this.options.min[axis],10);\r
+ }\r
+\r
+ },\r
+ convertValue: function(value,axis) {\r
+ return this.options.min[axis] + (value / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis))) * this.options.realMax[axis];\r
+ },\r
+ \r
+ translateValue: function(value,axis) {\r
+ return ((value - this.options.min[axis]) / this.options.realMax[axis]) * (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis));\r
+ },\r
+ translateRange: function(value,axis) {\r
+ if (this.rangeElement) {\r
+ if (this.currentHandle[0] == this.handle[0] && value >= this.translateValue(this.value(1),axis))\r
+ value = this.translateValue(this.value(1,axis) - this.oneStep(axis), axis);\r
+ if (this.currentHandle[0] == this.handle[1] && value <= this.translateValue(this.value(0),axis))\r
+ value = this.translateValue(this.value(0,axis) + this.oneStep(axis), axis);\r
+ }\r
+ if (this.options.handles) {\r
+ var handle = this.options.handles[this.handleIndex()];\r
+ if (value < this.translateValue(handle.min,axis)) {\r
+ value = this.translateValue(handle.min,axis);\r
+ } else if (value > this.translateValue(handle.max,axis)) {\r
+ value = this.translateValue(handle.max,axis);\r
}\r
- return value;\r
- },\r
- translateLimits: function(value,axis) {\r
- if (value >= this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis))\r
- value = this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis);\r
- if (value <= 0)\r
- value = 0;\r
- return value;\r
- },\r
- handleSize: function(handle,axis) {\r
- return $(handle != undefined && handle !== null ? this.handle[handle] : this.currentHandle)[0]["offset"+(axis == "x" ? "Width" : "Height")]; \r
- },\r
- oneStep: function(axis) {\r
- return this.options.stepping[axis] || 1;\r
- },\r
+ }\r
+ return value;\r
+ },\r
+ translateLimits: function(value,axis) {\r
+ if (value >= this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis))\r
+ value = this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis);\r
+ if (value <= 0)\r
+ value = 0;\r
+ return value;\r
+ },\r
+ handleSize: function(handle,axis) {\r
+ return $(handle != undefined && handle !== null ? this.handle[handle] : this.currentHandle)[0]["offset"+(axis == "x" ? "Width" : "Height")]; \r
+ },\r
+ oneStep: function(axis) {\r
+ return this.options.stepping[axis] || 1;\r
+ },\r
\r
\r
- start: function(e, handle) {\r
- \r
- var o = this.options;\r
- if(this.disabled) return false;\r
+ start: function(e, handle) {\r
+ \r
+ var o = this.options;\r
+ if(this.disabled) return false;\r
\r
- // Prepare the outer size\r
- this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };\r
- \r
- // This is a especially ugly fix for strange blur events happening on mousemove events\r
- if (!this.currentHandle)\r
- this.focus(this.previousHandle, true); \r
+ // Prepare the outer size\r
+ this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };\r
+ \r
+ // This is a especially ugly fix for strange blur events happening on mousemove events\r
+ if (!this.currentHandle)\r
+ this.focus(this.previousHandle, true); \r
\r
- this.offset = this.element.offset();\r
- \r
- this.handleOffset = this.currentHandle.offset();\r
- this.clickOffset = { top: e.pageY - this.handleOffset.top, left: e.pageX - this.handleOffset.left };\r
- \r
- this.firstValue = this.value();\r
- \r
- this.propagate('start', e);\r
- return true;\r
- \r
- },\r
- stop: function(e) {\r
- this.propagate('stop', e);\r
- if (this.firstValue != this.value())\r
- this.propagate('change', e);\r
- // This is a especially ugly fix for strange blur events happening on mousemove events\r
- this.focus(this.currentHandle, true);\r
- return false;\r
- },\r
- drag: function(e, handle) {\r
+ this.offset = this.element.offset();\r
+ \r
+ this.handleOffset = this.currentHandle.offset();\r
+ this.clickOffset = { top: e.pageY - this.handleOffset.top, left: e.pageX - this.handleOffset.left };\r
+ \r
+ this.firstValue = this.value();\r
+ \r
+ this.propagate('start', e);\r
+ return true;\r
+ \r
+ },\r
+ stop: function(e) {\r
+ this.propagate('stop', e);\r
+ if (this.firstValue != this.value())\r
+ this.propagate('change', e);\r
+ // This is a especially ugly fix for strange blur events happening on mousemove events\r
+ this.focus(this.currentHandle, true);\r
+ return false;\r
+ },\r
+ drag: function(e, handle) {\r
\r
- var o = this.options;\r
- var position = { top: e.pageY - this.offset.top - this.clickOffset.top, left: e.pageX - this.offset.left - this.clickOffset.left};\r
- if(!this.currentHandle) this.focus(this.previousHandle, true); //This is a especially ugly fix for strange blur events happening on mousemove events\r
+ var o = this.options;\r
+ var position = { top: e.pageY - this.offset.top - this.clickOffset.top, left: e.pageX - this.offset.left - this.clickOffset.left};\r
+ if(!this.currentHandle) this.focus(this.previousHandle, true); //This is a especially ugly fix for strange blur events happening on mousemove events\r
\r
- position.left = this.translateLimits(position.left, "x");\r
- position.top = this.translateLimits(position.top, "y");\r
- \r
- if (o.stepping.x) {\r
- var value = this.convertValue(position.left, "x");\r
- value = Math.round(value / o.stepping.x) * o.stepping.x;\r
- position.left = this.translateValue(value, "x"); \r
- }\r
- if (o.stepping.y) {\r
- var value = this.convertValue(position.top, "y");\r
- value = Math.round(value / o.stepping.y) * o.stepping.y;\r
- position.top = this.translateValue(value, "y"); \r
- }\r
- \r
- position.left = this.translateRange(position.left, "x");\r
- position.top = this.translateRange(position.top, "y");\r
+ position.left = this.translateLimits(position.left, "x");\r
+ position.top = this.translateLimits(position.top, "y");\r
+ \r
+ if (o.stepping.x) {\r
+ var value = this.convertValue(position.left, "x");\r
+ value = Math.round(value / o.stepping.x) * o.stepping.x;\r
+ position.left = this.translateValue(value, "x"); \r
+ }\r
+ if (o.stepping.y) {\r
+ var value = this.convertValue(position.top, "y");\r
+ value = Math.round(value / o.stepping.y) * o.stepping.y;\r
+ position.top = this.translateValue(value, "y"); \r
+ }\r
+ \r
+ position.left = this.translateRange(position.left, "x");\r
+ position.top = this.translateRange(position.top, "y");\r
\r
- if(o.axis != "vertical") this.currentHandle.css({ left: position.left });\r
- if(o.axis != "horizontal") this.currentHandle.css({ top: position.top });\r
- \r
- //Store the slider's value\r
- this.currentHandle.data("mouse").sliderValue = {\r
- x: Math.round(this.convertValue(position.left, "x")) || 0,\r
- y: Math.round(this.convertValue(position.top, "y")) || 0\r
- };\r
- \r
- if (this.rangeElement)\r
- this.updateRange();\r
- this.propagate('slide', e);\r
- return false;\r
- },\r
+ if(o.axis != "vertical") this.currentHandle.css({ left: position.left });\r
+ if(o.axis != "horizontal") this.currentHandle.css({ top: position.top });\r
\r
- moveTo: function(value, handle, noPropagation) {\r
+ //Store the slider's value\r
+ this.currentHandle.data("mouse").sliderValue = {\r
+ x: Math.round(this.convertValue(position.left, "x")) || 0,\r
+ y: Math.round(this.convertValue(position.top, "y")) || 0\r
+ };\r
+ \r
+ if (this.rangeElement)\r
+ this.updateRange();\r
+ this.propagate('slide', e);\r
+ return false;\r
+ },\r
+ \r
+ moveTo: function(value, handle, noPropagation) {\r
\r
- var o = this.options;\r
+ var o = this.options;\r
\r
- // Prepare the outer size\r
- this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };\r
+ // Prepare the outer size\r
+ this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };\r
\r
- //If no handle has been passed, no current handle is available and we have multiple handles, return false\r
- if (handle == undefined && !this.currentHandle && this.handle.length != 1)\r
- return false; \r
- \r
- //If only one handle is available, use it\r
- if (handle == undefined && !this.currentHandle)\r
- handle = 0;\r
- \r
- if (handle != undefined)\r
- this.currentHandle = this.previousHandle = $(this.handle[handle] || handle);\r
+ //If no handle has been passed, no current handle is available and we have multiple handles, return false\r
+ if (handle == undefined && !this.currentHandle && this.handle.length != 1)\r
+ return false; \r
+ \r
+ //If only one handle is available, use it\r
+ if (handle == undefined && !this.currentHandle)\r
+ handle = 0;\r
+ \r
+ if (handle != undefined)\r
+ this.currentHandle = this.previousHandle = $(this.handle[handle] || handle);\r
\r
\r
- if(value.x !== undefined && value.y !== undefined) {\r
- var x = value.x, y = value.y;\r
- } else {\r
- var x = value, y = value;\r
- }\r
+ if(value.x !== undefined && value.y !== undefined) {\r
+ var x = value.x, y = value.y;\r
+ } else {\r
+ var x = value, y = value;\r
+ }\r
\r
- if(x !== undefined && x.constructor != Number) {\r
- var me = /^\-\=/.test(x), pe = /^\+\=/.test(x);\r
- if(me || pe) {\r
- x = this.value(null, "x") + parseInt(x.replace(me ? '=' : '+=', ''), 10);\r
- } else {\r
- x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10);\r
- }\r
+ if(x !== undefined && x.constructor != Number) {\r
+ var me = /^\-\=/.test(x), pe = /^\+\=/.test(x);\r
+ if(me || pe) {\r
+ x = this.value(null, "x") + parseInt(x.replace(me ? '=' : '+=', ''), 10);\r
+ } else {\r
+ x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10);\r
}\r
- \r
- if(y !== undefined && y.constructor != Number) {\r
- var me = /^\-\=/.test(y), pe = /^\+\=/.test(y);\r
- if(me || pe) {\r
- y = this.value(null, "y") + parseInt(y.replace(me ? '=' : '+=', ''), 10);\r
- } else {\r
- y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10);\r
- }\r
+ }\r
+ \r
+ if(y !== undefined && y.constructor != Number) {\r
+ var me = /^\-\=/.test(y), pe = /^\+\=/.test(y);\r
+ if(me || pe) {\r
+ y = this.value(null, "y") + parseInt(y.replace(me ? '=' : '+=', ''), 10);\r
+ } else {\r
+ y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10);\r
}\r
+ }\r
\r
- if(o.axis != "vertical" && x !== undefined) {\r
- if(o.stepping.x) x = Math.round(x / o.stepping.x) * o.stepping.x;\r
- x = this.translateValue(x, "x");\r
- x = this.translateLimits(x, "x");\r
- x = this.translateRange(x, "x");\r
- this.currentHandle.css({ left: x });\r
- }\r
+ if(o.axis != "vertical" && x !== undefined) {\r
+ if(o.stepping.x) x = Math.round(x / o.stepping.x) * o.stepping.x;\r
+ x = this.translateValue(x, "x");\r
+ x = this.translateLimits(x, "x");\r
+ x = this.translateRange(x, "x");\r
+ this.currentHandle.css({ left: x });\r
+ }\r
\r
- if(o.axis != "horizontal" && y !== undefined) {\r
- if(o.stepping.y) y = Math.round(y / o.stepping.y) * o.stepping.y;\r
- y = this.translateValue(y, "y");\r
- y = this.translateLimits(y, "y");\r
- y = this.translateRange(y, "y");\r
- this.currentHandle.css({ top: y });\r
- }\r
- \r
- if (this.rangeElement)\r
- this.updateRange();\r
- \r
- //Store the slider's value\r
- this.currentHandle.data("mouse").sliderValue = {\r
- x: Math.round(this.convertValue(x, "x")) || 0,\r
- y: Math.round(this.convertValue(y, "y")) || 0\r
- };\r
+ if(o.axis != "horizontal" && y !== undefined) {\r
+ if(o.stepping.y) y = Math.round(y / o.stepping.y) * o.stepping.y;\r
+ y = this.translateValue(y, "y");\r
+ y = this.translateLimits(y, "y");\r
+ y = this.translateRange(y, "y");\r
+ this.currentHandle.css({ top: y });\r
+ }\r
\r
- if (!noPropagation) {\r
- this.propagate('start', null);\r
- this.propagate('stop', null);\r
- this.propagate('change', null);\r
- this.propagate("slide", null);\r
- }\r
+ if (this.rangeElement)\r
+ this.updateRange();\r
+ \r
+ //Store the slider's value\r
+ this.currentHandle.data("mouse").sliderValue = {\r
+ x: Math.round(this.convertValue(x, "x")) || 0,\r
+ y: Math.round(this.convertValue(y, "y")) || 0\r
+ };\r
+ \r
+ if (!noPropagation) {\r
+ this.propagate('start', null);\r
+ this.propagate('stop', null);\r
+ this.propagate('change', null);\r
+ this.propagate("slide", null);\r
}\r
- });\r
+ }\r
+});\r
\r
- $.ui.slider.getter = "value";\r
- \r
- $.ui.slider.defaults = {\r
- handle: ".ui-slider-handle",\r
- distance: 1\r
- };\r
+$.ui.slider.getter = "value";\r
+\r
+$.ui.slider.defaults = {\r
+ handle: ".ui-slider-handle",\r
+ distance: 1\r
+};\r
\r
})(jQuery);\r
* Revision: $Id: ui.sortable.js 5433 2008-05-04 20:07:17Z joern.zaefferer $\r
*/\r
;(function($) {\r
+\r
+function contains(a, b) { \r
+ var safari2 = $.browser.safari && $.browser.version < 522; \r
+ if (a.contains && !safari2) { \r
+ return a.contains(b); \r
+ } \r
+ if (a.compareDocumentPosition) \r
+ return !!(a.compareDocumentPosition(b) & 16); \r
+ while (b = b.parentNode) \r
+ if (b == a) return true; \r
+ return false; \r
+};\r
+\r
+$.widget("ui.sortable", $.extend($.ui.mouse, {\r
+ init: function() {\r
+\r
+ var o = this.options;\r
+ this.containerCache = {};\r
+ this.element.addClass("ui-sortable");\r
\r
- function contains(a, b) { \r
- var safari2 = $.browser.safari && $.browser.version < 522; \r
- if (a.contains && !safari2) { \r
- return a.contains(b); \r
- } \r
- if (a.compareDocumentPosition) \r
- return !!(a.compareDocumentPosition(b) & 16); \r
- while (b = b.parentNode) \r
- if (b == a) return true; \r
- return false; \r
- };\r
- \r
- $.widget("ui.sortable", $.extend($.ui.mouse, {\r
- init: function() {\r
+ //Get the items\r
+ this.refresh();\r
\r
- var o = this.options;\r
- this.containerCache = {};\r
- this.element.addClass("ui-sortable");\r
+ //Let's determine if the items are floating\r
+ this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false;\r
\r
- //Get the items\r
- this.refresh();\r
- \r
- //Let's determine if the items are floating\r
- this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false;\r
- \r
- //Let's determine the parent's offset\r
- if(!(/(relative|absolute|fixed)/).test(this.element.css('position'))) this.element.css('position', 'relative');\r
- this.offset = this.element.offset();\r
- \r
- //Initialize mouse events for interaction\r
- this.mouseInit();\r
- \r
- },\r
- plugins: {},\r
- ui: function(inst) {\r
- return {\r
- helper: (inst || this)["helper"],\r
- placeholder: (inst || this)["placeholder"] || $([]),\r
- position: (inst || this)["position"],\r
- absolutePosition: (inst || this)["positionAbs"],\r
- options: this.options,\r
- element: this.element,\r
- item: (inst || this)["currentItem"],\r
- sender: inst ? inst.element : null\r
- }; \r
- },\r
- propagate: function(n,e,inst, noPropagation) {\r
- $.ui.plugin.call(this, n, [e, this.ui(inst)]);\r
- if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]);\r
- },\r
- serialize: function(o) {\r
- \r
- \r
- \r
- var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself\r
- var str = []; o = o || {};\r
- \r
- items.each(function() {\r
- var res = ($(this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));\r
- if(res) str.push((o.key || res[1])+'[]='+(o.key ? res[1] : res[2]));\r
- });\r
- \r
- return str.join('&');\r
- \r
- },\r
- toArray: function(attr) {\r
- var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself\r
- var ret = [];\r
-\r
- items.each(function() { ret.push($(this).attr(attr || 'id')); });\r
- return ret;\r
- },\r
- enable: function() {\r
- this.element.removeClass("ui-sortable-disabled");\r
- this.options.disabled = false;\r
- },\r
- disable: function() {\r
- this.element.addClass("ui-sortable-disabled");\r
- this.options.disabled = true;\r
- },\r
- /* Be careful with the following core functions */\r
- intersectsWith: function(item) {\r
- \r
- var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width,\r
+ //Let's determine the parent's offset\r
+ if(!(/(relative|absolute|fixed)/).test(this.element.css('position'))) this.element.css('position', 'relative');\r
+ this.offset = this.element.offset();\r
+\r
+ //Initialize mouse events for interaction\r
+ this.mouseInit();\r
+ \r
+ },\r
+ plugins: {},\r
+ ui: function(inst) {\r
+ return {\r
+ helper: (inst || this)["helper"],\r
+ placeholder: (inst || this)["placeholder"] || $([]),\r
+ position: (inst || this)["position"],\r
+ absolutePosition: (inst || this)["positionAbs"],\r
+ options: this.options,\r
+ element: this.element,\r
+ item: (inst || this)["currentItem"],\r
+ sender: inst ? inst.element : null\r
+ }; \r
+ },\r
+ propagate: function(n,e,inst, noPropagation) {\r
+ $.ui.plugin.call(this, n, [e, this.ui(inst)]);\r
+ if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]);\r
+ },\r
+ serialize: function(o) {\r
+ \r
+ \r
+ \r
+ var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself\r
+ var str = []; o = o || {};\r
+ \r
+ items.each(function() {\r
+ var res = ($(this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));\r
+ if(res) str.push((o.key || res[1])+'[]='+(o.key ? res[1] : res[2]));\r
+ });\r
+ \r
+ return str.join('&');\r
+ \r
+ },\r
+ toArray: function(attr) {\r
+ var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself\r
+ var ret = [];\r
+\r
+ items.each(function() { ret.push($(this).attr(attr || 'id')); });\r
+ return ret;\r
+ },\r
+ enable: function() {\r
+ this.element.removeClass("ui-sortable-disabled");\r
+ this.options.disabled = false;\r
+ },\r
+ disable: function() {\r
+ this.element.addClass("ui-sortable-disabled");\r
+ this.options.disabled = true;\r
+ },\r
+ /* Be careful with the following core functions */\r
+ intersectsWith: function(item) {\r
+ \r
+ var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width,\r
+ y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height;\r
+ var l = item.left, r = l + item.width, \r
+ t = item.top, b = t + item.height;\r
+\r
+ if(this.options.tolerance == "pointer") {\r
+ return (y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r);\r
+ } else {\r
+ \r
+ return (l < x1 + (this.helperProportions.width / 2) // Right Half\r
+ && x2 - (this.helperProportions.width / 2) < r // Left Half\r
+ && t < y1 + (this.helperProportions.height / 2) // Bottom Half\r
+ && y2 - (this.helperProportions.height / 2) < b ); // Top Half\r
+ \r
+ }\r
+ \r
+ },\r
+ intersectsWithEdge: function(item) { \r
+ var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width,\r
y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height;\r
- var l = item.left, r = l + item.width, \r
+ var l = item.left, r = l + item.width, \r
t = item.top, b = t + item.height;\r
\r
- if(this.options.tolerance == "pointer") {\r
- return (y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r);\r
- } else {\r
- \r
- return (l < x1 + (this.helperProportions.width / 2) // Right Half\r
- && x2 - (this.helperProportions.width / 2) < r // Left Half\r
- && t < y1 + (this.helperProportions.height / 2) // Bottom Half\r
- && y2 - (this.helperProportions.height / 2) < b ); // Top Half\r
+ if(this.options.tolerance == "pointer" || (this.options.tolerance == "guess" && this.currentItem[0]['offset'+(this.floating ? 'Width' : 'Height')] > item.item[0]['offset'+(this.floating ? 'Width' : 'Height')])) {\r
+\r
+ if(!(y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r)) return false;\r
\r
+ if(this.floating) {\r
+ if(x1 + this.offset.click.left > l && x1 + this.offset.click.left < l + item.width/2) return 2;\r
+ if(x1 + this.offset.click.left > l+item.width/2 && x1 + this.offset.click.left < r) return 1;\r
+ } else {\r
+ if(y1 + this.offset.click.top > t && y1 + this.offset.click.top < t + item.height/2) return 2;\r
+ if(y1 + this.offset.click.top > t+item.height/2 && y1 + this.offset.click.top < b) return 1;\r
}\r
- \r
- },\r
- intersectsWithEdge: function(item) { \r
- var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width,\r
- y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height;\r
- var l = item.left, r = l + item.width, \r
- t = item.top, b = t + item.height;\r
-\r
- if(this.options.tolerance == "pointer" || (this.options.tolerance == "guess" && this.currentItem[0]['offset'+(this.floating ? 'Width' : 'Height')] > item.item[0]['offset'+(this.floating ? 'Width' : 'Height')])) {\r
-\r
- if(!(y1 + this.offset.click.top > t && y1 + this.offset.click.top < b && x1 + this.offset.click.left > l && x1 + this.offset.click.left < r)) return false;\r
- \r
- if(this.floating) {\r
- if(x1 + this.offset.click.left > l && x1 + this.offset.click.left < l + item.width/2) return 2;\r
- if(x1 + this.offset.click.left > l+item.width/2 && x1 + this.offset.click.left < r) return 1;\r
- } else {\r
- if(y1 + this.offset.click.top > t && y1 + this.offset.click.top < t + item.height/2) return 2;\r
- if(y1 + this.offset.click.top > t+item.height/2 && y1 + this.offset.click.top < b) return 1;\r
- }\r
\r
+ } else {\r
+ \r
+ if (!(l < x1 + (this.helperProportions.width / 2) // Right Half\r
+ && x2 - (this.helperProportions.width / 2) < r // Left Half\r
+ && t < y1 + (this.helperProportions.height / 2) // Bottom Half\r
+ && y2 - (this.helperProportions.height / 2) < b )) return false; // Top Half\r
+ \r
+ if(this.floating) {\r
+ if(x2 > l && x1 < l) return 2; //Crosses left edge\r
+ if(x1 < r && x2 > r) return 1; //Crosses right edge\r
} else {\r
- \r
- if (!(l < x1 + (this.helperProportions.width / 2) // Right Half\r
- && x2 - (this.helperProportions.width / 2) < r // Left Half\r
- && t < y1 + (this.helperProportions.height / 2) // Bottom Half\r
- && y2 - (this.helperProportions.height / 2) < b )) return false; // Top Half\r
- \r
- if(this.floating) {\r
- if(x2 > l && x1 < l) return 2; //Crosses left edge\r
- if(x1 < r && x2 > r) return 1; //Crosses right edge\r
- } else {\r
- if(y2 > t && y1 < t) return 1; //Crosses top edge\r
- if(y1 < b && y2 > b) return 2; //Crosses bottom edge\r
- }\r
- \r
+ if(y2 > t && y1 < t) return 1; //Crosses top edge\r
+ if(y1 < b && y2 > b) return 2; //Crosses bottom edge\r
}\r
- \r
- return false;\r
- \r
- },\r
- refresh: function() {\r
- this.refreshItems();\r
- this.refreshPositions();\r
- },\r
- refreshItems: function() {\r
- \r
- this.items = [];\r
- this.containers = [this];\r
- var items = this.items;\r
- var queries = [$.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)];\r
- \r
- if(this.options.connectWith) {\r
- for (var i = this.options.connectWith.length - 1; i >= 0; i--){\r
- var cur = $(this.options.connectWith[i]);\r
- for (var j = cur.length - 1; j >= 0; j--){\r
- var inst = $.data(cur[j], 'sortable');\r
- if(inst && !inst.options.disabled) {\r
- queries.push($.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element));\r
- this.containers.push(inst);\r
- }\r
- };\r
+ \r
+ }\r
+ \r
+ return false;\r
+ \r
+ },\r
+ refresh: function() {\r
+ this.refreshItems();\r
+ this.refreshPositions();\r
+ },\r
+ refreshItems: function() {\r
+ \r
+ this.items = [];\r
+ this.containers = [this];\r
+ var items = this.items;\r
+ var queries = [$.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)];\r
+ \r
+ if(this.options.connectWith) {\r
+ for (var i = this.options.connectWith.length - 1; i >= 0; i--){\r
+ var cur = $(this.options.connectWith[i]);\r
+ for (var j = cur.length - 1; j >= 0; j--){\r
+ var inst = $.data(cur[j], 'sortable');\r
+ if(inst && !inst.options.disabled) {\r
+ queries.push($.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element));\r
+ this.containers.push(inst);\r
+ }\r
};\r
- }\r
+ };\r
+ }\r
\r
- for (var i = queries.length - 1; i >= 0; i--){\r
- queries[i].each(function() {\r
- $.data(this, 'sortable-item', true); // Data for target checking (mouse manager)\r
- items.push({\r
- item: $(this),\r
- width: 0, height: 0,\r
- left: 0, top: 0\r
- });\r
+ for (var i = queries.length - 1; i >= 0; i--){\r
+ queries[i].each(function() {\r
+ $.data(this, 'sortable-item', true); // Data for target checking (mouse manager)\r
+ items.push({\r
+ item: $(this),\r
+ width: 0, height: 0,\r
+ left: 0, top: 0\r
});\r
- };\r
+ });\r
+ };\r
\r
- },\r
- refreshPositions: function(fast) {\r
- for (var i = this.items.length - 1; i >= 0; i--){\r
- var t = this.items[i].item;\r
- if(!fast) this.items[i].width = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerWidth();\r
- if(!fast) this.items[i].height = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerHeight();\r
- var p = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).offset();\r
- this.items[i].left = p.left;\r
- this.items[i].top = p.top;\r
- };\r
- for (var i = this.containers.length - 1; i >= 0; i--){\r
- var p =this.containers[i].element.offset();\r
- this.containers[i].containerCache.left = p.left;\r
- this.containers[i].containerCache.top = p.top;\r
- this.containers[i].containerCache.width = this.containers[i].element.outerWidth();\r
- this.containers[i].containerCache.height = this.containers[i].element.outerHeight();\r
+ },\r
+ refreshPositions: function(fast) {\r
+ for (var i = this.items.length - 1; i >= 0; i--){\r
+ var t = this.items[i].item;\r
+ if(!fast) this.items[i].width = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerWidth();\r
+ if(!fast) this.items[i].height = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).outerHeight();\r
+ var p = (this.options.toleranceElement ? $(this.options.toleranceElement, t) : t).offset();\r
+ this.items[i].left = p.left;\r
+ this.items[i].top = p.top;\r
+ };\r
+ for (var i = this.containers.length - 1; i >= 0; i--){\r
+ var p =this.containers[i].element.offset();\r
+ this.containers[i].containerCache.left = p.left;\r
+ this.containers[i].containerCache.top = p.top;\r
+ this.containers[i].containerCache.width = this.containers[i].element.outerWidth();\r
+ this.containers[i].containerCache.height = this.containers[i].element.outerHeight();\r
+ };\r
+ },\r
+ destroy: function() {\r
+ this.element\r
+ .removeClass("ui-sortable ui-sortable-disabled")\r
+ .removeData("sortable")\r
+ .unbind(".sortable");\r
+ this.mouseDestroy();\r
+ \r
+ for ( var i = this.items.length - 1; i >= 0; i-- )\r
+ this.items[i].item.removeData("sortable-item");\r
+ },\r
+ createPlaceholder: function(that) {\r
+ \r
+ var self = that || this, o = self.options;\r
+\r
+ if(o.placeholder.constructor == String) {\r
+ var className = o.placeholder;\r
+ o.placeholder = {\r
+ element: function() {\r
+ return $('<div></div>').addClass(className)[0];\r
+ },\r
+ update: function(i, p) {\r
+ p.css(i.offset()).css({ width: i.outerWidth(), height: i.outerHeight() });\r
+ }\r
};\r
- },\r
- destroy: function() {\r
- this.element\r
- .removeClass("ui-sortable ui-sortable-disabled")\r
- .removeData("sortable")\r
- .unbind(".sortable");\r
- this.mouseDestroy();\r
- \r
- for ( var i = this.items.length - 1; i >= 0; i-- )\r
- this.items[i].item.removeData("sortable-item");\r
- },\r
- createPlaceholder: function(that) {\r
- \r
- var self = that || this, o = self.options;\r
- \r
- if(o.placeholder.constructor == String) {\r
- var className = o.placeholder;\r
- o.placeholder = {\r
- element: function() {\r
- return $('<div></div>').addClass(className)[0];\r
- },\r
- update: function(i, p) {\r
- p.css(i.offset()).css({ width: i.outerWidth(), height: i.outerHeight() });\r
- }\r
- };\r
- }\r
- \r
- self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem)).appendTo('body').css({ position: 'absolute' });\r
- o.placeholder.update.call(self.element, self.currentItem, self.placeholder);\r
- },\r
- contactContainers: function(e) {\r
- for (var i = this.containers.length - 1; i >= 0; i--){\r
+ }\r
+ \r
+ self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem)).appendTo('body').css({ position: 'absolute' });\r
+ o.placeholder.update.call(self.element, self.currentItem, self.placeholder);\r
+ },\r
+ contactContainers: function(e) {\r
+ for (var i = this.containers.length - 1; i >= 0; i--){\r
\r
- if(this.intersectsWith(this.containers[i].containerCache)) {\r
- if(!this.containers[i].containerCache.over) {\r
- \r
+ if(this.intersectsWith(this.containers[i].containerCache)) {\r
+ if(!this.containers[i].containerCache.over) {\r
+ \r
\r
- if(this.currentContainer != this.containers[i]) {\r
- \r
- //When entering a new container, we will find the item with the least distance and append our item near it\r
- var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[i].floating ? 'left' : 'top'];\r
- for (var j = this.items.length - 1; j >= 0; j--) {\r
- if(!contains(this.containers[i].element[0], this.items[j].item[0])) continue;\r
- var cur = this.items[j][this.containers[i].floating ? 'left' : 'top'];\r
- if(Math.abs(cur - base) < dist) {\r
- dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];\r
- }\r
- }\r
- \r
- if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled\r
- continue;\r
- \r
- //We also need to exchange the placeholder\r
- if(this.placeholder) this.placeholder.remove();\r
- if(this.containers[i].options.placeholder) {\r
- this.containers[i].createPlaceholder(this);\r
- } else {\r
- this.placeholder = null;;\r
+ if(this.currentContainer != this.containers[i]) {\r
+ \r
+ //When entering a new container, we will find the item with the least distance and append our item near it\r
+ var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[i].floating ? 'left' : 'top'];\r
+ for (var j = this.items.length - 1; j >= 0; j--) {\r
+ if(!contains(this.containers[i].element[0], this.items[j].item[0])) continue;\r
+ var cur = this.items[j][this.containers[i].floating ? 'left' : 'top'];\r
+ if(Math.abs(cur - base) < dist) {\r
+ dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];\r
}\r
- \r
- \r
- itemWithLeastDistance ? this.rearrange(e, itemWithLeastDistance) : this.rearrange(e, null, this.containers[i].element);\r
- this.propagate("change", e); //Call plugins and callbacks\r
- this.containers[i].propagate("change", e, this); //Call plugins and callbacks\r
- this.currentContainer = this.containers[i];\r
-\r
}\r
\r
- this.containers[i].propagate("over", e, this);\r
- this.containers[i].containerCache.over = 1;\r
- }\r
- } else {\r
- if(this.containers[i].containerCache.over) {\r
- this.containers[i].propagate("out", e, this);\r
- this.containers[i].containerCache.over = 0;\r
+ if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled\r
+ continue;\r
+ \r
+ //We also need to exchange the placeholder\r
+ if(this.placeholder) this.placeholder.remove();\r
+ if(this.containers[i].options.placeholder) {\r
+ this.containers[i].createPlaceholder(this);\r
+ } else {\r
+ this.placeholder = null;;\r
+ }\r
+ \r
+ \r
+ itemWithLeastDistance ? this.rearrange(e, itemWithLeastDistance) : this.rearrange(e, null, this.containers[i].element);\r
+ this.propagate("change", e); //Call plugins and callbacks\r
+ this.containers[i].propagate("change", e, this); //Call plugins and callbacks\r
+ this.currentContainer = this.containers[i];\r
+\r
}\r
+ \r
+ this.containers[i].propagate("over", e, this);\r
+ this.containers[i].containerCache.over = 1;\r
}\r
- \r
- }; \r
- },\r
- mouseStart: function(e, overrideHandle, noActivation) {\r
- \r
- var o = this.options;\r
- this.currentContainer = this;\r
- \r
- if(this.options.disabled || this.options.type == 'static') return false;\r
-\r
- //Find out if the clicked node (or one of its parents) is a actual item in this.items\r
- var currentItem = null, nodes = $(e.target).parents().each(function() { \r
- if($.data(this, 'sortable-item')) {\r
- currentItem = $(this);\r
- return false;\r
+ } else {\r
+ if(this.containers[i].containerCache.over) {\r
+ this.containers[i].propagate("out", e, this);\r
+ this.containers[i].containerCache.over = 0;\r
}\r
- });\r
- if($.data(e.target, 'sortable-item')) currentItem = $(e.target);\r
+ }\r
+ \r
+ }; \r
+ },\r
+ mouseStart: function(e, overrideHandle, noActivation) {\r
+ \r
+ var o = this.options;\r
+ this.currentContainer = this;\r
\r
- if(!currentItem) return false;\r
- if(this.options.handle && !overrideHandle) {\r
- var validHandle = false;\r
- $(this.options.handle, currentItem).each(function() { if(this == e.target) validHandle = true; });\r
- if(!validHandle) return false;\r
+ if(this.options.disabled || this.options.type == 'static') return false;\r
+\r
+ //Find out if the clicked node (or one of its parents) is a actual item in this.items\r
+ var currentItem = null, nodes = $(e.target).parents().each(function() { \r
+ if($.data(this, 'sortable-item')) {\r
+ currentItem = $(this);\r
+ return false;\r
}\r
- \r
- this.currentItem = currentItem;\r
+ });\r
+ if($.data(e.target, 'sortable-item')) currentItem = $(e.target);\r
+ \r
+ if(!currentItem) return false;\r
+ if(this.options.handle && !overrideHandle) {\r
+ var validHandle = false;\r
+ $(this.options.handle, currentItem).each(function() { if(this == e.target) validHandle = true; });\r
+ if(!validHandle) return false;\r
+ }\r
+ \r
+ this.currentItem = currentItem;\r
\r
- this.refresh();\r
+ this.refresh();\r
\r
- //Create and append the visible helper \r
- this.helper = typeof o.helper == 'function' ? $(o.helper.apply(this.element[0], [e, this.currentItem])) : this.currentItem.clone();\r
- if(!this.helper.parents('body').length) this.helper.appendTo((o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)); //Add the helper to the DOM if that didn't happen already\r
- this.helper.css({ position: 'absolute', clear: 'both' }).addClass('ui-sortable-helper'); //Position it absolutely and add a helper class\r
+ //Create and append the visible helper \r
+ this.helper = typeof o.helper == 'function' ? $(o.helper.apply(this.element[0], [e, this.currentItem])) : this.currentItem.clone();\r
+ if(!this.helper.parents('body').length) this.helper.appendTo((o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)); //Add the helper to the DOM if that didn't happen already\r
+ this.helper.css({ position: 'absolute', clear: 'both' }).addClass('ui-sortable-helper'); //Position it absolutely and add a helper class\r
\r
- /*\r
- * - Position generation -\r
- * This block generates everything position related - it's the core of draggables.\r
- */\r
+ /*\r
+ * - Position generation -\r
+ * This block generates everything position related - it's the core of draggables.\r
+ */\r
\r
- this.margins = { //Cache the margins\r
- left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),\r
- top: (parseInt(this.currentItem.css("marginTop"),10) || 0)\r
- }; \r
+ this.margins = { //Cache the margins\r
+ left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),\r
+ top: (parseInt(this.currentItem.css("marginTop"),10) || 0)\r
+ }; \r
+ \r
+ this.offset = this.currentItem.offset(); //The element's absolute position on the page\r
+ this.offset = { //Substract the margins from the element's absolute offset\r
+ top: this.offset.top - this.margins.top,\r
+ left: this.offset.left - this.margins.left\r
+ };\r
\r
- this.offset = this.currentItem.offset(); //The element's absolute position on the page\r
- this.offset = { //Substract the margins from the element's absolute offset\r
- top: this.offset.top - this.margins.top,\r
- left: this.offset.left - this.margins.left\r
- };\r
- \r
- this.offset.click = { //Where the click happened, relative to the element\r
- left: e.pageX - this.offset.left,\r
- top: e.pageY - this.offset.top\r
- };\r
- \r
- this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position\r
+ this.offset.click = { //Where the click happened, relative to the element\r
+ left: e.pageX - this.offset.left,\r
+ top: e.pageY - this.offset.top\r
+ };\r
+ \r
+ this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position\r
\r
- this.offset.parent = { //Store its position plus border\r
- top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),\r
- left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)\r
- };\r
+ this.offset.parent = { //Store its position plus border\r
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),\r
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)\r
+ };\r
+ \r
+ this.originalPosition = this.generatePosition(e); //Generate the original position\r
+ this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size\r
\r
- this.originalPosition = this.generatePosition(e); //Generate the original position\r
- this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size\r
- \r
- if(o.cursorAt) {\r
- if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left;\r
- if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right;\r
- if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top;\r
- if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom;\r
- }\r
+ if(o.cursorAt) {\r
+ if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left;\r
+ if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right;\r
+ if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top;\r
+ if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom;\r
+ }\r
\r
- this.domPosition = this.currentItem.prev()[0]; //Cache the former DOM position\r
+ this.domPosition = this.currentItem.prev()[0]; //Cache the former DOM position\r
\r
- /*\r
- * - Position constraining -\r
- * Here we prepare position constraining like grid and containment.\r
- */ \r
- \r
- if(o.containment) {\r
- if(o.containment == 'parent') o.containment = this.helper[0].parentNode;\r
- if(o.containment == 'document') this.containment = [0,0,$(document).width(), ($(document).height() || document.body.parentNode.scrollHeight)];\r
- if(!(/^(document|window|parent)$/).test(o.containment)) {\r
- var ce = $(o.containment)[0];\r
- var co = $(o.containment).offset();\r
- \r
- this.containment = [\r
- co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left,\r
- co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top,\r
- co.left+Math.max(ce.scrollWidth,ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0),\r
- co.top+Math.max(ce.scrollHeight,ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0)\r
- ];\r
- }\r
- }\r
- \r
- //If o.placeholder is used, create a new element at the given position with the class\r
- if(o.placeholder) this.createPlaceholder();\r
- \r
- //Call plugins and callbacks\r
- this.propagate("start", e);\r
- this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size\r
-\r
- if(this.options.placeholder != 'clone') this.currentItem.css('visibility', 'hidden'); //Set the original element visibility to hidden to still fill out the white space\r
- \r
- if(!noActivation) {\r
- for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i].propagate("activate", e, this); } //Post 'activate' events to possible containers\r
- }\r
- \r
- //Prepare possible droppables\r
- if($.ui.ddmanager) $.ui.ddmanager.current = this;\r
- if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);\r
-\r
- this.dragging = true;\r
-\r
- this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position\r
- return true;\r
-\r
-\r
- },\r
- convertPositionTo: function(d, pos) {\r
- if(!pos) pos = this.position;\r
- var mod = d == "absolute" ? 1 : -1;\r
- return {\r
- top: (\r
- pos.top // the calculated relative position\r
- + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)\r
- - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) * mod // The offsetParent's scroll position\r
- + this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)\r
- ),\r
- left: (\r
- pos.left // the calculated relative position\r
- + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)\r
- - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position\r
- + this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)\r
- )\r
- };\r
- },\r
- generatePosition: function(e) {\r
- \r
- var o = this.options;\r
- var position = {\r
- top: (\r
- e.pageY // The absolute mouse position\r
- - this.offset.click.top // Click offset (relative to the element)\r
- - this.offset.parent.top // The offsetParent's offset without borders (offset + border)\r
- + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed\r
- ),\r
- left: (\r
- e.pageX // The absolute mouse position\r
- - this.offset.click.left // Click offset (relative to the element)\r
- - this.offset.parent.left // The offsetParent's offset without borders (offset + border)\r
- + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed\r
- )\r
- };\r
- \r
- if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options\r
- \r
- /*\r
- * - Position constraining -\r
- * Constrain the position to a mix of grid, containment.\r
- */\r
- if(this.containment) {\r
- if(position.left < this.containment[0]) position.left = this.containment[0];\r
- if(position.top < this.containment[1]) position.top = this.containment[1];\r
- if(position.left > this.containment[2]) position.left = this.containment[2];\r
- if(position.top > this.containment[3]) position.top = this.containment[3];\r
- }\r
- \r
- if(o.grid) {\r
- var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];\r
- position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;\r
+ /*\r
+ * - Position constraining -\r
+ * Here we prepare position constraining like grid and containment.\r
+ */ \r
+ \r
+ if(o.containment) {\r
+ if(o.containment == 'parent') o.containment = this.helper[0].parentNode;\r
+ if(o.containment == 'document') this.containment = [0,0,$(document).width(), ($(document).height() || document.body.parentNode.scrollHeight)];\r
+ if(!(/^(document|window|parent)$/).test(o.containment)) {\r
+ var ce = $(o.containment)[0];\r
+ var co = $(o.containment).offset();\r
\r
- var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];\r
- position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;\r
+ this.containment = [\r
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left,\r
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top,\r
+ co.left+Math.max(ce.scrollWidth,ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0),\r
+ co.top+Math.max(ce.scrollHeight,ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0)\r
+ ];\r
}\r
- \r
- return position;\r
- },\r
- mouseDrag: function(e) {\r
+ }\r
+ \r
+ //If o.placeholder is used, create a new element at the given position with the class\r
+ if(o.placeholder) this.createPlaceholder();\r
+ \r
+ //Call plugins and callbacks\r
+ this.propagate("start", e);\r
+ this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size\r
\r
+ if(this.options.placeholder != 'clone') this.currentItem.css('visibility', 'hidden'); //Set the original element visibility to hidden to still fill out the white space\r
+ \r
+ if(!noActivation) {\r
+ for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i].propagate("activate", e, this); } //Post 'activate' events to possible containers\r
+ }\r
+ \r
+ //Prepare possible droppables\r
+ if($.ui.ddmanager) $.ui.ddmanager.current = this;\r
+ if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);\r
\r
- //Compute the helpers position\r
- this.position = this.generatePosition(e);\r
- this.positionAbs = this.convertPositionTo("absolute");\r
+ this.dragging = true;\r
\r
- //Rearrange\r
- for (var i = this.items.length - 1; i >= 0; i--) {\r
- var intersection = this.intersectsWithEdge(this.items[i]);\r
- if(!intersection) continue;\r
- \r
- if(this.items[i].item[0] != this.currentItem[0] //cannot intersect with itself\r
- && this.currentItem[intersection == 1 ? "next" : "prev"]()[0] != this.items[i].item[0] //no useless actions that have been done before\r
- && !contains(this.currentItem[0], this.items[i].item[0]) //no action if the item moved is the parent of the item checked\r
- && (this.options.type == 'semi-dynamic' ? !contains(this.element[0], this.items[i].item[0]) : true)\r
- ) {\r
- \r
- this.direction = intersection == 1 ? "down" : "up";\r
- this.rearrange(e, this.items[i]);\r
- this.propagate("change", e); //Call plugins and callbacks\r
- break;\r
- }\r
- }\r
- \r
- //Post events to containers\r
- this.contactContainers(e);\r
- \r
- //Call plugins and callbacks\r
- this.propagate("sort", e);\r
+ this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position\r
+ return true;\r
\r
- if(!this.options.axis || this.options.axis == "x") this.helper[0].style.left = this.position.left+'px';\r
- if(!this.options.axis || this.options.axis == "y") this.helper[0].style.top = this.position.top+'px';\r
- \r
- //Interconnect with droppables\r
- if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);\r
\r
- return false;\r
+ },\r
+ convertPositionTo: function(d, pos) {\r
+ if(!pos) pos = this.position;\r
+ var mod = d == "absolute" ? 1 : -1;\r
+ return {\r
+ top: (\r
+ pos.top // the calculated relative position\r
+ + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)\r
+ - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) * mod // The offsetParent's scroll position\r
+ + this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)\r
+ ),\r
+ left: (\r
+ pos.left // the calculated relative position\r
+ + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)\r
+ - (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position\r
+ + this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)\r
+ )\r
+ };\r
+ },\r
+ generatePosition: function(e) {\r
+ \r
+ var o = this.options;\r
+ var position = {\r
+ top: (\r
+ e.pageY // The absolute mouse position\r
+ - this.offset.click.top // Click offset (relative to the element)\r
+ - this.offset.parent.top // The offsetParent's offset without borders (offset + border)\r
+ + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed\r
+ ),\r
+ left: (\r
+ e.pageX // The absolute mouse position\r
+ - this.offset.click.left // Click offset (relative to the element)\r
+ - this.offset.parent.left // The offsetParent's offset without borders (offset + border)\r
+ + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed\r
+ )\r
+ };\r
+ \r
+ if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options\r
+ \r
+ /*\r
+ * - Position constraining -\r
+ * Constrain the position to a mix of grid, containment.\r
+ */\r
+ if(this.containment) {\r
+ if(position.left < this.containment[0]) position.left = this.containment[0];\r
+ if(position.top < this.containment[1]) position.top = this.containment[1];\r
+ if(position.left > this.containment[2]) position.left = this.containment[2];\r
+ if(position.top > this.containment[3]) position.top = this.containment[3];\r
+ }\r
+ \r
+ if(o.grid) {\r
+ var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];\r
+ position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;\r
\r
- },\r
- mouseStop: function(e, noPropagation) {\r
+ var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];\r
+ position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;\r
+ }\r
+ \r
+ return position;\r
+ },\r
+ mouseDrag: function(e) {\r
+\r
+\r
+ //Compute the helpers position\r
+ this.position = this.generatePosition(e);\r
+ this.positionAbs = this.convertPositionTo("absolute");\r
\r
- //If we are using droppables, inform the manager about the drop\r
- if ($.ui.ddmanager && !this.options.dropBehaviour)\r
- $.ui.ddmanager.drop(this, e);\r
+ //Rearrange\r
+ for (var i = this.items.length - 1; i >= 0; i--) {\r
+ var intersection = this.intersectsWithEdge(this.items[i]);\r
+ if(!intersection) continue;\r
+ \r
+ if(this.items[i].item[0] != this.currentItem[0] //cannot intersect with itself\r
+ && this.currentItem[intersection == 1 ? "next" : "prev"]()[0] != this.items[i].item[0] //no useless actions that have been done before\r
+ && !contains(this.currentItem[0], this.items[i].item[0]) //no action if the item moved is the parent of the item checked\r
+ && (this.options.type == 'semi-dynamic' ? !contains(this.element[0], this.items[i].item[0]) : true)\r
+ ) {\r
\r
- if(this.options.revert) {\r
- var self = this;\r
- var cur = self.currentItem.offset();\r
-\r
- //Also animate the placeholder if we have one\r
- if(self.placeholder) self.placeholder.animate({ opacity: 'hide' }, (parseInt(this.options.revert, 10) || 500)-50);\r
-\r
- $(this.helper).animate({\r
- left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),\r
- top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)\r
- }, parseInt(this.options.revert, 10) || 500, function() {\r
- self.propagate("stop", e, null, noPropagation);\r
- self.clear(e);\r
- });\r
- } else {\r
- this.propagate("stop", e, null, noPropagation);\r
- this.clear(e, noPropagation);\r
+ this.direction = intersection == 1 ? "down" : "up";\r
+ this.rearrange(e, this.items[i]);\r
+ this.propagate("change", e); //Call plugins and callbacks\r
+ break;\r
}\r
+ }\r
+ \r
+ //Post events to containers\r
+ this.contactContainers(e);\r
+ \r
+ //Call plugins and callbacks\r
+ this.propagate("sort", e);\r
\r
- return false;\r
- \r
- },\r
- clear: function(e, noPropagation) {\r
- \r
- if(this.domPosition != this.currentItem.prev()[0]) this.propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed\r
- if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element\r
- this.propagate("remove", e, null, noPropagation);\r
- for (var i = this.containers.length - 1; i >= 0; i--){\r
- if(contains(this.containers[i].element[0], this.currentItem[0])) {\r
- this.containers[i].propagate("update", e, this, noPropagation);\r
- this.containers[i].propagate("receive", e, this, noPropagation);\r
- }\r
- };\r
- };\r
+ if(!this.options.axis || this.options.axis == "x") this.helper[0].style.left = this.position.left+'px';\r
+ if(!this.options.axis || this.options.axis == "y") this.helper[0].style.top = this.position.top+'px';\r
+ \r
+ //Interconnect with droppables\r
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);\r
+\r
+ return false;\r
+ \r
+ },\r
+ mouseStop: function(e, noPropagation) {\r
+\r
+ //If we are using droppables, inform the manager about the drop\r
+ if ($.ui.ddmanager && !this.options.dropBehaviour)\r
+ $.ui.ddmanager.drop(this, e);\r
\r
- //Post events to containers\r
+ if(this.options.revert) {\r
+ var self = this;\r
+ var cur = self.currentItem.offset();\r
+\r
+ //Also animate the placeholder if we have one\r
+ if(self.placeholder) self.placeholder.animate({ opacity: 'hide' }, (parseInt(this.options.revert, 10) || 500)-50);\r
+\r
+ $(this.helper).animate({\r
+ left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),\r
+ top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)\r
+ }, parseInt(this.options.revert, 10) || 500, function() {\r
+ self.propagate("stop", e, null, noPropagation);\r
+ self.clear(e);\r
+ });\r
+ } else {\r
+ this.propagate("stop", e, null, noPropagation);\r
+ this.clear(e, noPropagation);\r
+ }\r
+\r
+ return false;\r
+ \r
+ },\r
+ clear: function(e, noPropagation) {\r
+ \r
+ if(this.domPosition != this.currentItem.prev()[0]) this.propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed\r
+ if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element\r
+ this.propagate("remove", e, null, noPropagation);\r
for (var i = this.containers.length - 1; i >= 0; i--){\r
- this.containers[i].propagate("deactivate", e, this, noPropagation);\r
- if(this.containers[i].containerCache.over) {\r
- this.containers[i].propagate("out", e, this);\r
- this.containers[i].containerCache.over = 0;\r
+ if(contains(this.containers[i].element[0], this.currentItem[0])) {\r
+ this.containers[i].propagate("update", e, this, noPropagation);\r
+ this.containers[i].propagate("receive", e, this, noPropagation);\r
}\r
+ };\r
+ };\r
+ \r
+ //Post events to containers\r
+ for (var i = this.containers.length - 1; i >= 0; i--){\r
+ this.containers[i].propagate("deactivate", e, this, noPropagation);\r
+ if(this.containers[i].containerCache.over) {\r
+ this.containers[i].propagate("out", e, this);\r
+ this.containers[i].containerCache.over = 0;\r
}\r
- \r
- this.dragging = false;\r
- if(this.cancelHelperRemoval) return false;\r
- $(this.currentItem).css('visibility', '');\r
- if(this.placeholder) this.placeholder.remove();\r
- this.helper.remove();\r
- \r
- return true;\r
- \r
- },\r
- rearrange: function(e, i, a) {\r
- a ? a.append(this.currentItem) : i.item[this.direction == 'down' ? 'before' : 'after'](this.currentItem);\r
- this.refreshPositions(true); //Precompute after each DOM insertion, NOT on mousemove\r
- if(this.options.placeholder) this.options.placeholder.update.call(this.element, this.currentItem, this.placeholder);\r
- }\r
- }));\r
- \r
- $.extend($.ui.sortable, {\r
- getter: "serialize toArray",\r
- defaults: {\r
- tolerance: "guess",\r
- distance: 0,\r
- delay: 0,\r
- cancel: ":input,button",\r
- items: '> *',\r
- zIndex: 1000,\r
- dropOnEmpty: true,\r
- appendTo: "parent"\r
}\r
- });\r
+ \r
+ this.dragging = false;\r
+ if(this.cancelHelperRemoval) return false;\r
+ $(this.currentItem).css('visibility', '');\r
+ if(this.placeholder) this.placeholder.remove();\r
+ this.helper.remove();\r
+ \r
+ return true;\r
+ \r
+ },\r
+ rearrange: function(e, i, a) {\r
+ a ? a.append(this.currentItem) : i.item[this.direction == 'down' ? 'before' : 'after'](this.currentItem);\r
+ this.refreshPositions(true); //Precompute after each DOM insertion, NOT on mousemove\r
+ if(this.options.placeholder) this.options.placeholder.update.call(this.element, this.currentItem, this.placeholder);\r
+ }\r
+}));\r
+\r
+$.extend($.ui.sortable, {\r
+ getter: "serialize toArray",\r
+ defaults: {\r
+ tolerance: "guess",\r
+ distance: 0,\r
+ delay: 0,\r
+ cancel: ":input,button",\r
+ items: '> *',\r
+ zIndex: 1000,\r
+ dropOnEmpty: true,\r
+ appendTo: "parent"\r
+ }\r
+});\r
\r
- \r
/*\r
* Sortable Extensions\r
*/\r
}\r
});\r
\r
-\r
})(jQuery);\r
* Revision: $Id: ui.tabs.js 5641 2008-05-20 02:53:23Z scott.gonzalez $\r
*/\r
;(function($) {\r
- \r
- $.widget("ui.tabs", {\r
- init: function() {\r
- this.options.event += '.tabs'; // namespace event\r
- \r
- // create tabs\r
- this.tabify(true);\r
- },\r
- setData: function(key, value) {\r
- if ((/^selected/).test(key))\r
- this.select(value);\r
- else {\r
- this.options[key] = value;\r
- this.tabify();\r
- }\r
- },\r
- length: function() {\r
- return this.$tabs.length;\r
- },\r
- tabId: function(a) {\r
- return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '')\r
- || this.options.idPrefix + $.data(a);\r
- },\r
- ui: function(tab, panel) {\r
- return {\r
- instance: this,\r
- options: this.options,\r
- tab: tab,\r
- panel: panel\r
- };\r
- },\r
- tabify: function(init) {\r
-\r
- this.$lis = $('li:has(a[href])', this.element);\r
- this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });\r
- this.$panels = $([]);\r
-\r
- var self = this, o = this.options;\r
-\r
- this.$tabs.each(function(i, a) {\r
- // inline tab\r
- if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash\r
- self.$panels = self.$panels.add(a.hash);\r
- // remote tab\r
- else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"\r
- $.data(a, 'href.tabs', a.href); // required for restore on destroy\r
- $.data(a, 'load.tabs', a.href); // mutable\r
- var id = self.tabId(a);\r
- a.href = '#' + id;\r
- var $panel = $('#' + id);\r
- if (!$panel.length) {\r
- $panel = $(o.panelTemplate).attr('id', id).addClass(o.panelClass)\r
- .insertAfter( self.$panels[i - 1] || self.element );\r
- $panel.data('destroy.tabs', true);\r
- }\r
- self.$panels = self.$panels.add( $panel );\r
+\r
+$.widget("ui.tabs", {\r
+ init: function() {\r
+ this.options.event += '.tabs'; // namespace event\r
+ \r
+ // create tabs\r
+ this.tabify(true);\r
+ },\r
+ setData: function(key, value) {\r
+ if ((/^selected/).test(key))\r
+ this.select(value);\r
+ else {\r
+ this.options[key] = value;\r
+ this.tabify();\r
+ }\r
+ },\r
+ length: function() {\r
+ return this.$tabs.length;\r
+ },\r
+ tabId: function(a) {\r
+ return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '')\r
+ || this.options.idPrefix + $.data(a);\r
+ },\r
+ ui: function(tab, panel) {\r
+ return {\r
+ instance: this,\r
+ options: this.options,\r
+ tab: tab,\r
+ panel: panel\r
+ };\r
+ },\r
+ tabify: function(init) {\r
+\r
+ this.$lis = $('li:has(a[href])', this.element);\r
+ this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });\r
+ this.$panels = $([]);\r
+\r
+ var self = this, o = this.options;\r
+\r
+ this.$tabs.each(function(i, a) {\r
+ // inline tab\r
+ if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash\r
+ self.$panels = self.$panels.add(a.hash);\r
+ // remote tab\r
+ else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"\r
+ $.data(a, 'href.tabs', a.href); // required for restore on destroy\r
+ $.data(a, 'load.tabs', a.href); // mutable\r
+ var id = self.tabId(a);\r
+ a.href = '#' + id;\r
+ var $panel = $('#' + id);\r
+ if (!$panel.length) {\r
+ $panel = $(o.panelTemplate).attr('id', id).addClass(o.panelClass)\r
+ .insertAfter( self.$panels[i - 1] || self.element );\r
+ $panel.data('destroy.tabs', true);\r
}\r
- // invalid tab href\r
- else\r
- o.disabled.push(i + 1);\r
- });\r
+ self.$panels = self.$panels.add( $panel );\r
+ }\r
+ // invalid tab href\r
+ else\r
+ o.disabled.push(i + 1);\r
+ });\r
\r
- if (init) {\r
+ if (init) {\r
\r
- // attach necessary classes for styling if not present\r
- this.element.addClass(o.navClass);\r
- this.$panels.each(function() {\r
- var $this = $(this);\r
- $this.addClass(o.panelClass);\r
- });\r
+ // attach necessary classes for styling if not present\r
+ this.element.addClass(o.navClass);\r
+ this.$panels.each(function() {\r
+ var $this = $(this);\r
+ $this.addClass(o.panelClass);\r
+ });\r
\r
- // Selected tab\r
- // use "selected" option or try to retrieve:\r
- // 1. from fragment identifier in url\r
- // 2. from cookie\r
- // 3. from selected class attribute on <li>\r
- if (o.selected === undefined) {\r
- if (location.hash) {\r
- this.$tabs.each(function(i, a) {\r
- if (a.hash == location.hash) {\r
- o.selected = i;\r
- // prevent page scroll to fragment\r
- if ($.browser.msie || $.browser.opera) { // && !o.remote\r
- var $toShow = $(location.hash), toShowId = $toShow.attr('id');\r
- $toShow.attr('id', '');\r
- setTimeout(function() {\r
- $toShow.attr('id', toShowId); // restore id\r
- }, 500);\r
- }\r
- scrollTo(0, 0);\r
- return false; // break\r
+ // Selected tab\r
+ // use "selected" option or try to retrieve:\r
+ // 1. from fragment identifier in url\r
+ // 2. from cookie\r
+ // 3. from selected class attribute on <li>\r
+ if (o.selected === undefined) {\r
+ if (location.hash) {\r
+ this.$tabs.each(function(i, a) {\r
+ if (a.hash == location.hash) {\r
+ o.selected = i;\r
+ // prevent page scroll to fragment\r
+ if ($.browser.msie || $.browser.opera) { // && !o.remote\r
+ var $toShow = $(location.hash), toShowId = $toShow.attr('id');\r
+ $toShow.attr('id', '');\r
+ setTimeout(function() {\r
+ $toShow.attr('id', toShowId); // restore id\r
+ }, 500);\r
}\r
- });\r
- }\r
- else if (o.cookie) {\r
- var index = parseInt($.cookie('ui-tabs' + $.data(self.element)),10);\r
- if (index && self.$tabs[index])\r
- o.selected = index;\r
- }\r
- else if (self.$lis.filter('.' + o.selectedClass).length)\r
- o.selected = self.$lis.index( self.$lis.filter('.' + o.selectedClass)[0] );\r
+ scrollTo(0, 0);\r
+ return false; // break\r
+ }\r
+ });\r
}\r
- o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default\r
-\r
- // Take disabling tabs via class attribute from HTML\r
- // into account and update option properly.\r
- // A selected tab cannot become disabled.\r
- o.disabled = $.unique(o.disabled.concat(\r
- $.map(this.$lis.filter('.' + o.disabledClass),\r
- function(n, i) { return self.$lis.index(n); } )\r
- )).sort();\r
- if ($.inArray(o.selected, o.disabled) != -1)\r
- o.disabled.splice($.inArray(o.selected, o.disabled), 1);\r
- \r
- // highlight selected tab\r
- this.$panels.addClass(o.hideClass);\r
- this.$lis.removeClass(o.selectedClass);\r
- if (o.selected !== null) {\r
- this.$panels.eq(o.selected).show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before\r
- this.$lis.eq(o.selected).addClass(o.selectedClass);\r
- \r
- // seems to be expected behavior that the show callback is fired\r
- var onShow = function() {\r
- $(self.element).triggerHandler('tabsshow',\r
- [self.ui(self.$tabs[o.selected], self.$panels[o.selected])], o.show);\r
- }; \r
-\r
- // load if remote tab\r
- if ($.data(this.$tabs[o.selected], 'load.tabs'))\r
- this.load(o.selected, onShow);\r
- // just trigger show event\r
- else\r
- onShow();\r
- \r
+ else if (o.cookie) {\r
+ var index = parseInt($.cookie('ui-tabs' + $.data(self.element)),10);\r
+ if (index && self.$tabs[index])\r
+ o.selected = index;\r
}\r
+ else if (self.$lis.filter('.' + o.selectedClass).length)\r
+ o.selected = self.$lis.index( self.$lis.filter('.' + o.selectedClass)[0] );\r
+ }\r
+ o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default\r
+\r
+ // Take disabling tabs via class attribute from HTML\r
+ // into account and update option properly.\r
+ // A selected tab cannot become disabled.\r
+ o.disabled = $.unique(o.disabled.concat(\r
+ $.map(this.$lis.filter('.' + o.disabledClass),\r
+ function(n, i) { return self.$lis.index(n); } )\r
+ )).sort();\r
+ if ($.inArray(o.selected, o.disabled) != -1)\r
+ o.disabled.splice($.inArray(o.selected, o.disabled), 1);\r
+ \r
+ // highlight selected tab\r
+ this.$panels.addClass(o.hideClass);\r
+ this.$lis.removeClass(o.selectedClass);\r
+ if (o.selected !== null) {\r
+ this.$panels.eq(o.selected).show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before\r
+ this.$lis.eq(o.selected).addClass(o.selectedClass);\r
\r
- // clean up to avoid memory leaks in certain versions of IE 6\r
- $(window).bind('unload', function() {\r
- self.$tabs.unbind('.tabs');\r
- self.$lis = self.$tabs = self.$panels = null;\r
- });\r
+ // seems to be expected behavior that the show callback is fired\r
+ var onShow = function() {\r
+ $(self.element).triggerHandler('tabsshow',\r
+ [self.ui(self.$tabs[o.selected], self.$panels[o.selected])], o.show);\r
+ }; \r
\r
+ // load if remote tab\r
+ if ($.data(this.$tabs[o.selected], 'load.tabs'))\r
+ this.load(o.selected, onShow);\r
+ // just trigger show event\r
+ else\r
+ onShow();\r
+ \r
}\r
+ \r
+ // clean up to avoid memory leaks in certain versions of IE 6\r
+ $(window).bind('unload', function() {\r
+ self.$tabs.unbind('.tabs');\r
+ self.$lis = self.$tabs = self.$panels = null;\r
+ });\r
\r
- // disable tabs\r
- for (var i = 0, li; li = this.$lis[i]; i++)\r
- $(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass);\r
+ }\r
\r
- // reset cache if switching from cached to not cached\r
- if (o.cache === false)\r
- this.$tabs.removeData('cache.tabs');\r
- \r
- // set up animations\r
- var hideFx, showFx, baseFx = { 'min-width': 0, duration: 1 }, baseDuration = 'normal';\r
- if (o.fx && o.fx.constructor == Array)\r
- hideFx = o.fx[0] || baseFx, showFx = o.fx[1] || baseFx;\r
- else\r
- hideFx = showFx = o.fx || baseFx;\r
-\r
- // reset some styles to maintain print style sheets etc.\r
- var resetCSS = { display: '', overflow: '', height: '' };\r
- if (!$.browser.msie) // not in IE to prevent ClearType font issue\r
- resetCSS.opacity = '';\r
-\r
- // Hide a tab, animation prevents browser scrolling to fragment,\r
- // $show is optional.\r
- function hideTab(clicked, $hide, $show) {\r
- $hide.animate(hideFx, hideFx.duration || baseDuration, function() { //\r
- $hide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.\r
- if ($.browser.msie && hideFx.opacity)\r
- $hide[0].style.filter = '';\r
- if ($show)\r
- showTab(clicked, $show, $hide);\r
- });\r
- }\r
+ // disable tabs\r
+ for (var i = 0, li; li = this.$lis[i]; i++)\r
+ $(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass);\r
+\r
+ // reset cache if switching from cached to not cached\r
+ if (o.cache === false)\r
+ this.$tabs.removeData('cache.tabs');\r
+ \r
+ // set up animations\r
+ var hideFx, showFx, baseFx = { 'min-width': 0, duration: 1 }, baseDuration = 'normal';\r
+ if (o.fx && o.fx.constructor == Array)\r
+ hideFx = o.fx[0] || baseFx, showFx = o.fx[1] || baseFx;\r
+ else\r
+ hideFx = showFx = o.fx || baseFx;\r
+\r
+ // reset some styles to maintain print style sheets etc.\r
+ var resetCSS = { display: '', overflow: '', height: '' };\r
+ if (!$.browser.msie) // not in IE to prevent ClearType font issue\r
+ resetCSS.opacity = '';\r
+\r
+ // Hide a tab, animation prevents browser scrolling to fragment,\r
+ // $show is optional.\r
+ function hideTab(clicked, $hide, $show) {\r
+ $hide.animate(hideFx, hideFx.duration || baseDuration, function() { //\r
+ $hide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.\r
+ if ($.browser.msie && hideFx.opacity)\r
+ $hide[0].style.filter = '';\r
+ if ($show)\r
+ showTab(clicked, $show, $hide);\r
+ });\r
+ }\r
\r
- // Show a tab, animation prevents browser scrolling to fragment,\r
- // $hide is optional.\r
- function showTab(clicked, $show, $hide) {\r
- if (showFx === baseFx)\r
- $show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab panels\r
- $show.animate(showFx, showFx.duration || baseDuration, function() {\r
- $show.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.\r
- if ($.browser.msie && showFx.opacity)\r
- $show[0].style.filter = '';\r
-\r
- // callback\r
- $(self.element).triggerHandler('tabsshow',\r
- [self.ui(clicked, $show[0])], o.show);\r
+ // Show a tab, animation prevents browser scrolling to fragment,\r
+ // $hide is optional.\r
+ function showTab(clicked, $show, $hide) {\r
+ if (showFx === baseFx)\r
+ $show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab panels\r
+ $show.animate(showFx, showFx.duration || baseDuration, function() {\r
+ $show.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.\r
+ if ($.browser.msie && showFx.opacity)\r
+ $show[0].style.filter = '';\r
\r
- });\r
- }\r
+ // callback\r
+ $(self.element).triggerHandler('tabsshow',\r
+ [self.ui(clicked, $show[0])], o.show);\r
\r
- // switch a tab\r
- function switchTab(clicked, $li, $hide, $show) {\r
- /*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click\r
- $.ajaxHistory.update(clicked.hash);\r
- }*/\r
- $li.addClass(o.selectedClass)\r
- .siblings().removeClass(o.selectedClass);\r
- hideTab(clicked, $hide, $show);\r
+ });\r
+ }\r
+\r
+ // switch a tab\r
+ function switchTab(clicked, $li, $hide, $show) {\r
+ /*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click\r
+ $.ajaxHistory.update(clicked.hash);\r
+ }*/\r
+ $li.addClass(o.selectedClass)\r
+ .siblings().removeClass(o.selectedClass);\r
+ hideTab(clicked, $hide, $show);\r
+ }\r
+\r
+ // attach tab event handler, unbind to avoid duplicates from former tabifying...\r
+ this.$tabs.unbind('.tabs').bind(o.event, function() {\r
+\r
+ //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click\r
+ var $li = $(this).parents('li:eq(0)'),\r
+ $hide = self.$panels.filter(':visible'),\r
+ $show = $(this.hash);\r
+\r
+ // If tab is already selected and not unselectable or tab disabled or \r
+ // or is already loading or click callback returns false stop here.\r
+ // Check if click handler returns false last so that it is not executed\r
+ // for a disabled or loading tab!\r
+ if (($li.hasClass(o.selectedClass) && !o.unselect)\r
+ || $li.hasClass(o.disabledClass) \r
+ || $(this).hasClass(o.loadingClass)\r
+ || $(self.element).triggerHandler('tabsselect', [self.ui(this, $show[0])], o.select) === false\r
+ ) {\r
+ this.blur();\r
+ return false;\r
}\r
\r
- // attach tab event handler, unbind to avoid duplicates from former tabifying...\r
- this.$tabs.unbind('.tabs').bind(o.event, function() {\r
-\r
- //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click\r
- var $li = $(this).parents('li:eq(0)'),\r
- $hide = self.$panels.filter(':visible'),\r
- $show = $(this.hash);\r
-\r
- // If tab is already selected and not unselectable or tab disabled or \r
- // or is already loading or click callback returns false stop here.\r
- // Check if click handler returns false last so that it is not executed\r
- // for a disabled or loading tab!\r
- if (($li.hasClass(o.selectedClass) && !o.unselect)\r
- || $li.hasClass(o.disabledClass) \r
- || $(this).hasClass(o.loadingClass)\r
- || $(self.element).triggerHandler('tabsselect', [self.ui(this, $show[0])], o.select) === false\r
- ) {\r
+ self.options.selected = self.$tabs.index(this);\r
+\r
+ // if tab may be closed\r
+ if (o.unselect) {\r
+ if ($li.hasClass(o.selectedClass)) {\r
+ self.options.selected = null;\r
+ $li.removeClass(o.selectedClass);\r
+ self.$panels.stop();\r
+ hideTab(this, $hide);\r
+ this.blur();\r
+ return false;\r
+ } else if (!$hide.length) {\r
+ self.$panels.stop();\r
+ var a = this;\r
+ self.load(self.$tabs.index(this), function() {\r
+ $li.addClass(o.selectedClass).addClass(o.unselectClass);\r
+ showTab(a, $show);\r
+ });\r
this.blur();\r
return false;\r
}\r
+ }\r
\r
- self.options.selected = self.$tabs.index(this);\r
-\r
- // if tab may be closed\r
- if (o.unselect) {\r
- if ($li.hasClass(o.selectedClass)) {\r
- self.options.selected = null;\r
- $li.removeClass(o.selectedClass);\r
- self.$panels.stop();\r
- hideTab(this, $hide);\r
- this.blur();\r
- return false;\r
- } else if (!$hide.length) {\r
- self.$panels.stop();\r
- var a = this;\r
- self.load(self.$tabs.index(this), function() {\r
- $li.addClass(o.selectedClass).addClass(o.unselectClass);\r
- showTab(a, $show);\r
- });\r
- this.blur();\r
- return false;\r
- }\r
- }\r
-\r
- if (o.cookie)\r
- $.cookie('ui-tabs' + $.data(self.element), self.options.selected, o.cookie);\r
-\r
- // stop possibly running animations\r
- self.$panels.stop();\r
-\r
- // show new tab\r
- if ($show.length) {\r
+ if (o.cookie)\r
+ $.cookie('ui-tabs' + $.data(self.element), self.options.selected, o.cookie);\r
\r
- // prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled\r
- /*if ($.browser.msie && o.bookmarkable) {\r
- var showId = this.hash.replace('#', '');\r
- $show.attr('id', '');\r
- setTimeout(function() {\r
- $show.attr('id', showId); // restore id\r
- }, 0);\r
- }*/\r
+ // stop possibly running animations\r
+ self.$panels.stop();\r
\r
- var a = this;\r
- self.load(self.$tabs.index(this), $hide.length ? \r
- function() {\r
- switchTab(a, $li, $hide, $show);\r
- } :\r
- function() {\r
- $li.addClass(o.selectedClass);\r
- showTab(a, $show);\r
- }\r
- );\r
+ // show new tab\r
+ if ($show.length) {\r
\r
- // Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash\r
- /*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;\r
- var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;\r
+ // prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled\r
+ /*if ($.browser.msie && o.bookmarkable) {\r
+ var showId = this.hash.replace('#', '');\r
+ $show.attr('id', '');\r
setTimeout(function() {\r
- scrollTo(scrollX, scrollY);\r
- }, 0);*/\r
+ $show.attr('id', showId); // restore id\r
+ }, 0);\r
+ }*/\r
\r
- } else\r
- throw 'jQuery UI Tabs: Mismatching fragment identifier.';\r
+ var a = this;\r
+ self.load(self.$tabs.index(this), $hide.length ? \r
+ function() {\r
+ switchTab(a, $li, $hide, $show);\r
+ } :\r
+ function() {\r
+ $li.addClass(o.selectedClass);\r
+ showTab(a, $show);\r
+ }\r
+ );\r
\r
- // Prevent IE from keeping other link focussed when using the back button\r
- // and remove dotted border from clicked link. This is controlled in modern\r
- // browsers via CSS, also blur removes focus from address bar in Firefox\r
- // which can become a usability and annoying problem with tabsRotate.\r
- if ($.browser.msie)\r
- this.blur();\r
+ // Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash\r
+ /*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;\r
+ var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;\r
+ setTimeout(function() {\r
+ scrollTo(scrollX, scrollY);\r
+ }, 0);*/\r
\r
- //return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE\r
- return false;\r
+ } else\r
+ throw 'jQuery UI Tabs: Mismatching fragment identifier.';\r
\r
- });\r
+ // Prevent IE from keeping other link focussed when using the back button\r
+ // and remove dotted border from clicked link. This is controlled in modern\r
+ // browsers via CSS, also blur removes focus from address bar in Firefox\r
+ // which can become a usability and annoying problem with tabsRotate.\r
+ if ($.browser.msie)\r
+ this.blur();\r
\r
- // disable click if event is configured to something else\r
- if (!(/^click/).test(o.event))\r
- this.$tabs.bind('click.tabs', function() { return false; });\r
+ //return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE\r
+ return false;\r
\r
- },\r
- add: function(url, label, index) {\r
- if (index == undefined) \r
- index = this.$tabs.length; // append by default\r
+ });\r
\r
- var o = this.options;\r
- var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label));\r
- $li.data('destroy.tabs', true);\r
+ // disable click if event is configured to something else\r
+ if (!(/^click/).test(o.event))\r
+ this.$tabs.bind('click.tabs', function() { return false; });\r
\r
- var id = url.indexOf('#') == 0 ? url.replace('#', '') : this.tabId( $('a:first-child', $li)[0] );\r
+ },\r
+ add: function(url, label, index) {\r
+ if (index == undefined) \r
+ index = this.$tabs.length; // append by default\r
\r
- // try to find an existing element before creating a new one\r
- var $panel = $('#' + id);\r
- if (!$panel.length) {\r
- $panel = $(o.panelTemplate).attr('id', id)\r
- .addClass(o.hideClass)\r
- .data('destroy.tabs', true);\r
- }\r
- $panel.addClass(o.panelClass);\r
- if (index >= this.$lis.length) {\r
- $li.appendTo(this.element);\r
- $panel.appendTo(this.element[0].parentNode);\r
- } else {\r
- $li.insertBefore(this.$lis[index]);\r
- $panel.insertBefore(this.$panels[index]);\r
- }\r
- \r
- o.disabled = $.map(o.disabled,\r
- function(n, i) { return n >= index ? ++n : n });\r
- \r
- this.tabify();\r
+ var o = this.options;\r
+ var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label));\r
+ $li.data('destroy.tabs', true);\r
\r
- if (this.$tabs.length == 1) {\r
- $li.addClass(o.selectedClass);\r
- $panel.removeClass(o.hideClass);\r
- var href = $.data(this.$tabs[0], 'load.tabs');\r
- if (href)\r
- this.load(index, href);\r
- }\r
+ var id = url.indexOf('#') == 0 ? url.replace('#', '') : this.tabId( $('a:first-child', $li)[0] );\r
\r
- // callback\r
- this.element.triggerHandler('tabsadd',\r
- [this.ui(this.$tabs[index], this.$panels[index])], o.add\r
- );\r
- },\r
- remove: function(index) {\r
- var o = this.options, $li = this.$lis.eq(index).remove(),\r
- $panel = this.$panels.eq(index).remove();\r
+ // try to find an existing element before creating a new one\r
+ var $panel = $('#' + id);\r
+ if (!$panel.length) {\r
+ $panel = $(o.panelTemplate).attr('id', id)\r
+ .addClass(o.hideClass)\r
+ .data('destroy.tabs', true);\r
+ }\r
+ $panel.addClass(o.panelClass);\r
+ if (index >= this.$lis.length) {\r
+ $li.appendTo(this.element);\r
+ $panel.appendTo(this.element[0].parentNode);\r
+ } else {\r
+ $li.insertBefore(this.$lis[index]);\r
+ $panel.insertBefore(this.$panels[index]);\r
+ }\r
+ \r
+ o.disabled = $.map(o.disabled,\r
+ function(n, i) { return n >= index ? ++n : n });\r
+ \r
+ this.tabify();\r
+\r
+ if (this.$tabs.length == 1) {\r
+ $li.addClass(o.selectedClass);\r
+ $panel.removeClass(o.hideClass);\r
+ var href = $.data(this.$tabs[0], 'load.tabs');\r
+ if (href)\r
+ this.load(index, href);\r
+ }\r
\r
- // If selected tab was removed focus tab to the right or\r
- // in case the last tab was removed the tab to the left.\r
- if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1)\r
- this.select(index + (index + 1 < this.$tabs.length ? 1 : -1));\r
+ // callback\r
+ this.element.triggerHandler('tabsadd',\r
+ [this.ui(this.$tabs[index], this.$panels[index])], o.add\r
+ );\r
+ },\r
+ remove: function(index) {\r
+ var o = this.options, $li = this.$lis.eq(index).remove(),\r
+ $panel = this.$panels.eq(index).remove();\r
+\r
+ // If selected tab was removed focus tab to the right or\r
+ // in case the last tab was removed the tab to the left.\r
+ if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1)\r
+ this.select(index + (index + 1 < this.$tabs.length ? 1 : -1));\r
+\r
+ o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }),\r
+ function(n, i) { return n >= index ? --n : n });\r
+\r
+ this.tabify();\r
+\r
+ // callback\r
+ this.element.triggerHandler('tabsremove',\r
+ [this.ui($li.find('a')[0], $panel[0])], o.remove\r
+ );\r
+ },\r
+ enable: function(index) {\r
+ var o = this.options;\r
+ if ($.inArray(index, o.disabled) == -1)\r
+ return;\r
+ \r
+ var $li = this.$lis.eq(index).removeClass(o.disabledClass);\r
+ if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2...\r
+ $li.css('display', 'inline-block');\r
+ setTimeout(function() {\r
+ $li.css('display', 'block');\r
+ }, 0);\r
+ }\r
\r
- o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }),\r
- function(n, i) { return n >= index ? --n : n });\r
+ o.disabled = $.grep(o.disabled, function(n, i) { return n != index; });\r
\r
- this.tabify();\r
+ // callback\r
+ this.element.triggerHandler('tabsenable',\r
+ [this.ui(this.$tabs[index], this.$panels[index])], o.enable\r
+ );\r
\r
- // callback\r
- this.element.triggerHandler('tabsremove',\r
- [this.ui($li.find('a')[0], $panel[0])], o.remove\r
- );\r
- },\r
- enable: function(index) {\r
- var o = this.options;\r
- if ($.inArray(index, o.disabled) == -1)\r
- return;\r
- \r
- var $li = this.$lis.eq(index).removeClass(o.disabledClass);\r
- if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2...\r
- $li.css('display', 'inline-block');\r
- setTimeout(function() {\r
- $li.css('display', 'block');\r
- }, 0);\r
- }\r
+ },\r
+ disable: function(index) {\r
+ var self = this, o = this.options;\r
+ if (index != o.selected) { // cannot disable already selected tab\r
+ this.$lis.eq(index).addClass(o.disabledClass);\r
\r
- o.disabled = $.grep(o.disabled, function(n, i) { return n != index; });\r
+ o.disabled.push(index);\r
+ o.disabled.sort();\r
\r
// callback\r
- this.element.triggerHandler('tabsenable',\r
- [this.ui(this.$tabs[index], this.$panels[index])], o.enable\r
+ this.element.triggerHandler('tabsdisable',\r
+ [this.ui(this.$tabs[index], this.$panels[index])], o.disable\r
);\r
+ }\r
+ },\r
+ select: function(index) {\r
+ if (typeof index == 'string')\r
+ index = this.$tabs.index( this.$tabs.filter('[href$=' + index + ']')[0] );\r
+ this.$tabs.eq(index).trigger(this.options.event);\r
+ },\r
+ load: function(index, callback) { // callback is for internal usage only\r
+ \r
+ var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0],\r
+ bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs');\r
+\r
+ callback = callback || function() {};\r
+ \r
+ // no remote or from cache - just finish with callback\r
+ if (!url || !bypassCache && $.data(a, 'cache.tabs')) {\r
+ callback();\r
+ return;\r
+ }\r
\r
- },\r
- disable: function(index) {\r
- var self = this, o = this.options;\r
- if (index != o.selected) { // cannot disable already selected tab\r
- this.$lis.eq(index).addClass(o.disabledClass);\r
+ // load remote from here on\r
+ \r
+ var inner = function(parent) {\r
+ var $parent = $(parent), $inner = $parent.find('*:last');\r
+ return $inner.length && $inner || $parent;\r
+ };\r
+ var cleanup = function() {\r
+ self.$tabs.filter('.' + o.loadingClass).removeClass(o.loadingClass)\r
+ .each(function() {\r
+ if (o.spinner)\r
+ inner(this).parent().html(inner(this).data('label.tabs'));\r
+ });\r
+ self.xhr = null;\r
+ };\r
+ \r
+ if (o.spinner) {\r
+ var label = inner(a).html();\r
+ inner(a).wrapInner('<em></em>')\r
+ .find('em').data('label.tabs', label).html(o.spinner);\r
+ }\r
\r
- o.disabled.push(index);\r
- o.disabled.sort();\r
+ var ajaxOptions = $.extend({}, o.ajaxOptions, {\r
+ url: url,\r
+ success: function(r, s) {\r
+ $(a.hash).html(r);\r
+ cleanup();\r
+ \r
+ if (o.cache)\r
+ $.data(a, 'cache.tabs', true); // if loaded once do not load them again\r
\r
- // callback\r
- this.element.triggerHandler('tabsdisable',\r
- [this.ui(this.$tabs[index], this.$panels[index])], o.disable\r
+ // callbacks\r
+ $(self.element).triggerHandler('tabsload',\r
+ [self.ui(self.$tabs[index], self.$panels[index])], o.load\r
);\r
- }\r
- },\r
- select: function(index) {\r
- if (typeof index == 'string')\r
- index = this.$tabs.index( this.$tabs.filter('[href$=' + index + ']')[0] );\r
- this.$tabs.eq(index).trigger(this.options.event);\r
- },\r
- load: function(index, callback) { // callback is for internal usage only\r
- \r
- var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0],\r
- bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs');\r
-\r
- callback = callback || function() {};\r
- \r
- // no remote or from cache - just finish with callback\r
- if (!url || !bypassCache && $.data(a, 'cache.tabs')) {\r
+ o.ajaxOptions.success && o.ajaxOptions.success(r, s);\r
+ \r
+ // This callback is required because the switch has to take\r
+ // place after loading has completed. Call last in order to \r
+ // fire load before show callback...\r
callback();\r
- return;\r
- }\r
-\r
- // load remote from here on\r
- \r
- var inner = function(parent) {\r
- var $parent = $(parent), $inner = $parent.find('*:last');\r
- return $inner.length && $inner || $parent;\r
- };\r
- var cleanup = function() {\r
- self.$tabs.filter('.' + o.loadingClass).removeClass(o.loadingClass)\r
- .each(function() {\r
- if (o.spinner)\r
- inner(this).parent().html(inner(this).data('label.tabs'));\r
- });\r
- self.xhr = null;\r
- };\r
- \r
- if (o.spinner) {\r
- var label = inner(a).html();\r
- inner(a).wrapInner('<em></em>')\r
- .find('em').data('label.tabs', label).html(o.spinner);\r
}\r
-\r
- var ajaxOptions = $.extend({}, o.ajaxOptions, {\r
- url: url,\r
- success: function(r, s) {\r
- $(a.hash).html(r);\r
- cleanup();\r
- \r
- if (o.cache)\r
- $.data(a, 'cache.tabs', true); // if loaded once do not load them again\r
-\r
- // callbacks\r
- $(self.element).triggerHandler('tabsload',\r
- [self.ui(self.$tabs[index], self.$panels[index])], o.load\r
- );\r
- o.ajaxOptions.success && o.ajaxOptions.success(r, s);\r
- \r
- // This callback is required because the switch has to take\r
- // place after loading has completed. Call last in order to \r
- // fire load before show callback...\r
- callback();\r
- }\r
- });\r
- if (this.xhr) {\r
- // terminate pending requests from other tabs and restore tab label\r
- this.xhr.abort();\r
- cleanup();\r
- }\r
- $a.addClass(o.loadingClass);\r
- setTimeout(function() { // timeout is again required in IE, "wait" for id being restored\r
- self.xhr = $.ajax(ajaxOptions);\r
- }, 0);\r
-\r
- },\r
- url: function(index, url) {\r
- this.$tabs.eq(index).removeData('cache.tabs').data('load.tabs', url);\r
- },\r
- destroy: function() {\r
- var o = this.options;\r
- this.element.unbind('.tabs')\r
- .removeClass(o.navClass).removeData('tabs');\r
- this.$tabs.each(function() {\r
- var href = $.data(this, 'href.tabs');\r
- if (href)\r
- this.href = href;\r
- var $this = $(this).unbind('.tabs');\r
- $.each(['href', 'load', 'cache'], function(i, prefix) {\r
- $this.removeData(prefix + '.tabs');\r
- });\r
- });\r
- this.$lis.add(this.$panels).each(function() {\r
- if ($.data(this, 'destroy.tabs'))\r
- $(this).remove();\r
- else\r
- $(this).removeClass([o.selectedClass, o.unselectClass,\r
- o.disabledClass, o.panelClass, o.hideClass].join(' '));\r
- });\r
+ });\r
+ if (this.xhr) {\r
+ // terminate pending requests from other tabs and restore tab label\r
+ this.xhr.abort();\r
+ cleanup();\r
}\r
- });\r
- \r
- $.ui.tabs.defaults = {\r
- // basic setup\r
- unselect: false,\r
- event: 'click',\r
- disabled: [],\r
- cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }\r
- // TODO history: false,\r
-\r
- // Ajax\r
- spinner: 'Loading…',\r
- cache: false,\r
- idPrefix: 'ui-tabs-',\r
- ajaxOptions: {},\r
-\r
- // animations\r
- fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }\r
-\r
- // templates\r
- tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',\r
- panelTemplate: '<div></div>',\r
-\r
- // CSS classes\r
- navClass: 'ui-tabs-nav',\r
- selectedClass: 'ui-tabs-selected',\r
- unselectClass: 'ui-tabs-unselect',\r
- disabledClass: 'ui-tabs-disabled',\r
- panelClass: 'ui-tabs-panel',\r
- hideClass: 'ui-tabs-hide',\r
- loadingClass: 'ui-tabs-loading'\r
- };\r
- \r
- $.ui.tabs.getter = "length";\r
+ $a.addClass(o.loadingClass);\r
+ setTimeout(function() { // timeout is again required in IE, "wait" for id being restored\r
+ self.xhr = $.ajax(ajaxOptions);\r
+ }, 0);\r
+\r
+ },\r
+ url: function(index, url) {\r
+ this.$tabs.eq(index).removeData('cache.tabs').data('load.tabs', url);\r
+ },\r
+ destroy: function() {\r
+ var o = this.options;\r
+ this.element.unbind('.tabs')\r
+ .removeClass(o.navClass).removeData('tabs');\r
+ this.$tabs.each(function() {\r
+ var href = $.data(this, 'href.tabs');\r
+ if (href)\r
+ this.href = href;\r
+ var $this = $(this).unbind('.tabs');\r
+ $.each(['href', 'load', 'cache'], function(i, prefix) {\r
+ $this.removeData(prefix + '.tabs');\r
+ });\r
+ });\r
+ this.$lis.add(this.$panels).each(function() {\r
+ if ($.data(this, 'destroy.tabs'))\r
+ $(this).remove();\r
+ else\r
+ $(this).removeClass([o.selectedClass, o.unselectClass,\r
+ o.disabledClass, o.panelClass, o.hideClass].join(' '));\r
+ });\r
+ }\r
+});\r
+\r
+$.ui.tabs.defaults = {\r
+ // basic setup\r
+ unselect: false,\r
+ event: 'click',\r
+ disabled: [],\r
+ cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }\r
+ // TODO history: false,\r
+\r
+ // Ajax\r
+ spinner: 'Loading…',\r
+ cache: false,\r
+ idPrefix: 'ui-tabs-',\r
+ ajaxOptions: {},\r
+\r
+ // animations\r
+ fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }\r
+\r
+ // templates\r
+ tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',\r
+ panelTemplate: '<div></div>',\r
+\r
+ // CSS classes\r
+ navClass: 'ui-tabs-nav',\r
+ selectedClass: 'ui-tabs-selected',\r
+ unselectClass: 'ui-tabs-unselect',\r
+ disabledClass: 'ui-tabs-disabled',\r
+ panelClass: 'ui-tabs-panel',\r
+ hideClass: 'ui-tabs-hide',\r
+ loadingClass: 'ui-tabs-loading'\r
+};\r
+\r
+$.ui.tabs.getter = "length";\r
\r
/*\r
* Tabs Extensions\r
*/\r
\r
- /*\r
- * Rotate\r
- */\r
- $.extend($.ui.tabs.prototype, {\r
- rotation: null,\r
- rotate: function(ms, continuing) {\r
- \r
- continuing = continuing || false;\r
- \r
- var self = this, t = this.options.selected;\r
- \r
- function start() {\r
- self.rotation = setInterval(function() {\r
- t = ++t < self.$tabs.length ? t : 0;\r
- self.select(t);\r
- }, ms); \r
- }\r
- \r
- function stop(e) {\r
- if (!e || e.clientX) { // only in case of a true click\r
- clearInterval(self.rotation);\r
- }\r
- }\r
- \r
- // start interval\r
- if (ms) {\r
- start();\r
- if (!continuing)\r
- this.$tabs.bind(this.options.event, stop);\r
- else\r
- this.$tabs.bind(this.options.event, function() {\r
- stop();\r
- t = self.options.selected;\r
- start();\r
- });\r
- }\r
- // stop interval\r
- else {\r
- stop();\r
- this.$tabs.unbind(this.options.event, stop);\r
+/*\r
+ * Rotate\r
+ */\r
+$.extend($.ui.tabs.prototype, {\r
+ rotation: null,\r
+ rotate: function(ms, continuing) {\r
+ \r
+ continuing = continuing || false;\r
+ \r
+ var self = this, t = this.options.selected;\r
+ \r
+ function start() {\r
+ self.rotation = setInterval(function() {\r
+ t = ++t < self.$tabs.length ? t : 0;\r
+ self.select(t);\r
+ }, ms); \r
+ }\r
+ \r
+ function stop(e) {\r
+ if (!e || e.clientX) { // only in case of a true click\r
+ clearInterval(self.rotation);\r
}\r
}\r
- });\r
+ \r
+ // start interval\r
+ if (ms) {\r
+ start();\r
+ if (!continuing)\r
+ this.$tabs.bind(this.options.event, stop);\r
+ else\r
+ this.$tabs.bind(this.options.event, function() {\r
+ stop();\r
+ t = self.options.selected;\r
+ start();\r
+ });\r
+ }\r
+ // stop interval\r
+ else {\r
+ stop();\r
+ this.$tabs.unbind(this.options.event, stop);\r
+ }\r
+ }\r
+});\r
\r
})(jQuery);\r