Internal methods: fixes #3195, #3196, #3200, #3201, #3209

This commit is contained in:
Chi Cheng 2008-08-17 02:15:55 +00:00
parent 8c3be4fdcb
commit dd6a17b434
5 changed files with 182 additions and 182 deletions

View File

@ -14,7 +14,7 @@
$.widget("ui.autocomplete", { $.widget("ui.autocomplete", {
init: function() { _init: function() {
$.extend(this.options, { $.extend(this.options, {
delay: this.options.url ? $.Autocompleter.defaults.delay : 10, delay: this.options.url ? $.Autocompleter.defaults.delay : 10,

View File

@ -14,18 +14,18 @@
$.widget("ui.colorpicker", { $.widget("ui.colorpicker", {
init: function() { _init: function() {
this.charMin = 65; this.charMin = 65;
var o = this.options, self = this, var o = this.options, self = this,
tpl = '<div class="ui-colorpicker clearfix"><div class="ui-colorpicker-color"><div><div></div></div></div><div class="ui-colorpicker-hue"><div></div></div><div class="ui-colorpicker-new-color"></div><div class="ui-colorpicker-current-color"></div><div class="ui-colorpicker-hex"><label for="ui-colorpicker-hex" title="hex">#</label><input type="text" maxlength="6" size="6" /></div><div class="ui-colorpicker-rgb-r ui-colorpicker-field"><label for="ui-colorpicker-rgb-r">R</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-rgb-g ui-colorpicker-field"><label for="ui-colorpicker-rgb-g">G</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-rgb-b ui-colorpicker-field"><label for="ui-colorpicker-rgb-b">B</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-hsb-h ui-colorpicker-field"><label for="ui-colorpicker-hsb-h">H</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-hsb-s ui-colorpicker-field"><label for="ui-colorpicker-hsb-s">S</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-hsb-b ui-colorpicker-field"><label for="ui-colorpicker-hsb-b">B</label><input type="text" maxlength="3" size="3" /><span></span></div><button class="ui-colorpicker-submit ui-default-state" name="submit" type="submit">Done</button></div>'; tpl = '<div class="ui-colorpicker clearfix"><div class="ui-colorpicker-color"><div><div></div></div></div><div class="ui-colorpicker-hue"><div></div></div><div class="ui-colorpicker-new-color"></div><div class="ui-colorpicker-current-color"></div><div class="ui-colorpicker-hex"><label for="ui-colorpicker-hex" title="hex">#</label><input type="text" maxlength="6" size="6" /></div><div class="ui-colorpicker-rgb-r ui-colorpicker-field"><label for="ui-colorpicker-rgb-r">R</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-rgb-g ui-colorpicker-field"><label for="ui-colorpicker-rgb-g">G</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-rgb-b ui-colorpicker-field"><label for="ui-colorpicker-rgb-b">B</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-hsb-h ui-colorpicker-field"><label for="ui-colorpicker-hsb-h">H</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-hsb-s ui-colorpicker-field"><label for="ui-colorpicker-hsb-s">S</label><input type="text" maxlength="3" size="3" /><span></span></div><div class="ui-colorpicker-hsb-b ui-colorpicker-field"><label for="ui-colorpicker-hsb-b">B</label><input type="text" maxlength="3" size="3" /><span></span></div><button class="ui-colorpicker-submit ui-default-state" name="submit" type="submit">Done</button></div>';
if (typeof o.color == 'string') { if (typeof o.color == 'string') {
this.color = this.HexToHSB(o.color); this.color = this._HexToHSB(o.color);
} else if (o.color.r != undefined && o.color.g != undefined && o.color.b != undefined) { } else if (o.color.r != undefined && o.color.g != undefined && o.color.b != undefined) {
this.color = this.RGBToHSB(o.color); this.color = this._RGBToHSB(o.color);
} else if (o.color.h != undefined && o.color.s != undefined && o.color.b != undefined) { } else if (o.color.h != undefined && o.color.s != undefined && o.color.b != undefined) {
this.color = this.fixHSB(o.color); this.color = this._fixHSB(o.color);
} else { } else {
return this; return this;
} }
@ -40,33 +40,33 @@ $.widget("ui.colorpicker", {
} }
this.fields = this.picker.find('input') this.fields = this.picker.find('input')
.bind('keydown', function(e) { return self.keyDown.call(self, e); }) .bind('keydown', function(e) { return self._keyDown.call(self, e); })
.bind('change', function(e) { return self.change.call(self, e); }) .bind('change', function(e) { return self._change.call(self, e); })
.bind('blur', function(e) { return self.blur.call(self, e); }) .bind('blur', function(e) { return self._blur.call(self, e); })
.bind('focus', function(e) { return self.focus.call(self, e); }); .bind('focus', function(e) { return self._focus.call(self, e); });
this.picker.find('span').bind('mousedown', function(e) { return self.downIncrement.call(self, e); }); this.picker.find('span').bind('mousedown', function(e) { return self._downIncrement.call(self, e); });
this.selector = this.picker.find('div.ui-colorpicker-color').bind('mousedown', function(e) { return self.downSelector.call(self, e); }); this.selector = this.picker.find('div.ui-colorpicker-color').bind('mousedown', function(e) { return self._downSelector.call(self, e); });
this.selectorIndic = this.selector.find('div div'); this.selectorIndic = this.selector.find('div div');
this.hue = this.picker.find('div.ui-colorpicker-hue div'); this.hue = this.picker.find('div.ui-colorpicker-hue div');
this.picker.find('div.ui-colorpicker-hue').bind('mousedown', function(e) { return self.downHue.call(self, e); }); this.picker.find('div.ui-colorpicker-hue').bind('mousedown', function(e) { return self._downHue.call(self, e); });
this.newColor = this.picker.find('div.ui-colorpicker-new-color'); this.newColor = this.picker.find('div.ui-colorpicker-new-color');
this.currentColor = this.picker.find('div.ui-colorpicker-current-color'); this.currentColor = this.picker.find('div.ui-colorpicker-current-color');
this.picker.find('div.ui-colorpicker-submit') this.picker.find('div.ui-colorpicker-submit')
.bind('mouseenter', function(e) { return self.enterSubmit.call(self, e); }) .bind('mouseenter', function(e) { return self._enterSubmit.call(self, e); })
.bind('mouseleave', function(e) { return self.leaveSubmit.call(self, e); }) .bind('mouseleave', function(e) { return self._leaveSubmit.call(self, e); })
.bind('click', function(e) { return self.clickSubmit.call(self, e); }); .bind('click', function(e) { return self._clickSubmit.call(self, e); });
this.fillRGBFields(this.color); this._fillRGBFields(this.color);
this.fillHSBFields(this.color); this._fillHSBFields(this.color);
this.fillHexFields(this.color); this._fillHexFields(this.color);
this.setHue(this.color); this._setHue(this.color);
this.setSelector(this.color); this._setSelector(this.color);
this.setCurrentColor(this.color); this._setCurrentColor(this.color);
this.setNewColor(this.color); this._setNewColor(this.color);
if (o.flat) { if (o.flat) {
this.picker.css({ this.picker.css({
@ -74,7 +74,7 @@ $.widget("ui.colorpicker", {
display: 'block' display: 'block'
}); });
} else { } else {
$(this.element).bind(o.eventName+".colorpicker", function(e) { return self.show.call(self, e); }); $(this.element).bind(o.eventName+".colorpicker", function(e) { return self._show.call(self, e); });
} }
}, },
@ -86,96 +86,96 @@ $.widget("ui.colorpicker", {
}, },
fillRGBFields: function(hsb) { _fillRGBFields: function(hsb) {
var rgb = this.HSBToRGB(hsb); var rgb = this._HSBToRGB(hsb);
this.fields this.fields
.eq(1).val(rgb.r).end() .eq(1).val(rgb.r).end()
.eq(2).val(rgb.g).end() .eq(2).val(rgb.g).end()
.eq(3).val(rgb.b).end(); .eq(3).val(rgb.b).end();
}, },
fillHSBFields: function(hsb) { _fillHSBFields: function(hsb) {
this.fields this.fields
.eq(4).val(hsb.h).end() .eq(4).val(hsb.h).end()
.eq(5).val(hsb.s).end() .eq(5).val(hsb.s).end()
.eq(6).val(hsb.b).end(); .eq(6).val(hsb.b).end();
}, },
fillHexFields: function (hsb) { _fillHexFields: function (hsb) {
this.fields this.fields
.eq(0).val(this.HSBToHex(hsb)).end(); .eq(0).val(this._HSBToHex(hsb)).end();
}, },
setSelector: function(hsb) { _setSelector: function(hsb) {
this.selector.css('backgroundColor', '#' + this.HSBToHex({h: hsb.h, s: 100, b: 100})); this.selector.css('backgroundColor', '#' + this._HSBToHex({h: hsb.h, s: 100, b: 100}));
this.selectorIndic.css({ this.selectorIndic.css({
left: parseInt(150 * hsb.s/100, 10), left: parseInt(150 * hsb.s/100, 10),
top: parseInt(150 * (100-hsb.b)/100, 10) top: parseInt(150 * (100-hsb.b)/100, 10)
}); });
}, },
setHue: function(hsb) { _setHue: function(hsb) {
this.hue.css('top', parseInt(150 - 150 * hsb.h/360, 10)); this.hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
}, },
setCurrentColor: function(hsb) { _setCurrentColor: function(hsb) {
this.currentColor.css('backgroundColor', '#' + this.HSBToHex(hsb)); this.currentColor.css('backgroundColor', '#' + this._HSBToHex(hsb));
}, },
setNewColor: function(hsb) { _setNewColor: function(hsb) {
this.newColor.css('backgroundColor', '#' + this.HSBToHex(hsb)); this.newColor.css('backgroundColor', '#' + this._HSBToHex(hsb));
}, },
keyDown: function(e) { _keyDown: function(e) {
var pressedKey = e.charCode || e.keyCode || -1; var pressedKey = e.charCode || e.keyCode || -1;
if ((pressedKey >= this.charMin && pressedKey <= 90) || pressedKey == 32) { if ((pressedKey >= this.charMin && pressedKey <= 90) || pressedKey == 32) {
return false; return false;
} }
}, },
change: function(e, target) { _change: function(e, target) {
var col; var col;
target = target || e.target; target = target || e.target;
if (target.parentNode.className.indexOf('-hex') > 0) { if (target.parentNode.className.indexOf('-hex') > 0) {
this.color = col = this.HexToHSB(this.value); this.color = col = this._HexToHSB(this.value);
this.fillRGBFields(col.color); this._fillRGBFields(col.color);
this.fillHSBFields(col); this._fillHSBFields(col);
} else if (target.parentNode.className.indexOf('-hsb') > 0) { } else if (target.parentNode.className.indexOf('-hsb') > 0) {
this.color = col = this.fixHSB({ this.color = col = this._fixHSB({
h: parseInt(this.fields.eq(4).val(), 10), h: parseInt(this.fields.eq(4).val(), 10),
s: parseInt(this.fields.eq(5).val(), 10), s: parseInt(this.fields.eq(5).val(), 10),
b: parseInt(this.fields.eq(6).val(), 10) b: parseInt(this.fields.eq(6).val(), 10)
}); });
this.fillRGBFields(col); this._fillRGBFields(col);
this.fillHexFields(col); this._fillHexFields(col);
} else { } else {
this.color = col = this.RGBToHSB(this.fixRGB({ this.color = col = this._RGBToHSB(this._fixRGB({
r: parseInt(this.fields.eq(1).val(), 10), r: parseInt(this.fields.eq(1).val(), 10),
g: parseInt(this.fields.eq(2).val(), 10), g: parseInt(this.fields.eq(2).val(), 10),
b: parseInt(this.fields.eq(3).val(), 10) b: parseInt(this.fields.eq(3).val(), 10)
})); }));
this.fillHexFields(col); this._fillHexFields(col);
this.fillHSBFields(col); this._fillHSBFields(col);
} }
this.setSelector(col); this._setSelector(col);
this.setHue(col); this._setHue(col);
this.setNewColor(col); this._setNewColor(col);
this.trigger('change', e, { options: this.options, hsb: col, hex: this.HSBToHex(col), rgb: this.HSBToRGB(col) }); this._trigger('change', e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) });
}, },
blur: function(e) { _blur: function(e) {
var col = this.color; var col = this.color;
this.fillRGBFields(col); this._fillRGBFields(col);
this.fillHSBFields(col); this._fillHSBFields(col);
this.fillHexFields(col); this._fillHexFields(col);
this.setHue(col); this._setHue(col);
this.setSelector(col); this._setSelector(col);
this.setNewColor(col); this._setNewColor(col);
this.fields.parent().removeClass('ui-colorpicker-focus'); this.fields.parent().removeClass('ui-colorpicker-focus');
}, },
focus: function(e) { _focus: function(e) {
this.charMin = e.target.parentNode.className.indexOf('-hex') > 0 ? 70 : 65; this.charMin = e.target.parentNode.className.indexOf('-hex') > 0 ? 70 : 65;
this.fields.parent().removeClass('ui-colorpicker-focus'); this.fields.parent().removeClass('ui-colorpicker-focus');
$(e.target.parentNode).addClass('ui-colorpicker-focus'); $(e.target.parentNode).addClass('ui-colorpicker-focus');
}, },
downIncrement: function(e) { _downIncrement: function(e) {
var field = $(e.target).parent().find('input').focus(), self = this; var field = $(e.target).parent().find('input').focus(), self = this;
this.currentIncrement = { this.currentIncrement = {
@ -185,44 +185,44 @@ $.widget("ui.colorpicker", {
field: field, field: field,
val: parseInt(field.val(), 10) val: parseInt(field.val(), 10)
}; };
$(document).bind('mouseup.cpSlider', function(e) { return self.upIncrement.call(self, e); }); $(document).bind('mouseup.cpSlider', function(e) { return self._upIncrement.call(self, e); });
$(document).bind('mousemove.cpSlider', function(e) { return self.moveIncrement.call(self, e); }); $(document).bind('mousemove.cpSlider', function(e) { return self._moveIncrement.call(self, e); });
return false; return false;
}, },
moveIncrement: function(e) { _moveIncrement: function(e) {
this.currentIncrement.field.val(Math.max(0, Math.min(this.currentIncrement.max, parseInt(this.currentIncrement.val + e.pageY - this.currentIncrement.y, 10)))); this.currentIncrement.field.val(Math.max(0, Math.min(this.currentIncrement.max, parseInt(this.currentIncrement.val + e.pageY - this.currentIncrement.y, 10))));
this.change.apply(this, [e, this.currentIncrement.field.get(0)]); this._change.apply(this, [e, this.currentIncrement.field.get(0)]);
return false; return false;
}, },
upIncrement: function(e) { _upIncrement: function(e) {
this.currentIncrement.el.removeClass('ui-colorpicker-slider').find('input').focus(); this.currentIncrement.el.removeClass('ui-colorpicker-slider').find('input').focus();
this.change.apply(this, [e, this.currentIncrement.field.get(0)]); this._change.apply(this, [e, this.currentIncrement.field.get(0)]);
$(document).unbind('mouseup.cpSlider'); $(document).unbind('mouseup.cpSlider');
$(document).unbind('mousemove.cpSlider'); $(document).unbind('mousemove.cpSlider');
return false; return false;
}, },
downHue: function(e) { _downHue: function(e) {
this.currentHue = { this.currentHue = {
y: this.picker.find('div.ui-colorpicker-hue').offset().top y: this.picker.find('div.ui-colorpicker-hue').offset().top
}; };
this.change.apply(this, [e, this this._change.apply(this, [e, this
.fields .fields
.eq(4) .eq(4)
.val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10)) .val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10))
.get(0)]); .get(0)]);
var self = this; var self = this;
$(document).bind('mouseup.cpSlider', function(e) { return self.upHue.call(self, e); }); $(document).bind('mouseup.cpSlider', function(e) { return self._upHue.call(self, e); });
$(document).bind('mousemove.cpSlider', function(e) { return self.moveHue.call(self, e); }); $(document).bind('mousemove.cpSlider', function(e) { return self._moveHue.call(self, e); });
return false; return false;
}, },
moveHue: function(e) { _moveHue: function(e) {
this.change.apply(this, [e, this this._change.apply(this, [e, this
.fields .fields
.eq(4) .eq(4)
.val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10)) .val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10))
@ -231,19 +231,19 @@ $.widget("ui.colorpicker", {
return false; return false;
}, },
upHue: function(e) { _upHue: function(e) {
$(document).unbind('mouseup.cpSlider'); $(document).unbind('mouseup.cpSlider');
$(document).unbind('mousemove.cpSlider'); $(document).unbind('mousemove.cpSlider');
return false; return false;
}, },
downSelector: function(e) { _downSelector: function(e) {
var self = this; var self = this;
this.currentSelector = { this.currentSelector = {
pos: this.picker.find('div.ui-colorpicker-color').offset() pos: this.picker.find('div.ui-colorpicker-color').offset()
}; };
this.change.apply(this, [e, this this._change.apply(this, [e, this
.fields .fields
.eq(6) .eq(6)
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10)) .val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10))
@ -252,14 +252,14 @@ $.widget("ui.colorpicker", {
.val(parseInt(100*(Math.max(0,Math.min(150,(e.pageX - this.currentSelector.pos.left))))/150, 10)) .val(parseInt(100*(Math.max(0,Math.min(150,(e.pageX - this.currentSelector.pos.left))))/150, 10))
.get(0) .get(0)
]); ]);
$(document).bind('mouseup.cpSlider', function(e) { return self.upSelector.call(self, e); }); $(document).bind('mouseup.cpSlider', function(e) { return self._upSelector.call(self, e); });
$(document).bind('mousemove.cpSlider', function(e) { return self.moveSelector.call(self, e); }); $(document).bind('mousemove.cpSlider', function(e) { return self._moveSelector.call(self, e); });
return false; return false;
}, },
moveSelector: function(e) { _moveSelector: function(e) {
this.change.apply(this, [e, this this._change.apply(this, [e, this
.fields .fields
.eq(6) .eq(6)
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10)) .val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10))
@ -271,33 +271,33 @@ $.widget("ui.colorpicker", {
return false; return false;
}, },
upSelector: function(e) { _upSelector: function(e) {
$(document).unbind('mouseup.cpSlider'); $(document).unbind('mouseup.cpSlider');
$(document).unbind('mousemove.cpSlider'); $(document).unbind('mousemove.cpSlider');
return false; return false;
}, },
enterSubmit: function(e) { _enterSubmit: function(e) {
this.picker.find('div.ui-colorpicker-submit').addClass('ui-colorpicker-focus'); this.picker.find('div.ui-colorpicker-submit').addClass('ui-colorpicker-focus');
}, },
leaveSubmit: function(e) { _leaveSubmit: function(e) {
this.picker.find('div.ui-colorpicker-submit').removeClass('ui-colorpicker-focus'); this.picker.find('div.ui-colorpicker-submit').removeClass('ui-colorpicker-focus');
}, },
clickSubmit: function(e) { _clickSubmit: function(e) {
var col = this.color; var col = this.color;
this.origColor = col; this.origColor = col;
this.setCurrentColor(col); this._setCurrentColor(col);
this.trigger("submit", e, { options: this.options, hsb: col, hex: this.HSBToHex(col), rgb: this.HSBToRGB(col) }); this._trigger("submit", e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) });
return false; return false;
}, },
show: function(e) { _show: function(e) {
this.trigger("beforeShow", e, { options: this.options, hsb: this.color, hex: this.HSBToHex(this.color), rgb: this.HSBToRGB(this.color) }); this._trigger("beforeShow", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) });
var pos = this.element.offset(); var pos = this.element.offset();
var viewPort = this.getScroll(); var viewPort = this._getScroll();
var top = pos.top + this.element[0].offsetHeight; var top = pos.top + this.element[0].offsetHeight;
var left = pos.left; var left = pos.left;
if (top + 176 > viewPort.t + Math.min(viewPort.h,viewPort.ih)) { if (top + 176 > viewPort.t + Math.min(viewPort.h,viewPort.ih)) {
@ -307,26 +307,26 @@ $.widget("ui.colorpicker", {
left -= 356; left -= 356;
} }
this.picker.css({left: left + 'px', top: top + 'px'}); this.picker.css({left: left + 'px', top: top + 'px'});
if (this.trigger("show", e, { options: this.options, hsb: this.color, hex: this.HSBToHex(this.color), rgb: this.HSBToRGB(this.color) }) != false) { if (this._trigger("show", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) }) != false) {
this.picker.show(); this.picker.show();
} }
var self = this; var self = this;
$(document).bind('mousedown.colorpicker', function(e) { return self.hide.call(self, e); }); $(document).bind('mousedown.colorpicker', function(e) { return self._hide.call(self, e); });
return false; return false;
}, },
hide: function(e) { _hide: function(e) {
if (!this.isChildOf(this.picker[0], e.target, this.picker[0])) { if (!this._isChildOf(this.picker[0], e.target, this.picker[0])) {
if (this.trigger("hide", e, { options: this.options, hsb: this.color, hex: this.HSBToHex(this.color), rgb: this.HSBToRGB(this.color) }) != false) { if (this._trigger("hide", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) }) != false) {
this.picker.hide(); this.picker.hide();
} }
$(document).unbind('mousedown.colorpicker'); $(document).unbind('mousedown.colorpicker');
} }
}, },
isChildOf: function(parentEl, el, container) { _isChildOf: function(parentEl, el, container) {
if (parentEl == el) { if (parentEl == el) {
return true; return true;
} }
@ -344,7 +344,7 @@ $.widget("ui.colorpicker", {
} }
return false; return false;
}, },
getScroll: function() { _getScroll: function() {
var t,l,w,h,iw,ih; var t,l,w,h,iw,ih;
if (document.documentElement) { if (document.documentElement) {
t = document.documentElement.scrollTop; t = document.documentElement.scrollTop;
@ -361,28 +361,28 @@ $.widget("ui.colorpicker", {
ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0;
return { t: t, l: l, w: w, h: h, iw: iw, ih: ih }; return { t: t, l: l, w: w, h: h, iw: iw, ih: ih };
}, },
fixHSB: function(hsb) { _fixHSB: function(hsb) {
return { return {
h: Math.min(360, Math.max(0, hsb.h)), h: Math.min(360, Math.max(0, hsb.h)),
s: Math.min(100, Math.max(0, hsb.s)), s: Math.min(100, Math.max(0, hsb.s)),
b: Math.min(100, Math.max(0, hsb.b)) b: Math.min(100, Math.max(0, hsb.b))
}; };
}, },
fixRGB: function(rgb) { _fixRGB: function(rgb) {
return { return {
r: Math.min(255, Math.max(0, rgb.r)), r: Math.min(255, Math.max(0, rgb.r)),
g: Math.min(255, Math.max(0, rgb.g)), g: Math.min(255, Math.max(0, rgb.g)),
b: Math.min(255, Math.max(0, rgb.b)) b: Math.min(255, Math.max(0, rgb.b))
}; };
}, },
HexToRGB: function (hex) { _HexToRGB: function (hex) {
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16); var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)}; return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
}, },
HexToHSB: function(hex) { _HexToHSB: function(hex) {
return this.RGBToHSB(this.HexToRGB(hex)); return this._RGBToHSB(this._HexToRGB(hex));
}, },
RGBToHSB: function(rgb) { _RGBToHSB: function(rgb) {
var hsb = {}; var hsb = {};
hsb.b = Math.max(Math.max(rgb.r,rgb.g),rgb.b); hsb.b = Math.max(Math.max(rgb.r,rgb.g),rgb.b);
hsb.s = (hsb.b <= 0) ? 0 : Math.round(100*(hsb.b - Math.min(Math.min(rgb.r,rgb.g),rgb.b))/hsb.b); hsb.s = (hsb.b <= 0) ? 0 : Math.round(100*(hsb.b - Math.min(Math.min(rgb.r,rgb.g),rgb.b))/hsb.b);
@ -398,7 +398,7 @@ $.widget("ui.colorpicker", {
hsb.h = Math.round(hsb.h); hsb.h = Math.round(hsb.h);
return hsb; return hsb;
}, },
HSBToRGB: function(hsb) { _HSBToRGB: function(hsb) {
var rgb = {}; var rgb = {};
var h = Math.round(hsb.h); var h = Math.round(hsb.h);
var s = Math.round(hsb.s*255/100); var s = Math.round(hsb.s*255/100);
@ -420,7 +420,7 @@ $.widget("ui.colorpicker", {
} }
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)}; return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
}, },
RGBToHex: function(rgb) { _RGBToHex: function(rgb) {
var hex = [ var hex = [
rgb.r.toString(16), rgb.r.toString(16),
rgb.g.toString(16), rgb.g.toString(16),
@ -433,29 +433,29 @@ $.widget("ui.colorpicker", {
}); });
return hex.join(''); return hex.join('');
}, },
HSBToHex: function(hsb) { _HSBToHex: function(hsb) {
return this.RGBToHex(this.HSBToRGB(hsb)); return this._RGBToHex(this._HSBToRGB(hsb));
}, },
setColor: function(col) { setColor: function(col) {
if (typeof col == 'string') { if (typeof col == 'string') {
col = this.HexToHSB(col); col = this._HexToHSB(col);
} else if (col.r != undefined && col.g != undefined && col.b != undefined) { } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
col = this.RGBToHSB(col); col = this._RGBToHSB(col);
} else if (col.h != undefined && col.s != undefined && col.b != undefined) { } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
col = this.fixHSB(col); col = this._fixHSB(col);
} else { } else {
return this; return this;
} }
this.color = col; this.color = col;
this.origColor = col; this.origColor = col;
this.fillRGBFields(col); this._fillRGBFields(col);
this.fillHSBFields(col); this._fillHSBFields(col);
this.fillHexFields(col); this._fillHexFields(col);
this.setHue(col); this._setHue(col);
this.setSelector(col); this._setSelector(col);
this.setCurrentColor(col); this._setCurrentColor(col);
this.setNewColor(col); this._setNewColor(col);
} }

View File

@ -13,7 +13,7 @@
(function($) { (function($) {
$.widget("ui.draggable", $.extend({}, $.ui.mouse, { $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
init: function() { _init: function() {
if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
this.element[0].style.position = 'relative'; this.element[0].style.position = 'relative';
@ -90,7 +90,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + (this.scrollLeftParent[0].scrollLeft || 0) left: p.left - (parseInt(this.helper.css("left"),10) || 0) + (this.scrollLeftParent[0].scrollLeft || 0)
} : { top: 0, left: 0 }; } : { top: 0, left: 0 };
this.originalPosition = this.generatePosition(e); //Generate the original position this.originalPosition = this._generatePosition(e); //Generate the original position
this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size
if(o.cursorAt) { if(o.cursorAt) {
@ -129,7 +129,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
} }
//Call plugins and callbacks //Call plugins and callbacks
this.propagate("start", e); this._propagate("start", e);
this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size
if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e); if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);
@ -138,7 +138,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
return true; return true;
}, },
convertPositionTo: function(d, pos) { _convertPositionTo: function(d, pos) {
if(!pos) pos = this.position; if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1; var mod = d == "absolute" ? 1 : -1;
@ -162,7 +162,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
) )
}; };
}, },
generatePosition: function(e) { _generatePosition: function(e) {
var o = this.options; var o = this.options;
var position = { var position = {
@ -210,11 +210,11 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
mouseDrag: function(e) { mouseDrag: function(e) {
//Compute the helpers position //Compute the helpers position
this.position = this.generatePosition(e); this.position = this._generatePosition(e);
this.positionAbs = this.convertPositionTo("absolute"); this.positionAbs = this._convertPositionTo("absolute");
//Call plugins and callbacks and use the resulting position if something is returned //Call plugins and callbacks and use the resulting position if something is returned
this.position = this.propagate("drag", e) || this.position; 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 != "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(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
@ -232,17 +232,17 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true) { if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true) {
var self = this; var self = this;
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10) || 500, function() { $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10) || 500, function() {
self.propagate("stop", e); self._propagate("stop", e);
self.clear(); self._clear();
}); });
} else { } else {
this.propagate("stop", e); this._propagate("stop", e);
this.clear(); this._clear();
} }
return false; return false;
}, },
clear: function() { _clear: function() {
this.helper.removeClass("ui-draggable-dragging"); this.helper.removeClass("ui-draggable-dragging");
if(this.options.helper != 'original' && !this.cancelHelperRemoval) this.helper.remove(); if(this.options.helper != 'original' && !this.cancelHelperRemoval) this.helper.remove();
//if($.ui.ddmanager) $.ui.ddmanager.current = null; //if($.ui.ddmanager) $.ui.ddmanager.current = null;
@ -260,9 +260,9 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
options: this.options options: this.options
}; };
}, },
propagate: function(n,e) { _propagate: function(n,e) {
$.ui.plugin.call(this, n, [e, this.uiHash()]); $.ui.plugin.call(this, n, [e, this.uiHash()]);
if(n == "drag") this.positionAbs = this.convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins if(n == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [e, this.uiHash()], this.options[n]); return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [e, this.uiHash()], this.options[n]);
}, },
destroy: function() { destroy: function() {
@ -435,10 +435,10 @@ $.ui.plugin.add("draggable", "snap", {
var bs = Math.abs(b - y1) <= d; var bs = Math.abs(b - y1) <= d;
var ls = Math.abs(l - x2) <= d; var ls = Math.abs(l - x2) <= d;
var rs = Math.abs(r - x1) <= d; var rs = Math.abs(r - x1) <= d;
if(ts) ui.position.top = inst.convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top; if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
if(bs) ui.position.top = inst.convertPositionTo("relative", { top: b, left: 0 }).top; if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
if(ls) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left; if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
if(rs) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: r }).left; if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
} }
var first = (ts || bs || ls || rs); var first = (ts || bs || ls || rs);
@ -448,10 +448,10 @@ $.ui.plugin.add("draggable", "snap", {
var bs = Math.abs(b - y2) <= d; var bs = Math.abs(b - y2) <= d;
var ls = Math.abs(l - x1) <= d; var ls = Math.abs(l - x1) <= d;
var rs = Math.abs(r - x2) <= d; var rs = Math.abs(r - x2) <= d;
if(ts) ui.position.top = inst.convertPositionTo("relative", { top: t, left: 0 }).top; if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
if(bs) ui.position.top = inst.convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top; if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
if(ls) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: l }).left; if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
if(rs) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left; if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
} }
if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
@ -476,7 +476,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
shouldRevert: sortable.options.revert shouldRevert: sortable.options.revert
}); });
sortable.refreshItems(); //Do a one-time refresh at start to refresh the containerCache sortable.refreshItems(); //Do a one-time refresh at start to refresh the containerCache
sortable.propagate("activate", e, inst); sortable._propagate("activate", e, inst);
} }
}); });
@ -499,7 +499,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
this.instance.options.helper = this.instance.options._helper; this.instance.options.helper = this.instance.options._helper;
} else { } else {
this.instance.propagate("deactivate", e, inst); this.instance._propagate("deactivate", e, inst);
} }
}); });
@ -543,7 +543,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
inst.propagate("toSortable", e); inst._propagate("toSortable", e);
} }
@ -565,7 +565,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
this.instance.currentItem.remove(); this.instance.currentItem.remove();
if(this.instance.placeholder) this.instance.placeholder.remove(); if(this.instance.placeholder) this.instance.placeholder.remove();
inst.propagate("fromSortable", e); inst._propagate("fromSortable", e);
} }
}; };

View File

@ -14,7 +14,7 @@
(function($) { (function($) {
$.widget("ui.droppable", { $.widget("ui.droppable", {
init: function() { _init: function() {
var o = this.options, accept = o.accept; var o = this.options, accept = o.accept;
this.isover = 0; this.isout = 1; this.isover = 0; this.isout = 1;
@ -55,7 +55,7 @@ $.widget("ui.droppable", {
.removeData("droppable") .removeData("droppable")
.unbind(".droppable"); .unbind(".droppable");
}, },
over: function(e) { _over: function(e) {
var draggable = $.ui.ddmanager.current; var draggable = $.ui.ddmanager.current;
if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
@ -66,7 +66,7 @@ $.widget("ui.droppable", {
} }
}, },
out: function(e) { _out: function(e) {
var draggable = $.ui.ddmanager.current; var draggable = $.ui.ddmanager.current;
if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
@ -77,7 +77,7 @@ $.widget("ui.droppable", {
} }
}, },
drop: function(e,custom) { _drop: function(e,custom) {
var draggable = custom || $.ui.ddmanager.current; var draggable = custom || $.ui.ddmanager.current;
if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
@ -100,14 +100,14 @@ $.widget("ui.droppable", {
return false; return false;
}, },
activate: function(e) { _activate: function(e) {
var draggable = $.ui.ddmanager.current; var draggable = $.ui.ddmanager.current;
$.ui.plugin.call(this, 'activate', [e, this.ui(draggable)]); $.ui.plugin.call(this, 'activate', [e, this.ui(draggable)]);
if(draggable) this.element.triggerHandler("dropactivate", [e, this.ui(draggable)], this.options.activate); if(draggable) this.element.triggerHandler("dropactivate", [e, this.ui(draggable)], this.options.activate);
}, },
deactivate: function(e) { _deactivate: function(e) {
var draggable = $.ui.ddmanager.current; var draggable = $.ui.ddmanager.current;
$.ui.plugin.call(this, 'deactivate', [e, this.ui(draggable)]); $.ui.plugin.call(this, 'deactivate', [e, this.ui(draggable)]);
@ -188,7 +188,7 @@ $.ui.ddmanager = {
m[i].offset = m[i].element.offset(); m[i].offset = m[i].element.offset();
m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight }; m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
if(type == "dragstart" || type == "sortactivate") m[i].activate.call(m[i], e); //Activate the droppable if used directly from draggables if(type == "dragstart" || type == "sortactivate") m[i]._activate.call(m[i], e); //Activate the droppable if used directly from draggables
} }
@ -200,11 +200,11 @@ $.ui.ddmanager = {
if(!this.options) return; if(!this.options) return;
if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
dropped = this.drop.call(this, e); dropped = this._drop.call(this, e);
if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) { if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
this.isout = 1; this.isover = 0; this.isout = 1; this.isover = 0;
this.deactivate.call(this, e); this._deactivate.call(this, e);
} }
}); });
@ -239,17 +239,17 @@ $.ui.ddmanager = {
if (parentInstance && c == 'isover') { if (parentInstance && c == 'isover') {
parentInstance['isover'] = 0; parentInstance['isover'] = 0;
parentInstance['isout'] = 1; parentInstance['isout'] = 1;
parentInstance.out.call(parentInstance, e); parentInstance._out.call(parentInstance, e);
} }
this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0; this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
this[c == "isover" ? "over" : "out"].call(this, e); this[c == "isover" ? "_over" : "_out"].call(this, e);
// we just moved out of a greedy child // we just moved out of a greedy child
if (parentInstance && c == 'isout') { if (parentInstance && c == 'isout') {
parentInstance['isout'] = 0; parentInstance['isout'] = 0;
parentInstance['isover'] = 1; parentInstance['isover'] = 1;
parentInstance.over.call(parentInstance, e); parentInstance._over.call(parentInstance, e);
} }
}); });

View File

@ -25,7 +25,7 @@ function contains(a, b) {
}; };
$.widget("ui.sortable", $.extend({}, $.ui.mouse, { $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
init: function() { _init: function() {
var o = this.options; var o = this.options;
this.containerCache = {}; this.containerCache = {};
@ -58,7 +58,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
}; };
}, },
propagate: function(n,e,inst, noPropagation) { _propagate: function(n,e,inst, noPropagation) {
$.ui.plugin.call(this, n, [e, this.ui(inst)]); $.ui.plugin.call(this, n, [e, this.ui(inst)]);
if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]); if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]);
}, },
@ -339,20 +339,20 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
this.currentContainer = this.containers[i]; this.currentContainer = this.containers[i];
itemWithLeastDistance ? this.options.sortIndicator.call(this, e, itemWithLeastDistance, null, true) : this.options.sortIndicator.call(this, e, null, this.containers[i].element, true); itemWithLeastDistance ? this.options.sortIndicator.call(this, e, itemWithLeastDistance, null, true) : this.options.sortIndicator.call(this, e, null, this.containers[i].element, true);
this.propagate("change", e); //Call plugins and callbacks this._propagate("change", e); //Call plugins and callbacks
this.containers[i].propagate("change", e, this); //Call plugins and callbacks this.containers[i]._propagate("change", e, this); //Call plugins and callbacks
//Update the placeholder //Update the placeholder
this.options.placeholder.update(this.currentContainer, this.placeholder); this.options.placeholder.update(this.currentContainer, this.placeholder);
} }
this.containers[i].propagate("over", e, this); this.containers[i]._propagate("over", e, this);
this.containers[i].containerCache.over = 1; this.containers[i].containerCache.over = 1;
} }
} else { } else {
if(this.containers[i].containerCache.over) { if(this.containers[i].containerCache.over) {
this.containers[i].propagate("out", e, this); this.containers[i]._propagate("out", e, this);
this.containers[i].containerCache.over = 0; this.containers[i].containerCache.over = 0;
} }
} }
@ -435,7 +435,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
left: po.left + this.offsetParentBorders.left left: po.left + this.offsetParentBorders.left
}; };
this.updateOriginalPosition = this.originalPosition = this.generatePosition(e); //Generate the original position this.updateOriginalPosition = this.originalPosition = this._generatePosition(e); //Generate the original position
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; //Cache the former DOM position this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; //Cache the former DOM position
//If o.placeholder is used, create a new element at the given position with the class //If o.placeholder is used, create a new element at the given position with the class
@ -451,7 +451,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
this.createPlaceholder(); this.createPlaceholder();
//Call plugins and callbacks //Call plugins and callbacks
this.propagate("start", e); this._propagate("start", e);
if(!this._preserveHelperProportions) this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size if(!this._preserveHelperProportions) this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size
if(o.cursorAt) { if(o.cursorAt) {
@ -490,7 +490,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
//Post 'activate' events to possible containers //Post 'activate' events to possible containers
if(!noActivation) { if(!noActivation) {
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i].propagate("activate", e, this); } for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._propagate("activate", e, this); }
} }
//Prepare possible droppables //Prepare possible droppables
@ -505,7 +505,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
}, },
convertPositionTo: function(d, pos) { _convertPositionTo: function(d, pos) {
if(!pos) pos = this.position; if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1; var mod = d == "absolute" ? 1 : -1;
return { return {
@ -524,7 +524,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
}; };
}, },
generatePosition: function(e) { _generatePosition: function(e) {
var o = this.options; var o = this.options;
var position = { var position = {
@ -569,14 +569,14 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
mouseDrag: function(e) { mouseDrag: function(e) {
//Compute the helpers position //Compute the helpers position
this.position = this.generatePosition(e); this.position = this._generatePosition(e);
this.positionAbs = this.convertPositionTo("absolute"); this.positionAbs = this._convertPositionTo("absolute");
//Call the internal plugins //Call the internal plugins
$.ui.plugin.call(this, "sort", [e, this.ui()]); $.ui.plugin.call(this, "sort", [e, this.ui()]);
//Regenerate the absolute position used for position checks //Regenerate the absolute position used for position checks
this.positionAbs = this.convertPositionTo("absolute"); this.positionAbs = this._convertPositionTo("absolute");
//Set the helper's position //Set the helper's position
this.helper[0].style.left = this.position.left+'px'; this.helper[0].style.left = this.position.left+'px';
@ -593,11 +593,11 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
&& (this.options.type == 'semi-dynamic' ? !contains(this.element[0], this.items[i].item[0]) : true) && (this.options.type == 'semi-dynamic' ? !contains(this.element[0], this.items[i].item[0]) : true)
) { ) {
this.updateOriginalPosition = this.generatePosition(e); this.updateOriginalPosition = this._generatePosition(e);
this.direction = intersection == 1 ? "down" : "up"; this.direction = intersection == 1 ? "down" : "up";
this.options.sortIndicator.call(this, e, this.items[i]); this.options.sortIndicator.call(this, e, this.items[i]);
this.propagate("change", e); //Call plugins and callbacks this._propagate("change", e); //Call plugins and callbacks
break; break;
} }
} }
@ -647,17 +647,17 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft), left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
}, parseInt(this.options.revert, 10) || 500, function() { }, parseInt(this.options.revert, 10) || 500, function() {
self.clear(e); self._clear(e);
}); });
} else { } else {
this.clear(e, noPropagation); this._clear(e, noPropagation);
} }
return false; return false;
}, },
clear: function(e, noPropagation) { _clear: function(e, noPropagation) {
//We first have to update the dom position of the actual currentItem //We first have to update the dom position of the actual currentItem
if(!this._noFinalSort) this.placeholder.before(this.currentItem); if(!this._noFinalSort) this.placeholder.before(this.currentItem);
@ -668,38 +668,38 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
else else
this.currentItem.show(); this.currentItem.show();
if(this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) this.propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed if(this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) this._propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed
if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
this.propagate("remove", e, null, noPropagation); this._propagate("remove", e, null, noPropagation);
for (var i = this.containers.length - 1; i >= 0; i--){ for (var i = this.containers.length - 1; i >= 0; i--){
if(contains(this.containers[i].element[0], this.currentItem[0])) { if(contains(this.containers[i].element[0], this.currentItem[0])) {
this.containers[i].propagate("update", e, this, noPropagation); this.containers[i]._propagate("update", e, this, noPropagation);
this.containers[i].propagate("receive", e, this, noPropagation); this.containers[i]._propagate("receive", e, this, noPropagation);
} }
}; };
}; };
//Post events to containers //Post events to containers
for (var i = this.containers.length - 1; i >= 0; i--){ for (var i = this.containers.length - 1; i >= 0; i--){
this.containers[i].propagate("deactivate", e, this, noPropagation); this.containers[i]._propagate("deactivate", e, this, noPropagation);
if(this.containers[i].containerCache.over) { if(this.containers[i].containerCache.over) {
this.containers[i].propagate("out", e, this); this.containers[i]._propagate("out", e, this);
this.containers[i].containerCache.over = 0; this.containers[i].containerCache.over = 0;
} }
} }
this.dragging = false; this.dragging = false;
if(this.cancelHelperRemoval) { if(this.cancelHelperRemoval) {
this.propagate("beforeStop", e, null, noPropagation); this._propagate("beforeStop", e, null, noPropagation);
this.propagate("stop", e, null, noPropagation); this._propagate("stop", e, null, noPropagation);
return false; return false;
} }
this.propagate("beforeStop", e, null, noPropagation); this._propagate("beforeStop", e, null, noPropagation);
this.placeholder.remove(); this.placeholder.remove();
if(this.options.helper != "original") this.helper.remove(); this.helper = null; if(this.options.helper != "original") this.helper.remove(); this.helper = null;
this.propagate("stop", e, null, noPropagation); this._propagate("stop", e, null, noPropagation);
return true; return true;