aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2008-07-10 02:50:51 +0000
committerScott González <scott.gonzalez@gmail.com>2008-07-10 02:50:51 +0000
commit12cdae02b136f7a542dfac7319d008cf9c3d5505 (patch)
tree5face07144b2c77f390a03e96d9bdd710e152255
parent4f412c60ea8dbf11b9447e838b815214ab3ca1a2 (diff)
downloadjquery-ui-12cdae02b136f7a542dfac7319d008cf9c3d5505.tar.gz
jquery-ui-12cdae02b136f7a542dfac7319d008cf9c3d5505.zip
New plugins for 1.6: Fixed headers and indentation.
-rw-r--r--ui/ui.autocomplete.js23
-rw-r--r--ui/ui.history.js179
-rw-r--r--ui/ui.magnifier.js298
-rw-r--r--ui/ui.progressbar.js348
-rw-r--r--ui/ui.spinner.js230
5 files changed, 546 insertions, 532 deletions
diff --git a/ui/ui.autocomplete.js b/ui/ui.autocomplete.js
index 19a51451a..8476c5c1d 100644
--- a/ui/ui.autocomplete.js
+++ b/ui/ui.autocomplete.js
@@ -1,18 +1,16 @@
/*
- * Autocomplete - jQuery plugin 1.0.1
+ * jQuery UI Autocomplete
*
- * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
- *
- * Dual licensed under the MIT and GPL licenses:
- * http://www.opensource.org/licenses/mit-license.php
- * http://www.gnu.org/licenses/gpl.html
- *
- * Revision: $Id: jquery.autocomplete.js 5698 2008-05-27 13:53:30Z paul.bakaus $
+ * Copyright (c) 2007, 2008 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI/Autocomplete
*
+ * Depends:
+ * ui.core.js
*/
-
-;(function($) {
-
+(function($) {
$.widget("ui.autocomplete", {
@@ -47,7 +45,6 @@ $.widget("ui.autocomplete", {
});
-
$.Autocompleter = function(input, options) {
var KEY = {
@@ -772,4 +769,4 @@ $.Autocompleter.Selection = function(field, start, end) {
field.focus();
};
-})(jQuery); \ No newline at end of file
+})(jQuery);
diff --git a/ui/ui.history.js b/ui/ui.history.js
index 6378b75a0..40848ebe5 100644
--- a/ui/ui.history.js
+++ b/ui/ui.history.js
@@ -7,111 +7,106 @@
*
* http://docs.jquery.com/UI/History
*
- * Revision: $Id: ui.history.js 5218 2008-04-09 20:08:24Z rdworth $
+ * Depends:
+ * ui.core.js
*/
-;(function($) {
+(function($) {
- // if the UI scope is not availalable, add it
- $.ui = $.ui || {};
+// TODO lazy loading singleton
+$.ui.hmanager = new function() {
+ var states = {}, def = function() {};
- // TODO lazy loading singleton
- $.ui.hmanager = new function() {
- var states = {}, def = function() {};
-
- var $window = $(window), hash = location.hash;
-
- function getState() {
- return hash.replace('#', '');
- }
-
- var iframe;
- // var keepHistoryIn = iframe || window;
-
- return {
+ var $window = $(window), hash = location.hash;
- enable: function() {
-
- if ($.browser.msie && parseInt($.browser.version) < 8) {
- $(function() {
- // create hidden iframe for hash change tracking
- iframe = $('<iframe id="ui-history-iframe" style="display: none;"></iframe>').
- prependTo(document.body)[0];
-
- // create initial history entry
- iframe.contentWindow.document.open();
- iframe.contentWindow.document.close();
-
- if (getState())
- iframe.contentWindow.document.location.hash = getState();
-
- });
- }
-
- $window.bind('hashchange', function(e) {
- // Prevent IE 8 from fireing an event twice,
- // one from true event, one from trigger...
- if (!iframe && hash == location.hash || iframe && hash == iframe.contentWindow.document.location.hash)
- return false;
+ function getState() {
+ return hash.replace('#', '');
+ }
+
+ var iframe;
+ // var keepHistoryIn = iframe || window;
+
+ return {
- if ($.browser.msie && parseInt($.browser.version) < 8) {
- hash = iframe.contentWindow.document.location.hash;
- }
- else
- hash = location.hash;
+ enable: function() {
+
+ if ($.browser.msie && parseInt($.browser.version) < 8) {
+ $(function() {
+ // create hidden iframe for hash change tracking
+ iframe = $('<iframe id="ui-history-iframe" style="display: none;"></iframe>').
+ prependTo(document.body)[0];
+
+ // create initial history entry
+ iframe.contentWindow.document.open();
+ iframe.contentWindow.document.close();
if (getState())
- states[getState()]();
- else
- // TODO invoke default
- ;
+ iframe.contentWindow.document.location.hash = getState();
+
});
-
- if (!($.browser.msie && parseInt($.browser.version) >= 8)) {
- setInterval(
- ($.browser.msie ?
- function() {
- if (hash != iframe.contentWindow.document.location.hash)
- $window.trigger('hashchange');
- } :
- function() {
- if (hash != location.hash)
- $window.trigger('hashchange');
- else
- // Do the history.length check hack for Safari 2
- ;
- }
- )
- , 200
- );
+ }
+
+ $window.bind('hashchange', function(e) {
+ // Prevent IE 8 from fireing an event twice,
+ // one from true event, one from trigger...
+ if (!iframe && hash == location.hash || iframe && hash == iframe.contentWindow.document.location.hash)
+ return false;
+
+ if ($.browser.msie && parseInt($.browser.version) < 8) {
+ hash = iframe.contentWindow.document.location.hash;
}
+ else
+ hash = location.hash;
- },
-
- add: function(state, handler) {
- states[state] = handler;
- },
+ if (getState())
+ states[getState()]();
+ else
+ // TODO invoke default
+ ;
+ });
- go: function(state) {
- if (state) {
- if ($.browser.msie && parseInt($.browser.version) < 8) {
- iframe.contentWindow.document.open();
- iframe.contentWindow.document.close();
- iframe.contentWindow.document.location.hash = state;
- }
- location.hash = state;
- $window.trigger('hashchange');
- }
- else
- console.log('TODO do default state');
+ if (!($.browser.msie && parseInt($.browser.version) >= 8)) {
+ setInterval(
+ ($.browser.msie ?
+ function() {
+ if (hash != iframe.contentWindow.document.location.hash)
+ $window.trigger('hashchange');
+ } :
+ function() {
+ if (hash != location.hash)
+ $window.trigger('hashchange');
+ else
+ // Do the history.length check hack for Safari 2
+ ;
+ }
+ )
+ , 200
+ );
}
+ },
- }
+ add: function(state, handler) {
+ states[state] = handler;
+ },
- };
+ go: function(state) {
+ if (state) {
+ if ($.browser.msie && parseInt($.browser.version) < 8) {
+ iframe.contentWindow.document.open();
+ iframe.contentWindow.document.close();
+ iframe.contentWindow.document.location.hash = state;
+ }
+ location.hash = state;
+ $window.trigger('hashchange');
+ }
+ else
+ console.log('TODO do default state');
+ }
+ }
+};
+
+$.ui.history = function() {
+ var args = Array.prototype.slice.call(arguments, 1);
+ $.ui.hmanager[arguments[0]].apply($.ui.hmanager, args);
+};
- $.ui.history = function() {
- var args = Array.prototype.slice.call(arguments, 1);
- $.ui.hmanager[arguments[0]].apply($.ui.hmanager, args);
- };
-
})(jQuery);
diff --git a/ui/ui.magnifier.js b/ui/ui.magnifier.js
index 2adf7ed52..e40e6f3f4 100644
--- a/ui/ui.magnifier.js
+++ b/ui/ui.magnifier.js
@@ -1,74 +1,152 @@
+/*
+ * jQuery UI Magnifier
+ *
+ * Copyright (c) 2008 jQuery
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI/Magnifier
+ *
+ * Depends:
+ * ui.core.js
+ */
(function($) {
- $.widget("ui.magnifier", {
- init: function() {
+$.widget("ui.magnifier", {
+ init: function() {
- var self = this, o = this.options;
- this.items = [];
- this.element.addClass("ui-magnifier");
- if(!(/^(r|a)/).test(this.element.css("position"))) this.element.css("position", "relative");
-
- this.pp = this.element.offset();
-
- $(o.items, this.element).each(function() {
+ var self = this, o = this.options;
+ this.items = [];
+ this.element.addClass("ui-magnifier");
+ if(!(/^(r|a)/).test(this.element.css("position"))) this.element.css("position", "relative");
+
+ this.pp = this.element.offset();
+
+ $(o.items, this.element).each(function() {
- self.items.push([
- this,
- $(this).offset(),
- [$(this).width(),$(this).height()],
- (o.overlap ? $(this).position() : null)
- ]);
+ self.items.push([
+ this,
+ $(this).offset(),
+ [$(this).width(),$(this).height()],
+ (o.overlap ? $(this).position() : null)
+ ]);
- if(o.opacity)
- $(this).css('opacity', o.opacity.min);
+ if(o.opacity)
+ $(this).css('opacity', o.opacity.min);
+ });
+
+ if(o.overlap) {
+ for(var i=0;i<this.items.length;i++) {
+ //Absolutize
+ $(this.items[i][0]).css({
+ position: "absolute",
+ top: this.items[i][3].top,
+ left: this.items[i][3].left
+ });
+ };
+ }
+
+ this.identifier = ++$.ui.magnifier.counter;
+ $(document).bind("mousemove.magnifier"+this.identifier, function(e) {
+ if(!self.disabled) self.magnify.apply(self, [e]);
+ });
+
+ if(o.click) {
+ this.element.bind('click.magnifier', function(e) {
+ if(!self.disabled) o.click.apply(this, [e, { options: self.options, current: self.current[0], currentOffset: self.current[1] }]);
});
+ }
+
+ },
+
+
+ destroy: function() {
+ this.reset();
+ this.element
+ .removeClass("ui-magnifier")
+ .removeClass("ui-magnifier-disabled")
+ .unbind(".magnifier");
+ $(document).unbind("mousemove.magnifier"+this.identifier);
+ },
+ disable: function() {
+ this.reset();
+ this.element.addClass("ui-magnifier-disabled");
+ this.options.disabled = true;
+ },
+ reset: function(e) {
- if(o.overlap) {
- for(var i=0;i<this.items.length;i++) {
- //Absolutize
- $(this.items[i][0]).css({
- position: "absolute",
- top: this.items[i][3].top,
- left: this.items[i][3].left
- });
- };
- }
+ var o = this.options, c, distance = 1;
+
+ for(var i=0; i < this.items.length; i++) {
+
+ c = this.items[i];
- this.identifier = ++$.ui.magnifier.counter;
- $(document).bind("mousemove.magnifier"+this.identifier, function(e) {
- if(!self.disabled) self.magnify.apply(self, [e]);
+ $(c[0]).css({
+ width: c[2][0],
+ height: c[2][1],
+ top: (c[3] ? c[3].top : 0),
+ left: (c[3] ? c[3].left : 0)
});
- if(o.click) {
- this.element.bind('click.magnifier', function(e) {
- if(!self.disabled) o.click.apply(this, [e, { options: self.options, current: self.current[0], currentOffset: self.current[1] }]);
- });
- }
+ if(o.opacity)
+ $(c[0]).css('opacity', o.opacity.min);
+
+ if(o.zIndex)
+ $(c[0]).css("z-index", "");
+
+ }
- },
-
+ },
+ magnify: function(e) {
- destroy: function() {
- this.reset();
- this.element
- .removeClass("ui-magnifier")
- .removeClass("ui-magnifier-disabled")
- .unbind(".magnifier");
- $(document).unbind("mousemove.magnifier"+this.identifier);
- },
- disable: function() {
- this.reset();
- this.element.addClass("ui-magnifier-disabled");
- this.options.disabled = true;
- },
- reset: function(e) {
+ var p = [e.pageX,e.pageY], o = this.options, c, distance = 1;
+ this.current = this.items[0];
+
+ //Compute the parents distance, because we don't need to fire anything if we are not near the parent
+ var overlap = ((p[0] > this.pp.left-o.distance && p[0] < this.pp.left + this.element[0].offsetWidth + o.distance) && (p[1] > this.pp.top-o.distance && p[1] < this.pp.top + this.element[0].offsetHeight + o.distance));
+ if(!overlap) return false;
- var o = this.options, c, distance = 1;
+ for(var i=0;i<this.items.length;i++) {
- for(var i=0; i < this.items.length; i++) {
-
- c = this.items[i];
+ c = this.items[i];
+
+ var olddistance = distance;
+ if(!o.axis) {
+ distance = Math.sqrt(
+ Math.pow(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2), 2)
+ + Math.pow(p[1] - ((c[3] ? this.pp.top : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2), 2)
+ );
+ } else {
+ if(o.axis == "y") {
+ distance = Math.abs(p[1] - ((c[3] ? this.pp.top : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2));
+ } else {
+ distance = Math.abs(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2));
+ }
+ }
+
+ if(distance < o.distance) {
+
+ this.current = distance < olddistance ? this.items[i] : this.current;
+
+ if(!o.axis || o.axis != "y") {
+ $(c[0]).css({
+ width: c[2][0]+ (c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)),
+ left: (c[3] ? (c[3].left + o.verticalLine * ((c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)))) : 0)
+ });
+ }
+
+ if(!o.axis || o.axis != "x") {
+ $(c[0]).css({
+ height: c[2][1]+ (c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)),
+ top: (c[3] ? c[3].top : 0) + (o.baseline-0.5) * ((c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)))
+ });
+ }
+
+ if(o.opacity)
+ $(c[0]).css('opacity', o.opacity.max-(distance/o.distance) < o.opacity.min ? o.opacity.min : o.opacity.max-(distance/o.distance));
+
+ } else {
$(c[0]).css({
width: c[2][0],
@@ -79,97 +157,31 @@
if(o.opacity)
$(c[0]).css('opacity', o.opacity.min);
-
- if(o.zIndex)
- $(c[0]).css("z-index", "");
-
+
}
-
- },
- magnify: function(e) {
- var p = [e.pageX,e.pageY], o = this.options, c, distance = 1;
- this.current = this.items[0];
-
- //Compute the parents distance, because we don't need to fire anything if we are not near the parent
- var overlap = ((p[0] > this.pp.left-o.distance && p[0] < this.pp.left + this.element[0].offsetWidth + o.distance) && (p[1] > this.pp.top-o.distance && p[1] < this.pp.top + this.element[0].offsetHeight + o.distance));
- if(!overlap) return false;
-
- for(var i=0;i<this.items.length;i++) {
-
- c = this.items[i];
-
- var olddistance = distance;
- if(!o.axis) {
- distance = Math.sqrt(
- Math.pow(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2), 2)
- + Math.pow(p[1] - ((c[3] ? this.pp.top : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2), 2)
- );
- } else {
- if(o.axis == "y") {
- distance = Math.abs(p[1] - ((c[3] ? this.pp.top : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2));
- } else {
- distance = Math.abs(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2));
- }
- }
-
- if(distance < o.distance) {
-
- this.current = distance < olddistance ? this.items[i] : this.current;
-
- if(!o.axis || o.axis != "y") {
- $(c[0]).css({
- width: c[2][0]+ (c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)),
- left: (c[3] ? (c[3].left + o.verticalLine * ((c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)))) : 0)
- });
- }
-
- if(!o.axis || o.axis != "x") {
- $(c[0]).css({
- height: c[2][1]+ (c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)),
- top: (c[3] ? c[3].top : 0) + (o.baseline-0.5) * ((c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)))
- });
- }
-
- if(o.opacity)
- $(c[0]).css('opacity', o.opacity.max-(distance/o.distance) < o.opacity.min ? o.opacity.min : o.opacity.max-(distance/o.distance));
-
- } else {
-
- $(c[0]).css({
- width: c[2][0],
- height: c[2][1],
- top: (c[3] ? c[3].top : 0),
- left: (c[3] ? c[3].left : 0)
- });
-
- if(o.opacity)
- $(c[0]).css('opacity', o.opacity.min);
-
- }
-
- if(o.zIndex)
- $(c[0]).css("z-index", "");
-
- }
-
- if(this.options.zIndex)
- $(this.current[0]).css("z-index", this.options.zIndex);
-
- }
+ if(o.zIndex)
+ $(c[0]).css("z-index", "");
+
+ }
+ if(this.options.zIndex)
+ $(this.current[0]).css("z-index", this.options.zIndex);
- });
+ }
+
- $.extend($.ui.magnifier, {
- counter: 0,
- defaults: {
- distance: 150,
- magnification: 2,
- baseline: 0,
- verticalLine: -0.5,
- items: "> *"
- }
- });
+});
+
+$.extend($.ui.magnifier, {
+ counter: 0,
+ defaults: {
+ distance: 150,
+ magnification: 2,
+ baseline: 0,
+ verticalLine: -0.5,
+ items: "> *"
+ }
+});
})(jQuery);
diff --git a/ui/ui.progressbar.js b/ui/ui.progressbar.js
index 55f26cba9..124cb6f44 100644
--- a/ui/ui.progressbar.js
+++ b/ui/ui.progressbar.js
@@ -8,188 +8,186 @@
* http://docs.jquery.com/UI/ProgressBar
*
* Depends:
- * ui.base.js
- *
- * Revision: $Id: ui.progressbar.js 5196 2008-04-04 12:52:32Z braeker $
+ * ui.core.js
*/
-;(function($) {
+(function($) {
- $.widget("ui.progressbar", {
- init: function() {
+$.widget("ui.progressbar", {
+ init: function() {
- var self = this, o = this.options, text = o.text ? o.text : (o.range ? '0%' : '');;
- this.element.addClass("ui-progressbar");
+ var self = this, o = this.options, text = o.text ? o.text : (o.range ? '0%' : '');;
+ this.element.addClass("ui-progressbar");
- $.extend(o, {
- stepping: o.stepping > 100 ? 100 : o.stepping
- });
-
- $.extend(this, {
- _step: 0,
- rangeValue: 0,
- threads: {},
-
- wrapper: $("<div class='ui-progressbar-wrap'></div>"),
- bar: $("<div class='ui-progressbar-bar ui-hidden'></div>").css({
- width: '0px', overflow: 'hidden', zIndex: 100
- }),
- textElement: $("<div class='ui-progressbar-text'></div>").html(text).css({
- width: '0px', overflow: 'hidden'
- }),
- textBg: $("<div class='ui-progressbar-text ui-progressbar-text-back'></div>").html(text).css({
- width: this.element.css('width')
- })
-
- });
-
- this.wrapper
- .append(this.bar.append(this.textElement), this.textBg)
- .appendTo(this.element);
+ $.extend(o, {
+ stepping: o.stepping > 100 ? 100 : o.stepping
+ });
+
+ $.extend(this, {
+ _step: 0,
+ rangeValue: 0,
+ threads: {},
+
+ wrapper: $("<div class='ui-progressbar-wrap'></div>"),
+ bar: $("<div class='ui-progressbar-bar ui-hidden'></div>").css({
+ width: '0px', overflow: 'hidden', zIndex: 100
+ }),
+ textElement: $("<div class='ui-progressbar-text'></div>").html(text).css({
+ width: '0px', overflow: 'hidden'
+ }),
+ textBg: $("<div class='ui-progressbar-text ui-progressbar-text-back'></div>").html(text).css({
+ width: this.element.css('width')
+ })
+
+ });
+
+ this.wrapper
+ .append(this.bar.append(this.textElement), this.textBg)
+ .appendTo(this.element);
- },
-
- plugins: {},
- ui: function(e) {
- return {
- instance: this,
- options: this.options,
- step: this._step,
- rangeValue: this.rangeValue,
- pixelRange: this.pixelRange
- };
- },
- 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.reset();
-
- this.element
- .removeClass("ui-progressbar ui-progressbar-disabled")
- .removeData("progressbar").unbind(".progressbar")
- .find('.ui-progressbar-wrap').remove();
- },
- enable: function() {
- this.element.removeClass("ui-progressbar-disabled");
- this.disabled = false;
- if(this.inProgress) this.start();
- },
- disable: function() {
- this.element.addClass("ui-progressbar-disabled");
- this.disabled = true;
- this.clearThreads();
- },
- start: function() {
-
- if (this.disabled) return false;
- this.inProgress = true;
-
- var self = this, o = this.options, el = this.element;
- this.clearThreads();
-
- if (typeof o.wait == 'number' && !self.waitThread)
- self.waitThread = setTimeout(function() {
- clearInterval(self.waitThread);
- self.waitThread = null;
- }, o.wait);
-
- var frames = Math.ceil(100/o.stepping) || 0, ms = o.duration/frames || 0,
+ },
+
+ plugins: {},
+ ui: function(e) {
+ return {
+ instance: this,
+ options: this.options,
+ step: this._step,
+ rangeValue: this.rangeValue,
+ pixelRange: this.pixelRange
+ };
+ },
+ 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.reset();
+
+ this.element
+ .removeClass("ui-progressbar ui-progressbar-disabled")
+ .removeData("progressbar").unbind(".progressbar")
+ .find('.ui-progressbar-wrap').remove();
+ },
+ enable: function() {
+ this.element.removeClass("ui-progressbar-disabled");
+ this.disabled = false;
+ if(this.inProgress) this.start();
+ },
+ disable: function() {
+ this.element.addClass("ui-progressbar-disabled");
+ this.disabled = true;
+ this.clearThreads();
+ },
+ start: function() {
+
+ if (this.disabled) return false;
+ this.inProgress = true;
+
+ var self = this, o = this.options, el = this.element;
+ this.clearThreads();
+
+ if (typeof o.wait == 'number' && !self.waitThread)
+ self.waitThread = setTimeout(function() {
+ clearInterval(self.waitThread);
+ self.waitThread = null;
+ }, o.wait);
+
+ var frames = Math.ceil(100/o.stepping) || 0, ms = o.duration/frames || 0,
+
+ render = function(step, t) {
+ //clearInterval(t);
- render = function(step, t) {
- //clearInterval(t);
-
- self.progress(o.stepping * step);
- // on end
- if (step >= frames) {
- self.stop();
+ self.progress(o.stepping * step);
+ // on end
+ if (step >= frames) {
+ self.stop();
- if (self.waitThread || o.wait == 'loop') {
- self._step = 0;
- self.start();
- }
+ if (self.waitThread || o.wait == 'loop') {
+ self._step = 0;
+ self.start();
}
- };
- var from = this._step, _step = (this._step - (from - 1));
-
- /*for(var step = from; step <= frames; step++) {
- var interval = (step - (from - 1)) * ms;
- this.threads[step] = setTimeout(render(step, this.threads[step]), interval);
- }*/
-
- this.threads[0] = setInterval(function() {
- render(_step++);
- }, ms);
-
- this.propagate('start');
- return false;
- },
- clearThreads: function() {
- $.each(this.threads, function(s, t) { clearInterval(t); });
- this.threads = {};
- },
- stop: function() {
-
- if (this.disabled) return false;
- var o = this.options, self = this;
-
- this.clearThreads();
- this.propagate('stop');
-
- this.inProgress = false;
- return false;
-
- },
- reset: function() {
-
- if (this.disabled) return false;
- this._step = 0;
- this.rangeValue = 0;
- this.inProgress = false;
- this.clearThreads();
- this.progress(0);
- this.bar.addClass('ui-hidden');
- return false;
-
- },
- progress: function(range) {
-
- var o = this.options, el = this.element, bar = this.bar;
- if (this.disabled) return false;
-
- range = parseInt(range, 10);
- this.rangeValue = this._fixRange(range);
- this.pixelRange = Math.round( ((this.rangeValue/100)||0) * (el.innerWidth() - (el.outerWidth() - el.innerWidth()) - (bar.outerWidth() - bar.innerWidth())) );
-
- this.bar.removeClass('ui-hidden');
-
- var css = { width: this.pixelRange + 'px' };
- this.bar.css(css);
- this.textElement.css(css);
-
- if (!o.text && o.range) this.text(this.rangeValue + '%');
- this.propagate('progress', this.rangeValue);
- return false;
- },
- text: function(text) {
- this.textElement.html(text);
- },
- _fixRange: function(range) {
- var o = this.options;
- this._step = Math.ceil(range/o.stepping);
- this.rangeValue = Math.round(o.stepping * this._step);
- this.rangeValue = (this.rangeValue) >= 100 ? 100 : this.rangeValue;
- return this.rangeValue;
- }
- });
-
- $.ui.progressbar.defaults = {
- duration: 3000,
- stepping: 1,
- text: '',
- range: true,
- addClass: '',
- textClass: ''
- };
+ }
+ };
+ var from = this._step, _step = (this._step - (from - 1));
+
+ /*for(var step = from; step <= frames; step++) {
+ var interval = (step - (from - 1)) * ms;
+ this.threads[step] = setTimeout(render(step, this.threads[step]), interval);
+ }*/
+
+ this.threads[0] = setInterval(function() {
+ render(_step++);
+ }, ms);
+
+ this.propagate('start');
+ return false;
+ },
+ clearThreads: function() {
+ $.each(this.threads, function(s, t) { clearInterval(t); });
+ this.threads = {};
+ },
+ stop: function() {
+
+ if (this.disabled) return false;
+ var o = this.options, self = this;
+
+ this.clearThreads();
+ this.propagate('stop');
+
+ this.inProgress = false;
+ return false;
+
+ },
+ reset: function() {
+
+ if (this.disabled) return false;
+ this._step = 0;
+ this.rangeValue = 0;
+ this.inProgress = false;
+ this.clearThreads();
+ this.progress(0);
+ this.bar.addClass('ui-hidden');
+ return false;
+
+ },
+ progress: function(range) {
+
+ var o = this.options, el = this.element, bar = this.bar;
+ if (this.disabled) return false;
+
+ range = parseInt(range, 10);
+ this.rangeValue = this._fixRange(range);
+ this.pixelRange = Math.round( ((this.rangeValue/100)||0) * (el.innerWidth() - (el.outerWidth() - el.innerWidth()) - (bar.outerWidth() - bar.innerWidth())) );
+
+ this.bar.removeClass('ui-hidden');
+
+ var css = { width: this.pixelRange + 'px' };
+ this.bar.css(css);
+ this.textElement.css(css);
+
+ if (!o.text && o.range) this.text(this.rangeValue + '%');
+ this.propagate('progress', this.rangeValue);
+ return false;
+ },
+ text: function(text) {
+ this.textElement.html(text);
+ },
+ _fixRange: function(range) {
+ var o = this.options;
+ this._step = Math.ceil(range/o.stepping);
+ this.rangeValue = Math.round(o.stepping * this._step);
+ this.rangeValue = (this.rangeValue) >= 100 ? 100 : this.rangeValue;
+ return this.rangeValue;
+ }
+});
+
+$.ui.progressbar.defaults = {
+ duration: 3000,
+ stepping: 1,
+ text: '',
+ range: true,
+ addClass: '',
+ textClass: ''
+};
})(jQuery);
diff --git a/ui/ui.spinner.js b/ui/ui.spinner.js
index 064ec9aac..34f759982 100644
--- a/ui/ui.spinner.js
+++ b/ui/ui.spinner.js
@@ -1,114 +1,126 @@
+/*
+ * jQuery UI Spinner
+ *
+ * Copyright (c) 2008 jQuery
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI/Spinner
+ *
+ * Depends:
+ * ui.core.js
+ */
(function($) {
- $.widget("ui.spinner", {
- init: function() {
+$.widget("ui.spinner", {
+ init: function() {
- //Initialize needed constants
- var self = this;
- this.element.addClass("ui-spinner");
- this.element[0].value = this.options.start;
-
- var pickerHeight = this.element.innerHeight() / 2 - parseInt(this.element.css("borderTopWidth"),10) - 2;
- this.element
- .wrap("<div>")
- .parent()
- .css({
- position: this.element.css("position") == "static" ? "relative" : this.element.css("position"),
- left: this.element.css("left"),
- top: this.element.css("top"),
- width: this.element.outerWidth(),
- height: this.element.outerHeight()
- })
- .css("float", this.element.css("float"))
- .prepend('<div class="ui-spinner-up"></div>')
- .find("div.ui-spinner-up")
- .bind("mousedown", function() { if(!self.counter) self.counter = 1; self.mousedown(100, "up"); })
- .bind("mouseup", function(e) { self.counter = 0; if(self.timer) window.clearInterval(self.timer); self.element[0].focus(); self.propagate("change", e); })
- .css({ height: pickerHeight, top: parseInt(this.element.css("borderTopWidth"),10)+1, right: parseInt(this.element.css("borderRightWidth"),10)+1 })
- .end()
- .append('<div class="ui-spinner-down"></div>')
- .find("div.ui-spinner-down")
- .bind("mousedown", function() { if(!self.counter) self.counter = 1; self.mousedown(100, "down"); })
- .bind("mouseup", function(e) { self.counter = 0; if(self.timer) window.clearInterval(self.timer); self.element[0].focus(); self.propagate("change", e); })
- .css({ height: pickerHeight, bottom: parseInt(this.element.css("borderBottomWidth"),10)+1, right: parseInt(this.element.css("borderRightWidth"),10)+1 })
- .end()
- ;
-
- this.element
- .bind("keydown.spinner", function(e) {
- if(!self.counter) self.counter = 1;
- self.keydown.call(self, e);
+ //Initialize needed constants
+ var self = this;
+ this.element.addClass("ui-spinner");
+ this.element[0].value = this.options.start;
+
+ var pickerHeight = this.element.innerHeight() / 2 - parseInt(this.element.css("borderTopWidth"),10) - 2;
+ this.element
+ .wrap("<div>")
+ .parent()
+ .css({
+ position: this.element.css("position") == "static" ? "relative" : this.element.css("position"),
+ left: this.element.css("left"),
+ top: this.element.css("top"),
+ width: this.element.outerWidth(),
+ height: this.element.outerHeight()
})
- .bind("keyup.spinner", function(e) {
- self.counter = 0;
- self.cleanUp();
- self.propagate("change", e);
- })
- ;
+ .css("float", this.element.css("float"))
+ .prepend('<div class="ui-spinner-up"></div>')
+ .find("div.ui-spinner-up")
+ .bind("mousedown", function() { if(!self.counter) self.counter = 1; self.mousedown(100, "up"); })
+ .bind("mouseup", function(e) { self.counter = 0; if(self.timer) window.clearInterval(self.timer); self.element[0].focus(); self.propagate("change", e); })
+ .css({ height: pickerHeight, top: parseInt(this.element.css("borderTopWidth"),10)+1, right: parseInt(this.element.css("borderRightWidth"),10)+1 })
+ .end()
+ .append('<div class="ui-spinner-down"></div>')
+ .find("div.ui-spinner-down")
+ .bind("mousedown", function() { if(!self.counter) self.counter = 1; self.mousedown(100, "down"); })
+ .bind("mouseup", function(e) { self.counter = 0; if(self.timer) window.clearInterval(self.timer); self.element[0].focus(); self.propagate("change", e); })
+ .css({ height: pickerHeight, bottom: parseInt(this.element.css("borderBottomWidth"),10)+1, right: parseInt(this.element.css("borderRightWidth"),10)+1 })
+ .end()
+ ;
+
+ this.element
+ .bind("keydown.spinner", function(e) {
+ if(!self.counter) self.counter = 1;
+ self.keydown.call(self, e);
+ })
+ .bind("keyup.spinner", function(e) {
+ self.counter = 0;
+ self.cleanUp();
+ self.propagate("change", e);
+ })
+ ;
+
+ },
+ plugins: {},
+ constrain: function() {
+ if(this.options.min != undefined && this.element[0].value < this.options.min) this.element[0].value = this.options.min;
+ if(this.options.max != undefined && this.element[0].value > this.options.max) this.element[0].value = this.options.max;
+ },
+ cleanUp: function() {
+ this.element[0].value = this.element[0].value.replace(/[^0-9\-]/g, '');
+ this.constrain();
+ },
+ down: function(e) {
+ if(isNaN(parseInt(this.element[0].value,10))) this.element[0].value = this.options.start;
+ this.element[0].value -= (this.options.incremental && this.counter > 100 ? (this.counter > 200 ? 100 : 10) : 1) * this.options.stepping;
+ this.constrain();
+ if(this.counter) this.counter++;
+ this.propagate("spin", e);
+ },
+ up: function(e) {
+ if(isNaN(parseInt(this.element[0].value,10))) this.element[0].value = this.options.start;
+ this.element[0].value = parseFloat(this.element[0].value) + (this.options.incremental && this.counter > 100 ? (this.counter > 200 ? 100 : 10) : 1) * this.options.stepping;
+ this.constrain();
+ if(this.counter) this.counter++;
+ this.propagate("spin", e);
+ },
+ mousedown: function(i, d) {
+ var self = this;
+ i = i || 100;
+ if(this.timer) window.clearInterval(this.timer);
+ this.timer = window.setInterval(function() {
+ self[d]();
+ if(self.counter > 20) self.mousedown(20, d);
+ }, i);
+ },
+ keydown: function(e) {
+ if(e.keyCode == 38 || e.keyCode == 39) this.up(e);
+ if(e.keyCode == 40 || e.keyCode == 37) this.down(e);
+ if(e.keyCode == 36) this.element[0].value = this.options.min || this.options.start; //Home key goes to min, if defined, else to start
+ if(e.keyCode == 35 && this.options.max != undefined) this.element[0].value = this.options.max; //End key goes to maximum
+ },
+ ui: function(e) {
+ return {
+ instance: this,
+ options: this.options,
+ element: this.element
+ };
+ },
+ propagate: function(n,e) {
+ $.ui.plugin.call(this, n, [e, this.ui()]);
+ return this.element.triggerHandler(n == "spin" ? n : "spin"+n, [e, this.ui()], this.options[n]);
+ },
+ destroy: function() {
+ if(!$.data(this.element[0], 'spinner')) return;
+ this.element
+ .removeClass("ui-spinner ui-spinner-disabled")
+ .removeData("spinner")
+ .unbind(".spinner");
+ }
+});
+
+$.ui.spinner.defaults = {
+ stepping: 1,
+ start: 0,
+ incremental: true
+};
- },
- plugins: {},
- constrain: function() {
- if(this.options.min != undefined && this.element[0].value < this.options.min) this.element[0].value = this.options.min;
- if(this.options.max != undefined && this.element[0].value > this.options.max) this.element[0].value = this.options.max;
- },
- cleanUp: function() {
- this.element[0].value = this.element[0].value.replace(/[^0-9\-]/g, '');
- this.constrain();
- },
- down: function(e) {
- if(isNaN(parseInt(this.element[0].value,10))) this.element[0].value = this.options.start;
- this.element[0].value -= (this.options.incremental && this.counter > 100 ? (this.counter > 200 ? 100 : 10) : 1) * this.options.stepping;
- this.constrain();
- if(this.counter) this.counter++;
- this.propagate("spin", e);
- },
- up: function(e) {
- if(isNaN(parseInt(this.element[0].value,10))) this.element[0].value = this.options.start;
- this.element[0].value = parseFloat(this.element[0].value) + (this.options.incremental && this.counter > 100 ? (this.counter > 200 ? 100 : 10) : 1) * this.options.stepping;
- this.constrain();
- if(this.counter) this.counter++;
- this.propagate("spin", e);
- },
- mousedown: function(i, d) {
- var self = this;
- i = i || 100;
- if(this.timer) window.clearInterval(this.timer);
- this.timer = window.setInterval(function() {
- self[d]();
- if(self.counter > 20) self.mousedown(20, d);
- }, i);
- },
- keydown: function(e) {
- if(e.keyCode == 38 || e.keyCode == 39) this.up(e);
- if(e.keyCode == 40 || e.keyCode == 37) this.down(e);
- if(e.keyCode == 36) this.element[0].value = this.options.min || this.options.start; //Home key goes to min, if defined, else to start
- if(e.keyCode == 35 && this.options.max != undefined) this.element[0].value = this.options.max; //End key goes to maximum
- },
- ui: function(e) {
- return {
- instance: this,
- options: this.options,
- element: this.element
- };
- },
- propagate: function(n,e) {
- $.ui.plugin.call(this, n, [e, this.ui()]);
- return this.element.triggerHandler(n == "spin" ? n : "spin"+n, [e, this.ui()], this.options[n]);
- },
- destroy: function() {
- if(!$.data(this.element[0], 'spinner')) return;
- this.element
- .removeClass("ui-spinner ui-spinner-disabled")
- .removeData("spinner")
- .unbind(".spinner");
- }
- });
-
- $.ui.spinner.defaults = {
- stepping: 1,
- start: 0,
- incremental: true
- };
-
-})(jQuery); \ No newline at end of file
+})(jQuery);