\r
$.widget("ui.colorpicker", {\r
\r
- init: function() {\r
+ _init: function() {\r
\r
this.charMin = 65;\r
var o = this.options, self = this,\r
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>';\r
\r
if (typeof o.color == 'string') {\r
- this.color = this.HexToHSB(o.color);\r
+ this.color = this._HexToHSB(o.color);\r
} else if (o.color.r != undefined && o.color.g != undefined && o.color.b != undefined) {\r
- this.color = this.RGBToHSB(o.color);\r
+ this.color = this._RGBToHSB(o.color);\r
} else if (o.color.h != undefined && o.color.s != undefined && o.color.b != undefined) {\r
- this.color = this.fixHSB(o.color);\r
+ this.color = this._fixHSB(o.color);\r
} else {\r
return this;\r
}\r
}\r
\r
this.fields = this.picker.find('input')\r
- .bind('keydown', function(e) { return self.keyDown.call(self, e); })\r
- .bind('change', function(e) { return self.change.call(self, e); })\r
- .bind('blur', function(e) { return self.blur.call(self, e); })\r
- .bind('focus', function(e) { return self.focus.call(self, e); });\r
+ .bind('keydown', function(e) { return self._keyDown.call(self, e); })\r
+ .bind('change', function(e) { return self._change.call(self, e); })\r
+ .bind('blur', function(e) { return self._blur.call(self, e); })\r
+ .bind('focus', function(e) { return self._focus.call(self, e); });\r
\r
- this.picker.find('span').bind('mousedown', function(e) { return self.downIncrement.call(self, e); });\r
+ this.picker.find('span').bind('mousedown', function(e) { return self._downIncrement.call(self, e); });\r
\r
- this.selector = this.picker.find('div.ui-colorpicker-color').bind('mousedown', function(e) { return self.downSelector.call(self, e); });\r
+ this.selector = this.picker.find('div.ui-colorpicker-color').bind('mousedown', function(e) { return self._downSelector.call(self, e); });\r
this.selectorIndic = this.selector.find('div div');\r
this.hue = this.picker.find('div.ui-colorpicker-hue div');\r
- this.picker.find('div.ui-colorpicker-hue').bind('mousedown', function(e) { return self.downHue.call(self, e); });\r
+ this.picker.find('div.ui-colorpicker-hue').bind('mousedown', function(e) { return self._downHue.call(self, e); });\r
\r
this.newColor = this.picker.find('div.ui-colorpicker-new-color');\r
this.currentColor = this.picker.find('div.ui-colorpicker-current-color');\r
\r
this.picker.find('div.ui-colorpicker-submit')\r
- .bind('mouseenter', function(e) { return self.enterSubmit.call(self, e); })\r
- .bind('mouseleave', function(e) { return self.leaveSubmit.call(self, e); })\r
- .bind('click', function(e) { return self.clickSubmit.call(self, e); });\r
+ .bind('mouseenter', function(e) { return self._enterSubmit.call(self, e); })\r
+ .bind('mouseleave', function(e) { return self._leaveSubmit.call(self, e); })\r
+ .bind('click', function(e) { return self._clickSubmit.call(self, e); });\r
\r
- this.fillRGBFields(this.color);\r
- this.fillHSBFields(this.color);\r
- this.fillHexFields(this.color);\r
- this.setHue(this.color);\r
- this.setSelector(this.color);\r
- this.setCurrentColor(this.color);\r
- this.setNewColor(this.color);\r
+ this._fillRGBFields(this.color);\r
+ this._fillHSBFields(this.color);\r
+ this._fillHexFields(this.color);\r
+ this._setHue(this.color);\r
+ this._setSelector(this.color);\r
+ this._setCurrentColor(this.color);\r
+ this._setNewColor(this.color);\r
\r
if (o.flat) {\r
this.picker.css({\r
display: 'block'\r
});\r
} else {\r
- $(this.element).bind(o.eventName+".colorpicker", function(e) { return self.show.call(self, e); });\r
+ $(this.element).bind(o.eventName+".colorpicker", function(e) { return self._show.call(self, e); });\r
}\r
\r
},\r
\r
},\r
\r
- fillRGBFields: function(hsb) {\r
- var rgb = this.HSBToRGB(hsb);\r
+ _fillRGBFields: function(hsb) {\r
+ var rgb = this._HSBToRGB(hsb);\r
this.fields\r
.eq(1).val(rgb.r).end()\r
.eq(2).val(rgb.g).end()\r
.eq(3).val(rgb.b).end();\r
},\r
- fillHSBFields: function(hsb) {\r
+ _fillHSBFields: function(hsb) {\r
this.fields\r
.eq(4).val(hsb.h).end()\r
.eq(5).val(hsb.s).end()\r
.eq(6).val(hsb.b).end();\r
},\r
- fillHexFields: function (hsb) {\r
+ _fillHexFields: function (hsb) {\r
this.fields\r
- .eq(0).val(this.HSBToHex(hsb)).end();\r
+ .eq(0).val(this._HSBToHex(hsb)).end();\r
},\r
- setSelector: function(hsb) {\r
- this.selector.css('backgroundColor', '#' + this.HSBToHex({h: hsb.h, s: 100, b: 100}));\r
+ _setSelector: function(hsb) {\r
+ this.selector.css('backgroundColor', '#' + this._HSBToHex({h: hsb.h, s: 100, b: 100}));\r
this.selectorIndic.css({\r
left: parseInt(150 * hsb.s/100, 10),\r
top: parseInt(150 * (100-hsb.b)/100, 10)\r
});\r
},\r
- setHue: function(hsb) {\r
+ _setHue: function(hsb) {\r
this.hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));\r
},\r
- setCurrentColor: function(hsb) {\r
- this.currentColor.css('backgroundColor', '#' + this.HSBToHex(hsb));\r
+ _setCurrentColor: function(hsb) {\r
+ this.currentColor.css('backgroundColor', '#' + this._HSBToHex(hsb));\r
},\r
- setNewColor: function(hsb) {\r
- this.newColor.css('backgroundColor', '#' + this.HSBToHex(hsb));\r
+ _setNewColor: function(hsb) {\r
+ this.newColor.css('backgroundColor', '#' + this._HSBToHex(hsb));\r
},\r
- keyDown: function(e) {\r
+ _keyDown: function(e) {\r
var pressedKey = e.charCode || e.keyCode || -1;\r
if ((pressedKey >= this.charMin && pressedKey <= 90) || pressedKey == 32) {\r
return false;\r
}\r
},\r
- change: function(e, target) {\r
+ _change: function(e, target) {\r
\r
var col;\r
target = target || e.target;\r
if (target.parentNode.className.indexOf('-hex') > 0) {\r
- this.color = col = this.HexToHSB(this.value);\r
- this.fillRGBFields(col.color);\r
- this.fillHSBFields(col);\r
+ this.color = col = this._HexToHSB(this.value);\r
+ this._fillRGBFields(col.color);\r
+ this._fillHSBFields(col);\r
} else if (target.parentNode.className.indexOf('-hsb') > 0) {\r
- this.color = col = this.fixHSB({\r
+ this.color = col = this._fixHSB({\r
h: parseInt(this.fields.eq(4).val(), 10),\r
s: parseInt(this.fields.eq(5).val(), 10),\r
b: parseInt(this.fields.eq(6).val(), 10)\r
});\r
- this.fillRGBFields(col);\r
- this.fillHexFields(col);\r
+ this._fillRGBFields(col);\r
+ this._fillHexFields(col);\r
} else {\r
- this.color = col = this.RGBToHSB(this.fixRGB({\r
+ this.color = col = this._RGBToHSB(this._fixRGB({\r
r: parseInt(this.fields.eq(1).val(), 10),\r
g: parseInt(this.fields.eq(2).val(), 10),\r
b: parseInt(this.fields.eq(3).val(), 10)\r
}));\r
- this.fillHexFields(col);\r
- this.fillHSBFields(col);\r
+ this._fillHexFields(col);\r
+ this._fillHSBFields(col);\r
}\r
- this.setSelector(col);\r
- this.setHue(col);\r
- this.setNewColor(col);\r
+ this._setSelector(col);\r
+ this._setHue(col);\r
+ this._setNewColor(col);\r
\r
- this.trigger('change', e, { options: this.options, hsb: col, hex: this.HSBToHex(col), rgb: this.HSBToRGB(col) });\r
+ this._trigger('change', e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) });\r
},\r
- blur: function(e) {\r
+ _blur: function(e) {\r
\r
var col = this.color;\r
- this.fillRGBFields(col);\r
- this.fillHSBFields(col);\r
- this.fillHexFields(col);\r
- this.setHue(col);\r
- this.setSelector(col);\r
- this.setNewColor(col);\r
+ this._fillRGBFields(col);\r
+ this._fillHSBFields(col);\r
+ this._fillHexFields(col);\r
+ this._setHue(col);\r
+ this._setSelector(col);\r
+ this._setNewColor(col);\r
this.fields.parent().removeClass('ui-colorpicker-focus');\r
\r
},\r
- focus: function(e) {\r
+ _focus: function(e) {\r
\r
this.charMin = e.target.parentNode.className.indexOf('-hex') > 0 ? 70 : 65;\r
this.fields.parent().removeClass('ui-colorpicker-focus');\r
$(e.target.parentNode).addClass('ui-colorpicker-focus');\r
\r
},\r
- downIncrement: function(e) {\r
+ _downIncrement: function(e) {\r
\r
var field = $(e.target).parent().find('input').focus(), self = this;\r
this.currentIncrement = {\r
field: field,\r
val: parseInt(field.val(), 10)\r
};\r
- $(document).bind('mouseup.cpSlider', function(e) { return self.upIncrement.call(self, e); });\r
- $(document).bind('mousemove.cpSlider', function(e) { return self.moveIncrement.call(self, e); });\r
+ $(document).bind('mouseup.cpSlider', function(e) { return self._upIncrement.call(self, e); });\r
+ $(document).bind('mousemove.cpSlider', function(e) { return self._moveIncrement.call(self, e); });\r
return false;\r
\r
},\r
- moveIncrement: function(e) {\r
+ _moveIncrement: function(e) {\r
this.currentIncrement.field.val(Math.max(0, Math.min(this.currentIncrement.max, parseInt(this.currentIncrement.val + e.pageY - this.currentIncrement.y, 10))));\r
- this.change.apply(this, [e, this.currentIncrement.field.get(0)]);\r
+ this._change.apply(this, [e, this.currentIncrement.field.get(0)]);\r
return false;\r
},\r
- upIncrement: function(e) {\r
+ _upIncrement: function(e) {\r
this.currentIncrement.el.removeClass('ui-colorpicker-slider').find('input').focus();\r
- this.change.apply(this, [e, this.currentIncrement.field.get(0)]);\r
+ this._change.apply(this, [e, this.currentIncrement.field.get(0)]);\r
$(document).unbind('mouseup.cpSlider');\r
$(document).unbind('mousemove.cpSlider');\r
return false;\r
},\r
- downHue: function(e) {\r
+ _downHue: function(e) {\r
\r
this.currentHue = {\r
y: this.picker.find('div.ui-colorpicker-hue').offset().top\r
};\r
\r
- this.change.apply(this, [e, this\r
+ this._change.apply(this, [e, this\r
.fields\r
.eq(4)\r
.val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10))\r
.get(0)]);\r
\r
var self = this;\r
- $(document).bind('mouseup.cpSlider', function(e) { return self.upHue.call(self, e); });\r
- $(document).bind('mousemove.cpSlider', function(e) { return self.moveHue.call(self, e); });\r
+ $(document).bind('mouseup.cpSlider', function(e) { return self._upHue.call(self, e); });\r
+ $(document).bind('mousemove.cpSlider', function(e) { return self._moveHue.call(self, e); });\r
return false;\r
\r
},\r
- moveHue: function(e) {\r
+ _moveHue: function(e) {\r
\r
- this.change.apply(this, [e, this\r
+ this._change.apply(this, [e, this\r
.fields\r
.eq(4)\r
.val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10))\r
return false;\r
\r
},\r
- upHue: function(e) {\r
+ _upHue: function(e) {\r
$(document).unbind('mouseup.cpSlider');\r
$(document).unbind('mousemove.cpSlider');\r
return false;\r
},\r
- downSelector: function(e) {\r
+ _downSelector: function(e) {\r
\r
var self = this;\r
this.currentSelector = {\r
pos: this.picker.find('div.ui-colorpicker-color').offset()\r
};\r
\r
- this.change.apply(this, [e, this\r
+ this._change.apply(this, [e, this\r
.fields\r
.eq(6)\r
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10))\r
.val(parseInt(100*(Math.max(0,Math.min(150,(e.pageX - this.currentSelector.pos.left))))/150, 10))\r
.get(0)\r
]);\r
- $(document).bind('mouseup.cpSlider', function(e) { return self.upSelector.call(self, e); });\r
- $(document).bind('mousemove.cpSlider', function(e) { return self.moveSelector.call(self, e); });\r
+ $(document).bind('mouseup.cpSlider', function(e) { return self._upSelector.call(self, e); });\r
+ $(document).bind('mousemove.cpSlider', function(e) { return self._moveSelector.call(self, e); });\r
return false;\r
\r
},\r
- moveSelector: function(e) {\r
+ _moveSelector: function(e) {\r
\r
- this.change.apply(this, [e, this\r
+ this._change.apply(this, [e, this\r
.fields\r
.eq(6)\r
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10))\r
return false;\r
\r
},\r
- upSelector: function(e) {\r
+ _upSelector: function(e) {\r
$(document).unbind('mouseup.cpSlider');\r
$(document).unbind('mousemove.cpSlider');\r
return false;\r
},\r
- enterSubmit: function(e) {\r
+ _enterSubmit: function(e) {\r
this.picker.find('div.ui-colorpicker-submit').addClass('ui-colorpicker-focus');\r
},\r
- leaveSubmit: function(e) {\r
+ _leaveSubmit: function(e) {\r
this.picker.find('div.ui-colorpicker-submit').removeClass('ui-colorpicker-focus');\r
},\r
- clickSubmit: function(e) {\r
+ _clickSubmit: function(e) {\r
\r
var col = this.color;\r
this.origColor = col;\r
- this.setCurrentColor(col);\r
+ this._setCurrentColor(col);\r
\r
- this.trigger("submit", e, { options: this.options, hsb: col, hex: this.HSBToHex(col), rgb: this.HSBToRGB(col) });\r
+ this._trigger("submit", e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) });\r
return false;\r
\r
},\r
- show: function(e) {\r
+ _show: function(e) {\r
\r
- this.trigger("beforeShow", e, { options: this.options, hsb: this.color, hex: this.HSBToHex(this.color), rgb: this.HSBToRGB(this.color) });\r
+ this._trigger("beforeShow", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) });\r
\r
var pos = this.element.offset();\r
- var viewPort = this.getScroll();\r
+ var viewPort = this._getScroll();\r
var top = pos.top + this.element[0].offsetHeight;\r
var left = pos.left;\r
if (top + 176 > viewPort.t + Math.min(viewPort.h,viewPort.ih)) {\r
left -= 356;\r
}\r
this.picker.css({left: left + 'px', top: top + 'px'});\r
- if (this.trigger("show", e, { options: this.options, hsb: this.color, hex: this.HSBToHex(this.color), rgb: this.HSBToRGB(this.color) }) != false) {\r
+ if (this._trigger("show", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) }) != false) {\r
this.picker.show();\r
}\r
\r
var self = this;\r
- $(document).bind('mousedown.colorpicker', function(e) { return self.hide.call(self, e); });\r
+ $(document).bind('mousedown.colorpicker', function(e) { return self._hide.call(self, e); });\r
return false;\r
\r
},\r
- hide: function(e) {\r
+ _hide: function(e) {\r
\r
- if (!this.isChildOf(this.picker[0], e.target, this.picker[0])) {\r
- if (this.trigger("hide", e, { options: this.options, hsb: this.color, hex: this.HSBToHex(this.color), rgb: this.HSBToRGB(this.color) }) != false) {\r
+ if (!this._isChildOf(this.picker[0], e.target, this.picker[0])) {\r
+ if (this._trigger("hide", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) }) != false) {\r
this.picker.hide();\r
}\r
$(document).unbind('mousedown.colorpicker');\r
}\r
\r
},\r
- isChildOf: function(parentEl, el, container) {\r
+ _isChildOf: function(parentEl, el, container) {\r
if (parentEl == el) {\r
return true;\r
}\r
}\r
return false;\r
},\r
- getScroll: function() {\r
+ _getScroll: function() {\r
var t,l,w,h,iw,ih;\r
if (document.documentElement) {\r
t = document.documentElement.scrollTop;\r
ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0;\r
return { t: t, l: l, w: w, h: h, iw: iw, ih: ih };\r
},\r
- fixHSB: function(hsb) {\r
+ _fixHSB: function(hsb) {\r
return {\r
h: Math.min(360, Math.max(0, hsb.h)),\r
s: Math.min(100, Math.max(0, hsb.s)),\r
b: Math.min(100, Math.max(0, hsb.b))\r
};\r
}, \r
- fixRGB: function(rgb) {\r
+ _fixRGB: function(rgb) {\r
return {\r
r: Math.min(255, Math.max(0, rgb.r)),\r
g: Math.min(255, Math.max(0, rgb.g)),\r
b: Math.min(255, Math.max(0, rgb.b))\r
};\r
}, \r
- HexToRGB: function (hex) {\r
+ _HexToRGB: function (hex) {\r
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);\r
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};\r
},\r
- HexToHSB: function(hex) {\r
- return this.RGBToHSB(this.HexToRGB(hex));\r
+ _HexToHSB: function(hex) {\r
+ return this._RGBToHSB(this._HexToRGB(hex));\r
},\r
- RGBToHSB: function(rgb) {\r
+ _RGBToHSB: function(rgb) {\r
var hsb = {};\r
hsb.b = Math.max(Math.max(rgb.r,rgb.g),rgb.b);\r
hsb.s = (hsb.b <= 0) ? 0 : Math.round(100*(hsb.b - Math.min(Math.min(rgb.r,rgb.g),rgb.b))/hsb.b);\r
hsb.h = Math.round(hsb.h);\r
return hsb;\r
},\r
- HSBToRGB: function(hsb) {\r
+ _HSBToRGB: function(hsb) {\r
var rgb = {};\r
var h = Math.round(hsb.h);\r
var s = Math.round(hsb.s*255/100);\r
}\r
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};\r
},\r
- RGBToHex: function(rgb) {\r
+ _RGBToHex: function(rgb) {\r
var hex = [\r
rgb.r.toString(16),\r
rgb.g.toString(16),\r
});\r
return hex.join('');\r
},\r
- HSBToHex: function(hsb) {\r
- return this.RGBToHex(this.HSBToRGB(hsb));\r
+ _HSBToHex: function(hsb) {\r
+ return this._RGBToHex(this._HSBToRGB(hsb));\r
},\r
setColor: function(col) {\r
if (typeof col == 'string') {\r
- col = this.HexToHSB(col);\r
+ col = this._HexToHSB(col);\r
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {\r
- col = this.RGBToHSB(col);\r
+ col = this._RGBToHSB(col);\r
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {\r
- col = this.fixHSB(col);\r
+ col = this._fixHSB(col);\r
} else {\r
return this;\r
}\r
\r
this.color = col;\r
this.origColor = col;\r
- this.fillRGBFields(col);\r
- this.fillHSBFields(col);\r
- this.fillHexFields(col);\r
- this.setHue(col);\r
- this.setSelector(col);\r
- this.setCurrentColor(col);\r
- this.setNewColor(col);\r
+ this._fillRGBFields(col);\r
+ this._fillHSBFields(col);\r
+ this._fillHexFields(col);\r
+ this._setHue(col);\r
+ this._setSelector(col);\r
+ this._setCurrentColor(col);\r
+ this._setNewColor(col);\r
\r
}\r
\r
(function($) {
$.widget("ui.draggable", $.extend({}, $.ui.mouse, {
- init: function() {
+ _init: function() {
if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
this.element[0].style.position = 'relative';
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + (this.scrollLeftParent[0].scrollLeft || 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
if(o.cursorAt) {
}
//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
if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);
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) {
+ _convertPositionTo: function(d, pos) {
if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1;
)
};
},
- generatePosition: function(e) {
+ _generatePosition: function(e) {
var o = this.options;
var position = {
mouseDrag: function(e) {
//Compute the helpers position
- this.position = this.generatePosition(e);
- this.positionAbs = this.convertPositionTo("absolute");
+ 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;
+ 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((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true) {
var self = this;
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10) || 500, function() {
- self.propagate("stop", e);
- self.clear();
+ self._propagate("stop", e);
+ self._clear();
});
} else {
- this.propagate("stop", e);
- this.clear();
+ this._propagate("stop", e);
+ this._clear();
}
return false;
},
- clear: function() {
+ _clear: function() {
this.helper.removeClass("ui-draggable-dragging");
if(this.options.helper != 'original' && !this.cancelHelperRemoval) this.helper.remove();
//if($.ui.ddmanager) $.ui.ddmanager.current = null;
options: this.options
};
},
- propagate: function(n,e) {
+ _propagate: function(n,e) {
$.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]);
},
destroy: function() {
var bs = Math.abs(b - y1) <= d;
var ls = Math.abs(l - x2) <= 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(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(rs) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: r }).left;
+ 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(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;
}
var first = (ts || bs || ls || rs);
var bs = Math.abs(b - y2) <= d;
var ls = Math.abs(l - x1) <= d;
var rs = Math.abs(r - x2) <= d;
- 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(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(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(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(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
shouldRevert: sortable.options.revert
});
sortable.refreshItems(); //Do a one-time refresh at start to refresh the containerCache
- sortable.propagate("activate", e, inst);
+ sortable._propagate("activate", e, inst);
}
});
this.instance.options.helper = this.instance.options._helper;
} else {
- this.instance.propagate("deactivate", e, inst);
+ this.instance._propagate("deactivate", e, inst);
}
});
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;
- inst.propagate("toSortable", e);
+ inst._propagate("toSortable", e);
}
this.instance.currentItem.remove();
if(this.instance.placeholder) this.instance.placeholder.remove();
- inst.propagate("fromSortable", e);
+ inst._propagate("fromSortable", e);
}
};
};
$.widget("ui.sortable", $.extend({}, $.ui.mouse, {
- init: function() {
+ _init: function() {
var o = this.options;
this.containerCache = {};
};
},
- propagate: function(n,e,inst, noPropagation) {
+ _propagate: function(n,e,inst, noPropagation) {
$.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]);
},
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);
- this.propagate("change", e); //Call plugins and callbacks
- this.containers[i].propagate("change", e, this); //Call plugins and callbacks
+ this._propagate("change", e); //Call plugins and callbacks
+ this.containers[i]._propagate("change", e, this); //Call plugins and callbacks
//Update the 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;
}
} else {
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;
}
}
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
//If o.placeholder is used, create a new element at the given position with the class
this.createPlaceholder();
//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(o.cursorAt) {
//Post 'activate' events to possible containers
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
},
- convertPositionTo: function(d, pos) {
+ _convertPositionTo: function(d, pos) {
if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1;
return {
};
},
- generatePosition: function(e) {
+ _generatePosition: function(e) {
var o = this.options;
var position = {
mouseDrag: function(e) {
//Compute the helpers position
- this.position = this.generatePosition(e);
- this.positionAbs = this.convertPositionTo("absolute");
+ this.position = this._generatePosition(e);
+ this.positionAbs = this._convertPositionTo("absolute");
//Call the internal plugins
$.ui.plugin.call(this, "sort", [e, this.ui()]);
//Regenerate the absolute position used for position checks
- this.positionAbs = this.convertPositionTo("absolute");
+ this.positionAbs = this._convertPositionTo("absolute");
//Set the helper's position
this.helper[0].style.left = this.position.left+'px';
&& (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.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;
}
}
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)
}, parseInt(this.options.revert, 10) || 500, function() {
- self.clear(e);
+ self._clear(e);
});
} else {
- this.clear(e, noPropagation);
+ this._clear(e, noPropagation);
}
return false;
},
- clear: function(e, noPropagation) {
+ _clear: function(e, noPropagation) {
//We first have to update the dom position of the actual currentItem
if(!this._noFinalSort) this.placeholder.before(this.currentItem);
else
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
- this.propagate("remove", e, null, noPropagation);
+ this._propagate("remove", e, null, noPropagation);
for (var i = this.containers.length - 1; i >= 0; i--){
if(contains(this.containers[i].element[0], this.currentItem[0])) {
- this.containers[i].propagate("update", e, this, noPropagation);
- this.containers[i].propagate("receive", e, this, noPropagation);
+ this.containers[i]._propagate("update", e, this, noPropagation);
+ this.containers[i]._propagate("receive", e, this, noPropagation);
}
};
};
//Post events to containers
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) {
- this.containers[i].propagate("out", e, this);
+ this.containers[i]._propagate("out", e, this);
this.containers[i].containerCache.over = 0;
}
}
this.dragging = false;
if(this.cancelHelperRemoval) {
- this.propagate("beforeStop", e, null, noPropagation);
- this.propagate("stop", e, null, noPropagation);
+ this._propagate("beforeStop", e, null, noPropagation);
+ this._propagate("stop", e, null, noPropagation);
return false;
}
- this.propagate("beforeStop", e, null, noPropagation);
+ this._propagate("beforeStop", e, null, noPropagation);
this.placeholder.remove();
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;