]> source.dussan.org Git - jquery-ui.git/commitdiff
Datepicker: Update tests and demos for new structure
authorTJ VanToll <tj.vantoll@gmail.com>
Fri, 30 Aug 2013 12:27:19 +0000 (08:27 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 29 Jan 2015 22:47:46 +0000 (17:47 -0500)
22 files changed:
Gruntfile.js
demos/datepicker/alt-field.html
demos/datepicker/animation.html
demos/datepicker/buttonbar.html
demos/datepicker/date-formats.html
demos/datepicker/date-range.html
demos/datepicker/datepicker-ar.js [deleted file]
demos/datepicker/datepicker-fr.js [deleted file]
demos/datepicker/datepicker-he.js [deleted file]
demos/datepicker/datepicker-zh-TW.js [deleted file]
demos/datepicker/dropdown-month-year.html
demos/datepicker/icon-trigger.html
demos/datepicker/inline.html
demos/datepicker/localization.html
demos/datepicker/min-max.html
demos/datepicker/multiple-calendars.html
demos/datepicker/other-months.html
demos/datepicker/show-week.html
tests/unit/date/date_core.js
tests/unit/datepicker/datepicker.html
tests/unit/datepicker/datepicker_core.js
ui/datepicker.js

index 277169a72175fec92eb8d06c9e41e76527895530..3dba46987f81435bc7030d5631c6c790c26fde6c 100644 (file)
@@ -174,7 +174,7 @@ grunt.initConfig({
        },
        qunit: {
                files: expandFiles( "tests/unit/" + component + "/*.html" ).filter(function( file ) {
-                       return !( /(all|index|test)\.html$/ ).test( file );
+                       return !( /(all|index|test|datepicker)\.html$/ ).test( file );
                }),
                options: {
                        page: {
index 7e3b50a6de9c887e3b3e13c1326cc6e84549d52e..4fd64bf6f1955f890a0c4aae5f68f83d654d6e2e 100644 (file)
@@ -5,15 +5,22 @@
        <title>jQuery UI Datepicker - Populate alternate field</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
        $(function() {
                $( "#datepicker" ).datepicker({
-                       altField: "#alternate",
-                       altFormat: "DD, d MM, yy"
+                       select: function( event, ui ) {
+                               var date = Globalize.parseDate( ui.date );
+                               $( "#alternate" ).val( Globalize.format( date, "dddd, d MMMM, yyyy" ) );
+                       }
                });
        });
        </script>
index 990fd6262e3e71df54518b79993de43c44d19ed2..5fda2046f521b69a457cea8a5f44bcefa5df13ad 100644 (file)
@@ -5,6 +5,9 @@
        <title>jQuery UI Datepicker - Animations</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
        <script src="../../ui/effect.js"></script>
        <script src="../../ui/effect-drop.js"></script>
        <script src="../../ui/effect-fold.js"></script>
        <script src="../../ui/effect-slide.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
        $(function() {
                $( "#datepicker" ).datepicker();
                $( "#anim" ).change(function() {
-                       $( "#datepicker" ).datepicker( "option", "showAnim", $( this ).val() );
+                       var value = $( this ).val(),
+                               hideValue = $( this ).find( "option:selected" ).data( "hide" );
+                       $( "#datepicker" )
+                               .datepicker( "option", "show", value )
+                               .datepicker( "option", "hide", hideValue || value );
                });
        });
        </script>
 
 <p>Animations:<br />
        <select id="anim">
-               <option value="show">Show (default)</option>
-               <option value="slideDown">Slide down</option>
-               <option value="fadeIn">Fade in</option>
+               <option value="show">Fade in/out (default)</option>
+               <option value="slideDown" data-hide="slideUp">Slide down/up</option>
                <option value="blind">Blind (UI Effect)</option>
                <option value="bounce">Bounce (UI Effect)</option>
                <option value="clip">Clip (UI Effect)</option>
                <option value="drop">Drop (UI Effect)</option>
                <option value="fold">Fold (UI Effect)</option>
                <option value="slide">Slide (UI Effect)</option>
-               <option value="">None</option>
+               <option value="false">None</option>
        </select>
 </p>
 
index 040ec1112ecdd458f55d1c82c24be3e941606302..446bc9fe4952fde98bdd15c23d43ac535aaf5ced 100644 (file)
@@ -5,8 +5,13 @@
        <title>jQuery UI Datepicker - Display button bar</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
index 39be9aa1522991a6991b2458cf3be2cb874596c4..1b8874f8cf66691444578857082914515ad6f42c 100644 (file)
@@ -5,8 +5,13 @@
        <title>jQuery UI Datepicker - Format date</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
 
 <p>Format options:<br />
        <select id="format">
-               <option value="mm/dd/yy">Default - mm/dd/yy</option>
-               <option value="yy-mm-dd">ISO 8601 - yy-mm-dd</option>
-               <option value="d M, y">Short - d M, y</option>
-               <option value="d MM, y">Medium - d MM, y</option>
-               <option value="DD, d MM, yy">Full - DD, d MM, yy</option>
-               <option value="'day' d 'of' MM 'in the year' yy">With text - 'day' d 'of' MM 'in the year' yy</option>
+               <option value="d">Default - M/d/yyyy</option>
+               <option value="D">Long - dddd, MMMM dd, yyyy</option>
+               <option value="yyyy-MM-dd">ISO 8601 - yyyy-MM-dd</option>
        </select>
 </p>
 
index 34c64a9b2e026ee40f5e7d4790432fcca2f0b1ba..506c0483ec793c4df2771051e4b589e71ade1b02 100644 (file)
@@ -5,8 +5,13 @@
        <title>jQuery UI Datepicker - Select a Date Range</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
diff --git a/demos/datepicker/datepicker-ar.js b/demos/datepicker/datepicker-ar.js
deleted file mode 100644 (file)
index fc6d2a8..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Arabic Translation for jQuery UI date picker plugin. */
-/* Khaled Alhourani -- me@khaledalhourani.com */
-/* NOTE: monthNames are the original months names and they are the Arabic names, not the new months name فبراير - يناير and there isn't any Arabic roots for these months */
-(function( factory ) {
-       if ( typeof define === "function" && define.amd ) {
-
-               // AMD. Register as an anonymous module.
-               define([ "../jquery.ui.datepicker" ], factory );
-       } else {
-
-               // Browser globals
-               factory( jQuery.datepicker );
-       }
-}(function( datepicker ) {
-       datepicker.regional['ar'] = {
-               closeText: 'إغلاق',
-               prevText: '&#x3C;السابق',
-               nextText: 'التالي&#x3E;',
-               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']);
-
-       return datepicker.regional['ar'];
-
-}));
diff --git a/demos/datepicker/datepicker-fr.js b/demos/datepicker/datepicker-fr.js
deleted file mode 100644 (file)
index 33fa80d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* French initialisation for the jQuery UI date picker plugin. */
-/* Written by Keith Wood (kbwood{at}iinet.com.au),
-                         Stéphane Nahmani (sholby@sholby.net),
-                         Stéphane Raimbault <stephane.raimbault@gmail.com> */
-(function( factory ) {
-       if ( typeof define === "function" && define.amd ) {
-
-               // AMD. Register as an anonymous module.
-               define([ "../jquery.ui.datepicker" ], factory );
-       } else {
-
-               // Browser globals
-               factory( jQuery.datepicker );
-       }
-}(function( datepicker ) {
-       datepicker.regional['fr'] = {
-               closeText: 'Fermer',
-               prevText: 'Précédent',
-               nextText: 'Suivant',
-               currentText: 'Aujourd\'hui',
-               monthNames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin',
-                       'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
-               monthNamesShort: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin',
-                       'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'],
-               dayNames: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
-               dayNamesShort: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'],
-               dayNamesMin: ['D','L','M','M','J','V','S'],
-               weekHeader: 'Sem.',
-               dateFormat: 'dd/mm/yy',
-               firstDay: 1,
-               isRTL: false,
-               showMonthAfterYear: false,
-               yearSuffix: ''};
-       datepicker.setDefaults(datepicker.regional['fr']);
-
-       return datepicker.regional['fr'];
-
-}));
diff --git a/demos/datepicker/datepicker-he.js b/demos/datepicker/datepicker-he.js
deleted file mode 100644 (file)
index bf58038..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Hebrew initialisation for the UI Datepicker extension. */
-/* Written by Amir Hardon (ahardon at gmail dot com). */
-(function( factory ) {
-       if ( typeof define === "function" && define.amd ) {
-
-               // AMD. Register as an anonymous module.
-               define([ "../jquery.ui.datepicker" ], factory );
-       } else {
-
-               // Browser globals
-               factory( jQuery.datepicker );
-       }
-}(function( datepicker ) {
-       datepicker.regional['he'] = {
-               closeText: 'סגור',
-               prevText: '&#x3C;הקודם',
-               nextText: 'הבא&#x3E;',
-               currentText: 'היום',
-               monthNames: ['ינואר','פברואר','מרץ','אפריל','מאי','יוני',
-               'יולי','אוגוסט','ספטמבר','אוקטובר','נובמבר','דצמבר'],
-               monthNamesShort: ['ינו','פבר','מרץ','אפר','מאי','יוני',
-               'יולי','אוג','ספט','אוק','נוב','דצמ'],
-               dayNames: ['ראשון','שני','שלישי','רביעי','חמישי','שישי','שבת'],
-               dayNamesShort: ['א\'','ב\'','ג\'','ד\'','ה\'','ו\'','שבת'],
-               dayNamesMin: ['א\'','ב\'','ג\'','ד\'','ה\'','ו\'','שבת'],
-               weekHeader: 'Wk',
-               dateFormat: 'dd/mm/yy',
-               firstDay: 0,
-               isRTL: true,
-               showMonthAfterYear: false,
-               yearSuffix: ''};
-       datepicker.setDefaults(datepicker.regional['he']);
-
-       return datepicker.regional['he'];
-
-}));
diff --git a/demos/datepicker/datepicker-zh-TW.js b/demos/datepicker/datepicker-zh-TW.js
deleted file mode 100644 (file)
index ebfd73a..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Chinese initialisation for the jQuery UI date picker plugin. */
-/* Written by Ressol (ressol@gmail.com). */
-(function( factory ) {
-       if ( typeof define === "function" && define.amd ) {
-
-               // AMD. Register as an anonymous module.
-               define([ "../jquery.ui.datepicker" ], factory );
-       } else {
-
-               // Browser globals
-               factory( jQuery.datepicker );
-       }
-}(function( datepicker ) {
-       datepicker.regional['zh-TW'] = {
-               closeText: '關閉',
-               prevText: '&#x3C;上月',
-               nextText: '下月&#x3E;',
-               currentText: '今天',
-               monthNames: ['一月','二月','三月','四月','五月','六月',
-               '七月','八月','九月','十月','十一月','十二月'],
-               monthNamesShort: ['一月','二月','三月','四月','五月','六月',
-               '七月','八月','九月','十月','十一月','十二月'],
-               dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
-               dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
-               dayNamesMin: ['日','一','二','三','四','五','六'],
-               weekHeader: '周',
-               dateFormat: 'yy/mm/dd',
-               firstDay: 1,
-               isRTL: false,
-               showMonthAfterYear: true,
-               yearSuffix: '年'};
-       datepicker.setDefaults(datepicker.regional['zh-TW']);
-
-       return datepicker.regional['zh-TW'];
-
-}));
index 8668018d96e96cd3db3365a213572ff63aa1f2a4..c6102917f43df12683a14759dd460fefa337a585 100644 (file)
@@ -5,8 +5,13 @@
        <title>jQuery UI Datepicker - Display month &amp; year menus</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
index 8268f947b3ce691c190b5c1c69ae274be5656abc..e880df27e7fd1ac915ddef5398e605d72a2cbe04 100644 (file)
@@ -5,18 +5,32 @@
        <title>jQuery UI Datepicker - Icon trigger</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
        $(function() {
-               $( "#datepicker" ).datepicker({
-                       showOn: "button",
-                       buttonImage: "images/calendar.gif",
-                       buttonImageOnly: true,
-                       buttonText: "Select date"
+               var allowOpen = false;
+               var datepicker = $( "#datepicker" ).datepicker({
+                       beforeOpen: function() {
+                               return allowOpen;
+                       }
                });
+               $( "<img src='images/calendar.gif' alt='Open Datepicker'>")
+                       .insertAfter( datepicker )
+                       .click(function() {
+                               allowOpen = true;
+                               datepicker.focus();
+                               setTimeout(function() {
+                                       allowOpen = false;
+                               });
+                       });
        });
        </script>
 </head>
index 5d120457b7740b56883aaf57f7fc785447f8b0e3..5d48291902054a6c094eea4b4b4d479fb88bd66a 100644 (file)
@@ -5,8 +5,13 @@
        <title>jQuery UI Datepicker - Display inline</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
index 2761dd31baf6e11eb07a2538cc47525254f705a1..b8c99547b7b9e595984a13191605bfabbea1dce6 100644 (file)
@@ -5,20 +5,24 @@
        <title>jQuery UI Datepicker - Localize calendar</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/globalize/globalize.culture.de-DE.js"></script>
+       <script src="../../external/globalize/globalize.culture.ja-JP.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
-       <script src="datepicker-ar.js"></script>
-       <script src="datepicker-fr.js"></script>
-       <script src="datepicker-he.js"></script>
-       <script src="datepicker-zh-TW.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
        $(function() {
-               $( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] );
+               Globalize.culture( "de-DE" );
+               $( "#datepicker" ).datepicker();
                $( "#locale" ).change(function() {
-                       $( "#datepicker" ).datepicker( "option",
-                               $.datepicker.regional[ $( this ).val() ] );
+                       // TODO refresh the current value to convert to the selected culture
+                       Globalize.culture( $(this).val() );
                });
        });
        </script>
 
 <p>Date: <input type="text" id="datepicker"/>&nbsp;
        <select id="locale">
-               <option value="ar">Arabic (&#8235;(&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;</option>
-               <option value="zh-TW">Chinese Traditional (&#32321;&#39636;&#20013;&#25991;)</option>
-               <option value="">English</option>
-               <option value="fr" selected="selected">French (Fran&ccedil;ais)</option>
-               <option value="he">Hebrew (&#8235;(&#1506;&#1489;&#1512;&#1497;&#1514;</option>
+               <option value="de-DE" selected>German (Deutsch)</option>
+               <option value="ja-JP">Japanese (日本語</option>
+               <option value="en">English</option>
        </select></p>
 
 <div class="demo-description">
index 4052c17852b0316d45041a779c376ba289e0f6a1..6dcc16a48bcd1651dcbd451feaaf06683fd2e341 100644 (file)
@@ -5,8 +5,13 @@
        <title>jQuery UI Datepicker - Restrict date range</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
index 716b6c68ef6ebf359f4a95a944116bc5fe66793a..3d8278cd62554285c0cccde0887f55301a9bf32b 100644 (file)
@@ -5,8 +5,13 @@
        <title>jQuery UI Datepicker - Display multiple months</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
index 71a06c5d2b9b29c8566e9ed075d31727df88812e..bad2b1977fab6e1b6aff976dcceedc48939ca36a 100644 (file)
@@ -5,8 +5,13 @@
        <title>jQuery UI Datepicker - Dates in other months</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
index 362645a7ede502d298e55e27ec92e1f0a77c2de6..e9a33d8da1666735265b49109cad323d09e9f268 100644 (file)
@@ -5,8 +5,13 @@
        <title>jQuery UI Datepicker - Show week of the year</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
        <script src="../../external/jquery/jquery.js"></script>
+       <script src="../../external/globalize/globalize.js"></script>
+       <script src="../../external/date.js"></script>
+       <script src="../../external/localization.js"></script>
        <script src="../../ui/core.js"></script>
        <script src="../../ui/widget.js"></script>
+       <script src="../../ui/button.js"></script>
+       <script src="../../ui/position.js"></script>
        <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <script>
index f8f34abfc78abac87d5f45cb3e197017e5c5d9fe..b75ef8087eb10067ad2de9a4de1aabad05a9779e 100644 (file)
+module("date: core");
 
-
-var PROP_NAME = 'date';
-
-
-module('date: core');
-
-test('Check Date Setup', 2, function(){
-       ok(true,'First Test Always Passes');
-       ok($.date(), 'Load JQuery Date');
+test("Check Date Setup", 2, function(){
+       ok(true,"First Test Always Passes");
+       ok($.date(), "Load JQuery Date");
 });
-test('Check Sets and Gets', 6, function(){
+test("Check Sets and Gets", 6, function(){
        var date = $.date();
-       equal(date.setYear(2012).year(), 2012, 'Set year and retrieve');
-       equal(date.setMonth(9).month(), 9, 'Set month and retrieve');
-       equal(date.setDay(15).day(), 15, 'Set day and retrieve');
-       equal(date.setFullDate(2012,9,15).year(), 2012, 'Set full date and retrieve year');
-       equal(date.month(), 9, 'Set full date and retrieve month');
-       equal(date.day(), 15, 'Set full date and retrieve day');
-});
-test('Date Adjustments - Normal Use Cases', 10, function(){
+       equal(date.setYear(2012).year(), 2012, "Set year and retrieve");
+       equal(date.setMonth(9).month(), 9, "Set month and retrieve");
+       equal(date.setDay(15).day(), 15, "Set day and retrieve");
+       equal(date.setFullDate(2012,9,15).year(), 2012, "Set full date and retrieve year");
+       equal(date.month(), 9, "Set full date and retrieve month");
+       equal(date.day(), 15, "Set full date and retrieve day");
+});
+test("Date Adjustments - Normal Use Cases", 10, function(){
        var date = $.date();
        //Use October 15, 2012
        date.setFullDate(2012,9,15);
-       equal(date.adjust('D',1).day(),16,'Add 1 day');
-       equal(date.adjust('D',-1).day(),15,'Subtract 1 day');
-       equal(date.adjust('M',1).month(),10,'Add 1 month');
-       equal(date.adjust('M',-1).month(),9,'Subtract 1 month');
-       equal(date.adjust('Y',1).year(),2013,'Add 1 year');
-       equal(date.adjust('Y',-1).year(),2012,'Subtract 1 year');
+       equal(date.adjust("D",1).day(),16,"Add 1 day");
+       equal(date.adjust("D",-1).day(),15,"Subtract 1 day");
+       equal(date.adjust("M",1).month(),10,"Add 1 month");
+       equal(date.adjust("M",-1).month(),9,"Subtract 1 month");
+       equal(date.adjust("Y",1).year(),2013,"Add 1 year");
+       equal(date.adjust("Y",-1).year(),2012,"Subtract 1 year");
        //Check changing one value impact another.  Ex: Day impacts month
        //Use April 30th 2012
        date.setFullDate(2012,3,30);
-       equal(date.adjust('D',1).month(),4,'Add 1 day to change month from April to May');
-       equal(date.adjust('D',-1).month(),3,'Subtract 1 day to change month from May to April');
+       equal(date.adjust("D",1).month(),4,"Add 1 day to change month from April to May");
+       equal(date.adjust("D",-1).month(),3,"Subtract 1 day to change month from May to April");
        //Use December 31st 2012
        date.setFullDate(2012,11,31);
-       equal(date.adjust('D',1).year(),2013,'Add 1 day to change year from 2012 to 2013');
-       equal(date.adjust('D',-1).year(),2012,'Subtract 1 day to change month from 2013 to 2012');
+       equal(date.adjust("D",1).year(),2013,"Add 1 day to change year from 2012 to 2013");
+       equal(date.adjust("D",-1).year(),2012,"Subtract 1 day to change month from 2013 to 2012");
 
 });
 
-test('Date Adjustments - Month Overflow Edge Cases', 2, function(){
+test("Date Adjustments - Month Overflow Edge Cases", 2, function(){
        var date = $.date();
        //Use May 31 2012
        date.setFullDate(2012,4,31);
-       equal(date.adjust('M',1).day(),30,'Add 1 month from May to June sets days to 30, last day in June (prevent Overflow)');
-       equal(date.adjust('M',-1).day(),30,'Subtract 1 month from June to May sets days to 30 in May');
+       equal(date.adjust("M",1).day(),30,"Add 1 month from May to June sets days to 30, last day in June (prevent Overflow)");
+       equal(date.adjust("M",-1).day(),30,"Subtract 1 month from June to May sets days to 30 in May");
 });
 
-test('Date Adjustments - Leap Year Edge Cases', 1, function(){
+test("Date Adjustments - Leap Year Edge Cases", 1, function(){
        var date = $.date();
        //Use February 29 2012 a Leap year
        date.setFullDate(2012,1,29);
-       equal(date.adjust('Y',1).day(),28,'Feb 29 2012, add a year to convert to Feb 28, 2013');
+       equal(date.adjust("Y",1).day(),28,"Feb 29 2012, add a year to convert to Feb 28, 2013");
 });
 
-test('List days of Week', 2, function(){
-       var date = $.date();
-       var offset0 = [
-               { 'fullname': 'Sunday', 'shortname': 'Su' },
-               { 'fullname': 'Monday', 'shortname': 'Mo' },
-               { 'fullname': 'Tuesday', 'shortname': 'Tu' },
-               { 'fullname': 'Wednesday', 'shortname': 'We' },
-               { 'fullname': 'Thursday', 'shortname': 'Th' },
-               { 'fullname': 'Friday', 'shortname': 'Fr' },
-               { 'fullname': 'Saturday', 'shortname': 'Sa' } ];
-       var offset1 = [
-               { 'fullname': 'Montag', 'shortname': 'Mo' },
-               { 'fullname': 'Dienstag', 'shortname': 'Di' },
-               { 'fullname': 'Mittwoch', 'shortname': 'Mi' },
-               { 'fullname': 'Donnerstag', 'shortname': 'Do' },
-               { 'fullname': 'Freitag', 'shortname': 'Fr' },
-               { 'fullname': 'Samstag', 'shortname': 'Sa' },
-               { 'fullname': 'Sonntag', 'shortname': 'So' } ];
-       deepEqual(date.weekdays(), offset0, 'Get weekdays with start of day on 0 (English)');
-       Globalize.culture( 'de-DE' );
+test("List days of Week", 2, function(){
+       var date = $.date(),
+               offset0 = [
+                       { "fullname": "Sunday", "shortname": "Su" },
+                       { "fullname": "Monday", "shortname": "Mo" },
+                       { "fullname": "Tuesday", "shortname": "Tu" },
+                       { "fullname": "Wednesday", "shortname": "We" },
+                       { "fullname": "Thursday", "shortname": "Th" },
+                       { "fullname": "Friday", "shortname": "Fr" },
+                       { "fullname": "Saturday", "shortname": "Sa" }
+               ],
+               offset1 = [
+                       { "fullname": "Montag", "shortname": "Mo" },
+                       { "fullname": "Dienstag", "shortname": "Di" },
+                       { "fullname": "Mittwoch", "shortname": "Mi" },
+                       { "fullname": "Donnerstag", "shortname": "Do" },
+                       { "fullname": "Freitag", "shortname": "Fr" },
+                       { "fullname": "Samstag", "shortname": "Sa" },
+                       { "fullname": "Sonntag", "shortname": "So" }
+               ];
+       deepEqual(date.weekdays(), offset0, "Get weekdays with start of day on 0 (English)");
+       Globalize.culture( "de-DE" );
        date.refresh();
-       deepEqual(date.weekdays(), offset1, 'Get weekdays with start of day on 1 (Germany)');
+       deepEqual(date.weekdays(), offset1, "Get weekdays with start of day on 1 (Germany)");
        //Revert Globalize changes back to English
-       Globalize.culture('en-EN');
+       Globalize.culture("en-EN");
 });
 
-test('Leap Year Check', 8, function(){
+test("Leap Year Check", 8, function(){
        var date = $.date();
-       ok(date.setYear( 2008 ).isLeapYear(), '2008 is a Leap Year');
-       ok(!date.setYear( 2009 ).isLeapYear(), '2009 is not a Leap Year');
-       ok(!date.setYear( 2010 ).isLeapYear(), '2010 is not a Leap Year');
-       ok(!date.setYear( 2011 ).isLeapYear(), '2011 is not a Leap Year');
-       ok(date.isLeapYear( 2012 ), '2012 is a Leap Year');
-       ok(!date.isLeapYear( 2013 ), '2013 is not a Leap Year');
-       ok(!date.isLeapYear( 2014 ), '2014 is not a Leap year');
-       ok(!date.isLeapYear( 2015 ), '2015 is not a Leap year');
+       ok(date.setYear( 2008 ).isLeapYear(), "2008 is a Leap Year");
+       ok(!date.setYear( 2009 ).isLeapYear(), "2009 is not a Leap Year");
+       ok(!date.setYear( 2010 ).isLeapYear(), "2010 is not a Leap Year");
+       ok(!date.setYear( 2011 ).isLeapYear(), "2011 is not a Leap Year");
+       ok(date.isLeapYear( 2012 ), "2012 is a Leap Year");
+       ok(!date.isLeapYear( 2013 ), "2013 is not a Leap Year");
+       ok(!date.isLeapYear( 2014 ), "2014 is not a Leap year");
+       ok(!date.isLeapYear( 2015 ), "2015 is not a Leap year");
 });
 
-test('Days in Month', 3, function(){
+test("Days in Month", 3, function(){
        var date = $.date();
        date.setFullDate( 2012, 1, 1 );
-       equal(date.daysInMonth(), 29, 'Leap Year implicit check for 29 days');
-       equal(date.daysInMonth( 2012, 1 ), 29, 'Leap Year explicit check for 29 days');
-       equal(date.daysInMonth( 2011, 3 ), 30, 'April has 30 days');
+       equal(date.daysInMonth(), 29, "Leap Year implicit check for 29 days");
+       equal(date.daysInMonth( 2012, 1 ), 29, "Leap Year explicit check for 29 days");
+       equal(date.daysInMonth( 2011, 3 ), 30, "April has 30 days");
 });
 
-test('Month Name', 2, function(){
+test("Month Name", 2, function(){
        var date = $.date();
-       equal(date.setMonth(3).monthName(), 'April', 'Month name return April (English)');
-       Globalize.culture( 'de-DE' );
+       equal(date.setMonth(3).monthName(), "April", "Month name return April (English)");
+       Globalize.culture( "de-DE" );
        date.refresh();
-       equal(date.setMonth(2).monthName(), 'März', 'Month name return March (German)');
-       Globalize.culture('en-EN');
+       equal(date.setMonth(2).monthName(), "März", "Month name return March (German)");
+       Globalize.culture("en-EN");
 
 });
 
-test('Clone', 2, function(){
-       var date = $.date();
-       var date2 = date.clone();
-       ok(date2, 'Created cloned object');
-       notEqual(date.adjust('Y',1).year(), date2.year(), 'Object manipulated independently');
+test("Clone", 2, function(){
+       var date = $.date(),
+               date2 = date.clone();
+       ok(date2, "Created cloned object");
+       notEqual(date.adjust("Y",1).year(), date2.year(), "Object manipulated independently");
 });
 
-test('Days', 1, function(){
+test("Days", 1, function(){
        //TODO needs work
        var date = $.date();
        date.eachDay = function( day ) {
@@ -133,7 +130,7 @@ test('Days', 1, function(){
                        day.render = true;
                        day.extraClasses = "ui-state-disabled";
                }
-               if ( day.date == 1 ) {
+               if ( day.date === 1 ) {
                        day.extraClasses = "ui-state-error";
                        day.title = "Something bad explaining the error highlight";
                }
@@ -141,7 +138,7 @@ test('Days', 1, function(){
                        day.title = "A good day!";
                }
        };
-       ok(date.days(), 'Date days() returns');
+       ok(date.days(), "Date days() returns");
 });
 
 test( "Months", 5, function(){
@@ -154,70 +151,72 @@ test( "Months", 5, function(){
        ok( lastMonth.last );
        ok( !lastMonth.first );
 
-       ok( firstMonth.month() == ( lastMonth.month() - 1 ) );
+       ok( firstMonth.month() === lastMonth.month() - 1 );
 });
 
-test('iso8601Week', 2, function(){
+test("iso8601Week", 2, function(){
        var date = $.date();
        //date.setFullDate(2012, 0, 8);
-       equal(date.iso8601Week(new Date(2012, 0, 8)), 1, 'Test first week is 1');
-       equal(date.iso8601Week(new Date(2012, 11, 31)), 1, 'Test last week is 1 in next year');
+       equal(date.iso8601Week(new Date(2012, 0, 8)), 1, "Test first week is 1");
+       equal(date.iso8601Week(new Date(2012, 11, 31)), 1, "Test last week is 1 in next year");
 });
 
-test('Equal', 4, function(){
+test("Equal", 4, function(){
        var date = $.date();
        date.setFullDate(2012, 9, 16);
-       ok(date.equal(new Date(2012, 9, 16)), 'Does date equal provide date');
-       ok(!date.equal(new Date(2011, 9, 16)), 'Does date year not equal provide date');
-       ok(!date.equal(new Date(2012, 8, 16)), 'Does date month not equal provide date');
-       ok(!date.equal(new Date(2012, 9, 15)), 'Does date day not equal provide date');
+       ok(date.equal(new Date(2012, 9, 16)), "Does date equal provide date");
+       ok(!date.equal(new Date(2011, 9, 16)), "Does date year not equal provide date");
+       ok(!date.equal(new Date(2012, 8, 16)), "Does date month not equal provide date");
+       ok(!date.equal(new Date(2012, 9, 15)), "Does date day not equal provide date");
 });
 
-test('Date', 1, function(){
+test("Date", 1, function(){
        var date = $.date();
-       ok(date.date() instanceof Date, 'Date returned');
+       ok(date.date() instanceof Date, "Date returned");
 });
 
-test('Format', 4, function(){
+test("Format", 4, function(){
        var date = $.date();
        date.setFullDate(2012, 9, 16);
-       equal(date.format(), '10/16/2012', 'Checking default US format');
-       equal(date.format('yyyy/MM/dd'), '2012/10/16', 'Checking yyyy/MM/dd format');
-       equal(date.format('yy/dd/MM'), '12/16/10', 'Checking yy/dd/MM format');
-       equal(date.format('MMMM dd, yyyy'), 'October 16, 2012', 'Checking MMMM dd, yyyy format');
+       equal(date.format(), "10/16/2012", "Checking default US format");
+       equal(date.format("yyyy/MM/dd"), "2012/10/16", "Checking yyyy/MM/dd format");
+       equal(date.format("yy/dd/MM"), "12/16/10", "Checking yy/dd/MM format");
+       equal(date.format("MMMM dd, yyyy"), "October 16, 2012", "Checking MMMM dd, yyyy format");
 });
 
-test('Calendar', 3, function(){
-       var date = $.date();
-       ok(date.calendar(), 'Calendar type returned')
-       var de_cal = {calendars: {
-               standard: {
-                       "/": ".",
-                       firstDay: 1,
-                       days: {
-                               names: ["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],
-                               namesAbbr: ["So","Mo","Di","Mi","Do","Fr","Sa"],
-                               namesShort: ["So","Mo","Di","Mi","Do","Fr","Sa"]
-                       },
-                       months: {
-                               names: ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember",""],
-                               namesAbbr: ["Jan","Feb","Mrz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez",""]
-                       },
-                       AM: null,
-                       PM: null,
-                       eras: [{"name":"n. Chr.","start":null,"offset":0}],
-                       patterns: {
-                               d: "dd.MM.yyyy",
-                               D: "dddd, d. MMMM yyyy",
-                               t: "HH:mm",
-                               T: "HH:mm:ss",
-                               f: "dddd, d. MMMM yyyy HH:mm",
-                               F: "dddd, d. MMMM yyyy HH:mm:ss",
-                               M: "dd MMMM",
-                               Y: "MMMM yyyy"
+test("Calendar", 3, function(){
+       var date = $.date(),
+               de_cal = {
+                       calendars: {
+                               standard: {
+                                       "/": ".",
+                                       firstDay: 1,
+                                       days: {
+                                               names: ["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],
+                                               namesAbbr: ["So","Mo","Di","Mi","Do","Fr","Sa"],
+                                               namesShort: ["So","Mo","Di","Mi","Do","Fr","Sa"]
+                                       },
+                                       months: {
+                                               names: ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember",""],
+                                               namesAbbr: ["Jan","Feb","Mrz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez",""]
+                                       },
+                                       AM: null,
+                                       PM: null,
+                                       eras: [{"name":"n. Chr.","start":null,"offset":0}],
+                                       patterns: {
+                                               d: "dd.MM.yyyy",
+                                               D: "dddd, d. MMMM yyyy",
+                                               t: "HH:mm",
+                                               T: "HH:mm:ss",
+                                               f: "dddd, d. MMMM yyyy HH:mm",
+                                               F: "dddd, d. MMMM yyyy HH:mm:ss",
+                                               M: "dd MMMM",
+                                               Y: "MMMM yyyy"
+                                       }
+                               }
                        }
-               }
-       }};
-       ok(date.calendar(de_cal), 'Calendar type changed');
-       deepEqual(date.calendar(), de_cal, 'Calendar change verified');
-});
\ No newline at end of file
+               };
+       ok(date.calendar(), "Calendar type returned");
+       ok(date.calendar(de_cal), "Calendar type changed");
+       deepEqual(date.calendar(), de_cal, "Calendar change verified");
+});
index 136bd2f6b9bd88d3ef141fe80e14443a14607e40..2b3feb9e3432214d6a6515642488f4f373b89265 100644 (file)
@@ -8,16 +8,23 @@
        <link rel="stylesheet" href="../../../external/qunit/qunit.css">
        <script src="../../../external/qunit/qunit.js"></script>
        <script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
+       <script src="../../../external/date.js"></script>
+       <script src="../../../external/globalize/globalize.js"></script>
+       <script src="../../../external/localization.js"></script>
        <script src="../testsuite.js"></script>
        <script>
        TestHelpers.loadResources({
                css: [ "core", "datepicker" ],
                js: [
                        "ui/core.js",
-                       "ui/datepicker.js",
+                       "ui/widget.js",
+                       "ui/button.js",
+                       "ui/position.js",
+                       "ui/datepicker.js"
+                       /* TODO: Replace with Globalize cultures
                        "ui/i18n/datepicker-fr.js",
                        "ui/i18n/datepicker-he.js",
-                       "ui/i18n/datepicker-zh-CN.js"
+                       "ui/i18n/datepicker-zh-CN.js"*/
                ]
        });
        </script>
index 65b07e2f6ca030a89cb76d345f39499bbc22dff4..7b9dd2b93920c1f7c90eede176100e312e1223a9 100644 (file)
@@ -12,16 +12,6 @@ module( "datepicker: core", {
 
 TestHelpers.testJshint( "datepicker" );
 
-test("initialization - Reinitialization after body had been emptied.", function() {
-       expect( 1 );
-       var bodyContent = $("body").children(), inp = $("#inp");
-       $("#inp").datepicker();
-       $("body").empty().append(inp);
-       $("#inp").datepicker();
-       ok( $("#"+$.datepicker._mainDivId).length===1, "Datepicker container added" );
-       $("body").empty().append(bodyContent); // Returning to initial state for later tests
-});
-
 test( "widget method - empty collection", function() {
        expect( 1 );
        $( "#nonExist" ).datepicker(); // should create nothing
index ad01adc749a371400eda5ff6798e34f65e2d7597..f1b9dc6c01cb656b4458396c70732183c187d313 100644 (file)
@@ -39,6 +39,7 @@ var idIncrement = 0,
 $.widget( "ui.datepicker", {
        options: {
                appendTo: null,
+               dateFormat: null,
                // TODO review
                eachDay: $.noop,
                numberOfMonths: 1,
@@ -51,12 +52,13 @@ $.widget( "ui.datepicker", {
                hide: true,
 
                // callbacks
+               beforeOpen: null,
                close: null,
                open: null,
                select: null
        },
        _create: function() {
-               this.date = $.date();
+               this.date = $.date( null, this.options.dateFormat );
                this.date.eachDay = this.options.eachDay;
                this.id = "ui-datepicker-" + idIncrement;
                idIncrement++;
@@ -511,8 +513,8 @@ $.widget( "ui.datepicker", {
                this.element.focus();
        },
        // Refreshing the entire datepicker during interaction confuses screen readers, specifically
-       // because the grid heading is marked up as a live region and will often not update if it's 
-       // destroyed and recreated instead of just having its text change. Additionally, interacting 
+       // because the grid heading is marked up as a live region and will often not update if it's
+       // destroyed and recreated instead of just having its text change. Additionally, interacting
        // with the prev and next links would cause loss of focus issues because the links being
        // interacted with will disappear while focused.
        refresh: function() {
@@ -529,7 +531,7 @@ $.widget( "ui.datepicker", {
                }
        },
        _refreshMultiplePicker: function() {
-               for (var i = 0; i < this.options.numberOfMonths; i++ ) {
+               for ( var i = 0; i < this.options.numberOfMonths; i++ ) {
                        $( ".ui-datepicker-title", this.picker ).eq( i ).html( this._buildTitle() );
                        $( ".ui-datepicker-calendar", this.picker ).eq( i ).html( this._buildGrid() );
                        this.date.adjust( "M", 1 );
@@ -541,9 +543,12 @@ $.widget( "ui.datepicker", {
                if ( this.inline || this.isOpen ) {
                        return;
                }
+               if ( this._trigger( "beforeOpen", event ) === false ) {
+                       return;
+               }
 
                // TODO explain this
-               this.date = $.date( this.element.val() );
+               this.date = $.date( this.element.val(), this.options.dateFormat );
                this.date.eachDay = this.options.eachDay;
                this.date.select();
                this.refresh();