]> source.dussan.org Git - jquery-ui.git/commitdiff
Merge branch 'master' into datepicker
authorScott González <scott.gonzalez@gmail.com>
Thu, 20 Aug 2015 13:48:11 +0000 (09:48 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 20 Aug 2015 13:48:11 +0000 (09:48 -0400)
30 files changed:
1  2 
Gruntfile.js
demos/bootstrap.js
demos/calendar/buttonbar.html
demos/calendar/default.html
demos/calendar/dropdown-month-year.html
demos/calendar/localization.html
demos/calendar/min-max.html
demos/calendar/multiple-months.html
demos/calendar/other-months.html
demos/calendar/show-week.html
demos/datepicker/animation.html
demos/datepicker/date-formats.html
demos/datepicker/icon-trigger.html
demos/datepicker/localization.html
demos/spinner/currency.html
demos/spinner/decimal.html
demos/spinner/time.html
tests/unit/calendar/common.js
tests/unit/calendar/core.js
tests/unit/calendar/methods.js
tests/unit/calendar/options.js
tests/unit/datepicker/common.js
tests/unit/datepicker/core.js
tests/unit/datepicker/events.js
tests/unit/datepicker/helper.js
tests/unit/datepicker/methods.js
tests/unit/datepicker/options.js
tests/unit/spinner/options.js
ui/widgets/calendar.js
ui/widgets/datepicker.js

diff --cc Gruntfile.js
index ee949a3f5001ebc9ec0383ba8bce6c4675606e7c,41961061b61bb807bc554b930ba935389535d6ea..85dfb42be366fbf2408c0bcc7dccccd0061bc95a
@@@ -150,33 -126,25 +126,30 @@@ grunt.initConfig(
                dist: "<%= pkg.name %>-<%= pkg.version %>"
        },
        compare_size: compareFiles,
-       concat: {
-               ui: {
-                       options: {
-                               banner: createBanner( uiFiles ),
-                               stripBanners: {
-                                       block: true
-                               }
-                       },
-                       src: uiFiles,
-                       dest: "dist/jquery-ui.js"
-               },
-               i18n: {
-                       options: {
-                               banner: createBanner( allI18nFiles )
-                       },
-                       src: allI18nFiles,
-                       dest: "dist/i18n/jquery-ui-i18n.js"
-               },
-               css: {
+       requirejs: {
+               js: {
                        options: {
-                               banner: createBanner( cssFiles ),
-                               stripBanners: {
-                                       block: true
+                               baseUrl: "./",
+                               paths: {
+                                       jquery: "./external/jquery/jquery",
+                                       external: "./external/"
+                               },
+                               preserveLicenseComments: false,
+                               optimize: "none",
+                               findNestedDependencies: true,
+                               skipModuleInsertion: true,
+                               exclude: [ "jquery" ],
 -                              include: expandFiles( [ "ui/**/*.js", "!ui/i18n/*" ] ),
++                              include: expandFiles( [
++                                      "ui/**/*.js",
++                                      "!ui/widgets/calendar.js",
++                                      "!ui/widgets/datepicker.js",
++                                      "!ui/i18n/*"
++                              ] ),
+                               out: "dist/jquery-ui.js",
+                               wrap: {
+                                       start: createBanner( uiFiles ),
                                }
-                       },
-                       src: cssFiles,
-                       dest: "dist/jquery-ui.css"
+                       }
                }
        },
  
index 0000000000000000000000000000000000000000,1b28a4dc6595951b89a17bc1febdf0f2d6dbf04e..2f2b3209aa2ed3a9b08b17582c3d059343becdfd
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,102 +1,107 @@@
 -              "external/globalize/globalize.culture.de-DE": [ "external/globalize/globalize" ],
 -              "external/globalize/globalize.culture.ja-JP": [ "external/globalize/globalize" ]
+ /* globals window:true, document:true */
+ ( function() {
+ // Find the script element
+ var scripts = document.getElementsByTagName( "script" );
+ var script = scripts[ scripts.length - 1 ];
+ // Read the modules
+ var modules = script.getAttribute( "data-modules" );
+ var pathParts = window.location.pathname.split( "/" );
+ var effectsAll = [
+       "effects/effect-blind",
+       "effects/effect-bounce",
+       "effects/effect-clip",
+       "effects/effect-drop",
+       "effects/effect-explode",
+       "effects/effect-fade",
+       "effects/effect-fold",
+       "effects/effect-highlight",
+       "effects/effect-puff",
+       "effects/effect-pulsate",
+       "effects/effect-scale",
+       "effects/effect-shake",
+       "effects/effect-size",
+       "effects/effect-slide"
+ ];
+ var widgets = [
+       "accordion",
+       "autocomplete",
+       "button",
++      "calendar",
+       "datepicker",
+       "dialog",
+       "draggable",
+       "droppable",
+       "menu",
+       "mouse",
+       "progressbar",
+       "resizable",
+       "selectable",
+       "selectmenu",
+       "slider",
+       "sortable",
+       "spinner",
+       "tabs",
+       "tooltip"
+ ];
+ function getPath( module ) {
+       for ( var i = 0; i < widgets.length; i++ ) {
+               if ( widgets[ i ] === module ) {
+                       return "widgets/" + module;
+               }
+       }
+       for ( var j = 0; j < effectsAll.length; j++ ) {
+               if ( module !== "effect" && effectsAll[ j ].indexOf( module ) !== -1 ) {
+                       return "effects/" + module;
+               }
+       }
+       return module;
+ }
+ function fixPaths( modules ) {
+       for ( var i = 0; i < modules.length; i++ ) {
+               modules[ i ] = getPath( modules[ i ] );
+       }
+       return modules;
+ }
+ // Hide the page while things are loading to prevent a FOUC
+ document.documentElement.className = "demo-loading";
+ require.config( {
+       baseUrl: "../../ui",
+       paths: {
++              cldr: "../external/cldrjs/cldr",
++              date: "../external/date",
++              globalize: "../external/globalize/globalize",
++              "globalize-locales": "../external/localization",
+               jquery: "../external/jquery/jquery",
+               external: "../external/"
+       },
+       shim: {
++              "external/globalize-old/globalize.culture.de-DE": [ "external/globalize-old/globalize" ],
++              "external/globalize-old/globalize.culture.ja-JP": [ "external/globalize-old/globalize" ]
+       }
+ } );
+ // Replace effects all shortcut modules with all the effects modules
+ if ( modules && modules.indexOf( "effects-all" ) !== -1 ) {
+       modules = modules.replace( /effects-all/, effectsAll.join( " " ) );
+ }
+ modules = modules ? modules.replace( /^\s+|\s+$/g, "" ).split( /\s+/ ) : [];
+ modules.push( pathParts[ pathParts.length - 2 ] );
+ modules = fixPaths( modules );
+ require( modules, function() {
+       var newScript = document.createElement( "script" );
+       document.documentElement.className = "";
+       newScript.text = "( function() { " + script.innerHTML + " } )();";
+       document.head.appendChild( newScript ).parentNode.removeChild( newScript );
+ } );
+ } )();
index 52a07a32fc60094de394a66ac1efab0f9ed59785,0000000000000000000000000000000000000000..9acd89bdd55f4a2138cd027829604246bff04b8a
mode 100644,000000..100644
--- /dev/null
@@@ -1,41 -1,0 +1,27 @@@
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
 +<!doctype html>
 +<html lang="en">
 +<head>
 +      <meta charset="utf-8">
 +      <title>jQuery UI Calendar - Display button bar</title>
 +      <link rel="stylesheet" href="../../themes/base/all.css">
-       <script>
-       $(function() {
 +      <link rel="stylesheet" href="../demos.css">
-       });
++      <script src="../../external/requirejs/require.js"></script>
++      <script src="../bootstrap.js">
 +              $( "#calendar" ).calendar({
 +                      buttons: {
 +                              Today: function() {
 +                                      $( this ).calendar( "valueAsDate", new Date() );
 +                              }
 +                      }
 +              });
 +      </script>
 +</head>
 +<body>
 +
 +<div id="calendar"></div>
 +
 +<div class="demo-description">
 +<p>Display a button for selecting Today's date with the <code>buttons</code> option.</p>
 +</div>
 +</body>
 +</html>
index c83b8f85de7b75c935c96fc5735ba01258418f25,0000000000000000000000000000000000000000..9be0f19885b3cb7885c2350eecd90b011debbe6c
mode 100644,000000..100644
--- /dev/null
@@@ -1,35 -1,0 +1,21 @@@
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
 +<!doctype html>
 +<html lang="en">
 +<head>
 +      <meta charset="utf-8">
 +      <title>jQuery UI Calendar - Default functionality</title>
 +      <link rel="stylesheet" href="../../themes/base/all.css">
-       <script>
-       $(function() {
 +      <link rel="stylesheet" href="../demos.css">
-       });
++      <script src="../../external/requirejs/require.js"></script>
++      <script src="../bootstrap.js">
 +              $( "#calendar" ).calendar();
 +      </script>
 +</head>
 +<body>
 +
 +<div id="calendar"></div>
 +
 +<div class="demo-description">
 +<p>The calendar is a widget for selecting a date using a visual calendar representation.</p>
 +</div>
 +</body>
 +</html>
index fbb4b7b85128a2806a34dffa78e51ef2162eacea,0000000000000000000000000000000000000000..3aacaef4743ae16e3a6b1e0cc13eb5fef1b62077
mode 100644,000000..100644
--- /dev/null
@@@ -1,38 -1,0 +1,24 @@@
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
 +<!doctype html>
 +<html lang="en">
 +<head>
 +      <meta charset="utf-8">
 +      <title>jQuery UI Calendar - Display month &amp; year menus</title>
 +      <link rel="stylesheet" href="../../themes/base/all.css">
-       <script>
-       $(function() {
 +      <link rel="stylesheet" href="../demos.css">
-       });
++      <script src="../../external/requirejs/require.js"></script>
++      <script src="../bootstrap.js">
 +              $( "#calendar" ).calendar({
 +                      changeMonth: true,
 +                      changeYear: true
 +              });
 +      </script>
 +</head>
 +<body>
 +
 +<div id="calendar"></div>
 +
 +<div class="demo-description">
 +<p>Show month and year dropdowns in place of the static month/year header to facilitate navigation through large timeframes.  Add the boolean <code>changeMonth</code> and <code>changeYear</code> options.</p>
 +</div>
 +</body>
 +</html>
index 1307052ef5b06a15270218cc88e7bb800d75bb89,0000000000000000000000000000000000000000..df50ca2c9bda091adab1af398bfb37123f6d4e2d
mode 100644,000000..100644
--- /dev/null
@@@ -1,54 -1,0 +1,41 @@@
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
 +<!doctype html>
 +<html lang="en">
 +<head>
 +      <meta charset="utf-8">
 +      <title>jQuery UI Calendar - Localize calendar</title>
 +      <link rel="stylesheet" href="../../themes/base/all.css">
-       <script>
-       $(function() {
++      <link rel="stylesheet" href="../../themes/base/all.css">
 +      <link rel="stylesheet" href="../demos.css">
-       });
++      <script src="../../external/requirejs/require.js"></script>
++      <script src="../bootstrap.js" data-modules="external/localization">
 +              var calendar = $( "#calendar" ),
 +                      select = $( "#locale" );
 +
 +              calendar.calendar({
 +                      locale: select.val()
 +              });
 +
 +              select.change( function() {
 +                      calendar.calendar( "option", {
 +                              locale: select.val()
 +                      });
 +                      calendar.calendar( "valueAsDate", calendar.calendar( "valueAsDate" ) );
 +              });
 +      </script>
 +</head>
 +<body>
 +
 +<div id="calendar"></div>
 +<select id="locale">
 +      <option value="ar">Arabic</option>
 +      <option value="de" selected>German</option>
 +      <option value="en">English</option>
 +      <option value="es">Spanish</option>
 +      <option value="zh">Chinese Simplified</option>
 +</select>
 +
 +<div class="demo-description">
 +<p>Localize the calendar language and format (English / Western formatting is the default). The calendar includes built-in support for languages that read right-to-left, such as Arabic and Hebrew.</p>
 +</div>
 +</body>
 +</html>
index f8af39bd2b89b75782891503f7f915d2765e6c98,0000000000000000000000000000000000000000..36535b8752532e645efc520e519ddd8fbfd94470
mode 100644,000000..100644
--- /dev/null
@@@ -1,42 -1,0 +1,28 @@@
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
 +<!doctype html>
 +<html lang="en">
 +<head>
 +      <meta charset="utf-8">
 +      <title>jQuery UI Calendar - Restrict date range</title>
 +      <link rel="stylesheet" href="../../themes/base/all.css">
-       <script>
-       $(function() {
 +      <link rel="stylesheet" href="../demos.css">
-       });
++      <script src="../../external/requirejs/require.js"></script>
++      <script src="../bootstrap.js">
 +              var now = new Date(),
 +                      dateMin = new Date( now.getFullYear(), now.getMonth(), now.getDay() + 1 ),
 +                      dateMax = new Date( now.getFullYear(), now.getMonth(), now.getDay() + 8 );
 +
 +              $( "#calendar" ).calendar({
 +                      min: dateMin,
 +                      max: dateMax
 +              });
 +      </script>
 +</head>
 +<body>
 +
 +<div id="calendar"></div>
 +
 +<div class="demo-description">
 +<p>Restrict the range of selectable dates with the <code>min</code> and <code>max</code> options. Set the beginning and end dates as actual dates (<code>new Date(2009, 1 - 1, 26)</code>).</p>
 +</div>
 +</body>
 +</html>
index 22118abaad693cf6607e0c68ecdfbd1f37b06181,0000000000000000000000000000000000000000..3bde416c0bc8bf9eb590b65e0ccb5c613e686aae
mode 100644,000000..100644
--- /dev/null
@@@ -1,37 -1,0 +1,23 @@@
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
 +<!doctype html>
 +<html lang="en">
 +<head>
 +      <meta charset="utf-8">
 +      <title>jQuery UI Calendar - Display multiple months</title>
 +      <link rel="stylesheet" href="../../themes/base/all.css">
-       <script>
-       $(function() {
 +      <link rel="stylesheet" href="../demos.css">
-       });
++      <script src="../../external/requirejs/require.js"></script>
++      <script src="../bootstrap.js">
 +              $( "#calendar" ).calendar({
 +                      numberOfMonths: 3
 +              });
 +      </script>
 +</head>
 +<body>
 +
 +<div id="calendar"></div>
 +
 +<div class="demo-description">
 +<p>Set the <code>numberOfMonths</code> option to an integer of 2 or more to show multiple months in a single calendar.</p>
 +</div>
 +</body>
 +</html>
index ef43f7b82ce581ac332a5cc93159bf7cba14a712,0000000000000000000000000000000000000000..ac8df8d3a8bbb6f3d5518b8fed85918100b90ffd
mode 100644,000000..100644
--- /dev/null
@@@ -1,44 -1,0 +1,30 @@@
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
 +<!doctype html>
 +<html lang="en">
 +<head>
 +      <meta charset="utf-8">
 +      <title>jQuery UI Calendar - Dates in other months</title>
 +      <link rel="stylesheet" href="../../themes/base/all.css">
-       <script>
-       $(function() {
 +      <link rel="stylesheet" href="../demos.css">
-       });
++      <script src="../../external/requirejs/require.js"></script>
++      <script src="../bootstrap.js">
 +              $( "#calendar" ).calendar({
 +                      eachDay: function( day ) {
 +                              if ( day.lead ) {
 +                                      day.render = true;
 +                                      day.selectable = true;
 +                                      day.extraClasses = "ui-priority-secondary";
 +                              }
 +                      }
 +              });
 +      </script>
 +</head>
 +<body>
 +
 +<div id="calendar"></div>
 +
 +<div class="demo-description">
 +<p>The calendar can show dates that come from other than the main month
 +      being displayed. These other dates can also be made selectable.</p>
 +</div>
 +</body>
 +</html>
index dfa76240529d9978363cbc823f0ca6c4be9bcdef,0000000000000000000000000000000000000000..96f3c7da2510195e2aa923e20ef47e0c16c8b339
mode 100644,000000..100644
--- /dev/null
@@@ -1,39 -1,0 +1,25 @@@
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
 +<!doctype html>
 +<html lang="en">
 +<head>
 +      <meta charset="utf-8">
 +      <title>jQuery UI Calendar - Show week of the year</title>
 +      <link rel="stylesheet" href="../../themes/base/all.css">
-       <script>
-       $(function() {
 +      <link rel="stylesheet" href="../demos.css">
-       });
++      <script src="../../external/requirejs/require.js"></script>
++      <script src="../bootstrap.js">
 +              $( "#calendar" ).calendar({
 +                      showWeek: true
 +              });
 +      </script>
 +</head>
 +<body>
 +
 +<div id="calendar"></div>
 +
 +<div class="demo-description">
 +<p>The calendar can show the week of the year. The calculation follows
 +      <a href="http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table">Unicode CLDR specification</a>.
 +      This means that some days from one year may be placed into weeks 'belonging' to another year.</p>
 +</div>
 +</body>
 +</html>
index f162231ba2654408ba40acd4f61e289cc179df34,0c43b7011ba24f1fa8cafc8d568a43b63375ff50..95d18e81b60b546e0ada51227dcecc0facf6c6e1
@@@ -4,40 -4,13 +4,17 @@@
        <meta charset="utf-8">
        <title>jQuery UI Datepicker - Animations</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/effect.js"></script>
-       <script src="../../ui/effect-blind.js"></script>
-       <script src="../../ui/effect-bounce.js"></script>
-       <script src="../../ui/effect-clip.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/calendar.js"></script>
-       <script src="../../ui/position.js"></script>
-       <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
-       <script>
-       $(function() {
+       <script src="../../external/requirejs/require.js"></script>
+       <script src="../bootstrap.js" data-modules="effect effect-bounce effect-blind effect-bounce effect-clip effect-drop effect-fold effect-slide">
                $( "#datepicker" ).datepicker();
                $( "#anim" ).on( "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>
  </head>
  <body>
index 6c713a3396476d59128aa41dc98ae3879abaa5f1,a07d7e336fed3e0f91efc94c2b738bcf64797e6b..87f4b0b443aaafa2e3938e7ca286a3c025baa850
@@@ -4,37 -4,13 +4,21 @@@
        <meta charset="utf-8">
        <title>jQuery UI Datepicker - Format date</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
-       <script src="../../ui/position.js"></script>
-       <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
-       <script>
-       $(function() {
+       <script src="../../external/requirejs/require.js"></script>
+       <script src="../bootstrap.js">
 -              $( "#datepicker" ).datepicker();
 +              var value,
 +                      datepicker = $( "#datepicker" ).datepicker();
 +
                $( "#format" ).on( "change", function() {
 -                      $( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val() );
 +                      value = $( this ).val();
 +
 +                      if ( value === "iso" ) {
 +                              datepicker.datepicker( "option", "dateFormat", { pattern: "yyyy-MM-dd" } );
 +                      } else {
 +                              datepicker.datepicker( "option", "dateFormat", { date: value } );
 +                      }
                });
-       });
        </script>
  </head>
  <body>
index 2478d29d85f758530152e5a981ee6c328614a663,3ea699409c948a0ff44a636b27089e823188d7e2..2ab3c2e236e5d4a263df17e0a76138ba94f34f95
@@@ -4,41 -4,15 +4,25 @@@
        <meta charset="utf-8">
        <title>jQuery UI Datepicker - Icon trigger</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
-       <script src="../../ui/position.js"></script>
-       <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
-       <script>
-       $(function() {
-         var allowOpen = false,
-             datepicker = $( "#datepicker" ).datepicker({
-                 beforeOpen: function() {
-                     return allowOpen;
-                 },
-                 open: function() {
-                     allowOpen = false;
-                 }
-             });
+       <script src="../../external/requirejs/require.js"></script>
+       <script src="../bootstrap.js">
 -              $( "#datepicker" ).datepicker({
 -                      showOn: "button",
 -                      buttonImage: "images/calendar.gif",
 -                      buttonImageOnly: true,
 -                      buttonText: "Select date"
 -              });
++              var allowOpen = false,
++                      datepicker = $( "#datepicker" ).datepicker({
++                              beforeOpen: function() {
++                                      return allowOpen;
++                              },
++                              open: function() {
++                                      allowOpen = false;
++                              }
++                      });
 +
-         $( "<img src='images/calendar.gif' alt='Open Datepicker'>")
-             .insertAfter( datepicker )
-             .click( function() {
-                 allowOpen = true;
-                 datepicker.focus();
-             });
-       });
++              $( "<img src='images/calendar.gif' alt='Open Datepicker'>")
++                      .insertAfter( datepicker )
++                      .on( "click", function() {
++                              allowOpen = true;
++                              datepicker.focus();
++                      });
        </script>
  </head>
  <body>
index 7d73a41540ccf989d8066452a0737675671b955c,351b2c9e110b3cffa3b5ed7f8ae3d2b6db65a223..4bede0e6a1d60292fc297ea5058af08667129b03
@@@ -4,38 -4,14 +4,22 @@@
        <meta charset="utf-8">
        <title>jQuery UI Datepicker - Localize calendar</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
-       <script src="../../external/cldrjs/cldr.js"></script>
-       <script src="../../external/cldrjs/cldr/supplemental.js"></script>
-       <script src="../../external/cldrjs/cldr/event.js"></script>
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/globalize/globalize.js"></script>
-       <script src="../../external/globalize/globalize/number.js"></script>
-       <script src="../../external/globalize/globalize/date.js"></script>
-       <script src="../../external/localization.js"></script>
-       <script src="../../external/date.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/calendar.js"></script>
-       <script src="../../ui/position.js"></script>
-       <script src="../../ui/datepicker.js"></script>
        <link rel="stylesheet" href="../demos.css">
-       <script>
-       $(function() {
+       <script src="../../external/requirejs/require.js"></script>
 -      <script src="../bootstrap.js" data-modules="i18n/datepicker-ar i18n/datepicker-fr i18n/datepicker-he i18n/datepicker-zh-TW">
 -              $( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] );
 -              $( "#locale" ).on( "change", function() {
 -                      $( "#datepicker" ).datepicker( "option",
 -                              $.datepicker.regional[ $( this ).val() ] );
++      <script src="../bootstrap.js" data-modules="external/localization">
 +              var datepicker = $( "#datepicker" ),
 +                      select = $( "#locale" );
 +
 +              datepicker.datepicker({
 +                      locale: select.val()
 +              });
 +
 +              select.on( "change", function() {
 +                      datepicker.datepicker( "option", {
 +                              locale: select.val()
 +                      });
 +                      datepicker.datepicker( "valueAsDate", datepicker.datepicker( "valueAsDate" ) );
                });
-       });
        </script>
  </head>
  <body>
index 1f2ef8c24a2372daf4cfd49943d6678c2115ba51,c19a1b8167988d8329ab42cfd9818db0ae2db743..ecf193b0981e4e1f85cbf7bf7831702fc98c4aca
@@@ -4,18 -4,9 +4,14 @@@
        <meta charset="utf-8">
        <title>jQuery UI Spinner - Currency</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/jquery-mousewheel/jquery.mousewheel.js"></script>
-       <script src="../../external/globalize-old/globalize.js"></script>
-       <script src="../../external/globalize-old/globalize.culture.de-DE.js"></script>
-       <script src="../../external/globalize-old/globalize.culture.ja-JP.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/spinner.js"></script>
        <link rel="stylesheet" href="../demos.css">
-       <script>
-       $(function() {
+       <script src="../../external/requirejs/require.js"></script>
 -      <script src="../bootstrap.js" data-modules="external/globalize/globalize external/globalize/globalize.culture.de-DE external/globalize/globalize.culture.ja-JP external/jquery-mousewheel/jquery.mousewheel">
++      <script src="../bootstrap.js" data-modules="
++              external/globalize-old/globalize
++              external/globalize-old/globalize.culture.de-DE
++              external/globalize-old/globalize.culture.ja-JP
++              external/jquery-mousewheel/jquery.mousewheel
++      ">
                $( "#currency" ).on( "change", function() {
                        $( "#spinner" ).spinner( "option", "culture", $( this ).val() );
                });
index 40ce5b2238cad8b1a1848cbf384775d622e60dcb,680d7b3d37f6191dccd50663dce3edd2fd9daf84..cb7e2b8a054585761e17d4fb9c7db4ecd6bfde2a
@@@ -4,18 -4,9 +4,14 @@@
        <meta charset="utf-8">
        <title>jQuery UI Spinner - Decimal</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/jquery-mousewheel/jquery.mousewheel.js"></script>
-       <script src="../../external/globalize-old/globalize.js"></script>
-       <script src="../../external/globalize-old/globalize.culture.de-DE.js"></script>
-       <script src="../../external/globalize-old/globalize.culture.ja-JP.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/spinner.js"></script>
        <link rel="stylesheet" href="../demos.css">
-       <script>
-       $(function() {
+       <script src="../../external/requirejs/require.js"></script>
 -      <script src="../bootstrap.js" data-modules="external/globalize/globalize external/globalize/globalize.culture.de-DE external/globalize/globalize.culture.ja-JP external/jquery-mousewheel/jquery.mousewheel">
++      <script src="../bootstrap.js" data-modules="
++              external/globalize-old/globalize
++              external/globalize-old/globalize.culture.de-DE
++              external/globalize-old/globalize.culture.ja-JP
++              external/jquery-mousewheel/jquery.mousewheel
++      ">
                $( "#spinner" ).spinner({
                        step: 0.01,
                        numberFormat: "n"
index e3cf6a66d7df3d3a4144e22634dfc789c049f3d1,ff27b1b750d10bbbbcc77e3e1cb352612023af6d..5e8638b1c9ba6ba7a5044cef1d014913576268ba
@@@ -4,41 -4,33 +4,37 @@@
        <meta charset="utf-8">
        <title>jQuery UI Spinner - Time</title>
        <link rel="stylesheet" href="../../themes/base/all.css">
-       <script src="../../external/jquery/jquery.js"></script>
-       <script src="../../external/jquery-mousewheel/jquery.mousewheel.js"></script>
-       <script src="../../external/globalize-old/globalize.js"></script>
-       <script src="../../external/globalize-old/globalize.culture.de-DE.js"></script>
-       <script src="../../ui/core.js"></script>
-       <script src="../../ui/widget.js"></script>
-       <script src="../../ui/button.js"></script>
-       <script src="../../ui/spinner.js"></script>
        <link rel="stylesheet" href="../demos.css">
-       <script>
-       $.widget( "ui.timespinner", $.ui.spinner, {
-               options: {
-                       // seconds
-                       step: 60 * 1000,
-                       // hours
-                       page: 60
-               },
+       <script src="../../external/requirejs/require.js"></script>
 -      <script src="../bootstrap.js" data-modules="external/globalize/globalize external/globalize/globalize.culture.de-DE external/jquery-mousewheel/jquery.mousewheel">
++      <script src="../bootstrap.js" data-modules="
++              external/globalize-old/globalize
++              external/globalize-old/globalize.culture.de-DE
++              external/jquery-mousewheel/jquery.mousewheel
++      ">
+               $.widget( "ui.timespinner", $.ui.spinner, {
+                       options: {
+                               // seconds
+                               step: 60 * 1000,
+                               // hours
+                               page: 60
+                       },
  
-               _parse: function( value ) {
-                       if ( typeof value === "string" ) {
-                               // already a timestamp
-                               if ( Number( value ) == value ) {
-                                       return Number( value );
+                       _parse: function( value ) {
+                               if ( typeof value === "string" ) {
+                                       // already a timestamp
+                                       if ( Number( value ) == value ) {
+                                               return Number( value );
+                                       }
+                                       return +Globalize.parseDate( value );
                                }
-                               return +Globalize.parseDate( value );
-                       }
-                       return value;
-               },
+                               return value;
+                       },
  
-               _format: function( value ) {
-                       return Globalize.format( new Date(value), "t" );
-               }
-       });
+                       _format: function( value ) {
+                               return Globalize.format( new Date(value), "t" );
+                       }
+               });
  
-       $(function() {
                $( "#spinner" ).timespinner();
  
                $( "#culture" ).on( "change", function() {
index ffbb4c5a31481e31d84c370021f937c219c65c29,0000000000000000000000000000000000000000..5dae54464e02c3936fa3a1cd7733079ca7edc088
mode 100644,000000..100644
--- /dev/null
@@@ -1,33 -1,0 +1,33 @@@
-       "ui/calendar",
 +define( [
 +      "lib/common",
++      "ui/widgets/calendar",
 +      "globalize-locales"
 +], function( common ) {
 +
 +common.testWidget( "calendar", {
 +      defaults: {
 +              buttons: [],
 +              classes: {},
 +              disabled: false,
 +              dateFormat: { date: "short" },
 +              eachDay: $.noop,
 +              labels: {
 +                      "datePickerRole": "date picker",
 +                      "nextText": "Next",
 +                      "prevText": "Prev",
 +                      "weekHeader": "Wk"
 +              },
 +              locale: "en",
 +              max: null,
 +              min: null,
 +              numberOfMonths: 1,
 +              showWeek: false,
 +              value: null,
 +
 +              // callbacks
 +              create: null,
 +              select: null
 +      }
 +});
 +
 +} );
index 1f30419ac8ec6a80c697bac4dc2af716ec1199cb,0000000000000000000000000000000000000000..23e5da43a900e647820218cacacf9b270e7e9454
mode 100644,000000..100644
--- /dev/null
@@@ -1,393 -1,0 +1,392 @@@
-       "globalize",
-       "ui/calendar"
- ], function( $, testHelper, Globalize ) {
 +define( [
 +      "jquery",
 +      "./helper",
++      "ui/widgets/calendar"
++], function( $, testHelper ) {
 +
 +module( "calendar: core" );
 +
 +test( "base structure", function() {
 +      expect( 26 );
 +
 +      var header, title, table, thead, week, child, buttonpane,
 +              element = $( "#calendar" ).calendar(),
 +              dp = element.calendar( "widget" );
 +
 +      function step1() {
 +              ok( !dp.is( ".ui-calendar-rtl" ), "Structure - not right-to-left" );
 +              ok( !dp.is( ".ui-calendar-multi" ), "Structure - not multi-month" );
 +              equal( dp.children().length, 2, "Structure - child count (header, calendar)" );
 +
 +              header = dp.children( ":first" );
 +              ok( header.is( "div.ui-calendar-header" ), "Structure - header division" );
 +              equal( header.children().length, 3, "Structure - header child count" );
 +              ok( header.children( ":first" ).is( ".ui-calendar-prev" ) && header.children( ":first" ).html() !== "", "Structure - prev link" );
 +              ok( header.children( ":eq(1)" ).is( ".ui-calendar-next" ) && header.children( ":eq(1)" ).html() !== "", "Structure - next link" );
 +
 +              title = header.children( ":last" ).children( ":first" );
 +              ok( title.is( "div.ui-calendar-title" ) && title.html() !== "", "Structure - title division" );
 +              equal( title.children().length, 2, "Structure - title child count" );
 +              ok( title.children( ":first" ).is( "span.ui-calendar-month" ) && title.children( ":first" ).text() !== "", "Structure - month text" );
 +              ok( title.children( ":last" ).is( "span.ui-calendar-year" ) && title.children( ":last" ).text() !== "", "Structure - year text" );
 +
 +              table = dp.children( ":eq(1)" );
 +              ok( table.is( "table.ui-calendar-calendar" ), "Structure - month table" );
 +              ok( table.children( ":first" ).is( "thead" ), "Structure - month table thead" );
 +
 +              thead = table.children( ":first" ).children( ":first" );
 +              ok( thead.is( "tr" ), "Structure - month table title row" );
 +              equal( thead.find( "th" ).length, 7, "Structure - month table title cells" );
 +              ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure - month table body" );
 +              ok( table.children( ":eq(1)" ).children( "tr" ).length >= 4, "Structure - month table week count" );
 +
 +              week = table.children( ":eq(1)" ).children( ":first" );
 +              ok( week.is( "tr" ), "Structure - month table week row" );
 +              equal( week.children().length, 7, "Structure - week child count" );
 +
 +              step2();
 +      }
 +
 +      function step2() {
 +              element.calendar( "option", "buttons", {
 +                      "test": function() {},
 +                      "test button": function() {}
 +              });
 +
 +              equal( dp.children().length, 3, "Structure buttons - child count (header, calendar, buttonpane)" );
 +
 +              buttonpane = dp.children( ".ui-calendar-buttonpane" );
 +              equal( buttonpane.children( "div.ui-calendar-buttonset" ).length, 1, "Structure buttons - buttonset" );
 +              equal( buttonpane.find( "button.ui-button:first" ).text(), "test", "Structure buttons - buttonset" );
 +              equal( buttonpane.find( "button.ui-button:eq(1)" ).text(), "test button", "Structure buttons - buttonset" );
 +
 +              element.calendar( "destroy" );
 +              step3();
 +      }
 +
 +      function step3() {
 +              // Multi-month 2
 +              element = $( "#calendar" ).calendar( { numberOfMonths: 2 } );
 +              dp = element.calendar( "widget" );
 +
 +              ok( dp.is( ".ui-calendar-multi" ), "Structure multi [2] - multi-month" );
 +              equal( dp.children().length, 3, "Structure multi [2] - child count" );
 +
 +              child = dp.children( ":eq(2)" );
 +              ok( child.is( "div.ui-calendar-row-break" ), "Structure multi [2] - row break" );
 +
 +              element.calendar( "destroy" );
 +      }
 +
 +      step1();
 +});
 +
 +test( "Localization", function() {
 +      expect( 10 );
 +
 +      var element = $( "#calendar" ),
 +              date = new Date( 2014, 0, 1 ),
 +              optionsDe = {
 +                      locale: "de",
 +                      labels: {
 +                              "nextText": "Vor",
 +                              "prevText": "Zurück"
 +                      }
 +              },
 +              initCalendar = function( options ) {
 +                      element
 +                              .calendar( options )
 +                              .calendar( "valueAsDate", date );
 +              },
 +              testLocalization = function( message ) {
 +                      equal(
 +                              element.find( ".ui-calendar-month" ).text(),
 +                              "Januar", message + "titlebar year"
 +                      );
 +                      equal(
 +                              element.find( "thead th:first" ).text(),
 +                              "Mo.", message + "teader first day"
 +                      );
 +                      equal(
 +                              element.find( "thead th:last" ).text(),
 +                              "So.", message + "header last day"
 +                      );
 +                      equal(
 +                              element.find( ".ui-calendar-prev" ).text(),
 +                              "Zurück", message + "header prev"
 +                      );
 +                      equal(
 +                              element.find( ".ui-calendar-next" ).text(),
 +                              "Vor", message + "header next"
 +                      );
 +              };
 +
 +      initCalendar( optionsDe );
 +      testLocalization( "Init: " );
 +      element.calendar( "destroy" );
 +
 +      initCalendar( {} );
 +      element
 +              .calendar( "option", optionsDe )
 +              .calendar( "refresh" );
 +      testLocalization( "After init: " );
 +});
 +
 +asyncTest( "keyboard handling", function() {
 +      expect( 10 );
 +
 +      var element = $( "#calendar" );
 +
 +      function step1() {
 +              element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
 +
 +              testHelper
 +                      .focusGrid( element )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      testHelper.equalsDate(
 +                              element.calendar( "valueAsDate" ),
 +                              new Date( 2013, 12 - 1, 31 ),
 +                              "Keystroke left to switch to previous day"
 +                      );
 +                      element.calendar( "destroy" );
 +                      step2();
 +              }, 50 );
 +      }
 +
 +      function step2() {
 +              element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
 +
 +              testHelper.focusGrid( element )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +
 +              testHelper.equalsDate(
 +                      element.calendar( "valueAsDate" ),
 +                      new Date( 2014, 1 - 1, 2 ),
 +                      "Keystroke right to switch to next day"
 +              );
 +              step3();
 +      }
 +
 +      function step3() {
 +              element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
 +
 +              testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      testHelper.equalsDate(
 +                              element.calendar( "valueAsDate" ),
 +                              new Date( 2013, 12 - 1, 25 ),
 +                              "Keystroke up to move to the previous week"
 +                      );
 +                      element.calendar( "destroy" );
 +                      step4();
 +              }, 50 );
 +      }
 +
 +      function step4() {
 +              element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
 +
 +              testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      testHelper.equalsDate(
 +                              element.calendar( "valueAsDate" ),
 +                              new Date( 2014, 1 - 1, 8 ),
 +                              "Keystroke down to move to the next week"
 +                      );
 +                      element.calendar( "destroy" );
 +                      step5();
 +              }, 50 );
 +      }
 +
 +      function step5() {
 +              element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
 +
 +              testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      testHelper.equalsDate(
 +                              element.calendar( "valueAsDate" ),
 +                              new Date( 2013, 12 - 1, 1 ),
 +                              "Keystroke Page Up moves date to previous month"
 +                      );
 +                      element.calendar( "destroy" );
 +                      step6();
 +              }, 50 );
 +      }
 +
 +      function step6() {
 +              element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
 +
 +              testHelper.focusGrid( element )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP, altKey: true } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      testHelper.equalsDate(
 +                              element.calendar( "valueAsDate" ),
 +                              new Date( 2013, 1 - 1, 1 ),
 +                              "Keystroke Page Up + ALT moves date to previous year"
 +                      );
 +                      element.calendar( "destroy" );
 +                      step7();
 +              }, 50 );
 +      }
 +
 +      function step7() {
 +              element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
 +
 +              testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      testHelper.equalsDate(
 +                              element.calendar( "valueAsDate" ),
 +                              new Date( 2014, 2 - 1, 1 ),
 +                              "Keystroke Page Down moves date to next month"
 +                      );
 +                      element.calendar( "destroy" );
 +                      step8();
 +              }, 50 );
 +      }
 +
 +      function step8() {
 +              element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
 +
 +              testHelper.focusGrid( element )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN, altKey: true } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      testHelper.equalsDate(
 +                              element.calendar( "valueAsDate" ),
 +                              new Date( 2015, 1 - 1, 1 ),
 +                              "Keystroke Page Down + ALT moves date to next year"
 +                      );
 +                      element.calendar( "destroy" );
 +                      step9();
 +              }, 50 );
 +      }
 +
 +      // Check for moving to short months
 +      function step9() {
 +              element.calendar({ value: new Date( 2014, 3 - 1, 31 ) });
 +
 +              testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      testHelper.equalsDate(
 +                              element.calendar( "valueAsDate" ),
 +                              new Date( 2014, 2 - 1, 28 ),
 +                              "Keystroke Page Up and short months"
 +                      );
 +                      element.calendar( "destroy" );
 +                      step10();
 +              }, 50 );
 +      }
 +
 +      function step10() {
 +              element.calendar({ value: new Date( 2016, 1 - 1, 30 ) });
 +
 +              testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      testHelper.equalsDate(
 +                              element.calendar( "valueAsDate" ),
 +                              new Date( 2016, 2 - 1, 29 ),
 +                              "Keystroke Page Down and leap years"
 +                      );
 +                      element.calendar( "destroy" );
 +                      start();
 +              }, 50 );
 +      }
 +
 +      step1();
 +});
 +
 +asyncTest( "mouse", function() {
 +      expect( 6 );
 +
 +      var element = $( "#calendar" ).calendar(),
 +              date = new Date();
 +
 +      function step1() {
 +              $( "tbody button:contains(10)", element ).simulate( "mousedown" );
 +              date.setDate( 10 );
 +              testHelper.equalsDate(
 +                      element.calendar( "valueAsDate" ),
 +                      date,
 +                      "Mouse click"
 +              );
 +
 +              element.calendar( "option", "value", new Date( 2008, 2 - 1, 4) );
 +              $( ".ui-calendar-calendar tbody button:contains(12)", element ).simulate( "mousedown" );
 +              testHelper.equalsDate(
 +                      element.calendar( "valueAsDate" ),
 +                      new Date( 2008, 2 - 1, 12 ),
 +                      "Mouse click - preset"
 +              );
 +
 +              // Previous/next
 +              element.calendar( "option", "value", new Date( 2008, 2 - 1, 4) );
 +              $( ".ui-calendar-prev", element ).simulate( "click" );
 +              $( ".ui-calendar-calendar tbody button:contains(16)", element ).simulate( "mousedown" );
 +              testHelper.equalsDate(
 +                      element.calendar( "valueAsDate" ),
 +                      new Date( 2008, 1 - 1, 16 ),
 +                      "Mouse click - previous"
 +              );
 +
 +              element.calendar( "option", "value", new Date( 2008, 2 - 1, 4) );
 +              $( ".ui-calendar-next", element ).simulate( "click" );
 +              $( ".ui-calendar-calendar tbody button:contains(18)", element ).simulate( "mousedown" );
 +              testHelper.equalsDate(
 +                      element.calendar( "valueAsDate" ),
 +                      new Date( 2008, 3 - 1, 18 ),
 +                      "Mouse click - next"
 +              );
 +
 +              step2();
 +      }
 +
 +      // Previous/next with minimum/maximum
 +      function step2() {
 +              element.calendar( "destroy" );
 +              element.calendar({
 +                      value: new Date( 2008, 3 - 1, 4),
 +                      min: new Date( 2008, 2 - 1, 2 ),
 +                      max: new Date( 2008, 2 - 1, 26 )
 +              });
 +
 +              $( ".ui-calendar-prev", element ).simulate( "click" );
 +              $( "tbody button:contains(16)", element ).simulate( "mousedown" );
 +              testHelper.equalsDate(
 +                      element.calendar( "valueAsDate" ),
 +                      new Date( 2008, 2 - 1, 16 ),
 +                      "Mouse click - previous + min/max"
 +              );
 +              step3();
 +      }
 +
 +      function step3() {
 +              element.calendar( "destroy" );
 +              element.calendar({
 +                      value: new Date( 2008, 1 - 1, 4),
 +                      min: new Date( 2008, 2 - 1, 2 ),
 +                      max: new Date( 2008, 2 - 1, 26 )
 +              });
 +
 +              $( ".ui-calendar-next", element ).simulate( "click" );
 +              $( "tbody button:contains(18)", element ).simulate( "mousedown" );
 +              testHelper.equalsDate(
 +                      element.calendar( "valueAsDate" ),
 +                      new Date( 2008, 2 - 1, 18 ),
 +                      "Mouse click - next + min/max"
 +              );
 +              start();
 +      }
 +
 +      step1();
 +});
 +
 +} );
