diff --git a/demos/datepicker/localization.html b/demos/datepicker/localization.html index 33d03c98c11..767cdaa54a7 100644 --- a/demos/datepicker/localization.html +++ b/demos/datepicker/localization.html @@ -10,6 +10,7 @@ + @@ -87,6 +88,7 @@ Afrikaans Albanian (Gjuha shqipe) + Algerian Arabic Arabic ((لعربي Armenian (Հայերեն) Azerbaijani (Azərbaycan dili) diff --git a/demos/effect/index.html b/demos/effect/index.html index 65aa3993aef..00766d3715b 100644 --- a/demos/effect/index.html +++ b/demos/effect/index.html @@ -11,6 +11,7 @@ Examples Effect showcase + Text Effect showcase Easing showcase diff --git a/demos/effect/text.html b/demos/effect/text.html new file mode 100644 index 00000000000..f0f93bdcd39 --- /dev/null +++ b/demos/effect/text.html @@ -0,0 +1,249 @@ + + + + + jQuery UI Effects - Text Effect demo + + + + + + + + + + + + + + + Click each block of text to play its animation + + + + + BlockFadeOut(by word) + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi nibh. Maecenas metus nisi, tempus sed. + + + BlockFadeIn(by word) + + + + + BlockFadeOut(by character) + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi nibh. Maecenas metus nisi, tempus sed. + + + BlockFadeIn(by character) + + + + + + + + build(by word) + + + + + disintegrate(by word) + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi nibh. Maecenas metus nisi, tempus sed. + + + build(by character) + + + + + disintegrate(by character) + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi nibh. Maecenas metus nisi, tempus sed. + + + + + + type (letters) + + + + + backspace (letters) + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi nibh. Maecenas metus nisi, tempus sed. + + + + + textExplode(by word) + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi nibh. Maecenas metus nisi, tempus sed. + + + textConverge(by word) + + + + + textExplode(by character) + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi nibh. Maecenas metus nisi, tempus sed. + + + textConverge(by character) + + + + + + + + + +options available in each effect: + + Whether or not the text should be split into words rather than characers + Text to use instead of the element's innerHTML + The distance the pieces travel (as a multiple of the element's respective dimensions) + The direction the pieces travel + Whether or not to fade the pieces in/out + How much the effect should be randomized (a percentage) + stop elements from leaving the document's boundaries + + + + + + General Options + + Random? + % randomness + + Reverse? (not really visible when random is turned on) + + + Build/Disintegrate options: + + bottom + top + left + right + bottom left + bottom right + top left + top right + + + Distance? (* parent height) + + + + + + + \ No newline at end of file diff --git a/demos/index.html b/demos/index.html index b870221eea2..e1f4eec9132 100644 --- a/demos/index.html +++ b/demos/index.html @@ -7,8 +7,8 @@ - - + + @@ -44,6 +44,7 @@ + diff --git a/demos/spinner/currency.html b/demos/spinner/currency.html index 2439674a028..1c2f01a7270 100644 --- a/demos/spinner/currency.html +++ b/demos/spinner/currency.html @@ -6,9 +6,9 @@ - - - + + + diff --git a/demos/spinner/decimal.html b/demos/spinner/decimal.html index 6f4b92da110..f396c18d203 100644 --- a/demos/spinner/decimal.html +++ b/demos/spinner/decimal.html @@ -6,9 +6,9 @@ - - - + + + diff --git a/demos/spinner/time.html b/demos/spinner/time.html index e38ee296fab..8c5560507b1 100644 --- a/demos/spinner/time.html +++ b/demos/spinner/time.html @@ -6,8 +6,8 @@ - - + + diff --git a/external/glob.de-DE.js b/external/jquery.global.de-DE.js similarity index 97% rename from external/glob.de-DE.js rename to external/jquery.global.de-DE.js index d68b84cc8c5..e526e783114 100644 --- a/external/glob.de-DE.js +++ b/external/jquery.global.de-DE.js @@ -1,5 +1,5 @@ (function($) { - var cultures = $.cultures, + var cultures = $.global.cultures, en = cultures.en, standard = en.calendars.standard, culture = cultures["de-DE"] = $.extend(true, {}, en, { @@ -52,4 +52,4 @@ } }, cultures["de-DE"]); culture.calendar = culture.calendars.standard; -})(Globalization); \ No newline at end of file +})(jQuery); \ No newline at end of file diff --git a/external/glob.ja-JP.js b/external/jquery.global.ja-JP.js similarity index 98% rename from external/glob.ja-JP.js rename to external/jquery.global.ja-JP.js index 454d478cb42..3673cefd1a7 100644 --- a/external/glob.ja-JP.js +++ b/external/jquery.global.ja-JP.js @@ -1,5 +1,5 @@ (function($) { - var cultures = $.cultures, + var cultures = $.global.cultures, en = cultures.en, standard = en.calendars.standard, culture = cultures["ja-JP"] = $.extend(true, {}, en, { @@ -71,4 +71,4 @@ } }, cultures["ja-JP"]); culture.calendar = culture.calendars.standard; -})(Globalization); \ No newline at end of file +})(jQuery); \ No newline at end of file diff --git a/external/glob.js b/external/jquery.global.js similarity index 97% rename from external/glob.js rename to external/jquery.global.js index 8075ee2bd2e..29ae5c637f0 100644 --- a/external/glob.js +++ b/external/jquery.global.js @@ -1,11 +1,14 @@ -/* - * Globalization - * http://github.com/nje/jquery-glob +/*! + * jQuery Globalization Plugin + * http://github.com/jquery/jquery-global + * + * Copyright Software Freedom Conservancy, Inc. + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license */ (function() { -var Globalization = {}, - localized = { en: {} }; +var Globalization = {}, localized = { en: {} }; localized["default"] = localized.en; Globalization.extend = function( deep ) { @@ -106,10 +109,12 @@ Globalization.preferCulture = function(name) { this.culture = this.findClosestCulture( name ) || this.cultures["default"]; } Globalization.localize = function(key, culture, value) { - if (typeof culture === 'string') { - culture = culture || "default"; - culture = this.cultures[ culture ] || { name: culture }; + // usign default culture in case culture is not provided + if (typeof culture !== 'string') { + culture = this.culture.name || this.culture || "default"; } + culture = this.cultures[ culture ] || { name: culture }; + var local = localized[ culture.name ]; if ( arguments.length === 3 ) { if ( !local) { @@ -147,10 +152,23 @@ Globalization.parseInt = function(value, radix, culture) { return Math.floor( this.parseFloat( value, radix, culture ) ); } Globalization.parseFloat = function(value, radix, culture) { + // make radix optional + if (typeof radix === "string") { + culture = radix; + radix = 10; + } + culture = this.findClosestCulture( culture ); var ret = NaN, nf = culture.numberFormat; + if (value.indexOf(culture.numberFormat.currency.symbol) > -1) { + // remove currency symbol + value = value.replace(culture.numberFormat.currency.symbol, ""); + // replace decimal seperator + value = value.replace(culture.numberFormat.currency["."], culture.numberFormat["."]); + } + // trim leading and trailing whitespace value = trim( value ); @@ -297,7 +315,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, { // And the 'zh-SG' culture is Simplified Chinese in Singapore, whose lanugage // field is "zh-CHS", not "zh". // This field should be used to navigate from a specific culture to it's - // more general, neutral culture. If a culture is already as general as it + // more general, neutral culture. If a culture is already as general as it // can get, the language may refer to itself. language: "en", // numberFormat defines general number formatting rules, like the digits in @@ -307,7 +325,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, { // Note, numberFormat.pattern has no 'positivePattern' unlike percent and currency, // but is still defined as an array for consistency with them. // negativePattern: one of "(n)|-n|- n|n-|n -" - pattern: ["-n"], + pattern: ["-n"], // number of decimal places normally shown decimals: 2, // string that separates number groups, as in 1,000,000 @@ -325,7 +343,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, { // [negativePattern, positivePattern] // negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %" // positivePattern: one of "n %|n%|%n|% n" - pattern: ["-n %","n %"], + pattern: ["-n %","n %"], // number of decimal places normally shown decimals: 2, // array of numbers indicating the size of each number group. @@ -389,7 +407,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, { }, // AM and PM designators in one of these forms: // The usual view, and the upper and lower case versions - // [standard,lowercase,uppercase] + // [standard,lowercase,uppercase] // The culture does not use AM or PM (likely all standard date formats use 24 hour time) // null AM: ["AM", "am", "AM"], @@ -443,7 +461,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, { Given the date as a parameter, return an array with parts [year, month, day] corresponding to the non-gregorian based year, month, and day for the calendar. toGregorian(year, month, day) - Given the non-gregorian year, month, and day, return a new Date() object + Given the non-gregorian year, month, and day, return a new Date() object set to the corresponding date in the gregorian calendar. */ } @@ -512,7 +530,7 @@ function expandNumber(number, precision, formatInfo) { rounded = number; } number = rounded; - + var numberString = number+"", right = "", split = numberString.split(/e/i), @@ -521,7 +539,7 @@ function expandNumber(number, precision, formatInfo) { split = numberString.split( "." ); numberString = split[ 0 ]; right = split.length > 1 ? split[ 1 ] : ""; - + var l; if ( exponent > 0 ) { right = zeroPad( right, exponent, false ); @@ -728,7 +746,7 @@ function getEraYear(date, cal, era, sortable) { // convert normal gregorian year to era-shifted gregorian // year by subtracting the era offset year -= cal.eras[ era ].offset; - } + } return year; } @@ -764,7 +782,7 @@ function getMonthIndex(cal, value, abbr) { if ( !upperMonths ) { cal._upperMonths = upperMonths = [ toUpperArray( months.names ), - toUpperArray( months.namesAbbr ), + toUpperArray( months.namesAbbr ) ]; cal._upperMonthsGen = upperMonthsGen = [ toUpperArray( monthsGen.names ), @@ -1153,7 +1171,7 @@ function formatDate(value, format, culture) { } return r; } - + function hasDay() { if ( foundDay || checkedDay ) { return foundDay; @@ -1162,7 +1180,7 @@ function formatDate(value, format, culture) { checkedDay = true; return foundDay; } - + function getPart( date, part ) { if ( converted ) { return converted[ part ]; @@ -1197,7 +1215,7 @@ function formatDate(value, format, culture) { ret.push( ar[ 0 ] ); continue; } - + var current = ar[ 0 ], clength = current.length; @@ -1284,7 +1302,7 @@ function formatDate(value, format, culture) { // Milliseconds ret.push( padZeros( value.getMilliseconds(), 3 ).substr( 0, clength ) ); break; - case "z": + case "z": // Time zone offset, no leading zero case "zz": // Time zone offset with leading zero @@ -1317,17 +1335,7 @@ function formatDate(value, format, culture) { } // EXPORTS - -window.Globalization = Globalization; - -//jQuery.findClosestCulture = Globalization.findClosestCulture; -//jQuery.culture = Globalization.culture; -//jQuery.cultures = Globalization.cultures -//jQuery.preferCulture = Globalization.preferCulture -//jQuery.localize = Globalization.localize -//jQuery.format = Globalization.format -//jQuery.parseInt = Globalization.parseInt -//jQuery.parseFloat = Globalization.parseFloat -//jQuery.parseDate = Globalization.parseDate +jQuery.global = Globalization; })(); + diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index af561a78389..33b07d6949d 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -796,16 +796,21 @@ test('parseDate', function() { equalsDate($.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy', 'day 3 of February (\'Saturday\'), 2001'), new Date(2001, 2 - 1, 3), 'Parse date \'day\' d \'of\' MM (\'\'DD\'\'), yy'); - equalsDate($.datepicker.parseDate('ymmdd', '010203'), - new Date(2001, 2 - 1, 3), 'Parse date ymmdd - default cutoff'); - equalsDate($.datepicker.parseDate('y-m-d', '01-02-03'), - new Date(2001, 2 - 1, 3), 'Parse date y-m-d - default cutoff'); - equalsDate($.datepicker.parseDate('y-m-d', '51-02-03'), - new Date(1951, 2 - 1, 3), 'Parse date y-m-d - default cutoff'); - equalsDate($.datepicker.parseDate('y-m-d', '51-02-03', {shortYearCutoff: 80}), - new Date(2051, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); - equalsDate($.datepicker.parseDate('y-m-d', '51-02-03', {shortYearCutoff: '+60'}), - new Date(2051, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); + var currentYear = new Date().getFullYear(); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000) + '-02-03'), + new Date(currentYear, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 10) + '-02-03'), + new Date(currentYear+10, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 11) + '-02-03'), + new Date(currentYear-89, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); + equalsDate($.datepicker.parseDate('y-m-d', '80-02-03', {shortYearCutoff: 80}), + new Date(2080, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); + equalsDate($.datepicker.parseDate('y-m-d', '81-02-03', {shortYearCutoff: 80}), + new Date(1981, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 60) + '-02-03', {shortYearCutoff: '+60'}), + new Date(currentYear + 60, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 61) + '-02-03', {shortYearCutoff: '+60'}), + new Date(currentYear - 39, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); var gmtDate = new Date(2001, 2 - 1, 3); gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset()); equalsDate($.datepicker.parseDate('@', '981158400000'), gmtDate, 'Parse date @'); diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html index ac90dcf6a29..92385669f92 100644 --- a/tests/unit/spinner/spinner.html +++ b/tests/unit/spinner/spinner.html @@ -7,7 +7,7 @@ - + diff --git a/ui/i18n/jquery.ui.datepicker-ar-DZ.js b/ui/i18n/jquery.ui.datepicker-ar-DZ.js new file mode 100644 index 00000000000..e0e1685d845 --- /dev/null +++ b/ui/i18n/jquery.ui.datepicker-ar-DZ.js @@ -0,0 +1,23 @@ +/* Algerian Arabic Translation for jQuery UI date picker plugin. (can be used for Tunisia)*/ +/* Mohamed Cherif BOUCHELAGHEM -- cherifbouchelaghem@yahoo.fr */ + +jQuery(function($){ + $.datepicker.regional['ar-DZ'] = { + closeText: 'إغلاق', + prevText: '<السابق', + nextText: 'التالي>', + currentText: 'اليوم', + monthNames: ['جانفي', 'فيفري', 'مارس', 'أفريل', 'ماي', 'جوان', + 'جويلية', 'أوت', 'سبتمبر','أكتوبر', 'نوفمبر', 'ديسمبر'], + monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'], + dayNames: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'], + dayNamesShort: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'], + dayNamesMin: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'], + weekHeader: 'أسبوع', + dateFormat: 'dd/mm/yy', + firstDay: 6, + isRTL: true, + showMonthAfterYear: false, + yearSuffix: ''}; + $.datepicker.setDefaults($.datepicker.regional['ar-DZ']); +}); diff --git a/ui/jquery.effects.text.js b/ui/jquery.effects.text.js new file mode 100644 index 00000000000..c9ac5c3db5d --- /dev/null +++ b/ui/jquery.effects.text.js @@ -0,0 +1,507 @@ +/* + * jQuery UI Effects Text @VERSION + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Effects/.. + * + * Depends: + * jquery.effects.text.js + */ +(function( $, undefined ) { + + + var defaultOptions = { + easing: 'linear', + words: true, + text: '', + distance: 1, + // move element to/from where * parent.height () + direction: 'top', + reverse: false, + random: false + }; + + $.effects.textExplode = function (o, show) { + + var docHeight = $(document).height(), + docWidth = $(document).width(); /* show is either 1 or null */ + show = show ? 1 : 0; + + /* Internal callback to run before animation has started */ + + function beforeAnimate() { + + /* Set the current position of the element */ + var $this = this.css(this.offset()); + /* + Have to find out why this happends, + just doing this.css ('position', 'absolute') doesn't work >:-[ + So we use this work around + */ + setTimeout( + + function () { + $this.css('position', 'absolute'); + }, 10); + + } + + function finished() { + this.empty(); + } + + var options = o.options = $.extend({}, defaultOptions, { + easing: show ? 'easeInSine' : 'easeInCirc' + }, o.options, { + finished: show ? null : finished, + beforeAnimate: beforeAnimate, + /* animation function */ + animate: function (interval, duration, i, wordCount, parentCoords) { + + /* set some basic stuff */ + var offset = this.offset(), + offsetTo = {}, + width = this.outerWidth(), + height = this.outerHeight(), + properties = {}, + /* max top */ + mTop = docHeight - height, + /* max left */ + mLeft = docWidth - width, + distance = options.distance * 2, + distanceY, distanceX, distanceXY, properties = { + opacity: show ? 1 : 0 + }, + _duration = duration, + randomX = 0, + randomY = 0, + delay = 10; + + /* Hide or show the element according to what we're going to do */ + this.css({ + opacity: show ? 0 : 1 + }); + + + if (options.random !== false) { + var seed = (Math.random() * options.random) + Math.max(1 - options.random, 0); + + distance *= seed; + duration *= seed; + + // To syncronize, give each piece an appropriate delay so they end together + //delay = ((args.unhide && args.sync) || (!args.unhide && !args.sync)) ? (args.duration - duration) : 0; + randomX = Math.random() - 0.5; + randomY = Math.random() - 0.5; + } + + distanceY = ((parentCoords.height - height) / 2 - (offset.top - parentCoords.top)); + distanceX = ((parentCoords.width - width) / 2 - (offset.left - parentCoords.left)); + distanceXY = Math.sqrt(Math.pow(distanceX, 2) + Math.pow(distanceY, 2)); + + offsetTo.top = offset.top - distanceY * distance + distanceXY * randomY; + offsetTo.left = offset.left - distanceX * distance + distanceXY * randomX; + + if (offsetTo.top > (docHeight - height)) { + offsetTo.top = docHeight - height; + } else if (offsetTo.top < 0) { + offsetTo.top = 0; + } + + if (offsetTo.left > (docWidth - width)) { + offsetTo.left = docWidth - width; + } else if (offsetTo.left < 0) { + offsetTo.left = 0; + } + + if (show) { + this.css(offsetTo); + properties.top = offset.top; + properties.left = offset.left; + + } else { + this.css(offset); + properties.top = offsetTo.top; + properties.left = offsetTo.left; + } + + /* run it */ + this.delay(delay).animate(properties, duration, options.easing); + + + + } + }); + + /* Pass everything to the general text engine */ + $.effects.textAnim.call(this, o); + }; + + $.effects.textConverge = function (o) { + $.effects.textExplode.call(this, o, 1); + }; + + $.effects.backspace = function (o, show) { /* show is either 1 or null */ + show = show || 0; + + /* Internal callback to run when animation has finished */ + + function finished() { + this.empty(); + } + + /* Internal callback to run before animation has started */ + + function beforeAnimate() { + this.css('opacity', 0); + } + + var options = o.options = $.extend({}, defaultOptions, { + easing: 'easeInOutSine' + }, o.options, { + words: false, + wordDelay: 0 + }, { + finished: show ? null : finished, + beforeAnimate: show ? beforeAnimate : null, + animate: function (interval, duration, i, wordCount, parentCoords) { + + + var text = this.text(), + space = /\s/.test(text), + + /* default delay */ + delay = show ? (interval * i) : (wordCount - i - 1) * interval; + + /* + Randomize delay if necessary + Note, reverse doesn't really matter at this time + */ + if (options.random !== false && show) { + var randomDelay = (Math.random() * text.length * interval) * interval; + + /* The higher the random % the slower */ + delay = (randomDelay / (2 - options.random)) + options.wordDelay; + options.wordDelay = delay; + } + + + /* run it */ + this.delay(delay).animate({ + opacity: show + }, 10, options.easing); + } + }); + + /* Pass everything to the general text engine */ + $.effects.textAnim.call(this, o); + }; + + + $.effects.type = function (o) { /* Use the backspace, for redundancy purposes */ + $.effects.backspace.call(this, o, 1); + }; + + $.effects.disintegrate = function (o, show) { + + var docHeight = $(document).height(), + docWidth = $(document).width(); /* show is either 1 or null (build or disintegrate) */ + show = show ? 1 : 0; + + /* Internal callback to run before animation has started */ + + function beforeAnimate() { + + /* Set the current position of the element */ + var $this = this.css(this.offset()); + /* + Have to find out why this happends, + just doing this.css ('position', 'absolute') doesn't work >:-[ + So we use this work around + */ + setTimeout( + + function () { + $this.css('position', 'absolute'); + }, 10); + + } + + function finished() { + this.empty(); + } + + var options = o.options = $.extend({}, defaultOptions, { + easing: show ? 'easeInSine' : 'easeInCirc' + }, o.options, { + finished: show ? null : finished, + beforeAnimate: beforeAnimate, + /* animation function */ + animate: function (interval, duration, i, wordCount, parentCoords) { + + /* set some basic stuff */ + var offset = this.offset(), + width = this.outerWidth(), + height = this.outerHeight(), + properties = {}, + /* max top */ + mTop = docHeight - height, + /* max left */ + mLeft = docWidth - width; + + /* Hide or show the element according to what we're going to do */ + this.css({ + opacity: show ? 0 : 1 + }); + + var top, left; + if (show) { /* we're going to build */ + properties.top = offset.top; + properties.left = offset.left; + properties.opacity = 1; + if (options.direction.indexOf('top') !== -1) { + top = offset.top - parentCoords.height * options.distance; + + this.css('top', top < 0 ? 0 : top); // 1 = o.distance + } else if (options.direction.indexOf('bottom') !== -1) { + top = offset.top + parentCoords.height * options.distance; + + this.css('top', top > mTop ? mTop : top); // 1 = o.distance + } + + if (options.direction.indexOf('left') !== -1) { + left = offset.left - parentCoords.width * options.distance; + + this.css('left', left < 0 ? 0 : left); // 1 = o.distance + } else if (options.direction.indexOf('right') !== -1) { + left = offset.left + parentCoords.width * options.distance; + + this.css('left', left > mLeft ? mLeft : left); // 1 = o.distance + } + + } else { /* We're going to disintegrate */ + if (options.direction.indexOf('bottom') !== -1) { + top = offset.top + parentCoords.height * options.distance; + + properties.top = top > mTop ? mTop : top; // 1 = o.distance + } else if (options.direction.indexOf('top') !== -1) { + var top = offset.top - parentCoords.height * options.distance + + properties.top = top < 0 ? 0 : top; // 1 = o.distance + } + + if (options.direction.indexOf('right') !== -1) { + left = offset.left + parentCoords.width * options.distance; + + properties.left = left > mLeft ? mLeft : left; // 1 = o.distance + } else if (options.direction.indexOf('left') !== -1) { + left = offset.left - parentCoords.width * options.distance; + + properties.left = left < 0 ? 0 : left; // 1 = o.distance + } + properties.opacity = 0; + } + + /* default delay */ + var delay = interval * i; + + /* + Randomize delay if necessary + Note, reverse doesn't really matter at this time + */ + if (options.random !== false) { + + var randomDelay = Math.random() * wordCount * interval, + /* If interval or random is negative, start from the bottom instead of top */ + uniformDelay = options.reverse ? ((wordCount - i) * interval) : (i * interval); + + delay = randomDelay * options.random + Math.max(1 - options.random, 0) * uniformDelay; + } + + + /* run it */ + this.delay(delay + 10 /* fixes stuff in chrome*/ ).animate(properties, duration, options.easing); + } + }); + + /* Pass everything to the general text engine */ + $.effects.textAnim.call(this, o); + }; + + $.effects.build = function (o) { /* Use the disintegrate, for redundancy purposes */ + $.effects.disintegrate.call(this, o, 1); + }; + + $.effects.blockFadeOut = function (o, show) { /* show is either 1 or null */ + show = show || 0; + + /* Internal callback to run when animation has finished */ + + function finished() { + this.empty(); + } + + /* Internal callback to run before animation has started */ + + function beforeAnimate() { + this.css('opacity', 0); + } + + + var options = o.options = $.extend({}, defaultOptions, { + easing: 'easeInOutSine' + }, o.options, { /* only run when we fadeOut */ + finished: !show ? finished : null, + /* only run when we fadeIn */ + beforeAnimate: show ? beforeAnimate : null, + /* animation function */ + animate: function (interval, duration, i, wordCount, parentCoords) { + + /* default delay */ + var delay = interval * i; + + /* + Randomize delay if necessary + Note, reverse doesn't really matter at this time + */ + if (options.random !== false) { + + var randomDelay = Math.random() * wordCount * interval, + /* If interval or random is negative, start from the bottom instead of top */ + uniformDelay = options.reverse ? ((wordCount - i) * interval) : (i * interval); + + delay = randomDelay * options.random + Math.max(1 - options.random, 0) * uniformDelay; + } + + /* run it */ + this.delay(delay).animate({ + opacity: show + }, duration, options.easing); + } + }); + + /* Pass everything to the general text engine */ + $.effects.textAnim.call(this, o); + }; + + + $.effects.blockFadeIn = function (o) { /* Use the blockFadeOut, for redundancy purposes */ + $.effects.blockFadeOut.call(this, o, 1); + }; + + $.effects.textAnim = function (o) { + + var options = o.options; + + return this.queue( + + function () { + + var replaceWith, tagReg, reg, html, i, $set, set, wordCount, duration, interval, parentCoords, $this = $(this); /* No height etc. */ + $this.width($this.width()); + $this.height($this.height()); + + + /* + The following regular expression courtesy of Phil Haack + http://haacked.com/archive/2004/10/25/usingregularexpressionstomatchhtml.aspx + */ + tagReg = /(<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>)/g; + + /* Translation: /(HTML tag plus spaces)|(word/letter without '<' plus spaces)/g */ + if (options.words) { + reg = /(<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>)\s*|([^\s<]+\s*)/g; + } else { + reg = /(<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>)\s*|([^\s<]\s*)/g; + } + + /* Make sure the correct html is in place */ + if (options.text !== '') { + $this.html(options.text); + } + + /* Set the current text to use */ + options.text = $this.html(); + + /* Get the words */ + words = options.text.match(reg); + + /* Array for HTML, will join later */ + html = []; + + /* Loop over the words and seperate them (put 'em in a span) */ + for (i = 0, l = words.length; i < l; i++) { + var word = words[i]; + + if (!word.match(tagReg)) { + html.push('' + word + ''); + } else { + html.push(word); + } + } + + + /* See how many words there are */ + wordCount = html.length; + + /* No words? halt */ + if (!wordCount) { + return; + } + + /* Put the newer correct html in place */ + $this.html(html.join('')); + + /* Retreive the total set of elements */ + $set = $this.find('span:not(:has(span))'); + set = $set.get(); + + /* Calculate the duration and interval points */ + interval = (o.duration / (1.5 * wordCount)); + + duration = (o.duration - wordCount * interval); + + /* If the cycle needs to reverse, reverse it all */ + if (options.reverse) { + set.reverse(); + } + + /* Width, height, left, top of parent for calculations */ + parentCoords = $.extend($this.offset(), { + width: $this.width(), + height: $this.height() + }); + + /* Iterate over all the elements run their animation function on it */ + for (i = 0, l = set.length; i < l; i++) { + var $word = $(set[i]); + + /* Do something to the element before the animation starts */ + $.type(options.beforeAnimate) === 'function' && options.beforeAnimate.call($word); + + /* + Call the animation per element + This way each method can define it's manipulation per element + */ + options.animate.call($word, interval, duration, i, wordCount, parentCoords); + } + + setTimeout( + + function () { /* internal callback when event has finished, therefor pass object */ + $.type(options.finished) === 'function' && options.finished.call($this); + + /* normal object, expecting domElement, so give it */ + $.type(o.callback) === 'function' && o.callback.call($this[0]); + + /* dequeue the shizzle */ + $this.dequeue(); + }, o.duration); + + }); + }; + +})(jQuery); diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 3ca6a34fb39..6b46dcfe27c 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -966,6 +966,8 @@ $.extend(Datepicker.prototype, { if (value == '') return null; var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff; + shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : + new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort; var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames; var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort; diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index aa57e3233e3..05cbf2132ac 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -359,7 +359,7 @@ $.widget("ui.sortable", $.ui.mouse, { if(this.dragging) { - this._mouseUp(); + this._mouseUp({ target: null }); if(this.options.helper == "original") this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); @@ -377,21 +377,23 @@ $.widget("ui.sortable", $.ui.mouse, { } - //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! - if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]); - if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove(); - - $.extend(this, { - helper: null, - dragging: false, - reverting: false, - _noFinalSort: null - }); + if (this.placeholder) { + //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! + if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]); + if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove(); - if(this.domPosition.prev) { - $(this.domPosition.prev).after(this.currentItem); - } else { - $(this.domPosition.parent).prepend(this.currentItem); + $.extend(this, { + helper: null, + dragging: false, + reverting: false, + _noFinalSort: null + }); + + if(this.domPosition.prev) { + $(this.domPosition.prev).after(this.currentItem); + } else { + $(this.domPosition.parent).prepend(this.currentItem); + } } return this; diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index f444e3126e4..8445db74e5c 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -305,20 +305,14 @@ $.widget('ui.spinner', { _parse: function(val) { var input = val; if (typeof val == 'string') { - // special case for currency formatting until Globalization handles currencies - if (this.options.numberformat == "C" && window.Globalization) { - // parseFloat should accept number format, including currency - var culture = Globalization.culture || Globalization.cultures['default']; - val = val.replace(culture.numberFormat.currency.symbol, ""); - } - val = window.Globalization && this.options.numberformat ? Globalization.parseFloat(val) : +val; + val = $.global && this.options.numberformat ? $.global.parseFloat(val) : +val; } return isNaN(val) ? null : val; }, _format: function(num) { var num = this.options.value; - this.element.val( window.Globalization && this.options.numberformat ? Globalization.format(num, this.options.numberformat) : num ); + this.element.val( $.global && this.options.numberformat ? $.global.format(num, this.options.numberformat) : num ); }, destroy: function() {
+ Click each block of text to play its animation +
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi nibh. Maecenas metus nisi, tempus sed.
+ General Options +
Build/Disintegrate options: