rbrindley: branch rbrindley/welcome_revamp r4200 - /team/rbrindley/welcome_re...
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Mon Nov 24 12:25:08 CST 2008
Author: rbrindley
Date: Mon Nov 24 12:25:08 2008
New Revision: 4200
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=4200
Log:
using jquery.ui-v1.5.2 for config/js/jquery.ui.* files
Modified:
team/rbrindley/welcome_revamp/config/js/jquery.ui.core.js
team/rbrindley/welcome_revamp/config/js/jquery.ui.draggable.js
team/rbrindley/welcome_revamp/config/js/jquery.ui.sortable.js
team/rbrindley/welcome_revamp/config/js/jquery.ui.tabs.js
Modified: team/rbrindley/welcome_revamp/config/js/jquery.ui.core.js
URL: http://svn.digium.com/view/asterisk-gui/team/rbrindley/welcome_revamp/config/js/jquery.ui.core.js?view=diff&rev=4200&r1=4199&r2=4200
==============================================================================
--- team/rbrindley/welcome_revamp/config/js/jquery.ui.core.js (original)
+++ team/rbrindley/welcome_revamp/config/js/jquery.ui.core.js Mon Nov 24 12:25:08 2008
@@ -1,7 +1,7 @@
/*
* jQuery UI @VERSION
*
- * Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about)
+ * Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
@@ -9,46 +9,7 @@
*/
;(function($) {
-/** jQuery core modifications and additions **/
-$.keyCode = {
- BACKSPACE: 8,
- CAPS_LOCK: 20,
- COMMA: 188,
- CONTROL: 17,
- DELETE: 46,
- DOWN: 40,
- END: 35,
- ENTER: 13,
- ESCAPE: 27,
- HOME: 36,
- INSERT: 45,
- LEFT: 37,
- NUMPAD_ADD: 107,
- NUMPAD_DECIMAL: 110,
- NUMPAD_DIVIDE: 111,
- NUMPAD_ENTER: 108,
- NUMPAD_MULTIPLY: 106,
- NUMPAD_SUBTRACT: 109,
- PAGE_DOWN: 34,
- PAGE_UP: 33,
- PERIOD: 190,
- RIGHT: 39,
- SHIFT: 16,
- SPACE: 32,
- TAB: 9,
- UP: 38
-};
-
-var _remove = $.fn.remove,
- isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
-
-
-//Helper functions and ui object
$.ui = {
-
- version: "@VERSION",
-
- // $.ui.plugin is deprecated. Use the proxy pattern instead.
plugin: {
add: function(module, option, set) {
var proto = $.ui[module].prototype;
@@ -60,325 +21,136 @@
call: function(instance, name, args) {
var set = instance.plugins[name];
if(!set) { return; }
-
+
for (var i = 0; i < set.length; i++) {
if (instance.options[set[i][0]]) {
set[i][1].apply(instance.element, args);
}
}
- }
- },
-
- contains: function(a, b) {
- var safari2 = $.browser.safari && $.browser.version < 522;
- if (a.contains && !safari2) {
- return a.contains(b);
- }
- if (a.compareDocumentPosition)
- return !!(a.compareDocumentPosition(b) & 16);
- while (b = b.parentNode)
- if (b == a) return true;
- return false;
- },
-
+ }
+ },
cssCache: {},
css: function(name) {
if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');
-
+
//if (!$.browser.safari)
- //tmp.appendTo('body');
-
+ //tmp.appendTo('body');
+
//Opera and Safari set width and height to 0px instead of auto
//Safari returns rgba(0,0,0,0) when bgcolor is not set
$.ui.cssCache[name] = !!(
- (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) ||
+ (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) ||
!(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))
);
try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){}
return $.ui.cssCache[name];
},
-
- hasScroll: function(el, a) {
-
- //If overflow is hidden, the element might have extra content, but the user wants to hide it
- if ($(el).css('overflow') == 'hidden') { return false; }
-
- var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
- has = false;
-
- if (el[scroll] > 0) { return true; }
-
- // TODO: determine which cases actually cause this to happen
- // if the element doesn't have the scroll set, see if it's possible to
- // set the scroll
- el[scroll] = 1;
- has = (el[scroll] > 0);
- el[scroll] = 0;
+ disableSelection: function(el) {
+ $(el).attr('unselectable', 'on').css('MozUserSelect', 'none');
+ },
+ enableSelection: function(el) {
+ $(el).attr('unselectable', 'off').css('MozUserSelect', '');
+ },
+ hasScroll: function(e, a) {
+ var scroll = /top/.test(a||"top") ? 'scrollTop' : 'scrollLeft', has = false;
+ if (e[scroll] > 0) return true; e[scroll] = 1;
+ has = e[scroll] > 0 ? true : false; e[scroll] = 0;
return has;
- },
-
- isOverAxis: function(x, reference, size) {
- //Determines when x coordinate is over "b" element axis
- return (x > reference) && (x < (reference + size));
- },
-
- isOver: function(y, x, top, left, height, width) {
- //Determines when x, y coordinates is over "b" element
- return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
}
};
-// WAI-ARIA normalization
-if (isFF2) {
- var attr = $.attr,
- removeAttr = $.fn.removeAttr,
- ariaNS = "http://www.w3.org/2005/07/aaa",
- ariaState = /^aria-/,
- ariaRole = /^wairole:/;
-
- $.attr = function(elem, name, value) {
- var set = value !== undefined;
-
- return (name == 'role'
- ? (set
- ? attr.call(this, elem, name, "wairole:" + value)
- : (attr.apply(this, arguments) || "").replace(ariaRole, ""))
- : (ariaState.test(name)
- ? (set
- ? elem.setAttributeNS(ariaNS,
- name.replace(ariaState, "aaa:"), value)
- : attr.call(this, elem, name.replace(ariaState, "aaa:")))
- : attr.apply(this, arguments)));
- };
-
- $.fn.removeAttr = function(name) {
- return (ariaState.test(name)
- ? this.each(function() {
- this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
- }) : removeAttr.call(this, name));
- };
-}
-
-//jQuery plugins
-$.fn.extend({
-
- remove: function() {
- // Safari has a native remove event which actually removes DOM elements,
- // so we have to use triggerHandler instead of trigger (#3037).
- $("*", this).add(this).each(function() {
- $(this).triggerHandler("remove");
- });
- return _remove.apply(this, arguments );
- },
-
- enableSelection: function() {
- return this
- .attr('unselectable', 'off')
- .css('MozUserSelect', '')
- .unbind('selectstart.ui');
- },
-
- disableSelection: function() {
- return this
- .attr('unselectable', 'on')
- .css('MozUserSelect', 'none')
- .bind('selectstart.ui', function() { return false; });
- },
-
- scrollParent: function() {
-
- var scrollParent;
- if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
- scrollParent = this.parents().filter(function() {
- return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
- }).eq(0);
- } else {
- scrollParent = this.parents().filter(function() {
- return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
- }).eq(0);
- }
-
- return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
-
-
- }
-
-});
-
-
-//Additional selectors
-$.extend($.expr[':'], {
-
- data: function(a, i, m) {
- return $.data(a, m[3]);
- },
-
- // TODO: add support for object, area
- tabbable: function(a, i, m) {
-
- var nodeName = a.nodeName.toLowerCase();
- function isVisible(element) {
- return !($(element).is(':hidden') || $(element).parents(':hidden').length);
- }
-
- return (
- // in tab order
- a.tabIndex >= 0 &&
-
- ( // filter node types that participate in the tab order
-
- // anchor tag
- ('a' == nodeName && a.href) ||
-
- // enabled form element
- (/input|select|textarea|button/.test(nodeName) &&
- 'hidden' != a.type && !a.disabled)
- ) &&
-
- // visible on page
- isVisible(a)
- );
-
- }
-
-});
-
+
+/** jQuery core modifications and additions **/
+
+var _remove = $.fn.remove;
+$.fn.remove = function() {
+ $("*", this).add(this).triggerHandler("remove");
+ return _remove.apply(this, arguments );
+};
// $.widget is a factory to create jQuery plugins
// taking some boilerplate code out of the plugin code
// created by Scott González and Jörn Zaefferer
-function getter(namespace, plugin, method, args) {
- function getMethods(type) {
- var methods = $[namespace][plugin][type] || [];
- return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
- }
-
- var methods = getMethods('getter');
- if (args.length == 1 && typeof args[0] == 'string') {
- methods = methods.concat(getMethods('getterSetter'));
- }
+function getter(namespace, plugin, method) {
+ var methods = $[namespace][plugin].getter || [];
+ methods = (typeof methods == "string" ? methods.split(/,?\s+/) : methods);
return ($.inArray(method, methods) != -1);
}
$.widget = function(name, prototype) {
var namespace = name.split(".")[0];
name = name.split(".")[1];
-
+
// create plugin method
$.fn[name] = function(options) {
var isMethodCall = (typeof options == 'string'),
args = Array.prototype.slice.call(arguments, 1);
-
- // prevent calls to internal methods
- if (isMethodCall && options.substring(0, 1) == '_') {
- return this;
- }
-
- // handle getter methods
- if (isMethodCall && getter(namespace, name, options, args)) {
+
+ if (isMethodCall && getter(namespace, name, options)) {
var instance = $.data(this[0], name);
return (instance ? instance[options].apply(instance, args)
: undefined);
}
-
- // handle initialization and non-getter methods
+
return this.each(function() {
var instance = $.data(this, name);
-
- // constructor
- (!instance && !isMethodCall &&
- $.data(this, name, new $[namespace][name](this, options)));
-
- // method call
- (instance && isMethodCall && $.isFunction(instance[options]) &&
- instance[options].apply(instance, args));
+ if (isMethodCall && instance && $.isFunction(instance[options])) {
+ instance[options].apply(instance, args);
+ } else if (!isMethodCall) {
+ $.data(this, name, new $[namespace][name](this, options));
+ }
});
};
-
+
// create widget constructor
- $[namespace] = $[namespace] || {};
$[namespace][name] = function(element, options) {
var self = this;
-
+
this.widgetName = name;
- this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
this.widgetBaseClass = namespace + '-' + name;
-
- this.options = $.extend({},
- $.widget.defaults,
- $[namespace][name].defaults,
- $.metadata && $.metadata.get(element)[name],
- options);
-
+
+ this.options = $.extend({}, $.widget.defaults, $[namespace][name].defaults, options);
this.element = $(element)
- .bind('setData.' + name, function(event, key, value) {
- return self._setData(key, value);
+ .bind('setData.' + name, function(e, key, value) {
+ return self.setData(key, value);
})
- .bind('getData.' + name, function(event, key) {
- return self._getData(key);
+ .bind('getData.' + name, function(e, key) {
+ return self.getData(key);
})
.bind('remove', function() {
return self.destroy();
});
-
- this._init();
+ this.init();
};
-
+
// add widget prototype
$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
-
- // TODO: merge getter and getterSetter properties from widget prototype
- // and plugin prototype
- $[namespace][name].getterSetter = 'option';
};
$.widget.prototype = {
- _init: function() {},
+ init: function() {},
destroy: function() {
this.element.removeData(this.widgetName);
},
-
- option: function(key, value) {
- var options = key,
- self = this;
-
- if (typeof key == "string") {
- if (value === undefined) {
- return this._getData(key);
- }
- options = {};
- options[key] = value;
- }
-
- $.each(options, function(key, value) {
- self._setData(key, value);
- });
- },
- _getData: function(key) {
+
+ getData: function(key) {
return this.options[key];
},
- _setData: function(key, value) {
+ setData: function(key, value) {
this.options[key] = value;
-
+
if (key == 'disabled') {
this.element[value ? 'addClass' : 'removeClass'](
this.widgetBaseClass + '-disabled');
}
},
-
+
enable: function() {
- this._setData('disabled', false);
+ this.setData('disabled', false);
},
disable: function() {
- this._setData('disabled', true);
- },
-
- _trigger: function(type, event, data) {
- var eventName = (type == this.widgetEventPrefix
- ? type : this.widgetEventPrefix + type);
- event = event || $.event.fix({ type: eventName, target: this.element[0] });
- return this.element.triggerHandler(eventName, [event, data], this.options[type]);
+ this.setData('disabled', true);
}
};
@@ -390,136 +162,124 @@
/** Mouse Interaction Plugin **/
$.ui.mouse = {
- _mouseInit: function() {
+ mouseInit: function() {
var self = this;
-
- this.element
- .bind('mousedown.'+this.widgetName, function(event) {
- return self._mouseDown(event);
- })
- .bind('click.'+this.widgetName, function(event) {
- if(self._preventClickEvent) {
- self._preventClickEvent = false;
- return false;
- }
- });
-
+
+ this.element.bind('mousedown.'+this.widgetName, function(e) {
+ return self.mouseDown(e);
+ });
+
// Prevent text selection in IE
if ($.browser.msie) {
this._mouseUnselectable = this.element.attr('unselectable');
this.element.attr('unselectable', 'on');
}
-
+
this.started = false;
},
-
+
// TODO: make sure destroying one instance of mouse doesn't mess with
// other instances of mouse
- _mouseDestroy: function() {
+ mouseDestroy: function() {
this.element.unbind('.'+this.widgetName);
-
+
// Restore text selection in IE
($.browser.msie
&& this.element.attr('unselectable', this._mouseUnselectable));
},
-
- _mouseDown: function(event) {
+
+ mouseDown: function(e) {
// we may have missed mouseup (out of window)
- (this._mouseStarted && this._mouseUp(event));
-
- this._mouseDownEvent = event;
-
+ (this._mouseStarted && this.mouseUp(e));
+
+ this._mouseDownEvent = e;
+
var self = this,
- btnIsLeft = (event.which == 1),
- elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
- if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ btnIsLeft = (e.which == 1),
+ elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this.mouseCapture(e)) {
return true;
}
-
- this.mouseDelayMet = !this.options.delay;
- if (!this.mouseDelayMet) {
+
+ this._mouseDelayMet = !this.options.delay;
+ if (!this._mouseDelayMet) {
this._mouseDelayTimer = setTimeout(function() {
- self.mouseDelayMet = true;
+ self._mouseDelayMet = true;
}, this.options.delay);
}
-
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
- this._mouseStarted = (this._mouseStart(event) !== false);
+
+ if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
+ this._mouseStarted = (this.mouseStart(e) !== false);
if (!this._mouseStarted) {
- event.preventDefault();
+ e.preventDefault();
return true;
}
}
-
+
// these delegates are required to keep context
- this._mouseMoveDelegate = function(event) {
- return self._mouseMove(event);
+ this._mouseMoveDelegate = function(e) {
+ return self.mouseMove(e);
};
- this._mouseUpDelegate = function(event) {
- return self._mouseUp(event);
+ this._mouseUpDelegate = function(e) {
+ return self.mouseUp(e);
};
$(document)
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
-
- // preventDefault() is used to prevent the selection of text here -
- // however, in Safari, this causes select boxes not to be selectable
- // anymore, so this fix is needed
- if(!$.browser.safari) event.preventDefault();
- return true;
- },
-
- _mouseMove: function(event) {
+
+ return false;
+ },
+
+ mouseMove: function(e) {
// IE mouseup check - mouseup happened when mouse was out of window
- if ($.browser.msie && !event.button) {
- return this._mouseUp(event);
- }
-
+ if ($.browser.msie && !e.button) {
+ return this.mouseUp(e);
+ }
+
if (this._mouseStarted) {
- this._mouseDrag(event);
- return event.preventDefault();
- }
-
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this.mouseDrag(e);
+ return false;
+ }
+
+ if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
this._mouseStarted =
- (this._mouseStart(this._mouseDownEvent, event) !== false);
- (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
- }
-
+ (this.mouseStart(this._mouseDownEvent, e) !== false);
+ (this._mouseStarted ? this.mouseDrag(e) : this.mouseUp(e));
+ }
+
return !this._mouseStarted;
},
-
- _mouseUp: function(event) {
+
+ mouseUp: function(e) {
$(document)
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
-
+
if (this._mouseStarted) {
this._mouseStarted = false;
- this._preventClickEvent = true;
- this._mouseStop(event);
- }
-
+ this.mouseStop(e);
+ }
+
return false;
},
-
- _mouseDistanceMet: function(event) {
+
+ mouseDistanceMet: function(e) {
return (Math.max(
- Math.abs(this._mouseDownEvent.pageX - event.pageX),
- Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ Math.abs(this._mouseDownEvent.pageX - e.pageX),
+ Math.abs(this._mouseDownEvent.pageY - e.pageY)
) >= this.options.distance
);
},
-
- _mouseDelayMet: function(event) {
- return this.mouseDelayMet;
- },
-
+
+ mouseDelayMet: function(e) {
+ return this._mouseDelayMet;
+ },
+
// These are placeholder methods, to be overriden by extending plugin
- _mouseStart: function(event) {},
- _mouseDrag: function(event) {},
- _mouseStop: function(event) {},
- _mouseCapture: function(event) { return true; }
+ mouseStart: function(e) {},
+ mouseDrag: function(e) {},
+ mouseStop: function(e) {},
+ mouseCapture: function(e) { return true; }
};
$.ui.mouse.defaults = {
Modified: team/rbrindley/welcome_revamp/config/js/jquery.ui.draggable.js
URL: http://svn.digium.com/view/asterisk-gui/team/rbrindley/welcome_revamp/config/js/jquery.ui.draggable.js?view=diff&rev=4200&r1=4199&r2=4200
==============================================================================
--- team/rbrindley/welcome_revamp/config/js/jquery.ui.draggable.js (original)
+++ team/rbrindley/welcome_revamp/config/js/jquery.ui.draggable.js Mon Nov 24 12:25:08 2008
@@ -1,10 +1,10 @@
/*
- * jQuery UI Draggable @VERSION
+ * jQuery UI Draggable
*
- * Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about)
+ * Copyright (c) 2008 Paul Bakaus
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
- *
+ *
* http://docs.jquery.com/UI/Draggables
*
* Depends:
@@ -13,297 +13,170 @@
(function($) {
$.widget("ui.draggable", $.extend({}, $.ui.mouse, {
-
- _init: function() {
-
- if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
- this.element[0].style.position = 'relative';
-
- (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-draggable"));
- (this.options.disabled && this.element.addClass('ui-draggable-disabled'));
-
- this._mouseInit();
-
- },
-
- destroy: function() {
- if(!this.element.data('draggable')) return;
- this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled');
- this._mouseDestroy();
- },
-
- _mouseCapture: function(event) {
-
+ init: function() {
+
+ //Initialize needed constants
var o = this.options;
- if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
- return false;
-
- //Quit if we're not on a valid handle
- this.handle = this._getHandle(event);
- if (!this.handle)
- return false;
-
- return true;
-
- },
-
- _mouseStart: function(event) {
-
+ //Position the node
+ if (o.helper == 'original' && !(/(relative|absolute|fixed)/).test(this.element.css('position')))
+ this.element.css('position', 'relative');
+
+ this.element.addClass('ui-draggable');
+ (o.disabled && this.element.addClass('ui-draggable-disabled'));
+
+ this.mouseInit();
+
+ },
+ mouseStart: function(e) {
var o = this.options;
-
+
+ if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle')) return false;
+
+ var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
+
+
+ $(this.options.handle, this.element).find("*").andSelf().each(function() {
+ if(this == e.target) handle = true;
+ });
+ if (!handle) return false;
+
+ if($.ui.ddmanager) $.ui.ddmanager.current = this;
+
//Create and append the visible helper
- this.helper = this._createHelper(event);
-
- //Cache the helper size
- this._cacheHelperProportions();
-
- //If ddmanager is used for droppables, set the global draggable
- if($.ui.ddmanager)
- $.ui.ddmanager.current = this;
-
+ this.helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [e])) : (o.helper == 'clone' ? this.element.clone() : this.element);
+ if(!this.helper.parents('body').length) this.helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
+ if(this.helper[0] != this.element[0] && !(/(fixed|absolute)/).test(this.helper.css("position"))) this.helper.css("position", "absolute");
+
/*
* - Position generation -
* This block generates everything position related - it's the core of draggables.
*/
-
- //Cache the margins of the original element
- this._cacheMargins();
-
- //Store the helper's css position
- this.cssPosition = this.helper.css("position");
- this.scrollParent = this.helper.scrollParent();
-
- //The element's absolute position on the page minus margins
- this.offset = this.element.offset();
- this.offset = {
+
+ this.margins = { //Cache the margins
+ left: (parseInt(this.element.css("marginLeft"),10) || 0),
+ top: (parseInt(this.element.css("marginTop"),10) || 0)
+ };
+
+ this.cssPosition = this.helper.css("position"); //Store the helper's css position
+ this.offset = this.element.offset(); //The element's absolute position on the page
+ this.offset = { //Substract the margins from the element's absolute offset
top: this.offset.top - this.margins.top,
left: this.offset.left - this.margins.left
};
-
- $.extend(this.offset, {
- click: { //Where the click happened, relative to the element
- left: event.pageX - this.offset.left,
- top: event.pageY - this.offset.top
- },
- parent: this._getParentOffset(),
- relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
- });
-
- //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
- if(o.cursorAt)
- this._adjustOffsetFromHelper(o.cursorAt);
-
- //Generate the original position
- this.originalPosition = this._generatePosition(event);
-
- //Set a containment if given in the options
- if(o.containment)
- this._setContainment();
-
- //Call plugins and callbacks
- this._propagate("start", event);
-
- //Recache the helper size
- this._cacheHelperProportions();
-
- //Prepare the droppable offsets
- if ($.ui.ddmanager && !o.dropBehaviour)
- $.ui.ddmanager.prepareOffsets(this, event);
-
- this.helper.addClass("ui-draggable-dragging");
- this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
- return true;
- },
-
- _mouseDrag: function(event, noPropagation) {
-
- //Compute the helpers position
- this.position = this._generatePosition(event);
- this.positionAbs = this._convertPositionTo("absolute");
-
- //Call plugins and callbacks and use the resulting position if something is returned
- if(!noPropagation) this.position = this._propagate("drag", event) || this.position;
-
- if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
- if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
- if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
-
- return false;
- },
-
- _mouseStop: function(event) {
-
- //If we are using droppables, inform the manager about the drop
- var dropped = false;
- if ($.ui.ddmanager && !this.options.dropBehaviour)
- var dropped = $.ui.ddmanager.drop(this, event);
-
- if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
- var self = this;
- $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
- self._propagate("stop", event);
- self._clear();
- });
- } else {
- this._propagate("stop", event);
- this._clear();
- }
-
- return false;
- },
-
- _getHandle: function(event) {
-
- var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
- $(this.options.handle, this.element)
- .find("*")
- .andSelf()
- .each(function() {
- if(this == event.target) handle = true;
- });
-
- return handle;
-
- },
-
- _createHelper: function(event) {
-
- var o = this.options;
- var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
-
- if(!helper.parents('body').length)
- helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
-
- if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
- helper.css("position", "absolute");
-
- return helper;
-
- },
-
- _adjustOffsetFromHelper: function(obj) {
- if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left;
- if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
- if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top;
- if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
- },
-
- _getParentOffset: function() {
-
+
+ this.offset.click = { //Where the click happened, relative to the element
+ left: e.pageX - this.offset.left,
+ top: e.pageY - this.offset.top
+ };
+
this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position
-
- if((this.offsetParent[0] == document.body && $.browser.mozilla) //Ugly FF3 fix
- || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
- po = { top: 0, left: 0 };
-
- return {
+ if(this.offsetParent[0] == document.body && $.browser.mozilla) po = { top: 0, left: 0 }; //Ugly FF3 fix
+ this.offset.parent = { //Store its position plus border
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
};
-
- },
-
- _getRelativeOffset: function() {
-
- if(this.cssPosition == "relative") {
- var p = this.element.position();
- return {
- top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
- left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
- };
- } else {
- return { top: 0, left: 0 };
- }
-
- },
-
- _cacheMargins: function() {
- this.margins = {
- left: (parseInt(this.element.css("marginLeft"),10) || 0),
- top: (parseInt(this.element.css("marginTop"),10) || 0)
- };
- },
-
- _cacheHelperProportions: function() {
- this.helperProportions = {
- width: this.helper.outerWidth(),
- height: this.helper.outerHeight()
- };
- },
-
- _setContainment: function() {
-
- var o = this.options;
- if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
- if(o.containment == 'document' || o.containment == 'window') this.containment = [
- 0 - this.offset.relative.left - this.offset.parent.left,
- 0 - this.offset.relative.top - this.offset.parent.top,
- $(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
- ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
- ];
-
- if(!(/^(document|window|parent)$/).test(o.containment)) {
- var ce = $(o.containment)[0];
- var co = $(o.containment).offset();
- var over = ($(ce).css("overflow") != 'hidden');
-
- this.containment = [
- co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left,
- co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top,
- co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : 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),
- co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : 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)
+
+ var p = this.element.position(); //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helpers
+ this.offset.relative = this.cssPosition == "relative" ? {
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.offsetParent[0].scrollTop,
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.offsetParent[0].scrollLeft
+ } : { top: 0, left: 0 };
+
+ this.originalPosition = this.generatePosition(e); //Generate the original position
+ this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size
+
+ if(o.cursorAt) {
+ if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left + this.margins.left;
+ if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right + this.margins.left;
+ if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top + this.margins.top;
+ if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom + this.margins.top;
+ }
+
+
+ /*
+ * - Position constraining -
+ * Here we prepare position constraining like grid and containment.
+ */
+
+ if(o.containment) {
+ if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
+ if(o.containment == 'document' || o.containment == 'window') this.containment = [
+ 0 - this.offset.relative.left - this.offset.parent.left,
+ 0 - this.offset.relative.top - this.offset.parent.top,
+ $(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
+ ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
];
- }
-
- },
-
- _convertPositionTo: function(d, pos) {
-
+
+ if(!(/^(document|window|parent)$/).test(o.containment)) {
+ var ce = $(o.containment)[0];
+ var co = $(o.containment).offset();
+
+ this.containment = [
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left,
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top,
+ 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),
+ 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)
+ ];
+ }
+ }
+
+ //Call plugins and callbacks
+ this.propagate("start", e);
+
+ this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size
+ if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);
+
+ this.helper.addClass("ui-draggable-dragging");
+ this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+ return true;
+ },
+ convertPositionTo: function(d, pos) {
if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1;
-
return {
top: (
pos.top // the calculated relative position
+ this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
- + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : this[(this.cssPosition == 'absolute' ? 'offset' : 'scroll')+'Parent'].scrollTop() ) * mod
+ - (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
+ + (this.cssPosition == "fixed" ? $(document).scrollTop() : 0) * mod
+ this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)
),
left: (
pos.left // the calculated relative position
+ this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
- + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : this[(this.cssPosition == 'absolute' ? 'offset' : 'scroll')+'Parent'].scrollLeft() ) * mod
+ - (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
+ + (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0) * mod
+ this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)
)
};
},
-
- _generatePosition: function(event) {
-
- var o = this.options, scroll = this[(this.cssPosition == 'absolute' ? 'offset' : 'scroll')+'Parent'], scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
-
+ generatePosition: function(e) {
+
+ var o = this.options;
var position = {
top: (
- event.pageY // The absolute mouse position
+ e.pageY // The absolute mouse position
- this.offset.click.top // Click offset (relative to the element)
- this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.parent.top // The offsetParent's offset without borders (offset + border)
- + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )
+ + (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
+ - (this.cssPosition == "fixed" ? $(document).scrollTop() : 0)
),
left: (
- event.pageX // The absolute mouse position
+ e.pageX // The absolute mouse position
- this.offset.click.left // Click offset (relative to the element)
- this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
- this.offset.parent.left // The offsetParent's offset without borders (offset + border)
- + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )
+ + (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
+ - (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0)
)
};
-
+
if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options
-
+
/*
* - Position constraining -
* Constrain the position to a mix of grid, containment.
@@ -314,83 +187,255 @@
if(position.left > this.containment[2]) position.left = this.containment[2];
if(position.top > this.containment[3]) position.top = this.containment[3];
}
-
+
if(o.grid) {
var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];
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;
-
+
var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];
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;
}
-
+
return position;
},
-
- _clear: function() {
+ mouseDrag: function(e) {
+
+ //Compute the helpers position
+ this.position = this.generatePosition(e);
+ this.positionAbs = this.convertPositionTo("absolute");
+
+ //Call plugins and callbacks and use the resulting position if something is returned
+ this.position = this.propagate("drag", e) || this.position;
+
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
+
+ return false;
+ },
+ mouseStop: function(e) {
+
+ //If we are using droppables, inform the manager about the drop
+ var dropped = false;
+ if ($.ui.ddmanager && !this.options.dropBehaviour)
+ var dropped = $.ui.ddmanager.drop(this, e);
+
[... 3145 lines stripped ...]
More information about the asterisk-gui-commits
mailing list