index e28d30d6b2d3fa34cc7f4c81f7b488521a0fa26f,0000000000000000000000000000000000000000..23989860c66e6a9eb0b006ddcdcbf86d71b9e1b1
mode 100644,000000..100644
--- /dev/null
@@@ -1,145 -1,0 +1,145 @@@
-       "ui/calendar"
 +define( [
 +      "jquery",
 +      "./helper",
++      "ui/widgets/calendar"
 +], function( $, testHelper ) {
 +
 +module( "calendar: methods" );
 +
 +test( "destroy", function( assert ) {
 +      expect( 1 );
 +
 +      assert.domEqual( "#calendar", function() {
 +              $( "#calendar" ).calendar().calendar( "destroy" );
 +      });
 +});
 +
 +test( "enable / disable", function() {
 +      expect( 8 );
 +
 +      var element = $( "#calendar" ).calendar();
 +
 +      element.calendar( "disable" );
 +      ok( element.calendar( "option", "disabled" ), "disabled option is set" );
 +      ok( element.hasClass( "ui-calendar-disabled" ), "has disabled widget class name" );
 +      ok( element.hasClass( "ui-state-disabled" ), "has disabled state class name" );
 +      equal( element.attr( "aria-disabled" ), "true", "has ARIA disabled" );
 +
 +      element.calendar( "enable" );
 +      ok( !element.calendar( "option", "disabled" ), "enabled after enable() call" );
 +      ok( !element.hasClass( "ui-calendar-disabled" ), "no longer has disabled widget class name" );
 +      ok( !element.hasClass( "ui-state-disabled" ), "no longer has disabled state class name" );
 +      equal( element.attr( "aria-disabled" ), "false", "no longer has ARIA disabled" );
 +});
 +
 +test( "widget", function() {
 +      expect( 1 );
 +
 +      var element = $( "#calendar" ).calendar(),
 +              widget = element.calendar( "widget" );
 +
 +      strictEqual( widget[ 0 ],  element[ 0 ] );
 +});
 +
 +test( "value", function() {
 +      expect( 3 );
 +      var element = $( "#calendar" ).calendar();
 +
 +      element.calendar( "value", "1/1/14" );
 +      ok( element.find( "button[data-timestamp]:first" )
 +                      .hasClass( "ui-state-active" ),
 +              "first day marked as selected"
 +      );
 +      equal( element.calendar( "value" ), "1/1/14", "getter" );
 +
 +      element.calendar( "value", "abc" );
 +      equal( element.calendar( "value" ), "1/1/14", "Setting invalid values should be ignored." );
 +});
 +
 +test( "valueAsDate", function() {
 +      expect( 11 );
 +
 +      var minDate, maxDate, dateAndTimeToSet, dateAndTimeClone,
 +              element = $( "#calendar" ).calendar(),
 +              date1 = new Date( 2008, 6 - 1, 4 ),
 +              date2;
 +
 +      element.calendar( "valueAsDate", new Date( 2014, 0, 1 ) );
 +      ok( element.find( "button[data-timestamp]:first" )
 +                      .hasClass( "ui-state-active" ),
 +              "First day marked as selected"
 +      );
 +      testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2014, 0, 1 ), "Getter" );
 +
 +      element.calendar( "destroy" );
 +
 +      element.calendar();
 +      equal( element.calendar( "valueAsDate" ), null, "Set date - default" );
 +
 +      element.calendar( "valueAsDate", date1 );
 +      testHelper.equalsDate(element.calendar( "valueAsDate" ), date1, "Set date - 2008-06-04" );
 +
 +      // With minimum/maximum
 +      element = $( "#calendar" ).calendar();
 +      date1 = new Date( 2008, 1 - 1, 4 );
 +      date2 = new Date( 2008, 6 - 1, 4 );
 +      minDate = new Date( 2008, 2 - 1, 29 );
 +      maxDate = new Date( 2008, 3 - 1, 28 );
 +
 +      element
 +              .calendar( "option", { min: minDate } )
 +              .calendar( "valueAsDate", date2 );
 +      testHelper.equalsDate(
 +              element.calendar( "valueAsDate" ),
 +              date2, "Set date min/max - value > min"
 +      );
 +
 +      element.calendar( "valueAsDate", date1 );
 +      testHelper.equalsDate(
 +              element.calendar( "valueAsDate" ),
 +              date2,
 +              "Set date min/max - value < min"
 +      );
 +
 +      element
 +              .calendar( "option", { max: maxDate, min: null } )
 +              .calendar( "valueAsDate", date1 );
 +      testHelper.equalsDate(
 +              element.calendar( "valueAsDate" ),
 +              date1,
 +              "Set date min/max - value < max"
 +      );
 +
 +      element.calendar( "valueAsDate", date2 );
 +      testHelper.equalsDate(
 +              element.calendar( "valueAsDate" ),
 +              date1,
 +              "Set date min/max - value > max"
 +      );
 +
 +      element
 +              .calendar( "option", { min: minDate } )
 +              .calendar( "valueAsDate", date1 );
 +      testHelper.equalsDate(
 +              element.calendar( "valueAsDate" ),
 +              date1,
 +              "Set date min/max - value < min"
 +      );
 +
 +      element.calendar( "valueAsDate", date2 );
 +      testHelper.equalsDate(
 +              element.calendar( "valueAsDate" ),
 +              date1, "Set date min/max - value > max"
 +      );
 +
 +      dateAndTimeToSet = new Date( 2008, 3 - 1, 28, 1, 11, 0 );
 +      dateAndTimeClone = new Date( 2008, 3 - 1, 28, 1, 11, 0 );
 +      element.calendar( "valueAsDate", dateAndTimeToSet );
 +      equal(
 +              dateAndTimeToSet.getTime(),
 +              dateAndTimeClone.getTime(),
 +              "Date object passed should not be changed by valueAsDate"
 +      );
 +});
 +
 +} );
index c6049fce370be56844f921c393e2789788be2e48,0000000000000000000000000000000000000000..5af5e479e5733518c0678adb1a3b8b2ae7ba8935
mode 100644,000000..100644
--- /dev/null
@@@ -1,323 -1,0 +1,323 @@@
-       "ui/calendar"
 +define( [
 +      "jquery",
 +      "./helper",
++      "ui/widgets/calendar"
 +], function( $, testHelper ) {
 +
 +module( "calendar: options" );
 +
 +test("buttons", function() {
 +      expect( 21 );
 +
 +      var button, i, newButtons,
 +              buttons = {
 +                      "Ok": function( event ) {
 +                              ok(true, "button click fires callback" );
 +                              equal( this, element[ 0 ], "context of callback" );
 +                              equal( event.target, button[ 0 ], "event target" );
 +                      },
 +                      "Cancel": function( event ) {
 +                              ok( true, "button click fires callback" );
 +                              equal( this, element[ 0 ], "context of callback" );
 +                              equal( event.target, button[ 1 ], "event target" );
 +                      }
 +              },
 +              element = $( "#calendar" ).calendar({ buttons: buttons });
 +
 +      button = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" );
 +      equal( button.length, 2, "number of buttons" );
 +
 +      i = 0;
 +      $.each( buttons, function( key ) {
 +              equal( button.eq( i ).text(), key, "text of button " + ( i + 1 ) );
 +              i++;
 +      });
 +
 +      ok( button.parent().hasClass( "ui-calendar-buttonset" ), "buttons in container" );
 +      ok(
 +              element.calendar( "widget" ).hasClass( "ui-calendar-buttons" ),
 +              "calendar wrapper adds class about having buttons"
 +      );
 +
 +      button.trigger( "click" );
 +
 +      newButtons = {
 +              "Close": function( event ) {
 +                      ok( true, "button click fires callback" );
 +                      equal( this, element[ 0 ], "context of callback" );
 +                      equal( event.target, button[ 0 ], "event target" );
 +              }
 +      };
 +
 +      deepEqual(
 +              element.calendar( "option", "buttons" ),
 +              buttons,
 +              ".calendar('option', 'buttons') getter"
 +      );
 +      element.calendar( "option", "buttons", newButtons );
 +      deepEqual(
 +              element.calendar( "option", "buttons" ),
 +              newButtons,
 +              ".calendar('option', 'buttons', ...) setter"
 +      );
 +
 +      button = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" );
 +      equal( button.length, 1, "number of buttons after setter" );
 +      button.trigger( "click" );
 +
 +      i = 0;
 +      $.each( newButtons, function( key ) {
 +              equal( button.eq( i ).text(), key, "text of button " + ( i + 1 ) );
 +              i += 1;
 +      });
 +
 +      element.calendar( "option", "buttons", null );
 +      button = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" );
 +      equal( button.length, 0, "all buttons have been removed" );
 +      equal( element.find( ".ui-calendar-buttonset" ).length, 0, "buttonset has been removed" );
 +      equal( element.hasClass( "ui-calendar-buttons" ), false, "calendar element removes class about having buttons" );
 +
 +      element.remove();
 +});
 +
 +test( "buttons - advanced", function() {
 +      expect( 7 );
 +
 +      var buttons,
 +              element = $( "#calendar" ).calendar({
 +                      buttons: [{
 +                              text: "a button",
 +                              "class": "additional-class",
 +                              id: "my-button-id",
 +                              click: function() {
 +                                      equal( this, element[ 0 ], "correct context" );
 +                              },
 +                              icons: {
 +                                      primary: "ui-icon-cancel"
 +                              },
 +                              showText: false
 +                      }]
 +              });
 +
 +      buttons = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" );
 +      equal( buttons.length, 1, "correct number of buttons" );
 +      equal( buttons.attr( "id" ), "my-button-id", "correct id" );
 +      equal ( buttons.text(), "a button", "correct label" );
 +      ok( buttons.hasClass( "additional-class" ), "additional classes added" );
 +      deepEqual( buttons.button( "option", "icons" ), { primary: "ui-icon-cancel", secondary: null } );
 +      equal( buttons.button( "option", "text" ), false );
 +      buttons.click();
 +
 +      element.remove();
 +});
 +
 +test( "dateFormat", function() {
 +      expect( 2 );
 +      var element = $( "#calendar" ).calendar();
 +
 +      element.calendar( "value", "1/1/14" );
 +
 +      element.calendar( "widget" ).find( "td[id]:first button" ).trigger( "mousedown" );
 +      equal( element.calendar( "value" ), "1/1/14", "default formatting" );
 +
 +      element.calendar( "option", "dateFormat", { date: "full" } );
 +      equal( element.calendar( "value" ), "Wednesday, January 1, 2014", "updated formatting" );
 +});
 +
 +test( "eachDay", function() {
 +      expect( 5 );
 +      var timestamp,
 +              input = $( "#calendar" ).calendar(),
 +              picker = input.calendar( "widget" ),
 +              firstCell = picker.find( "td[id]:first" );
 +
 +      equal( firstCell.find( "button" ).length, 1, "days are selectable by default" );
 +      timestamp = parseInt( firstCell.find( "button" ).attr( "data-timestamp" ), 10 );
 +      equal( new Date( timestamp ).getDate(), 1, "first available day is the 1st by default" );
 +
 +      // Do not render the 1st of the month
 +      input.calendar( "option", "eachDay", function( day ) {
 +              if ( day.date === 1 ) {
 +                      day.render = false;
 +              }
 +      });
 +      firstCell = picker.find( "td[id]:first" );
 +      timestamp = parseInt( firstCell.find( "button" ).attr( "data-timestamp" ), 10 );
 +      equal( new Date( timestamp ).getDate(), 2, "first available day is the 2nd" );
 +
 +      // Display the 1st of the month but make it not selectable.
 +      input.calendar( "option", "eachDay", function( day ) {
 +              if ( day.date === 1 ) {
 +                      day.selectable = false;
 +              }
 +      });
 +      firstCell = picker.find( "td[id]:first" );
 +      ok( firstCell.find( "button" ).prop( "disabled" ), "the 1st is not selectable" );
 +
 +      input.calendar( "option", "eachDay", function( day ) {
 +              if ( day.date === 1 ) {
 +                      day.extraClasses = "ui-custom";
 +              }
 +      });
 +      ok( picker.find( "td[id]:first button" ).hasClass( "ui-custom" ), "extraClasses applied" );
 +
 +      input.calendar( "destroy" );
 +});
 +
 +test( "showWeek", function() {
 +      expect( 7 );
 +      var input = $( "#calendar" ).calendar(),
 +              container = input.calendar( "widget" );
 +
 +      equal( container.find( "thead th" ).length, 7, "just 7 days, no column cell" );
 +      equal( container.find( ".ui-calendar-week-col" ).length, 0,
 +              "no week column cells present" );
 +      input.calendar( "destroy" );
 +
 +      input = $( "#calendar" ).calendar({ showWeek: true });
 +      container = input.calendar( "widget" );
 +      equal( container.find( "thead th" ).length, 8, "7 days + a column cell" );
 +      ok( container.find( "thead th:first" ).is( ".ui-calendar-week-col" ),
 +              "first cell should have ui-datepicker-week-col class name" );
 +      equal( container.find( ".ui-calendar-week-col" ).length,
 +              container.find( "tr" ).length, "one week cell for each week" );
 +      input.calendar( "destroy" );
 +
 +      input = $( "#calendar" ).calendar();
 +      container = input.calendar( "widget" );
 +      equal( container.find( "thead th" ).length, 7, "no week column" );
 +      input.calendar( "option", "showWeek", true );
 +      equal( container.find( "thead th" ).length, 8, "supports changing option after init" );
 +});
 +
 +test( "min / max", function() {
 +      expect( 7 );
 +
 +      // With existing date
 +      var element = $( "#calendar" ).calendar(),
 +              minDate = new Date( 2008, 2 - 1, 29 ),
 +              maxDate = new Date( 2008, 12 - 1, 7 );
 +
 +      element
 +              .calendar( "option", { min: minDate } )
 +              .calendar( "value", "6/4/08" );
 +      testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value > min" );
 +
 +      element
 +              .calendar( "option", { min: minDate } )
 +              .calendar( "value", "1/4/08" );
 +      testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value < min" );
 +
 +      element
 +              .calendar( "option", { min: null } )
 +              .calendar( "value", "6/4/08" )
 +              .calendar( "option", { max: maxDate } );
 +      testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value < max" );
 +
 +      element
 +              .calendar( "option", { max: maxDate } )
 +              .calendar( "value", "1/4/09" );
 +      testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - setDate > max" );
 +
 +      element
 +              .calendar( "option", { min: minDate, max: maxDate } )
 +              .calendar( "value", "1/4/08" );
 +      testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value < min" );
 +
 +      element
 +              .calendar( "option", { min: minDate, max: maxDate } )
 +              .calendar( "value", "6/4/08" );
 +      testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value > min, < max" );
 +
 +      element
 +              .calendar( "option", { min: minDate, max: maxDate } )
 +              .calendar( "value", "1/4/09" );
 +      testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value > max" );});
 +
 +/*
 +// TODO: Move this to $.date, Globalize or calendar widget
 +test( "daylightSaving", function() {
 +       expect( 25 );
 +       var inp = testHelper.init( "#inp" ),
 +       dp = $( "#ui-datepicker-div" );
 +       ok(true, "Daylight saving - " + new Date());
 +       // Australia, Sydney - AM change, southern hemisphere
 +       inp.val( "04/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(6) a", dp).simulate( "click" );
 +       equal(inp.val(), "04/05/2008", "Daylight saving - Australia 04/05/2008" );
 +       inp.val( "04/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(7) a", dp).simulate( "click" );
 +       equal(inp.val(), "04/06/2008", "Daylight saving - Australia 04/06/2008" );
 +       inp.val( "04/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(8) a", dp).simulate( "click" );
 +       equal(inp.val(), "04/07/2008", "Daylight saving - Australia 04/07/2008" );
 +       inp.val( "10/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(6) a", dp).simulate( "click" );
 +       equal(inp.val(), "10/04/2008", "Daylight saving - Australia 10/04/2008" );
 +       inp.val( "10/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(7) a", dp).simulate( "click" );
 +       equal(inp.val(), "10/05/2008", "Daylight saving - Australia 10/05/2008" );
 +       inp.val( "10/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(8) a", dp).simulate( "click" );
 +       equal(inp.val(), "10/06/2008", "Daylight saving - Australia 10/06/2008" );
 +       // Brasil, Brasilia - midnight change, southern hemisphere
 +       inp.val( "02/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(20) a", dp).simulate( "click" );
 +       equal(inp.val(), "02/16/2008", "Daylight saving - Brasil 02/16/2008" );
 +       inp.val( "02/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(21) a", dp).simulate( "click" );
 +       equal(inp.val(), "02/17/2008", "Daylight saving - Brasil 02/17/2008" );
 +       inp.val( "02/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(22) a", dp).simulate( "click" );
 +       equal(inp.val(), "02/18/2008", "Daylight saving - Brasil 02/18/2008" );
 +       inp.val( "10/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(13) a", dp).simulate( "click" );
 +       equal(inp.val(), "10/11/2008", "Daylight saving - Brasil 10/11/2008" );
 +       inp.val( "10/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(14) a", dp).simulate( "click" );
 +       equal(inp.val(), "10/12/2008", "Daylight saving - Brasil 10/12/2008" );
 +       inp.val( "10/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(15) a", dp).simulate( "click" );
 +       equal(inp.val(), "10/13/2008", "Daylight saving - Brasil 10/13/2008" );
 +       // Lebanon, Beirut - midnight change, northern hemisphere
 +       inp.val( "03/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(34) a", dp).simulate( "click" );
 +       equal(inp.val(), "03/29/2008", "Daylight saving - Lebanon 03/29/2008" );
 +       inp.val( "03/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(35) a", dp).simulate( "click" );
 +       equal(inp.val(), "03/30/2008", "Daylight saving - Lebanon 03/30/2008" );
 +       inp.val( "03/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(36) a", dp).simulate( "click" );
 +       equal(inp.val(), "03/31/2008", "Daylight saving - Lebanon 03/31/2008" );
 +       inp.val( "10/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(27) a", dp).simulate( "click" );
 +       equal(inp.val(), "10/25/2008", "Daylight saving - Lebanon 10/25/2008" );
 +       inp.val( "10/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(28) a", dp).simulate( "click" );
 +       equal(inp.val(), "10/26/2008", "Daylight saving - Lebanon 10/26/2008" );
 +       inp.val( "10/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(29) a", dp).simulate( "click" );
 +       equal(inp.val(), "10/27/2008", "Daylight saving - Lebanon 10/27/2008" );
 +       // US, Eastern - AM change, northern hemisphere
 +       inp.val( "03/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(13) a", dp).simulate( "click" );
 +       equal(inp.val(), "03/08/2008", "Daylight saving - US 03/08/2008" );
 +       inp.val( "03/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(14) a", dp).simulate( "click" );
 +       equal(inp.val(), "03/09/2008", "Daylight saving - US 03/09/2008" );
 +       inp.val( "03/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(15) a", dp).simulate( "click" );
 +       equal(inp.val(), "03/10/2008", "Daylight saving - US 03/10/2008" );
 +       inp.val( "11/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(6) a", dp).simulate( "click" );
 +       equal(inp.val(), "11/01/2008", "Daylight saving - US 11/01/2008" );
 +       inp.val( "11/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(7) a", dp).simulate( "click" );
 +       equal(inp.val(), "11/02/2008", "Daylight saving - US 11/02/2008" );
 +       inp.val( "11/01/2008" ).calendar( "show" );
 +       $( ".ui-calendar-calendar td:eq(8) a", dp).simulate( "click" );
 +       equal(inp.val(), "11/03/2008", "Daylight saving - US 11/03/2008" );
 + });
 + */
 +
 +} );
index 6389adaec08b9b7bf0d9cb0ebfbb6f90a8c37722,1eecc85cb501591086b7976e04fd5e62e966a3cc..61c7ace43e676397c8b4f59e85e1a860cb349036
@@@ -1,42 -1,7 +1,42 @@@
 -/*
 -TestHelpers.commonWidgetTests( "datepicker", {
 +define( [
 +      "lib/common",
-       "ui/datepicker",
++      "ui/widgets/datepicker",
 +      "globalize-locales"
 +], function( common ) {
 +
 +common.testWidget( "datepicker", {
        defaults: {
 -              disabled: false
 +              appendTo: null,
 +              buttons: [],
 +              classes: {},
 +              disabled: false,
 +              dateFormat: { date: "short" },
 +              eachDay: $.noop,
 +              labels: {
 +                      "datePickerRole": "date picker",
 +                      "nextText": "Next",
 +                      "prevText": "Prev",
 +                      "weekHeader": "Wk"
 +              },
 +              locale: "en",
 +              max: null,
 +              min: null,
 +              numberOfMonths: 1,
 +              position: {
 +                      my: "left top",
 +                      at: "left bottom"
 +              },
 +              show: true,
 +              showWeek: false,
 +              hide: true,
 +
 +              // callbacks
 +              beforeOpen: null,
 +              close: null,
 +              create: null,
 +              open: null,
 +              select: null
        }
  });
 -*/
 +
 +} );
