diff options
author | Richard Worth <rdworth@gmail.com> | 2008-09-20 02:43:18 +0000 |
---|---|---|
committer | Richard Worth <rdworth@gmail.com> | 2008-09-20 02:43:18 +0000 |
commit | 0bae0870d920842f10322763c66bc59541b9158c (patch) | |
tree | 4133b7ebeb79260c75efc5f8a7f1133bbce85c9f | |
parent | 1285c6e76302a65f8eaf6380b33c010a1900519c (diff) | |
download | jquery-ui-0bae0870d920842f10322763c66bc59541b9158c.tar.gz jquery-ui-0bae0870d920842f10322763c66bc59541b9158c.zip |
whitespace
-rw-r--r-- | ui/ui.accordion.js | 4 | ||||
-rw-r--r-- | ui/ui.autocomplete.js | 55 | ||||
-rw-r--r-- | ui/ui.colorpicker.js | 96 | ||||
-rw-r--r-- | ui/ui.datepicker.js | 110 | ||||
-rw-r--r-- | ui/ui.draggable.js | 93 | ||||
-rw-r--r-- | ui/ui.droppable.js | 12 | ||||
-rw-r--r-- | ui/ui.progressbar.js | 54 | ||||
-rw-r--r-- | ui/ui.resizable.js | 12 | ||||
-rw-r--r-- | ui/ui.selectable.js | 26 | ||||
-rw-r--r-- | ui/ui.slider.js | 51 | ||||
-rw-r--r-- | ui/ui.sortable.js | 137 | ||||
-rw-r--r-- | ui/ui.spinner.js | 3 | ||||
-rw-r--r-- | ui/ui.tabs.js | 112 |
13 files changed, 371 insertions, 394 deletions
diff --git a/ui/ui.accordion.js b/ui/ui.accordion.js index cb3b39031..4125a9ec7 100644 --- a/ui/ui.accordion.js +++ b/ui/ui.accordion.js @@ -60,7 +60,7 @@ $.widget("ui.accordion", { maxHeight = Math.max(maxHeight, $(this).outerHeight()); }).height(maxHeight); } - + options.headers .not(options.active || "") .next() @@ -214,7 +214,7 @@ function clickHandler(event) { options.active = clickedActive ? $([]) : clicked; toggle.call(this, toShow, toHide, data, clickedActive, down ); - + return false; }; diff --git a/ui/ui.autocomplete.js b/ui/ui.autocomplete.js index 8c2487a38..b065f093c 100644 --- a/ui/ui.autocomplete.js +++ b/ui/ui.autocomplete.js @@ -15,7 +15,7 @@ $.widget("ui.autocomplete", { _init: function() { - + $.extend(this.options, { delay: this.options.url ? $.Autocompleter.defaults.delay : 10, max: !this.options.scroll ? 10 : 150, @@ -46,7 +46,7 @@ $.widget("ui.autocomplete", { }); $.Autocompleter = function(input, options) { - + var KEY = { UP: 38, DOWN: 40, @@ -59,11 +59,11 @@ $.Autocompleter = function(input, options) { PAGEDOWN: 34, BACKSPACE: 8 }; - + // Create $ object for input element var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass); if(options.result) $input.bind('result.autocomplete', options.result); - + var timeout; var previousValue = ""; var cache = $.Autocompleter.Cache(options); @@ -89,7 +89,7 @@ $.Autocompleter = function(input, options) { // track last key pressed lastKeyPressCode = event.keyCode; switch(event.keyCode) { - + case KEY.UP: event.preventDefault(); if ( select.visible() ) { @@ -98,7 +98,7 @@ $.Autocompleter = function(input, options) { onChange(0, true); } break; - + case KEY.DOWN: event.preventDefault(); if ( select.visible() ) { @@ -107,7 +107,7 @@ $.Autocompleter = function(input, options) { onChange(0, true); } break; - + case KEY.PAGEUP: event.preventDefault(); if ( select.visible() ) { @@ -116,7 +116,7 @@ $.Autocompleter = function(input, options) { onChange(0, true); } break; - + case KEY.PAGEDOWN: event.preventDefault(); if ( select.visible() ) { @@ -137,11 +137,11 @@ $.Autocompleter = function(input, options) { return false; } break; - + case KEY.ESC: select.hide(); break; - + default: clearTimeout(timeout); timeout = setTimeout(onChange, options.delay); @@ -193,7 +193,6 @@ $.Autocompleter = function(input, options) { $(input.form).unbind(".autocomplete"); }); - function selectCurrent() { var selected = select.selected(); if( !selected ) @@ -274,12 +273,12 @@ $.Autocompleter = function(input, options) { $.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length); } }; - + function hideResults() { clearTimeout(timeout); timeout = setTimeout(hideResultsNow, 200); }; - + function hideResultsNow() { var wasVisible = select.visible(); select.hide(); @@ -304,7 +303,7 @@ $.Autocompleter = function(input, options) { // position cursor at end of input field $.Autocompleter.Selection(input, input.value.length, input.value.length); }; - + function receiveData(q, data) { if ( data && data.length && hasFocus ) { stopLoading(); @@ -315,7 +314,7 @@ $.Autocompleter = function(input, options) { hideResultsNow(); } }; - + function request(term, success, failure) { if (!options.matchCase) term = term.toLowerCase(); @@ -352,11 +351,11 @@ $.Autocompleter = function(input, options) { } }); } - + else if (options.source && typeof options.source == 'function') { var resultData = options.source(term); var parsed = (options.parse) ? options.parse(resultData) : resultData; - + cache.add(term, parsed); success(term, parsed); } else { @@ -382,11 +381,11 @@ $.Autocompleter = function(input, options) { } return parsed; }; - + function stopLoading() { $input.removeClass(options.loadingClass); }; - + }; $.Autocompleter.defaults = { @@ -421,7 +420,7 @@ $.extend($.ui.autocomplete, { }); $.Autocompleter.Cache = function(options) { - + var data = {}; var length = 0; @@ -448,7 +447,7 @@ $.Autocompleter.Cache = function(options) { // track the matches var stMatchSets = {}, nullData = 0; - + // no url was specified, we need to adjust the cache length to make sure it fits the local data store if( !options.url ) options.cacheLength = 1; @@ -464,12 +463,12 @@ $.Autocompleter.Cache = function(options) { var value = options.formatMatch(rawValue, i+1, options.data.length); if ( value === false ) continue; - + var firstChar = value.charAt(0).toLowerCase(); // if no lookup array for this character exists, look it up now if( !stMatchSets[firstChar] ) stMatchSets[firstChar] = []; - + // if the match is a string var row = { value: value, @@ -479,13 +478,13 @@ $.Autocompleter.Cache = function(options) { // push the current match into the set list stMatchSets[firstChar].push(row); - + // keep track of minChars zero items if ( nullData++ < options.max ) { stMatchSets[""].push(row); } }; - + // add the data items to the cache $.each(stMatchSets, function(i, value) { // increase the cache size @@ -578,7 +577,7 @@ $.Autocompleter.Select = function (options, input, select, config) { .addClass(options.resultsClass) .css("position", "absolute") .appendTo(document.body); - + list = $("<ul/>").appendTo(element).mouseover( function(event) { if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') { active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event)); @@ -598,7 +597,7 @@ $.Autocompleter.Select = function (options, input, select, config) { if( options.width > 0 ) element.css("width", options.width); - + needsInit = false; } @@ -611,7 +610,7 @@ $.Autocompleter.Select = function (options, input, select, config) { return []; return element; } - + function moveSelect(step) { listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE); movePosition(step); diff --git a/ui/ui.colorpicker.js b/ui/ui.colorpicker.js index 261be7983..f38052d7c 100644 --- a/ui/ui.colorpicker.js +++ b/ui/ui.colorpicker.js @@ -13,13 +13,13 @@ (function($) { $.widget("ui.colorpicker", { - + _init: function() { - + this.charMin = 65; 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"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-rgb-g ui-colorpicker-field"><label for="ui-colorpicker-rgb-g"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-rgb-b ui-colorpicker-field"><label for="ui-colorpicker-rgb-b"</label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-hsb-h ui-colorpicker-field"><label for="ui-colorpicker-hsb-h"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-hsb-s ui-colorpicker-field"><label for="ui-colorpicker-hsb-s"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-hsb-b ui-colorpicker-field"><label for="ui-colorpicker-hsb-b"></label><input type="text" maxlength="3" size="2" /><span></span></div><button class="ui-colorpicker-submit ui-default-state" name="submit" type="button">Done</button></div>'; - + if (typeof o.color == 'string') { this.color = this._HexToHSB(o.color); } else if (o.color.r != undefined && o.color.g != undefined && o.color.b != undefined) { @@ -29,37 +29,37 @@ $.widget("ui.colorpicker", { } else { return this; } - + this.origColor = this.color; this.picker = $(tpl); - + if (o.flat) { this.picker.appendTo(this.element).show(); } else { this.picker.appendTo(document.body); } - + this.fields = this.picker.find('input') .bind('keydown', function(e) { return self._keyDown.call(self, e); }) .bind('change', function(e) { return self._change.call(self, e); }) .bind('blur', function(e) { return self._blur.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.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.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.newColor = this.picker.find('div.ui-colorpicker-new-color'); this.currentColor = this.picker.find('div.ui-colorpicker-current-color'); - + this.picker.find('.ui-colorpicker-submit') .bind('mouseenter', function(e) { return self._enterSubmit.call(self, e); }) .bind('mouseleave', function(e) { return self._leaveSubmit.call(self, e); }) .bind('click', function(e) { return self._clickSubmit.call(self, e); }); - + this._fillRGBFields(this.color); this._fillHSBFields(this.color); this._fillHexFields(this.color); @@ -67,7 +67,7 @@ $.widget("ui.colorpicker", { this._setSelector(this.color); this._setCurrentColor(this.color); this._setNewColor(this.color); - + if (o.flat) { this.picker.css({ position: 'relative', @@ -76,16 +76,16 @@ $.widget("ui.colorpicker", { } else { $(this.element).bind(o.eventName+".colorpicker", function(e) { return self._show.call(self, e); }); } - + }, - + destroy: function() { - + this.picker.remove(); this.element.removeData("colorpicker").unbind(".colorpicker"); - + }, - + _fillRGBFields: function(hsb) { var rgb = this._HSBToRGB(hsb); this.fields @@ -126,7 +126,7 @@ $.widget("ui.colorpicker", { } }, _change: function(e, target) { - + var col; target = target || e.target; if (target.parentNode.className.indexOf('-hex') > 0) { @@ -153,11 +153,11 @@ $.widget("ui.colorpicker", { this._setSelector(col); this._setHue(col); this._setNewColor(col); - + this._trigger('change', e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) }); }, _blur: function(e) { - + var col = this.color; this._fillRGBFields(col); this._fillHSBFields(col); @@ -166,17 +166,17 @@ $.widget("ui.colorpicker", { this._setSelector(col); this._setNewColor(col); this.fields.parent().removeClass('ui-colorpicker-focus'); - + }, _focus: function(e) { - + this.charMin = e.target.parentNode.className.indexOf('-hex') > 0 ? 70 : 65; this.fields.parent().removeClass('ui-colorpicker-focus'); $(e.target.parentNode).addClass('ui-colorpicker-focus'); - + }, _downIncrement: function(e) { - + var field = $(e.target).parent().find('input').focus(), self = this; this.currentIncrement = { el: $(e.target).parent().addClass('ui-colorpicker-slider'), @@ -188,7 +188,7 @@ $.widget("ui.colorpicker", { $(document).bind('mouseup.cpSlider', function(e) { return self._upIncrement.call(self, e); }); $(document).bind('mousemove.cpSlider', function(e) { return self._moveIncrement.call(self, e); }); return false; - + }, _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)))); @@ -203,25 +203,25 @@ $.widget("ui.colorpicker", { return false; }, _downHue: function(e) { - + this.currentHue = { y: this.picker.find('div.ui-colorpicker-hue').offset().top }; - + this._change.apply(this, [e, this .fields .eq(4) .val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10)) .get(0)]); - + var self = this; $(document).bind('mouseup.cpSlider', function(e) { return self._upHue.call(self, e); }); $(document).bind('mousemove.cpSlider', function(e) { return self._moveHue.call(self, e); }); return false; - + }, _moveHue: function(e) { - + this._change.apply(this, [e, this .fields .eq(4) @@ -229,7 +229,7 @@ $.widget("ui.colorpicker", { .get(0)]); return false; - + }, _upHue: function(e) { $(document).unbind('mouseup.cpSlider'); @@ -237,12 +237,12 @@ $.widget("ui.colorpicker", { return false; }, _downSelector: function(e) { - + var self = this; this.currentSelector = { pos: this.picker.find('div.ui-colorpicker-color').offset() }; - + this._change.apply(this, [e, this .fields .eq(6) @@ -255,10 +255,10 @@ $.widget("ui.colorpicker", { $(document).bind('mouseup.cpSlider', function(e) { return self._upSelector.call(self, e); }); $(document).bind('mousemove.cpSlider', function(e) { return self._moveSelector.call(self, e); }); return false; - + }, _moveSelector: function(e) { - + this._change.apply(this, [e, this .fields .eq(6) @@ -269,7 +269,7 @@ $.widget("ui.colorpicker", { .get(0) ]); return false; - + }, _upSelector: function(e) { $(document).unbind('mouseup.cpSlider'); @@ -283,19 +283,19 @@ $.widget("ui.colorpicker", { this.picker.find('.ui-colorpicker-submit').removeClass('ui-colorpicker-focus'); }, _clickSubmit: function(e) { - + var col = this.color; this.origColor = col; this._setCurrentColor(col); - + this._trigger("submit", e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) }); return false; - + }, _show: function(e) { - + 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 viewPort = this._getScroll(); var top = pos.top + this.element[0].offsetHeight; @@ -310,21 +310,21 @@ $.widget("ui.colorpicker", { 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(); } - + var self = this; $(document).bind('mousedown.colorpicker', function(e) { return self._hide.call(self, e); }); return false; - + }, _hide: function(e) { - + 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) { this.picker.hide(); } $(document).unbind('mousedown.colorpicker'); } - + }, _isChildOf: function(parentEl, el, container) { if (parentEl == el) { @@ -446,7 +446,7 @@ $.widget("ui.colorpicker", { } else { return this; } - + this.color = col; this.origColor = col; this._fillRGBFields(col); @@ -456,9 +456,9 @@ $.widget("ui.colorpicker", { this._setSelector(col); this._setCurrentColor(col); this._setNewColor(col); - + } - + }); $.extend($.ui.colorpicker, { diff --git a/ui/ui.datepicker.js b/ui/ui.datepicker.js index 9a3ecd199..50e4c28d5 100644 --- a/ui/ui.datepicker.js +++ b/ui/ui.datepicker.js @@ -133,7 +133,7 @@ function Datepicker() { $.extend(Datepicker.prototype, { /* Class name added to elements to indicate already configured with a date picker. */ markerClassName: 'hasDatepicker', - + /* Debug logging (if enabled). */ log: function () { if (this.debug) @@ -147,7 +147,7 @@ $.extend(Datepicker.prototype, { extendRemove(this._defaults, settings || {}); return this; }, - + /* Attach the date picker to a jQuery selection. @param target element - the target input field or division or span @param settings object - the new settings to use for this date picker instance (anonymous) */ @@ -177,7 +177,7 @@ $.extend(Datepicker.prototype, { this._inlineDatepicker(target, inst); } }, - + /* Create a new instance object. */ _newInst: function(target, inline) { var id = target[0].id.replace(/([:\[\]\.])/g, '\\\\$1'); // escape jQuery meta chars @@ -188,7 +188,7 @@ $.extend(Datepicker.prototype, { dpDiv: (!inline ? this.dpDiv : // presentation div $('<div class="' + this._inlineClass + '"></div>'))}; }, - + /* Attach the date picker to an input field. */ _connectDatepicker: function(target, inst) { var input = $(target); @@ -227,7 +227,7 @@ $.extend(Datepicker.prototype, { }); $.data(target, PROP_NAME, inst); }, - + /* Attach an inline date picker to a div. */ _inlineDatepicker: function(target, inst) { var divSpan = $(target); @@ -243,13 +243,13 @@ $.extend(Datepicker.prototype, { this._setDate(inst, this._getDefaultDate(inst)); this._updateDatepicker(inst); }, - + /* Tidy up after displaying the date picker. */ _inlineShow: function(inst) { var numMonths = this._getNumberOfMonths(inst); // fix width for dynamic number of date pickers inst.dpDiv.width(numMonths[1] * $('.ui-datepicker', inst.dpDiv[0]).width()); }, - + /* Pop-up the date picker in a "dialog" box. @param input element - ignored @param dateText string - the initial date to display (in the current format) @@ -273,7 +273,7 @@ $.extend(Datepicker.prototype, { } extendRemove(inst.settings, settings || {}); this._dialogInput.val(dateText); - + this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); if (!this._pos) { var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; @@ -283,7 +283,7 @@ $.extend(Datepicker.prototype, { this._pos = // should use actual width/height below [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; } - + // move input on screen for focus, but hidden behind dialog this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px'); inst.settings.onSelect = onSelect; @@ -295,7 +295,7 @@ $.extend(Datepicker.prototype, { $.data(this._dialogInput[0], PROP_NAME, inst); return this; }, - + /* Detach a datepicker from its control. @param target element - the target input field or division or span */ _destroyDatepicker: function(target) { @@ -315,7 +315,7 @@ $.extend(Datepicker.prototype, { } else if (nodeName == 'div' || nodeName == 'span') $target.removeClass(this.markerClassName).empty(); }, - + /* Enable the date picker to a jQuery selection. @param target element - the target input field or division or span */ _enableDatepicker: function(target) { @@ -337,7 +337,7 @@ $.extend(Datepicker.prototype, { this._disabledInputs = $.map(this._disabledInputs, function(value) { return (value == target ? null : value); }); // delete entry }, - + /* Disable the date picker to a jQuery selection. @param target element - the target input field or division or span */ _disableDatepicker: function(target) { @@ -373,7 +373,7 @@ $.extend(Datepicker.prototype, { function(value) { return (value == target ? null : value); }); // delete entry this._disabledInputs[this._disabledInputs.length] = target; }, - + /* Is the first field in a jQuery collection disabled as a datepicker? @param target element - the target input field or division or span @return boolean - true if disabled, false if enabled */ @@ -386,7 +386,7 @@ $.extend(Datepicker.prototype, { } return false; }, - + /* Retrieve the instance data for the target control. @param target element - the target input field or division or span @return object - the associated instance data @@ -399,7 +399,7 @@ $.extend(Datepicker.prototype, { throw 'Missing instance data for this datepicker'; } }, - + /* Update the settings for a date picker attached to an input field or division. @param target element - the target input field or division or span @param name object - the new settings to update or @@ -428,7 +428,7 @@ $.extend(Datepicker.prototype, { this._updateDatepicker(inst); } }, - + /* Redraw the date picker attached to an input field or division. @param target element - the target input field or division or span */ _refreshDatepicker: function(target) { @@ -437,7 +437,7 @@ $.extend(Datepicker.prototype, { this._updateDatepicker(inst); } }, - + /* Set the dates for a jQuery selection. @param target element - the target input field or division or span @param date Date - the new date @@ -450,7 +450,7 @@ $.extend(Datepicker.prototype, { this._updateAlternate(inst); } }, - + /* Get the date(s) for the first entry in a jQuery selection. @param target element - the target input field or division or span @return Date - the current date or @@ -461,7 +461,7 @@ $.extend(Datepicker.prototype, { this._setDateFromField(inst); return (inst ? this._getDate(inst) : null); }, - + /* Handle keystrokes. */ _doKeyDown: function(e) { var inst = $.datepicker._getInst(e.target); @@ -513,7 +513,7 @@ $.extend(Datepicker.prototype, { e.stopPropagation(); } }, - + /* Filter entered characters - based on date format. */ _doKeyPress: function(e) { var inst = $.datepicker._getInst(e.target); @@ -521,7 +521,7 @@ $.extend(Datepicker.prototype, { var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); }, - + /* Pop-up the date picker for a given input field. @param input element - the input field attached to the date picker or event - if triggered by focus */ @@ -586,7 +586,7 @@ $.extend(Datepicker.prototype, { $.datepicker._curInst = inst; } }, - + /* Generate the date picker content. */ _updateDatepicker: function(inst) { var dims = {width: inst.dpDiv.width() + 4, @@ -602,7 +602,7 @@ $.extend(Datepicker.prototype, { if (inst.input && inst.input[0].type != 'hidden') $(inst.input[0]).focus(); }, - + /* Check positioning to remain on screen. */ _checkOffset: function(inst, offset, isFixed) { var pos = inst.input ? this._findPos(inst.input[0]) : null; @@ -635,7 +635,7 @@ $.extend(Datepicker.prototype, { var position = $(obj).offset(); return [position.left, position.top]; }, - + /* Hide the date picker from view. @param input element - the input field attached to the date picker @param duration string - the duration over which to close the date picker */ @@ -680,13 +680,13 @@ $.extend(Datepicker.prototype, { } this._curInst = null; }, - + /* Tidy up after a dialog display. */ _tidyDialog: function(inst) { inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker'); $('.' + this._promptClass, inst.dpDiv).remove(); }, - + /* Close date picker if clicked elsewhere. */ _checkExternalClick: function(event) { if (!$.datepicker._curInst) @@ -698,7 +698,7 @@ $.extend(Datepicker.prototype, { $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) $.datepicker._hideDatepicker(null, ''); }, - + /* Adjust one of the date sub-fields. */ _adjustDate: function(id, offset, period) { var target = $(id); @@ -706,7 +706,7 @@ $.extend(Datepicker.prototype, { this._adjustInstDate(inst, offset, period); this._updateDatepicker(inst); }, - + /* Action for current link. */ _gotoToday: function(id) { var target = $(id); @@ -725,7 +725,7 @@ $.extend(Datepicker.prototype, { this._notifyChange(inst); this._adjustDate(target); }, - + /* Action for selecting a new month/year. */ _selectMonthYear: function(id, select, period) { var target = $(id); @@ -737,7 +737,7 @@ $.extend(Datepicker.prototype, { this._notifyChange(inst); this._adjustDate(target); }, - + /* Restore input focus after not changing month/year. */ _clickMonthYear: function(id) { var target = $(id); @@ -746,7 +746,7 @@ $.extend(Datepicker.prototype, { inst.input[0].focus(); inst._selectingMonthYear = !inst._selectingMonthYear; }, - + /* Action for changing the first week day. */ _changeFirstDay: function(id, day) { var target = $(id); @@ -754,7 +754,7 @@ $.extend(Datepicker.prototype, { inst.settings.firstDay = day; this._updateDatepicker(inst); }, - + /* Action for selecting a day. */ _selectDay: function(id, month, year, td) { if ($(td).hasClass(this._unselectableClass)) @@ -795,7 +795,7 @@ $.extend(Datepicker.prototype, { this._updateDatepicker(inst); } }, - + /* Erase the input field and hide the date picker. */ _clearDate: function(id) { var target = $(id); @@ -806,7 +806,7 @@ $.extend(Datepicker.prototype, { inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null; this._selectDate(target, ''); }, - + /* Update the input field with the selected date. */ _selectDate: function(id, dateStr) { var target = $(id); @@ -848,7 +848,7 @@ $.extend(Datepicker.prototype, { $(altField).each(function() { $(this).val(dateStr); }); } }, - + /* Set as beforeShowDay function to prevent selection of weekends. @param date Date - the date to customise @return [boolean, string] - is this date selectable?, what is its CSS class? */ @@ -886,7 +886,7 @@ $.extend(Datepicker.prototype, { return $.datepicker.formatDate($.datepicker._get(inst, 'dateStatus'), date, $.datepicker._getFormatConfig(inst)); }, - + /* Parse a string value into a date object. See formatDate below for the possible formats. @@ -1022,7 +1022,7 @@ $.extend(Datepicker.prototype, { throw 'Invalid date'; // E.g. 31/02/* return date; }, - + /* Standard date formats. */ ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601) COOKIE: 'D, dd M yy', @@ -1035,7 +1035,7 @@ $.extend(Datepicker.prototype, { RSS: 'D, d M y', // RFC 822 TIMESTAMP: '@', W3C: 'yy-mm-dd', // ISO 8601 - + /* Format a date object into a string value. The format can be combinations of the following: d - day of month (no leading zero) @@ -1053,7 +1053,7 @@ $.extend(Datepicker.prototype, { @ - Unix timestamp (ms since 01/01/1970) '...' - literal text '' - single quote - + @param format string - the desired format of the date @param date Date - the date value to format @param settings Object - attributes include: @@ -1136,7 +1136,7 @@ $.extend(Datepicker.prototype, { } return output; }, - + /* Extract all possible characters from the date format. */ _possibleChars: function (format) { var chars = ''; @@ -1165,13 +1165,13 @@ $.extend(Datepicker.prototype, { } return chars; }, - + /* Get a setting value, defaulting if necessary. */ _get: function(inst, name) { return inst.settings[name] !== undefined ? inst.settings[name] : this._defaults[name]; }, - + /* Parse existing date and initialise date picker. */ _setDateFromField: function(inst) { var dateFormat = this._get(inst, 'dateFormat'); @@ -1211,7 +1211,7 @@ $.extend(Datepicker.prototype, { date = (maxDate && date > maxDate ? maxDate : date); return date; }, - + /* A date may be specified as an exact value or a relative one. */ _determineDate: function(date, defaultDate) { var offsetNumeric = function(offset) { @@ -1250,7 +1250,7 @@ $.extend(Datepicker.prototype, { (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date))); return (date && date.toString() == 'Invalid Date' ? defaultDate : date); }, - + /* Set the date(s) directly. */ _setDate: function(inst, date, endDate) { var clear = !(date); @@ -1280,7 +1280,7 @@ $.extend(Datepicker.prototype, { (!this._get(inst, 'rangeSelect') ? '' : this._get(inst, 'rangeSeparator') + this._formatDate(inst, inst.endDay, inst.endMonth, inst.endYear))); }, - + /* Retrieve the date(s) directly. */ _getDate: function(inst) { var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null : @@ -1292,7 +1292,7 @@ $.extend(Datepicker.prototype, { } else return startDate; }, - + /* Generate the HTML for the current state of the date picker. */ _generateHTML: function(inst) { var today = new Date(); @@ -1544,7 +1544,7 @@ $.extend(Datepicker.prototype, { html += '</div>'; // Close datepicker_header return html; }, - + /* Provide code to set and clear the status panel. */ _addStatus: function(showStatus, id, text, initStatus) { return (showStatus ? ' onmouseover="jQuery(\'#ui-datepicker-status-' + id + @@ -1552,7 +1552,7 @@ $.extend(Datepicker.prototype, { 'onmouseout="jQuery(\'#ui-datepicker-status-' + id + '\').html(\'' + initStatus + '\');"' : ''); }, - + /* Adjust one of the date sub-fields. */ _adjustInstDate: function(inst, offset, period) { var year = inst.drawYear + (period == 'Y' ? offset : 0); @@ -1571,7 +1571,7 @@ $.extend(Datepicker.prototype, { if (period == 'M' || period == 'Y') this._notifyChange(inst); }, - + /* Notify change of month/year. */ _notifyChange: function(inst) { var onChange = this._get(inst, 'onChangeMonthYear'); @@ -1585,7 +1585,7 @@ $.extend(Datepicker.prototype, { var numMonths = this._get(inst, 'numberOfMonths'); return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths)); }, - + /* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */ _getMinMaxDate: function(inst, minMax, checkRange) { var date = this._determineDate(this._get(inst, minMax + 'Date'), null); @@ -1598,17 +1598,17 @@ $.extend(Datepicker.prototype, { return (!checkRange || !inst.rangeStart ? date : (!date || inst.rangeStart > date ? inst.rangeStart : date)); }, - + /* Find the number of days in a given month. */ _getDaysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, - + /* Find the day of the week of the first of a month. */ _getFirstDayOfMonth: function(year, month) { return new Date(year, month, 1).getDay(); }, - + /* Determines if we should allow a "next/prev" month display change. */ _canAdjustMonth: function(inst, offset, curYear, curMonth) { var numMonths = this._getNumberOfMonths(inst); @@ -1617,7 +1617,7 @@ $.extend(Datepicker.prototype, { date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); return this._isInRange(inst, date); }, - + /* Is the given date in the accepted range? */ _isInRange: function(inst, date) { // during range selection, use minimum of selected date and range start @@ -1638,7 +1638,7 @@ $.extend(Datepicker.prototype, { dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'), monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')}; }, - + /* Format the given date for display. */ _formatDate: function(inst, day, month, year) { if (!day) { diff --git a/ui/ui.draggable.js b/ui/ui.draggable.js index fa8fbc611..ff3ebddd1 100644 --- a/ui/ui.draggable.js +++ b/ui/ui.draggable.js @@ -15,7 +15,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { getHandle: function(e) { - + var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; $(this.options.handle, this.element) .find("*") @@ -25,25 +25,24 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { }); return handle; - + }, createHelper: function() { - + var o = this.options; var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [e])) : (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; }, - _init: function() { if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) @@ -55,23 +54,23 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { this._mouseInit(); }, - + _mouseCapture: function(e) { - + var o = this.options; if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle')) return false; - + //Quit if we're not on a valid handle this.handle = this.getHandle(e); if (!this.handle) return false; return true; - + }, - + _mouseStart: function(e) { var o = this.options; @@ -104,7 +103,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { left: e.pageX - this.offset.left, top: e.pageY - this.offset.top }; - + //Calling this method cached the next parents that have scrollTop / scrollLeft attached this.cacheScrollParents(); @@ -136,7 +135,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied if(o.cursorAt) this.adjustOffsetFromHelper(o.cursorAt); - + //Cache later used stuff $.extend(this, { PAGEY_INCLUDES_SCROLL: (this.cssPosition == "absolute" && (!this.scrollTopParent[0].tagName || (/(html|body)/i).test(this.scrollTopParent[0].tagName))), @@ -147,7 +146,6 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { if(o.containment) this.setContainment(); - //Call plugins and callbacks this._propagate("start", e); @@ -165,7 +163,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { }, cacheScrollParents: function() { - + this.scrollTopParent = function(el) { do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode); return $(document); @@ -174,7 +172,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode); return $(document); }(this.helper); - + }, adjustOffsetFromHelper: function(obj) { @@ -192,7 +190,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { }, 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 = [ @@ -214,15 +212,14 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { 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) ]; } - + }, - _convertPositionTo: function(d, pos) { - + if(!pos) pos = this.position; var mod = d == "absolute" ? 1 : -1; - + return { top: ( pos.top // the calculated relative position @@ -243,7 +240,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { }; }, _generatePosition: function(e) { - + var o = this.options; var position = { top: ( @@ -263,7 +260,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { - (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0) ) }; - + if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options /* @@ -288,14 +285,14 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { return position; }, _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); @@ -415,8 +412,6 @@ $.ui.plugin.add("draggable", "iframeFix", { } }); - - $.ui.plugin.add("draggable", "scroll", { start: function(e, ui) { var o = ui.options; @@ -447,7 +442,6 @@ $.ui.plugin.add("draggable", "scroll", { i.overflowY[0].scrollTop = scrolled = i.overflowY[0].scrollTop + o.scrollSpeed; if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity) i.overflowY[0].scrollTop = scrolled = i.overflowY[0].scrollTop - o.scrollSpeed; - } else { if(e.pageY - $(document).scrollTop() < o.scrollSensitivity) scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); @@ -473,13 +467,12 @@ $.ui.plugin.add("draggable", "scroll", { } }); - $.ui.plugin.add("draggable", "snap", { start: function(e, ui) { var inst = $(this).data("draggable"); inst.snapElements = []; - + $(ui.options.snap.constructor != String ? ( ui.options.snap.items || ':data(draggable)' ) : ui.options.snap).each(function() { var $t = $(this); var $o = $t.offset(); if(this != inst.element[0]) inst.snapElements.push({ @@ -491,10 +484,10 @@ $.ui.plugin.add("draggable", "snap", { }, drag: function(e, ui) { - + var inst = $(this).data("draggable"); var d = ui.options.snapTolerance || 20; - + var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width, y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height; @@ -502,14 +495,14 @@ $.ui.plugin.add("draggable", "snap", { var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, t = inst.snapElements[i].top, b = t + inst.snapElements[i].height; - + //Yes, I know, this is insane ;) if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) { if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, null, $.extend(inst.uiHash(), { snapItem: inst.snapElements[i].item }))); inst.snapElements[i].snapping = false; continue; } - + if(ui.options.snapMode != 'inner') { var ts = Math.abs(t - y2) <= d; var bs = Math.abs(b - y1) <= d; @@ -539,13 +532,13 @@ $.ui.plugin.add("draggable", "snap", { inst.snapElements[i].snapping = (ts || bs || ls || rs || first); }; - + } }); $.ui.plugin.add("draggable", "connectToSortable", { start: function(e,ui) { - + var inst = $(this).data("draggable"); inst.sortables = []; $(ui.options.connectToSortable).each(function() { @@ -559,7 +552,7 @@ $.ui.plugin.add("draggable", "connectToSortable", { sortable._propagate("activate", e, inst); } }); - + }, stop: function(e,ui) { @@ -576,47 +569,47 @@ $.ui.plugin.add("draggable", "connectToSortable", { //Also propagate receive event, since the sortable is actually receiving a element this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), { sender: inst.element })], this.instance.options["receive"]); - + this.instance.options.helper = this.instance.options._helper; } else { this.instance._propagate("deactivate", e, inst); } - + }); }, drag: function(e,ui) { - + var inst = $(this).data("draggable"), self = this; var checkPos = function(o) { - + var l = o.left, r = l + o.width, t = o.top, b = t + o.height; - + return (l < (this.positionAbs.left + this.offset.click.left) && (this.positionAbs.left + this.offset.click.left) < r && t < (this.positionAbs.top + this.offset.click.top) && (this.positionAbs.top + this.offset.click.top) < b); }; $.each(inst.sortables, function(i) { - + if(checkPos.call(inst, this.instance.containerCache)) { - + //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once if(!this.instance.isOver) { this.instance.isOver = 1; - + //Now we fake the start of dragging for the sortable instance, //by cloning the list group item, appending it to the sortable and using it as inst.currentItem //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one) this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true); this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it this.instance.options.helper = function() { return ui.helper[0]; }; - + e.target = this.instance.currentItem[0]; this.instance._mouseCapture(e, true); this.instance._mouseStart(e, true, true); - + //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes this.instance.offset.click.top = inst.offset.click.top; this.instance.offset.click.left = inst.offset.click.left; @@ -624,7 +617,7 @@ $.ui.plugin.add("draggable", "connectToSortable", { this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; inst._propagate("toSortable", e); - + } //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable @@ -649,9 +642,9 @@ $.ui.plugin.add("draggable", "connectToSortable", { } }; - + }); - + } }); diff --git a/ui/ui.droppable.js b/ui/ui.droppable.js index 5d14a64d2..cdd60e76a 100644 --- a/ui/ui.droppable.js +++ b/ui/ui.droppable.js @@ -16,7 +16,7 @@ $.widget("ui.droppable", { _setData: function(key, value) { - + if(key == 'accept') { this.options.accept = value && $.isFunction(value) ? value : function(d) { return d.is(accept); @@ -24,18 +24,18 @@ $.widget("ui.droppable", { } else { $.widget.prototype._setData.apply(this, arguments); } - + }, _init: function() { var o = this.options, accept = o.accept; this.isover = 0; this.isout = 1; - + this.options.accept = this.options.accept && $.isFunction(this.options.accept) ? this.options.accept : function(d) { return d.is(accept); }; - + //Store the droppable's proportions this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight }; @@ -191,7 +191,7 @@ $.ui.ddmanager = { var m = $.ui.ddmanager.droppables[t.options.scope]; var type = e ? e.type : null; // workaround for #2317 var list = (t.currentItem || t.element).find(":data(droppable)").andSelf(); - + droppablesLoop: for (var i = 0; i < m.length; i++) { if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element,(t.currentItem || t.element)))) continue; //No disabled and non-accepted @@ -230,7 +230,7 @@ $.ui.ddmanager = { if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, e); //Run through all droppables and check their positions based on specific tolerance options - + $.each($.ui.ddmanager.droppables[draggable.options.scope], function() { if(this.options.disabled || this.greedyChild || !this.visible) return; diff --git a/ui/ui.progressbar.js b/ui/ui.progressbar.js index 6081e7382..cccf00b82 100644 --- a/ui/ui.progressbar.js +++ b/ui/ui.progressbar.js @@ -14,16 +14,16 @@ $.widget("ui.progressbar", { _init: function() { - + this._interval = this.options.interval; - + var self = this, options = this.options, id = (new Date()).getTime()+Math.random(), text = options.text || '0%'; - + this.element.addClass("ui-progressbar").width(options.width); - + $.extend(this, { active: false, pixelState: 0, @@ -40,12 +40,12 @@ $.widget("ui.progressbar", { }), wrapper: $('<div class="ui-progressbar-wrap"></div>') }); - + this.wrapper .append(this.bar.append(this.textElement.addClass(options.textClass)), this.textBg) .appendTo(this.element); }, - + plugins: {}, ui: function(e) { return { @@ -58,40 +58,40 @@ $.widget("ui.progressbar", { percentState: this.percentState }; }, - + _propagate: function(n,e) { $.ui.plugin.call(this, n, [e, this.ui()]); this.element.triggerHandler(n == "progressbar" ? n : ["progressbar", n].join(""), [e, this.ui()], this.options[n]); }, - + destroy: function() { this.stop(); - + this.element .removeClass("ui-progressbar ui-progressbar-disabled") .removeData("progressbar").unbind(".progressbar") .find('.ui-progressbar-wrap').remove(); - + delete jQuery.easing[this.identifier]; }, - + enable: function() { this.element.removeClass("ui-progressbar-disabled"); this.disabled = false; }, - + disable: function() { this.element.addClass("ui-progressbar-disabled"); this.disabled = true; }, - + start: function() { var self = this, options = this.options; - + if (this.disabled) { return; } - + jQuery.easing[this.identifier] = function (x, t, b, c, d) { var inc = options.increment, width = options.width, @@ -99,27 +99,27 @@ $.widget("ui.progressbar", { state = Math.round(x/step)*step; return state > 1 ? 1 : state; }; - + self.active = true; - + setTimeout( function() { self.active = false; }, options.duration ); - + this._animate(); - + this._propagate('start', this.ui()); return false; }, - + _animate: function() { var self = this, options = this.options, interval = options.interval; - + this.bar.animate( { width: options.width @@ -143,13 +143,13 @@ $.widget("ui.progressbar", { } ); }, - + pause: function() { if (this.disabled) return; this.bar.stop(); this._propagate('pause', this.ui()); }, - + stop: function() { this.bar.stop(); this.bar.width(0); @@ -158,22 +158,22 @@ $.widget("ui.progressbar", { this.options.interval = this._interval; this._propagate('stop', this.ui()); }, - + text: function(text){ this.textElement.html(text); this.textBg.html(text); }, - + progress: function(percentState) { if (this.bar.is('.ui-hidden')) { this.bar.removeClass('ui-hidden'); } - + this.percentState = percentState > 100 ? 100 : percentState; this.pixelState = (this.percentState/100)*this.options.width; this.bar.width(this.pixelState); this.textElement.width(this.pixelState); - + if (this.options.range && !this.options.text) { this.textElement.html(Math.round(this.percentState) + '%'); } diff --git a/ui/ui.resizable.js b/ui/ui.resizable.js index 1698b5f8d..fdd22b190 100644 --- a/ui/ui.resizable.js +++ b/ui/ui.resizable.js @@ -14,9 +14,9 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { _init: function() { - + var self = this, o = this.options; - + var elpos = this.element.css('position'); this.originalElement = this.element; @@ -316,7 +316,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { if (o.preserveCursor) $('body').css('cursor', this.axis + '-resize'); - + this._propagate("start", e); return true; }, @@ -555,16 +555,15 @@ $.ui.plugin.add("resizable", "containment", { }; } - // i'm a node, so compute top, left, right, bottom else{ self.containerOffset = $(ce).offset(); self.containerPosition = $(ce).position(); self.containerSize = { height: $(ce).innerHeight(), width: $(ce).innerWidth() }; - + var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); - + self.parentData = { element: ce, left: co.left, top: co.top, width: width, height: height }; @@ -611,7 +610,6 @@ $.ui.plugin.add("resizable", "containment", { var helper = $(self.helper), ho = helper.offset(), w = helper.innerWidth(), h = helper.innerHeight(); - if (o.helper && !o.animate && /relative/.test(ce.css('position'))) $(this).css({ left: (ho.left - co.left), top: (ho.top - co.top), width: w, height: h }); diff --git a/ui/ui.selectable.js b/ui/ui.selectable.js index 7d8d8cc2b..b75bb9894 100644 --- a/ui/ui.selectable.js +++ b/ui/ui.selectable.js @@ -19,7 +19,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { this.element.addClass("ui-selectable"); this.dragged = false; - + // cache selectee children based on filter var selectees; this.refresh = function() { @@ -42,7 +42,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { }); }; this.refresh(); - + this.selectees = selectees.addClass("ui-selectee"); this._mouseInit(); @@ -72,17 +72,17 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { if (this.options.disabled) return; - + var options = this.options; - + this.selectees = $(options.filter, this.element[0]); - + // selectable START callback this.element.triggerHandler("selectablestart", [e, { "selectable": this.element[0], "options": options }], options.start); - + $('body').append(this.helper); // position helper (lasso) this.helper.css({ @@ -93,11 +93,11 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { "width": 0, "height": 0 }); - + if (options.autoRefresh) { this.refresh(); } - + this.selectees.filter('.ui-selected').each(function() { var selectee = $.data(this, "selectable-item"); selectee.startselected = true; @@ -127,14 +127,14 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { if (this.options.disabled) return; - + var options = this.options; - + var x1 = this.opos[0], y1 = this.opos[1], x2 = e.pageX, y2 = e.pageY; if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; } if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; } this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1}); - + this.selectees.each(function() { var selectee = $.data(this, "selectable-item"); //prevent helper from being selected if appendTo: selectable @@ -146,7 +146,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { } else if (options.tolerance == 'fit') { hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2); } - + if (hit) { // SELECT if (selectee.selected) { @@ -216,7 +216,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { this.dragged = false; var options = this.options; - + $('.ui-unselecting', this.element[0]).each(function() { var selectee = $.data(this, "selectable-item"); selectee.$element.removeClass('ui-unselecting'); diff --git a/ui/ui.slider.js b/ui/ui.slider.js index e31e64545..af4c5de6e 100644 --- a/ui/ui.slider.js +++ b/ui/ui.slider.js @@ -64,7 +64,7 @@ $.widget("ui.slider", { } }, - + _init: function() { var self = this; @@ -82,7 +82,6 @@ $.widget("ui.slider", { }); } - var handleclass = function(el) { this.element = $(el); this.element.data("mouse", this); @@ -104,7 +103,6 @@ $.widget("ui.slider", { trigger: function(e) { this._mouseDown(e); } }); - $(this.handle) .each(function() { new handleclass(this); @@ -130,7 +128,7 @@ $.widget("ui.slider", { }); if (!isNaN(this.options.startValue)) this.moveTo(this.options.startValue, 0, true); - + this.previousHandle = $(this.handle[0]); //set the previous handle to the first to allow clicking before selecting the handle if(this.handle.length == 2 && this.options.range) this._createRange(); }, @@ -155,7 +153,6 @@ $.widget("ui.slider", { y: o.stepping && o.stepping.y || parseInt(o.stepping, 10) || (o.steps ? o.realMax.y/(o.steps.y || parseInt(o.steps, 10) || o.realMax.y) : 0) }; }, - _keydown: function(keyCode, handle) { var k = keyCode; @@ -202,22 +199,20 @@ $.widget("ui.slider", { }); if (clickedHandle || this.options.disabled || !(this.currentHandle || this.previousHandle)) return; - + // If a previous handle was focussed, focus it again if (!this.currentHandle && this.previousHandle) this._focus(this.previousHandle, true); // propagate only for distance > 0, otherwise propagation is done my drag this.offset = this.element.offset(); - + this.moveTo({ y: this._convertValue(e.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"), x: this._convertValue(e.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x") }, null, !this.options.distance); }, - - _createRange: function() { if(this.rangeElement) return; this.rangeElement = $('<div></div>') @@ -239,7 +234,7 @@ $.widget("ui.slider", { _getRange: function() { return this.rangeElement ? this._convertValue(parseInt(this.rangeElement.css(this.options.axis == "vertical" ? "height" : "width"),10), this.options.axis == "vertical" ? "y" : "x") : null; }, - + _handleIndex: function() { return this.handle.index(this.currentHandle[0]); }, @@ -297,19 +292,18 @@ $.widget("ui.slider", { return /* this.options.paging[axis] ||*/ 10; }, - _start: function(e, handle) { - + var o = this.options; if(o.disabled) return false; - + // Prepare the outer size this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() }; - + // This is a especially ugly fix for strange blur events happening on mousemove events if (!this.currentHandle) this._focus(this.previousHandle, true); - + this.offset = this.element.offset(); this.handleOffset = this.currentHandle.offset(); @@ -320,7 +314,7 @@ $.widget("ui.slider", { this._propagate('start', e); this._drag(e, handle); return true; - + }, _stop: function(e) { this._propagate('stop', e); @@ -331,11 +325,11 @@ $.widget("ui.slider", { return false; }, _drag: function(e, handle) { - + var o = this.options; var position = { top: e.pageY - this.offset.top - this.clickOffset.top, left: e.pageX - this.offset.left - this.clickOffset.left}; if(!this.currentHandle) this._focus(this.previousHandle, true); //This is a especially ugly fix for strange blur events happening on mousemove events - + position.left = this._translateLimits(position.left, "x"); position.top = this._translateLimits(position.top, "y"); @@ -352,7 +346,7 @@ $.widget("ui.slider", { position.left = this._translateRange(position.left, "x"); position.top = this._translateRange(position.top, "y"); - + if(o.axis != "vertical") this.currentHandle.css({ left: position.left }); if(o.axis != "horizontal") this.currentHandle.css({ top: position.top }); @@ -369,12 +363,12 @@ $.widget("ui.slider", { }, moveTo: function(value, handle, noPropagation) { - + var o = this.options; - + // Prepare the outer size this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() }; - + //If no handle has been passed, no current handle is available and we have multiple handles, return false if (handle == undefined && !this.currentHandle && this.handle.length != 1) return false; @@ -385,14 +379,13 @@ $.widget("ui.slider", { if (handle != undefined) this.currentHandle = this.previousHandle = $(this.handle[handle] || handle); - - + if(value.x !== undefined && value.y !== undefined) { var x = value.x, y = value.y; } else { var x = value, y = value; } - + if(x !== undefined && x.constructor != Number) { var me = /^\-\=/.test(x), pe = /^\+\=/.test(x); if(me || pe) { @@ -410,7 +403,7 @@ $.widget("ui.slider", { y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10); } } - + if(o.axis != "vertical" && x !== undefined) { if(o.stepping.x) x = Math.round(x / o.stepping.x) * o.stepping.x; x = this._translateValue(x, "x"); @@ -419,7 +412,7 @@ $.widget("ui.slider", { o.animate ? this.currentHandle.stop().animate({ left: x }, (Math.abs(parseInt(this.currentHandle.css("left")) - x)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ left: x }); } - + if(o.axis != "horizontal" && y !== undefined) { if(o.stepping.y) y = Math.round(y / o.stepping.y) * o.stepping.y; y = this._translateValue(y, "y"); @@ -430,13 +423,13 @@ $.widget("ui.slider", { if (this.rangeElement) this._updateRange(); - + //Store the slider's value this.currentHandle.data("mouse").sliderValue = { x: Math.round(this._convertValue(x, "x")) || 0, y: Math.round(this._convertValue(y, "y")) || 0 }; - + if (!noPropagation) { this._propagate('start', null); this._propagate('stop', null); diff --git a/ui/ui.sortable.js b/ui/ui.sortable.js index c459f2244..f4263263b 100644 --- a/ui/ui.sortable.js +++ b/ui/ui.sortable.js @@ -26,20 +26,20 @@ function contains(a, b) { $.widget("ui.sortable", $.extend({}, $.ui.mouse, { _init: function() { - + var o = this.options; this.containerCache = {}; this.element.addClass("ui-sortable"); - + //Get the items this.refresh(); - + //Let's determine if the items are floating this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false; //Let's determine the parent's offset this.offset = this.element.offset(); - + //Initialize mouse events for interaction this._mouseInit(); @@ -64,7 +64,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { }, serialize: function(o) { - + var items = this._getItemsAsjQuery(o && o.connected); var str = []; o = o || {}; @@ -81,7 +81,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { var items = this._getItemsAsjQuery(o && o.connected); var ret = []; - + items.each(function() { ret.push($(this).attr(o.attr || 'id')); }); return ret; @@ -100,7 +100,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { if(this.options.tolerance == "pointer" || this.options.forcePointerForContainers || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) { return isOverElement; } else { - + return (l < x1 + (this.helperProportions.width / 2) // Right Half && x2 - (this.helperProportions.width / 2) < r // Left Half && t < y1 + (this.helperProportions.height / 2) // Bottom Half @@ -121,7 +121,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { if(this.options.tolerance == "pointer" || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) { if(!isOverElement) return false; - + if(this.floating) { if ((x1 + dxClick) > l && (x1 + dxClick) < l + item.width/2) return 2; if ((x1 + dxClick) > l + item.width/2 && (x1 + dxClick) < r) return 1; @@ -132,7 +132,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { if (direction == 1 && (y1 + dyClick) < t + height/2) { return 2; } // up else if (direction == 2 && (y1 + dyClick) > t + height/2) { return 1; } // down } - + } else { if (!(l < x1 + (this.helperProportions.width / 2) // Right Half && x2 - (this.helperProportions.width / 2) < r // Left Half @@ -162,7 +162,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { var self = this; var items = []; var queries = []; - + if(this.options.connectWith && connected) { for (var i = this.options.connectWith.length - 1; i >= 0; i--){ var cur = $(this.options.connectWith[i]); @@ -176,7 +176,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { } queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper"), this]); - + for (var i = queries.length - 1; i >= 0; i--){ queries[i][0].each(function() { items.push(this); @@ -188,16 +188,16 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { }, _removeCurrentsFromItems: function() { - + var list = this.currentItem.find(":data(sortable-item)"); - + for (var i=0; i < this.items.length; i++) { for (var j=0; j < list.length; j++) { if(list[j] == this.items[i].item[0]) this.items.splice(i,1); }; - + }; }, @@ -209,7 +209,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { var items = this.items; var self = this; var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element), this]]; - + if(this.options.connectWith) { for (var i = this.options.connectWith.length - 1; i >= 0; i--){ var cur = $(this.options.connectWith[i]); @@ -222,7 +222,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { }; }; } - + for (var i = queries.length - 1; i >= 0; i--){ queries[i][0].each(function() { $.data(this, 'sortable-item', queries[i][1]); // Data for target checking (mouse manager) @@ -234,23 +234,23 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { }); }); }; - + }, refreshPositions: function(fast) { - + //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change if(this.offsetParent) { var po = this.offsetParent.offset(); this.offset.parent = { top: po.top + this.offsetParentBorders.top, left: po.left + this.offsetParentBorders.left }; } - + for (var i = this.items.length - 1; i >= 0; i--){ //We ignore calculating positions of all connected containers when we're not over them if(this.items[i].instance != this.currentContainer && this.currentContainer && this.items[i].item[0] != this.currentItem[0]) continue; - + var t = this.options.toleranceElement ? $(this.options.toleranceElement, this.items[i].item) : this.items[i].item; if(!fast) { @@ -263,7 +263,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { this.items[i].top = p.top; }; - + if(this.options.custom && this.options.custom.refreshContainers) { this.options.custom.refreshContainers.call(this); } else { @@ -275,7 +275,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); }; } - + }, destroy: function() { @@ -292,20 +292,20 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { _createPlaceholder: function(that) { var self = that || this, o = self.options; - + if(!o.placeholder || o.placeholder.constructor == String) { var className = o.placeholder; o.placeholder = { element: function() { var el = $(document.createElement(self.currentItem[0].nodeName)).addClass(className || "ui-sortable-placeholder")[0]; - + if(!className) { el.style.visibility = "hidden"; document.body.appendChild(el); el.innerHTML = self.currentItem[0].innerHTML; document.body.removeChild(el); }; - + return el; }, update: function(container, p) { @@ -324,11 +324,10 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { _contactContainers: function(e) { for (var i = this.containers.length - 1; i >= 0; i--){ - + if(this._intersectsWith(this.containers[i].containerCache)) { if(!this.containers[i].containerCache.over) { - if(this.currentContainer != this.containers[i]) { //When entering a new container, we will find the item with the least distance and append our item near it @@ -351,7 +350,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { //Update the placeholder this.options.placeholder.update(this.currentContainer, this.placeholder); - + } this.containers[i]._propagate("over", e, this); @@ -368,12 +367,12 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { }, _mouseCapture: function(e, overrideHandle) { - + if(this.options.disabled || this.options.type == 'static') return false; - + //We have to refresh the items data once first this._refreshItems(); - + //Find out if the clicked node (or one of its parents) is a actual item in this.items var currentItem = null, self = this, nodes = $(e.target).parents().each(function() { if($.data(this, 'sortable-item') == self) { @@ -382,7 +381,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { } }); if($.data(e.target, 'sortable-item') == self) currentItem = $(e.target); - + if(!currentItem) return false; if(this.options.handle && !overrideHandle) { var validHandle = false; @@ -390,11 +389,11 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == e.target) validHandle = true; }); if(!validHandle) return false; } - + this.currentItem = currentItem; this._removeCurrentsFromItems(); return true; - + }, createHelper: function(e) { @@ -404,32 +403,32 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { if (!helper.parents('body').length) $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); //Add the helper to the DOM if that didn't happen already - + return helper; - + }, _mouseStart: function(e, overrideHandle, noActivation) { - + var o = this.options; this.currentContainer = this; - + //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture this.refreshPositions(); - + //Create and append the visible helper this.helper = this.createHelper(e); - + /* * - Position generation - * This block generates everything position related - it's the core of draggables. */ - + this.margins = { //Cache the margins left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), top: (parseInt(this.currentItem.css("marginTop"),10) || 0) }; - + this.offset = this.currentItem.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, @@ -443,7 +442,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { this.offsetParent = this.helper.offsetParent(); //Get the offsetParent and cache its position var po = this.offsetParent.offset(); - + this.offsetParentBorders = { top: (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), left: (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) @@ -453,20 +452,19 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { top: po.top + this.offsetParentBorders.top, left: po.left + this.offsetParentBorders.left }; - + 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.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size - - + if(o.helper == "original") { this._storedCSS = { position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left"), clear: this.currentItem.css("clear") }; } else { this.currentItem.hide(); //Hide the original, won't cause anything bad this way } - + //Position it absolutely and add a helper class this.helper .css({ position: 'absolute', clear: 'both' }) @@ -474,7 +472,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { //Create the placeholder this._createPlaceholder(); - + //Call plugins and callbacks this._propagate("start", e); @@ -488,7 +486,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top; if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom; } - + /* * - Position constraining - * Here we prepare position constraining like grid and containment. @@ -502,7 +500,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { $(o.containment == 'document' ? document : window).width() - 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.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(); @@ -528,13 +526,12 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e); - + this.dragging = true; - + 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) { @@ -599,11 +596,11 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { }, _mouseDrag: function(e) { - + //Compute the helpers position this.position = this._generatePosition(e); this.positionAbs = this._convertPositionTo("absolute"); - + //Call the internal plugins $.ui.plugin.call(this, "sort", [e, this.ui()]); @@ -613,7 +610,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { //Set the helper's position this.helper[0].style.left = this.position.left+'px'; this.helper[0].style.top = this.position.top+'px'; - + //Rearrange for (var i = this.items.length - 1; i >= 0; i--) { var intersection = this._intersectsWithEdge(this.items[i]); @@ -639,16 +636,16 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { //Interconnect with droppables if($.ui.ddmanager) $.ui.ddmanager.drag(this, e); - + //Call callbacks this.element.triggerHandler("sort", [e, this.ui()], this.options["sort"]); - + return false; }, _rearrange: function(e, i, a, hardRefresh) { - + a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextSibling)); //Various things done here to improve the performance: @@ -658,23 +655,23 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { // 4. this lets only the last addition to the timeout stack through this.counter = this.counter ? ++this.counter : 1; var self = this, counter = this.counter; - + window.setTimeout(function() { if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove },0); - + }, _mouseStop: function(e, noPropagation) { - + //If we are using droppables, inform the manager about the drop if ($.ui.ddmanager && !this.options.dropBehaviour) $.ui.ddmanager.drop(this, e); - + if(this.options.revert) { var self = this; var cur = self.placeholder.offset(); - + $(this.helper).animate({ 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) @@ -684,22 +681,22 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { } else { this._clear(e, noPropagation); } - + return false; }, _clear: function(e, noPropagation) { - + //We first have to update the dom position of the actual currentItem if(!this._noFinalSort) this.placeholder.before(this.currentItem); this._noFinalSort = null; - + if(this.options.helper == "original") this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); 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(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element this._propagate("remove", e, null, noPropagation); @@ -800,7 +797,7 @@ $.ui.plugin.add("sortable", "scroll", { start: function(e, ui) { var o = ui.options; var i = $(this).data("sortable"); - + i.overflowY = function(el) { do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode); return $(document); diff --git a/ui/ui.spinner.js b/ui/ui.spinner.js index f639719d6..1413a4286 100644 --- a/ui/ui.spinner.js +++ b/ui/ui.spinner.js @@ -118,7 +118,6 @@ $.widget('ui.spinner', { }) .end(); - // DataList: Set contraints for object length and step size. // Manipulate height of spinner. this._items = this.element.children().length; @@ -157,7 +156,6 @@ $.widget('ui.spinner', { } }, - _constrain: function() { if(this.options.min != undefined && this._getValue() < this.options.min) this._setValue(this.options.min); if(this.options.max != undefined && this._getValue() > this.options.max) this._setValue(this.options.max); @@ -246,7 +244,6 @@ $.widget('ui.spinner', { } }, - plugins: {}, ui: function(e) { return { diff --git a/ui/ui.tabs.js b/ui/ui.tabs.js index 109ead137..b25a892ab 100644 --- a/ui/ui.tabs.js +++ b/ui/ui.tabs.js @@ -43,13 +43,13 @@ $.widget("ui.tabs", { }; }, _tabify: function(init) { - + this.$lis = $('li:has(a[href])', this.element); this.$tabs = this.$lis.map(function() { return $('a', this)[0]; }); this.$panels = $([]); - + var self = this, o = this.options; - + this.$tabs.each(function(i, a) { // inline tab if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash @@ -72,17 +72,17 @@ $.widget("ui.tabs", { else o.disabled.push(i + 1); }); - + // initialization from scratch if (init) { - + // attach necessary classes for styling if not present this.element.addClass(o.navClass); this.$panels.each(function() { var $this = $(this); $this.addClass(o.panelClass); }); - + // Selected tab // use "selected" option or try to retrieve: // 1. from fragment identifier in url @@ -115,7 +115,7 @@ $.widget("ui.tabs", { o.selected = self.$lis.index( self.$lis.filter('.' + o.selectedClass)[0] ); } o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default - + // Take disabling tabs via class attribute from HTML // into account and update option properly. // A selected tab cannot become disabled. @@ -138,7 +138,7 @@ $.widget("ui.tabs", { self._trigger('show', null, self.ui(self.$tabs[o.selected], self.$panels[o.selected])); }; - + // load if remote tab if ($.data(this.$tabs[o.selected], 'load.tabs')) this.load(o.selected, onShow); @@ -152,12 +152,12 @@ $.widget("ui.tabs", { self.$tabs.unbind('.tabs'); self.$lis = self.$tabs = self.$panels = null; }); - + } // update selected after add/remove else o.selected = this.$lis.index( this.$lis.filter('.' + o.selectedClass)[0] ); - + // set or update cookie after init and add/remove respectively if (o.cookie) $.cookie('ui-tabs-' + $.data(self.element[0]), o.selected, o.cookie); @@ -165,7 +165,7 @@ $.widget("ui.tabs", { // disable tabs for (var i = 0, li; li = this.$lis[i]; i++) $(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass); - + // reset cache if switching from cached to not cached if (o.cache === false) this.$tabs.removeData('cache.tabs'); @@ -176,12 +176,12 @@ $.widget("ui.tabs", { hideFx = o.fx[0] || baseFx, showFx = o.fx[1] || baseFx; else hideFx = showFx = o.fx || baseFx; - + // reset some styles to maintain print style sheets etc. var resetCSS = { display: '', overflow: '', height: '' }; if (!$.browser.msie) // not in IE to prevent ClearType font issue resetCSS.opacity = ''; - + // Hide a tab, animation prevents browser scrolling to fragment, // $show is optional. function hideTab(clicked, $hide, $show) { @@ -193,7 +193,7 @@ $.widget("ui.tabs", { showTab(clicked, $show, $hide); }); } - + // Show a tab, animation prevents browser scrolling to fragment, // $hide is optional. function showTab(clicked, $show, $hide) { @@ -203,12 +203,12 @@ $.widget("ui.tabs", { $show.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc. if ($.browser.msie && showFx.opacity) $show[0].style.filter = ''; - + // callback self._trigger('show', null, self.ui(clicked, $show[0])); }); } - + // switch a tab function switchTab(clicked, $li, $hide, $show) { /*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click @@ -218,15 +218,15 @@ $.widget("ui.tabs", { .siblings().removeClass(o.selectedClass); hideTab(clicked, $hide, $show); } - + // attach tab event handler, unbind to avoid duplicates from former tabifying... this.$tabs.unbind('.tabs').bind(o.event, function() { - + //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click var $li = $(this).parents('li:eq(0)'), $hide = self.$panels.filter(':visible'), $show = $(this.hash); - + // If tab is already selected and not unselectable or tab disabled or // or is already loading or click callback returns false stop here. // Check if click handler returns false last so that it is not executed @@ -239,9 +239,9 @@ $.widget("ui.tabs", { this.blur(); return false; } - + self.options.selected = self.$tabs.index(this); - + // if tab may be closed if (o.unselect) { if ($li.hasClass(o.selectedClass)) { @@ -262,16 +262,16 @@ $.widget("ui.tabs", { return false; } } - + if (o.cookie) $.cookie('ui-tabs-' + $.data(self.element[0]), self.options.selected, o.cookie); - + // stop possibly running animations self.$panels.stop(); - + // show new tab if ($show.length) { - + // prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled /*if ($.browser.msie && o.bookmarkable) { var showId = this.hash.replace('#', ''); @@ -280,7 +280,7 @@ $.widget("ui.tabs", { $show.attr('id', showId); // restore id }, 0); }*/ - + var a = this; self.load(self.$tabs.index(this), $hide.length ? function() { @@ -291,44 +291,44 @@ $.widget("ui.tabs", { showTab(a, $show); } ); - + // Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash /*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0; var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0; setTimeout(function() { scrollTo(scrollX, scrollY); }, 0);*/ - + } else throw 'jQuery UI Tabs: Mismatching fragment identifier.'; - + // Prevent IE from keeping other link focussed when using the back button // and remove dotted border from clicked link. This is controlled in modern // browsers via CSS, also blur removes focus from address bar in Firefox // which can become a usability and annoying problem with tabsRotate. if ($.browser.msie) this.blur(); - + //return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE return false; - + }); - + // disable click if event is configured to something else if (!(/^click/).test(o.event)) this.$tabs.bind('click.tabs', function() { return false; }); - + }, add: function(url, label, index) { if (index == undefined) index = this.$tabs.length; // append by default - + var o = this.options; var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label)); $li.data('destroy.tabs', true); - + var id = url.indexOf('#') == 0 ? url.replace('#', '') : this._tabId( $('a:first-child', $li)[0] ); - + // try to find an existing element before creating a new one var $panel = $('#' + id); if (!$panel.length) { @@ -347,9 +347,9 @@ $.widget("ui.tabs", { o.disabled = $.map(o.disabled, function(n, i) { return n >= index ? ++n : n }); - + this._tabify(); - + if (this.$tabs.length == 1) { $li.addClass(o.selectedClass); $panel.removeClass(o.hideClass); @@ -357,24 +357,24 @@ $.widget("ui.tabs", { if (href) this.load(index, href); } - + // callback this._trigger('add', null, this.ui(this.$tabs[index], this.$panels[index])); }, remove: function(index) { var o = this.options, $li = this.$lis.eq(index).remove(), $panel = this.$panels.eq(index).remove(); - + // If selected tab was removed focus tab to the right or // in case the last tab was removed the tab to the left. if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1) this.select(index + (index + 1 < this.$tabs.length ? 1 : -1)); - + o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }), function(n, i) { return n >= index ? --n : n }); - + this._tabify(); - + // callback this._trigger('remove', null, this.ui($li.find('a')[0], $panel[0])); }, @@ -382,7 +382,7 @@ $.widget("ui.tabs", { var o = this.options; if ($.inArray(index, o.disabled) == -1) return; - + var $li = this.$lis.eq(index).removeClass(o.disabledClass); if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2... $li.css('display', 'inline-block'); @@ -390,9 +390,9 @@ $.widget("ui.tabs", { $li.css('display', 'block'); }, 0); } - + o.disabled = $.grep(o.disabled, function(n, i) { return n != index; }); - + // callback this._trigger('enable', null, this.ui(this.$tabs[index], this.$panels[index])); }, @@ -400,10 +400,10 @@ $.widget("ui.tabs", { var self = this, o = this.options; if (index != o.selected) { // cannot disable already selected tab this.$lis.eq(index).addClass(o.disabledClass); - + o.disabled.push(index); o.disabled.sort(); - + // callback this._trigger('disable', null, this.ui(this.$tabs[index], this.$panels[index])); } @@ -417,7 +417,7 @@ $.widget("ui.tabs", { var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0], bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs'); - + callback = callback || function() {}; // no remote or from cache - just finish with callback @@ -425,7 +425,7 @@ $.widget("ui.tabs", { callback(); return; } - + // load remote from here on var inner = function(parent) { @@ -446,7 +446,7 @@ $.widget("ui.tabs", { inner(a).wrapInner('<em></em>') .find('em').data('label.tabs', label).html(o.spinner); } - + var ajaxOptions = $.extend({}, o.ajaxOptions, { url: url, success: function(r, s) { @@ -455,7 +455,7 @@ $.widget("ui.tabs", { if (o.cache) $.data(a, 'cache.tabs', true); // if loaded once do not load them again - + // callbacks self._trigger('load', null, self.ui(self.$tabs[index], self.$panels[index])); o.ajaxOptions.success && o.ajaxOptions.success(r, s); @@ -510,20 +510,20 @@ $.ui.tabs.defaults = { disabled: [], cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true } // TODO history: false, - + // Ajax spinner: 'Loading…', cache: false, idPrefix: 'ui-tabs-', ajaxOptions: {}, - + // animations fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 } - + // templates tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>', panelTemplate: '<div></div>', - + // CSS classes navClass: 'ui-tabs-nav', selectedClass: 'ui-tabs-selected', |