diff options
author | Richard Worth <rdworth@gmail.com> | 2008-11-18 02:55:25 +0000 |
---|---|---|
committer | Richard Worth <rdworth@gmail.com> | 2008-11-18 02:55:25 +0000 |
commit | 29f7dc9a2c078495f6a0ed13c531733146528fb4 (patch) | |
tree | 5d56f5a7ecba3c8173de3322c2a85bfecf61348b /ui | |
parent | ce69e7ced4e8786ca5164372007c48a11ba90e72 (diff) | |
download | jquery-ui-29f7dc9a2c078495f6a0ed13c531733146528fb4.tar.gz jquery-ui-29f7dc9a2c078495f6a0ed13c531733146528fb4.zip |
Removed all trailing whitespace from .js and .html files
Diffstat (limited to 'ui')
-rw-r--r-- | ui/effects.blind.js | 10 | ||||
-rw-r--r-- | ui/effects.bounce.js | 4 | ||||
-rw-r--r-- | ui/effects.clip.js | 12 | ||||
-rw-r--r-- | ui/effects.core.js | 2 | ||||
-rw-r--r-- | ui/effects.drop.js | 12 | ||||
-rw-r--r-- | ui/effects.explode.js | 18 | ||||
-rw-r--r-- | ui/effects.fold.js | 12 | ||||
-rw-r--r-- | ui/effects.highlight.js | 14 | ||||
-rw-r--r-- | ui/effects.pulsate.js | 10 | ||||
-rw-r--r-- | ui/effects.scale.js | 34 | ||||
-rw-r--r-- | ui/effects.shake.js | 10 | ||||
-rw-r--r-- | ui/effects.slide.js | 12 | ||||
-rw-r--r-- | ui/effects.transfer.js | 12 | ||||
-rw-r--r-- | ui/ui.accordion.js | 74 | ||||
-rw-r--r-- | ui/ui.core.js | 148 | ||||
-rw-r--r-- | ui/ui.datepicker.js | 134 | ||||
-rw-r--r-- | ui/ui.dialog.js | 126 | ||||
-rw-r--r-- | ui/ui.droppable.js | 104 | ||||
-rw-r--r-- | ui/ui.progressbar.js | 62 | ||||
-rw-r--r-- | ui/ui.resizable.js | 310 | ||||
-rw-r--r-- | ui/ui.selectable.js | 52 | ||||
-rw-r--r-- | ui/ui.slider.js | 116 | ||||
-rw-r--r-- | ui/ui.spinner.js | 30 | ||||
-rw-r--r-- | ui/ui.tabs.js | 126 |
24 files changed, 722 insertions, 722 deletions
diff --git a/ui/effects.blind.js b/ui/effects.blind.js index bdcd1e66a..e56dfba65 100644 --- a/ui/effects.blind.js +++ b/ui/effects.blind.js @@ -18,18 +18,18 @@ $.effects.blind = function(o) { // Create element var el = $(this), props = ['position','top','left']; - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var direction = o.options.direction || 'vertical'; // Default direction - + // Adjust $.effects.save(el, props); el.show(); // Save & Show var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper var ref = (direction == 'vertical') ? 'height' : 'width'; var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width(); if(mode == 'show') wrapper.css(ref, 0); // Shift - + // Animation var animation = {}; animation[ref] = mode == 'show' ? distance : 0; @@ -41,9 +41,9 @@ $.effects.blind = function(o) { if(o.callback) o.callback.apply(el[0], arguments); // Callback el.dequeue(); }); - + }); - + }; })(jQuery); diff --git a/ui/effects.bounce.js b/ui/effects.bounce.js index f4d347505..b32b5ba66 100644 --- a/ui/effects.bounce.js +++ b/ui/effects.bounce.js @@ -36,7 +36,7 @@ $.effects.bounce = function(o) { if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift if (mode == 'hide') distance = distance / (times * 2); if (mode != 'hide') times--; - + // Animate if (mode == 'show') { // Show Bounce var animation = {opacity: 1}; @@ -72,7 +72,7 @@ $.effects.bounce = function(o) { el.queue('fx', function() { el.dequeue(); }); el.dequeue(); }); - + }; })(jQuery); diff --git a/ui/effects.clip.js b/ui/effects.clip.js index f10922282..46d59472f 100644 --- a/ui/effects.clip.js +++ b/ui/effects.clip.js @@ -18,11 +18,11 @@ $.effects.clip = function(o) { // Create element var el = $(this), props = ['position','top','left','height','width']; - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var direction = o.options.direction || 'vertical'; // Default direction - + // Adjust $.effects.save(el, props); el.show(); // Save & Show var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper @@ -33,12 +33,12 @@ $.effects.clip = function(o) { }; var distance = (direction == 'vertical') ? animate.height() : animate.width(); if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift - + // Animation var animation = {}; animation[ref.size] = mode == 'show' ? distance : 0; animation[ref.position] = mode == 'show' ? 0 : distance / 2; - + // Animate animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { if(mode == 'hide') el.hide(); // Hide @@ -46,9 +46,9 @@ $.effects.clip = function(o) { if(o.callback) o.callback.apply(el[0], arguments); // Callback el.dequeue(); }}); - + }); - + }; })(jQuery); diff --git a/ui/effects.core.js b/ui/effects.core.js index 633f90a1e..286360537 100644 --- a/ui/effects.core.js +++ b/ui/effects.core.js @@ -300,7 +300,7 @@ var colors = { yellow:[255,255,0], transparent: [255,255,255] }; - + /* * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ * diff --git a/ui/effects.drop.js b/ui/effects.drop.js index 7166aea66..13a8fffa6 100644 --- a/ui/effects.drop.js +++ b/ui/effects.drop.js @@ -18,11 +18,11 @@ $.effects.drop = function(o) { // Create element var el = $(this), props = ['position','top','left','opacity']; - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var direction = o.options.direction || 'left'; // Default Direction - + // Adjust $.effects.save(el, props); el.show(); // Save & Show $.effects.createWrapper(el); // Create Wrapper @@ -30,11 +30,11 @@ $.effects.drop = function(o) { var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2); if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift - + // Animation var animation = {opacity: mode == 'show' ? 1 : 0}; animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; - + // Animate el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { if(mode == 'hide') el.hide(); // Hide @@ -42,9 +42,9 @@ $.effects.drop = function(o) { if(o.callback) o.callback.apply(this, arguments); // Callback el.dequeue(); }}); - + }); - + }; })(jQuery); diff --git a/ui/effects.explode.js b/ui/effects.explode.js index 7ade03c50..18109a330 100644 --- a/ui/effects.explode.js +++ b/ui/effects.explode.js @@ -18,15 +18,15 @@ $.effects.explode = function(o) { var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; - + o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode; var el = $(this).show().css('visibility', 'hidden'); var offset = el.offset(); - + //Substract the margins - not fixing the problem yet. offset.top -= parseInt(el.css("marginTop")) || 0; offset.left -= parseInt(el.css("marginLeft")) || 0; - + var width = el.outerWidth(true); var height = el.outerHeight(true); @@ -62,18 +62,18 @@ $.effects.explode = function(o) { // Set a timeout, to call the callback approx. when the other animations have finished setTimeout(function() { - + o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide(); if(o.callback) o.callback.apply(el[0]); // Callback el.dequeue(); - + $('.effects-explode').remove(); - + }, o.duration || 500); - - + + }); - + }; })(jQuery); diff --git a/ui/effects.fold.js b/ui/effects.fold.js index 4db29adfa..7964f1985 100644 --- a/ui/effects.fold.js +++ b/ui/effects.fold.js @@ -18,12 +18,12 @@ $.effects.fold = function(o) { // Create element var el = $(this), props = ['position','top','left']; - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var size = o.options.size || 15; // Default fold size var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value - + // Adjust $.effects.save(el, props); el.show(); // Save & Show var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper @@ -33,12 +33,12 @@ $.effects.fold = function(o) { var percent = /([0-9]+)%/.exec(size); if(percent) size = parseInt(percent[1]) / 100 * distance[mode == 'hide' ? 0 : 1]; if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift - + // Animation var animation1 = {}, animation2 = {}; animation1[ref[0]] = mode == 'show' ? distance[0] : size; animation2[ref[1]] = mode == 'show' ? distance[1] : 0; - + // Animate wrapper.animate(animation1, o.duration / 2, o.options.easing) .animate(animation2, o.duration / 2, o.options.easing, function() { @@ -47,9 +47,9 @@ $.effects.fold = function(o) { if(o.callback) o.callback.apply(el[0], arguments); // Callback el.dequeue(); }); - + }); - + }; })(jQuery); diff --git a/ui/effects.highlight.js b/ui/effects.highlight.js index 038b9d6a7..09bbad817 100644 --- a/ui/effects.highlight.js +++ b/ui/effects.highlight.js @@ -15,23 +15,23 @@ $.effects.highlight = function(o) { return this.queue(function() { - + // Create element var el = $(this), props = ['backgroundImage','backgroundColor','opacity']; - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode var color = o.options.color || "#ffff99"; // Default highlight color var oldColor = el.css("backgroundColor"); - + // Adjust $.effects.save(el, props); el.show(); // Save & Show el.css({backgroundImage: 'none', backgroundColor: color}); // Shift - + // Animation var animation = {backgroundColor: oldColor }; if (mode == "hide") animation['opacity'] = 0; - + // Animate el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { if(mode == "hide") el.hide(); @@ -40,9 +40,9 @@ $.effects.highlight = function(o) { if(o.callback) o.callback.apply(this, arguments); el.dequeue(); }}); - + }); - + }; })(jQuery); diff --git a/ui/effects.pulsate.js b/ui/effects.pulsate.js index 8d507b71e..44cb4868f 100644 --- a/ui/effects.pulsate.js +++ b/ui/effects.pulsate.js @@ -15,14 +15,14 @@ $.effects.pulsate = function(o) { return this.queue(function() { - + // Create element var el = $(this); - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode var times = o.options.times || 5; // Default # of times - + // Adjust if (mode == 'hide') times--; if (el.is(':hidden')) { // Show fadeIn @@ -31,7 +31,7 @@ $.effects.pulsate = function(o) { el.animate({opacity: 1}, o.duration / 2, o.options.easing); times = times-2; } - + // Animate for (var i = 0; i < times; i++) { // Pulsate el.animate({opacity: 0}, o.duration / 2, o.options.easing).animate({opacity: 1}, o.duration / 2, o.options.easing); @@ -49,7 +49,7 @@ $.effects.pulsate = function(o) { el.queue('fx', function() { el.dequeue(); }); el.dequeue(); }); - + }; })(jQuery); diff --git a/ui/effects.scale.js b/ui/effects.scale.js index ce185e65e..3ea44683b 100644 --- a/ui/effects.scale.js +++ b/ui/effects.scale.js @@ -18,34 +18,34 @@ $.effects.puff = function(o) { // Create element var el = $(this); - + // Set options var options = $.extend(true, {}, o.options); var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var percent = parseInt(o.options.percent) || 150; // Set default puff percent options.fade = true; // It's not a puff if it doesn't fade! :) var original = {height: el.height(), width: el.width()}; // Save original - + // Adjust var factor = percent / 100; el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor}; - + // Animation options.from = el.from; options.percent = (mode == 'hide') ? percent : 100; options.mode = mode; - + // Animate el.effect('scale', options, o.duration, o.callback); el.dequeue(); }); - + }; $.effects.scale = function(o) { - + return this.queue(function() { - + // Create element var el = $(this); @@ -61,33 +61,33 @@ $.effects.scale = function(o) { } var original = {height: el.height(), width: el.width()}; // Save original el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state - + // Adjust var factor = { // Set scaling factor y: direction != 'horizontal' ? (percent / 100) : 1, x: direction != 'vertical' ? (percent / 100) : 1 }; el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state - + if (o.options.fade) { // Fade option to support puff if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;}; if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;}; }; - + // Animation options.from = el.from; options.to = el.to; options.mode = mode; - + // Animate el.effect('size', options, o.duration, o.callback); el.dequeue(); }); - + }; $.effects.size = function(o) { return this.queue(function() { - + // Create element var el = $(this), props = ['position','top','left','width','height','overflow','opacity']; var props1 = ['position','top','left','overflow','opacity']; // Always restore @@ -95,7 +95,7 @@ $.effects.size = function(o) { var cProps = ['fontSize']; var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom']; var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight']; - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode var restore = o.options.restore || false; // Default restore @@ -138,7 +138,7 @@ $.effects.size = function(o) { $.effects.save(el, restore ? props : props1); el.show(); // Save & Show $.effects.createWrapper(el); // Create Wrapper el.css('overflow','hidden').css(el.from); // Shift - + // Animate if (scale == 'content' || scale == 'both') { // Scale the children vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size @@ -164,7 +164,7 @@ $.effects.size = function(o) { }); // Animate children }); }; - + // Animate el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { if(mode == 'hide') el.hide(); // Hide @@ -172,7 +172,7 @@ $.effects.size = function(o) { if(o.callback) o.callback.apply(this, arguments); // Callback el.dequeue(); }}); - + }); }; diff --git a/ui/effects.shake.js b/ui/effects.shake.js index 0af029c9d..c4b922dd8 100644 --- a/ui/effects.shake.js +++ b/ui/effects.shake.js @@ -18,26 +18,26 @@ $.effects.shake = function(o) { // Create element var el = $(this), props = ['position','top','left']; - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode var direction = o.options.direction || 'left'; // Default direction var distance = o.options.distance || 20; // Default distance var times = o.options.times || 3; // Default # of times var speed = o.duration || o.options.duration || 140; // Default speed per shake - + // Adjust $.effects.save(el, props); el.show(); // Save & Show $.effects.createWrapper(el); // Create Wrapper var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; - + // Animation var animation = {}, animation1 = {}, animation2 = {}; animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance; animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2; animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2; - + // Animate el.animate(animation, speed, o.options.easing); for (var i = 1; i < times; i++) { // Shakes @@ -51,7 +51,7 @@ $.effects.shake = function(o) { el.queue('fx', function() { el.dequeue(); }); el.dequeue(); }); - + }; })(jQuery); diff --git a/ui/effects.slide.js b/ui/effects.slide.js index c48994764..24237e73f 100644 --- a/ui/effects.slide.js +++ b/ui/effects.slide.js @@ -18,11 +18,11 @@ $.effects.slide = function(o) { // Create element var el = $(this), props = ['position','top','left']; - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode var direction = o.options.direction || 'left'; // Default Direction - + // Adjust $.effects.save(el, props); el.show(); // Save & Show $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper @@ -30,11 +30,11 @@ $.effects.slide = function(o) { var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true})); if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift - + // Animation var animation = {}; animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; - + // Animate el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { if(mode == 'hide') el.hide(); // Hide @@ -42,9 +42,9 @@ $.effects.slide = function(o) { if(o.callback) o.callback.apply(this, arguments); // Callback el.dequeue(); }}); - + }); - + }; })(jQuery); diff --git a/ui/effects.transfer.js b/ui/effects.transfer.js index 7940216a6..d18c86613 100644 --- a/ui/effects.transfer.js +++ b/ui/effects.transfer.js @@ -18,14 +18,14 @@ $.effects.transfer = function(o) { // Create element var el = $(this); - + // Set options var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode var target = $(o.options.to); // Find Target var position = el.offset(); var transfer = $('<div class="ui-effects-transfer"></div>').appendTo(document.body); if(o.options.className) transfer.addClass(o.options.className); - + // Set target css transfer.addClass(o.options.className); transfer.css({ @@ -35,7 +35,7 @@ $.effects.transfer = function(o) { width: el.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')), position: 'absolute' }); - + // Animation position = target.offset(); animation = { @@ -44,16 +44,16 @@ $.effects.transfer = function(o) { height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')), width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')) }; - + // Animate transfer.animate(animation, o.duration, o.options.easing, function() { transfer.remove(); // Remove div if(o.callback) o.callback.apply(el[0], arguments); // Callback el.dequeue(); }); - + }); - + }; })(jQuery); diff --git a/ui/ui.accordion.js b/ui/ui.accordion.js index 1e519c975..e32c5e214 100644 --- a/ui/ui.accordion.js +++ b/ui/ui.accordion.js @@ -15,7 +15,7 @@ $.widget("ui.accordion", { _init: function() { var options = this.options; - + if ( options.navigation ) { var current = this.element.find("a").filter(options.navigationFilter); if ( current.length ) { @@ -27,23 +27,23 @@ $.widget("ui.accordion", { } } } - + // calculate active if not specified, using the first header options.headers = this.element.find(options.header); options.active = findActive(options.headers, options.active); - + // IE7-/Win - Extra vertical space in Lists fixed if ($.browser.msie) { this.element.find('a').css('zoom', '1'); } - + if (!this.element.hasClass("ui-accordion")) { this.element.addClass("ui-accordion"); $('<span class="ui-accordion-left"/>').insertBefore(options.headers); $('<span class="ui-accordion-right"/>').appendTo(options.headers); options.headers.addClass("ui-accordion-header"); } - + var maxHeight; if ( options.fillSpace ) { maxHeight = this.element.parent().height(); @@ -60,7 +60,7 @@ $.widget("ui.accordion", { maxHeight = Math.max(maxHeight, $(this).outerHeight()); }).height(maxHeight); } - + this.element.attr('role','tablist'); var self=this; @@ -69,14 +69,14 @@ $.widget("ui.accordion", { .bind('keydown', function(event) { return self._keydown(event); }) .next() .attr('role','tabpanel'); - + options.headers .not(options.active || "") .attr('aria-expanded','false') .attr("tabIndex", "-1") .next() .hide(); - + // make sure at least one header is in the tab order if (!options.active.length) { options.headers.eq(0).attr('tabIndex','0'); @@ -86,26 +86,26 @@ $.widget("ui.accordion", { .attr("tabIndex", "0") .parent().andSelf().addClass(options.selectedClass); } - + // only need links in taborder for Safari if (!$.browser.safari) options.headers.find('a').attr('tabIndex','-1'); - + if (options.event) { this.element.bind((options.event) + ".accordion", clickHandler); } }, - + _keydown: function(event) { if (this.options.disabled || event.altKey || event.ctrlKey) return; var keyCode = $.keyCode; - + var length = this.options.headers.length; var currentIndex = this.options.headers.index(event.target); var toFocus = false; - + switch(event.keyCode) { case keyCode.RIGHT: case keyCode.DOWN: @@ -119,7 +119,7 @@ $.widget("ui.accordion", { case keyCode.ENTER: return clickHandler.call(this.element[0], { target: event.target }); } - + if (toFocus) { $(event.target).attr('tabIndex','-1'); $(toFocus).attr('tabIndex','0'); @@ -129,14 +129,14 @@ $.widget("ui.accordion", { return true; }, - + activate: function(index) { // call clickHandler with custom event clickHandler.call(this.element[0], { target: findActive( this.options.headers, index )[0] }); }, - + destroy: function() { this.options.headers.parent().andSelf().removeClass(this.options.selectedClass); this.options.headers.prev(".ui-accordion-left").remove(); @@ -146,7 +146,7 @@ $.widget("ui.accordion", { this.options.headers.next().css("height", ""); } $.removeData(this.element[0], "accordion"); - + this.element.removeClass("ui-accordion").unbind(".accordion"); } }); @@ -162,7 +162,7 @@ function completed(cancel) { if (!$.data(this, "accordion")) { return; } - + var instance = $.data(this, "accordion"); var options = instance.options; options.running = cancel ? 0 : --options.running; @@ -184,15 +184,15 @@ function toggle(toShow, toHide, data, clickedActive, down) { options.toHide = toHide; options.data = data; var complete = scopeCallback(completed, this); - + $.data(this, "accordion")._trigger("changestart", null, options.data); - + // count elements to animate options.running = toHide.size() === 0 ? toShow.size() : toHide.size(); - + if ( options.animated ) { var animOptions = {}; - + if ( !options.alwaysOpen && clickedActive ) { animOptions = { toShow: $([]), @@ -210,25 +210,25 @@ function toggle(toShow, toHide, data, clickedActive, down) { autoHeight: options.autoHeight }; } - + if (!options.proxied) { options.proxied = options.animated; } - + if (!options.proxiedDuration) { options.proxiedDuration = options.duration; } - + options.animated = $.isFunction(options.proxied) ? options.proxied(animOptions) : options.proxied; - + options.duration = $.isFunction(options.proxiedDuration) ? options.proxiedDuration(animOptions) : options.proxiedDuration; var animations = $.ui.accordion.animations, duration = options.duration, easing = options.animated; - + if (!animations[easing]) { animations[easing] = function(options) { this.slide(options, { @@ -237,9 +237,9 @@ function toggle(toShow, toHide, data, clickedActive, down) { }); }; } - + animations[easing](animOptions); - + } else { if ( !options.alwaysOpen && clickedActive ) { toShow.toggle(); @@ -258,7 +258,7 @@ function clickHandler(event) { if (options.disabled) { return false; } - + // called only when using activate(false) to close all parts programmatically if ( !event.target && !options.alwaysOpen ) { options.active.parent().andSelf().toggleClass(options.selectedClass); @@ -276,14 +276,14 @@ function clickHandler(event) { } // get the click target var clicked = $(event.target); - + // due to the event delegation model, we have to check if one // of the parent elements is our actual header, and find that // otherwise stick with the initial target clicked = $( clicked.parents(options.header)[0] || clicked ); - + var clickedActive = clicked[0] == options.active[0]; - + // if animations are still active, or the active header is the target, ignore click if (options.running || (options.alwaysOpen && clickedActive)) { return false; @@ -291,13 +291,13 @@ function clickHandler(event) { if (!clicked.is(options.header)) { return; } - + // switch classes options.active.parent().andSelf().toggleClass(options.selectedClass); if ( !clickedActive ) { clicked.parent().andSelf().addClass(options.selectedClass); } - + // find elements to show and hide var toShow = clicked.next(), toHide = options.active.next(), @@ -309,10 +309,10 @@ function clickHandler(event) { oldContent: toHide }, down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] ); - + options.active = clickedActive ? $([]) : clicked; toggle.call(this, toShow, toHide, data, clickedActive, down ); - + return false; }; diff --git a/ui/ui.core.js b/ui/ui.core.js index 7601588b3..29df97609 100644 --- a/ui/ui.core.js +++ b/ui/ui.core.js @@ -45,9 +45,9 @@ var _remove = $.fn.remove, //Helper functions and ui object $.ui = { - + version: "@VERSION", - + // $.ui.plugin is deprecated. Use the proxy pattern instead. plugin: { add: function(module, option, set) { @@ -60,7 +60,7 @@ $.ui = { call: function(instance, name, args) { var set = instance.plugins[name]; if(!set) { return; } - + for (var i = 0; i < set.length; i++) { if (instance.options[set[i][0]]) { set[i][1].apply(instance.element, args); @@ -68,7 +68,7 @@ $.ui = { } } }, - + contains: function(a, b) { var safari2 = $.browser.safari && $.browser.version < 522; if (a.contains && !safari2) { @@ -80,15 +80,15 @@ $.ui = { if (b == a) return true; return false; }, - + cssCache: {}, css: function(name) { if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; } var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body'); - + //if (!$.browser.safari) //tmp.appendTo('body'); - + //Opera and Safari set width and height to 0px instead of auto //Safari returns rgba(0,0,0,0) when bgcolor is not set $.ui.cssCache[name] = !!( @@ -100,15 +100,15 @@ $.ui = { }, hasScroll: function(el, a) { - + //If overflow is hidden, the element might have extra content, but the user wants to hide it if ($(el).css('overflow') == 'hidden') { return false; } - + var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', has = false; - + if (el[scroll] > 0) { return true; } - + // TODO: determine which cases actually cause this to happen // if the element doesn't have the scroll set, see if it's possible to // set the scroll @@ -117,17 +117,17 @@ $.ui = { el[scroll] = 0; return has; }, - + isOverHeight: function(y, top, height) { //Determines when y coordinate is over "b" element height return (y > top) && (y < (top + height)); }, - + isOverWidth: function(x, left, width) { //Determines when x coordinate is over "b" element width return (x > left) && (x < (left + width)); }, - + isOver: function(y, x, top, left, height, width) { //Determines when x, y coordinates is over "b" element return $.ui.isOverHeight(y, top, height) && $.ui.isOverWidth(x, left, width); @@ -141,10 +141,10 @@ if (isFF2) { ariaNS = "http://www.w3.org/2005/07/aaa", ariaState = /^aria-/, ariaRole = /^wairole:/; - + $.attr = function(elem, name, value) { var set = value !== undefined; - + return (name == 'role' ? (set ? attr.call(this, elem, name, "wairole:" + value) @@ -156,7 +156,7 @@ if (isFF2) { : attr.call(this, elem, name.replace(ariaState, "aaa:"))) : attr.apply(this, arguments))); }; - + $.fn.removeAttr = function(name) { return (ariaState.test(name) ? this.each(function() { @@ -167,7 +167,7 @@ if (isFF2) { //jQuery plugins $.fn.extend({ - + remove: function() { // Safari has a native remove event which actually removes DOM elements, // so we have to use triggerHandler instead of trigger (#3037). @@ -176,65 +176,65 @@ $.fn.extend({ }); return _remove.apply(this, arguments ); }, - + enableSelection: function() { return this .attr('unselectable', 'off') .css('MozUserSelect', '') .unbind('selectstart.ui'); }, - + disableSelection: function() { return this .attr('unselectable', 'on') .css('MozUserSelect', 'none') .bind('selectstart.ui', function() { return false; }); }, - + scrollParent: function() { return $(this).parents().filter(function() { return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); }).eq(0); } - + }); //Additional selectors $.extend($.expr[':'], { - + data: function(a, i, m) { return $.data(a, m[3]); }, - + // TODO: add support for object, area tabbable: function(a, i, m) { - + var nodeName = a.nodeName.toLowerCase(); function isVisible(element) { return !($(element).is(':hidden') || $(element).parents(':hidden').length); } - + return ( // in tab order a.tabIndex >= 0 && - + ( // filter node types that participate in the tab order - + // anchor tag ('a' == nodeName && a.href) || - + // enabled form element (/input|select|textarea|button/.test(nodeName) && 'hidden' != a.type && !a.disabled) ) && - + // visible on page isVisible(a) ); - + } - + }); @@ -246,7 +246,7 @@ function getter(namespace, plugin, method, args) { var methods = $[namespace][plugin][type] || []; return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods); } - + var methods = getMethods('getter'); if (args.length == 1 && typeof args[0] == 'string') { methods = methods.concat(getMethods('getterSetter')); @@ -257,53 +257,53 @@ function getter(namespace, plugin, method, args) { $.widget = function(name, prototype) { var namespace = name.split(".")[0]; name = name.split(".")[1]; - + // create plugin method $.fn[name] = function(options) { var isMethodCall = (typeof options == 'string'), args = Array.prototype.slice.call(arguments, 1); - + // prevent calls to internal methods if (isMethodCall && options.substring(0, 1) == '_') { return this; } - + // handle getter methods if (isMethodCall && getter(namespace, name, options, args)) { var instance = $.data(this[0], name); return (instance ? instance[options].apply(instance, args) : undefined); } - + // handle initialization and non-getter methods return this.each(function() { var instance = $.data(this, name); - + // constructor (!instance && !isMethodCall && $.data(this, name, new $[namespace][name](this, options))); - + // method call (instance && isMethodCall && $.isFunction(instance[options]) && instance[options].apply(instance, args)); }); }; - + // create widget constructor $[namespace] = $[namespace] || {}; $[namespace][name] = function(element, options) { var self = this; - + this.widgetName = name; this.widgetEventPrefix = $[namespace][name].eventPrefix || name; this.widgetBaseClass = namespace + '-' + name; - + this.options = $.extend({}, $.widget.defaults, $[namespace][name].defaults, $.metadata && $.metadata.get(element)[name], options); - + this.element = $(element) .bind('setData.' + name, function(event, key, value) { return self._setData(key, value); @@ -314,13 +314,13 @@ $.widget = function(name, prototype) { .bind('remove', function() { return self.destroy(); }); - + this._init(); }; - + // add widget prototype $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype); - + // TODO: merge getter and getterSetter properties from widget prototype // and plugin prototype $[namespace][name].getterSetter = 'option'; @@ -331,11 +331,11 @@ $.widget.prototype = { destroy: function() { this.element.removeData(this.widgetName); }, - + option: function(key, value) { var options = key, self = this; - + if (typeof key == "string") { if (value === undefined) { return this._getData(key); @@ -343,7 +343,7 @@ $.widget.prototype = { options = {}; options[key] = value; } - + $.each(options, function(key, value) { self._setData(key, value); }); @@ -353,20 +353,20 @@ $.widget.prototype = { }, _setData: function(key, value) { this.options[key] = value; - + if (key == 'disabled') { this.element[value ? 'addClass' : 'removeClass']( this.widgetBaseClass + '-disabled'); } }, - + enable: function() { this._setData('disabled', false); }, disable: function() { this._setData('disabled', true); }, - + _trigger: function(type, event, data) { var eventName = (type == this.widgetEventPrefix ? type : this.widgetEventPrefix + type); @@ -385,7 +385,7 @@ $.widget.defaults = { $.ui.mouse = { _mouseInit: function() { var self = this; - + this.element .bind('mousedown.'+this.widgetName, function(event) { return self._mouseDown(event); @@ -396,46 +396,46 @@ $.ui.mouse = { return false; } }); - + // Prevent text selection in IE if ($.browser.msie) { this._mouseUnselectable = this.element.attr('unselectable'); this.element.attr('unselectable', 'on'); } - + this.started = false; }, - + // TODO: make sure destroying one instance of mouse doesn't mess with // other instances of mouse _mouseDestroy: function() { this.element.unbind('.'+this.widgetName); - + // Restore text selection in IE ($.browser.msie && this.element.attr('unselectable', this._mouseUnselectable)); }, - + _mouseDown: function(event) { // we may have missed mouseup (out of window) (this._mouseStarted && this._mouseUp(event)); - + this._mouseDownEvent = event; - + var self = this, btnIsLeft = (event.which == 1), elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { return true; } - + this.mouseDelayMet = !this.options.delay; if (!this.mouseDelayMet) { this._mouseDelayTimer = setTimeout(function() { self.mouseDelayMet = true; }, this.options.delay); } - + if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { this._mouseStarted = (this._mouseStart(event) !== false); if (!this._mouseStarted) { @@ -443,7 +443,7 @@ $.ui.mouse = { return true; } } - + // these delegates are required to keep context this._mouseMoveDelegate = function(event) { return self._mouseMove(event); @@ -454,44 +454,44 @@ $.ui.mouse = { $(document) .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); - + return false; }, - + _mouseMove: function(event) { // IE mouseup check - mouseup happened when mouse was out of window if ($.browser.msie && !event.button) { return this._mouseUp(event); } - + if (this._mouseStarted) { this._mouseDrag(event); return false; } - + if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { this._mouseStarted = (this._mouseStart(this._mouseDownEvent, event) !== false); (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); } - + return !this._mouseStarted; }, - + _mouseUp: function(event) { $(document) .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); - + if (this._mouseStarted) { this._mouseStarted = false; this._preventClickEvent = true; this._mouseStop(event); } - + return false; }, - + _mouseDistanceMet: function(event) { return (Math.max( Math.abs(this._mouseDownEvent.pageX - event.pageX), @@ -499,11 +499,11 @@ $.ui.mouse = { ) >= this.options.distance ); }, - + _mouseDelayMet: function(event) { return this.mouseDelayMet; }, - + // These are placeholder methods, to be overriden by extending plugin _mouseStart: function(event) {}, _mouseDrag: function(event) {}, diff --git a/ui/ui.datepicker.js b/ui/ui.datepicker.js index dc54dd94d..99bc8ec93 100644 --- a/ui/ui.datepicker.js +++ b/ui/ui.datepicker.js @@ -139,13 +139,13 @@ 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) console.log.apply('', arguments); }, - + /* Override the default settings for all instances of the date picker. @param settings object - the new settings to use as defaults (anonymous object) @return the manager object */ @@ -153,7 +153,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) */ @@ -183,7 +183,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 @@ -194,7 +194,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); @@ -233,7 +233,7 @@ $.extend(Datepicker.prototype, { }); $.data(target, PROP_NAME, inst); }, - + /* Attach an inline date picker to a div. */ _inlineDatepicker: function(target, inst) { var divSpan = $(target); @@ -250,7 +250,7 @@ $.extend(Datepicker.prototype, { this._updateDatepicker(inst); this._updateAlternate(inst); }, - + /* 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) @@ -274,7 +274,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; @@ -284,7 +284,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; @@ -296,7 +296,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) { @@ -316,7 +316,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) { @@ -338,7 +338,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) { @@ -374,7 +374,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 */ @@ -387,7 +387,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 @@ -400,7 +400,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 @@ -429,12 +429,12 @@ $.extend(Datepicker.prototype, { this._updateDatepicker(inst); } }, - + // change method deprecated _changeDatepicker: function(target, name, value) { this._optionDatepicker(target, name, value); }, - + /* 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) { @@ -443,7 +443,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 @@ -456,7 +456,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 @@ -467,7 +467,7 @@ $.extend(Datepicker.prototype, { this._setDateFromField(inst); return (inst ? this._getDate(inst) : null); }, - + /* Handle keystrokes. */ _doKeyDown: function(event) { var inst = $.datepicker._getInst(event.target); @@ -535,7 +535,7 @@ $.extend(Datepicker.prototype, { event.stopPropagation(); } }, - + /* Filter entered characters - based on date format. */ _doKeyPress: function(event) { var inst = $.datepicker._getInst(event.target); @@ -545,7 +545,7 @@ $.extend(Datepicker.prototype, { return event.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 */ @@ -610,7 +610,7 @@ $.extend(Datepicker.prototype, { $.datepicker._curInst = inst; } }, - + /* Generate the date picker content. */ _updateDatepicker: function(inst) { var dims = {width: inst.dpDiv.width() + 4, @@ -626,7 +626,7 @@ $.extend(Datepicker.prototype, { if (inst.input && inst.input[0].type != 'hidden' && inst == $.datepicker._curInst) $(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; @@ -652,7 +652,7 @@ $.extend(Datepicker.prototype, { offset.top -= (isFixed ? scrollY : 0); return offset; }, - + /* Find an object's position on the screen. */ _findPos: function(obj) { while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) { @@ -661,7 +661,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 */ @@ -706,13 +706,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) @@ -724,7 +724,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); @@ -732,7 +732,7 @@ $.extend(Datepicker.prototype, { this._adjustInstDate(inst, offset, period); this._updateDatepicker(inst); }, - + /* Action for current link. */ _gotoToday: function(id) { var target = $(id); @@ -751,7 +751,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); @@ -763,7 +763,7 @@ $.extend(Datepicker.prototype, { this._notifyChange(inst); this._adjustDate(target); }, - + /* Restore input focus after not changing month/year. */ _clickMonthYear: function(id) { var target = $(id); @@ -772,7 +772,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); @@ -780,7 +780,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)) @@ -822,7 +822,7 @@ $.extend(Datepicker.prototype, { this._updateDatepicker(inst); } }, - + /* Erase the input field and hide the date picker. */ _clearDate: function(id) { var target = $(id); @@ -833,7 +833,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); @@ -860,7 +860,7 @@ $.extend(Datepicker.prototype, { this._lastInput = null; } }, - + /* Update any alternate field to synchronise with the main field. */ _updateAlternate: function(inst) { var altField = this._get(inst, 'altField'); @@ -875,7 +875,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? */ @@ -883,7 +883,7 @@ $.extend(Datepicker.prototype, { var day = date.getDay(); return [(day > 0 && day < 6), '']; }, - + /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. @param date Date - the date to get the week for @return number - the number of the week within the year that contains this date */ @@ -903,7 +903,7 @@ $.extend(Datepicker.prototype, { } return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date }, - + /* Provide status text for a particular date. @param date the date to get the status for @param inst the current datepicker instance @@ -912,7 +912,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. @@ -946,7 +946,7 @@ $.extend(Datepicker.prototype, { var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); if (matches) iFormat++; - return matches; + return matches; }; // Extract a number from the string value var getNumber = function(match) { @@ -1050,7 +1050,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', @@ -1063,7 +1063,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) @@ -1081,7 +1081,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: @@ -1102,7 +1102,7 @@ $.extend(Datepicker.prototype, { var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); if (matches) iFormat++; - return matches; + return matches; }; // Format a number, with leading zero if necessary var formatNumber = function(match, value, len) { @@ -1164,7 +1164,7 @@ $.extend(Datepicker.prototype, { } return output; }, - + /* Extract all possible characters from the date format. */ _possibleChars: function (format) { var chars = ''; @@ -1193,13 +1193,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'); @@ -1229,7 +1229,7 @@ $.extend(Datepicker.prototype, { inst.currentYear = (dates[0] ? date.getFullYear() : 0); this._adjustInstDate(inst); }, - + /* Retrieve the default date shown on opening. */ _getDefaultDate: function(inst) { var date = this._determineDate(this._get(inst, 'defaultDate'), new Date()); @@ -1239,7 +1239,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) { @@ -1327,7 +1327,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 : @@ -1340,7 +1340,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(); @@ -1535,7 +1535,7 @@ $.extend(Datepicker.prototype, { inst._keyEvent = false; return html; }, - + /* Generate the month and year header. */ _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, selectedDate, secondary, showStatus, initStatus, monthNames) { @@ -1603,7 +1603,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 + @@ -1611,7 +1611,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); @@ -1630,7 +1630,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'); @@ -1638,30 +1638,30 @@ $.extend(Datepicker.prototype, { onChange.apply((inst.input ? inst.input[0] : null), [inst.selectedYear, inst.selectedMonth + 1, inst]); }, - + /* Determine the number of months to show. */ _getNumberOfMonths: function(inst) { 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); 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); @@ -1671,7 +1671,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 @@ -1682,7 +1682,7 @@ $.extend(Datepicker.prototype, { var maxDate = this._getMinMaxDate(inst, 'max'); return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate)); }, - + /* Provide the configuration settings for formatting/parsing. */ _getFormatConfig: function(inst) { var shortYearCutoff = this._get(inst, 'shortYearCutoff'); @@ -1692,7 +1692,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) { @@ -1727,14 +1727,14 @@ function isArray(a) { Object - settings for attaching new datepicker functionality @return jQuery object */ $.fn.datepicker = function(options){ - + /* Initialise the date picker. */ if (!$.datepicker.initialized) { $(document.body).append($.datepicker.dpDiv). mousedown($.datepicker._checkExternalClick); $.datepicker.initialized = true; } - + var otherArgs = Array.prototype.slice.call(arguments, 1); if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate')) return $.datepicker['_' + options + 'Datepicker']. diff --git a/ui/ui.dialog.js b/ui/ui.dialog.js index 81d2730c5..9e381cb15 100644 --- a/ui/ui.dialog.js +++ b/ui/ui.dialog.js @@ -31,16 +31,16 @@ $.widget("ui.dialog", { _init: function() { this.originalTitle = this.element.attr('title'); this.options.title = this.options.title || this.originalTitle; - + var self = this, options = this.options, - + uiDialogContent = this.element .removeAttr('title') .addClass('ui-dialog-content') .wrap('<div/>') .wrap('<div/>'), - + uiDialogContainer = (this.uiDialogContainer = uiDialogContent.parent()) .addClass('ui-dialog-container') .css({ @@ -48,7 +48,7 @@ $.widget("ui.dialog", { width: '100%', height: '100%' }), - + uiDialogTitlebar = (this.uiDialogTitlebar = $('<div/>')) .addClass('ui-dialog-titlebar') .append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>') @@ -56,7 +56,7 @@ $.widget("ui.dialog", { self.moveToTop(); }) .prependTo(uiDialogContainer), - + title = options.title || ' ', titleId = $.ui.dialog.getTitleId(this.element), uiDialogTitle = $('<span/>') @@ -64,7 +64,7 @@ $.widget("ui.dialog", { .attr('id', titleId) .html(title) .prependTo(uiDialogTitlebar), - + uiDialog = (this.uiDialog = uiDialogContainer.parent()) .appendTo(document.body) .hide() @@ -90,7 +90,7 @@ $.widget("ui.dialog", { .mouseup(function() { self.moveToTop(); }), - + uiDialogButtonPane = (this.uiDialogButtonPane = $('<div/>')) .addClass('ui-dialog-buttonpane') .css({ @@ -98,7 +98,7 @@ $.widget("ui.dialog", { bottom: 0 }) .appendTo(uiDialog), - + uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar) .hover( function() { @@ -115,19 +115,19 @@ $.widget("ui.dialog", { self.close(); return false; }); - + uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection(); - + (options.draggable && $.fn.draggable && this._makeDraggable()); (options.resizable && $.fn.resizable && this._makeResizable()); - + this._createButtons(options.buttons); this._isOpen = false; - + (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe()); (options.autoOpen && this.open()); }, - + destroy: function() { (this.overlay && this.overlay.destroy()); this.uiDialog.hide(); @@ -137,45 +137,45 @@ $.widget("ui.dialog", { .removeClass('ui-dialog-content') .hide().appendTo('body'); this.uiDialog.remove(); - + (this.originalTitle && this.element.attr('title', this.originalTitle)); }, - + close: function() { if (false === this._trigger('beforeclose', null, { options: this.options })) { return; } - + (this.overlay && this.overlay.destroy()); this.uiDialog .hide(this.options.hide) .unbind('keypress.ui-dialog'); - + this._trigger('close', null, { options: this.options }); $.ui.dialog.overlay.resize(); - + this._isOpen = false; }, - + isOpen: function() { return this._isOpen; }, - + // the force parameter allows us to move modal dialogs to their correct // position on open moveToTop: function(force) { - + if ((this.options.modal && !force) || (!this.options.stack && !this.options.modal)) { return this._trigger('focus', null, { options: this.options }); } - + var maxZ = this.options.zIndex, options = this.options; $('.ui-dialog:visible').each(function() { maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex); }); (this.overlay && this.overlay.$el.css('z-index', ++maxZ)); - + //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed. // http://ui.jquery.com/bugs/ticket/3193 var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') }; @@ -183,27 +183,27 @@ $.widget("ui.dialog", { this.element.attr(saveScroll); this._trigger('focus', null, { options: this.options }); }, - + open: function() { if (this._isOpen) { return; } - + this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null; (this.uiDialog.next().length && this.uiDialog.appendTo('body')); this._position(this.options.position); this.uiDialog.show(this.options.show); (this.options.autoResize && this._size()); this.moveToTop(true); - + // prevent tabbing out of modal dialogs (this.options.modal && this.uiDialog.bind('keypress.ui-dialog', function(event) { if (event.keyCode != $.keyCode.TAB) { return; } - + var tabbables = $(':tabbable', this), first = tabbables.filter(':first')[0], last = tabbables.filter(':last')[0]; - + if (event.target == last && !event.shiftKey) { setTimeout(function() { first.focus(); @@ -214,20 +214,20 @@ $.widget("ui.dialog", { }, 1); } })); - + this.uiDialog.find(':tabbable:first').focus(); this._trigger('open', null, { options: this.options }); this._isOpen = true; }, - + _createButtons: function(buttons) { var self = this, hasButtons = false, uiDialogButtonPane = this.uiDialogButtonPane; - + // remove any existing buttons uiDialogButtonPane.empty().hide(); - + $.each(buttons, function() { return !(hasButtons = true); }); if (hasButtons) { uiDialogButtonPane.show(); @@ -239,11 +239,11 @@ $.widget("ui.dialog", { }); } }, - + _makeDraggable: function() { var self = this, options = this.options; - + this.uiDialog.draggable({ cancel: '.ui-dialog-content', helper: options.dragHelper, @@ -261,7 +261,7 @@ $.widget("ui.dialog", { } }); }, - + _makeResizable: function(handles) { handles = (handles === undefined ? this.options.resizable : handles); var self = this, @@ -269,7 +269,7 @@ $.widget("ui.dialog", { resizeHandles = typeof handles == 'string' ? handles : 'n,e,s,w,se,sw,ne,nw'; - + this.uiDialog.resizable({ cancel: '.ui-dialog-content', helper: options.resizeHelper, @@ -292,12 +292,12 @@ $.widget("ui.dialog", { } }); }, - + _position: function(pos) { var wnd = $(window), doc = $(document), pTop = doc.scrollTop(), pLeft = doc.scrollLeft(), minTop = pTop; - + if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) { pos = [ pos == 'right' || pos == 'left' ? pos : 'center', @@ -337,13 +337,13 @@ $.widget("ui.dialog", { pTop += (wnd.height() - this.uiDialog.height()) / 2; } } - + // prevent the dialog from being too high (make sure the titlebar // is accessible) pTop = Math.max(pTop, minTop); this.uiDialog.css({top: pTop, left: pLeft}); }, - + _setData: function(key, value){ (setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value)); switch (key) { @@ -364,17 +364,17 @@ $.widget("ui.dialog", { case "resizable": var uiDialog = this.uiDialog, isResizable = this.uiDialog.is(':data(resizable)'); - + // currently resizable, becoming non-resizable (isResizable && !value && uiDialog.resizable('destroy')); - + // currently resizable, changing handles (isResizable && typeof value == 'string' && uiDialog.resizable('option', 'handles', value)); - + // currently non-resizable, becoming resizable (isResizable || this._makeResizable(value)); - + break; case "title": $(".ui-dialog-title", this.uiDialogTitlebar).html(value || ' '); @@ -383,10 +383,10 @@ $.widget("ui.dialog", { this.uiDialog.width(value); break; } - + $.widget.prototype._setData.apply(this, arguments); }, - + _size: function() { var container = this.uiDialogContainer, titlebar = this.uiDialogTitlebar, @@ -420,14 +420,14 @@ $.extend($.ui.dialog, { width: 300, zIndex: 1000 }, - + getter: 'isOpen', - + uuid: 0, getTitleId: function($el) { return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid); }, - + overlay: function(dialog) { this.$el = $.ui.dialog.overlay.create(dialog); } @@ -464,17 +464,17 @@ $.extend($.ui.dialog.overlay, { return allow; }); }, 1); - + // allow closing by pressing the escape key $(document).bind('keydown.dialog-overlay', function(event) { (dialog.options.closeOnEscape && event.keyCode && event.keyCode == $.keyCode.ESCAPE && dialog.close()); }); - + // handle window resize $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize); } - + var $el = $('<div/>').appendTo(document.body) .addClass('ui-dialog-overlay').css($.extend({ borderWidth: 0, margin: 0, padding: 0, @@ -482,23 +482,23 @@ $.extend($.ui.dialog.overlay, { width: this.width(), height: this.height() }, dialog.options.overlay)); - + (dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe()); - + this.instances.push($el); return $el; }, - + destroy: function($el) { this.instances.splice($.inArray(this.instances, $el), 1); - + if (this.instances.length === 0) { $('a, :input').add([document, window]).unbind('.dialog-overlay'); } - + $el.remove(); }, - + height: function() { // handle IE 6 if ($.browser.msie && $.browser.version < 7) { @@ -510,7 +510,7 @@ $.extend($.ui.dialog.overlay, { document.documentElement.offsetHeight, document.body.offsetHeight ); - + if (scrollHeight < offsetHeight) { return $(window).height() + 'px'; } else { @@ -527,7 +527,7 @@ $.extend($.ui.dialog.overlay, { return $(document).height() + 'px'; } }, - + width: function() { // handle IE 6 if ($.browser.msie && $.browser.version < 7) { @@ -539,7 +539,7 @@ $.extend($.ui.dialog.overlay, { document.documentElement.offsetWidth, document.body.offsetWidth ); - + if (scrollWidth < offsetWidth) { return $(window).width() + 'px'; } else { @@ -556,7 +556,7 @@ $.extend($.ui.dialog.overlay, { return $(document).width() + 'px'; } }, - + resize: function() { /* If the dialog is draggable and the user drags it past the * right edge of the window, the document becomes wider so we @@ -570,7 +570,7 @@ $.extend($.ui.dialog.overlay, { $.each($.ui.dialog.overlay.instances, function() { $overlays = $overlays.add(this); }); - + $overlays.css({ width: 0, height: 0 diff --git a/ui/ui.droppable.js b/ui/ui.droppable.js index 7a6fe7ac8..f5d81babc 100644 --- a/ui/ui.droppable.js +++ b/ui/ui.droppable.js @@ -14,9 +14,9 @@ (function($) { $.widget("ui.droppable", { - + _setData: function(key, value) { - + if(key == 'accept') { this.options.accept = value && $.isFunction(value) ? value : function(d) { return d.is(accept); @@ -24,27 +24,27 @@ $.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 }; - + // Add the reference and positions to the manager $.ui.ddmanager.droppables[this.options.scope] = $.ui.ddmanager.droppables[this.options.scope] || []; $.ui.ddmanager.droppables[this.options.scope].push(this); - + (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-droppable")); - + }, plugins: {}, ui: function(c) { @@ -62,39 +62,39 @@ $.widget("ui.droppable", { for ( var i = 0; i < drop.length; i++ ) if ( drop[i] == this ) drop.splice(i, 1); - + this.element .removeClass("ui-droppable-disabled") .removeData("droppable") .unbind(".droppable"); }, _over: function(event) { - + var draggable = $.ui.ddmanager.current; if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element - + if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) { $.ui.plugin.call(this, 'over', [event, this.ui(draggable)]); this.element.triggerHandler("dropover", [event, this.ui(draggable)], this.options.over); } - + }, _out: function(event) { - + var draggable = $.ui.ddmanager.current; if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element - + if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) { $.ui.plugin.call(this, 'out', [event, this.ui(draggable)]); this.element.triggerHandler("dropout", [event, this.ui(draggable)], this.options.out); } - + }, _drop: function(event,custom) { - + var draggable = custom || $.ui.ddmanager.current; if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element - + var childrenIntersection = false; this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() { var inst = $.data(this, 'droppable'); @@ -103,29 +103,29 @@ $.widget("ui.droppable", { } }); if(childrenIntersection) return false; - + if(this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) { $.ui.plugin.call(this, 'drop', [event, this.ui(draggable)]); this.element.triggerHandler("drop", [event, this.ui(draggable)], this.options.drop); return this.element; } - + return false; - + }, _activate: function(event) { - + var draggable = $.ui.ddmanager.current; $.ui.plugin.call(this, 'activate', [event, this.ui(draggable)]); if(draggable) this.element.triggerHandler("dropactivate", [event, this.ui(draggable)], this.options.activate); - + }, _deactivate: function(event) { - + var draggable = $.ui.ddmanager.current; $.ui.plugin.call(this, 'deactivate', [event, this.ui(draggable)]); if(draggable) this.element.triggerHandler("dropdeactivate", [event, this.ui(draggable)], this.options.deactivate); - + } }); @@ -143,14 +143,14 @@ $.extend($.ui.droppable, { }); $.ui.intersect = function(draggable, droppable, toleranceMode) { - + if (!droppable.offset) return false; - + var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width, y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height; var l = droppable.offset.left, r = l + droppable.proportions.width, t = droppable.offset.top, b = t + droppable.proportions.height; - + switch (toleranceMode) { case 'fit': return (l < x1 && x2 < r @@ -183,7 +183,7 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) { return false; break; } - + }; /* @@ -193,58 +193,58 @@ $.ui.ddmanager = { current: null, droppables: { 'default': [] }, prepareOffsets: function(t, event) { - + var m = $.ui.ddmanager.droppables[t.options.scope]; var type = event ? event.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 for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue - + m[i].offset = m[i].element.offset(); m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight }; - + if(type == "dragstart" || type == "sortactivate") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables - + } - + }, drop: function(draggable, event) { - + var dropped = false; $.each($.ui.ddmanager.droppables[draggable.options.scope], function() { - + if(!this.options) return; if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) dropped = this._drop.call(this, event); - + if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) { this.isout = 1; this.isover = 0; this._deactivate.call(this, event); } - + }); return dropped; - + }, drag: function(draggable, event) { - + //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event); - + //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; var intersects = $.ui.intersect(draggable, this, this.options.tolerance); - + var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null); if(!c) return; - + var parentInstance; if (this.options.greedy) { var parent = this.element.parents(':data(droppable):eq(0)'); @@ -253,17 +253,17 @@ $.ui.ddmanager = { parentInstance.greedyChild = (c == 'isover' ? 1 : 0); } } - + // we just moved into a greedy child if (parentInstance && c == 'isover') { parentInstance['isover'] = 0; parentInstance['isout'] = 1; parentInstance._out.call(parentInstance, event); } - + this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0; this[c == "isover" ? "_over" : "_out"].call(this, event); - + // we just moved out of a greedy child if (parentInstance && c == 'isout') { parentInstance['isout'] = 0; @@ -271,7 +271,7 @@ $.ui.ddmanager = { parentInstance._over.call(parentInstance, event); } }); - + } }; diff --git a/ui/ui.progressbar.js b/ui/ui.progressbar.js index 9e758bd40..d188a1253 100644 --- a/ui/ui.progressbar.js +++ b/ui/ui.progressbar.js @@ -14,14 +14,14 @@ $.widget("ui.progressbar", { _init: function() { - + this._interval = this.options.interval; - + var self = this, options = this.options, identifier = 'progressbar' + (++$.ui.progressbar.uuid), text = options.text || '0%'; - + this.element .addClass("ui-progressbar") .width(options.width) @@ -31,17 +31,17 @@ $.widget("ui.progressbar", { "aria-valuemax": 100, "aria-valuenow": 0 }); - + $.extend(this, { active: false, pixelState: 0, percentState: 0, identifier: identifier }); - + this.wrapper = $('<div class="ui-progressbar-wrap"></div>') .appendTo(this.element); - + this.bar = $('<div class="ui-progressbar-bar ui-hidden"></div>') .css({ width: 0, @@ -49,7 +49,7 @@ $.widget("ui.progressbar", { zIndex: 100 }) .appendTo(this.wrapper); - + this.textElement = $('<div class="ui-progressbar-text"></div>') .html(text) .css({ @@ -57,7 +57,7 @@ $.widget("ui.progressbar", { overflow: 'hidden' }) .appendTo(this.bar); - + this.textBg = $('<div class="ui-progressbar-text ui-progressbar-text-back"></div>') .html(text) .css({ @@ -70,7 +70,7 @@ $.widget("ui.progressbar", { var self = this, options = this.options, interval = options.interval; - + this.bar.animate( { width: options.width @@ -97,15 +97,15 @@ $.widget("ui.progressbar", { } ); }, - + destroy: function() { this.stop(); - + this.element .removeClass("ui-progressbar ui-progressbar-disabled") .removeData("progressbar").unbind(".progressbar") .find('.ui-progressbar-wrap').remove(); - + delete $.easing[this.identifier]; }, @@ -114,27 +114,27 @@ $.widget("ui.progressbar", { this.disabled = true; this.element.attr("aria-disabled", true); }, - + enable: function() { this.element.removeClass("ui-progressbar-disabled"); this.disabled = false; this.element.attr("aria-disabled", false); }, - + pause: function() { if (this.disabled) return; this.bar.stop(); this._trigger('pause', null, this.ui()); }, - + progress: function(percentState) { 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); - + var percent = Math.round(this.percentState); if (this.options.range && !this.options.text) { this._setText(percent + '%'); @@ -142,14 +142,14 @@ $.widget("ui.progressbar", { this.element.attr("aria-valuenow", percent); this._trigger('progress', null, this.ui()); }, - + start: function() { var self = this, options = this.options; - + if (this.disabled) { return; } - + $.easing[this.identifier] = function (x, t, b, c, d) { var inc = options.increment, width = options.width, @@ -157,26 +157,26 @@ $.widget("ui.progressbar", { state = Math.round(x/step)*step; return state > 1 ? 1 : state; }; - + self.active = true; - + if (options.duration < options.interval) { options.duration = options.interval; } - + setTimeout( function() { self.active = false; }, options.duration ); - + this._animate(); - + this._trigger('start', null, this.ui()); return false; }, - + stop: function() { this.bar.stop(); this.bar.width(0); @@ -185,7 +185,7 @@ $.widget("ui.progressbar", { this.options.interval = this._interval; this._trigger('stop', null, this.ui()); }, - + ui: function() { return { options: this.options, @@ -193,17 +193,17 @@ $.widget("ui.progressbar", { percentState: this.percentState }; }, - + _setData: function(key, value){ switch (key) { case 'text': this._setText(value); break; } - + $.widget.prototype._setData.apply(this, arguments); }, - + _setText: function(text){ this.textElement.add(this.textBg).html(text); } @@ -219,7 +219,7 @@ $.extend($.ui.progressbar, { range: true, text: '' }, - + uuid: 0 }); diff --git a/ui/ui.resizable.js b/ui/ui.resizable.js index 0e6e760e3..3f5b0fb8c 100644 --- a/ui/ui.resizable.js +++ b/ui/ui.resizable.js @@ -14,25 +14,25 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { _init: function() { - + var self = this, o = this.options; - + var elpos = this.element.css('position'); - + this.originalElement = this.element; - + // simulate .ui-resizable { position: relative; } this.element.addClass("ui-resizable").css({ position: /static/.test(elpos) ? 'relative' : elpos }); - + $.extend(o, { _aspectRatio: !!(o.aspectRatio), helper: o.helper || o.ghost || o.animate ? o.helper || 'proxy' : null, knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles }); - + //Default Theme var aBorder = '1px solid #DEDEDE'; - + o.defaultTheme = { 'ui-resizable': { display: 'block' }, 'ui-resizable-handle': { position: 'absolute', background: '#F2F2F2', fontSize: '0.1px' }, @@ -45,7 +45,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { 'ui-resizable-ne': { cursor: 'ne-resize', width: '4px', height: '4px', borderRight: aBorder, borderTop: aBorder }, 'ui-resizable-nw': { cursor: 'nw-resize', width: '4px', height: '4px', borderLeft: aBorder, borderTop: aBorder } }; - + o.knobTheme = { 'ui-resizable-handle': { background: '#F2F2F2', border: '1px solid #808080', height: '8px', width: '8px' }, 'ui-resizable-n': { cursor: 'n-resize', top: '0px', left: '45%' }, @@ -57,17 +57,17 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { 'ui-resizable-nw': { cursor: 'nw-resize', left: '0px', top: '0px' }, 'ui-resizable-ne': { cursor: 'ne-resize', right: '0px', top: '0px' } }; - + o._nodeName = this.element[0].nodeName; - + //Wrap the element if it cannot hold child nodes if(o._nodeName.match(/canvas|textarea|input|select|button|img/i)) { var el = this.element; - + //Opera fixing relative position if (/relative/.test(el.css('position')) && $.browser.opera) el.css({ position: 'relative', top: 'auto', left: 'auto' }); - + //Create a wrapper element and set the wrapper to the new current internal element el.wrap( $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css( { @@ -78,40 +78,40 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { left: el.css('left') }) ); - + var oel = this.element; this.element = this.element.parent(); - + // store instance on wrapper this.element.data('resizable', this); - + //Move margins to the wrapper this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"), marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom") }); - + oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); - + //Prevent Safari textarea resize if ($.browser.safari && o.preventDefault) oel.css('resize', 'none'); - + o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' }); - + // avoid IE jump this.element.css({ margin: oel.css('margin') }); - + // fix handlers offset this._proportionallyResize(); } - + if(!o.handles) o.handles = !$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' }; if(o.handles.constructor == String) { - + o.zIndex = o.zIndex || 1000; - + if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw'; - + var n = o.handles.split(","); o.handles = {}; - + // insertions are applied when don't have theme loaded var insertionsDefault = { handle: 'position: absolute; display: none; overflow:hidden;', @@ -124,18 +124,18 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { ne: 'top: 0pt; right: 0px;', nw: 'top: 0pt; left: 0px;' }; - + for(var i = 0; i < n.length; i++) { var handle = $.trim(n[i]), dt = o.defaultTheme, hname = 'ui-resizable-'+handle, loadDefault = !$.ui.css(hname) && !o.knobHandles, userKnobClass = $.ui.css('ui-resizable-knob-handle'), allDefTheme = $.extend(dt[hname], dt['ui-resizable-handle']), allKnobTheme = $.extend(o.knobTheme[hname], !userKnobClass ? o.knobTheme['ui-resizable-handle'] : {}); - + // increase zIndex of sw, se, ne, nw axis var applyZIndex = /sw|se|ne|nw/.test(handle) ? { zIndex: ++o.zIndex } : {}; - + var defCss = (loadDefault ? insertionsDefault[handle] : ''), axis = $(['<div class="ui-resizable-handle ', hname, '" style="', defCss, insertionsDefault.handle, '"></div>'].join('')).css( applyZIndex ); o.handles[handle] = '.ui-resizable-'+handle; - + this.element.append( //Theme detection, if not loaded, load o.defaultTheme axis.css( loadDefault ? allDefTheme : {} ) @@ -143,50 +143,50 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { .css( o.knobHandles ? allKnobTheme : {} ).addClass(o.knobHandles ? 'ui-resizable-knob-handle' : '').addClass(o.knobHandles) ); } - + if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} ); } - + this._renderAxis = function(target) { target = target || this.element; - + for(var i in o.handles) { if(o.handles[i].constructor == String) o.handles[i] = $(o.handles[i], this.element).show(); - + if (o.transparent) o.handles[i].css({opacity:0}); - + //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) if (this.element.is('.ui-wrapper') && o._nodeName.match(/textarea|input|select|button/i)) { - + var axis = $(o.handles[i], this.element), padWrapper = 0; - + //Checking the correct pad and border padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); - + //The padding type i have to apply... var padPos = [ 'padding', /ne|nw|n/.test(i) ? 'Top' : /se|sw|s/.test(i) ? 'Bottom' : /^e$/.test(i) ? 'Right' : 'Left' ].join(""); - + if (!o.transparent) target.css(padPos, padWrapper); - + this._proportionallyResize(); } if(!$(o.handles[i]).length) continue; } }; - + this._renderAxis(this.element); o._handles = $('.ui-resizable-handle', self.element); - + if (o.disableSelection) o._handles.disableSelection(); - + //Matching axis name o._handles.mouseover(function() { if (!o.resizing) { @@ -196,7 +196,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { self.axis = o.axis = axis && axis[1] ? axis[1] : 'se'; } }); - + //If we want to auto hide the elements if (o.autoHide) { o._handles.hide(); @@ -211,7 +211,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { } }); } - + this._mouseInit(); }, plugins: {}, @@ -233,16 +233,16 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { }, destroy: function() { var el = this.element, wrapped = el.children(".ui-resizable").get(0); - + this._mouseDestroy(); - + var _destroy = function(exp) { $(exp).removeClass("ui-resizable ui-resizable-disabled") .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); }; - + _destroy(el); - + if (el.is('.ui-wrapper') && wrapped) { el.parent().append( $(wrapped).css({ @@ -253,55 +253,55 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { left: el.css('left') }) ).end().remove(); - + _destroy(wrapped); } }, - + _mouseCapture: function(event) { - + if(this.options.disabled) return false; - + var handle = false; for(var i in this.options.handles) { if($(this.options.handles[i])[0] == event.target) handle = true; } if (!handle) return false; - + return true; - + }, - + _mouseStart: function(event) { - + var o = this.options, iniPos = this.element.position(), el = this.element, num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7; o.resizing = true; o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() }; - + // bugfix #1749 if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) { - + // sOffset decides if document scrollOffset will be added to the top/left of the resizable element var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position')); var dscrollt = sOffset ? o.documentScroll.top : 0, dscrolll = sOffset ? o.documentScroll.left : 0; - + el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) }); } - + //Opera fixing relative position if ($.browser.opera && (/relative/).test(el.css('position'))) el.css({ position: 'relative', top: 'auto', left: 'auto' }); - + this._renderProxy(); - + var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top')); - + if (o.containment) { curleft += $(o.containment).scrollLeft()||0; curtop += $(o.containment).scrollTop()||0; } - + //Store needed variables this.offset = this.helper.offset(); this.position = { left: curleft, top: curtop }; @@ -310,79 +310,79 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { this.originalPosition = { left: curleft, top: curtop }; this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; this.originalMousePosition = { left: event.pageX, top: event.pageY }; - + //Aspect Ratio o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height)||1); - + if (o.preserveCursor) $('body').css('cursor', this.axis + '-resize'); - + this._propagate("start", event); return true; }, _mouseDrag: function(event) { - + //Increase performance, avoid regex var el = this.helper, o = this.options, props = {}, self = this, smp = this.originalMousePosition, a = this.axis; - + var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0; var trigger = this._change[a]; if (!trigger) return false; - + // Calculate the attrs that will be change var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; - + if (o._aspectRatio || event.shiftKey) data = this._updateRatio(data, event); - + data = this._respectSize(data, event); - + // plugins callbacks need to be called first this._propagate("resize", event); - + el.css({ top: this.position.top + "px", left: this.position.left + "px", width: this.size.width + "px", height: this.size.height + "px" }); - + if (!o.helper && o.proportionallyResize) this._proportionallyResize(); - + this._updateCache(data); - + // calling the user callback at the end this.element.triggerHandler("resize", [event, this.ui()], this.options["resize"]); - + return false; }, _mouseStop: function(event) { - + this.options.resizing = false; var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this; - + if(o.helper) { var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, soffsetw = ista ? 0 : self.sizeDiff.width; - + var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; - + if (!o.animate) this.element.css($.extend(s, { top: top, left: left })); - + if (o.helper && !o.animate) this._proportionallyResize(); } - + if (o.preserveCursor) $('body').css('cursor', 'auto'); - + this._propagate("stop", event); - + if (o.helper) this.helper.remove(); - + return false; }, _updateCache: function(data) { @@ -394,12 +394,12 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { if (data.width) this.size.width = data.width; }, _updateRatio: function(data, event) { - + var o = this.options, cpos = this.position, csize = this.size, a = this.axis; - + if (data.height) data.width = (csize.height * o.aspectRatio); else if (data.width) data.height = (csize.width / o.aspectRatio); - + if (a == 'sw') { data.left = cpos.left + (csize.width - data.width); data.top = null; @@ -408,44 +408,44 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { data.top = cpos.top + (csize.height - data.height); data.left = cpos.left + (csize.width - data.width); } - + return data; }, _respectSize: function(data, event) { - + var el = this.helper, o = this.options, pRatio = o._aspectRatio || event.shiftKey, a = this.axis, ismaxw = data.width && o.maxWidth && o.maxWidth < data.width, ismaxh = data.height && o.maxHeight && o.maxHeight < data.height, isminw = data.width && o.minWidth && o.minWidth > data.width, isminh = data.height && o.minHeight && o.minHeight > data.height; - + if (isminw) data.width = o.minWidth; if (isminh) data.height = o.minHeight; if (ismaxw) data.width = o.maxWidth; if (ismaxh) data.height = o.maxHeight; - + var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height; var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); - + if (isminw && cw) data.left = dw - o.minWidth; if (ismaxw && cw) data.left = dw - o.maxWidth; if (isminh && ch) data.top = dh - o.minHeight; if (ismaxh && ch) data.top = dh - o.maxHeight; - + // fixing jump error on top/left - bug #2330 var isNotwh = !data.width && !data.height; if (isNotwh && !data.left && data.top) data.top = null; else if (isNotwh && !data.top && data.left) data.left = null; - + return data; }, _proportionallyResize: function() { var o = this.options; if (!o.proportionallyResize) return; var prel = o.proportionallyResize, el = this.helper || this.element; - + if (!o.borderDif) { var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')], p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')]; - + o.borderDif = $.map(b, function(v, i) { var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0; return border + padding; @@ -459,14 +459,14 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { _renderProxy: function() { var el = this.element, o = this.options; this.elementOffset = el.offset(); - + if(o.helper) { this.helper = this.helper || $('<div style="overflow:hidden;"></div>'); - + // fix ie6 offset var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), pxyoffset = ( ie6 ? 2 : -1 ); - + this.helper.addClass(o.helper).css({ width: el.outerWidth() + pxyoffset, height: el.outerHeight() + pxyoffset, @@ -475,12 +475,12 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, { top: this.elementOffset.top - ie6offset +'px', zIndex: ++o.zIndex }); - + this.helper.appendTo("body"); - + if (o.disableSelection) $.ui.disableSelection(this.helper.get(0)); - + } else { this.helper = el; } @@ -548,95 +548,95 @@ $.extend($.ui.resizable, { */ $.ui.plugin.add("resizable", "containment", { - + start: function(event, ui) { var o = ui.options, self = $(this).data("resizable"), el = self.element; var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; if (!ce) return; - + self.containerElement = $(ce); - + if (/document/.test(oc) || oc == document) { self.containerOffset = { left: 0, top: 0 }; self.containerPosition = { left: 0, top: 0 }; - + self.parentData = { element: $(document), left: 0, top: 0, width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight }; } - + // 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 }; } }, - + resize: function(event, ui) { var o = ui.options, self = $(this).data("resizable"), ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position, pRatio = o._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement; - + if (ce[0] != document && (/static/).test(ce.css('position'))) cop = self.containerPosition; - + if (cp.left < (o.helper ? co.left : cop.left)) { self.size.width = self.size.width + (o.helper ? (self.position.left - co.left) : (self.position.left - cop.left)); if (pRatio) self.size.height = self.size.width / o.aspectRatio; self.position.left = o.helper ? co.left : cop.left; } - + if (cp.top < (o.helper ? co.top : 0)) { self.size.height = self.size.height + (o.helper ? (self.position.top - co.top) : self.position.top); if (pRatio) self.size.width = self.size.height * o.aspectRatio; self.position.top = o.helper ? co.top : 0; } - + var woset = (o.helper ? self.offset.left - co.left : (self.position.left - cop.left)) + self.sizeDiff.width, hoset = (o.helper ? self.offset.top - co.top : self.position.top) + self.sizeDiff.height; - + if (woset + self.size.width >= self.parentData.width) { self.size.width = self.parentData.width - woset; if (pRatio) self.size.height = self.size.width / o.aspectRatio; } - + if (hoset + self.size.height >= self.parentData.height) { self.size.height = self.parentData.height - hoset; if (pRatio) self.size.width = self.size.height * o.aspectRatio; } }, - + stop: function(event, ui){ var o = ui.options, self = $(this).data("resizable"), cp = self.position, co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement; - + 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 }); - + if (o.helper && !o.animate && (/static/).test(ce.css('position'))) $(this).css({ left: cop.left + (ho.left - co.left), top: cop.top + (ho.top - co.top), width: w, height: h }); - + } }); $.ui.plugin.add("resizable", "grid", { - + resize: function(event, ui) { var o = ui.options, self = $(this).data("resizable"), cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey; o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid; var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1); - + if (/^(se|s|e)$/.test(a)) { self.size.width = os.width + ox; self.size.height = os.height + oy; @@ -658,84 +658,84 @@ $.ui.plugin.add("resizable", "grid", { self.position.left = op.left - ox; } } - + }); $.ui.plugin.add("resizable", "animate", { - + stop: function(event, ui) { var o = ui.options, self = $(this).data("resizable"); - + var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, soffsetw = ista ? 0 : self.sizeDiff.width; - + var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; - + self.element.animate( $.extend(style, top && left ? { top: top, left: left } : {}), { duration: o.animateDuration, easing: o.animateEasing, step: function() { - + var data = { width: parseInt(self.element.css('width'), 10), height: parseInt(self.element.css('height'), 10), top: parseInt(self.element.css('top'), 10), left: parseInt(self.element.css('left'), 10) }; - + if (pr) pr.css({ width: data.width, height: data.height }); - + // propagating resize, and updating values for each animation step self._updateCache(data); self._propagate("animate", event); - + } } ); } - + }); $.ui.plugin.add("resizable", "ghost", { - + start: function(event, ui) { var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize, cs = self.size; - + if (!pr) self.ghost = self.element.clone(); else self.ghost = pr.clone(); - + self.ghost.css( { opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 } ) .addClass('ui-resizable-ghost').addClass(typeof o.ghost == 'string' ? o.ghost : ''); - + self.ghost.appendTo(self.helper); - + }, - + resize: function(event, ui){ var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize; - + if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width }); - + }, - + stop: function(event, ui){ var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize; if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0)); } - + }); $.ui.plugin.add("resizable", "alsoResize", { - + start: function(event, ui) { var o = ui.options, self = $(this).data("resizable"), - + _store = function(exp) { $(exp).each(function() { $(this).data("resizable-alsoresize", { @@ -744,7 +744,7 @@ $.ui.plugin.add("resizable", "alsoResize", { }); }); }; - + if (typeof(o.alsoResize) == 'object') { if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); } @@ -752,19 +752,19 @@ $.ui.plugin.add("resizable", "alsoResize", { _store(o.alsoResize); } }, - + resize: function(event, ui){ var o = ui.options, self = $(this).data("resizable"), os = self.originalSize, op = self.originalPosition; - + var delta = { height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 }, - + _alsoResize = function(exp, c) { $(exp).each(function() { var start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left']; - + $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) { var sum = (start[prop]||0) + (delta[prop]||0); if (sum && sum >= 0) @@ -773,14 +773,14 @@ $.ui.plugin.add("resizable", "alsoResize", { $(this).css(style); }); }; - + if (typeof(o.alsoResize) == 'object') { $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); }); }else{ _alsoResize(o.alsoResize); } }, - + stop: function(event, ui){ $(this).removeData("resizable-alsoresize-start"); } diff --git a/ui/ui.selectable.js b/ui/ui.selectable.js index d551566bf..6e46a3d73 100644 --- a/ui/ui.selectable.js +++ b/ui/ui.selectable.js @@ -15,11 +15,11 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { _init: function() { var self = this; - + this.element.addClass("ui-selectable"); - + this.dragged = false; - + // cache selectee children based on filter var selectees; this.refresh = function() { @@ -42,11 +42,11 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { }); }; this.refresh(); - + this.selectees = selectees.addClass("ui-selectee"); - + this._mouseInit(); - + this.helper = $(document.createElement('div')) .css({border:'1px dotted black'}) .addClass("ui-selectable-helper"); @@ -67,22 +67,22 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { }, _mouseStart: function(event) { var self = this; - + this.opos = [event.pageX, event.pageY]; - + if (this.options.disabled) return; - + var options = this.options; - + this.selectees = $(options.filter, this.element[0]); - + // selectable START callback this.element.triggerHandler("selectablestart", [event, { "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; @@ -114,7 +114,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { }], options.unselecting); } }); - + var isSelectee = false; $(event.target).parents().andSelf().each(function() { if($.data(this, "selectable-item")) isSelectee = true; @@ -124,17 +124,17 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { _mouseDrag: function(event) { var self = this; this.dragged = true; - + if (this.options.disabled) return; - + var options = this.options; - + var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.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) { @@ -207,16 +207,16 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { } } }); - + return false; }, _mouseStop: function(event) { var self = this; - + 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'); @@ -244,9 +244,9 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, { selectable: self.element[0], options: this.options }], this.options.stop); - + this.helper.remove(); - + return false; } })); diff --git a/ui/ui.slider.js b/ui/ui.slider.js index b485fb75e..02efa29d3 100644 --- a/ui/ui.slider.js +++ b/ui/ui.slider.js @@ -36,12 +36,12 @@ $.widget("ui.slider", { this.element.triggerHandler(n == "slide" ? n : "slide"+n, [event, this.ui()], this.options[n]); }, destroy: function() { - + this.element .removeClass("ui-slider ui-slider-disabled") .removeData("slider") .unbind(".slider"); - + if(this.handle && this.handle.length) { this.handle .unwrap("a"); @@ -50,28 +50,28 @@ $.widget("ui.slider", { mouse && mouse._mouseDestroy(); }); } - + this.generated && this.generated.remove(); - + }, _setData: function(key, value) { $.widget.prototype._setData.apply(this, arguments); if (/min|max|steps/.test(key)) { this._initBoundaries(); } - + if(key == "range") { value ? this.handle.length == 2 && this._createRange() : this._removeRange(); } - + }, - + _init: function() { - + var self = this; this.element.addClass("ui-slider"); this._initBoundaries(); - + // Initialize mouse and key events for interaction this.handle = $(this.options.handle, this.element); if (!this.handle.length) { @@ -82,20 +82,20 @@ $.widget("ui.slider", { return handle[0]; }); } - + var handleclass = function(el) { this.element = $(el); this.element.data("mouse", this); this.options = self.options; - + this.element.bind("mousedown", function() { if(self.currentHandle) this.blur(self.currentHandle); self._focus(this, true); }); - + this._mouseInit(); }; - + $.extend(handleclass.prototype, $.ui.mouse, { _mouseStart: function(event) { return self._start.call(self, event, this.element[0]); }, _mouseStop: function(event) { return self._stop.call(self, event, this.element[0]); }, @@ -103,7 +103,7 @@ $.widget("ui.slider", { _mouseCapture: function() { return true; }, trigger: function(event) { this._mouseDown(event); } }); - + $(this.handle) .each(function() { new handleclass(this); @@ -115,29 +115,29 @@ $.widget("ui.slider", { .bind('blur', function(event) { self._blur(this.firstChild); }) .bind('keydown', function(event) { if(!self.options.noKeyboard) return self._keydown(event.keyCode, this.firstChild); }) ; - + // Bind the click to the slider itself this.element.bind('mousedown.slider', function(event) { self._click.apply(self, [event]); self.currentHandle.data("mouse").trigger(event); self.firstValue = self.firstValue + 1; //This is for always triggering the change event }); - + // Move the first handle to the startValue $.each(this.options.handles || [], function(index, handle) { self.moveTo(handle.start, index, true); }); 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(); }, _initBoundaries: function() { - + var element = this.element[0], o = this.options; this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() }; - + $.extend(o, { axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'), max: !isNaN(parseInt(o.max,10)) ? { x: parseInt(o.max, 10), y: parseInt(o.max, 10) } : ({ x: o.max && o.max.x || 100, y: o.max && o.max.y || 100 }), @@ -154,7 +154,7 @@ $.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) { if (this.options.disabled) return; @@ -193,9 +193,9 @@ $.widget("ui.slider", { // - The user didn't click a handle // - The Slider is not disabled // - There is a current, or previous selected handle (otherwise we wouldn't know which one to move) - + var pointer = [event.pageX, event.pageY]; - + var clickedHandle = false; this.handle.each(function() { if(this == event.target) @@ -203,20 +203,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(event.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"), x: this._convertValue(event.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x") }, null, !this.options.distance); }, - + _createRange: function() { if(this.rangeElement) return; this.rangeElement = $('<div></div>') @@ -238,7 +238,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]); }, @@ -247,7 +247,7 @@ $.widget("ui.slider", { if(!axis) axis = this.options.axis == "vertical" ? "y" : "x"; var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle); - + if(curHandle.data("mouse").sliderValue) { return parseInt(curHandle.data("mouse").sliderValue[axis],10); } else { @@ -258,7 +258,7 @@ $.widget("ui.slider", { _convertValue: function(value,axis) { return this.options.min[axis] + (value / (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis))) * this.options.realMax[axis]; }, - + _translateValue: function(value,axis) { return ((value - this.options.min[axis]) / this.options.realMax[axis]) * (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis)); }, @@ -297,28 +297,28 @@ $.widget("ui.slider", { }, _start: function(event, 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(); this.clickOffset = { top: event.pageY - this.handleOffset.top, left: event.pageX - this.handleOffset.left }; - + this.firstValue = this.value(); - + this._propagate('start', event); this._drag(event, handle); return true; - + }, _stop: function(event) { this._propagate('stop', event); @@ -329,14 +329,14 @@ $.widget("ui.slider", { return false; }, _drag: function(event, handle) { - + var o = this.options; var position = { top: event.pageY - this.offset.top - this.clickOffset.top, left: event.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"); - + if (o.stepping.x) { var value = this._convertValue(position.left, "x"); value = Math.round(value / o.stepping.x) * o.stepping.x; @@ -347,49 +347,49 @@ $.widget("ui.slider", { value = Math.round(value / o.stepping.y) * o.stepping.y; position.top = this._translateValue(value, "y"); } - + 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 }); - + //Store the slider's value this.currentHandle.data("mouse").sliderValue = { x: Math.round(this._convertValue(position.left, "x")) || 0, y: Math.round(this._convertValue(position.top, "y")) || 0 }; - + if (this.rangeElement) this._updateRange(); this._propagate('slide', event); return false; }, - + 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; - + //If only one handle is available, use it if (handle == undefined && !this.currentHandle) handle = 0; - + 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) { @@ -398,7 +398,7 @@ $.widget("ui.slider", { x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10); } } - + if(y !== undefined && y.constructor != Number) { var me = /^\-\=/.test(y), pe = /^\+\=/.test(y); if(me || pe) { @@ -407,7 +407,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"); @@ -416,7 +416,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"); @@ -424,16 +424,16 @@ $.widget("ui.slider", { y = this._translateRange(y, "y"); o.animate ? this.currentHandle.stop().animate({ top: y }, (Math.abs(parseInt(this.currentHandle.css("top")) - y)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ top: y }); } - + 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("slide", null); diff --git a/ui/ui.spinner.js b/ui/ui.spinner.js index 93bd96ba8..7af29e814 100644 --- a/ui/ui.spinner.js +++ b/ui/ui.spinner.js @@ -15,7 +15,7 @@ $.widget('ui.spinner', { _init: function() { this._trigger('init', null, this.ui(null)); - + // perform data bind on generic objects if (typeof this.options.items[0] == 'object' && !this.element.is('input')) { var data = this.options.items; @@ -23,22 +23,22 @@ $.widget('ui.spinner', { this._addItem(data[i]); } } - + // check for decimals in steppinng and set _decimals as internal this._decimals = parseInt(this.options.decimals, 10); if (this.options.stepping.toString().indexOf('.') != -1 && this._decimals == 0) { var s = this.options.stepping.toString(); this._decimals = s.slice(s.indexOf('.')+1, s.length).length; } - + //Initialize needed constants var self = this; this.element .addClass('ui-spinner-box') .attr('autocomplete', 'off'); // switch off autocomplete in opera - + this._setValue( isNaN(this._getValue()) ? this.options.start : this._getValue() ); - + this.element .wrap('<div>') .parent() @@ -137,7 +137,7 @@ $.widget('ui.spinner', { self._propagate('change', event); }) .end(); - + // Give the spinner casing a unique id only if one exists in original input // - this should aid targetted customisations if a page contains multiple instances this.element.attr('id', function(){ @@ -145,7 +145,7 @@ $.widget('ui.spinner', { $(this).parent().attr('id', this.id+'-ui-spinner'); } }); - + // DataList: Set contraints for object length and step size. // Manipulate height of spinner. this._items = this.element.children().length; @@ -166,7 +166,7 @@ $.widget('ui.spinner', { this.options.min = 0; this.options.max = this._items-1; } - + this.element .bind('keydown.spinner', function(event) { if (!self.counter) { @@ -181,14 +181,14 @@ $.widget('ui.spinner', { .bind('blur.spinner', function(event) { self._cleanUp(); }); - + if ($.fn.mousewheel) { this.element.mousewheel(function(event, delta) { self._mousewheel(event, delta); }); } }, - + _constrain: function() { if (this.options.min != undefined && this._getValue() < this.options.min) { this._setValue(this.options.min); @@ -205,7 +205,7 @@ $.widget('ui.spinner', { if (this.disabled) { return; } - + if (isNaN(this._getValue())) { this._setValue(this.options.start); } @@ -250,7 +250,7 @@ $.widget('ui.spinner', { }, _keydown: function(event) { var KEYS = $.keyCode; - + if (event.keyCode == KEYS.UP) { this._up(event); } @@ -314,10 +314,10 @@ $.widget('ui.spinner', { wrapper = 'li'; } var html = obj; // string or object set it to html first - + if (typeof obj == 'object') { var format = (fmt !== undefined ? fmt : this.options.format); - + html = format.replace(/%(\(([^)]+)\))?/g, (function(data){ return function(match, a, lbl) { @@ -335,7 +335,7 @@ $.widget('ui.spinner', { this.element.append('<'+ wrapper +' class="ui-spinner-dyn">'+ html + '</'+ wrapper +'>'); } }, - + plugins: {}, ui: function(event) { return { diff --git a/ui/ui.tabs.js b/ui/ui.tabs.js index d75b2ab9f..d51fee912 100644 --- a/ui/ui.tabs.js +++ b/ui/ui.tabs.js @@ -48,13 +48,13 @@ $.widget("ui.tabs", { return $.cookie.apply(null, [cookie].concat($.makeArray(arguments))); }, _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 @@ -77,14 +77,14 @@ $.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.addClass(o.panelClass); - + // Selected tab // use "selected" option or try to retrieve: // 1. from fragment identifier in url @@ -107,7 +107,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. @@ -117,7 +117,7 @@ $.widget("ui.tabs", { )).sort(); if ($.inArray(o.selected, o.disabled) != -1) o.disabled.splice($.inArray(o.selected, o.disabled), 1); - + // highlight selected tab this.$panels.addClass(o.hideClass); this.$lis.removeClass(o.selectedClass); @@ -126,41 +126,41 @@ $.widget("ui.tabs", { var classes = [o.selectedClass]; if (o.deselectable) classes.push(o.deselectableClass); this.$lis.eq(o.selected).addClass(classes.join(' ')); - + // seems to be expected behavior that the show callback is fired var onShow = function() { 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); // just trigger show event else onShow(); } - + // clean up to avoid memory leaks in certain versions of IE 6 $(window).bind('unload', function() { 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) this._cookie(o.selected, o.cookie); - + // 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'); - + // set up animations var hideFx, showFx; if (o.fx) { @@ -170,7 +170,7 @@ $.widget("ui.tabs", { } else hideFx = showFx = o.fx; } - + // Reset certain styles left over from animation // and prevent IE's ClearType bug... function resetStyle($el, fx) { @@ -191,7 +191,7 @@ $.widget("ui.tabs", { $show.removeClass(o.hideClass); self._trigger('show', null, self.ui(clicked, $show[0])); }; - + // Hide a tab, $show is optional... var hideTab = hideFx ? function(clicked, $hide, $show) { @@ -205,7 +205,7 @@ $.widget("ui.tabs", { $hide.addClass(o.hideClass); if ($show) showTab(clicked, $show); }; - + // Switch a tab... function switchTab(clicked, $li, $hide, $show) { var classes = [o.selectedClass]; @@ -213,15 +213,15 @@ $.widget("ui.tabs", { $li.addClass(classes.join(' ')).siblings().removeClass(classes.join(' ')); hideTab(clicked, $hide, $show); } - + // attach tab event handler, unbind to avoid duplicates from former tabifying... this.$tabs.unbind('.tabs').bind(o.event + '.tabs', function() { - + //var trueClick = event.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 = $(self._sanitizeSelector(this.hash)); - + // If tab is already selected and not deselectable 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 @@ -234,9 +234,9 @@ $.widget("ui.tabs", { this.blur(); return false; } - + o.selected = self.$tabs.index(this); - + // if tab may be closed if (o.deselectable) { if ($li.hasClass(o.selectedClass)) { @@ -257,12 +257,12 @@ $.widget("ui.tabs", { return false; } } - + if (o.cookie) self._cookie(o.selected, o.cookie); - + // stop possibly running animations self.$panels.stop(); - + // show new tab if ($show.length) { var a = this; @@ -277,31 +277,31 @@ $.widget("ui.tabs", { ); } 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 via CSS // in modern browsers; blur() removes focus from address bar in Firefox // which can become a usability and annoying problem with tabs('rotate'). if ($.browser.msie) this.blur(); - + return false; - + }); - + // disable click if event is configured to something else if (o.event != 'click') 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) { @@ -317,12 +317,12 @@ $.widget("ui.tabs", { $li.insertBefore(this.$lis[index]); $panel.insertBefore(this.$panels[index]); } - + 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); @@ -330,24 +330,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])); }, @@ -355,7 +355,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'); @@ -363,9 +363,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])); }, @@ -373,10 +373,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])); } @@ -388,20 +388,20 @@ $.widget("ui.tabs", { this.$tabs.eq(index).trigger(this.options.event + '.tabs'); }, load: function(index, callback) { // callback is for internal usage only - + 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 if (!url || !bypassCache && $.data(a, 'cache.tabs')) { callback(); return; } - + // load remote from here on - + var inner = function(parent) { var $parent = $(parent), $inner = $parent.find('*:last'); return $inner.length && $inner.is(':not(img)') && $inner || $parent; @@ -414,29 +414,29 @@ $.widget("ui.tabs", { }); self.xhr = null; }; - + if (o.spinner) { var label = inner(a).html(); 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) { $(self._sanitizeSelector(a.hash)).html(r); cleanup(); - + 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])); try { o.ajaxOptions.success(r, s); } catch (event) {} - + // This callback is required because the switch has to take // place after loading has completed. Call last in order to // fire load before show callback... @@ -519,24 +519,24 @@ $.extend($.ui.tabs, { $.extend($.ui.tabs.prototype, { rotation: null, rotate: function(ms, continuing) { - + continuing = continuing || false; - + var self = this, t = this.options.selected; - + function start() { self.rotation = setInterval(function() { t = ++t < self.$tabs.length ? t : 0; self.select(t); }, ms); } - + function stop(event) { if (!event || event.clientX) { // only in case of a true click clearInterval(self.rotation); } } - + // start interval if (ms) { start(); |