index a9f5b0abf4985fbdd539d556b20a0da2f281d501,43d5e2243ec17261c61174ed4b8660036e84d0b1..2a89108755fdac760b8bb7d9ff3e1b7dc4bd53e2
  define( [
        "jquery",
 -      "lib/common",
        "./helper",
-       "ui/datepicker"
 -      "ui/widgets/datepicker",
 -      "ui/i18n/datepicker-he"
 -], function( $, common, testHelper ) {
++      "ui/widgets/datepicker"
 +], function( $, testHelper ) {
  
 -module( "datepicker: core", {
 -      setup: function() {
 -              $( "body" ).trigger( "focus" );
 -      }
 -});
 -
 -common.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
 -      ok( !$( "#ui-datepicker-div" ).length, "Non init on empty collection" );
 -});
 -
 -test("widget method", function() {
 -      expect( 1 );
 -      var actual = $("#inp").datepicker().datepicker("widget")[0];
 -      deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
 -});
 -
 -asyncTest( "baseStructure", function() {
 -      expect( 58 );
 -      var header, title, table, thead, week, panel, inl, child,
 -              inp = testHelper.initNewInput(),
 -              dp = $( "#ui-datepicker-div" );
 -
 -      function step1() {
 -              testHelper.onFocus( inp, function() {
 -                      ok( dp.is( ":visible" ), "Structure - datepicker visible" );
 -                      ok( !dp.is( ".ui-datepicker-rtl" ), "Structure - not right-to-left" );
 -                      ok( !dp.is( ".ui-datepicker-multi" ), "Structure - not multi-month" );
 -                      equal( dp.children().length, 2, "Structure - child count" );
 -
 -                      header = dp.children( ":first" );
 -                      ok( header.is( "div.ui-datepicker-header" ), "Structure - header division" );
 -                      equal( header.children().length, 3, "Structure - header child count" );
 -                      ok( header.children( ":first" ).is( "a.ui-datepicker-prev" ) && header.children( ":first" ).html() !== "", "Structure - prev link" );
 -                      ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-next" ) && header.children( ":eq(1)" ).html() !== "", "Structure - next link" );
 -
 -                      title = header.children( ":last" );
 -                      ok( title.is( "div.ui-datepicker-title" ) && title.html() !== "","Structure - title division" );
 -                      equal( title.children().length, 2, "Structure - title child count" );
 -                      ok( title.children( ":first" ).is( "span.ui-datepicker-month" ) && title.children( ":first" ).text() !== "", "Structure - month text" );
 -                      ok( title.children( ":last" ).is( "span.ui-datepicker-year" ) && title.children( ":last" ).text() !== "", "Structure - year text" );
 -
 -                      table = dp.children( ":eq(1)" );
 -                      ok( table.is( "table.ui-datepicker-calendar" ), "Structure - month table" );
 -                      ok( table.children( ":first" ).is( "thead" ), "Structure - month table thead" );
 -
 -                      thead = table.children( ":first" ).children( ":first" );
 -                      ok( thead.is( "tr" ), "Structure - month table title row" );
 -                      equal( thead.find( "th" ).length, 7, "Structure - month table title cells" );
 -                      ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure - month table body" );
 -                      ok( table.children( ":eq(1)" ).children( "tr" ).length >= 4, "Structure - month table week count" );
 -
 -                      week = table.children( ":eq(1)" ).children( ":first" );
 -                      ok( week.is( "tr" ), "Structure - month table week row" );
 -                      equal( week.children().length, 7, "Structure - week child count" );
 -                      ok( week.children( ":first" ).is( "td.ui-datepicker-week-end" ), "Structure - month table first day cell" );
 -                      ok( week.children( ":last" ).is( "td.ui-datepicker-week-end" ), "Structure - month table second day cell" );
 -
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -                      step2();
 -              });
 -      }
 -
 -      function step2() {
 -              // Editable month/year and button panel
 -              inp = testHelper.initNewInput({
 -                      changeMonth: true,
 -                      changeYear: true,
 -                      showButtonPanel: true
 -              });
 -              testHelper.onFocus( inp, function() {
 -                      title = dp.find( "div.ui-datepicker-title" );
 -                      ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure - month selector" );
 -                      ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure - year selector" );
 -
 -                      panel = dp.children( ":last" );
 -                      ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure - button panel division" );
 -                      equal( panel.children().length, 2, "Structure - button panel child count" );
 -                      ok( panel.children( ":first" ).is( "button.ui-datepicker-current" ), "Structure - today button" );
 -                      ok( panel.children( ":last" ).is( "button.ui-datepicker-close" ), "Structure - close button" );
 -
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -                      step3();
 -              });
 -      }
 -
 -      function step3() {
 -              // Multi-month 2
 -              inp = testHelper.initNewInput({ numberOfMonths: 2 });
 -              testHelper.onFocus( inp, function() {
 -                      ok( dp.is( ".ui-datepicker-multi" ), "Structure multi [2] - multi-month" );
 -                      equal( dp.children().length, 3, "Structure multi [2] - child count" );
 -
 -                      child = dp.children( ":first" );
 -                      ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2] - first month division" );
 -
 -                      child = dp.children( ":eq(1)" );
 -                      ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2] - second month division" );
 -
 -                      child = dp.children( ":eq(2)" );
 -                      ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2] - row break" );
 -                      ok( dp.is( ".ui-datepicker-multi-2" ), "Structure multi [2] - multi-2" );
 -
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -                      step4();
 -              });
 -      }
 -
 -      function step4() {
 -              // Multi-month 3
 -              inp = testHelper.initNewInput({ numberOfMonths: 3 });
 -              testHelper.onFocus( inp, function() {
 -                      ok( dp.is( ".ui-datepicker-multi-3" ), "Structure multi [3] - multi-3" );
 -                      ok( !dp.is( ".ui-datepicker-multi-2" ), "Structure multi [3] - Trac #6704" );
 -
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -                      step5();
 -              });
 -      }
 +module( "datepicker: core" );
  
 -      function step5() {
 -              // Multi-month [2, 2]
 -              inp = testHelper.initNewInput({ numberOfMonths: [ 2, 2 ] });
 -              testHelper.onFocus( inp, function() {
 -                      ok( dp.is( ".ui-datepicker-multi" ), "Structure multi - multi-month" );
 -                      equal( dp.children().length, 6, "Structure multi [2,2] - child count" );
 +test( "input's value determines starting date", function() {
 +      expect( 3 );
  
 -                      child = dp.children( ":first" );
 -                      ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - first month division" );
 +      var input = $( "#datepicker" ).val( "1/1/14" ).datepicker(),
 +              picker = input.datepicker( "widget" );
  
 -                      child = dp.children( ":eq(1)" );
 -                      ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - second month division" );
 +      input.datepicker( "open" );
  
 -                      child = dp.children( ":eq(2)" );
 -                      ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
 +      equal( picker.find( ".ui-calendar-month" ).html(), "January", "correct month displayed" );
 +      equal( picker.find( ".ui-calendar-year" ).html(), "2014", "correct year displayed" );
 +      equal( picker.find( ".ui-state-active" ).html(), "1", "correct day highlighted" );
  
 -                      child = dp.children( ":eq(3)" );
 -                      ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - third month division" );
 -
 -                      child = dp.children( ":eq(4)" );
 -                      ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - fourth month division" );
 -
 -                      child = dp.children( ":eq(5)" );
 -                      ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
 -
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -
 -                      // Inline
 -                      inl = testHelper.init( "#inl" );
 -                      dp = inl.children();
 -
 -                      ok( dp.is( ".ui-datepicker-inline" ), "Structure inline - main div" );
 -                      ok( !dp.is( ".ui-datepicker-rtl" ), "Structure inline - not right-to-left" );
 -                      ok( !dp.is( ".ui-datepicker-multi" ), "Structure inline - not multi-month" );
 -                      equal( dp.children().length, 2, "Structure inline - child count" );
 -
 -                      header = dp.children( ":first" );
 -                      ok( header.is( "div.ui-datepicker-header" ), "Structure inline - header division" );
 -                      equal( header.children().length, 3, "Structure inline - header child count" );
 -
 -                      table = dp.children( ":eq(1)" );
 -                      ok( table.is( "table.ui-datepicker-calendar" ), "Structure inline - month table" );
 -                      ok( table.children( ":first" ).is( "thead" ), "Structure inline - month table thead" );
 -                      ok( table.children( ":eq(1)" ).is( "tbody" ), "Structure inline - month table body" );
 -
 -                      inl.datepicker( "destroy" );
 -
 -                      // Inline multi-month
 -                      inl = testHelper.init( "#inl", { numberOfMonths: 2 } );
 -                      dp = inl.children();
 +      input.val( "" ).datepicker( "destroy" );
 +});
  
 -                      ok( dp.is( ".ui-datepicker-inline" ) && dp.is( ".ui-datepicker-multi" ), "Structure inline multi - main div" );
 -                      equal( dp.children().length, 3, "Structure inline multi - child count" );
 +asyncTest( "base structure", function() {
 +      expect( 5 );
  
 -                      child = dp.children( ":first" );
 -                      ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure inline multi - first month division" );
 +      var input = testHelper.initNewInput(),
 +              widget = input.datepicker( "widget" );
  
 -                      child = dp.children( ":eq(1)" );
 -                      ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure inline multi - second month division" );
 +      input.focus();
  
 -                      child = dp.children( ":eq(2)" );
 -                      ok( child.is( "div.ui-datepicker-row-break" ), "Structure inline multi - row break" );
 +      setTimeout(function() {
 +              ok( widget.is( ":visible" ), "Datepicker visible" );
 +              equal( widget.children().length, 2, "Child count" );
 +              ok( widget.is( ".ui-calendar" ), "Class ui-calendar" );
 +              ok( widget.is( ".ui-datepicker" ), "Class ui-datepicker" );
 +              ok( widget.is( ".ui-front" ), "Class ui-front" );
  
 -                      inl.datepicker( "destroy" );
 -                      start();
 -              });
 -      }
 -
 -      step1();
 +              input.datepicker( "close" );
 +              start();
 +      }, 50 );
  });
  
 -asyncTest( "customStructure", function() {
 -      expect( 20 );
 -      var header, panel, title, thead,
 -              inp = testHelper.initNewInput( $.datepicker.regional.he ),
 -              dp = $( "#ui-datepicker-div" );
 +asyncTest( "Keyboard handling: input", function() {
 +      expect( 10 );
 +      var picker, instance,
 +              input = $( "#datepicker" ).datepicker();
  
        function step1() {
 -              inp.datepicker( "option", "showButtonPanel", true );
 -
 -              testHelper.onFocus( inp, function() {
 -                      ok( dp.is( ".ui-datepicker-rtl" ), "Structure RTL - right-to-left" );
 +              testHelper.init( input );
 +              picker = input.datepicker( "widget" );
  
 -                      header = dp.children( ":first" );
 -                      ok( header.is( "div.ui-datepicker-header" ), "Structure RTL - header division" );
 -                      equal( header.children().length, 3, "Structure RTL - header child count" );
 -                      ok( header.children( ":first" ).is( "a.ui-datepicker-next" ), "Structure RTL - prev link" );
 -                      ok( header.children( ":eq(1)" ).is( "a.ui-datepicker-prev" ), "Structure RTL - next link" );
 +              ok( !picker.is( ":visible" ), "datepicker closed" );
  
 -                      panel = dp.children( ":last" );
 -                      ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure RTL - button division" );
 -                      equal( panel.children().length, 2, "Structure RTL - button panel child count" );
 -                      ok( panel.children( ":first" ).is( "button.ui-datepicker-close" ), "Structure RTL - close button" );
 -                      ok( panel.children( ":last" ).is( "button.ui-datepicker-current" ), "Structure RTL - today button" );
 -
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 +              input.val( "" ).simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
 +              setTimeout(function() {
 +                      ok( picker.is( ":visible" ), "Keystroke down opens datepicker" );
 +                      input.datepicker( "destroy" );
                        step2();
 -              });
 +              }, 100 );
        }
  
 -      // Hide prev/next
        function step2() {
 -              inp = testHelper.initNewInput({
 -                      hideIfNoPrevNext: true,
 -                      minDate: new Date( 2008, 2 - 1, 4 ),
 -                      maxDate: new Date( 2008, 2 - 1, 14 )
 -              });
 -              inp.val( "02/10/2008" );
 -
 -              testHelper.onFocus( inp, function() {
 -                      header = dp.children( ":first" );
 -                      ok( header.is( "div.ui-datepicker-header" ), "Structure hide prev/next - header division" );
 -                      equal( header.children().length, 1, "Structure hide prev/next - links child count" );
 -                      ok( header.children( ":first" ).is( "div.ui-datepicker-title" ), "Structure hide prev/next - title division" );
 -
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -                      step3();
 -              });
 -      }
 -
 -      // Changeable Month with read-only year
 -      function step3() {
 -              inp = testHelper.initNewInput({ changeMonth: true });
 -
 -              testHelper.onFocus( inp, function() {
 -                      title = dp.children( ":first" ).children( ":last" );
 -                      equal( title.children().length, 2, "Structure changeable month - title child count" );
 -                      ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure changeable month - month selector" );
 -                      ok( title.children( ":last" ).is( "span.ui-datepicker-year" ), "Structure changeable month - read-only year" );
 -
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -                      step4();
 -              });
 -      }
 -
 -      // Changeable year with read-only month
 -      function step4() {
 -              inp = testHelper.initNewInput({ changeYear: true });
 +              testHelper.init( input );
 +              picker = input.datepicker( "widget" );
  
 -              testHelper.onFocus( inp, function() {
 -                      title = dp.children( ":first" ).children( ":last" );
 -                      equal( title.children().length, 2, "Structure changeable year - title child count" );
 -                      ok( title.children( ":first" ).is( "span.ui-datepicker-month" ), "Structure changeable year - read-only month" );
 -                      ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure changeable year - year selector" );
 +              ok( !picker.is( ":visible" ), "datepicker closed" );
  
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -                      step5();
 -              });
 +              input.val( "" ).simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
 +              setTimeout(function() {
 +                      ok( picker.is( ":visible" ), "Keystroke up opens datepicker" );
 +                      input.datepicker( "destroy" );
 +                      step3();
 +              }, 100 );
        }
  
 -      // Read-only first day of week
 -      function step5() {
 -              inp = testHelper.initNewInput({ changeFirstDay: false });
 -
 -              testHelper.onFocus( inp, function() {
 -                      thead = dp.find( ".ui-datepicker-calendar thead tr" );
 -                      equal( thead.children().length, 7, "Structure read-only first day - thead child count" );
 -                      equal( thead.find( "a" ).length, 0, "Structure read-only first day - thead links count" );
 -
 -                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -                      start();
 -              });
 +      function step3() {
 +              testHelper.init( input );
 +              instance = input.datepicker( "instance" );
 +
 +              // Enter = Select preset date
 +              input
 +                      .val( "1/1/14" )
 +                      .datepicker( "refresh" )
 +                      .datepicker( "open" )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +              testHelper.equalsDate( input.datepicker( "valueAsDate" ), new Date( 2014, 0, 1 ),
 +                      "Keystroke enter - preset" );
 +
 +              input
 +                      .val( "" )
 +                      .datepicker( "open" );
 +              ok( instance.isOpen, "datepicker is open before escape" );
 +
 +              input.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
 +              ok( !instance.isOpen, "escape closes the datepicker" );
 +
 +              input
 +                      .val( "1/1/14" )
 +                      .datepicker( "open" )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
 +              testHelper.equalsDate( input.datepicker( "valueAsDate" ), new Date( 2014, 0, 1 ),
 +                      "Keystroke esc - preset" );
 +
 +              input
 +                      .val( "1/1/14" )
 +                      .datepicker( "open" )
 +                      .simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
 +              testHelper.equalsDate( input.datepicker( "valueAsDate" ), new Date( 2014, 0, 1 ),
 +                      "Keystroke esc - abandoned" );
 +
 +              input
 +                      .val( "1/2/14" )
 +                      .simulate( "keyup" );
 +              testHelper.equalsDate( input.datepicker( "valueAsDate" ), new Date( 2014, 0, 2 ),
 +                      "Picker updated as user types into input" );
 +
 +              input.datepicker( "destroy" );
 +              start();
        }
  
 -      // TODO: figure out why this setTimeout is needed in IE,
 -      // it only is necessary when the previous baseStructure tests runs first
 -      // Support: IE
 -      setTimeout( step1 );
 +      step1();
  });
  
 -test("keystrokes", function() {
 -      expect( 26 );
 -      var inp = testHelper.init("#inp"),
 -              date = new Date();
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke enter");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
 -              "Keystroke enter - preset");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+home");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END});
 -      ok(inp.datepicker("getDate") == null, "Keystroke ctrl+end");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
 -      ok(inp.datepicker("getDate") == null, "Keystroke esc");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
 -              "Keystroke esc - preset");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
 -              "Keystroke esc - abandoned");
 -      // Moving by day or week
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.LEFT}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() - 1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+left");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.LEFT}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() + 1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke left");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.RIGHT}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() + 1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+right");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.RIGHT}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() - 1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke right");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() - 7);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+up");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() + 7);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke up");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() + 7);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+down");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() - 7);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke down");
 -      // Moving by month or year
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 4),
 -              "Keystroke pgup");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 4),
 -              "Keystroke pgdn");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 4),
 -              "Keystroke ctrl+pgup");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 4),
 -              "Keystroke ctrl+pgdn");
 -      // Check for moving to short months
 -      inp.val("03/31/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29),
 -              "Keystroke pgup - Feb");
 -      inp.val("01/30/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29),
 -              "Keystroke pgdn - Feb");
 -      inp.val("02/29/2008").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 28),
 -              "Keystroke ctrl+pgup - Feb");
 -      inp.val("02/29/2008").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 28),
 -              "Keystroke ctrl+pgdn - Feb");
 -      // Goto current
 -      inp.datepicker("option", {gotoCurrent: true}).
 -              datepicker("hide").val("02/04/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
 -              "Keystroke ctrl+home");
 -      // Change steps
 -      inp.datepicker("option", {stepMonths: 2, gotoCurrent: false}).
 -              datepicker("hide").val("02/04/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2007, 12 - 1, 4),
 -              "Keystroke pgup step 2");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 4 - 1, 4),
 -              "Keystroke pgdn step 2");
 +// TODO: implement
 +test( "ARIA", function() {
 +      expect( 0 );
  });
  
 -test("mouse", function() {
 -      expect( 15 );
 -      var inl,
 -              inp = testHelper.init("#inp"),
 -              dp = $("#ui-datepicker-div"),
 -              date = new Date();
 -      inp.val("").datepicker("show");
 -      $(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {});
 -      date.setDate(10);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Mouse click");
 -      inp.val("02/04/2008").datepicker("show");
 -      $(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 12),
 -              "Mouse click - preset");
 -      inp.val("02/04/2008").datepicker("show");
 -      inp.val("").datepicker("show");
 -      $("button.ui-datepicker-close", dp).simulate("click", {});
 -      ok(inp.datepicker("getDate") == null, "Mouse click - close");
 -      inp.val("02/04/2008").datepicker("show");
 -      $("button.ui-datepicker-close", dp).simulate("click", {});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
 -              "Mouse click - close + preset");
 -      inp.val("02/04/2008").datepicker("show");
 -      $("a.ui-datepicker-prev", dp).simulate("click", {});
 -      $("button.ui-datepicker-close", dp).simulate("click", {});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
 -              "Mouse click - abandoned");
 -      // Current/previous/next
 -      inp.val("02/04/2008").datepicker("option", {showButtonPanel: true}).datepicker("show");
 -      $(".ui-datepicker-current", dp).simulate("click", {});
 -      $(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {});
 -      date.setDate(14);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Mouse click - current");
 -      inp.val("02/04/2008").datepicker("show");
 -      $(".ui-datepicker-prev", dp).simulate("click");
 -      $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click");
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 16),
 -              "Mouse click - previous");
 -      inp.val("02/04/2008").datepicker("show");
 -      $(".ui-datepicker-next", dp).simulate("click");
 -      $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click");
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 18),
 -              "Mouse click - next");
 -      // Previous/next with minimum/maximum
 -      inp.datepicker("option", {minDate: new Date(2008, 2 - 1, 2),
 -              maxDate: new Date(2008, 2 - 1, 26)}).val("02/04/2008").datepicker("show");
 -      $(".ui-datepicker-prev", dp).simulate("click");
 -      $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click");
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 16),
 -              "Mouse click - previous + min/max");
 -      inp.val("02/04/2008").datepicker("show");
 -      $(".ui-datepicker-next", dp).simulate("click");
 -      $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click");
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 18),
 -              "Mouse click - next + min/max");
 -      // Inline
 -      inl = testHelper.init("#inl");
 -      dp = $(".ui-datepicker-inline", inl);
 -      date = new Date();
 -      inl.datepicker("setDate", date);
 -      $(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {});
 -      date.setDate(10);
 -      testHelper.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline");
 -      inl.datepicker("option", {showButtonPanel: true}).datepicker("setDate", new Date(2008, 2 - 1, 4));
 -      $(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {});
 -      testHelper.equalsDate(inl.datepicker("getDate"), new Date(2008, 2 - 1, 12), "Mouse click inline - preset");
 -      inl.datepicker("option", {showButtonPanel: true});
 -      $(".ui-datepicker-current", dp).simulate("click", {});
 -      $(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {});
 -      date.setDate(14);
 -      testHelper.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline - current");
 -      inl.datepicker("setDate", new Date(2008, 2 - 1, 4));
 -      $(".ui-datepicker-prev", dp).simulate("click");
 -      $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click");
 -      testHelper.equalsDate(inl.datepicker("getDate"), new Date(2008, 1 - 1, 16),
 -              "Mouse click inline - previous");
 -      inl.datepicker("setDate", new Date(2008, 2 - 1, 4));
 -      $(".ui-datepicker-next", dp).simulate("click");
 -      $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click");
 -      testHelper.equalsDate(inl.datepicker("getDate"), new Date(2008, 3 - 1, 18),
 -              "Mouse click inline - next");
 +asyncTest( "mouse", function() {
 +      expect( 4 );
 +
 +      var input = testHelper.init( $( "#datepicker" ).val( "" ) ),
 +              picker = input.datepicker( "widget" );
 +
 +      input.datepicker( "open" );
 +
 +      setTimeout(function() {
 +              input.val( "4/4/08" ).datepicker( "refresh" ).datepicker( "open" );
 +              $( ".ui-calendar-calendar tbody button:contains(12)", picker ).simulate( "mousedown", {} );
 +              testHelper.equalsDate(
 +                      input.datepicker( "valueAsDate" ),
 +                      new Date( 2008, 4 - 1, 12 ),
 +                      "Mouse click - preset"
 +              );
 +
 +              input.val( "" ).datepicker( "refresh" );
 +              input.simulate( "click" );
 +              strictEqual( input.datepicker( "valueAsDate" ), null, "Mouse click - close" );
 +
 +              input.val( "4/4/08" ).datepicker( "refresh" ).datepicker( "open" );
 +              input.simulate( "click" );
 +              testHelper.equalsDate(
 +                      input.datepicker( "valueAsDate" ),
 +                      new Date( 2008, 4 - 1, 4 ),
 +                      "Mouse click - close + preset"
 +              );
 +
 +              input.val( "4/4/08" ).datepicker( "refresh" ).datepicker( "open" );
 +              picker.find( "a.ui-calendar-prev" ).simulate( "click" );
 +              input.simulate( "click" );
 +              testHelper.equalsDate(
 +                      input.datepicker( "valueAsDate" ),
 +                      new Date( 2008, 4 - 1, 4 ),
 +                      "Mouse click - abandoned"
 +              );
 +
 +              start();
 +      }, 100 );
  });
  
  } );
index dcadfecf947f4f3279b56522abd5baab09f6fde6,f33351b57a5541b27476531a75a846d68b2edf83..833316ce48ac16afed29bf01e768dd5346e66678
  define( [
        "jquery",
        "./helper",
-       "ui/datepicker"
+       "ui/widgets/datepicker"
  ], function( $, testHelper ) {
  
 -module("datepicker: events");
 -
 -var selectedThis = null,
 -selectedDate = null,
 -selectedInst = null;
 -
 -function callback(date, inst) {
 -      selectedThis = this;
 -      selectedDate = date;
 -      selectedInst = inst;
 -}
 -
 -function callback2(year, month, inst) {
 -      selectedThis = this;
 -      selectedDate = year + "/" + month;
 -      selectedInst = inst;
 -}
 -
 -test("events", function() {
 -      expect( 26 );
 -      var dateStr, newMonthYear, inp2,
 -              inp = testHelper.init("#inp", {onSelect: callback}),
 -      date = new Date();
 -      // onSelect
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      equal(selectedThis, inp[0], "Callback selected this");
 -      equal(selectedInst, $.data(inp[0], testHelper.PROP_NAME), "Callback selected inst");
 -      equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date),
 -              "Callback selected date");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() + 7);
 -      equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date),
 -              "Callback selected date - ctrl+down");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
 -      equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date),
 -              "Callback selected date - esc");
 -    dateStr = "02/04/2008";
 -    inp.val(dateStr).datepicker("show").
 -        simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -    equal(dateStr, selectedDate,
 -        "onSelect is called after enter keydown");
 -      // onChangeMonthYear
 -      inp.datepicker("option", {onChangeMonthYear: callback2, onSelect: null}).
 -              val("").datepicker("show");
 -      newMonthYear = function(date) {
 -              return date.getFullYear() + "/" + (date.getMonth() + 1);
 -      };
 -      date = new Date();
 -      date.setDate(1);
 -      inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP});
 -      date.setMonth(date.getMonth() - 1);
 -      equal(selectedThis, inp[0], "Callback change month/year this");
 -      equal(selectedInst, $.data(inp[0], testHelper.PROP_NAME), "Callback change month/year inst");
 -      equal(selectedDate, newMonthYear(date),
 -              "Callback change month/year date - pgup");
 -      inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN});
 -      date.setMonth(date.getMonth() + 1);
 -      equal(selectedDate, newMonthYear(date),
 -              "Callback change month/year date - pgdn");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP});
 -      date.setFullYear(date.getFullYear() - 1);
 -      equal(selectedDate, newMonthYear(date),
 -              "Callback change month/year date - ctrl+pgup");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME});
 -      date.setFullYear(date.getFullYear() + 1);
 -      equal(selectedDate, newMonthYear(date),
 -              "Callback change month/year date - ctrl+home");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN});
 -      date.setFullYear(date.getFullYear() + 1);
 -      equal(selectedDate, newMonthYear(date),
 -              "Callback change month/year date - ctrl+pgdn");
 -      inp.datepicker("setDate", new Date(2007, 1 - 1, 26));
 -      equal(selectedDate, "2007/1", "Callback change month/year date - setDate");
 -      selectedDate = null;
 -      inp.datepicker("setDate", new Date(2007, 1 - 1, 12));
 -      ok(selectedDate == null, "Callback change month/year date - setDate no change");
 -      // onChangeMonthYear step by 2
 -      inp.datepicker("option", {stepMonths: 2}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP});
 -      date.setMonth(date.getMonth() - 14);
 -      equal(selectedDate, newMonthYear(date),
 -              "Callback change month/year by 2 date - pgup");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP});
 -      date.setMonth(date.getMonth() - 12);
 -      equal(selectedDate, newMonthYear(date),
 -              "Callback change month/year by 2 date - ctrl+pgup");
 -      inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN});
 -      date.setMonth(date.getMonth() + 2);
 -      equal(selectedDate, newMonthYear(date),
 -              "Callback change month/year by 2 date - pgdn");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN});
 -      date.setMonth(date.getMonth() + 12);
 -      equal(selectedDate, newMonthYear(date),
 -              "Callback change month/year by 2 date - ctrl+pgdn");
 -      // onClose
 -      inp.datepicker("option", {onClose: callback, onChangeMonthYear: null, stepMonths: 1}).
 -              val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
 -      equal(selectedThis, inp[0], "Callback close this");
 -      equal(selectedInst, $.data(inp[0], testHelper.PROP_NAME), "Callback close inst");
 -      equal(selectedDate, "", "Callback close date - esc");
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", new Date()),
 -              "Callback close date - enter");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
 -      equal(selectedDate, "02/04/2008", "Callback close date - preset");
 -      inp.val("02/04/2008").datepicker("show").
 -              simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END});
 -      equal(selectedDate, "", "Callback close date - ctrl+end");
 -
 -      inp2 = testHelper.init("#inp2");
 -      inp2.datepicker().datepicker("option", {onClose: callback}).datepicker("show");
 -      inp.datepicker("show");
 -      equal(selectedThis, inp2[0], "Callback close this");
 -});
 +module( "datepicker: events" );
  
 -test("beforeShowDay-getDate", function() {
 +test( "beforeOpen", function() {
        expect( 3 );
 -      var inp = testHelper.init("#inp", {beforeShowDay: function() { inp.datepicker("getDate"); return [true, ""]; }}),
 -              dp = $("#ui-datepicker-div");
 -      inp.val("01/01/2010").datepicker("show");
 -      // contains non-breaking space
 -      equal($("div.ui-datepicker-title").text(),
 -              // support: IE <9, jQuery <1.8
 -              // In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
 -              $( "<span>January&#xa0;2010</span>" ).text(), "Initial month");
 -      $("a.ui-datepicker-next", dp).trigger( "click" );
 -      $("a.ui-datepicker-next", dp).trigger( "click" );
 -      // contains non-breaking space
 -      equal($("div.ui-datepicker-title").text(),
 -              $( "<span>March&#xa0;2010</span>" ).text(), "After next clicks");
 -      inp.datepicker("hide").datepicker("show");
 -      $("a.ui-datepicker-prev", dp).trigger( "click" );
 -      $("a.ui-datepicker-prev", dp).trigger( "click" );
 -      // contains non-breaking space
 -      equal($("div.ui-datepicker-title").text(),
 -              $( "<span>November&#xa0;2009</span>" ).text(), "After prev clicks");
 -      inp.datepicker("hide");
 +
 +      var input = testHelper.init( "#datepicker", {
 +                      beforeOpen: function() {
 +                              ok( true, "beforeOpen event fired before open" );
 +                              ok( input.datepicker( "widget" ).is( ":hidden" ), "calendar hidden on beforeOpen" );
 +                      },
 +                      open: function() {
 +                              ok( input.datepicker( "widget" ).is( ":visible" ), "calendar open on open" );
 +                      }
 +              });
 +
 +      input
 +              .datepicker( "open" )
 +              .datepicker( "close" )
 +              .datepicker( "option", {
 +                      beforeOpen: function() {
 +                              return false;
 +                      },
 +                      open: function() {
 +                              ok( false, "calendar should not open when openBefore is canceled" );
 +                      }
 +              })
 +              .datepicker( "open" );
 +});
 +
 +test( "close", function() {
 +      expect( 4 );
 +
 +      var shouldFire,
 +              input = testHelper.init( "#datepicker", {
 +                      close: function() {
 +                              ok( shouldFire, "close event fired" );
 +                      }
 +              });
 +
 +      shouldFire = false;
 +      input.datepicker( "open" );
 +      shouldFire = true;
 +      input.datepicker( "close" );
 +
 +      shouldFire = false;
 +      input.datepicker( "open" );
 +      shouldFire = true;
 +      $( "body" ).trigger( "mousedown" );
 +
 +      shouldFire = false;
 +      input.datepicker( "open" );
 +      shouldFire = true;
 +      input.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
 +
 +      shouldFire = false;
 +      input.datepicker( "open" );
 +      shouldFire = true;
 +      input.datepicker( "widget" ).find( "tbody tr:first button:first" ).simulate( "mousedown" );
 +});
 +
 +test( "open", function() {
 +      expect( 2 );
 +
 +      var input = testHelper.init( "#datepicker", {
 +                      open: function() {
 +                              ok( true, "open event fired on open" );
 +                              ok( widget.is( ":visible" ), "calendar open on open" );
 +                      }
 +              }),
 +              widget = input.datepicker( "widget" );
 +
 +      input.datepicker( "open" );
 +});
 +
 +asyncTest( "select", function() {
 +      expect( 4 );
 +
 +      var input = testHelper.init( "#datepicker", {
 +                      select: function( event ) {
 +                              ok( true, "select event fired " + message );
 +                              equal(
 +                                      event.originalEvent.type,
 +                                      "calendarselect",
 +                                      "select originalEvent " + message
 +                              );
 +                      }
 +              }),
 +              widget = input.datepicker( "widget" ),
 +              message = "";
 +
 +      function step1() {
 +              message = "on calendar cell click";
 +              input
 +                      .simulate( "focus" )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
 +              setTimeout(function() {
 +                      widget.find( "tbody tr:first button:first" ).simulate( "mousedown" );
 +                      input.datepicker( "close" );
 +                      step2();
 +              }, 100 );
 +      }
 +
 +      function step2() {
 +              message = "on calendar cell enter";
 +              input
 +                      .simulate( "focus" )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
 +              setTimeout(function() {
 +                      $( document.activeElement )
 +                              .simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } )
 +                              .simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
 +                      input.datepicker( "close" );
 +                      step3();
 +              }, 100 );
 +      }
 +
 +      function step3() {
 +              message = "on calendar escape (not expected)";
 +              input
 +                      .simulate( "focus" )
 +                      .simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
 +              setTimeout(function() {
 +                      $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
 +                      input.datepicker( "close" );
 +                      start();
 +              }, 100 );
 +      }
 +
 +      step1();
  });
  
  } );
Simple merge
index db3762fff59c7d278fc24da0a7d2bac9c2f653fe,571b4cb98d49ee7e4b210b234e0f3cfce673660a..f05958af0b1ce0a2cbf653a55d1b9efc2f0d9f7f
  define( [
        "jquery",
        "./helper",
-       "ui/datepicker"
+       "ui/widgets/datepicker"
  ], function( $, testHelper ) {
  
 -module("datepicker: methods");
 -
 -test("destroy", function() {
 -      expect( 33 );
 -      var inl,
 -              inp = testHelper.init("#inp");
 -      ok(inp.is(".hasDatepicker"), "Default - marker class set");
 -      ok($.data(inp[0], testHelper.PROP_NAME), "Default - instance present");
 -      ok(inp.next().is("#alt"), "Default - button absent");
 -      inp.datepicker("destroy");
 -      inp = $("#inp");
 -      ok(!inp.is(".hasDatepicker"), "Default - marker class cleared");
 -      ok(!$.data(inp[0], testHelper.PROP_NAME), "Default - instance absent");
 -      ok(inp.next().is("#alt"), "Default - button absent");
 -      // With button
 -      inp= testHelper.init("#inp", {showOn: "both"});
 -      ok(inp.is(".hasDatepicker"), "Button - marker class set");
 -      ok($.data(inp[0], testHelper.PROP_NAME), "Button - instance present");
 -      ok(inp.next().text() === "...", "Button - button added");
 -      inp.datepicker("destroy");
 -      inp = $("#inp");
 -      ok(!inp.is(".hasDatepicker"), "Button - marker class cleared");
 -      ok(!$.data(inp[0], testHelper.PROP_NAME), "Button - instance absent");
 -      ok(inp.next().is("#alt"), "Button - button removed");
 -      // With append text
 -      inp = testHelper.init("#inp", {appendText: "Testing"});
 -      ok(inp.is(".hasDatepicker"), "Append - marker class set");
 -      ok($.data(inp[0], testHelper.PROP_NAME), "Append - instance present");
 -      ok(inp.next().text() === "Testing", "Append - append text added");
 -      inp.datepicker("destroy");
 -      inp = $("#inp");
 -      ok(!inp.is(".hasDatepicker"), "Append - marker class cleared");
 -      ok(!$.data(inp[0], testHelper.PROP_NAME), "Append - instance absent");
 -      ok(inp.next().is("#alt"), "Append - append text removed");
 -      // With both
 -      inp= testHelper.init("#inp", {showOn: "both", buttonImageOnly: true,
 -              buttonImage: "images/calendar.gif", appendText: "Testing"});
 -      ok(inp.is(".hasDatepicker"), "Both - marker class set");
 -      ok($.data(inp[0], testHelper.PROP_NAME), "Both - instance present");
 -      ok(inp.next()[0].nodeName.toLowerCase() === "img", "Both - button added");
 -      ok(inp.next().next().text() === "Testing", "Both - append text added");
 -      inp.datepicker("destroy");
 -      inp = $("#inp");
 -      ok(!inp.is(".hasDatepicker"), "Both - marker class cleared");
 -      ok(!$.data(inp[0], testHelper.PROP_NAME), "Both - instance absent");
 -      ok(inp.next().is("#alt"), "Both - button and append text absent");
 -      // Inline
 -      inl = testHelper.init("#inl");
 -      ok(inl.is(".hasDatepicker"), "Inline - marker class set");
 -      ok(inl.html() !== "", "Inline - datepicker present");
 -      ok($.data(inl[0], testHelper.PROP_NAME), "Inline - instance present");
 -      ok(inl.next().length === 0 || inl.next().is("p"), "Inline - button absent");
 -      inl.datepicker("destroy");
 -      inl = $("#inl");
 -      ok(!inl.is(".hasDatepicker"), "Inline - marker class cleared");
 -      ok(inl.html() === "", "Inline - datepicker absent");
 -      ok(!$.data(inl[0], testHelper.PROP_NAME), "Inline - instance absent");
 -      ok(inl.next().length === 0 || inl.next().is("p"), "Inline - button absent");
 +module( "datepicker: methods" );
 +
 +test( "destroy", function( assert ) {
 +      expect( 3 );
 +
 +      var input = $( "#datepicker" );
 +      assert.domEqual( input, function() {
 +              input.datepicker();
 +              ok( input.attr( "aria-owns" ), "aria-owns attribute added" );
 +              ok( input.attr( "aria-haspopup" ), "aria-haspopup attribute added" );
 +              input.datepicker( "destroy" );
 +      });
 +});
 +
 +test( "enable / disable", function() {
 +      expect( 10 );
 +
 +      var input = testHelper.init( "#datepicker" ),
 +              calendar = input.datepicker( "widget" );
 +
 +      input.datepicker( "disable" );
 +      ok( input.datepicker( "option", "disabled" ), "disabled option is set" );
 +      ok( calendar.hasClass( "ui-datepicker-disabled" ), "has disabled widget class name" );
 +      ok( input.hasClass( "ui-state-disabled" ), "has disabled state class name" );
 +      equal( input.attr( "aria-disabled" ), "true", "has ARIA disabled" );
 +      equal( input.attr( "disabled" ), "disabled", "input disabled" );
 +
 +      input.datepicker( "enable" );
 +      ok( !input.datepicker( "option", "disabled" ), "enabled after enable() call" );
 +      ok( !calendar.hasClass( "ui-datepicker-disabled" ), "no longer has disabled widget class name" );
 +      ok( !input.hasClass( "ui-state-disabled" ), "no longer has disabled state class name" );
 +      equal( input.attr( "aria-disabled" ), "false", "no longer has ARIA disabled" );
 +      equal( input.attr( "disabled" ), undefined, "input no longer disabled" );
 +});
 +
 +test( "widget", function() {
 +      expect( 1 );
 +
 +      var actual = $( "#datepicker" ).datepicker().datepicker( "widget" );
 +      deepEqual( $( "body > .ui-front" )[ 0 ],  actual[ 0 ] );
 +      actual.remove();
 +});
 +
 +test( "open / close", function() {
 +      expect( 7 );
 +
 +      var input = testHelper.initNewInput({ show: false, hide: false }),
 +              calendar = input.datepicker( "widget" );
 +
 +      ok( calendar.is( ":hidden" ), "calendar hidden on init" );
 +
 +      input.datepicker( "open" );
 +      ok( calendar.is( ":visible" ), "open: calendar visible" );
 +      equal( calendar.attr( "aria-hidden" ), "false", "open: calendar aria-hidden" );
 +      equal( calendar.attr( "aria-expanded" ), "true", "close: calendar aria-expanded" );
 +
 +      input.datepicker( "close" );
 +      ok( !calendar.is( ":visible" ), "close: calendar hidden" );
 +      equal( calendar.attr( "aria-hidden" ), "true", "close: calendar aria-hidden" );
 +      equal( calendar.attr( "aria-expanded" ), "false", "close: calendar aria-expanded" );
  });
  
 -test("enableDisable", function() {
 -      expect( 33 );
 -      var inl, dp,
 -              inp = testHelper.init("#inp");
 -      ok(!inp.datepicker("isDisabled"), "Enable/disable - initially marked as enabled");
 -      ok(!inp[0].disabled, "Enable/disable - field initially enabled");
 -      inp.datepicker("disable");
 -      ok(inp.datepicker("isDisabled"), "Enable/disable - now marked as disabled");
 -      ok(inp[0].disabled, "Enable/disable - field now disabled");
 -      inp.datepicker("enable");
 -      ok(!inp.datepicker("isDisabled"), "Enable/disable - now marked as enabled");
 -      ok(!inp[0].disabled, "Enable/disable - field now enabled");
 -      inp.datepicker("destroy");
 -      // With a button
 -      inp = testHelper.init("#inp", {showOn: "button"});
 -      ok(!inp.datepicker("isDisabled"), "Enable/disable button - initially marked as enabled");
 -      ok(!inp[0].disabled, "Enable/disable button - field initially enabled");
 -      ok(!inp.next("button")[0].disabled, "Enable/disable button - button initially enabled");
 -      inp.datepicker("disable");
 -      ok(inp.datepicker("isDisabled"), "Enable/disable button - now marked as disabled");
 -      ok(inp[0].disabled, "Enable/disable button - field now disabled");
 -      ok(inp.next("button")[0].disabled, "Enable/disable button - button now disabled");
 -      inp.datepicker("enable");
 -      ok(!inp.datepicker("isDisabled"), "Enable/disable button - now marked as enabled");
 -      ok(!inp[0].disabled, "Enable/disable button - field now enabled");
 -      ok(!inp.next("button")[0].disabled, "Enable/disable button - button now enabled");
 -      inp.datepicker("destroy");
 -      // With an image button
 -      inp = testHelper.init("#inp", {showOn: "button", buttonImageOnly: true,
 -              buttonImage: "images/calendar.gif"});
 -      ok(!inp.datepicker("isDisabled"), "Enable/disable image - initially marked as enabled");
 -      ok(!inp[0].disabled, "Enable/disable image - field initially enabled");
 -      ok(parseFloat(inp.next("img").css("opacity")) === 1, "Enable/disable image - image initially enabled");
 -      inp.datepicker("disable");
 -      ok(inp.datepicker("isDisabled"), "Enable/disable image - now marked as disabled");
 -      ok(inp[0].disabled, "Enable/disable image - field now disabled");
 -      ok(parseFloat(inp.next("img").css("opacity")) !== 1, "Enable/disable image - image now disabled");
 -      inp.datepicker("enable");
 -      ok(!inp.datepicker("isDisabled"), "Enable/disable image - now marked as enabled");
 -      ok(!inp[0].disabled, "Enable/disable image - field now enabled");
 -      ok(parseFloat(inp.next("img").css("opacity")) === 1, "Enable/disable image - image now enabled");
 -      inp.datepicker("destroy");
 -      // Inline
 -      inl = testHelper.init("#inl", {changeYear: true});
 -      dp = $(".ui-datepicker-inline", inl);
 -      ok(!inl.datepicker("isDisabled"), "Enable/disable inline - initially marked as enabled");
 -      ok(!dp.children().is(".ui-state-disabled"), "Enable/disable inline - not visually disabled initially");
 -      ok(!dp.find("select").prop("disabled"), "Enable/disable inline - form element enabled initially");
 -      inl.datepicker("disable");
 -      ok(inl.datepicker("isDisabled"), "Enable/disable inline - now marked as disabled");
 -      ok(dp.children().is(".ui-state-disabled"), "Enable/disable inline - visually disabled");
 -      ok(dp.find("select").prop("disabled"), "Enable/disable inline - form element disabled");
 -      inl.datepicker("enable");
 -      ok(!inl.datepicker("isDisabled"), "Enable/disable inline - now marked as enabled");
 -      ok(!dp.children().is(".ui-state-disabled"), "Enable/disable inline - not visiually disabled");
 -      ok(!dp.find("select").prop("disabled"), "Enable/disable inline - form element enabled");
 -      inl.datepicker("destroy");
 +test( "value", function() {
 +      expect( 4 );
 +
 +      var input = $( "#datepicker" ).datepicker(),
 +              picker = input.datepicker( "widget" );
 +
 +      input.datepicker( "value", "1/1/14" );
 +      equal( input.val(), "1/1/14", "input's value set" );
 +
 +      input.datepicker( "open" );
 +      ok(
 +              picker.find( "button[data-timestamp]" ).eq( 0 ).hasClass( "ui-state-active" ),
 +              "first day marked as selected"
 +      );
 +      equal( input.datepicker( "value" ), "1/1/14", "getter" );
 +
 +      input.val( "abc" );
 +      strictEqual( input.datepicker( "value" ), null, "Invalid values should return null." );
 +});
 +
 +test( "valueAsDate", function() {
 +      expect( 6 );
 +
 +      var input = testHelper.init( "#datepicker" ),
 +              picker = input.datepicker( "widget" ),
 +              date1 = new Date( 2008, 6 - 1, 4 );
 +
 +      input.datepicker( "valueAsDate", new Date( 2014, 0, 1 ) );
 +      equal( input.val(), "1/1/14", "Input's value set" );
 +      ok(
 +              picker.find( "button[data-timestamp]" ).eq( 0 ).hasClass( "ui-state-active" ),
 +              "First day marked as selected"
 +      );
 +      testHelper.equalsDate( input.datepicker( "valueAsDate" ), new Date( 2014, 0, 1 ), "Getter" );
 +
 +      input.val( "a/b/c" );
 +      equal( input.datepicker( "valueAsDate" ), null, "Invalid dates return null" );
 +
 +      input.val( "" ).datepicker( "destroy" );
 +      input = testHelper.init( "#datepicker" );
 +
 +      strictEqual( input.datepicker( "valueAsDate" ), null, "Set date - default" );
 +      input.datepicker( "valueAsDate", date1 );
 +      testHelper.equalsDate( input.datepicker( "valueAsDate" ), date1, "Set date - 2008-06-04" );
 +});
 +
 +test( "isValid", function() {
 +      expect( 2 );
 +      var input = $( "#datepicker" ).datepicker();
 +
 +      input.val( "1/1/14" );
 +      ok( input.datepicker( "isValid" ) );
 +
 +      input.val( "1/1/abc" );
 +      ok( !input.datepicker( "isValid" ) );
 +
 +      input.datepicker( "destroy" );
  });
  
  } );
index 6bad27b6a4f1cda3e1fda8037c19e531d98f76dc,3a6c15c6daf37f75a978d71e21d778f0b598560a..75d74546055062cc562a78c509a03278d04361fc
  define( [
        "jquery",
        "./helper",
-       "ui/datepicker"
 -      "ui/widgets/datepicker",
 -      "ui/i18n/datepicker-fr",
 -      "ui/i18n/datepicker-he",
 -      "ui/i18n/datepicker-zh-CN"
++      "ui/widgets/datepicker"
  ], function( $, testHelper ) {
  
 -module("datepicker: options");
 -
 -test("setDefaults", function() {
 -      expect( 3 );
 -      testHelper.init("#inp");
 -      equal($.datepicker._defaults.showOn, "focus", "Initial showOn");
 -      $.datepicker.setDefaults({showOn: "button"});
 -      equal($.datepicker._defaults.showOn, "button", "Change default showOn");
 -      $.datepicker.setDefaults({showOn: "focus"});
 -      equal($.datepicker._defaults.showOn, "focus", "Restore showOn");
 -});
 -
 -test("option", function() {
 -      expect( 17 );
 -      var inp = testHelper.init("#inp"),
 -      inst = $.data(inp[0], testHelper.PROP_NAME);
 -      // Set option
 -      equal(inst.settings.showOn, null, "Initial setting showOn");
 -      equal($.datepicker._get(inst, "showOn"), "focus", "Initial instance showOn");
 -      equal($.datepicker._defaults.showOn, "focus", "Initial default showOn");
 -      inp.datepicker("option", "showOn", "button");
 -      equal(inst.settings.showOn, "button", "Change setting showOn");
 -      equal($.datepicker._get(inst, "showOn"), "button", "Change instance showOn");
 -      equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
 -      inp.datepicker("option", {showOn: "both"});
 -      equal(inst.settings.showOn, "both", "Change setting showOn");
 -      equal($.datepicker._get(inst, "showOn"), "both", "Change instance showOn");
 -      equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
 -      inp.datepicker("option", "showOn", undefined);
 -      equal(inst.settings.showOn, null, "Clear setting showOn");
 -      equal($.datepicker._get(inst, "showOn"), "focus", "Restore instance showOn");
 -      equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
 -      // Get option
 -      inp = testHelper.init("#inp");
 -      equal(inp.datepicker("option", "showOn"), "focus", "Initial setting showOn");
 -      inp.datepicker("option", "showOn", "button");
 -      equal(inp.datepicker("option", "showOn"), "button", "Change instance showOn");
 -      inp.datepicker("option", "showOn", undefined);
 -      equal(inp.datepicker("option", "showOn"), "focus", "Reset instance showOn");
 -      deepEqual(inp.datepicker("option", "all"), {showAnim: ""}, "Get instance settings");
 -      deepEqual(inp.datepicker("option", "defaults"), $.datepicker._defaults,
 -              "Get default settings");
 -});
 -
 -test( "disabled", function() {
 -      expect(8);
 -      var inp = testHelper.init("#inp");
 -      ok(!inp.datepicker("isDisabled"), "Initially marked as enabled");
 -      ok(!inp[0].disabled, "Field initially enabled");
 -      inp.datepicker("option", "disabled", true);
 -      ok(inp.datepicker("isDisabled"), "Marked as disabled");
 -      ok(inp[0].disabled, "Field now disabled");
 -      inp.datepicker("option", "disabled", false);
 -      ok(!inp.datepicker("isDisabled"), "Marked as enabled");
 -      ok(!inp[0].disabled, "Field now enabled");
 -      inp.datepicker("destroy");
 -
 -      inp = testHelper.init("#inp", { disabled: true });
 -      ok(inp.datepicker("isDisabled"), "Initially marked as disabled");
 -      ok(inp[0].disabled, "Field initially disabled");
 -});
 -
 -test("change", function() {
 -      expect( 12 );
 -      var inp = testHelper.init("#inp"),
 -      inst = $.data(inp[0], testHelper.PROP_NAME);
 -      equal(inst.settings.showOn, null, "Initial setting showOn");
 -      equal($.datepicker._get(inst, "showOn"), "focus", "Initial instance showOn");
 -      equal($.datepicker._defaults.showOn, "focus", "Initial default showOn");
 -      inp.datepicker("change", "showOn", "button");
 -      equal(inst.settings.showOn, "button", "Change setting showOn");
 -      equal($.datepicker._get(inst, "showOn"), "button", "Change instance showOn");
 -      equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
 -      inp.datepicker("change", {showOn: "both"});
 -      equal(inst.settings.showOn, "both", "Change setting showOn");
 -      equal($.datepicker._get(inst, "showOn"), "both", "Change instance showOn");
 -      equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
 -      inp.datepicker("change", "showOn", undefined);
 -      equal(inst.settings.showOn, null, "Clear setting showOn");
 -      equal($.datepicker._get(inst, "showOn"), "focus", "Restore instance showOn");
 -      equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
 -});
 -
 -(function() {
 -      var url = window.location.search;
 -      url = decodeURIComponent( url.slice( url.indexOf( "swarmURL=" ) + 9 ) );
 -
 -      // TODO: This test occassionally fails in IE in TestSwarm
 -      if ( $.ui.ie && url && url.indexOf( "http" ) === 0 ) {
 -              return;
 -      }
 -
 -      asyncTest( "invocation", function() {
 -              var button, image,
 -                      isOldIE = $.ui.ie && ( !document.documentMode || document.documentMode < 9 ),
 -                      body = $( "body" );
 -
 -              expect( isOldIE ? 25 : 29 );
 -
 -              function step0() {
 -                      var inp = testHelper.initNewInput(),
 -                              dp = $( "#ui-datepicker-div" );
 -
 -                      button = inp.siblings( "button" );
 -                      ok( button.length === 0, "Focus - button absent" );
 -                      image = inp.siblings( "img" );
 -                      ok( image.length === 0, "Focus - image absent" );
 -
 -                      testHelper.onFocus( inp, function() {
 -                              ok( dp.is( ":visible" ), "Focus - rendered on focus" );
 -                              inp.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
 -                              ok( !dp.is( ":visible" ), "Focus - hidden on exit" );
 -                              step1();
 -                      });
 -              }
 -
 -              function step1() {
 -
 -                      var inp = testHelper.initNewInput(),
 -                              dp = $( "#ui-datepicker-div" );
 -
 -                      testHelper.onFocus( inp, function() {
 -                              ok( dp.is( ":visible" ), "Focus - rendered on focus" );
 -                              body.simulate( "mousedown", {} );
 -                              ok( !dp.is( ":visible" ), "Focus - hidden on external click" );
 -                              inp.datepicker( "hide" ).datepicker( "destroy" );
 -
 -                              step2();
 -                      });
 -              }
 -
 -              function step2() {
 -                      var inp = testHelper.initNewInput({
 -                                      showOn: "button",
 -                                      buttonText: "Popup"
 -                              }),
 -                              dp = $( "#ui-datepicker-div" );
 -
 -                      ok( !dp.is( ":visible" ), "Button - initially hidden" );
 -                      button = inp.siblings( "button" );
 -                      image = inp.siblings( "img" );
 -                      ok( button.length === 1, "Button - button present" );
 -                      ok( image.length === 0, "Button - image absent" );
 -                      equal( button.text(), "Popup", "Button - button text" );
 -
 -                      testHelper.onFocus( inp, function() {
 -                              ok( !dp.is( ":visible" ), "Button - not rendered on focus" );
 -                              button.trigger( "click" );
 -                              ok( dp.is( ":visible" ), "Button - rendered on button click" );
 -                              button.trigger( "click" );
 -                              ok( !dp.is( ":visible" ), "Button - hidden on second button click" );
 -                              inp.datepicker( "hide" ).datepicker( "destroy" );
 -
 -                              step3();
 -                      });
 -              }
 -
 -              function step3() {
 -                      var inp = testHelper.initNewInput({
 -                                      showOn: "button",
 -                                      buttonImageOnly: true,
 -                                      buttonImage: "images/calendar.gif",
 -                                      buttonText: "Cal"
 -                              }),
 -                              dp = $( "#ui-datepicker-div" );
 -
 -                      ok( !dp.is( ":visible" ), "Image button - initially hidden" );
 -                      button = inp.siblings( "button" );
 -                      ok( button.length === 0, "Image button - button absent" );
 -                      image = inp.siblings( "img" );
 -                      ok( image.length === 1, "Image button - image present" );
 -                      ok( /images\/calendar\.gif$/.test( image.attr( "src" ) ), "Image button - image source" );
 -                      equal( image.attr( "title" ), "Cal", "Image button - image text" );
 -
 -                      testHelper.onFocus( inp, function() {
 -                              ok( !dp.is( ":visible" ), "Image button - not rendered on focus" );
 -                              image.trigger( "click" );
 -                              ok( dp.is( ":visible" ), "Image button - rendered on image click" );
 -                              image.trigger( "click" );
 -                              ok( !dp.is( ":visible" ), "Image button - hidden on second image click" );
 -                              inp.datepicker( "hide" ).datepicker( "destroy" );
 -
 -                              step4();
 -                      });
 +module( "datepicker: options" );
 +
 +test( "appendTo", function() {
 +      expect( 6 );
 +      var container,
 +              detached = $( "<div>" ),
 +              input = $( "#datepicker" );
 +
 +      input.datepicker();
 +      container = input.datepicker( "widget" ).parent()[ 0 ];
 +      equal( container, document.body, "defaults to body" );
 +      input.datepicker( "destroy" );
 +
 +      input.datepicker({ appendTo: "#qunit-fixture" });
 +      container = input.datepicker( "widget" ).parent()[ 0 ];
 +      equal( container, $( "#qunit-fixture" )[ 0 ], "child of specified element" );
 +      input.datepicker( "destroy" );
 +
 +      input.datepicker({ appendTo: "#does-not-exist" });
 +      container = input.datepicker( "widget" ).parent()[ 0 ];
 +      equal( container, document.body, "set to body if element does not exist" );
 +      input.datepicker( "destroy" );
 +
 +      input.datepicker()
 +              .datepicker( "option", "appendTo", "#qunit-fixture" );
 +      container = input.datepicker( "widget" ).parent()[ 0 ];
 +      equal( container, $( "#qunit-fixture" )[ 0 ], "modified after init" );
 +      input.datepicker( "destroy" );
 +
 +      input.datepicker({ appendTo: detached });
 +      container = input.datepicker( "widget" ).parent()[ 0 ];
 +      equal( container, detached[ 0 ], "detached jQuery object" );
 +      input.datepicker( "destroy" );
 +
 +      input.datepicker({ appendTo: detached[ 0 ] });
 +      container = input.datepicker( "widget" ).parent()[ 0 ];
 +      equal( container, detached[ 0 ], "detached DOM element" );
 +      input.datepicker( "destroy" );
 +});
 +
 +test( "Pass-through options", function() {
 +      expect( 11 );
 +
 +      var options = {
 +                      buttons: { "Test": $.noop },
 +                      dateFormat: { date: "full" },
 +                      disabled: true,
 +                      eachDay: function( day ) { day; },
 +                      locale: "de",
 +                      max: new Date( 2000, 0, 1 ),
 +                      min: new Date( 2000, 0, 2 ),
 +                      numberOfMonths: 3,
 +                      showWeek: true
 +              },
 +              input = $( "#datepicker" ).val( "1/1/14" ).datepicker(),
 +              datepickerInstance = input.datepicker( "instance" );
 +
 +      $.each( options, function( key, value ) {
 +              input.datepicker( "option", key, value );
 +
 +              deepEqual(
 +                      datepickerInstance.calendar.calendar( "option", key ),
 +                      value,
 +                      "option " + key + ": correct value"
 +              );
 +
 +              if ( key === "dateFormat" ) {
 +                      equal( input.val(), "Wednesday, January 1, 2014", "option " + key + ": updated format" );
                }
  
 -              function step4() {
 -                      var inp = testHelper.initNewInput({
 -                                      showOn: "both",
 -                                      buttonImage: "images/calendar.gif"
 -                              }),
 -                              dp = $( "#ui-datepicker-div" );
 -
 -                      ok( !dp.is( ":visible" ), "Both - initially hidden" );
 -                      button = inp.siblings( "button" );
 -                      ok( button.length === 1, "Both - button present" );
 -                      image = inp.siblings( "img" );
 -                      ok( image.length === 0, "Both - image absent" );
 -                      image = button.children( "img" );
 -                      ok( image.length === 1, "Both - button image present" );
 -
 -                      // TODO: This test occasionally fails to focus in IE8 in BrowserStack
 -                      if ( !isOldIE ) {
 -                              testHelper.onFocus( inp, function() {
 -                                      ok( dp.is( ":visible" ), "Both - rendered on focus" );
 -                                      body.simulate( "mousedown", {} );
 -                                      ok( !dp.is( ":visible" ), "Both - hidden on external click" );
 -                                      button.trigger( "click" );
 -                                      ok( dp.is( ":visible" ), "Both - rendered on button click" );
 -                                      button.trigger( "click" );
 -                                      ok( !dp.is( ":visible" ), "Both - hidden on second button click" );
 -                                      inp.datepicker( "hide" ).datepicker( "destroy" );
 -
 -                                      start();
 -                              });
 -                      } else {
 -                              start();
 -                      }
 +              if ( key === "locale" ) {
 +                      equal( input.val(), "Mittwoch, 1. Januar 2014", "option " + key + ": updated locale" );
                }
 -
 -              step0();
        });
 -})();
 -
 -test("otherMonths", function() {
 -      expect( 8 );
 -      var inp = testHelper.init("#inp"),
 -              pop = $("#ui-datepicker-div");
 -      inp.val("06/01/2009").datepicker("show");
 -      equal(pop.find("tbody").text(),
 -              // support: IE <9, jQuery <1.8
 -              // In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
 -              $( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(),
 -              "Other months - none");
 -      ok(pop.find("td:last *").length === 0, "Other months - no content");
 -      inp.datepicker("hide").datepicker("option", "showOtherMonths", true).datepicker("show");
 -      equal(pop.find("tbody").text(), "311234567891011121314151617181920212223242526272829301234",
 -              "Other months - show");
 -      ok(pop.find("td:last span").length === 1, "Other months - span content");
 -      inp.datepicker("hide").datepicker("option", "selectOtherMonths", true).datepicker("show");
 -      equal(pop.find("tbody").text(), "311234567891011121314151617181920212223242526272829301234",
 -              "Other months - select");
 -      ok(pop.find("td:last a").length === 1, "Other months - link content");
 -      inp.datepicker("hide").datepicker("option", "showOtherMonths", false).datepicker("show");
 -      equal(pop.find("tbody").text(),
 -              // support: IE <9, jQuery <1.8
 -              // In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
 -              $( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(),
 -              "Other months - none");
 -      ok(pop.find("td:last *").length === 0, "Other months - no content");
 -});
 -
 -test("defaultDate", function() {
 -      expect( 16 );
 -      var inp = testHelper.init("#inp"),
 -              date = new Date();
 -      inp.val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date null");
 -
 -      // Numeric values
 -      inp.datepicker("option", {defaultDate: -2}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() - 2);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -2");
 -
 -      date = new Date();
 -      inp.datepicker("option", {defaultDate: 3}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() + 3);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 3");
 -
 -      date = new Date();
 -      inp.datepicker("option", {defaultDate: 1 / "a"}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date NaN");
 -
 -      // String offset values
 -      inp.datepicker("option", {defaultDate: "-1d"}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() - 1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -1d");
 -      inp.datepicker("option", {defaultDate: "+3D"}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() + 4);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +3D");
 -      inp.datepicker("option", {defaultDate: " -2 w "}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date = new Date();
 -      date.setDate(date.getDate() - 14);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -2 w");
 -      inp.datepicker("option", {defaultDate: "+1 W"}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setDate(date.getDate() + 21);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +1 W");
 -      inp.datepicker("option", {defaultDate: " -1 m "}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date = testHelper.addMonths(new Date(), -1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -1 m");
 -      inp.datepicker("option", {defaultDate: "+2M"}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date = testHelper.addMonths(new Date(), 2);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +2M");
 -      inp.datepicker("option", {defaultDate: "-2y"}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date = new Date();
 -      date.setFullYear(date.getFullYear() - 2);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -2y");
 -      inp.datepicker("option", {defaultDate: "+1 Y "}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date.setFullYear(date.getFullYear() + 3);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +1 Y");
 -      inp.datepicker("option", {defaultDate: "+1M +10d"}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date = testHelper.addMonths(new Date(), 1);
 -      date.setDate(date.getDate() + 10);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +1M +10d");
 -      // String date values
 -      inp.datepicker("option", {defaultDate: "07/04/2007"}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date = new Date(2007, 7 - 1, 4);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 07/04/2007");
 -      inp.datepicker("option", {dateFormat: "yy-mm-dd", defaultDate: "2007-04-02"}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date = new Date(2007, 4 - 1, 2);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 2007-04-02");
 -      // Date value
 -      date = new Date(2007, 1 - 1, 26);
 -      inp.datepicker("option", {dateFormat: "mm/dd/yy", defaultDate: date}).
 -              datepicker("hide").val("").datepicker("show").
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 01/26/2007");
 -});
 -
 -test("miscellaneous", function() {
 -      expect( 19 );
 -      var curYear, longNames, shortNames, date,
 -              dp = $("#ui-datepicker-div"),
 -              inp = testHelper.init("#inp");
 -      // Year range
 -      function genRange(start, offset) {
 -              var i = start,
 -                      range = "";
 -              for (; i < start + offset; i++) {
 -                      range += i;
 -              }
 -              return range;
 -      }
 -      curYear = new Date().getFullYear();
 -      inp.val("02/04/2008").datepicker("show");
 -      equal(dp.find(".ui-datepicker-year").text(), "2008", "Year range - read-only default");
 -      inp.datepicker("hide").datepicker("option", {changeYear: true}).datepicker("show");
 -      equal(dp.find(".ui-datepicker-year").text(), genRange(2008 - 10, 21), "Year range - changeable default");
 -      inp.datepicker("hide").datepicker("option", {yearRange: "c-6:c+2", changeYear: true}).datepicker("show");
 -      equal(dp.find(".ui-datepicker-year").text(), genRange(2008 - 6, 9), "Year range - c-6:c+2");
 -      inp.datepicker("hide").datepicker("option", {yearRange: "2000:2010", changeYear: true}).datepicker("show");
 -      equal(dp.find(".ui-datepicker-year").text(), genRange(2000, 11), "Year range - 2000:2010");
 -      inp.datepicker("hide").datepicker("option", {yearRange: "-5:+3", changeYear: true}).datepicker("show");
 -      equal(dp.find(".ui-datepicker-year").text(), genRange(curYear - 5, 9), "Year range - -5:+3");
 -      inp.datepicker("hide").datepicker("option", {yearRange: "2000:-5", changeYear: true}).datepicker("show");
 -      equal(dp.find(".ui-datepicker-year").text(), genRange(2000, curYear - 2004), "Year range - 2000:-5");
 -      inp.datepicker("hide").datepicker("option", {yearRange: "", changeYear: true}).datepicker("show");
 -      equal(dp.find(".ui-datepicker-year").text(), genRange(curYear, 1), "Year range - -6:+2");
 -
 -      // Navigation as date format
 -      inp.datepicker("option", {showButtonPanel: true});
 -      equal(dp.find(".ui-datepicker-prev").text(), "Prev", "Navigation prev - default");
 -      equal(dp.find(".ui-datepicker-current").text(), "Today", "Navigation current - default");
 -      equal(dp.find(".ui-datepicker-next").text(), "Next", "Navigation next - default");
 -      inp.datepicker("hide").datepicker("option", {navigationAsDateFormat: true, prevText: "< M", currentText: "MM", nextText: "M >"}).
 -              val("02/04/2008").datepicker("show");
 -      longNames = $.datepicker.regional[""].monthNames;
 -      shortNames = $.datepicker.regional[""].monthNamesShort;
 -      date = new Date();
 -      equal(dp.find(".ui-datepicker-prev").text(), "< " + shortNames[0], "Navigation prev - as date format");
 -      equal(dp.find(".ui-datepicker-current").text(),
 -              longNames[date.getMonth()], "Navigation current - as date format");
 -      equal(dp.find(".ui-datepicker-next").text(),
 -              shortNames[2] + " >", "Navigation next - as date format");
 -      inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN});
 -      equal(dp.find(".ui-datepicker-prev").text(),
 -              "< " + shortNames[1], "Navigation prev - as date format + pgdn");
 -      equal(dp.find(".ui-datepicker-current").text(),
 -              longNames[date.getMonth()], "Navigation current - as date format + pgdn");
 -      equal(dp.find(".ui-datepicker-next").text(),
 -              shortNames[3] + " >", "Navigation next - as date format + pgdn");
 -      inp.datepicker("hide").datepicker("option", {gotoCurrent: true}).
 -              val("02/04/2008").datepicker("show");
 -      equal(dp.find(".ui-datepicker-prev").text(),
 -              "< " + shortNames[0], "Navigation prev - as date format + goto current");
 -      equal(dp.find(".ui-datepicker-current").text(),
 -              longNames[1], "Navigation current - as date format + goto current");
 -      equal(dp.find(".ui-datepicker-next").text(),
 -              shortNames[2] + " >", "Navigation next - as date format + goto current");
  });
  
 -test("minMax", function() {
 -      expect( 23 );
 -      var date,
 -              inp = testHelper.init("#inp"),
 -              dp = $("#ui-datepicker-div"),
 -              lastYear = new Date(2007, 6 - 1, 4),
 -              nextYear = new Date(2009, 6 - 1, 4),
 -              minDate = new Date(2008, 2 - 1, 29),
 -              maxDate = new Date(2008, 12 - 1, 7);
 -      inp.val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), lastYear,
 -              "Min/max - null, null - ctrl+pgup");
 -      inp.val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), nextYear,
 -              "Min/max - null, null - ctrl+pgdn");
 -      inp.datepicker("option", {minDate: minDate}).
 -              datepicker("hide").val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), minDate,
 -              "Min/max - 02/29/2008, null - ctrl+pgup");
 -      inp.val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), nextYear,
 -              "Min/max - 02/29/2008, null - ctrl+pgdn");
 -      inp.datepicker("option", {maxDate: maxDate}).
 -              datepicker("hide").val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), minDate,
 -              "Min/max - 02/29/2008, 12/07/2008 - ctrl+pgup");
 -      inp.val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), maxDate,
 -              "Min/max - 02/29/2008, 12/07/2008 - ctrl+pgdn");
 -      inp.datepicker("option", {minDate: null}).
 -              datepicker("hide").val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), lastYear,
 -              "Min/max - null, 12/07/2008 - ctrl+pgup");
 -      inp.val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), maxDate,
 -              "Min/max - null, 12/07/2008 - ctrl+pgdn");
 -      // Relative dates
 -      date = new Date();
 -      date.setDate(date.getDate() - 7);
 -      inp.datepicker("option", {minDate: "-1w", maxDate: "+1 M +10 D "}).
 -              datepicker("hide").val("").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), date,
 -              "Min/max - -1w, +1 M +10 D - ctrl+pgup");
 -      date = testHelper.addMonths(new Date(), 1);
 -      date.setDate(date.getDate() + 10);
 -      inp.val("").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      testHelper.equalsDate(inp.datepicker("getDate"), date,
 -              "Min/max - -1w, +1 M +10 D - ctrl+pgdn");
 -      // With existing date
 -      inp = testHelper.init("#inp");
 -      inp.val("06/04/2008").datepicker("option", {minDate: minDate});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min");
 -      inp.datepicker("option", {minDate: null}).val("01/04/2008").datepicker("option", {minDate: minDate});
 -      testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min");
 -      inp.datepicker("option", {minDate: null}).val("06/04/2008").datepicker("option", {maxDate: maxDate});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate < max");
 -      inp.datepicker("option", {maxDate: null}).val("01/04/2009").datepicker("option", {maxDate: maxDate});
 -      testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max");
 -      inp.datepicker("option", {maxDate: null}).val("01/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate});
 -      testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min");
 -      inp.datepicker("option", {maxDate: null}).val("06/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate});
 -      testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min, < max");
 -      inp.datepicker("option", {maxDate: null}).val("01/04/2009").datepicker("option", {minDate: minDate, maxDate: maxDate});
 -      testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max");
 -
 -      inp.datepicker("option", {yearRange: "-0:+1"}).val("01/01/" + new Date().getFullYear());
 -      ok(dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - previous button disabled at 1/1/minYear");
 -      inp.datepicker("setDate", "12/30/" + new Date().getFullYear());
 -      ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled at 12/30/maxYear");
 -
 -      inp.datepicker("option", {
 -              minDate: new Date(1900, 0, 1),
 -              maxDate: "-7Y",
 -              yearRange: "1900:-7"
 -      }).val( "" );
 -      ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - relative - next button disabled");
 -      ok(!dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - relative - prev button enabled");
 -
 -      inp.datepicker("option", {
 -              minDate: new Date(1900, 0, 1),
 -              maxDate: "1/25/2007",
 -              yearRange: "1900:2007"
 -      }).val( "" );
 -      ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - absolute - next button disabled");
 -      ok(!dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - absolute - prev button enabled");
 -});
 -
 -test("setDate", function() {
 -      expect( 24 );
 -      var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone,
 -              inp = testHelper.init("#inp"),
 -              date1 = new Date(2008, 6 - 1, 4),
 -              date2 = new Date();
 -      ok(inp.datepicker("getDate") == null, "Set date - default");
 -      inp.datepicker("setDate", date1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - 2008-06-04");
 -      date1 = new Date();
 -      date1.setDate(date1.getDate() + 7);
 -      inp.datepicker("setDate", +7);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - +7");
 -      date2.setFullYear(date2.getFullYear() + 2);
 -      inp.datepicker("setDate", "+2y");
 -      testHelper.equalsDate(inp.datepicker("getDate"), date2, "Set date - +2y");
 -      inp.datepicker("setDate", date1, date2);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - two dates");
 -      inp.datepicker("setDate");
 -      ok(inp.datepicker("getDate") == null, "Set date - null");
 -      // Relative to current date
 -      date1 = new Date();
 -      date1.setDate(date1.getDate() + 7);
 -      inp.datepicker("setDate", "c +7");
 -      testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - c +7");
 -      date1.setDate(date1.getDate() + 7);
 -      inp.datepicker("setDate", "c+7");
 -      testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - c+7");
 -      date1.setDate(date1.getDate() - 21);
 -      inp.datepicker("setDate", "c -3 w");
 -      testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - c -3 w");
 -      // Inline
 -      inl = testHelper.init("#inl");
 -      date1 = new Date(2008, 6 - 1, 4);
 -      date2 = new Date();
 -      testHelper.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - default");
 -      inl.datepicker("setDate", date1);
 -      testHelper.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - 2008-06-04");
 -      date1 = new Date();
 -      date1.setDate(date1.getDate() + 7);
 -      inl.datepicker("setDate", +7);
 -      testHelper.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - +7");
 -      date2.setFullYear(date2.getFullYear() + 2);
 -      inl.datepicker("setDate", "+2y");
 -      testHelper.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - +2y");
 -      inl.datepicker("setDate", date1, date2);
 -      testHelper.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - two dates");
 -      inl.datepicker("setDate");
 -      ok(inl.datepicker("getDate") == null, "Set date inline - null");
 -      // Alternate field
 -      alt = $("#alt");
 -      inp.datepicker("option", {altField: "#alt", altFormat: "yy-mm-dd"});
 -      date1 = new Date(2008, 6 - 1, 4);
 -      inp.datepicker("setDate", date1);
 -      equal(inp.val(), "06/04/2008", "Set date alternate - 06/04/2008");
 -      equal(alt.val(), "2008-06-04", "Set date alternate - 2008-06-04");
 -      // With minimum/maximum
 -      inp = testHelper.init("#inp");
 -      date1 = new Date(2008, 1 - 1, 4);
 -      date2 = new Date(2008, 6 - 1, 4);
 -      minDate = new Date(2008, 2 - 1, 29);
 -      maxDate = new Date(2008, 3 - 1, 28);
 -      inp.val("").datepicker("option", {minDate: minDate}).datepicker("setDate", date2);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date2, "Set date min/max - setDate > min");
 -      inp.datepicker("setDate", date1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min");
 -      inp.val("").datepicker("option", {maxDate: maxDate, minDate: null}).datepicker("setDate", date1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date min/max - setDate < max");
 -      inp.datepicker("setDate", date2);
 -      testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max");
 -      inp.val("").datepicker("option", {minDate: minDate}).datepicker("setDate", date1);
 -      testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min");
 -      inp.datepicker("setDate", date2);
 -      testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max");
 -      dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0);
 -      dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0);
 -      inp.datepicker("setDate", dateAndTimeToSet);
 -      equal(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), "Date object passed should not be changed by setDate");
 -});
 -
 -test("altField", function() {
 -      expect( 10 );
 -      var inp = testHelper.init("#inp"),
 -              alt = $("#alt");
 -      // No alternate field set
 -      alt.val("");
 -      inp.val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      equal(inp.val(), "06/04/2008", "Alt field - dp - enter");
 -      equal(alt.val(), "", "Alt field - alt not set");
 -      // Alternate field set
 -      alt.val("");
 -      inp.datepicker("option", {altField: "#alt", altFormat: "yy-mm-dd"}).
 -              val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      equal(inp.val(), "06/04/2008", "Alt field - dp - enter");
 -      equal(alt.val(), "2008-06-04", "Alt field - alt - enter");
 -      // Move from initial date
 -      alt.val("");
 -      inp.val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      equal(inp.val(), "07/04/2008", "Alt field - dp - pgdn");
 -      equal(alt.val(), "2008-07-04", "Alt field - alt - pgdn");
 -      // Alternate field set - closed
 -      alt.val("");
 -      inp.val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
 -              simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
 -      equal(inp.val(), "06/04/2008", "Alt field - dp - pgdn/esc");
 -      equal(alt.val(), "", "Alt field - alt - pgdn/esc");
 -      // Clear date and alternate
 -      alt.val("");
 -      inp.val("06/04/2008").datepicker("show");
 -      inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END});
 -      equal(inp.val(), "", "Alt field - dp - ctrl+end");
 -      equal(alt.val(), "", "Alt field - alt - ctrl+end");
 -});
 -
 -test("autoSize", function() {
 -      expect( 15 );
 -      var inp = testHelper.init("#inp");
 -      equal(inp.prop("size"), 20, "Auto size - default");
 -      inp.datepicker("option", "autoSize", true);
 -      equal(inp.prop("size"), 10, "Auto size - mm/dd/yy");
 -      inp.datepicker("option", "dateFormat", "m/d/yy");
 -      equal(inp.prop("size"), 10, "Auto size - m/d/yy");
 -      inp.datepicker("option", "dateFormat", "D M d yy");
 -      equal(inp.prop("size"), 15, "Auto size - D M d yy");
 -      inp.datepicker("option", "dateFormat", "DD, MM dd, yy");
 -      equal(inp.prop("size"), 29, "Auto size - DD, MM dd, yy");
 -
 -      // French
 -      inp.datepicker("option", $.extend({autoSize: false}, $.datepicker.regional.fr));
 -      equal(inp.prop("size"), 29, "Auto size - fr - default");
 -      inp.datepicker("option", "autoSize", true);
 -      equal(inp.prop("size"), 10, "Auto size - fr - dd/mm/yy");
 -      inp.datepicker("option", "dateFormat", "m/d/yy");
 -      equal(inp.prop("size"), 10, "Auto size - fr - m/d/yy");
 -      inp.datepicker("option", "dateFormat", "D M d yy");
 -      equal(inp.prop("size"), 18, "Auto size - fr - D M d yy");
 -      inp.datepicker("option", "dateFormat", "DD, MM dd, yy");
 -      equal(inp.prop("size"), 28, "Auto size - fr - DD, MM dd, yy");
 -
 -      // Hebrew
 -      inp.datepicker("option", $.extend({autoSize: false}, $.datepicker.regional.he));
 -      equal(inp.prop("size"), 28, "Auto size - he - default");
 -      inp.datepicker("option", "autoSize", true);
 -      equal(inp.prop("size"), 10, "Auto size - he - dd/mm/yy");
 -      inp.datepicker("option", "dateFormat", "m/d/yy");
 -      equal(inp.prop("size"), 10, "Auto size - he - m/d/yy");
 -      inp.datepicker("option", "dateFormat", "D M d yy");
 -      equal(inp.prop("size"), 16, "Auto size - he - D M d yy");
 -      inp.datepicker("option", "dateFormat", "DD, MM dd, yy");
 -      equal(inp.prop("size"), 23, "Auto size - he - DD, MM dd, yy");
 -});
 -
 -test("daylightSaving", function() {
 -      expect( 25 );
 -      var inp = testHelper.init("#inp"),
 -              dp = $("#ui-datepicker-div");
 -      ok(true, "Daylight saving - " + new Date());
 -      // Australia, Sydney - AM change, southern hemisphere
 -      inp.val("04/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(6) a", dp).simulate("click");
 -      equal(inp.val(), "04/05/2008", "Daylight saving - Australia 04/05/2008");
 -      inp.val("04/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(7) a", dp).simulate("click");
 -      equal(inp.val(), "04/06/2008", "Daylight saving - Australia 04/06/2008");
 -      inp.val("04/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(8) a", dp).simulate("click");
 -      equal(inp.val(), "04/07/2008", "Daylight saving - Australia 04/07/2008");
 -      inp.val("10/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(6) a", dp).simulate("click");
 -      equal(inp.val(), "10/04/2008", "Daylight saving - Australia 10/04/2008");
 -      inp.val("10/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(7) a", dp).simulate("click");
 -      equal(inp.val(), "10/05/2008", "Daylight saving - Australia 10/05/2008");
 -      inp.val("10/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(8) a", dp).simulate("click");
 -      equal(inp.val(), "10/06/2008", "Daylight saving - Australia 10/06/2008");
 -      // Brasil, Brasilia - midnight change, southern hemisphere
 -      inp.val("02/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(20) a", dp).simulate("click");
 -      equal(inp.val(), "02/16/2008", "Daylight saving - Brasil 02/16/2008");
 -      inp.val("02/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(21) a", dp).simulate("click");
 -      equal(inp.val(), "02/17/2008", "Daylight saving - Brasil 02/17/2008");
 -      inp.val("02/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(22) a", dp).simulate("click");
 -      equal(inp.val(), "02/18/2008", "Daylight saving - Brasil 02/18/2008");
 -      inp.val("10/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(13) a", dp).simulate("click");
 -      equal(inp.val(), "10/11/2008", "Daylight saving - Brasil 10/11/2008");
 -      inp.val("10/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(14) a", dp).simulate("click");
 -      equal(inp.val(), "10/12/2008", "Daylight saving - Brasil 10/12/2008");
 -      inp.val("10/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(15) a", dp).simulate("click");
 -      equal(inp.val(), "10/13/2008", "Daylight saving - Brasil 10/13/2008");
 -      // Lebanon, Beirut - midnight change, northern hemisphere
 -      inp.val("03/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(34) a", dp).simulate("click");
 -      equal(inp.val(), "03/29/2008", "Daylight saving - Lebanon 03/29/2008");
 -      inp.val("03/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(35) a", dp).simulate("click");
 -      equal(inp.val(), "03/30/2008", "Daylight saving - Lebanon 03/30/2008");
 -      inp.val("03/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(36) a", dp).simulate("click");
 -      equal(inp.val(), "03/31/2008", "Daylight saving - Lebanon 03/31/2008");
 -      inp.val("10/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(27) a", dp).simulate("click");
 -      equal(inp.val(), "10/25/2008", "Daylight saving - Lebanon 10/25/2008");
 -      inp.val("10/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(28) a", dp).simulate("click");
 -      equal(inp.val(), "10/26/2008", "Daylight saving - Lebanon 10/26/2008");
 -      inp.val("10/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(29) a", dp).simulate("click");
 -      equal(inp.val(), "10/27/2008", "Daylight saving - Lebanon 10/27/2008");
 -      // US, Eastern - AM change, northern hemisphere
 -      inp.val("03/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(13) a", dp).simulate("click");
 -      equal(inp.val(), "03/08/2008", "Daylight saving - US 03/08/2008");
 -      inp.val("03/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(14) a", dp).simulate("click");
 -      equal(inp.val(), "03/09/2008", "Daylight saving - US 03/09/2008");
 -      inp.val("03/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(15) a", dp).simulate("click");
 -      equal(inp.val(), "03/10/2008", "Daylight saving - US 03/10/2008");
 -      inp.val("11/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(6) a", dp).simulate("click");
 -      equal(inp.val(), "11/01/2008", "Daylight saving - US 11/01/2008");
 -      inp.val("11/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(7) a", dp).simulate("click");
 -      equal(inp.val(), "11/02/2008", "Daylight saving - US 11/02/2008");
 -      inp.val("11/01/2008").datepicker("show");
 -      $(".ui-datepicker-calendar td:eq(8) a", dp).simulate("click");
 -      equal(inp.val(), "11/03/2008", "Daylight saving - US 11/03/2008");
 -});
 -
 -var beforeShowThis = null,
 -      beforeShowInput = null,
 -      beforeShowInst = null,
 -      beforeShowDayThis = null,
 -      beforeShowDayOK = true;
 -
 -function beforeAll(input, inst) {
 -      beforeShowThis = this;
 -      beforeShowInput = input;
 -      beforeShowInst = inst;
 -      return {currentText: "Current"};
 -}
 -
 -function beforeDay(date) {
 -      beforeShowDayThis = this;
 -      beforeShowDayOK &= (date > new Date(2008, 1 - 1, 26) &&
 -              date < new Date(2008, 3 - 1, 6));
 -      return [(date.getDate() % 2 === 0), (date.getDate() % 10 === 0 ? "day10" : ""),
 -              (date.getDate() % 3 === 0 ? "Divisble by 3" : "")];
 -}
 -
 -test("callbacks", function() {
 -      expect( 13 );
 -      // Before show
 -      var dp, day20, day21,
 -              inp = testHelper.init("#inp", {beforeShow: beforeAll}),
 -              inst = $.data(inp[0], "datepicker");
 -      equal($.datepicker._get(inst, "currentText"), "Today", "Before show - initial");
 -      inp.val("02/04/2008").datepicker("show");
 -      equal($.datepicker._get(inst, "currentText"), "Current", "Before show - changed");
 -      ok(beforeShowThis.id === inp[0].id, "Before show - this OK");
 -      ok(beforeShowInput.id === inp[0].id, "Before show - input OK");
 -      deepEqual(beforeShowInst, inst, "Before show - inst OK");
 -      inp.datepicker("hide").datepicker("destroy");
 -      // Before show day
 -      inp = testHelper.init("#inp", {beforeShowDay: beforeDay});
 -      dp = $("#ui-datepicker-div");
 -      inp.val("02/04/2008").datepicker("show");
 -      ok(beforeShowDayThis.id === inp[0].id, "Before show day - this OK");
 -      ok(beforeShowDayOK, "Before show day - dates OK");
 -      day20 = dp.find(".ui-datepicker-calendar td:contains('20')");
 -      day21 = dp.find(".ui-datepicker-calendar td:contains('21')");
 -      ok(!day20.is(".ui-datepicker-unselectable"), "Before show day - unselectable 20");
 -      ok(day21.is(".ui-datepicker-unselectable"), "Before show day - unselectable 21");
 -      ok(day20.is(".day10"), "Before show day - CSS 20");
 -      ok(!day21.is(".day10"), "Before show day - CSS 21");
 -      ok(!day20.attr("title"), "Before show day - title 20");
 -      ok(day21.attr("title") === "Divisble by 3", "Before show day - title 21");
 -      inp.datepicker("hide").datepicker("destroy");
 -});
 -
 -test("beforeShowDay - tooltips with quotes", function() {
 -      expect( 1 );
 -      var inp, dp;
 -      inp = testHelper.init("#inp", {
 -              beforeShowDay: function() {
 -                      return [ true, "", "'" ];
 -              }
 -      });
 -      dp = $("#ui-datepicker-div");
 -
 -      inp.datepicker("show");
 -      equal( dp.find( ".ui-datepicker-calendar td:contains('9')").attr( "title" ), "'" );
 -      inp.datepicker("hide").datepicker("destroy");
 -});
 -
 -test("localisation", function() {
 -      expect( 24 );
 -      var dp, month, day, date,
 -              inp = testHelper.init("#inp", $.datepicker.regional.fr);
 -      inp.datepicker("option", {dateFormat: "DD, d MM yy", showButtonPanel:true, changeMonth:true, changeYear:true}).val("").datepicker("show");
 -      dp = $("#ui-datepicker-div");
 -      equal($(".ui-datepicker-close", dp).text(), "Fermer", "Localisation - close");
 -      $(".ui-datepicker-close", dp).simulate("mouseover");
 -      equal($(".ui-datepicker-prev", dp).text(), "Précédent", "Localisation - previous");
 -      equal($(".ui-datepicker-current", dp).text(), "Aujourd'hui", "Localisation - current");
 -      equal($(".ui-datepicker-next", dp).text(), "Suivant", "Localisation - next");
 -      month = 0;
 -      $(".ui-datepicker-month option", dp).each(function() {
 -              equal($(this).text(), $.datepicker.regional.fr.monthNamesShort[month],
 -                      "Localisation - month " + month);
 -              month++;
 -      });
 -      day = 1;
 -      $(".ui-datepicker-calendar th", dp).each(function() {
 -              equal($(this).text(), $.datepicker.regional.fr.dayNamesMin[day],
 -                      "Localisation - day " + day);
 -              day = (day + 1) % 7;
 +asyncTest( "position", function(assert) {
 +      expect( 3 );
 +      var input = $( "<input>" ).datepicker().appendTo( "body" ).css({
 +                      position: "absolute",
 +                      top: 0,
 +                      left: 0
 +              }),
 +              container = input.datepicker( "widget" );
 +
 +      input.datepicker( "open" );
 +      setTimeout(function() {
 +              assert.close( input.offset().left, container.offset().left, 1, "left sides line up by default" );
 +              assert.close( container.offset().top, input.offset().top + input.outerHeight(), 1,
 +                      "datepicker directly under input by default" );
 +
 +              // Change the position option using option()
 +              input.datepicker( "option", "position", {
 +                      my: "left top",
 +                      at: "right bottom"
 +              });
 +              assert.close( container.offset().left, input.offset().left + input.outerWidth(), 1,
 +                      "datepicker on right hand side of input after position change" );
 +
 +              input.remove();
 +              start();
        });
 -      inp.simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
 -      date = new Date();
 -      equal(inp.val(), $.datepicker.regional.fr.dayNames[date.getDay()] + ", " +
 -              date.getDate() + " " + $.datepicker.regional.fr.monthNames[date.getMonth()] +
 -              " " + date.getFullYear(), "Localisation - formatting");
 -});
 -
 -test("noWeekends", function() {
 -      expect( 31 );
 -      var i, date;
 -      for (i = 1; i <= 31; i++) {
 -              date = new Date(2001, 1 - 1, i);
 -              deepEqual($.datepicker.noWeekends(date), [(i + 1) % 7 >= 2, ""],
 -                      "No weekends " + date);
 -      }
 -});
 -
 -test("iso8601Week", function() {
 -      expect( 12 );
 -      var date = new Date(2000, 12 - 1, 31);
 -      equal($.datepicker.iso8601Week(date), 52, "ISO 8601 week " + date);
 -      date = new Date(2001, 1 - 1, 1);
 -      equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
 -      date = new Date(2001, 1 - 1, 7);
 -      equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
 -      date = new Date(2001, 1 - 1, 8);
 -      equal($.datepicker.iso8601Week(date), 2, "ISO 8601 week " + date);
 -      date = new Date(2003, 12 - 1, 28);
 -      equal($.datepicker.iso8601Week(date), 52, "ISO 8601 week " + date);
 -      date = new Date(2003, 12 - 1, 29);
 -      equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
 -      date = new Date(2004, 1 - 1, 4);
 -      equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
 -      date = new Date(2004, 1 - 1, 5);
 -      equal($.datepicker.iso8601Week(date), 2, "ISO 8601 week " + date);
 -      date = new Date(2009, 12 - 1, 28);
 -      equal($.datepicker.iso8601Week(date), 53, "ISO 8601 week " + date);
 -      date = new Date(2010, 1 - 1, 3);
 -      equal($.datepicker.iso8601Week(date), 53, "ISO 8601 week " + date);
 -      date = new Date(2010, 1 - 1, 4);
 -      equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
 -      date = new Date(2010, 1 - 1, 10);
 -      equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
  });
  
 -test("parseDate", function() {
 -      expect( 26 );
 -      testHelper.init("#inp");
 -      var currentYear, gmtDate, fr, settings, zh;
 -      ok($.datepicker.parseDate("d m y", "") == null, "Parse date empty");
 -      testHelper.equalsDate($.datepicker.parseDate("d m y", "3 2 01"),
 -              new Date(2001, 2 - 1, 3), "Parse date d m y");
 -      testHelper.equalsDate($.datepicker.parseDate("dd mm yy", "03 02 2001"),
 -              new Date(2001, 2 - 1, 3), "Parse date dd mm yy");
 -      testHelper.equalsDate($.datepicker.parseDate("d m y", "13 12 01"),
 -              new Date(2001, 12 - 1, 13), "Parse date d m y");
 -      testHelper.equalsDate($.datepicker.parseDate("dd mm yy", "13 12 2001"),
 -              new Date(2001, 12 - 1, 13), "Parse date dd mm yy");
 -      testHelper.equalsDate($.datepicker.parseDate("y-o", "01-34"),
 -              new Date(2001, 2 - 1, 3), "Parse date y-o");
 -      testHelper.equalsDate($.datepicker.parseDate("yy-oo", "2001-347"),
 -              new Date(2001, 12 - 1, 13), "Parse date yy-oo");
 -      testHelper.equalsDate($.datepicker.parseDate("oo yy", "348 2004"),
 -              new Date(2004, 12 - 1, 13), "Parse date oo yy");
 -      testHelper.equalsDate($.datepicker.parseDate("D d M y", "Sat 3 Feb 01"),
 -              new Date(2001, 2 - 1, 3), "Parse date D d M y");
 -      testHelper.equalsDate($.datepicker.parseDate("d MM DD yy", "3 February Saturday 2001"),
 -              new Date(2001, 2 - 1, 3), "Parse date dd MM DD yy");
 -      testHelper.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Saturday, February 3, 2001"),
 -              new Date(2001, 2 - 1, 3), "Parse date DD, MM d, yy");
 -      testHelper.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");
 -      currentYear = new Date().getFullYear();
 -      testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000) + "-02-03"),
 -                      new Date(currentYear, 2 - 1, 3), "Parse date y-m-d - default cutuff");
 -      testHelper.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");
 -      testHelper.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");
 -      testHelper.equalsDate($.datepicker.parseDate("y-m-d", "80-02-03", {shortYearCutoff: 80}),
 -              new Date(2080, 2 - 1, 3), "Parse date y-m-d - cutoff 80");
 -      testHelper.equalsDate($.datepicker.parseDate("y-m-d", "81-02-03", {shortYearCutoff: 80}),
 -              new Date(1981, 2 - 1, 3), "Parse date y-m-d - cutoff 80");
 -      testHelper.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");
 -      testHelper.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");
 -      gmtDate = new Date(2001, 2 - 1, 3);
 -      gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset());
 -      testHelper.equalsDate($.datepicker.parseDate("@", "981158400000"), gmtDate, "Parse date @");
 -      testHelper.equalsDate($.datepicker.parseDate("!", "631167552000000000"), gmtDate, "Parse date !");
 -
 -      fr = $.datepicker.regional.fr;
 -      settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
 -              monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
 -      testHelper.equalsDate($.datepicker.parseDate("D d M y", "Lun. 9 avr. 01", settings),
 -              new Date(2001, 4 - 1, 9), "Parse date D M y with settings");
 -      testHelper.equalsDate($.datepicker.parseDate("d MM DD yy", "9 Avril Lundi 2001", settings),
 -              new Date(2001, 4 - 1, 9), "Parse date d MM DD yy with settings");
 -      testHelper.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Lundi, Avril 9, 2001", settings),
 -              new Date(2001, 4 - 1, 9), "Parse date DD, MM d, yy with settings");
 -      testHelper.equalsDate($.datepicker.parseDate("'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings),
 -              new Date(2001, 4 - 1, 9), "Parse date 'jour' d 'de' MM (''DD''), yy with settings");
 -
 -      zh = $.datepicker.regional["zh-CN"];
 -      testHelper.equalsDate($.datepicker.parseDate("yy M d", "2011 十一月 22", zh),
 -              new Date(2011, 11 - 1, 22), "Parse date yy M d with zh-CN");
 -});
 -
 -test("parseDateErrors", function() {
 -      expect( 18 );
 -      testHelper.init("#inp");
 -      var fr, settings;
 -      function expectError(expr, value, error) {
 -              try {
 -                      expr();
 -                      ok(false, "Parsed error " + value);
 -              }
 -              catch (e) {
 -                      equal(e, error, "Parsed error " + value);
 -              }
 -      }
 -      expectError(function() { $.datepicker.parseDate(null, "Sat 2 01"); },
 -              "Sat 2 01", "Invalid arguments");
 -      expectError(function() { $.datepicker.parseDate("d m y", null); },
 -              "null", "Invalid arguments");
 -      expectError(function() { $.datepicker.parseDate("d m y", "Sat 2 01"); },
 -              "Sat 2 01 - d m y", "Missing number at position 0");
 -      expectError(function() { $.datepicker.parseDate("dd mm yy", "Sat 2 01"); },
 -              "Sat 2 01 - dd mm yy", "Missing number at position 0");
 -      expectError(function() { $.datepicker.parseDate("d m y", "3 Feb 01"); },
 -              "3 Feb 01 - d m y", "Missing number at position 2");
 -      expectError(function() { $.datepicker.parseDate("dd mm yy", "3 Feb 01"); },
 -              "3 Feb 01 - dd mm yy", "Missing number at position 2");
 -      expectError(function() { $.datepicker.parseDate("mm dd yy", "2 1 01"); },
 -              "2 1 01 - dd mm yy", "Missing number at position 4");
 -      expectError(function() { $.datepicker.parseDate("d m y", "3 2 AD01"); },
 -              "3 2 AD01 - d m y", "Missing number at position 4");
 -      expectError(function() { $.datepicker.parseDate("d m yy", "3 2 AD01"); },
 -              "3 2 AD01 - dd mm yy", "Missing number at position 4");
 -      expectError(function() { $.datepicker.parseDate("y-o", "01-D01"); },
 -              "2001-D01 - y-o", "Missing number at position 3");
 -      expectError(function() { $.datepicker.parseDate("yy-oo", "2001-D01"); },
 -              "2001-D01 - yy-oo", "Missing number at position 5");
 -      expectError(function() { $.datepicker.parseDate("D d M y", "D7 3 Feb 01"); },
 -              "D7 3 Feb 01 - D d M y", "Unknown name at position 0");
 -      expectError(function() { $.datepicker.parseDate("D d M y", "Sat 3 M2 01"); },
 -              "Sat 3 M2 01 - D d M y", "Unknown name at position 6");
 -      expectError(function() { $.datepicker.parseDate("DD, MM d, yy", "Saturday- Feb 3, 2001"); },
 -              "Saturday- Feb 3, 2001 - DD, MM d, yy", "Unexpected literal at position 8");
 -      expectError(function() { $.datepicker.parseDate("'day' d 'of' MM (''DD''), yy",
 -              "day 3 of February (\"Saturday\"), 2001"); },
 -              "day 3 of Mon2 ('Day7'), 2001", "Unexpected literal at position 19");
 -      expectError(function() { $.datepicker.parseDate("d m y", "29 2 01"); },
 -              "29 2 01 - d m y", "Invalid date");
 -      fr = $.datepicker.regional.fr;
 -      settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
 -              monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
 -      expectError(function() { $.datepicker.parseDate("D d M y", "Mon 9 Avr 01", settings); },
 -              "Mon 9 Avr 01 - D d M y", "Unknown name at position 0");
 -      expectError(function() { $.datepicker.parseDate("D d M y", "Lun. 9 Apr 01", settings); },
 -              "Lun. 9 Apr 01 - D d M y", "Unknown name at position 7");
 -});
 -
 -test("Ticket #7244: date parser does not fail when too many numbers are passed into the date function", function() {
 -      expect( 4 );
 -      var date;
 -      try{
 -              date = $.datepicker.parseDate("dd/mm/yy", "18/04/19881");
 -              ok(false, "Did not properly detect an invalid date");
 -      }catch(e){
 -              ok("invalid date detected");
 -      }
 -
 -      try {
 -              date = $.datepicker.parseDate("dd/mm/yy", "18/04/1988 @ 2:43 pm");
 -              equal(date.getDate(), 18);
 -              equal(date.getMonth(), 3);
 -              equal(date.getFullYear(), 1988);
 -      } catch(e) {
 -              ok(false, "Did not properly parse date with extra text separated by whitespace");
 -      }
 -});
 -
 -test("formatDate", function() {
 -      expect( 16 );
 -      testHelper.init("#inp");
 -      var gmtDate, fr, settings;
 -      equal($.datepicker.formatDate("d m y", new Date(2001, 2 - 1, 3)),
 -              "3 2 01", "Format date d m y");
 -      equal($.datepicker.formatDate("dd mm yy", new Date(2001, 2 - 1, 3)),
 -              "03 02 2001", "Format date dd mm yy");
 -      equal($.datepicker.formatDate("d m y", new Date(2001, 12 - 1, 13)),
 -              "13 12 01", "Format date d m y");
 -      equal($.datepicker.formatDate("dd mm yy", new Date(2001, 12 - 1, 13)),
 -              "13 12 2001", "Format date dd mm yy");
 -      equal($.datepicker.formatDate("yy-o", new Date(2001, 2 - 1, 3)),
 -              "2001-34", "Format date yy-o");
 -      equal($.datepicker.formatDate("yy-oo", new Date(2001, 2 - 1, 3)),
 -              "2001-034", "Format date yy-oo");
 -      equal($.datepicker.formatDate("D M y", new Date(2001, 2 - 1, 3)),
 -              "Sat Feb 01", "Format date D M y");
 -      equal($.datepicker.formatDate("DD MM yy", new Date(2001, 2 - 1, 3)),
 -              "Saturday February 2001", "Format date DD MM yy");
 -      equal($.datepicker.formatDate("DD, MM d, yy", new Date(2001, 2 - 1, 3)),
 -              "Saturday, February 3, 2001", "Format date DD, MM d, yy");
 -      equal($.datepicker.formatDate("'day' d 'of' MM (''DD''), yy",
 -              new Date(2001, 2 - 1, 3)), "day 3 of February ('Saturday'), 2001",
 -              "Format date 'day' d 'of' MM ('DD'), yy");
 -      gmtDate = new Date(2001, 2 - 1, 3);
 -      gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset());
 -      equal($.datepicker.formatDate("@", gmtDate), "981158400000", "Format date @");
 -      equal($.datepicker.formatDate("!", gmtDate), "631167552000000000", "Format date !");
 -      fr = $.datepicker.regional.fr;
 -      settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
 -              monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
 -      equal($.datepicker.formatDate("D M y", new Date(2001, 4 - 1, 9), settings),
 -              "lun. avr. 01", "Format date D M y with settings");
 -      equal($.datepicker.formatDate("DD MM yy", new Date(2001, 4 - 1, 9), settings),
 -              "lundi avril 2001", "Format date DD MM yy with settings");
 -      equal($.datepicker.formatDate("DD, MM d, yy", new Date(2001, 4 - 1, 9), settings),
 -              "lundi, avril 9, 2001", "Format date DD, MM d, yy with settings");
 -      equal($.datepicker.formatDate("'jour' d 'de' MM (''DD''), yy",
 -              new Date(2001, 4 - 1, 9), settings), "jour 9 de avril ('lundi'), 2001",
 -              "Format date 'jour' d 'de' MM (''DD''), yy with settings");
 -});
 -
 -// TODO: Fix this test so it isn't mysteriously flaky in Browserstack on certain OS/Browser combos
 -// test("Ticket 6827: formatDate day of year calculation is wrong during day lights savings time", function(){
 -//    expect( 1 );
 -//    var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
 -//    equal(time, "089");
 -// });
 -
 -test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler", function() {
 +test( "Stop datepicker from appearing with beforeOpen event handler", function() {
        expect( 3 );
  
 -      var inp, dp;
 -
 -      inp = testHelper.init( "#inp", {
 -              beforeShow: function() {
 -              }
 +      var input = testHelper.init( "#datepicker", {
 +              beforeOpen: function() {}
        });
 -      dp = $( "#ui-datepicker-div" );
 -      inp.datepicker( "show" );
 -      equal( dp.css( "display" ), "block", "beforeShow returns nothing" );
 -      inp.datepicker( "hide" ).datepicker( "destroy" );
  
 -      inp = testHelper.init( "#inp", {
 -              beforeShow: function() {
 +      input.datepicker( "open" );
 +      ok( input.datepicker( "widget" ).is( ":visible" ), "beforeOpen returns nothing" );
 +      input.datepicker( "close" ).datepicker( "destroy" );
 +
 +      input = testHelper.init( "#datepicker", {
 +              beforeOpen: function() {
                        return true;
                }
        });
index 424932da44edb8c110e7862b13d8ee70b0974b09,d43c968cdb9d12237572d3041bc1997575d4d77b..6a9d3e9b74c29d6d25ff211f711e54e748b82c24
@@@ -1,8 -1,8 +1,8 @@@
  define( [
        "jquery",
-       "ui/spinner",
+       "ui/widgets/spinner",
 -      "globalize",
 -      "globalize/ja-JP"
 +      "globalize-old",
 +      "globalize-old/ja-JP"
  ], function( $ ) {
  
  module( "spinner: options" );
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..947d79d8d7118fdd6b132c2ef3b5c03f8d804a0a
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,657 @@@
++/*!
++ * jQuery UI Calendar @VERSION
++ * http://jqueryui.com
++ *
++ * Copyright 2014 jQuery Foundation and other contributors
++ * Released under the MIT license.
++ * http://jquery.org/license
++ */
++
++//>>label: Datepicker
++//>>group: Widgets
++//>>description: Displays a calendar for inline date selection.
++//>>docs: http://api.jqueryui.com/calendar/
++//>>demos: http://jqueryui.com/calendar/
++
++( function( factory ) {
++      if ( typeof define === "function" && define.amd ) {
++
++              // AMD. Register as an anonymous module.
++              // TODO: Keep button even if its optional?
++              define( [
++                      "jquery",
++                      "globalize",
++                      "globalize/date",
++                      "globalize-locales",
++                      "date",
++                      "./button",
++                      "../widget",
++                      "../version",
++                      "../keycode",
++                      "../unique-id",
++                      "../tabbable"
++              ], factory );
++      } else {
++
++              // Browser globals
++              factory( jQuery, Globalize );
++      }
++}( function( $, Globalize ) {
++
++return $.widget( "ui.calendar", {
++      version: "@VERSION",
++      options: {
++              buttons: [],
++              dateFormat: { date: "short" },
++              eachDay: $.noop,
++              labels: {
++                      "datePickerRole": "date picker",
++                      "nextText": "Next",
++                      "prevText": "Prev",
++                      "weekHeader": "Wk"
++              },
++              locale: "en",
++              max: null,
++              min: null,
++              numberOfMonths: 1,
++              showWeek: false,
++              value: null,
++
++              // callbacks
++              select: null
++      },
++
++      refreshRelatedOptions: {
++              dateFormat: true,
++              eachDay: true,
++              locale: true,
++              max: true,
++              min: true,
++              showWeek: true,
++              value: true
++      },
++
++      _create: function() {
++              this.id = this.element.uniqueId().attr( "id" );
++              this.labels = this.options.labels;
++              this.buttonClickContext = this.element[ 0 ];
++
++              this._setLocale( this.options.locale, this.options.dateFormat );
++
++              this.date = new $.ui.calendarDate( this.options.value, this._calendarDateOptions );
++              this.viewDate = this.date.clone();
++              this.viewDate.eachDay = this.options.eachDay;
++
++              this._on( this.element, {
++                      "click .ui-calendar-prev": function( event ) {
++                              event.preventDefault();
++                              this.date.adjust( "M", -this.options.numberOfMonths );
++                              this._refresh();
++                      },
++                      "click .ui-calendar-next": function( event ) {
++                              event.preventDefault();
++                              this.date.adjust( "M", this.options.numberOfMonths );
++                              this._refresh();
++                      },
++                      "mousedown .ui-calendar-calendar button": function( event ) {
++                              event.preventDefault();
++
++                              this._setOption( "value", new Date( $( event.currentTarget ).data( "timestamp" ) ) );
++                              this.refresh();
++                              this._trigger( "select", event );
++                              this.grid.focus();
++                      },
++                      "mouseenter .ui-calendar-header button": "_hover",
++                      "mouseleave .ui-calendar-header button": "_hover",
++                      "mouseenter .ui-calendar-calendar button": "_hover",
++                      "mouseleave .ui-calendar-calendar button": "_hover",
++                      "keydown .ui-calendar-calendar": "_handleKeydown"
++              } );
++
++              this._createCalendar();
++      },
++
++      _hover: function( event ) {
++              $( event.currentTarget ).toggleClass( "ui-state-hover" );
++      },
++
++      _handleKeydown: function( event ) {
++              switch ( event.keyCode ) {
++              case $.ui.keyCode.ENTER:
++                      this.activeDescendant.mousedown();
++                      return;
++              case $.ui.keyCode.PAGE_UP:
++                      this.date.adjust( event.altKey ? "Y" : "M", -1 );
++                      break;
++              case $.ui.keyCode.PAGE_DOWN:
++                      this.date.adjust( event.altKey ? "Y" : "M", 1 );
++                      break;
++              case $.ui.keyCode.END:
++                      this.date.setDay( this.date.daysInMonth() );
++                      break;
++              case $.ui.keyCode.HOME:
++                      this.date.setDay( 1 );
++                      break;
++              case $.ui.keyCode.LEFT:
++                      this.date.adjust( "D", -1 );
++                      break;
++              case $.ui.keyCode.UP:
++                      this.date.adjust( "D", -7 );
++                      break;
++              case $.ui.keyCode.RIGHT:
++                      this.date.adjust( "D", 1 );
++                      break;
++              case $.ui.keyCode.DOWN:
++                      this.date.adjust( "D", 7 );
++                      break;
++              default:
++                      event.preventDefault();
++                      return;
++              }
++
++              if ( this._needsRefresh() ) {
++                      this._refresh();
++                      this.grid.focus();
++              }
++
++              this._setActiveDescendant();
++      },
++
++      _needsRefresh: function() {
++              if ( this.date.month() !== this.viewDate.month() || this.date.year() !== this.viewDate.year() ) {
++
++                      // Check if the needed day is already present in our grid due
++                      // to eachDay option changes (eg. other-months demo)
++                      return !this.grid.find(
++                                      this._sanitizeSelector( "#" + this._getDayId( this.date ) )
++                              ).length;
++              }
++
++              return false;
++      },
++
++      _setActiveDescendant: function() {
++              var id = this._getDayId( this.date );
++
++              this.grid
++                      .attr( "aria-activedescendant", id )
++                      .find( ".ui-state-focus" )
++                      .removeClass( "ui-state-focus" );
++
++              this.activeDescendant = this.grid.find(
++                      this._sanitizeSelector( "#" + id ) + " > button"
++              ).addClass( "ui-state-focus" );
++      },
++
++      _setLocale: function( locale, dateFormat ) {
++              var globalize = new Globalize( locale ),
++                      weekdayShortFormatter = globalize.dateFormatter({ raw: "EEEEEE" }),
++                      weekdayNarrowFormatter = globalize.dateFormatter({ raw: "EEEEE" });
++
++              this._format = globalize.dateFormatter( dateFormat );
++              this._parse = globalize.dateParser( dateFormat );
++              this._calendarDateOptions = {
++                      firstDay: globalize.cldr.supplemental.weekData.firstDay(),
++                      formatWeekdayShort: function( date ) {
++
++                              // Return the short weekday if its length is < 3. Otherwise, its narrow form.
++                              var shortWeekday = weekdayShortFormatter( date );
++
++                              return shortWeekday.length > 3 ? weekdayNarrowFormatter( date ) : shortWeekday;
++                      },
++                      formatWeekdayFull: globalize.dateFormatter({ raw: "EEEE" }),
++                      formatMonth: globalize.dateFormatter({ raw: "MMMM" }),
++                      formatWeekOfYear: globalize.dateFormatter({ raw: "w" }),
++                      parse: this._parse
++              };
++      },
++
++      _createCalendar: function() {
++              var classes = "ui-calendar ui-widget ui-widget-content ui-helper-clearfix ui-corner-all",
++                      pickerHtml = "";
++
++              if ( this.options.numberOfMonths === 1 ) {
++                      pickerHtml = this._buildHeader() + this._buildGrid();
++              } else {
++                      pickerHtml = this._buildMultiplePicker();
++                      classes += " ui-calendar-multi";
++              }
++
++              this.element
++                      .addClass( classes )
++                      .attr( {
++                              role: "region",
++                              "aria-labelledby": this.id + "-title"
++                      } )
++                      .html( pickerHtml );
++
++              this._createButtonPane();
++
++              this.grid = this.element.find( ".ui-calendar-calendar" );
++      },
++
++      _buildMultiplePicker: function() {
++              var headerClass,
++                      html = "",
++                      currentDate = this.viewDate,
++                      months = this.viewDate.months( this.options.numberOfMonths - 1 ),
++                      i = 0;
++
++              for ( ; i < months.length; i++ ) {
++
++                      // TODO: Shouldn't we pass date as a parameter to build* fns instead of setting this.date?
++                      this.viewDate = months[ i ];
++                      headerClass = "ui-calendar-header ui-widget-header ui-helper-clearfix";
++                      if ( months[ i ].first ) {
++                              headerClass += " ui-corner-left";
++                      } else if ( months[ i ].last ) {
++                              headerClass += " ui-corner-right";
++                      }
++
++                      html += "<div class='ui-calendar-group'>" +
++                              "<div class='" + headerClass + "'>";
++                      if ( months[ i ].first ) {
++                              html += this._buildPreviousLink();
++                      } else if ( months[ i ].last ) {
++                              html += this._buildNextLink();
++                      }
++
++                      html += this._buildTitlebar() + "</div>" + this._buildGrid() + "</div>";
++              }
++
++              html += "<div class='ui-calendar-row-break'></div>";
++
++              this.viewDate = currentDate;
++
++              return html;
++      },
++
++      _buildHeader: function() {
++              return "<div class='ui-calendar-header ui-widget-header ui-helper-clearfix ui-corner-all'>" +
++                              this._buildPreviousLink() +
++                              this._buildNextLink() +
++                              this._buildTitlebar() +
++                      "</div>";
++      },
++
++      _buildPreviousLink: function() {
++              var prevText = this._getTranslation( "prevText" );
++
++              return "<button class='ui-calendar-prev ui-corner-all' title='" +
++                                      prevText + "'>" +
++                      "<span class='ui-icon ui-icon-circle-triangle-w'>" +
++                              prevText +
++                      "</span>" +
++              "</button>";
++      },
++
++      _buildNextLink: function() {
++              var nextText = this._getTranslation( "nextText" );
++
++              return "<button class='ui-calendar-next ui-corner-all' title='" +
++                                      nextText + "'>" +
++                      "<span class='ui-icon ui-icon-circle-triangle-e'>" +
++                              nextText +
++                      "</span>" +
++              "</button>";
++      },
++
++      _buildTitlebar: function() {
++              return "<div role='header' id='" + this.id + "-title'>" +
++                      "<div id='" + this.id + "-month-label' class='ui-calendar-title'>" +
++                                      this._buildTitle() +
++                              "</div>" +
++                              "<span class='ui-helper-hidden-accessible'>, " +
++                                      this._getTranslation( "datePickerRole" ) +
++                              "</span>" +
++                      "</div>";
++      },
++
++      _buildTitle: function() {
++              return "<span class='ui-calendar-month'>" +
++                      this.viewDate.monthName() +
++              "</span> " +
++              "<span class='ui-calendar-year'>" +
++                      this.viewDate.year() +
++              "</span>";
++      },
++
++      _buildGrid: function() {
++              return "<table class='ui-calendar-calendar' role='grid' aria-readonly='true' " +
++                              "aria-labelledby='" + this.id + "-month-label' tabindex='0' " +
++                              "aria-activedescendant='" + this._getDayId( this.date ) + "'>" +
++                              this._buildGridHeading() +
++                              this._buildGridBody() +
++                      "</table>";
++      },
++
++      _buildGridHeading: function() {
++              var cells = "",
++                      i = 0,
++                      weekDayLength = this.viewDate.weekdays().length,
++                      weekdays = this.date.weekdays();
++
++              if ( this.options.showWeek ) {
++                      cells += "<th class='ui-calendar-week-col'>" + this._getTranslation( "weekHeader" ) + "</th>";
++              }
++              for ( ; i < weekDayLength; i++ ) {
++                      cells += this._buildGridHeaderCell( weekdays[ i ] );
++              }
++
++              return "<thead role='presentation'>" +
++                              "<tr role='row'>" + cells + "</tr>" +
++                      "</thead>";
++      },
++
++      _buildGridHeaderCell: function( day ) {
++              return "<th role='columnheader' abbr='" + day.fullname + "' aria-label='" + day.fullname + "'>" +
++                              "<span title='" + day.fullname + "'>" +
++                                      day.shortname +
++                              "</span>" +
++                      "</th>";
++      },
++
++      _buildGridBody: function() {
++              var days = this.viewDate.days(),
++                      i = 0,
++                      rows = "";
++
++              for ( ; i < days.length; i++ ) {
++                      rows += this._buildWeekRow( days[ i ] );
++              }
++
++              return "<tbody role='presentation'>" + rows + "</tbody>";
++      },
++
++      _buildWeekRow: function( week ) {
++              var cells = "",
++                      i = 0;
++
++              if ( this.options.showWeek ) {
++                      cells += "<td class='ui-calendar-week-col'>" + week.number + "</td>";
++              }
++              for ( ; i < week.days.length; i++ ) {
++                      cells += this._buildDayCell( week.days[ i ] );
++              }
++
++              return "<tr role='row'>" + cells + "</tr>";
++      },
++
++      _buildDayCell: function( day ) {
++              var content = "",
++                      attributes = [
++                              "role='gridcell'",
++                              "aria-selected='" + ( this._isCurrent( day ) ? true : false ) + "'"
++                      ],
++                      selectable = ( day.selectable && this._isValid( new Date( day.timestamp ) ) );
++
++              if ( day.render ) {
++                      attributes.push( "id='" + this.id + "-" + day.year + "-" + day.month + "-" + day.date + "'" );
++
++                      if ( !selectable ) {
++                              attributes.push( "aria-disabled='true'" );
++                              attributes.push( "class='ui-state-disabled'" );
++                      }
++
++                      content = this._buildDayElement( day, selectable );
++              }
++
++              return "<td " + attributes.join( " " ) + ">" + content + "</td>";
++      },
++
++      _getDayId: function( date ) {
++              return this.id + "-" + date.year() + "-" + date.month() + "-" + date.day();
++      },
++
++      _buildDayElement: function( day, selectable ) {
++              var attributes, content,
++                      classes = [ "ui-state-default" ];
++
++              if ( day === this.date && selectable ) {
++                      classes.push( "ui-state-focus" );
++              }
++              if ( this._isCurrent( day ) ) {
++                      classes.push( "ui-state-active" );
++              }
++              if ( day.today ) {
++                      classes.push( "ui-state-highlight" );
++              }
++              if ( day.extraClasses ) {
++                      classes.push( day.extraClasses.split( " " ) );
++              }
++
++              attributes = " class='" + classes.join( " " ) + "'";
++              if ( selectable ) {
++                      attributes += " tabindex='-1' data-timestamp='" + day.timestamp + "'";
++              } else {
++                      attributes += " disabled='disabled'";
++              }
++              content = "<button" + attributes + ">" + day.date + "</button>";
++
++              if ( day.today ) {
++                      content += "<span class='ui-helper-hidden-accessible'>, " + this._getTranslation( "currentText" ) + "</span>";
++              }
++
++              return content;
++      },
++
++      _isCurrent: function( day ) {
++              return this.options.value && day.timestamp === this.options.value.getTime();
++      },
++
++      _createButtonPane: function() {
++              this.buttonPane = $( "<div>" )
++                      .addClass( "ui-calendar-buttonpane ui-widget-content ui-helper-clearfix" );
++
++              this.buttonSet = $( "<div>" )
++                      .addClass( "ui-calendar-buttonset" )
++                      .appendTo( this.buttonPane );
++
++              this._createButtons();
++      },
++
++      _createButtons: function() {
++              var that = this,
++                      buttons = this.options.buttons;
++
++              this.buttonPane.remove();
++              this.buttonSet.empty();
++
++              if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) {
++                      this.element.removeClass( "ui-calendar-buttons" );
++                      return;
++              }
++
++              $.each( buttons, function( name, props ) {
++                      var click, buttonOptions;
++                      props = $.isFunction( props ) ?
++                              { click: props, text: name } :
++                              props;
++
++                      // Default to a non-submitting button
++                      props = $.extend( { type: "button" }, props );
++
++                      // Change the context for the click callback to be the main element
++                      click = props.click;
++                      props.click = function() {
++                              click.apply( that.buttonClickContext, arguments );
++                      };
++                      buttonOptions = {
++                              icons: props.icons,
++                              text: props.showText
++                      };
++                      delete props.icons;
++                      delete props.showText;
++                      $( "<button></button>", props )
++                              .button( buttonOptions )
++                              .appendTo( that.buttonSet );
++              } );
++              this.element.addClass( "ui-calendar-buttons" );
++              this.buttonPane.appendTo( this.element );
++      },
++
++      _refresh: function() {
++              this.viewDate.setTime( this.date.date().getTime() );
++              this.refresh();
++      },
++
++      // Refreshing the entire calendar 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
++      // with the prev and next links would cause loss of focus issues because the links being
++      // interacted with will disappear while focused.
++      refresh: function() {
++              this.labels = this.options.labels;
++
++              // Determine which day gridcell to focus after refresh
++              // TODO: Prevent disabled cells from being focused
++              if ( this.options.numberOfMonths === 1 ) {
++                      this.grid = $( this._buildGrid() );
++                      this.element.find( ".ui-calendar-title" ).html( this._buildTitle() );
++                      this.element.find( ".ui-calendar-calendar" ).replaceWith( this.grid );
++                      $( ".ui-calendar-prev", this.element ).attr( "title", this.labels.prevText )
++                              .children().html( this.labels.prevText );
++                      $( ".ui-calendar-next", this.element ).attr( "title", this.labels.nextText )
++                              .children().html( this.labels.nextText );
++                      this._createButtons();
++              } else {
++                      this._refreshMultiplePicker();
++              }
++      },
++
++      _refreshMultiplePicker: function() {
++              var i = 0;
++
++              for ( ; i < this.options.numberOfMonths; i++ ) {
++                      this.element.find( ".ui-calendar-title" ).eq( i ).html( this._buildTitle() );
++                      this.element.find( ".ui-calendar-calendar" ).eq( i ).html( this._buildGrid() );
++                      this.viewDate.adjust( "M", 1 );
++              }
++              this.viewDate.adjust( "M", -this.options.numberOfMonths );
++
++              // TODO: This assumes focus is on the first grid. For multi pickers, the widget needs
++              // to maintain the currently focused grid and base queries like this off of it.
++              this.element.find( ".ui-state-focus" ).not( ":first" ).removeClass( "ui-state-focus" );
++      },
++
++      _getTranslation: function( key ) {
++              return $( "<a>" ).text( this.labels[ key ] ).html();
++      },
++
++      _sanitizeSelector: function( hash ) {
++              return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
++      },
++
++      _setHiddenPicker: function() {
++              this.element.attr( {
++                      "aria-hidden": "true",
++                      "aria-expanded": "false"
++              } );
++      },
++
++      value: function( value ) {
++              if ( arguments.length ) {
++                      this.valueAsDate( this._parse( value ) );
++              } else {
++                      return this._format( this.option( "value" ) );
++              }
++      },
++
++      valueAsDate: function( value ) {
++              if ( arguments.length ) {
++                      this.option( "value", value );
++              } else {
++                      return this.options.value;
++              }
++      },
++
++      _isValid: function( value ) {
++              if ( $.type( value ) !== "date" ) {
++                      return false;
++              }
++
++              if ( $.type( this.options.max ) === "date" ) {
++                      if ( value > this.options.max ) {
++                              return false;
++                      }
++              }
++
++              if ( $.type( this.options.min ) === "date" ) {
++                      if ( value < this.options.min ) {
++                              return false;
++                      }
++              }
++
++              return true;
++      },
++
++      _destroy: function() {
++              this.element
++                      .off( ".calendar" )
++                      .removeClass( "ui-calendar ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-calendar-multi" )
++                      .removeAttr( "role aria-labelledby" )
++                      .removeUniqueId()
++                      .empty();
++      },
++
++      _setOptions: function( options ) {
++              var that = this,
++                      refresh = false,
++                      dateAttributes = false;
++
++              $.each( options, function( key, value ) {
++                      that._setOption( key, value );
++
++                      if ( key in that.refreshRelatedOptions ) {
++                              refresh = true;
++                      }
++                      if ( key === "dateFormat" || key === "locale" ) {
++                              dateAttributes = true;
++                      }
++              } );
++
++              if ( dateAttributes ) {
++                      this._setLocale( this.options.locale, this.options.dateFormat );
++                      this.date.setAttributes( this._calendarDateOptions );
++                      this.viewDate.setAttributes( this._calendarDateOptions );
++              }
++              if ( refresh ) {
++                      this._refresh();
++              }
++      },
++
++      _setOption: function( key, value ) {
++              if ( key === "value" ) {
++                      if ( this._isValid( value ) ) {
++                              this.date.setTime( value.getTime() );
++                              this._super( key, value );
++                      }
++                      return;
++              }
++
++              if ( key === "max" || key === "min" ) {
++                      if ( $.type( value ) === "date" || value === null ) {
++                              this._super( key, value );
++                      }
++                      return;
++              }
++
++              this._super( key, value );
++
++              if ( key === "buttons" ) {
++                      this._createButtons();
++              }
++
++              if ( key === "disabled" ) {
++                      this.element
++                              .toggleClass( "ui-state-disabled", value )
++                              .attr( "aria-disabled", value );
++              }
++
++              if ( key === "eachDay" ) {
++                      this.viewDate.eachDay = value;
++              }
++      }
++} );
++
++} ) );
index 0000000000000000000000000000000000000000,85b658319bbb0b00cc78bb8b3c201f1e57586132..5e0e47eb5d25d8d996a801510e0362cae24604a7
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,2093 +1,362 @@@
 -//>>description: Displays a calendar from an input or inline for selecting dates.
+ /*!
+  * jQuery UI Datepicker @VERSION
+  * http://jqueryui.com
+  *
+  * Copyright jQuery Foundation and other contributors
+  * Released under the MIT license.
+  * http://jquery.org/license
+  */
+ //>>label: Datepicker
+ //>>group: Widgets
 -//>>css.structure: ../themes/base/core.css
 -//>>css.structure: ../themes/base/datepicker.css
 -//>>css.theme: ../themes/base/theme.css
++//>>description: Displays a calendar for input-based date selection.
+ //>>docs: http://api.jqueryui.com/datepicker/
+ //>>demos: http://jqueryui.com/datepicker/
 -              factory( jQuery );
+ (function( factory ) {
+       if ( typeof define === "function" && define.amd ) {
+               // AMD. Register as an anonymous module.
+               define([
+                       "jquery",
++                      "globalize",
++                      "globalize/date",
++                      "./calendar",
++                      "../widget",
++                      "../position",
+                       "../version",
+                       "../keycode"
+               ], factory );
+       } else {
+               // Browser globals
 -}(function( $ ) {
++              factory( jQuery, Globalize );
+       }
 -$.extend($.ui, { datepicker: { version: "@VERSION" } });
++}(function( $, Globalize ) {
 -var datepicker_instActive;
 -
 -function datepicker_getZindex( elem ) {
 -      var position, value;
 -      while ( elem.length && elem[ 0 ] !== document ) {
 -              // Ignore z-index if position is set to a value where z-index is ignored by the browser
 -              // This makes behavior of this function consistent across browsers
 -              // WebKit always returns auto if the element is positioned
 -              position = elem.css( "position" );
 -              if ( position === "absolute" || position === "relative" || position === "fixed" ) {
 -                      // IE returns 0 when zIndex is not specified
 -                      // other browsers return a string
 -                      // we ignore the case of nested elements with an explicit value of 0
 -                      // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
 -                      value = parseInt( elem.css( "zIndex" ), 10 );
 -                      if ( !isNaN( value ) && value !== 0 ) {
 -                              return value;
 -                      }
 -              }
 -              elem = elem.parent();
 -      }
 -
 -      return 0;
 -}
 -/* Date picker manager.
 -   Use the singleton instance of this class, $.datepicker, to interact with the date picker.
 -   Settings for (groups of) date pickers are maintained in an instance object,
 -   allowing multiple different settings on the same page. */
 -
 -function Datepicker() {
 -      this._curInst = null; // The current instance in use
 -      this._keyEvent = false; // If the last event was a key event
 -      this._disabledInputs = []; // List of date picker inputs that have been disabled
 -      this._datepickerShowing = false; // True if the popup picker is showing , false if not
 -      this._inDialog = false; // True if showing within a "dialog", false if not
 -      this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
 -      this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
 -      this._appendClass = "ui-datepicker-append"; // The name of the append marker class
 -      this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
 -      this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
 -      this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
 -      this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
 -      this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
 -      this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
 -      this.regional = []; // Available regional settings, indexed by language code
 -      this.regional[""] = { // Default regional settings
 -              closeText: "Done", // Display text for close link
 -              prevText: "Prev", // Display text for previous month link
 -              nextText: "Next", // Display text for next month link
 -              currentText: "Today", // Display text for current month link
 -              monthNames: ["January","February","March","April","May","June",
 -                      "July","August","September","October","November","December"], // Names of months for drop-down and formatting
 -              monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
 -              dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
 -              dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
 -              dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
 -              weekHeader: "Wk", // Column header for week of the year
 -              dateFormat: "mm/dd/yy", // See format options on parseDate
 -              firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
 -              isRTL: false, // True if right-to-left language, false if left-to-right
 -              showMonthAfterYear: false, // True if the year select precedes month, false for month then year
 -              yearSuffix: "" // Additional text to append to the year in the month headers
 -      };
 -      this._defaults = { // Global defaults for all the date picker instances
 -              showOn: "focus", // "focus" for popup on focus,
 -                      // "button" for trigger button, or "both" for either
 -              showAnim: "fadeIn", // Name of jQuery animation for popup
 -              showOptions: {}, // Options for enhanced animations
 -              defaultDate: null, // Used when field is blank: actual date,
 -                      // +/-number for offset from today, null for today
 -              appendText: "", // Display text following the input box, e.g. showing the format
 -              buttonText: "...", // Text for trigger button
 -              buttonImage: "", // URL for trigger button image
 -              buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
 -              hideIfNoPrevNext: false, // True to hide next/previous month links
 -                      // if not applicable, false to just disable them
 -              navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
 -              gotoCurrent: false, // True if today link goes back to current selection instead
 -              changeMonth: false, // True if month can be selected directly, false if only prev/next
 -              changeYear: false, // True if year can be selected directly, false if only prev/next
 -              yearRange: "c-10:c+10", // Range of years to display in drop-down,
 -                      // either relative to today's year (-nn:+nn), relative to currently displayed year
 -                      // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
 -              showOtherMonths: false, // True to show dates in other months, false to leave blank
 -              selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
 -              showWeek: false, // True to show week of the year, false to not show it
 -              calculateWeek: this.iso8601Week, // How to calculate the week of the year,
 -                      // takes a Date and returns the number of the week for it
 -              shortYearCutoff: "+10", // Short year values < this are in the current century,
 -                      // > this are in the previous century,
 -                      // string value starting with "+" for current year + value
 -              minDate: null, // The earliest selectable date, or null for no limit
 -              maxDate: null, // The latest selectable date, or null for no limit
 -              duration: "fast", // Duration of display/closure
 -              beforeShowDay: null, // Function that takes a date and returns an array with
 -                      // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
 -                      // [2] = cell title (optional), e.g. $.datepicker.noWeekends
 -              beforeShow: null, // Function that takes an input field and
 -                      // returns a set of custom settings for the date picker
 -              onSelect: null, // Define a callback function when a date is selected
 -              onChangeMonthYear: null, // Define a callback function when the month or year is changed
 -              onClose: null, // Define a callback function when the datepicker is closed
 -              numberOfMonths: 1, // Number of months to show at a time
 -              showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
 -              stepMonths: 1, // Number of months to step back/forward
 -              stepBigMonths: 12, // Number of months to step back/forward for the big links
 -              altField: "", // Selector for an alternate field to store selected dates into
 -              altFormat: "", // The date format to use for the alternate field
 -              constrainInput: true, // The input is constrained by the current date format
 -              showButtonPanel: false, // True to show button panel, false to not show it
 -              autoSize: false, // True to size the input for the date format, false to leave as is
 -              disabled: false // The initial disabled state
 -      };
 -      $.extend(this._defaults, this.regional[""]);
 -      this.regional.en = $.extend( true, {}, this.regional[ "" ]);
 -      this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
 -      this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
 -}
 -
 -$.extend(Datepicker.prototype, {
 -      /* Class name added to elements to indicate already configured with a date picker. */
 -      markerClassName: "hasDatepicker",
 -
 -      //Keep track of the maximum number of rows displayed (see #7043)
 -      maxRows: 4,
 -
 -      // TODO rename to "widget" when switching to widget factory
 -      _widgetDatepicker: function() {
 -              return this.dpDiv;
 -      },
 -
 -      /* 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
 -       */
 -      setDefaults: function(settings) {
 -              datepicker_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)
 -       */
 -      _attachDatepicker: function(target, settings) {
 -              var nodeName, inline, inst;
 -              nodeName = target.nodeName.toLowerCase();
 -              inline = (nodeName === "div" || nodeName === "span");
 -              if (!target.id) {
 -                      this.uuid += 1;
 -                      target.id = "dp" + this.uuid;
 -              }
 -              inst = this._newInst($(target), inline);
 -              inst.settings = $.extend({}, settings || {});
 -              if (nodeName === "input") {
 -                      this._connectDatepicker(target, inst);
 -              } else if (inline) {
 -                      this._inlineDatepicker(target, inst);
 -              }
 -      },
 -
 -      /* Create a new instance object. */
 -      _newInst: function(target, inline) {
 -              var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
 -              return {id: id, input: target, // associated target
 -                      selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
 -                      drawMonth: 0, drawYear: 0, // month being drawn
 -                      inline: inline, // is datepicker inline or not
 -                      dpDiv: (!inline ? this.dpDiv : // presentation div
 -                      datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
 -      },
 -
 -      /* Attach the date picker to an input field. */
 -      _connectDatepicker: function(target, inst) {
 -              var input = $(target);
 -              inst.append = $([]);
 -              inst.trigger = $([]);
 -              if (input.hasClass(this.markerClassName)) {
 -                      return;
 -              }
 -              this._attachments(input, inst);
 -              input.addClass(this.markerClassName).on( "keydown", this._doKeyDown).
 -                      on( "keypress", this._doKeyPress).on( "keyup", this._doKeyUp);
 -              this._autoSize(inst);
 -              $.data(target, "datepicker", inst);
 -              //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
 -              if( inst.settings.disabled ) {
 -                      this._disableDatepicker( target );
 -              }
++var widget = $.widget( "ui.datepicker", {
++      version: "@VERSION",
++      options: {
++              appendTo: null,
++              position: {
++                      my: "left top",
++                      at: "left bottom"
++              },
++              show: true,
++              hide: true,
 -      /* Make attachments based on settings. */
 -      _attachments: function(input, inst) {
 -              var showOn, buttonText, buttonImage,
 -                      appendText = this._get(inst, "appendText"),
 -                      isRTL = this._get(inst, "isRTL");
 -
 -              if (inst.append) {
 -                      inst.append.remove();
 -              }
 -              if (appendText) {
 -                      inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
 -                      input[isRTL ? "before" : "after"](inst.append);
 -              }
 -
 -              input.off("focus", this._showDatepicker);
++              // callbacks
++              beforeOpen: null,
++              close: null,
++              open: null,
++              select: null
+       },
 -              if (inst.trigger) {
 -                      inst.trigger.remove();
 -              }
++      calendarOptions: [ "buttons", "disabled", "dateFormat", "eachDay", "labels",
++              "locale", "max", "min", "numberOfMonths", "showWeek" ],
 -              showOn = this._get(inst, "showOn");
 -              if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
 -                      input.on( "focus", this._showDatepicker );
++      _create: function() {
++              this.suppressExpandOnFocus = false;
 -              if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
 -                      buttonText = this._get(inst, "buttonText");
 -                      buttonImage = this._get(inst, "buttonImage");
 -                      inst.trigger = $(this._get(inst, "buttonImageOnly") ?
 -                              $("<img/>").addClass(this._triggerClass).
 -                                      attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
 -                              $("<button type='button'></button>").addClass(this._triggerClass).
 -                                      html(!buttonImage ? buttonText : $("<img/>").attr(
 -                                      { src:buttonImage, alt:buttonText, title:buttonText })));
 -                      input[isRTL ? "before" : "after"](inst.trigger);
 -                      inst.trigger.on( "click", function() {
 -                              if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
 -                                      $.datepicker._hideDatepicker();
 -                              } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
 -                                      $.datepicker._hideDatepicker();
 -                                      $.datepicker._showDatepicker(input[0]);
 -                              } else {
 -                                      $.datepicker._showDatepicker(input[0]);
 -                              }
 -                              return false;
 -                      });
 -              }
 -      },
 -
 -      /* Apply the maximum length for the date format. */
 -      _autoSize: function(inst) {
 -              if (this._get(inst, "autoSize") && !inst.inline) {
 -                      var findMax, max, maxI, i,
 -                              date = new Date(2009, 12 - 1, 20), // Ensure double digits
 -                              dateFormat = this._get(inst, "dateFormat");
 -
 -                      if (dateFormat.match(/[DM]/)) {
 -                              findMax = function(names) {
 -                                      max = 0;
 -                                      maxI = 0;
 -                                      for (i = 0; i < names.length; i++) {
 -                                              if (names[i].length > max) {
 -                                                      max = names[i].length;
 -                                                      maxI = i;
 -                                              }
 -                                      }
 -                                      return maxI;
 -                              };
 -                              date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
 -                                      "monthNames" : "monthNamesShort"))));
 -                              date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
 -                                      "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
 -                      }
 -                      inst.input.attr("size", this._formatDate(inst, date).length);
 -              }
 -      },
 -
 -      /* Attach an inline date picker to a div. */
 -      _inlineDatepicker: function(target, inst) {
 -              var divSpan = $(target);
 -              if (divSpan.hasClass(this.markerClassName)) {
 -                      return;
 -              }
 -              divSpan.addClass(this.markerClassName).append(inst.dpDiv);
 -              $.data(target, "datepicker", inst);
 -              this._setDate(inst, this._getDefaultDate(inst), true);
 -              this._updateDatepicker(inst);
 -              this._updateAlternate(inst);
 -              //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
 -              if( inst.settings.disabled ) {
 -                      this._disableDatepicker( target );
 -              }
 -              // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
 -              // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
 -              inst.dpDiv.css( "display", "block" );
 -      },
 -
 -      /* Pop-up the date picker in a "dialog" box.
 -       * @param  input element - ignored
 -       * @param  date string or Date - the initial date to display
 -       * @param  onSelect  function - the function to call when a date is selected
 -       * @param  settings  object - update the dialog date picker instance's settings (anonymous object)
 -       * @param  pos int[2] - coordinates for the dialog's position within the screen or
 -       *                                      event - with x/y coordinates or
 -       *                                      leave empty for default (screen centre)
 -       * @return the manager object
 -       */
 -      _dialogDatepicker: function(input, date, onSelect, settings, pos) {
 -              var id, browserWidth, browserHeight, scrollX, scrollY,
 -                      inst = this._dialogInst; // internal instance
 -
 -              if (!inst) {
 -                      this.uuid += 1;
 -                      id = "dp" + this.uuid;
 -                      this._dialogInput = $("<input type='text' id='" + id +
 -                              "' style='position: absolute; top: -100px; width: 0px;'/>");
 -                      this._dialogInput.on( "keydown", this._doKeyDown );
 -                      $("body").append(this._dialogInput);
 -                      inst = this._dialogInst = this._newInst(this._dialogInput, false);
 -                      inst.settings = {};
 -                      $.data(this._dialogInput[0], "datepicker", inst);
++              if ( $.type( this.options.max ) === "string" ) {
++                      this.options.max = Globalize.parseDate( this.options.max, { raw: "yyyy-MM-dd" } );
+               }
 -              datepicker_extendRemove(inst.settings, settings || {});
 -              date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
 -              this._dialogInput.val(date);
++              if ( $.type( this.options.min ) === "string" ) {
++                      this.options.min = Globalize.parseDate( this.options.min, { raw: "yyyy-MM-dd" } );
+               }
 -              this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
 -              if (!this._pos) {
 -                      browserWidth = document.documentElement.clientWidth;
 -                      browserHeight = document.documentElement.clientHeight;
 -                      scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
 -                      scrollY = document.documentElement.scrollTop || document.body.scrollTop;
 -                      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] + 20) + "px").css("top", this._pos[1] + "px");
 -              inst.settings.onSelect = onSelect;
 -              this._inDialog = true;
 -              this.dpDiv.addClass(this._dialogClass);
 -              this._showDatepicker(this._dialogInput[0]);
 -              if ($.blockUI) {
 -                      $.blockUI(this.dpDiv);
 -              }
 -              $.data(this._dialogInput[0], "datepicker", inst);
 -              return this;
++              this._createCalendar();
 -      /* Detach a datepicker from its control.
 -       * @param  target       element - the target input field or division or span
 -       */
 -      _destroyDatepicker: function(target) {
 -              var nodeName,
 -                      $target = $(target),
 -                      inst = $.data(target, "datepicker");
++              this._on( this._inputEvents );
++              this._on( this.calendar, this._calendarEvents );
++              this._on( this.document, this._documentEvents );
+       },
 -              if (!$target.hasClass(this.markerClassName)) {
 -                      return;
++      _getCreateOptions: function() {
++              var max = this.element.attr( "max" ),
++                      min = this.element.attr( "min" ),
++                      options = {};
 -              nodeName = target.nodeName.toLowerCase();
 -              $.removeData(target, "datepicker");
 -              if (nodeName === "input") {
 -                      inst.append.remove();
 -                      inst.trigger.remove();
 -                      $target.removeClass(this.markerClassName).
 -                              off("focus", this._showDatepicker).
 -                              off("keydown", this._doKeyDown).
 -                              off("keypress", this._doKeyPress).
 -                              off("keyup", this._doKeyUp);
 -              } else if (nodeName === "div" || nodeName === "span") {
 -                      $target.removeClass(this.markerClassName).empty();
++              if ( max !== undefined ) {
++                      options.max = Globalize.parseDate( max, { raw: "yyyy-MM-dd" } );
+               }
 -              if ( datepicker_instActive === inst ) {
 -                      datepicker_instActive = null;
 -              }
++              if ( min !== undefined ) {
++                      options.min = Globalize.parseDate( min, { raw: "yyyy-MM-dd" } );
+               }
 -      /* Enable the date picker to a jQuery selection.
 -       * @param  target       element - the target input field or division or span
 -       */
 -      _enableDatepicker: function(target) {
 -              var nodeName, inline,
 -                      $target = $(target),
 -                      inst = $.data(target, "datepicker");
++              return options;
+       },
 -              if (!$target.hasClass(this.markerClassName)) {
 -                      return;
 -              }
++      _createCalendar: function() {
++              var that = this,
++                      globalize = new Globalize( this.options.locale );
 -              nodeName = target.nodeName.toLowerCase();
 -              if (nodeName === "input") {
 -                      target.disabled = false;
 -                      inst.trigger.filter("button").
 -                              each(function() { this.disabled = false; }).end().
 -                              filter("img").css({opacity: "1.0", cursor: ""});
 -              } else if (nodeName === "div" || nodeName === "span") {
 -                      inline = $target.children("." + this._inlineClass);
 -                      inline.children().removeClass("ui-state-disabled");
 -                      inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
 -                              prop("disabled", false);
 -              }
 -              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) {
 -              var nodeName, inline,
 -                      $target = $(target),
 -                      inst = $.data(target, "datepicker");
 -
 -              if (!$target.hasClass(this.markerClassName)) {
 -                      return;
 -              }
++              this.calendar = $( "<div>" )
++                      .addClass( "ui-front ui-datepicker" )
++                      .appendTo( this._appendTo() );
 -              nodeName = target.nodeName.toLowerCase();
 -              if (nodeName === "input") {
 -                      target.disabled = true;
 -                      inst.trigger.filter("button").
 -                              each(function() { this.disabled = true; }).end().
 -                              filter("img").css({opacity: "0.5", cursor: "default"});
 -              } else if (nodeName === "div" || nodeName === "span") {
 -                      inline = $target.children("." + this._inlineClass);
 -                      inline.children().addClass("ui-state-disabled");
 -                      inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
 -                              prop("disabled", true);
 -              }
 -              this._disabledInputs = $.map(this._disabledInputs,
 -                      function(value) { return (value === target ? null : value); }); // delete entry
 -              this._disabledInputs[this._disabledInputs.length] = target;
 -      },
++              // Initialize calendar widget
++              this.calendarInstance = this.calendar
++                      .calendar( $.extend( {}, this.options, {
++                              value: globalize.dateParser( this.options.dateFormat )( this.element.val() ),
++                              select: function( event ) {
++                                      that.element.val( that.calendarInstance.value() );
++                                      that.close();
++                                      that._focusTrigger();
++                                      that._trigger( "select", event );
++                              }
++                      }) )
++                      .calendar( "instance" );
 -      /* 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
 -       */
 -      _isDisabledDatepicker: function(target) {
 -              if (!target) {
 -                      return false;
 -              }
 -              for (var i = 0; i < this._disabledInputs.length; i++) {
 -                      if (this._disabledInputs[i] === target) {
 -                              return true;
 -                      }
 -              }
 -              return false;
 -      },
++              this.calendarInstance.buttonClickContext = that.element[ 0 ];
 -      /* 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
 -       * @throws  error if a jQuery problem getting data
 -       */
 -      _getInst: function(target) {
 -              try {
 -                      return $.data(target, "datepicker");
 -              }
 -              catch (err) {
 -                      throw "Missing instance data for this datepicker";
 -              }
++              this._setHiddenPicker();
 -      /* Update or retrieve 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
 -       *                              string - the name of the setting to change or retrieve,
 -       *                              when retrieving also "all" for all instance settings or
 -       *                              "defaults" for all global defaults
 -       * @param  value   any - the new value for the setting
 -       *                              (omit if above is an object or to retrieve a value)
 -       */
 -      _optionDatepicker: function(target, name, value) {
 -              var settings, date, minDate, maxDate,
 -                      inst = this._getInst(target);
 -
 -              if (arguments.length === 2 && typeof name === "string") {
 -                      return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
 -                              (inst ? (name === "all" ? $.extend({}, inst.settings) :
 -                              this._get(inst, name)) : null));
 -              }
 -
 -              settings = name || {};
 -              if (typeof name === "string") {
 -                      settings = {};
 -                      settings[name] = value;
 -              }
 -
 -              if (inst) {
 -                      if (this._curInst === inst) {
 -                              this._hideDatepicker();
++              this.element.attr({
++                      "aria-haspopup": true,
++                      "aria-owns": this.calendar.attr( "id" )
++              });
+       },
 -
 -                      date = this._getDateDatepicker(target, true);
 -                      minDate = this._getMinMaxDate(inst, "min");
 -                      maxDate = this._getMinMaxDate(inst, "max");
 -                      datepicker_extendRemove(inst.settings, settings);
 -                      // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
 -                      if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
 -                              inst.settings.minDate = this._formatDate(inst, minDate);
 -                      }
 -                      if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
 -                              inst.settings.maxDate = this._formatDate(inst, maxDate);
++      _inputEvents: {
++              keydown: function( event ) {
++                      switch ( event.keyCode ) {
++                      case $.ui.keyCode.TAB:
++                              // Waiting for close() will make popup hide too late, which breaks tab key behavior
++                              this.calendar.hide();
++                              this.close( event );
++                              break;
++                      case $.ui.keyCode.ESCAPE:
++                              if ( this.isOpen ) {
++                                      this.close( event );
++                              }
++                              break;
++                      case $.ui.keyCode.DOWN:
++                      case $.ui.keyCode.UP:
++                              clearTimeout( this.closeTimer );
++                              this._delay( function() {
++                                      this.open( event );
++                                      this.calendarInstance.grid.focus();
++                              }, 1 );
++                              break;
+                       }
 -                      if ( "disabled" in settings ) {
 -                              if ( settings.disabled ) {
 -                                      this._disableDatepicker(target);
 -                              } else {
 -                                      this._enableDatepicker(target);
 -                              }
++              },
++              keyup: function() {
++                      if ( this.isValid() ) {
++                              this.refresh();
+                       }
 -                      this._attachments($(target), inst);
 -                      this._autoSize(inst);
 -                      this._setDate(inst, date);
 -                      this._updateAlternate(inst);
 -                      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) {
 -              var inst = this._getInst(target);
 -              if (inst) {
 -                      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
 -       */
 -      _setDateDatepicker: function(target, date) {
 -              var inst = this._getInst(target);
 -              if (inst) {
 -                      this._setDate(inst, date);
 -                      this._updateDatepicker(inst);
 -                      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
 -       * @param  noDefault boolean - true if no default date is to be used
 -       * @return Date - the current date
 -       */
 -      _getDateDatepicker: function(target, noDefault) {
 -              var inst = this._getInst(target);
 -              if (inst && !inst.inline) {
 -                      this._setDateFromField(inst, noDefault);
 -              }
 -              return (inst ? this._getDate(inst) : null);
 -      },
 -
 -      /* Handle keystrokes. */
 -      _doKeyDown: function(event) {
 -              var onSelect, dateStr, sel,
 -                      inst = $.datepicker._getInst(event.target),
 -                      handled = true,
 -                      isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
 -
 -              inst._keyEvent = true;
 -              if ($.datepicker._datepickerShowing) {
 -                      switch (event.keyCode) {
 -                              case 9: $.datepicker._hideDatepicker();
 -                                              handled = false;
 -                                              break; // hide on tab out
 -                              case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
 -                                                                      $.datepicker._currentClass + ")", inst.dpDiv);
 -                                              if (sel[0]) {
 -                                                      $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
 -                                              }
 -
 -                                              onSelect = $.datepicker._get(inst, "onSelect");
 -                                              if (onSelect) {
 -                                                      dateStr = $.datepicker._formatDate(inst);
 -
 -                                                      // trigger custom callback
 -                                                      onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
 -                                              } else {
 -                                                      $.datepicker._hideDatepicker();
 -                                              }
 -
 -                                              return false; // don't submit the form
 -                              case 27: $.datepicker._hideDatepicker();
 -                                              break; // hide on escape
 -                              case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
 -                                                      -$.datepicker._get(inst, "stepBigMonths") :
 -                                                      -$.datepicker._get(inst, "stepMonths")), "M");
 -                                              break; // previous month/year on page up/+ ctrl
 -                              case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
 -                                                      +$.datepicker._get(inst, "stepBigMonths") :
 -                                                      +$.datepicker._get(inst, "stepMonths")), "M");
 -                                              break; // next month/year on page down/+ ctrl
 -                              case 35: if (event.ctrlKey || event.metaKey) {
 -                                                      $.datepicker._clearDate(event.target);
 -                                              }
 -                                              handled = event.ctrlKey || event.metaKey;
 -                                              break; // clear on ctrl or command +end
 -                              case 36: if (event.ctrlKey || event.metaKey) {
 -                                                      $.datepicker._gotoToday(event.target);
 -                                              }
 -                                              handled = event.ctrlKey || event.metaKey;
 -                                              break; // current on ctrl or command +home
 -                              case 37: if (event.ctrlKey || event.metaKey) {
 -                                                      $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
 -                                              }
 -                                              handled = event.ctrlKey || event.metaKey;
 -                                              // -1 day on ctrl or command +left
 -                                              if (event.originalEvent.altKey) {
 -                                                      $.datepicker._adjustDate(event.target, (event.ctrlKey ?
 -                                                              -$.datepicker._get(inst, "stepBigMonths") :
 -                                                              -$.datepicker._get(inst, "stepMonths")), "M");
 -                                              }
 -                                              // next month/year on alt +left on Mac
 -                                              break;
 -                              case 38: if (event.ctrlKey || event.metaKey) {
 -                                                      $.datepicker._adjustDate(event.target, -7, "D");
 -                                              }
 -                                              handled = event.ctrlKey || event.metaKey;
 -                                              break; // -1 week on ctrl or command +up
 -                              case 39: if (event.ctrlKey || event.metaKey) {
 -                                                      $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
 -                                              }
 -                                              handled = event.ctrlKey || event.metaKey;
 -                                              // +1 day on ctrl or command +right
 -                                              if (event.originalEvent.altKey) {
 -                                                      $.datepicker._adjustDate(event.target, (event.ctrlKey ?
 -                                                              +$.datepicker._get(inst, "stepBigMonths") :
 -                                                              +$.datepicker._get(inst, "stepMonths")), "M");
 -                                              }
 -                                              // next month/year on alt +right
 -                                              break;
 -                              case 40: if (event.ctrlKey || event.metaKey) {
 -                                                      $.datepicker._adjustDate(event.target, +7, "D");
 -                                              }
 -                                              handled = event.ctrlKey || event.metaKey;
 -                                              break; // +1 week on ctrl or command +down
 -                              default: handled = false;
 -                      }
 -              } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
 -                      $.datepicker._showDatepicker(this);
 -              } else {
 -                      handled = false;
 -              }
 -
 -              if (handled) {
 -                      event.preventDefault();
 -                      event.stopPropagation();
 -              }
 -      },
 -
 -      /* Filter entered characters - based on date format. */
 -      _doKeyPress: function(event) {
 -              var chars, chr,
 -                      inst = $.datepicker._getInst(event.target);
 -
 -              if ($.datepicker._get(inst, "constrainInput")) {
 -                      chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
 -                      chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
 -                      return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
 -              }
 -      },
 -
 -      /* Synchronise manual entry and field/alternate field. */
 -      _doKeyUp: function(event) {
 -              var date,
 -                      inst = $.datepicker._getInst(event.target);
 -
 -              if (inst.input.val() !== inst.lastVal) {
 -                      try {
 -                              date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
 -                                      (inst.input ? inst.input.val() : null),
 -                                      $.datepicker._getFormatConfig(inst));
 -
 -                              if (date) { // only if valid
 -                                      $.datepicker._setDateFromField(inst);
 -                                      $.datepicker._updateAlternate(inst);
 -                                      $.datepicker._updateDatepicker(inst);
 -                              }
++              },
++              mousedown: function( event ) {
++                      if ( this.isOpen ) {
++                              this.suppressExpandOnFocus = true;
++                              this.close();
++                              return;
+                       }
 -                      catch (err) {
++                      this.open( event );
++                      clearTimeout( this.closeTimer );
++              },
++              focus: function( event ) {
++                      if ( !this.suppressExpandOnFocus && !this.isOpen ) {
++                              this._delay( function() {
++                                      this.open( event );
++                              });
+                       }
 -              return true;
++                      this._delay( function() {
++                              this.suppressExpandOnFocus = false;
++                      }, 100 );
++              },
++              blur: function() {
++                      this.suppressExpandOnFocus = false;
++              }
++      },
++
++      _calendarEvents: {
++              focusout: function( event ) {
++                      // use a timer to allow click to clear it and letting that
++                      // handle the closing instead of opening again
++                      // also allows tabbing inside the calendar without it closing
++                      this.closeTimer = this._delay( function() {
++                              this.close( event );
++                      }, 150 );
++              },
++              focusin: function() {
++                      clearTimeout( this.closeTimer );
++              },
++              mouseup: function() {
++                      clearTimeout( this.closeTimer );
++              },
++              // TODO on TAB (or shift TAB), make sure it ends up on something useful in DOM order
++              keyup: function( event ) {
++                      if ( event.keyCode === $.ui.keyCode.ESCAPE && this.calendar.is( ":visible" ) ) {
++                              this.close( event );
++                              this._focusTrigger();
+                       }
+               }
 -      /* Pop-up the date picker for a given input field.
 -       * If false returned from beforeShow event handler do not show.
 -       * @param  input  element - the input field attached to the date picker or
 -       *                                      event - if triggered by focus
 -       */
 -      _showDatepicker: function(input) {
 -              input = input.target || input;
 -              if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
 -                      input = $("input", input.parentNode)[0];
 -              }
 -
 -              if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
 -                      return;
 -              }
 -
 -              var inst, beforeShow, beforeShowSettings, isFixed,
 -                      offset, showAnim, duration;
 -
 -              inst = $.datepicker._getInst(input);
 -              if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
 -                      $.datepicker._curInst.dpDiv.stop(true, true);
 -                      if ( inst && $.datepicker._datepickerShowing ) {
 -                              $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
+       },
 -              }
 -
 -              beforeShow = $.datepicker._get(inst, "beforeShow");
 -              beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
 -              if(beforeShowSettings === false){
 -                      return;
 -              }
 -              datepicker_extendRemove(inst.settings, beforeShowSettings);
 -
 -              inst.lastVal = null;
 -              $.datepicker._lastInput = input;
 -              $.datepicker._setDateFromField(inst);
++      _documentEvents: {
++              mousedown: function( event ) {
++                      if ( !this.isOpen ) {
++                              return;
+                       }
 -              if ($.datepicker._inDialog) { // hide cursor
 -                      input.value = "";
 -              }
 -              if (!$.datepicker._pos) { // position below input
 -                      $.datepicker._pos = $.datepicker._findPos(input);
 -                      $.datepicker._pos[1] += input.offsetHeight; // add the height
 -              }
 -
 -              isFixed = false;
 -              $(input).parents().each(function() {
 -                      isFixed |= $(this).css("position") === "fixed";
 -                      return !isFixed;
 -              });
 -
 -              offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
 -              $.datepicker._pos = null;
 -              //to avoid flashes on Firefox
 -              inst.dpDiv.empty();
 -              // determine sizing offscreen
 -              inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
 -              $.datepicker._updateDatepicker(inst);
 -              // fix width for dynamic number of date pickers
 -              // and adjust position before showing
 -              offset = $.datepicker._checkOffset(inst, offset, isFixed);
 -              inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
 -                      "static" : (isFixed ? "fixed" : "absolute")), display: "none",
 -                      left: offset.left + "px", top: offset.top + "px"});
 -
 -              if (!inst.inline) {
 -                      showAnim = $.datepicker._get(inst, "showAnim");
 -                      duration = $.datepicker._get(inst, "duration");
 -                      inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
 -                      $.datepicker._datepickerShowing = true;
 -
 -                      if ( $.effects && $.effects.effect[ showAnim ] ) {
 -                              inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
 -                      } else {
 -                              inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
 -
 -                      if ( $.datepicker._shouldFocusInput( inst ) ) {
 -                              inst.input.trigger( "focus" );
 -                      }
 -
 -                      $.datepicker._curInst = inst;
++                      if ( !$( event.target ).closest( this.element.add( this.calendar ) ).length ) {
++                              this.close( event );
+                       }
 -      /* Generate the date picker content. */
 -      _updateDatepicker: function(inst) {
 -              this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
 -              datepicker_instActive = inst; // for delegate hover events
 -              inst.dpDiv.empty().append(this._generateHTML(inst));
 -              this._attachHandlers(inst);
+               }
+       },
 -              var origyearshtml,
 -                      numMonths = this._getNumberOfMonths(inst),
 -                      cols = numMonths[1],
 -                      width = 17,
 -                      activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
 -
 -              if ( activeCell.length > 0 ) {
 -                      datepicker_handleMouseover.apply( activeCell.get( 0 ) );
++      _appendTo: function() {
++              var element = this.options.appendTo;
 -              inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
 -              if (cols > 1) {
 -                      inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
++              if ( element ) {
++                      element = element.jquery || element.nodeType ?
++                              $( element ) :
++                              this.document.find( element ).eq( 0 );
+               }
 -              inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
 -                      "Class"]("ui-datepicker-multi");
 -              inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
 -                      "Class"]("ui-datepicker-rtl");
++              if ( !element || !element[ 0 ] ) {
++                      element = this.element.closest( ".ui-front, dialog" );
+               }
 -              if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
 -                      inst.input.trigger( "focus" );
 -              // deffered render of the years select (to avoid flashes on Firefox)
 -              if( inst.yearshtml ){
 -                      origyearshtml = inst.yearshtml;
 -                      setTimeout(function(){
 -                              //assure that inst.yearshtml didn't change.
 -                              if( origyearshtml === inst.yearshtml && inst.yearshtml ){
 -                                      inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
 -                              }
 -                              origyearshtml = inst.yearshtml = null;
 -                      }, 0);
 -              }
++              if ( !element.length ) {
++                      element = this.document[ 0 ].body;
+               }
 -      // #6694 - don't focus the input if it's already focused
 -      // this breaks the change event in IE
 -      // Support: IE and jQuery <1.9
 -      _shouldFocusInput: function( inst ) {
 -              return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
++              return element;
+       },
 -      /* Check positioning to remain on screen. */
 -      _checkOffset: function(inst, offset, isFixed) {
 -              var dpWidth = inst.dpDiv.outerWidth(),
 -                      dpHeight = inst.dpDiv.outerHeight(),
 -                      inputWidth = inst.input ? inst.input.outerWidth() : 0,
 -                      inputHeight = inst.input ? inst.input.outerHeight() : 0,
 -                      viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
 -                      viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
 -
 -              offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
 -              offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
 -              offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
 -
 -              // now check if datepicker is showing outside window viewport - move to a better place if so.
 -              offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
 -                      Math.abs(offset.left + dpWidth - viewWidth) : 0);
 -              offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
 -                      Math.abs(dpHeight + inputHeight) : 0);
 -
 -              return offset;
 -      },
 -
 -      /* Find an object's position on the screen. */
 -      _findPos: function(obj) {
 -              var position,
 -                      inst = this._getInst(obj),
 -                      isRTL = this._get(inst, "isRTL");
 -
 -              while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
 -                      obj = obj[isRTL ? "previousSibling" : "nextSibling"];
 -              }
 -
 -              position = $(obj).offset();
 -              return [position.left, position.top];
++      _focusTrigger: function() {
++              this.suppressExpandOnFocus = true;
++              this.element.focus();
+       },
 -      /* Hide the date picker from view.
 -       * @param  input  element - the input field attached to the date picker
 -       */
 -      _hideDatepicker: function(input) {
 -              var showAnim, duration, postProcess, onClose,
 -                      inst = this._curInst;
 -
 -              if (!inst || (input && inst !== $.data(input, "datepicker"))) {
++      refresh: function() {
++              this.calendarInstance.option( "value", this._getParsedValue() );
+       },
 -
 -              if (this._datepickerShowing) {
 -                      showAnim = this._get(inst, "showAnim");
 -                      duration = this._get(inst, "duration");
 -                      postProcess = function() {
 -                              $.datepicker._tidyDialog(inst);
 -                      };
 -
 -                      // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
 -                      if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
 -                              inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
 -                      } else {
 -                              inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
 -                                      (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
 -                      }
 -
 -                      if (!showAnim) {
 -                              postProcess();
 -                      }
 -                      this._datepickerShowing = false;
 -
 -                      onClose = this._get(inst, "onClose");
 -                      if (onClose) {
 -                              onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
 -                      }
 -
 -                      this._lastInput = null;
 -                      if (this._inDialog) {
 -                              this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
 -                              if ($.blockUI) {
 -                                      $.unblockUI();
 -                                      $("body").append(this.dpDiv);
 -                              }
 -                      }
 -                      this._inDialog = false;
 -              }
 -      },
 -
 -      /* Tidy up after a dialog display. */
 -      _tidyDialog: function(inst) {
 -              inst.dpDiv.removeClass(this._dialogClass).off(".ui-datepicker-calendar");
 -      },
 -
 -      /* Close date picker if clicked elsewhere. */
 -      _checkExternalClick: function(event) {
 -              if (!$.datepicker._curInst) {
++      open: function( event ) {
++              if ( this.isOpen ) {
+                       return;
+               }
 -              var $target = $(event.target),
 -                      inst = $.datepicker._getInst($target[0]);
 -
 -              if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
 -                              $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
 -                              !$target.hasClass($.datepicker.markerClassName) &&
 -                              !$target.closest("." + $.datepicker._triggerClass).length &&
 -                              $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
 -                      ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
 -                              $.datepicker._hideDatepicker();
 -              }
 -      },
 -
 -      /* Adjust one of the date sub-fields. */
 -      _adjustDate: function(id, offset, period) {
 -              var target = $(id),
 -                      inst = this._getInst(target[0]);
++              if ( this._trigger( "beforeOpen", event ) === false ) {
+                       return;
+               }
 -              if (this._isDisabledDatepicker(target[0])) {
 -                      return;
 -              }
 -              this._adjustInstDate(inst, offset +
 -                      (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
 -                      period);
 -              this._updateDatepicker(inst);
 -      },
++              this.calendarInstance.refresh();
++              this.calendar
++                      .attr({
++                              "aria-hidden": false,
++                              "aria-expanded": true
++                      })
++                      .show()
++                      .position( this._buildPosition() )
++                      .hide();
++              this._show( this.calendar, this.options.show );
 -      /* Action for current link. */
 -      _gotoToday: function(id) {
 -              var date,
 -                      target = $(id),
 -                      inst = this._getInst(target[0]);
 -
 -              if (this._get(inst, "gotoCurrent") && inst.currentDay) {
 -                      inst.selectedDay = inst.currentDay;
 -                      inst.drawMonth = inst.selectedMonth = inst.currentMonth;
 -                      inst.drawYear = inst.selectedYear = inst.currentYear;
 -              } else {
 -                      date = new Date();
 -                      inst.selectedDay = date.getDate();
 -                      inst.drawMonth = inst.selectedMonth = date.getMonth();
 -                      inst.drawYear = inst.selectedYear = date.getFullYear();
 -              }
 -              this._notifyChange(inst);
 -              this._adjustDate(target);
++              // Take trigger out of tab order to allow shift-tab to skip trigger
++              // TODO Does this really make sense? related bug: tab-shift moves focus to last element on page
++              this.element.attr( "tabindex", -1 );
++              this.isOpen = true;
 -      /* Action for selecting a new month/year. */
 -      _selectMonthYear: function(id, select, period) {
 -              var target = $(id),
 -                      inst = this._getInst(target[0]);
++              this._trigger( "open", event );
+       },
 -              inst["selected" + (period === "M" ? "Month" : "Year")] =
 -              inst["draw" + (period === "M" ? "Month" : "Year")] =
 -                      parseInt(select.options[select.selectedIndex].value,10);
++      close: function( event ) {
++              this._setHiddenPicker();
++              this._hide( this.calendar, this.options.hide );
 -              this._notifyChange(inst);
 -              this._adjustDate(target);
++              this.element.attr( "tabindex", 0 );
 -      /* Action for selecting a day. */
 -      _selectDay: function(id, month, year, td) {
 -              var inst,
 -                      target = $(id);
 -
 -              if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
 -                      return;
 -              }
 -
 -              inst = this._getInst(target[0]);
 -              inst.selectedDay = inst.currentDay = $("a", td).html();
 -              inst.selectedMonth = inst.currentMonth = month;
 -              inst.selectedYear = inst.currentYear = year;
 -              this._selectDate(id, this._formatDate(inst,
 -                      inst.currentDay, inst.currentMonth, inst.currentYear));
++              this.isOpen = false;
++              this._trigger( "close", event );
+       },
 -      /* Erase the input field and hide the date picker. */
 -      _clearDate: function(id) {
 -              var target = $(id);
 -              this._selectDate(target, "");
++      _setHiddenPicker: function() {
++              this.calendar.attr({
++                      "aria-hidden": true,
++                      "aria-expanded": false
++              });
+       },
 -      /* Update the input field with the selected date. */
 -      _selectDate: function(id, dateStr) {
 -              var onSelect,
 -                      target = $(id),
 -                      inst = this._getInst(target[0]);
 -
 -              dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
 -              if (inst.input) {
 -                      inst.input.val(dateStr);
 -              }
 -              this._updateAlternate(inst);
 -
 -              onSelect = this._get(inst, "onSelect");
 -              if (onSelect) {
 -                      onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
 -              } else if (inst.input) {
 -                      inst.input.trigger("change"); // fire the change event
 -              }
 -
 -              if (inst.inline){
 -                      this._updateDatepicker(inst);
++      _buildPosition: function() {
++              return $.extend( { of: this.element }, this.options.position );
+       },
 -                      this._hideDatepicker();
 -                      this._lastInput = inst.input[0];
 -                      if (typeof(inst.input[0]) !== "object") {
 -                              inst.input.trigger( "focus" ); // restore focus
 -                      }
 -                      this._lastInput = null;
 -              }
 -      },
 -
 -      /* Update any alternate field to synchronise with the main field. */
 -      _updateAlternate: function(inst) {
 -              var altFormat, date, dateStr,
 -                      altField = this._get(inst, "altField");
 -
 -              if (altField) { // update alternate field too
 -                      altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
 -                      date = this._getDate(inst);
 -                      dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
 -                      $(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?
 -       */
 -      noWeekends: function(date) {
 -              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
 -       */
 -      iso8601Week: function(date) {
 -              var time,
 -                      checkDate = new Date(date.getTime());
 -
 -              // Find Thursday of this week starting on Monday
 -              checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
 -
 -              time = checkDate.getTime();
 -              checkDate.setMonth(0); // Compare with Jan 1
 -              checkDate.setDate(1);
 -              return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
 -      },
 -
 -      /* Parse a string value into a date object.
 -       * See formatDate below for the possible formats.
 -       *
 -       * @param  format string - the expected format of the date
 -       * @param  value string - the date in the above format
 -       * @param  settings Object - attributes include:
 -       *                                      shortYearCutoff  number - the cutoff year for determining the century (optional)
 -       *                                      dayNamesShort   string[7] - abbreviated names of the days from Sunday (optional)
 -       *                                      dayNames                string[7] - names of the days from Sunday (optional)
 -       *                                      monthNamesShort string[12] - abbreviated names of the months (optional)
 -       *                                      monthNames              string[12] - names of the months (optional)
 -       * @return  Date - the extracted date value or null if value is blank
 -       */
 -      parseDate: function (format, value, settings) {
 -              if (format == null || value == null) {
 -                      throw "Invalid arguments";
 -              }
 -
 -              value = (typeof value === "object" ? value.toString() : value + "");
 -              if (value === "") {
 -                      return null;
 -              }
 -
 -              var iFormat, dim, extra,
 -                      iValue = 0,
 -                      shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
 -                      shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
 -                              new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
 -                      dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
 -                      dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
 -                      monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
 -                      monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
 -                      year = -1,
 -                      month = -1,
 -                      day = -1,
 -                      doy = -1,
 -                      literal = false,
 -                      date,
 -                      // Check whether a format character is doubled
 -                      lookAhead = function(match) {
 -                              var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
 -                              if (matches) {
 -                                      iFormat++;
 -                              }
 -                              return matches;
 -                      },
 -                      // Extract a number from the string value
 -                      getNumber = function(match) {
 -                              var isDoubled = lookAhead(match),
 -                                      size = (match === "@" ? 14 : (match === "!" ? 20 :
 -                                      (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
 -                                      minSize = (match === "y" ? size : 1),
 -                                      digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
 -                                      num = value.substring(iValue).match(digits);
 -                              if (!num) {
 -                                      throw "Missing number at position " + iValue;
 -                              }
 -                              iValue += num[0].length;
 -                              return parseInt(num[0], 10);
 -                      },
 -                      // Extract a name from the string value and convert to an index
 -                      getName = function(match, shortNames, longNames) {
 -                              var index = -1,
 -                                      names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
 -                                              return [ [k, v] ];
 -                                      }).sort(function (a, b) {
 -                                              return -(a[1].length - b[1].length);
 -                                      });
 -
 -                              $.each(names, function (i, pair) {
 -                                      var name = pair[1];
 -                                      if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
 -                                              index = pair[0];
 -                                              iValue += name.length;
 -                                              return false;
 -                                      }
 -                              });
 -                              if (index !== -1) {
 -                                      return index + 1;
 -                              } else {
 -                                      throw "Unknown name at position " + iValue;
 -                              }
 -                      },
 -                      // Confirm that a literal character matches the string value
 -                      checkLiteral = function() {
 -                              if (value.charAt(iValue) !== format.charAt(iFormat)) {
 -                                      throw "Unexpected literal at position " + iValue;
 -                              }
 -                              iValue++;
 -                      };
 -
 -              for (iFormat = 0; iFormat < format.length; iFormat++) {
 -                      if (literal) {
 -                              if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
 -                                      literal = false;
 -                              } else {
 -                                      checkLiteral();
 -                              }
 -                      } else {
 -                              switch (format.charAt(iFormat)) {
 -                                      case "d":
 -                                              day = getNumber("d");
 -                                              break;
 -                                      case "D":
 -                                              getName("D", dayNamesShort, dayNames);
 -                                              break;
 -                                      case "o":
 -                                              doy = getNumber("o");
 -                                              break;
 -                                      case "m":
 -                                              month = getNumber("m");
 -                                              break;
 -                                      case "M":
 -                                              month = getName("M", monthNamesShort, monthNames);
 -                                              break;
 -                                      case "y":
 -                                              year = getNumber("y");
 -                                              break;
 -                                      case "@":
 -                                              date = new Date(getNumber("@"));
 -                                              year = date.getFullYear();
 -                                              month = date.getMonth() + 1;
 -                                              day = date.getDate();
 -                                              break;
 -                                      case "!":
 -                                              date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
 -                                              year = date.getFullYear();
 -                                              month = date.getMonth() + 1;
 -                                              day = date.getDate();
 -                                              break;
 -                                      case "'":
 -                                              if (lookAhead("'")){
 -                                                      checkLiteral();
 -                                              } else {
 -                                                      literal = true;
 -                                              }
 -                                              break;
 -                                      default:
 -                                              checkLiteral();
 -                              }
 -                      }
 -              }
 -
 -              if (iValue < value.length){
 -                      extra = value.substr(iValue);
 -                      if (!/^\s+/.test(extra)) {
 -                              throw "Extra/unparsed characters found in date: " + extra;
 -                      }
 -              }
 -
 -              if (year === -1) {
 -                      year = new Date().getFullYear();
 -              } else if (year < 100) {
 -                      year += new Date().getFullYear() - new Date().getFullYear() % 100 +
 -                              (year <= shortYearCutoff ? 0 : -100);
 -              }
 -
 -              if (doy > -1) {
 -                      month = 1;
 -                      day = doy;
 -                      do {
 -                              dim = this._getDaysInMonth(year, month - 1);
 -                              if (day <= dim) {
 -                                      break;
 -                              }
 -                              month++;
 -                              day -= dim;
 -                      } while (true);
++      value: function( value ) {
++              if ( arguments.length ) {
++                      this.valueAsDate( this.calendarInstance._parse( value ) );
+               } else {
 -
 -              date = this._daylightSavingAdjust(new Date(year, month - 1, day));
 -              if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
 -                      throw "Invalid date"; // E.g. 31/02/00
 -              }
 -              return date;
++                      return this._getParsedValue() ? this.element.val() : null;
+               }
 -      /* Standard date formats. */
 -      ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
 -      COOKIE: "D, dd M yy",
 -      ISO_8601: "yy-mm-dd",
 -      RFC_822: "D, d M y",
 -      RFC_850: "DD, dd-M-y",
 -      RFC_1036: "D, d M y",
 -      RFC_1123: "D, d M yy",
 -      RFC_2822: "D, d M yy",
 -      RSS: "D, d M y", // RFC 822
 -      TICKS: "!",
 -      TIMESTAMP: "@",
 -      W3C: "yy-mm-dd", // ISO 8601
 -
 -      _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
 -              Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
 -
 -      /* Format a date object into a string value.
 -       * The format can be combinations of the following:
 -       * d  - day of month (no leading zero)
 -       * dd - day of month (two digit)
 -       * o  - day of year (no leading zeros)
 -       * oo - day of year (three digit)
 -       * D  - day name short
 -       * DD - day name long
 -       * m  - month of year (no leading zero)
 -       * mm - month of year (two digit)
 -       * M  - month name short
 -       * MM - month name long
 -       * y  - year (two digit)
 -       * yy - year (four digit)
 -       * @ - Unix timestamp (ms since 01/01/1970)
 -       * ! - Windows ticks (100ns since 01/01/0001)
 -       * "..." - 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:
 -       *                                      dayNamesShort   string[7] - abbreviated names of the days from Sunday (optional)
 -       *                                      dayNames                string[7] - names of the days from Sunday (optional)
 -       *                                      monthNamesShort string[12] - abbreviated names of the months (optional)
 -       *                                      monthNames              string[12] - names of the months (optional)
 -       * @return  string - the date in the above format
 -       */
 -      formatDate: function (format, date, settings) {
 -              if (!date) {
 -                      return "";
 -              }
 -
 -              var iFormat,
 -                      dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
 -                      dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
 -                      monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
 -                      monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
 -                      // Check whether a format character is doubled
 -                      lookAhead = function(match) {
 -                              var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
 -                              if (matches) {
 -                                      iFormat++;
 -                              }
 -                              return matches;
 -                      },
 -                      // Format a number, with leading zero if necessary
 -                      formatNumber = function(match, value, len) {
 -                              var num = "" + value;
 -                              if (lookAhead(match)) {
 -                                      while (num.length < len) {
 -                                              num = "0" + num;
 -                                      }
 -                              }
 -                              return num;
 -                      },
 -                      // Format a name, short or long as requested
 -                      formatName = function(match, value, shortNames, longNames) {
 -                              return (lookAhead(match) ? longNames[value] : shortNames[value]);
 -                      },
 -                      output = "",
 -                      literal = false;
 -
 -              if (date) {
 -                      for (iFormat = 0; iFormat < format.length; iFormat++) {
 -                              if (literal) {
 -                                      if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
 -                                              literal = false;
 -                                      } else {
 -                                              output += format.charAt(iFormat);
 -                                      }
 -                              } else {
 -                                      switch (format.charAt(iFormat)) {
 -                                              case "d":
 -                                                      output += formatNumber("d", date.getDate(), 2);
 -                                                      break;
 -                                              case "D":
 -                                                      output += formatName("D", date.getDay(), dayNamesShort, dayNames);
 -                                                      break;
 -                                              case "o":
 -                                                      output += formatNumber("o",
 -                                                              Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
 -                                                      break;
 -                                              case "m":
 -                                                      output += formatNumber("m", date.getMonth() + 1, 2);
 -                                                      break;
 -                                              case "M":
 -                                                      output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
 -                                                      break;
 -                                              case "y":
 -                                                      output += (lookAhead("y") ? date.getFullYear() :
 -                                                              (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
 -                                                      break;
 -                                              case "@":
 -                                                      output += date.getTime();
 -                                                      break;
 -                                              case "!":
 -                                                      output += date.getTime() * 10000 + this._ticksTo1970;
 -                                                      break;
 -                                              case "'":
 -                                                      if (lookAhead("'")) {
 -                                                              output += "'";
 -                                                      } else {
 -                                                              literal = true;
 -                                                      }
 -                                                      break;
 -                                              default:
 -                                                      output += format.charAt(iFormat);
 -                                      }
 -                              }
+       },
 -              return output;
++      valueAsDate: function( value ) {
++              if ( arguments.length ) {
++                      if ( this.calendarInstance._isValid( value ) ) {
++                              this.calendarInstance.valueAsDate( value );
++                              this.element.val( this.calendarInstance._format( value ) );
+                       }
++              } else {
++                      return this._getParsedValue();
+               }
 -      /* Extract all possible characters from the date format. */
 -      _possibleChars: function (format) {
 -              var iFormat,
 -                      chars = "",
 -                      literal = false,
 -                      // Check whether a format character is doubled
 -                      lookAhead = function(match) {
 -                              var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
 -                              if (matches) {
 -                                      iFormat++;
 -                              }
 -                              return matches;
 -                      };
 -
 -              for (iFormat = 0; iFormat < format.length; iFormat++) {
 -                      if (literal) {
 -                              if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
 -                                      literal = false;
 -                              } else {
 -                                      chars += format.charAt(iFormat);
 -                              }
 -                      } else {
 -                              switch (format.charAt(iFormat)) {
 -                                      case "d": case "m": case "y": case "@":
 -                                              chars += "0123456789";
 -                                              break;
 -                                      case "D": case "M":
 -                                              return null; // Accept anything
 -                                      case "'":
 -                                              if (lookAhead("'")) {
 -                                                      chars += "'";
 -                                              } else {
 -                                                      literal = true;
 -                                              }
 -                                              break;
 -                                      default:
 -                                              chars += format.charAt(iFormat);
 -                              }
 -                      }
 -              }
 -              return chars;
+       },
 -      /* Get a setting value, defaulting if necessary. */
 -      _get: function(inst, name) {
 -              return inst.settings[name] !== undefined ?
 -                      inst.settings[name] : this._defaults[name];
++      isValid: function() {
++              return this.calendarInstance._isValid( this._getParsedValue() );
+       },
 -      /* Parse existing date and initialise date picker. */
 -      _setDateFromField: function(inst, noDefault) {
 -              if (inst.input.val() === inst.lastVal) {
 -                      return;
 -              }
 -
 -              var dateFormat = this._get(inst, "dateFormat"),
 -                      dates = inst.lastVal = inst.input ? inst.input.val() : null,
 -                      defaultDate = this._getDefaultDate(inst),
 -                      date = defaultDate,
 -                      settings = this._getFormatConfig(inst);
 -
 -              try {
 -                      date = this.parseDate(dateFormat, dates, settings) || defaultDate;
 -              } catch (event) {
 -                      dates = (noDefault ? "" : dates);
 -              }
 -              inst.selectedDay = date.getDate();
 -              inst.drawMonth = inst.selectedMonth = date.getMonth();
 -              inst.drawYear = inst.selectedYear = date.getFullYear();
 -              inst.currentDay = (dates ? date.getDate() : 0);
 -              inst.currentMonth = (dates ? date.getMonth() : 0);
 -              inst.currentYear = (dates ? date.getFullYear() : 0);
 -              this._adjustInstDate(inst);
++      _destroy: function() {
++              this.calendarInstance.destroy();
++              this.calendar.remove();
++              this.element.removeAttr( "aria-haspopup aria-owns" );
+       },
 -      /* Retrieve the default date shown on opening. */
 -      _getDefaultDate: function(inst) {
 -              return this._restrictMinMax(inst,
 -                      this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
++      widget: function() {
++              return this.calendar;
+       },
 -      /* A date may be specified as an exact value or a relative one. */
 -      _determineDate: function(inst, date, defaultDate) {
 -              var offsetNumeric = function(offset) {
 -                              var date = new Date();
 -                              date.setDate(date.getDate() + offset);
 -                              return date;
 -                      },
 -                      offsetString = function(offset) {
 -                              try {
 -                                      return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
 -                                              offset, $.datepicker._getFormatConfig(inst));
 -                              }
 -                              catch (e) {
 -                                      // Ignore
 -                              }
 -
 -                              var date = (offset.toLowerCase().match(/^c/) ?
 -                                      $.datepicker._getDate(inst) : null) || new Date(),
 -                                      year = date.getFullYear(),
 -                                      month = date.getMonth(),
 -                                      day = date.getDate(),
 -                                      pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
 -                                      matches = pattern.exec(offset);
 -
 -                              while (matches) {
 -                                      switch (matches[2] || "d") {
 -                                              case "d" : case "D" :
 -                                                      day += parseInt(matches[1],10); break;
 -                                              case "w" : case "W" :
 -                                                      day += parseInt(matches[1],10) * 7; break;
 -                                              case "m" : case "M" :
 -                                                      month += parseInt(matches[1],10);
 -                                                      day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
 -                                                      break;
 -                                              case "y": case "Y" :
 -                                                      year += parseInt(matches[1],10);
 -                                                      day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
 -                                                      break;
 -                                      }
 -                                      matches = pattern.exec(offset);
 -                              }
 -                              return new Date(year, month, day);
 -                      },
 -                      newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
 -                              (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
++      _getParsedValue: function() {
++              return this.calendarInstance._parse( this.element.val() );
+       },
 -              newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
 -              if (newDate) {
 -                      newDate.setHours(0);
 -                      newDate.setMinutes(0);
 -                      newDate.setSeconds(0);
 -                      newDate.setMilliseconds(0);
++      _setOption: function( key, value ) {
++              this._super( key, value );
 -              return this._daylightSavingAdjust(newDate);
 -      },
++              if ( $.inArray( key, this.calendarOptions ) !== -1 ) {
++                      this.calendarInstance.option( key, value );
+               }
 -      /* Handle switch to/from daylight saving.
 -       * Hours may be non-zero on daylight saving cut-over:
 -       * > 12 when midnight changeover, but then cannot generate
 -       * midnight datetime, so jump to 1AM, otherwise reset.
 -       * @param  date  (Date) the date to check
 -       * @return  (Date) the corrected date
 -       */
 -      _daylightSavingAdjust: function(date) {
 -              if (!date) {
 -                      return null;
 -              date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
 -              return date;
 -      },
 -
 -      /* Set the date(s) directly. */
 -      _setDate: function(inst, date, noChange) {
 -              var clear = !date,
 -                      origMonth = inst.selectedMonth,
 -                      origYear = inst.selectedYear,
 -                      newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
++              if ( key === "appendTo" ) {
++                      this.calendar.appendTo( this._appendTo() );
+               }
 -              inst.selectedDay = inst.currentDay = newDate.getDate();
 -              inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
 -              inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
 -              if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
 -                      this._notifyChange(inst);
 -              this._adjustInstDate(inst);
 -              if (inst.input) {
 -                      inst.input.val(clear ? "" : this._formatDate(inst));
 -              }
 -      },
++              if ( key === "locale" || key === "dateFormat" ) {
++                      this.element.val( this.calendarInstance.value() );
+               }
 -      /* Retrieve the date(s) directly. */
 -      _getDate: function(inst) {
 -              var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
 -                      this._daylightSavingAdjust(new Date(
 -                      inst.currentYear, inst.currentMonth, inst.currentDay)));
 -                      return startDate;
 -      },
 -
 -      /* Attach the onxxx handlers.  These are declared statically so
 -       * they work with static code transformers like Caja.
 -       */
 -      _attachHandlers: function(inst) {
 -              var stepMonths = this._get(inst, "stepMonths"),
 -                      id = "#" + inst.id.replace( /\\\\/g, "\\" );
 -              inst.dpDiv.find("[data-handler]").map(function () {
 -                      var handler = {
 -                              prev: function () {
 -                                      $.datepicker._adjustDate(id, -stepMonths, "M");
 -                              },
 -                              next: function () {
 -                                      $.datepicker._adjustDate(id, +stepMonths, "M");
 -                              },
 -                              hide: function () {
 -                                      $.datepicker._hideDatepicker();
 -                              },
 -                              today: function () {
 -                                      $.datepicker._gotoToday(id);
 -                              },
 -                              selectDay: function () {
 -                                      $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
 -                                      return false;
 -                              },
 -                              selectMonth: function () {
 -                                      $.datepicker._selectMonthYear(id, this, "M");
 -                                      return false;
 -                              },
 -                              selectYear: function () {
 -                                      $.datepicker._selectMonthYear(id, this, "Y");
 -                                      return false;
 -                              }
 -                      };
 -                      $(this).on(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
 -              });
 -      },
 -      /* Generate the HTML for the current state of the date picker. */
 -      _generateHTML: function(inst) {
 -              var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
 -                      controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
 -                      monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
 -                      selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
 -                      cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
 -                      printDate, dRow, tbody, daySettings, otherMonth, unselectable,
 -                      tempDate = new Date(),
 -                      today = this._daylightSavingAdjust(
 -                              new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
 -                      isRTL = this._get(inst, "isRTL"),
 -                      showButtonPanel = this._get(inst, "showButtonPanel"),
 -                      hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
 -                      navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
 -                      numMonths = this._getNumberOfMonths(inst),
 -                      showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
 -                      stepMonths = this._get(inst, "stepMonths"),
 -                      isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
 -                      currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
 -                              new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
 -                      minDate = this._getMinMaxDate(inst, "min"),
 -                      maxDate = this._getMinMaxDate(inst, "max"),
 -                      drawMonth = inst.drawMonth - showCurrentAtPos,
 -                      drawYear = inst.drawYear;
 -
 -              if (drawMonth < 0) {
 -                      drawMonth += 12;
 -                      drawYear--;
 -              }
 -              if (maxDate) {
 -                      maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
 -                              maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
 -                      maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
 -                      while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
 -                              drawMonth--;
 -                              if (drawMonth < 0) {
 -                                      drawMonth = 11;
 -                                      drawYear--;
 -                              }
++              if ( key === "disabled" ) {
++                      this.element
++                              .prop( "disabled", value )
++                              .toggleClass( "ui-state-disabled", value )
++                              .attr( "aria-disabled", value );
 -              inst.drawMonth = drawMonth;
 -              inst.drawYear = drawYear;
 -
 -              prevText = this._get(inst, "prevText");
 -              prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
 -                      this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
 -                      this._getFormatConfig(inst)));
 -
 -              prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
 -                      "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
 -                      " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
 -                      (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+ prevText +"'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>"));
++                      if ( value ) {
++                              this.close();
+                       }
+               }
 -              nextText = this._get(inst, "nextText");
 -              nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
 -                      this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
 -                      this._getFormatConfig(inst)));
 -
 -              next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
 -                      "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
 -                      " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
 -                      (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+ nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>"));
 -
 -              currentText = this._get(inst, "currentText");
 -              gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
 -              currentText = (!navigationAsDateFormat ? currentText :
 -                      this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
 -
 -              controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
 -                      this._get(inst, "closeText") + "</button>" : "");
 -
 -              buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
 -                      (this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
 -                      ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
 -
 -              firstDay = parseInt(this._get(inst, "firstDay"),10);
 -              firstDay = (isNaN(firstDay) ? 0 : firstDay);
 -
 -              showWeek = this._get(inst, "showWeek");
 -              dayNames = this._get(inst, "dayNames");
 -              dayNamesMin = this._get(inst, "dayNamesMin");
 -              monthNames = this._get(inst, "monthNames");
 -              monthNamesShort = this._get(inst, "monthNamesShort");
 -              beforeShowDay = this._get(inst, "beforeShowDay");
 -              showOtherMonths = this._get(inst, "showOtherMonths");
 -              selectOtherMonths = this._get(inst, "selectOtherMonths");
 -              defaultDate = this._getDefaultDate(inst);
 -              html = "";
 -              dow;
 -              for (row = 0; row < numMonths[0]; row++) {
 -                      group = "";
 -                      this.maxRows = 4;
 -                      for (col = 0; col < numMonths[1]; col++) {
 -                              selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
 -                              cornerClass = " ui-corner-all";
 -                              calender = "";
 -                              if (isMultiMonth) {
 -                                      calender += "<div class='ui-datepicker-group";
 -                                      if (numMonths[1] > 1) {
 -                                              switch (col) {
 -                                                      case 0: calender += " ui-datepicker-group-first";
 -                                                              cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
 -                                                      case numMonths[1]-1: calender += " ui-datepicker-group-last";
 -                                                              cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
 -                                                      default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
 -                                              }
 -                                      }
 -                                      calender += "'>";
 -                              }
 -                              calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
 -                                      (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
 -                                      (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
 -                                      this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
 -                                      row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
 -                                      "</div><table class='ui-datepicker-calendar'><thead>" +
 -                                      "<tr>";
 -                              thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
 -                              for (dow = 0; dow < 7; dow++) { // days of the week
 -                                      day = (dow + firstDay) % 7;
 -                                      thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
 -                                              "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
 -                              }
 -                              calender += thead + "</tr></thead><tbody>";
 -                              daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
 -                              if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
 -                                      inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
 -                              }
 -                              leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
 -                              curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
 -                              numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
 -                              this.maxRows = numRows;
 -                              printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
 -                              for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
 -                                      calender += "<tr>";
 -                                      tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
 -                                              this._get(inst, "calculateWeek")(printDate) + "</td>");
 -                                      for (dow = 0; dow < 7; dow++) { // create date picker days
 -                                              daySettings = (beforeShowDay ?
 -                                                      beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
 -                                              otherMonth = (printDate.getMonth() !== drawMonth);
 -                                              unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
 -                                                      (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
 -                                              tbody += "<td class='" +
 -                                                      ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
 -                                                      (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
 -                                                      ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
 -                                                      (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
 -                                                      // or defaultDate is current printedDate and defaultDate is selectedDate
 -                                                      " " + this._dayOverClass : "") + // highlight selected day
 -                                                      (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") +  // highlight unselectable days
 -                                                      (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
 -                                                      (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
 -                                                      (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
 -                                                      ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
 -                                                      (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
 -                                                      (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
 -                                                      (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
 -                                                      (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
 -                                                      (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
 -                                                      (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
 -                                                      "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
 -                                              printDate.setDate(printDate.getDate() + 1);
 -                                              printDate = this._daylightSavingAdjust(printDate);
 -                                      }
 -                                      calender += tbody + "</tr>";
 -                              }
 -                              drawMonth++;
 -                              if (drawMonth > 11) {
 -                                      drawMonth = 0;
 -                                      drawYear++;
 -                              }
 -                              calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
 -                                                      ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
 -                              group += calender;
 -                      }
 -                      html += group;
 -              }
 -              html += buttonPanel;
 -              inst._keyEvent = false;
 -              return html;
 -      },
 -
 -      /* Generate the month and year header. */
 -      _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
 -                      secondary, monthNames, monthNamesShort) {
 -
 -              var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
 -                      changeMonth = this._get(inst, "changeMonth"),
 -                      changeYear = this._get(inst, "changeYear"),
 -                      showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
 -                      html = "<div class='ui-datepicker-title'>",
 -                      monthHtml = "";
 -
 -              // month selection
 -              if (secondary || !changeMonth) {
 -                      monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
 -              } else {
 -                      inMinYear = (minDate && minDate.getFullYear() === drawYear);
 -                      inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
 -                      monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
 -                      for ( month = 0; month < 12; month++) {
 -                              if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
 -                                      monthHtml += "<option value='" + month + "'" +
 -                                              (month === drawMonth ? " selected='selected'" : "") +
 -                                              ">" + monthNamesShort[month] + "</option>";
 -                              }
 -                      }
 -                      monthHtml += "</select>";
 -              }
 -
 -              if (!showMonthAfterYear) {
 -                      html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
 -              }
 -
 -              // year selection
 -              if ( !inst.yearshtml ) {
 -                      inst.yearshtml = "";
 -                      if (secondary || !changeYear) {
 -                              html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
 -                      } else {
 -                              // determine range of years to display
 -                              years = this._get(inst, "yearRange").split(":");
 -                              thisYear = new Date().getFullYear();
 -                              determineYear = function(value) {
 -                                      var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
 -                                              (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
 -                                              parseInt(value, 10)));
 -                                      return (isNaN(year) ? thisYear : year);
 -                              };
 -                              year = determineYear(years[0]);
 -                              endYear = Math.max(year, determineYear(years[1] || ""));
 -                              year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
 -                              endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
 -                              inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
 -                              for (; year <= endYear; year++) {
 -                                      inst.yearshtml += "<option value='" + year + "'" +
 -                                              (year === drawYear ? " selected='selected'" : "") +
 -                                              ">" + year + "</option>";
 -                              }
 -                              inst.yearshtml += "</select>";
 -
 -                              html += inst.yearshtml;
 -                              inst.yearshtml = null;
 -                      }
 -
 -              html += this._get(inst, "yearSuffix");
 -              if (showMonthAfterYear) {
 -                      html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
 -              }
 -              html += "</div>"; // Close datepicker_header
 -              return html;
 -      },
 -
 -      /* Adjust one of the date sub-fields. */
 -      _adjustInstDate: function(inst, offset, period) {
 -              var year = inst.drawYear + (period === "Y" ? offset : 0),
 -                      month = inst.drawMonth + (period === "M" ? offset : 0),
 -                      day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
 -                      date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
 -
 -              inst.selectedDay = date.getDate();
 -              inst.drawMonth = inst.selectedMonth = date.getMonth();
 -              inst.drawYear = inst.selectedYear = date.getFullYear();
 -              if (period === "M" || period === "Y") {
 -                      this._notifyChange(inst);
 -              }
 -      },
 -
 -      /* Ensure a date is within any min/max bounds. */
 -      _restrictMinMax: function(inst, date) {
 -              var minDate = this._getMinMaxDate(inst, "min"),
 -                      maxDate = this._getMinMaxDate(inst, "max"),
 -                      newDate = (minDate && date < minDate ? minDate : date);
 -              return (maxDate && newDate > maxDate ? maxDate : newDate);
 -      },
 -
 -      /* Notify change of month/year. */
 -      _notifyChange: function(inst) {
 -              var onChange = this._get(inst, "onChangeMonthYear");
 -              if (onChange) {
 -                      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. */
 -      _getMinMaxDate: function(inst, minMax) {
 -              return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
 -      },
 -
 -      /* Find the number of days in a given month. */
 -      _getDaysInMonth: function(year, month) {
 -              return 32 - this._daylightSavingAdjust(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),
 -                      date = this._daylightSavingAdjust(new Date(curYear,
 -                      curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
 -
 -              if (offset < 0) {
 -                      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) {
 -              var yearSplit, currentYear,
 -                      minDate = this._getMinMaxDate(inst, "min"),
 -                      maxDate = this._getMinMaxDate(inst, "max"),
 -                      minYear = null,
 -                      maxYear = null,
 -                      years = this._get(inst, "yearRange");
 -                      if (years){
 -                              yearSplit = years.split(":");
 -                              currentYear = new Date().getFullYear();
 -                              minYear = parseInt(yearSplit[0], 10);
 -                              maxYear = parseInt(yearSplit[1], 10);
 -                              if ( yearSplit[0].match(/[+\-].*/) ) {
 -                                      minYear += currentYear;
 -                              }
 -                              if ( yearSplit[1].match(/[+\-].*/) ) {
 -                                      maxYear += currentYear;
 -                              }
 -                      }
 -
 -              return ((!minDate || date.getTime() >= minDate.getTime()) &&
 -                      (!maxDate || date.getTime() <= maxDate.getTime()) &&
 -                      (!minYear || date.getFullYear() >= minYear) &&
 -                      (!maxYear || date.getFullYear() <= maxYear));
 -      },
 -
 -      /* Provide the configuration settings for formatting/parsing. */
 -      _getFormatConfig: function(inst) {
 -              var shortYearCutoff = this._get(inst, "shortYearCutoff");
 -              shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
 -                      new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
 -              return {shortYearCutoff: shortYearCutoff,
 -                      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) {
 -                      inst.currentDay = inst.selectedDay;
 -                      inst.currentMonth = inst.selectedMonth;
 -                      inst.currentYear = inst.selectedYear;
 -              }
 -              var date = (day ? (typeof day === "object" ? day :
 -                      this._daylightSavingAdjust(new Date(year, month, day))) :
 -                      this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
 -              return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
++              if ( key === "position" ) {
++                      this.calendar.position( this._buildPosition() );
+               }
 -/*
 - * Bind hover events for datepicker elements.
 - * Done via delegate so the binding only occurs once in the lifetime of the parent div.
 - * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
 - */
 -function datepicker_bindHover(dpDiv) {
 -      var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
 -      return dpDiv.on( "mouseout", selector, function() {
 -                      $(this).removeClass("ui-state-hover");
 -                      if (this.className.indexOf("ui-datepicker-prev") !== -1) {
 -                              $(this).removeClass("ui-datepicker-prev-hover");
 -                      }
 -                      if (this.className.indexOf("ui-datepicker-next") !== -1) {
 -                              $(this).removeClass("ui-datepicker-next-hover");
 -                      }
 -              })
 -              .on( "mouseover", selector, datepicker_handleMouseover );
 -}
 -
 -function datepicker_handleMouseover() {
 -      if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
 -              $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
 -              $(this).addClass("ui-state-hover");
 -              if (this.className.indexOf("ui-datepicker-prev") !== -1) {
 -                      $(this).addClass("ui-datepicker-prev-hover");
 -              }
 -              if (this.className.indexOf("ui-datepicker-next") !== -1) {
 -                      $(this).addClass("ui-datepicker-next-hover");
 -              }
 -      }
 -}
 -
 -/* jQuery extend now ignores nulls! */
 -function datepicker_extendRemove(target, props) {
 -      $.extend(target, props);
 -      for (var name in props) {
 -              if (props[name] == null) {
 -                      target[name] = props[name];
 -              }
 -      }
 -      return target;
 -}
 -
 -/* Invoke the datepicker functionality.
 -   @param  options  string - a command, optionally followed by additional parameters or
 -                                      Object - settings for attaching new datepicker functionality
 -   @return  jQuery object */
 -$.fn.datepicker = function(options){
 -
 -      /* Verify an empty collection wasn't passed - Fixes #6976 */
 -      if ( !this.length ) {
 -              return this;
 -      }
 -
 -      /* Initialise the date picker. */
 -      if (!$.datepicker.initialized) {
 -              $(document).on( "mousedown", $.datepicker._checkExternalClick );
 -              $.datepicker.initialized = true;
 -      }
 -
 -      /* Append datepicker main container to body if not exist. */
 -      if ($("#"+$.datepicker._mainDivId).length === 0) {
 -              $("body").append($.datepicker.dpDiv);
 -      }
 -
 -      var otherArgs = Array.prototype.slice.call(arguments, 1);
 -      if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
 -              return $.datepicker["_" + options + "Datepicker"].
 -                      apply($.datepicker, [this[0]].concat(otherArgs));
 -      }
 -      if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
 -              return $.datepicker["_" + options + "Datepicker"].
 -                      apply($.datepicker, [this[0]].concat(otherArgs));
 -      }
 -      return this.each(function() {
 -              typeof options === "string" ?
 -                      $.datepicker["_" + options + "Datepicker"].
 -                              apply($.datepicker, [this].concat(otherArgs)) :
 -                      $.datepicker._attachDatepicker(this, options);
 -      });
 -};
 -
 -$.datepicker = new Datepicker(); // singleton instance
 -$.datepicker.initialized = false;
 -$.datepicker.uuid = new Date().getTime();
 -$.datepicker.version = "@VERSION";
+       }
+ });
 -return $.datepicker;
++$.each( $.ui.datepicker.prototype.calendarOptions, function( index, option ) {
++      $.ui.datepicker.prototype.options[ option ] = $.ui.calendar.prototype.options[ option ];
++});
++return widget;
+ }));