summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Richardson <trentdrichardson@gmail.com>2013-08-11 17:53:41 -0400
committerTrent Richardson <trentdrichardson@gmail.com>2013-08-11 17:53:41 -0400
commit18de616243dae142bcef4c7bcbe050348454ca57 (patch)
tree3f98df5ba2ca135f5cb2aead9715a856d3dee49f
parent2675998f0275fd7b1606756da0e8e211c85ad414 (diff)
parent9c7d37fe17fe033e7103cbb41eec273d1225f84b (diff)
downloadjQuery-Timepicker-Addon-18de616243dae142bcef4c7bcbe050348454ca57.zip
jQuery-Timepicker-Addon-18de616243dae142bcef4c7bcbe050348454ca57.tar.gz
jQuery-Timepicker-Addon-18de616243dae142bcef4c7bcbe050348454ca57.tar.bz2
Merge branch 'dev'
-rw-r--r--.gitignore3
-rw-r--r--.jshintrc15
-rw-r--r--CONTRIBUTING.md31
-rw-r--r--Gruntfile.js146
-rw-r--r--LICENSE-MIT22
-rw-r--r--README.md13
-rw-r--r--bower.json (renamed from component.json)2
-rw-r--r--composer.json26
-rw-r--r--dist/i18n/jquery-ui-timepicker-af.js (renamed from i18n/jquery-ui-timepicker-af.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-bg.js (renamed from i18n/jquery-ui-timepicker-bg.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-ca.js (renamed from i18n/jquery-ui-timepicker-ca.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-cs.js (renamed from i18n/jquery-ui-timepicker-cs.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-da.js (renamed from i18n/jquery-ui-timepicker-da.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-de.js (renamed from i18n/jquery-ui-timepicker-de.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-el.js (renamed from i18n/jquery-ui-timepicker-el.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-es.js (renamed from i18n/jquery-ui-timepicker-es.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-et.js (renamed from i18n/jquery-ui-timepicker-et.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-eu.js (renamed from i18n/jquery-ui-timepicker-eu.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-fi.js (renamed from i18n/jquery-ui-timepicker-fi.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-fr.js (renamed from i18n/jquery-ui-timepicker-fr.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-gl.js (renamed from i18n/jquery-ui-timepicker-gl.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-he.js (renamed from i18n/jquery-ui-timepicker-he.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-hr.js (renamed from i18n/jquery-ui-timepicker-hr.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-hu.js (renamed from i18n/jquery-ui-timepicker-hu.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-id.js (renamed from i18n/jquery-ui-timepicker-id.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-it.js (renamed from i18n/jquery-ui-timepicker-it.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-ja.js (renamed from i18n/jquery-ui-timepicker-ja.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-ko.js (renamed from i18n/jquery-ui-timepicker-ko.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-lt.js (renamed from i18n/jquery-ui-timepicker-lt.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-nl.js (renamed from i18n/jquery-ui-timepicker-nl.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-no.js (renamed from i18n/jquery-ui-timepicker-no.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-pl.js (renamed from i18n/jquery-ui-timepicker-pl.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-pt-BR.js (renamed from i18n/jquery-ui-timepicker-pt-BR.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-pt.js (renamed from i18n/jquery-ui-timepicker-pt.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-ro.js (renamed from i18n/jquery-ui-timepicker-ro.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-ru.js (renamed from i18n/jquery-ui-timepicker-ru.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-sk.js (renamed from i18n/jquery-ui-timepicker-sk.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-sv.js (renamed from i18n/jquery-ui-timepicker-sv.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-th.js (renamed from i18n/jquery-ui-timepicker-th.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-tr.js (renamed from i18n/jquery-ui-timepicker-tr.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-uk.js (renamed from i18n/jquery-ui-timepicker-uk.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-vi.js (renamed from i18n/jquery-ui-timepicker-vi.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-zh-CN.js (renamed from i18n/jquery-ui-timepicker-zh-CN.js)0
-rw-r--r--dist/i18n/jquery-ui-timepicker-zh-TW.js (renamed from i18n/jquery-ui-timepicker-zh-TW.js)0
-rw-r--r--dist/index.html973
-rw-r--r--dist/jquery-ui-sliderAccess.js (renamed from jquery-ui-sliderAccess.js)10
-rw-r--r--dist/jquery-ui-timepicker-addon.css11
-rw-r--r--dist/jquery-ui-timepicker-addon.js2134
-rw-r--r--dist/jquery-ui-timepicker-addon.min.css5
-rw-r--r--dist/jquery-ui-timepicker-addon.min.js5
-rw-r--r--index.html975
-rw-r--r--jquery-ui-timepicker-addon.css10
-rw-r--r--jquery-ui-timepicker-addon.json27
-rw-r--r--lib/jasmine-1.3.1/MIT.LICENSE20
-rw-r--r--lib/jasmine-1.3.1/jasmine-html.js681
-rw-r--r--lib/jasmine-1.3.1/jasmine.css82
-rw-r--r--lib/jasmine-1.3.1/jasmine.js2600
-rw-r--r--lib/jasmine-jquery.js659
-rw-r--r--package.json22
-rw-r--r--src/.jshintrc17
-rw-r--r--src/docs/examples.html441
-rw-r--r--src/docs/footer.html37
-rw-r--r--src/docs/formatting.html40
-rw-r--r--src/docs/header.html75
-rw-r--r--src/docs/i18n.html65
-rw-r--r--src/docs/intro.html59
-rw-r--r--src/docs/options.html252
-rw-r--r--src/i18n/jquery-ui-timepicker-af.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-bg.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-ca.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-cs.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-da.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-de.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-el.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-es.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-et.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-eu.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-fi.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-fr.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-gl.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-he.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-hr.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-hu.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-id.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-it.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-ja.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-ko.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-lt.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-nl.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-no.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-pl.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-pt-BR.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-pt.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-ro.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-ru.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-sk.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-sv.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-th.js18
-rw-r--r--src/i18n/jquery-ui-timepicker-tr.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-uk.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-vi.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-zh-CN.js21
-rw-r--r--src/i18n/jquery-ui-timepicker-zh-TW.js21
-rw-r--r--src/jquery-ui-sliderAccess.js91
-rw-r--r--src/jquery-ui-timepicker-addon.css11
-rw-r--r--src/jquery-ui-timepicker-addon.js (renamed from jquery-ui-timepicker-addon.js)1044
-rw-r--r--test/.jshintrc41
-rw-r--r--test/SpecRunner.html52
-rw-r--r--test/jquery-ui-timepicker-addon_spec.js651
109 files changed, 10591 insertions, 1510 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..26b3838
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/node_modules/
+*.iml
+.idea
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..54c84f1
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,15 @@
+{
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "sub": true,
+ "undef": true,
+ "unused": true,
+ "boss": true,
+ "eqnull": true,
+ "node": true,
+ "es5": true
+}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..260644f
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,31 @@
+# Contributing
+
+## Important notes
+Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory!
+
+### Code style
+Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already (tabs).**
+
+### PhantomJS
+While Grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/), this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers.
+
+## Modifying the code
+First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
+
+Test that Grunt's CLI is installed by running `grunt --version`. If the command isn't found, run `npm install -g grunt-cli`. For more information about installing Grunt, see the [getting started guide](http://gruntjs.com/getting-started).
+
+1. Fork and clone the repo.
+1. Run `npm install` to install all dependencies (including Grunt).
+1. Run `grunt` to grunt this project.
+
+Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken.
+
+## Submitting pull requests
+
+1. Create a new branch, please don't work in your `master` branch directly. Please pull from the `dev` branch.
+1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
+1. Fix stuff.
+1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
+1. Open `test/*.html` unit test file(s) in actual browser to ensure tests pass everywhere.
+1. Update the documentation to reflect any changes.
+1. Push to your fork and submit a pull request (back to the `dev` branch).
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..75d9770
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,146 @@
+'use strict';
+
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ // Metadata.
+ pkg: grunt.file.readJSON('jquery-ui-timepicker-addon.json'),
+ banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
+ '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
+ '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
+ '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
+ ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
+ // Task configuration.
+ clean: {
+ files: ['dist']
+ },
+ copy: {
+ dist: {
+ files: [
+ //{ src: 'src/index.html', dest: 'dist/index.html' },
+ { src: 'src/<%= pkg.name %>.css', dest: 'dist/<%= pkg.name %>.css' },
+ { src: 'src/jquery-ui-sliderAccess.js', dest: 'dist/jquery-ui-sliderAccess.js' },
+ { src: 'src/i18n/jquery-ui-timepicker-*.js', dest: 'dist/i18n/', expand:true, flatten: true }
+ ]
+ }
+ },
+ concat: {
+ dist: {
+ options: {
+ banner: '<%= banner %>',
+ stripBanners: true
+ },
+ src: ['src/<%= pkg.name %>.js'],
+ dest: 'dist/<%= pkg.name %>.js'
+ },
+ docs: {
+ src: [
+ 'src/docs/header.html',
+ 'src/docs/intro.html',
+ 'src/docs/options.html',
+ 'src/docs/formatting.html',
+ 'src/docs/i18n.html',
+ 'src/docs/examples.html',
+ 'src/docs/footer.html'
+ ],
+ dest: 'dist/index.html'
+ }
+ },
+ uglify: {
+ options: {
+ banner: '<%= banner %>'
+ },
+ dist: {
+ src: '<%= concat.dist.dest %>',
+ dest: 'dist/<%= pkg.name %>.min.js'
+ }
+ },
+ cssmin: {
+ options: {
+ banner: '<%= banner %>'
+ },
+ dist: {
+ src: 'dist/<%= pkg.name %>.css',
+ dest: 'dist/<%= pkg.name %>.min.css'
+ }
+ },
+ replace: {
+ dist: {
+ options: {
+ variables: {
+ version: '<%= pkg.version %>',
+ timestamp: '<%= grunt.template.today("yyyy-mm-dd") %>'
+ },
+ prefix: '@@'
+ },
+ files: [
+ { src: 'dist/<%= pkg.name %>.js', dest: 'dist/<%= pkg.name %>.js' },
+ { src: 'dist/<%= pkg.name %>.css', dest: 'dist/<%= pkg.name %>.css' },
+ { src: 'dist/index.html', dest: 'dist/index.html' }
+ ]
+ }
+ },
+ jasmine: {
+ src: 'src/<%= pkg.name %>.js',
+ options: {
+ specs: 'test/*_spec.js',
+ vendor: [
+ 'http://code.jquery.com/jquery-1.10.1.min.js',
+ 'http://code.jquery.com/ui/1.10.3/jquery-ui.min.js',
+ 'http://github.com/searls/jasmine-fixture/releases/1.0.5/1737/jasmine-fixture.js'
+ ]
+ }
+ },
+ jshint: {
+ gruntfile: {
+ options: {
+ jshintrc: '.jshintrc'
+ },
+ src: 'Gruntfile.js'
+ },
+ src: {
+ options: {
+ jshintrc: 'src/.jshintrc'
+ },
+ src: ['src/**/*.js']
+ },
+ test: {
+ options: {
+ jshintrc: 'test/.jshintrc'
+ },
+ src: ['test/**/*.js']
+ }
+ },
+ watch: {
+ gruntfile: {
+ files: '<%= jshint.gruntfile.src %>',
+ tasks: ['jshint:gruntfile']
+ },
+ src: {
+ files: 'src/**',//'<%= jshint.src.src %>',
+ tasks: ['jshint:src', 'jasmine', 'clean', 'copy', 'concat', 'replace', 'uglify', 'cssmin']
+ //tasks: ['jshint:src', 'jasmine']
+ },
+ test: {
+ files: '<%= jshint.test.src %>',
+ tasks: ['jshint:test', 'jasmine']
+ }
+ }
+ });
+
+ // These plugins provide necessary tasks.
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ grunt.loadNpmTasks('grunt-contrib-concat');
+ grunt.loadNpmTasks('grunt-contrib-copy');
+ grunt.loadNpmTasks('grunt-replace');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-cssmin');
+ grunt.loadNpmTasks('grunt-contrib-jasmine');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-watch');
+
+ // Default task.
+ grunt.registerTask('default', ['jshint', 'jasmine', 'clean', 'copy', 'concat', 'replace', 'uglify', 'cssmin']);
+
+};
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..957a11c
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,22 @@
+Copyright (c) 2013 Trent Richardson
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index 62907c4..87e76a1 100644
--- a/README.md
+++ b/README.md
@@ -9,12 +9,17 @@ About
Use
---
-- To use this plugin you must include jQuery and jQuery UI with datepicker and slider
-- Include timepicker-addon script
-- now use timepicker with $('#selector').datetimepicker() or $('#selector').timepicker()
+I recommend getting the eBook [Handling Time](https://sellfy.com/p/8gxZ) as it has a lot of example code to get started. The quick and dirty:
+
+- To use this plugin you must include jQuery (1.6+) and jQuery UI with datepicker (and optionally slider).
+- Include timepicker-addon script located in the `dist` directory.
+- now use timepicker with `$('#selector').datetimepicker()` or `$('#selector').timepicker()`.
Contributing Code - Please Read!
--------------------------------
- All code contributions and bug reports are much appreciated.
- Please be sure to apply your fixes to the "dev" branch.
-- Also note tabs are appreciated over spaces. \ No newline at end of file
+- Also note tabs are appreciated over spaces.
+- Please read the [CONTRIBUTING.md][contributingmd] for more on using Grunt to produce builds.
+
+[contributingmd]: CONTRIBUTING.md \ No newline at end of file
diff --git a/component.json b/bower.json
index efcbec5..780c465 100644
--- a/component.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "jquery-timepicker-addon",
- "version": "1.3.1",
+ "version": "1.4",
"repository": {
"type": "git",
"url": "git://github.com/trentrichardson/jQuery-Timepicker-Addon.git"
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..150661e
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,26 @@
+{
+ "name": "trentrichardson/jquery-timepicker-addon",
+ "description": "Adds a timepicker to jQueryUI Datepicker.",
+ "type": "component",
+ "homepage": "http://trentrichardson.com/examples/timepicker/",
+ "license": [
+ "MIT"
+ ],
+ "require": {
+ "robloach/component-installer": "*",
+ "components/jqueryui": "~1.10.2"
+ },
+ "extra": {
+ "component": {
+ "name": "jquery-timepicker-addon",
+ "scripts": [
+ "dist/jquery-ui-sliderAccess.js",
+ "dist/jquery-ui-timepicker-addon.js",
+ "dist/i18n/**"
+ ],
+ "styles": [
+ "dist/jquery-ui-timepicker-addon.css"
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/i18n/jquery-ui-timepicker-af.js b/dist/i18n/jquery-ui-timepicker-af.js
index fe9f8c5..fe9f8c5 100644
--- a/i18n/jquery-ui-timepicker-af.js
+++ b/dist/i18n/jquery-ui-timepicker-af.js
diff --git a/i18n/jquery-ui-timepicker-bg.js b/dist/i18n/jquery-ui-timepicker-bg.js
index 1efb439..1efb439 100644
--- a/i18n/jquery-ui-timepicker-bg.js
+++ b/dist/i18n/jquery-ui-timepicker-bg.js
diff --git a/i18n/jquery-ui-timepicker-ca.js b/dist/i18n/jquery-ui-timepicker-ca.js
index 25b4eed..25b4eed 100644
--- a/i18n/jquery-ui-timepicker-ca.js
+++ b/dist/i18n/jquery-ui-timepicker-ca.js
diff --git a/i18n/jquery-ui-timepicker-cs.js b/dist/i18n/jquery-ui-timepicker-cs.js
index 9d358fa..9d358fa 100644
--- a/i18n/jquery-ui-timepicker-cs.js
+++ b/dist/i18n/jquery-ui-timepicker-cs.js
diff --git a/i18n/jquery-ui-timepicker-da.js b/dist/i18n/jquery-ui-timepicker-da.js
index 7afb189..7afb189 100644
--- a/i18n/jquery-ui-timepicker-da.js
+++ b/dist/i18n/jquery-ui-timepicker-da.js
diff --git a/i18n/jquery-ui-timepicker-de.js b/dist/i18n/jquery-ui-timepicker-de.js
index 286be73..286be73 100644
--- a/i18n/jquery-ui-timepicker-de.js
+++ b/dist/i18n/jquery-ui-timepicker-de.js
diff --git a/i18n/jquery-ui-timepicker-el.js b/dist/i18n/jquery-ui-timepicker-el.js
index 6b7e827..6b7e827 100644
--- a/i18n/jquery-ui-timepicker-el.js
+++ b/dist/i18n/jquery-ui-timepicker-el.js
diff --git a/i18n/jquery-ui-timepicker-es.js b/dist/i18n/jquery-ui-timepicker-es.js
index d73a1e8..d73a1e8 100644
--- a/i18n/jquery-ui-timepicker-es.js
+++ b/dist/i18n/jquery-ui-timepicker-es.js
diff --git a/i18n/jquery-ui-timepicker-et.js b/dist/i18n/jquery-ui-timepicker-et.js
index 2e64cc8..2e64cc8 100644
--- a/i18n/jquery-ui-timepicker-et.js
+++ b/dist/i18n/jquery-ui-timepicker-et.js
diff --git a/i18n/jquery-ui-timepicker-eu.js b/dist/i18n/jquery-ui-timepicker-eu.js
index 41ba5a7..41ba5a7 100644
--- a/i18n/jquery-ui-timepicker-eu.js
+++ b/dist/i18n/jquery-ui-timepicker-eu.js
diff --git a/i18n/jquery-ui-timepicker-fi.js b/dist/i18n/jquery-ui-timepicker-fi.js
index 3f1d95e..3f1d95e 100644
--- a/i18n/jquery-ui-timepicker-fi.js
+++ b/dist/i18n/jquery-ui-timepicker-fi.js
diff --git a/i18n/jquery-ui-timepicker-fr.js b/dist/i18n/jquery-ui-timepicker-fr.js
index a8a46fe..a8a46fe 100644
--- a/i18n/jquery-ui-timepicker-fr.js
+++ b/dist/i18n/jquery-ui-timepicker-fr.js
diff --git a/i18n/jquery-ui-timepicker-gl.js b/dist/i18n/jquery-ui-timepicker-gl.js
index 900e377..900e377 100644
--- a/i18n/jquery-ui-timepicker-gl.js
+++ b/dist/i18n/jquery-ui-timepicker-gl.js
diff --git a/i18n/jquery-ui-timepicker-he.js b/dist/i18n/jquery-ui-timepicker-he.js
index eb71018..eb71018 100644
--- a/i18n/jquery-ui-timepicker-he.js
+++ b/dist/i18n/jquery-ui-timepicker-he.js
diff --git a/i18n/jquery-ui-timepicker-hr.js b/dist/i18n/jquery-ui-timepicker-hr.js
index c314b8e..c314b8e 100644
--- a/i18n/jquery-ui-timepicker-hr.js
+++ b/dist/i18n/jquery-ui-timepicker-hr.js
diff --git a/i18n/jquery-ui-timepicker-hu.js b/dist/i18n/jquery-ui-timepicker-hu.js
index fd1f5e1..fd1f5e1 100644
--- a/i18n/jquery-ui-timepicker-hu.js
+++ b/dist/i18n/jquery-ui-timepicker-hu.js
diff --git a/i18n/jquery-ui-timepicker-id.js b/dist/i18n/jquery-ui-timepicker-id.js
index 50a976b..50a976b 100644
--- a/i18n/jquery-ui-timepicker-id.js
+++ b/dist/i18n/jquery-ui-timepicker-id.js
diff --git a/i18n/jquery-ui-timepicker-it.js b/dist/i18n/jquery-ui-timepicker-it.js
index ea976fd..ea976fd 100644
--- a/i18n/jquery-ui-timepicker-it.js
+++ b/dist/i18n/jquery-ui-timepicker-it.js
diff --git a/i18n/jquery-ui-timepicker-ja.js b/dist/i18n/jquery-ui-timepicker-ja.js
index 15c7b79..15c7b79 100644
--- a/i18n/jquery-ui-timepicker-ja.js
+++ b/dist/i18n/jquery-ui-timepicker-ja.js
diff --git a/i18n/jquery-ui-timepicker-ko.js b/dist/i18n/jquery-ui-timepicker-ko.js
index 0a41c5b..0a41c5b 100644
--- a/i18n/jquery-ui-timepicker-ko.js
+++ b/dist/i18n/jquery-ui-timepicker-ko.js
diff --git a/i18n/jquery-ui-timepicker-lt.js b/dist/i18n/jquery-ui-timepicker-lt.js
index eb7b3c7..eb7b3c7 100644
--- a/i18n/jquery-ui-timepicker-lt.js
+++ b/dist/i18n/jquery-ui-timepicker-lt.js
diff --git a/i18n/jquery-ui-timepicker-nl.js b/dist/i18n/jquery-ui-timepicker-nl.js
index 8189cc4..8189cc4 100644
--- a/i18n/jquery-ui-timepicker-nl.js
+++ b/dist/i18n/jquery-ui-timepicker-nl.js
diff --git a/i18n/jquery-ui-timepicker-no.js b/dist/i18n/jquery-ui-timepicker-no.js
index 1eeee6d..1eeee6d 100644
--- a/i18n/jquery-ui-timepicker-no.js
+++ b/dist/i18n/jquery-ui-timepicker-no.js
diff --git a/i18n/jquery-ui-timepicker-pl.js b/dist/i18n/jquery-ui-timepicker-pl.js
index 5b7d4a9..5b7d4a9 100644
--- a/i18n/jquery-ui-timepicker-pl.js
+++ b/dist/i18n/jquery-ui-timepicker-pl.js
diff --git a/i18n/jquery-ui-timepicker-pt-BR.js b/dist/i18n/jquery-ui-timepicker-pt-BR.js
index 2c1b02f..2c1b02f 100644
--- a/i18n/jquery-ui-timepicker-pt-BR.js
+++ b/dist/i18n/jquery-ui-timepicker-pt-BR.js
diff --git a/i18n/jquery-ui-timepicker-pt.js b/dist/i18n/jquery-ui-timepicker-pt.js
index bc549e0..bc549e0 100644
--- a/i18n/jquery-ui-timepicker-pt.js
+++ b/dist/i18n/jquery-ui-timepicker-pt.js
diff --git a/i18n/jquery-ui-timepicker-ro.js b/dist/i18n/jquery-ui-timepicker-ro.js
index 01acce7..01acce7 100644
--- a/i18n/jquery-ui-timepicker-ro.js
+++ b/dist/i18n/jquery-ui-timepicker-ro.js
diff --git a/i18n/jquery-ui-timepicker-ru.js b/dist/i18n/jquery-ui-timepicker-ru.js
index d7169fa..d7169fa 100644
--- a/i18n/jquery-ui-timepicker-ru.js
+++ b/dist/i18n/jquery-ui-timepicker-ru.js
diff --git a/i18n/jquery-ui-timepicker-sk.js b/dist/i18n/jquery-ui-timepicker-sk.js
index 15700e0..15700e0 100644
--- a/i18n/jquery-ui-timepicker-sk.js
+++ b/dist/i18n/jquery-ui-timepicker-sk.js
diff --git a/i18n/jquery-ui-timepicker-sv.js b/dist/i18n/jquery-ui-timepicker-sv.js
index 4540ac6..4540ac6 100644
--- a/i18n/jquery-ui-timepicker-sv.js
+++ b/dist/i18n/jquery-ui-timepicker-sv.js
diff --git a/i18n/jquery-ui-timepicker-th.js b/dist/i18n/jquery-ui-timepicker-th.js
index 7042e8c..7042e8c 100644
--- a/i18n/jquery-ui-timepicker-th.js
+++ b/dist/i18n/jquery-ui-timepicker-th.js
diff --git a/i18n/jquery-ui-timepicker-tr.js b/dist/i18n/jquery-ui-timepicker-tr.js
index 51f89d6..51f89d6 100644
--- a/i18n/jquery-ui-timepicker-tr.js
+++ b/dist/i18n/jquery-ui-timepicker-tr.js
diff --git a/i18n/jquery-ui-timepicker-uk.js b/dist/i18n/jquery-ui-timepicker-uk.js
index a239fe2..a239fe2 100644
--- a/i18n/jquery-ui-timepicker-uk.js
+++ b/dist/i18n/jquery-ui-timepicker-uk.js
diff --git a/i18n/jquery-ui-timepicker-vi.js b/dist/i18n/jquery-ui-timepicker-vi.js
index 48b05f1..48b05f1 100644
--- a/i18n/jquery-ui-timepicker-vi.js
+++ b/dist/i18n/jquery-ui-timepicker-vi.js
diff --git a/i18n/jquery-ui-timepicker-zh-CN.js b/dist/i18n/jquery-ui-timepicker-zh-CN.js
index 7488c04..7488c04 100644
--- a/i18n/jquery-ui-timepicker-zh-CN.js
+++ b/dist/i18n/jquery-ui-timepicker-zh-CN.js
diff --git a/i18n/jquery-ui-timepicker-zh-TW.js b/dist/i18n/jquery-ui-timepicker-zh-TW.js
index 9cbeabf..9cbeabf 100644
--- a/i18n/jquery-ui-timepicker-zh-TW.js
+++ b/dist/i18n/jquery-ui-timepicker-zh-TW.js
diff --git a/dist/index.html b/dist/index.html
new file mode 100644
index 0000000..63325ff
--- /dev/null
+++ b/dist/index.html
@@ -0,0 +1,973 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Adding a Timepicker to jQuery UI Datepicker</title>
+ <meta name="Description" content="jQuery Timepicker Addon. Add a timepicker to your jQuery UI Datepicker. With options to show only time, format time, and much more." />
+ <meta name="Keywords" content="jQuery, UI, datepicker, timepicker, datetime, time, format" />
+
+ <style type="text/css">
+ body,img,p,h1,h2,h3,h4,h5,h6,form,table,td,ul,ol,li,dl,dt,dd,pre,blockquote,fieldset,label{
+ margin:0;
+ padding:0;
+ border:0;
+ }
+ body{ background-color: #777; border-top: solid 10px #7b94b2; font: 90% Arial, Helvetica, sans-serif; padding: 20px; }
+ h1,h2,h3{ margin: 10px 0; }
+ h1{}
+ h2{ color: #f66; }
+ h3{ color: #6b84a2; }
+ p{ margin: 10px 0; }
+ a{ color: #7b94b2; }
+ ul,ol{ margin: 10px 0 10px 40px; }
+ li{ margin: 4px 0; }
+ dl.defs{ margin: 10px 0 10px 40px; }
+ dl.defs dt{ font-weight: bold; line-height: 20px; margin: 10px 0 0 0; }
+ dl.defs dd{ margin: -20px 0 10px 160px; padding-bottom: 10px; border-bottom: solid 1px #eee;}
+ pre{ font-size: 12px; line-height: 16px; padding: 5px 5px 5px 10px; margin: 10px 0; background-color: #e4f4d4; border-left: solid 5px #9EC45F; overflow: auto; tab-size: 4; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; }
+
+ .wrapper{ background-color: #ffffff; width: 800px; border: solid 1px #eeeeee; padding: 20px; margin: 0 auto; }
+ #tabs{ margin: 20px -20px; border: none; }
+ #tabs, #ui-datepicker-div, .ui-datepicker{ font-size: 85%; }
+ .clear{ clear: both; }
+
+ .example-container{ background-color: #f4f4f4; border-bottom: solid 2px #777777; margin: 0 0 20px 40px; padding: 20px; }
+ .example-container input{ border: solid 1px #aaa; padding: 4px; width: 175px; }
+ .ebook{}
+ .ebook img.ebookimg{ float: left; margin: 0 15px 15px 0; width: 100px; }
+ .ebook .buyp a iframe{ margin-bottom: -5px; }
+ </style>
+
+ <link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
+ <link rel="stylesheet" media="all" type="text/css" href="jquery-ui-timepicker-addon.css" />
+
+ </head>
+ <body>
+ <div class="wrapper">
+ <h1>Adding a Timepicker to jQuery UI Datepicker</h1>
+
+ <p>The timepicker addon adds a timepicker to jQuery UI Datepicker, thus the datepicker and slider components (jQueryUI) are required for using any of these. In addition all datepicker options are still available through the timepicker addon.</p>
+
+ <p>If you are interested in contributing to Timepicker Addon please <a href="http://github.com/trentrichardson/jQuery-Timepicker-Addon" title="Check out Timepicker on GitHub">check it out on GitHub</a>. If you do make additions please keep in mind I enjoy tabs over spaces,.. But contributions are welcome in any form.</p>
+
+ <p><a href="http://trentrichardson.com" title="Back to Blog">Back to Blog</a> or <a href="http://twitter.com/practicalweb" title="Follow Me on Twitter">Follow on Twitter</a></p>
+
+ <a href="http://carbounce.com" title="Car Bounce" style="float: right;display: inline-block;width:380px;padding: 10px;background-color: #fbfbfb;border: dotted 4px #e8e8e8;color: #9EC45F;font-size: 16px;text-decoration:none;letter-spacing:1px;"><img src="http://carbounce.com/img/logo_small.png" alt="Car Bounce" align="left" style="margin-right: 20px;"/>Try my new app to keep you informed of your car's financing status and value.</a>
+
+ <h2>Donation</h2>
+ <p>Has this Timepicker Addon been helpful to you?</p>
+ <div class="donation">
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
+ <input type="hidden" name="cmd" value="_s-xclick">
+ <input type="hidden" name="hosted_button_id" value="C2QQHR7JQGD28">
+ <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+ <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
+ </form>
+ </div>
+
+ <div id="tabs">
+ <ul>
+ <li><a href="#tp-getting-started" title="Getting Started">Getting Started</a></li>
+ <li><a href="#tp-options" title="Options">Options</a></li>
+ <li><a href="#tp-formatting" title="Examples">Formatting</a></li>
+ <li><a href="#tp-localization" title="Examples">Localization</a></li>
+ <li><a href="#tp-examples" title="Examples">Examples</a></li>
+ </ul>
+<!-- ############################################################################# -->
+<!-- Getting Started
+<!-- ############################################################################# -->
+<div id="tp-getting-started">
+ <h2>Getting Started</h2>
+
+ <h3>Highly Recommended</h3>
+
+ <h4>Handling Time eBook</h4>
+ <div class="ebook">
+ <p>Check out the <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook">Handling Time eBook</a> to learn from the basic setup to advanced i18n usage, and from client's javascript to the server's database.</p>
+ <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook"><img src="http://trentrichardson.com/wp-content/uploads/2013/04/time-book-titlepage.jpg" alt="Handling Time eBook" style="float:left;width:100px;margin:0 15px 15px 0;" /></a>
+ <p class="buyp"><a href="https://sellfy.com/p/8gxZ" id="8gxZ" class="sellfy-buy-button">buy</a> eBook + Example code</p>
+ <p class="buyp"><a href="https://sellfy.com/p/LvAG" id="LvAG" class="sellfy-buy-button">buy</a> eBook</p>
+ <p class="buyp"><a href="http://gum.co/ZWYO" class="gumroad-button">Handling Time</a></p>
+ <div class="clear"></div>
+ </div>
+
+ <h4>Subscribe to Blog and Twitter</h4>
+ <p><a href="http://trentrichardson.com" title="Subscribe to TrentRichardson.com via email">Subscribe to my blog via email</a> and follow <a href="http://twitter.com/practicalweb" title="Follow Me on Twitter">@PracticalWeb</a> on Twitter. I post for nearly every new version, so you know about updates.</p>
+ <div class="clear"></div>
+ <br />
+
+ <h3>Download</h3>
+ <p><a href="jquery-ui-timepicker-addon.js" title="Download Timepicker Addon">Download Timepicker Addon</a></p>
+ <p><a href="http://github.com/trentrichardson/jQuery-Timepicker-Addon" title="Check out Timepicker on GitHub">Download/Contribute on GitHub</a> (Need the entire repo? Find a bug? See if its fixed here)</p>
+ <p>There is a small bit of required CSS (<a href="jquery-ui-timepicker-addon.css" title="Download CSS">Download</a>):</p>
+<pre>/* css for timepicker */
+.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
+.ui-timepicker-div dl { text-align: left; }
+.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
+.ui-timepicker-div dl dd { margin: 0 10px 10px 45%; }
+.ui-timepicker-div td { font-size: 90%; }
+.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
+
+.ui-timepicker-rtl{ direction: rtl; }
+.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
+.ui-timepicker-rtl dl dt{ float: right; clear: right; }
+.ui-timepicker-rtl dl dd { margin: 0 45% 10px 10px; }
+</pre>
+ <br />
+
+ <h3>Requirements</h3>
+ <p>You also need to include jQuery and jQuery UI with datepicker and slider wigits. You should include them in your page in the following order:</p>
+ <ol>
+ <li>jQuery</li>
+ <li>jQueryUI (with datepicker and slider wigits)</li>
+ <li>Timepicker</li>
+ </ol>
+
+ <br />
+ <h3>Version</h3>
+ <p>Version 1.4</p>
+
+ <p>Last updated on 2013-08-11</p>
+ <p>jQuery Timepicker Addon is currently available for use in all personal or commercial projects under the MIT license.</p>
+ <p><a href="http://trentrichardson.com/Impromptu/MIT-LICENSE.txt" title="MIT License">MIT License</a></p>
+
+</div>
+
+<!-- ############################################################################# -->
+<!-- Options
+<!-- ############################################################################# -->
+<div id="tp-options">
+ <h2>Options</h2>
+
+ <p>The timepicker does inherit all options from datepicker. However, there are many options that are shared by them both, and many timepicker only options:</p>
+
+ <h3>Localization Options</h3>
+ <dl class="defs">
+ <dt>currentText</dt>
+ <dd><em>Default: "Now", A Localization Setting</em> - Text for the Now button.</dd>
+
+ <dt>closeText</dt>
+ <dd><em>Default: "Done", A Localization Setting</em> - Text for the Close button.</dd>
+
+ <dt>amNames</dt>
+ <dd><em>Default: ['AM', 'A'], A Localization Setting</em> - Array of strings to try and parse against to determine AM.</dd>
+
+ <dt>pmNames</dt>
+ <dd><em>Default: ['PM', 'P'], A Localization Setting</em> - Array of strings to try and parse against to determine PM.</dd>
+
+ <dt>timeFormat</dt>
+ <dd><em>Default: "HH:mm", A Localization Setting</em> - String of format tokens to be replaced with the time. <a href="#tp-formatting" title="Formatting" onclick="$('#tabs').tabs('select',2);">See Formatting</a>.</dd>
+
+ <dt>timeSuffix</dt>
+ <dd><em>Default: "", A Localization Setting</em> - String to place after the formatted time.</dd>
+
+ <dt>timeOnlyTitle</dt>
+ <dd><em>Default: "Choose Time", A Localization Setting</em> - Title of the wigit when using only timepicker.</dd>
+
+ <dt>timeText</dt>
+ <dd><em>Default: "Time", A Localization Setting</em> - Label used within timepicker for the formatted time.</dd>
+
+ <dt>hourText</dt>
+ <dd><em>Default: "Hour", A Localization Setting</em> - Label used to identify the hour slider.</dd>
+
+ <dt>minuteText</dt>
+ <dd><em>Default: "Minute", A Localization Setting</em> - Label used to identify the minute slider.</dd>
+
+ <dt>secondText</dt>
+ <dd><em>Default: "Second", A Localization Setting</em> - Label used to identify the second slider.</dd>
+
+ <dt>millisecText</dt>
+ <dd><em>Default: "Millisecond", A Localization Setting</em> - Label used to identify the millisecond slider.</dd>
+
+ <dt>microsecText</dt>
+ <dd><em>Default: "Microsecond", A Localization Setting</em> - Label used to identify the microsecond slider.</dd>
+
+ <dt>timezoneText</dt>
+ <dd><em>Default: "Timezone", A Localization Setting</em> - Label used to identify the timezone slider.</dd>
+
+ <dt>isRTL</dt>
+ <dd><em>Default: false, A Localization Setting</em> - Right to Left support.</dd>
+ </dl>
+
+ <h3>Alt Field Options</h3>
+ <dl class="defs">
+
+ <dt>altFieldTimeOnly</dt>
+ <dd><em>Default: true</em> - When altField is used from datepicker altField will only receive the formatted time and the original field only receives date.</dd>
+
+ <dt>altSeparator</dt>
+ <dd><em>Default: (separator option)</em> - String placed between formatted date and formatted time in the altField.</dd>
+
+ <dt>altTimeSuffix</dt>
+ <dd><em>Default: (timeSuffix option)</em> - String always placed after the formatted time in the altField.</dd>
+
+ <dt>altTimeFormat</dt>
+ <dd><em>Default: (timeFormat option)</em> - The time format to use with the altField.</dd>
+ </dl>
+
+ <h3>Timezone Options</h3>
+ <dl class="defs">
+
+ <dt>timezoneList</dt>
+ <dd><em>Default: [generated timezones]</em> - An array of timezones used to populate the timezone select. Can be an array of values or an array of objects: { label: "EDT", value: -240 }. The value should be the offset number in minutes. So "-0400" which is the format "-hhmm", would equate to -240 minutes.</dd>
+ </dl>
+
+ <h3>Time Field Options</h3>
+ <dl class="defs">
+
+ <dt>controlType</dt>
+ <dd><em>Default: 'slider'</em> - Whether to use 'slider' or 'select'. If 'slider' is unavailable through jQueryUI, 'select' will be used. For advanced usage you may pass an object which implements "create", "options", "value" methods to use controls other than sliders or selects. See the _controls property in the source code for more details.
+<pre>{
+ create: function(tp_inst, obj, unit, val, min, max, step){
+ // generate whatever controls you want here, just return obj
+ },
+ options: function(tp_inst, obj, unit, opts, val){
+ // if val==undefined return the value, else return obj
+ },
+ value: function(tp_inst, obj, unit, val){
+ // if val==undefined return the value, else return obj
+ }
+}</pre>
+ </dd>
+
+ <dt>showHour</dt>
+ <dd><em>Default: null</em> - Whether to show the hour control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showMinute</dt>
+ <dd><em>Default: null</em> - Whether to show the minute control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showSecond</dt>
+ <dd><em>Default: null</em> - Whether to show the second control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showMillisec</dt>
+ <dd><em>Default: null</em> - Whether to show the millisecond control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showMicrosec</dt>
+ <dd><em>Default: null</em> - Whether to show the microsecond control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showTimezone</dt>
+ <dd><em>Default: null</em> - Whether to show the timezone select.</dd>
+
+ <dt>showTime</dt>
+ <dd><em>Default: true</em> - Whether to show the time selected within the datetimepicker.</dd>
+
+ <dt>stepHour</dt>
+ <dd><em>Default: 1</em> - Hours per step the slider makes.</dd>
+
+ <dt>stepMinute</dt>
+ <dd><em>Default: 1</em> - Minutes per step the slider makes.</dd>
+
+ <dt>stepSecond</dt>
+ <dd><em>Default: 1</em> - Seconds per step the slider makes.</dd>
+
+ <dt>stepMillisec</dt>
+ <dd><em>Default: 1</em> - Milliseconds per step the slider makes.</dd>
+
+ <dt>stepMicrosec</dt>
+ <dd><em>Default: 1</em> - Microseconds per step the slider makes.</dd>
+
+ <dt>hour</dt>
+ <dd><em>Default: 0</em> - Initial hour set.</dd>
+
+ <dt>minute</dt>
+ <dd><em>Default: 0</em> - Initial minute set.</dd>
+
+ <dt>second</dt>
+ <dd><em>Default: 0</em> - Initial second set.</dd>
+
+ <dt>millisec</dt>
+ <dd><em>Default: 0</em> - Initial millisecond set.</dd>
+
+ <dt>microsec</dt>
+ <dd><em>Default: 0</em> - Initial microsecond set. Note: Javascript's native Date object does not natively support microseconds. Timepicker adds ability to simply Date.setMicroseconds(m) and Date.getMicroseconds(). Date comparisons will not acknowledge microseconds. Use this only for display purposes.</dd>
+
+ <dt>timezone</dt>
+ <dd><em>Default: null</em> - Initial timezone set. This is the offset in minutes. If null the browser's local timezone will be used. If you're timezone is "-0400" you would use -240. For backwards compatibility you may pass "-0400", however the timezone is stored in minutes and more reliable.</dd>
+
+ <dt>hourMin</dt>
+ <dd><em>Default: 0</em> - The minimum hour allowed for all dates.</dd>
+
+ <dt>minuteMin</dt>
+ <dd><em>Default: 0</em> - The minimum minute allowed for all dates.</dd>
+
+ <dt>secondMin</dt>
+ <dd><em>Default: 0</em> - The minimum second allowed for all dates.</dd>
+
+ <dt>millisecMin</dt>
+ <dd><em>Default: 0</em> - The minimum millisecond allowed for all dates.</dd>
+
+ <dt>microsecMin</dt>
+ <dd><em>Default: 0</em> - The minimum microsecond allowed for all dates.</dd>
+
+ <dt>hourMax</dt>
+ <dd><em>Default: 23</em> - The maximum hour allowed for all dates.</dd>
+
+ <dt>minuteMax</dt>
+ <dd><em>Default: 59</em> - The maximum minute allowed for all dates.</dd>
+
+ <dt>secondMax</dt>
+ <dd><em>Default: 59</em> - The maximum second allowed for all dates.</dd>
+
+ <dt>millisecMax</dt>
+ <dd><em>Default: 999</em> - The maximum millisecond allowed for all dates.</dd>
+
+ <dt>microsecMax</dt>
+ <dd><em>Default: 999</em> - The maximum microsecond allowed for all dates.</dd>
+
+ <dt>hourGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be generated under the slider. This number represents the units (in hours) between labels.</dd>
+
+ <dt>minuteGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be generated under the slider. This number represents the units (in minutes) between labels.</dd>
+
+ <dt>secondGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in seconds) between labels.</dd>
+
+ <dt>millisecGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in milliseconds) between labels.</dd>
+
+ <dt>microsecGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in microseconds) between labels.</dd>
+ </dl>
+
+ <h3>Other Options</h3>
+ <dl class="defs">
+ <dt>showButtonPanel</dt>
+ <dd><em>Default: true</em> - Whether to show the button panel at the bottom. This is generally needed.</dd>
+
+ <dt>timeOnly</dt>
+ <dd><em>Default: false</em> - Hide the datepicker and only provide a time interface.</dd>
+
+ <dt>onSelect</dt>
+ <dd><em>Default: null</em> - Function to be called when a date is chosen or time has changed (parameters: datetimeText, datepickerInstance).</dd>
+
+ <dt>alwaysSetTime</dt>
+ <dd><em>Default: true</em> - Always have a time set internally, even before user has chosen one.</dd>
+
+ <dt>separator</dt>
+ <dd><em>Default: " "</em> - When formatting the time this string is placed between the formatted date and formatted time.</dd>
+
+ <dt>pickerTimeFormat</dt>
+ <dd><em>Default: (timeFormat option)</em> - How to format the time displayed within the timepicker.</dd>
+
+ <dt>pickerTimeSuffix</dt>
+ <dd><em>Default: (timeSuffix option)</em> - String to place after the formatted time within the timepicker.</dd>
+
+ <dt>showTimepicker</dt>
+ <dd><em>Default: true</em> - Whether to show the timepicker within the datepicker.</dd>
+
+ <dt>addSliderAccess</dt>
+ <dd><em>Default: false</em> - Adds the <a href="http://trentrichardson.com/examples/jQuery-SliderAccess/" title="jQueryUI Slider Access Plugin">sliderAccess plugin</a> to sliders within timepicker</dd>
+
+ <dt>sliderAccessArgs</dt>
+ <dd><em>Default: null</em> - Object to pass to sliderAccess when used.</dd>
+
+ <dt>defaultValue</dt>
+ <dd><em>Default: null</em> - String of the default time value placed in the input on focus when the input is empty.</dd>
+
+ <dt>minDateTime</dt>
+ <dd><em>Default: null</em> - Date object of the minimum datetime allowed. Also available as minDate.</dd>
+
+ <dt>maxDateTime</dt>
+ <dd><em>Default: null</em> - Date object of the maximum datetime allowed. Also Available as maxDate.</dd>
+
+ <dt>parse</dt>
+ <dd><em>Default: 'strict'</em> - How to parse the time string. Two methods are provided: 'strict' which must match the timeFormat exactly, and 'loose' which uses javascript's new Date(timeString) to guess the time. You may also pass in a function(timeFormat, timeString, options) to handle the parsing yourself, returning a simple object:
+<pre>{
+ hour: 19,
+ minute: 10,
+ second: 23,
+ millisec: 45,
+ microsec: 23,
+ timezone: '-0400'
+}</pre>
+ </dd>
+ </dl>
+
+</div>
+
+<!-- ############################################################################# -->
+<!-- Formatting
+<!-- ############################################################################# -->
+<div id="tp-formatting">
+
+ <h2>Formatting Your Time</h2>
+
+ <p>The default format is "HH:mm". To use 12 hour time use something similar to: "hh:mm tt". When both "t" and lower case "h" are present in the timeFormat, 12 hour time will be used.</p>
+
+ <dl class="defs">
+ <dt>H</dt><dd>Hour with no leading 0 (24 hour)</dd>
+ <dt>HH</dt><dd>Hour with leading 0 (24 hour)</dd>
+ <dt>h</dt><dd>Hour with no leading 0 (12 hour)</dd>
+ <dt>hh</dt><dd>Hour with leading 0 (12 hour)</dd>
+ <dt>m</dt><dd>Minute with no leading 0</dd>
+ <dt>mm</dt><dd>Minute with leading 0</dd>
+ <dt>s</dt><dd>Second with no leading 0</dd>
+ <dt>ss</dt><dd>Second with leading 0</dd>
+ <dt>l</dt><dd>Milliseconds always with leading 0</dd>
+ <dt>c</dt><dd>Microseconds always with leading 0</dd>
+ <dt>t</dt><dd>a or p for AM/PM</dd>
+ <dt>T</dt><dd>A or P for AM/PM</dd>
+ <dt>tt</dt><dd>am or pm for AM/PM</dd>
+ <dt>TT</dt><dd>AM or PM for AM/PM</dd>
+ <dt>z</dt><dd>Timezone as defined by timezoneList</dd>
+ <dt>Z</dt><dd>Timezone in Iso 8601 format (+04:45)</dd>
+ <dt>'...'</dt><dd>Literal text (Uses single quotes)</dd>
+ </dl>
+
+ <p>Formats are used in the following ways:</p>
+ <ul>
+ <li>timeFormat option</li>
+ <li>altTimeFormat option</li>
+ <li>pickerTimeFormat option</li>
+ <li>$.datepicker.formatTime(format, timeObj, options) utility method</li>
+ <li>$.datepicker.parseTime(format, timeStr, options) utility method</li>
+ </ul>
+
+ <p>For help with formatting the date portion, visit the datepicker documentation for <a href="http://docs.jquery.com/UI/Datepicker/formatDate" title="jQuery UI Datepicker Formatting">formatting dates</a>.</p>
+</div>
+
+<!-- ############################################################################# -->
+<!-- Localization
+<!-- ############################################################################# -->
+<div id="tp-localization">
+
+ <h2>Working with Localizations</h2>
+
+ <p>Timepicker comes with many translations and localizations, thanks to all the contributors. They can be found in the i18n folder in the git repo.</p>
+
+ <p>The quick and cheap way to use localizations is to pass in options to a timepicker instance:</p>
+
+<pre>$('#example123').timepicker({
+ timeOnlyTitle: 'Выберите время',
+ timeText: 'Время',
+ hourText: 'Часы',
+ minuteText: 'Минуты',
+ secondText: 'Секунды',
+ currentText: 'Теперь',
+ closeText: 'Закрыть'
+});
+</pre>
+ <p>However, if you plan to use timepicker extensively you will need to include (build your own) localization. It is simply assigning those same variables to an object. As you see in the example below we maintain a separate object for timepicker. This way we aren't bound to any changes within datepicker.</p>
+
+<pre>$.datepicker.regional['ru'] = {
+ closeText: 'Закрыть',
+ prevText: '&#x3c;Пред',
+ nextText: 'След&#x3e;',
+ currentText: 'Сегодня',
+ monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь',
+ 'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
+ monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн',
+ 'Июл','Авг','Сен','Окт','Ноя','Дек'],
+ dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
+ dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'],
+ dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
+ weekHeader: 'Не',
+ dateFormat: 'dd.mm.yy',
+ firstDay: 1,
+ isRTL: false,
+ showMonthAfterYear: false,
+ yearSuffix: ''
+};
+$.datepicker.setDefaults($.datepicker.regional['ru']);
+
+
+$.timepicker.regional['ru'] = {
+ timeOnlyTitle: 'Выберите время',
+ timeText: 'Время',
+ hourText: 'Часы',
+ minuteText: 'Минуты',
+ secondText: 'Секунды',
+ millisecText: 'Миллисекунды',
+ timezoneText: 'Часовой пояс',
+ currentText: 'Сейчас',
+ closeText: 'Закрыть',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+};
+$.timepicker.setDefaults($.timepicker.regional['ru']);
+</pre>
+ <p>Now all you have to do is call timepicker and the Russian localization is used. Generally you only need to include the localization file, it will setDefaults() for you.</p>
+ <p>You can also visit <a href="http://docs.jquery.com/UI/Datepicker/Localization" title="localization for datepicker" target="_BLANK">localization for datepicker</a> for more information about datepicker localizations.</p>
+</div>
+
+<!-- ############################################################################# -->
+<!-- Examples
+<!-- ############################################################################# -->
+<div id="tp-examples">
+ <h2>Examples</h2>
+
+ <ul>
+ <li><a href="#basic_examples" title="Basic Initializations">Basic Initializations</a></li>
+ <li><a href="#timezone_examples" title="Using Timezones">Using Timezones</a></li>
+ <li><a href="#slider_examples" title="Slider Modifications">Slider Modifications</a></li>
+ <li><a href="#alt_examples" title="Alternate Field">Alternate Fields</a></li>
+ <li><a href="#rest_examples" title="Time Restraints">Time Restraints</a></li>
+ <li><a href="#utility_examples" title="Utilities">Utilities</a></li>
+ </ul>
+
+ <h3 id="basic_examples">Basic Initializations</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Add a simple datetimepicker to jQuery UI's datepicker</p>
+ <div>
+ <input type="text" name="basic_example_1" id="basic_example_1" value="" />
+ </div>
+<pre>
+$('#basic_example_1').datetimepicker();
+</pre>
+ </div>
+
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Add only a timepicker:</p>
+ <div>
+ <input type="text" name="basic_example_2" id="basic_example_2" value="" />
+ </div>
+<pre>
+$('#basic_example_2').timepicker();
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Format the time:</p>
+ <div>
+ <input type="text" name="basic_example_3" id="basic_example_3" value="" />
+ </div>
+<pre>
+$('#basic_example_3').datetimepicker({
+ timeFormat: "hh:mm tt"
+});
+</pre>
+ </div>
+
+ <h3 id="timezone_examples">Using Timezones</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Simplest timezone usage:</p>
+ <div>
+ <input type="text" name="timezone_example_1" id="timezone_example_1" value="" />
+ </div>
+<pre>
+$('#timezone_example_1').datetimepicker({
+ timeFormat: 'hh:mm tt z'
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Define your own timezone options:</p>
+ <div>
+ <input type="text" name="timezone_example_2" id="timezone_example_2" value="" />
+ </div>
+<pre>
+$('#timezone_example_2').datetimepicker({
+ timeFormat: 'HH:mm z',
+ timezoneList: [
+ { value: -300, label: 'Eastern'},
+ { value: -360, label: 'Central' },
+ { value: -420, label: 'Mountain' },
+ { value: -480, label: 'Pacific' }
+ ]
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>You may also use timezone string abbreviations for values. This should be used with caution. Computing accurate javascript Date objects may not be possible when trying to retrieve or set the date from timepicker (see setDate and getDate examples below). For simple input values however this should work.</p>
+ <div>
+ <input type="text" name="timezone_example_3" id="timezone_example_3" value="" />
+ </div>
+<pre>
+$('#timezone_example_3').datetimepicker({
+ timeFormat: 'HH:mm z',
+ timezone: 'MT',
+ timezoneList: [
+ { value: 'ET', label: 'Eastern'},
+ { value: 'CT', label: 'Central' },
+ { value: 'MT', label: 'Mountain' },
+ { value: 'PT', label: 'Pacific' }
+ ]
+});
+
+</pre>
+ </div>
+
+ <h3 id="slider_examples">Slider Modifications</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Add a grid to each slider:</p>
+ <div>
+ <input type="text" name="slider_example_1" id="slider_example_1" value="" />
+ </div>
+<pre>
+$('#slider_example_1').timepicker({
+ hourGrid: 4,
+ minuteGrid: 10,
+ timeFormat: 'hh:mm tt'
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Set the interval step of sliders:</p>
+ <div>
+ <input type="text" name="slider_example_2" id="slider_example_2" value="" />
+ </div>
+<pre>
+$('#slider_example_2').datetimepicker({
+ timeFormat: 'HH:mm:ss',
+ stepHour: 2,
+ stepMinute: 10,
+ stepSecond: 10
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Add sliderAccess plugin for touch devices:</p>
+ <div>
+ <input type="text" name="slider_example_3" id="slider_example_3" value="" />
+ </div>
+<pre>
+$('#slider_example_3').datetimepicker({
+ addSliderAccess: true,
+ sliderAccessArgs: { touchonly: false }
+});</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Use dropdowns instead of sliders. By default if slider is not available dropdowns will be used.</p>
+ <div>
+ <input type="text" name="slider_example_4" id="slider_example_4" value="" />
+ </div>
+<pre>
+$('#slider_example_4').datetimepicker({
+ controlType: 'select',
+ timeFormat: 'hh:mm tt'
+});</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Create your own control by implementing the create, options, and value methods. If you want to use your new control for all instances use the $.timepicker.setDefaults({controlType:myControl}). Here we implement jQueryUI's spinner control (jQueryUI 1.9+).</p>
+ <div>
+ <input type="text" name="slider_example_5" id="slider_example_5" value="" />
+ </div>
+<pre>var myControl= {
+ create: function(tp_inst, obj, unit, val, min, max, step){
+ $('&lt;input class="ui-timepicker-input" value="'+val+'" style="width:50%"&gt;')
+ .appendTo(obj)
+ .spinner({
+ min: min,
+ max: max,
+ step: step,
+ change: function(e,ui){ // key events
+ // don't call if api was used and not key press
+ if(e.originalEvent !== undefined)
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ },
+ spin: function(e,ui){ // spin events
+ tp_inst.control.value(tp_inst, obj, unit, ui.value);
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }
+ });
+ return obj;
+ },
+ options: function(tp_inst, obj, unit, opts, val){
+ if(typeof(opts) == 'string' && val !== undefined)
+ return obj.find('.ui-timepicker-input').spinner(opts, val);
+ return obj.find('.ui-timepicker-input').spinner(opts);
+ },
+ value: function(tp_inst, obj, unit, val){
+ if(val !== undefined)
+ return obj.find('.ui-timepicker-input').spinner('value', val);
+ return obj.find('.ui-timepicker-input').spinner('value');
+ }
+};
+
+$('#slider_example_5').datetimepicker({
+ controlType: myControl
+});</pre>
+ </div>
+
+ <h3 id="alt_examples">Alternate Fields</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Alt field in the simplest form:</p>
+ <div>
+ <input type="text" name="alt_example_1" id="alt_example_1" value="09/15/2012" />
+ <input type="text" name="alt_example_1_alt" id="alt_example_1_alt" value="10:15" />
+ </div>
+<pre>
+$('#alt_example_1').datetimepicker({
+ altField: "#alt_example_1_alt"
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>With datetime in both:</p>
+ <div>
+ <input type="text" name="alt_example_2" id="alt_example_2" value="" />
+ <input type="text" name="alt_example_2_alt" id="alt_example_2_alt" value="" />
+ </div>
+<pre>
+$('#alt_example_2').datetimepicker({
+ altField: "#alt_example_2_alt",
+ altFieldTimeOnly: false
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Format the altField differently:</p>
+ <div>
+ <input type="text" name="alt_example_3" id="alt_example_3" value="" />
+ <input type="text" name="alt_example_3_alt" id="alt_example_3_alt" value="" />
+ </div>
+<pre>
+$('#alt_example_3').datetimepicker({
+ altField: "#alt_example_3_alt",
+ altFieldTimeOnly: false,
+ altFormat: "yy-mm-dd",
+ altTimeFormat: "h:m t",
+ altSeparator: " @ "
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>With inline mode using altField:</p>
+ <div>
+ <input type="text" name="alt_example_4_alt" id="alt_example_4_alt" value="" />
+ <span id="alt_example_4" ></span>
+ </div>
+<pre>
+$('#alt_example_4').datetimepicker({
+ altField: "#alt_example_4_alt",
+ altFieldTimeOnly: false
+});
+</pre>
+ </div>
+
+ <h3 id="rest_examples">Time Restraints</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Set the min/max hour of every date:</p>
+ <div>
+ <input type="text" name="rest_example_1" id="rest_example_1" value="" />
+ </div>
+<pre>
+$('#rest_example_1').timepicker({
+ hourMin: 8,
+ hourMax: 16
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Set the min/max date numerically:</p>
+ <div>
+ <input type="text" name="rest_example_2" id="rest_example_2" value="" />
+ </div>
+<pre>
+$('#rest_example_2').datetimepicker({
+ numberOfMonths: 2,
+ minDate: 0,
+ maxDate: 30
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Set the min/max date and time with a Date object:</p>
+ <div>
+ <input type="text" name="rest_example_3" id="rest_example_3" value="" />
+ </div>
+<pre>
+$('#rest_example_3').datetimepicker({
+ minDate: new Date(2010, 11, 20, 8, 30),
+ maxDate: new Date(2010, 11, 31, 17, 30)
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Restrict a start and end date by using onSelect and onClose events for more control over functionality:</p>
+ <p>For more examples and advanced usage grab the <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook">Handling Time eBook</a>.</p>
+ <div>
+ <input type="text" name="rest_example_4_start" id="rest_example_4_start" value="" />
+ <input type="text" name="rest_example_4_end" id="rest_example_4_end" value="" />
+ </div>
+<pre>
+var startDateTextBox = $('#rest_example_4_start');
+var endDateTextBox = $('#rest_example_4_end');
+
+startDateTextBox.datetimepicker({
+ timeFormat: 'HH:mm z',
+ onClose: function(dateText, inst) {
+ if (endDateTextBox.val() != '') {
+ var testStartDate = startDateTextBox.datetimepicker('getDate');
+ var testEndDate = endDateTextBox.datetimepicker('getDate');
+ if (testStartDate > testEndDate)
+ endDateTextBox.datetimepicker('setDate', testStartDate);
+ }
+ else {
+ endDateTextBox.val(dateText);
+ }
+ },
+ onSelect: function (selectedDateTime){
+ endDateTextBox.datetimepicker('option', 'minDate', startDateTextBox.datetimepicker('getDate') );
+ }
+});
+endDateTextBox.datetimepicker({
+ timeFormat: 'HH:mm z',
+ onClose: function(dateText, inst) {
+ if (startDateTextBox.val() != '') {
+ var testStartDate = startDateTextBox.datetimepicker('getDate');
+ var testEndDate = endDateTextBox.datetimepicker('getDate');
+ if (testStartDate > testEndDate)
+ startDateTextBox.datetimepicker('setDate', testEndDate);
+ }
+ else {
+ startDateTextBox.val(dateText);
+ }
+ },
+ onSelect: function (selectedDateTime){
+ startDateTextBox.datetimepicker('option', 'maxDate', endDateTextBox.datetimepicker('getDate') );
+ }
+});
+</pre>
+ </div>
+
+ <h3 id="utility_examples">Utilities</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Get and Set Datetime with the getDate and setDate methods. This example uses timezone to demonstrate the timepicker regonizes the timezones and computes the offsets when getting and setting.</p>
+ <div>
+ <input type="text" name="utility_example_1" id="utility_example_1" value="" />
+ <button id="utility_example_1_setdt" value="1">Set Datetime</button>
+ <button id="utility_example_1_getdt" value="1">Get Datetime</button>
+ </div>
+
+<pre>
+var ex13 = $('#utility_example_1');
+
+ex13.datetimepicker({
+ timeFormat: 'hh:mm tt z',
+ separator: ' @ ',
+ showTimezone: true
+});
+
+$('#utility_example_1_setdt').click(function(){
+ ex13.datetimepicker('setDate', (new Date()) );
+});
+
+$('#utility_example_1_getdt').click(function(){
+ alert(ex13.datetimepicker('getDate'));
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Use the utility function to format your own time. $.datepicker.formatTime(format, time, options)</p>
+ <dl class="defs">
+ <dt>format</dt><dd>required - string represenation of the time format to use</dd>
+ <dt>time</dt><dd>required - hash: { hour, minute, second, millisecond, timezone }</dd>
+ <dt>options</dt><dd>optional - hash of any options in regional translation (ampm, amNames, pmNames..)</dd>
+ </dl>
+ <p>Returns a time string in the specified format.</p>
+ <div>
+ <div id="utility_example_2"></div>
+ </div>
+
+<pre>
+$('#utility_example_2').text(
+ $.datepicker.formatTime('HH:mm z', { hour: 14, minute: 36, timezone: '+2000' }, {})
+);
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Use the utility function to parses a formatted time. $.datepicker.parseTime(format, timeString, options)</p>
+ <dl class="defs">
+ <dt>format</dt><dd>required - string represenation of the time format to use</dd>
+ <dt>time</dt><dd>required - time string matching the format given in parameter 1</dd>
+ <dt>options</dt><dd>optional - hash of any options in regional translation (ampm, amNames, pmNames..)</dd>
+ </dl>
+ <p>Returns an object with hours, minutes, seconds, milliseconds, timezone.</p>
+ <div>
+ <div id="utility_example_3"></div>
+ </div>
+
+<pre>
+$('#utility_example_3').text(JSON.stringify(
+ $.datepicker.parseTime('HH:mm:ss:l z', "14:36:21:765 +2000", {})
+));
+</pre>
+ </div>
+
+</div>
+ </div>
+
+
+ </div>
+
+
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
+ <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
+ <script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
+ <script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
+
+ <script type="text/javascript">
+
+ $(function(){
+ $('#tabs').tabs();
+
+ $('.example-container > pre').each(function(i){
+ eval($(this).text());
+ });
+ });
+
+ </script>
+
+ <script type="text/javascript" src="https://sellfy.com/js/api_buttons.js"></script>
+ <script type="text/javascript" src="https://gumroad.com/js/gumroad.js"></script>
+
+ <script type="text/javascript"> /*
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ */</script>
+ <script type="text/javascript"> /*
+ try {
+ var pageTracker = _gat._getTracker("UA-7602218-1");
+ pageTracker._trackPageview();
+ } catch(err) {}*/</script>
+ </body>
+</html> \ No newline at end of file
diff --git a/jquery-ui-sliderAccess.js b/dist/jquery-ui-sliderAccess.js
index a54cf4a..b075c66 100644
--- a/jquery-ui-sliderAccess.js
+++ b/dist/jquery-ui-sliderAccess.js
@@ -17,8 +17,9 @@
options = options || {};
options.touchonly = options.touchonly !== undefined? options.touchonly : true; // by default only show it if touch device
- if(options.touchonly === true && !("ontouchend" in document))
+ if(options.touchonly === true && !("ontouchend" in document)){
return $(this);
+ }
return $(this).each(function(i,obj){
var $t = $(this),
@@ -56,8 +57,9 @@
e.preventDefault();
- if(newval < minval || newval > maxval)
+ if(newval < minval || newval > maxval){
return;
+ }
$t.slider('value', newval);
@@ -77,8 +79,8 @@
// adjust the width so we don't break the original layout
var bOuterWidth = $buttons.css({
- marginLeft: ((o.where == 'after' && !o.isRTL) || (o.where == 'before' && o.isRTL)? 10:0),
- marginRight: ((o.where == 'before' && !o.isRTL) || (o.where == 'after' && o.isRTL)? 10:0)
+ marginLeft: ((o.where === 'after' && !o.isRTL) || (o.where === 'before' && o.isRTL)? 10:0),
+ marginRight: ((o.where === 'before' && !o.isRTL) || (o.where === 'after' && o.isRTL)? 10:0)
}).outerWidth(true) + 5;
var tOuterWidth = $t.outerWidth(true);
$t.css('display','inline-block').width(tOuterWidth-bOuterWidth);
diff --git a/dist/jquery-ui-timepicker-addon.css b/dist/jquery-ui-timepicker-addon.css
new file mode 100644
index 0000000..da12d98
--- /dev/null
+++ b/dist/jquery-ui-timepicker-addon.css
@@ -0,0 +1,11 @@
+.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
+.ui-timepicker-div dl { text-align: left; }
+.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
+.ui-timepicker-div dl dd { margin: 0 10px 10px 40%; }
+.ui-timepicker-div td { font-size: 90%; }
+.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
+
+.ui-timepicker-rtl{ direction: rtl; }
+.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
+.ui-timepicker-rtl dl dt{ float: right; clear: right; }
+.ui-timepicker-rtl dl dd { margin: 0 40% 10px 10px; } \ No newline at end of file
diff --git a/dist/jquery-ui-timepicker-addon.js b/dist/jquery-ui-timepicker-addon.js
new file mode 100644
index 0000000..644703f
--- /dev/null
+++ b/dist/jquery-ui-timepicker-addon.js
@@ -0,0 +1,2134 @@
+/*! jQuery Timepicker Addon - v1.4 - 2013-08-11
+* http://trentrichardson.com/examples/timepicker
+* Copyright (c) 2013 Trent Richardson; Licensed MIT */
+(function ($) {
+
+ /*
+ * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded"
+ */
+ $.ui.timepicker = $.ui.timepicker || {};
+ if ($.ui.timepicker.version) {
+ return;
+ }
+
+ /*
+ * Extend jQueryUI, get it started with our version number
+ */
+ $.extend($.ui, {
+ timepicker: {
+ version: "1.4"
+ }
+ });
+
+ /*
+ * Timepicker manager.
+ * Use the singleton instance of this class, $.timepicker, to interact with the time picker.
+ * Settings for (groups of) time pickers are maintained in an instance object,
+ * allowing multiple different settings on the same page.
+ */
+ var Timepicker = function () {
+ this.regional = []; // Available regional settings, indexed by language code
+ this.regional[''] = { // Default regional settings
+ currentText: 'Now',
+ closeText: 'Done',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ timeFormat: 'HH:mm',
+ timeSuffix: '',
+ timeOnlyTitle: 'Choose Time',
+ timeText: 'Time',
+ hourText: 'Hour',
+ minuteText: 'Minute',
+ secondText: 'Second',
+ millisecText: 'Millisecond',
+ microsecText: 'Microsecond',
+ timezoneText: 'Time Zone',
+ isRTL: false
+ };
+ this._defaults = { // Global defaults for all the datetime picker instances
+ showButtonPanel: true,
+ timeOnly: false,
+ showHour: null,
+ showMinute: null,
+ showSecond: null,
+ showMillisec: null,
+ showMicrosec: null,
+ showTimezone: null,
+ showTime: true,
+ stepHour: 1,
+ stepMinute: 1,
+ stepSecond: 1,
+ stepMillisec: 1,
+ stepMicrosec: 1,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ microsec: 0,
+ timezone: null,
+ hourMin: 0,
+ minuteMin: 0,
+ secondMin: 0,
+ millisecMin: 0,
+ microsecMin: 0,
+ hourMax: 23,
+ minuteMax: 59,
+ secondMax: 59,
+ millisecMax: 999,
+ microsecMax: 999,
+ minDateTime: null,
+ maxDateTime: null,
+ onSelect: null,
+ hourGrid: 0,
+ minuteGrid: 0,
+ secondGrid: 0,
+ millisecGrid: 0,
+ microsecGrid: 0,
+ alwaysSetTime: true,
+ separator: ' ',
+ altFieldTimeOnly: true,
+ altTimeFormat: null,
+ altSeparator: null,
+ altTimeSuffix: null,
+ pickerTimeFormat: null,
+ pickerTimeSuffix: null,
+ showTimepicker: true,
+ timezoneList: null,
+ addSliderAccess: false,
+ sliderAccessArgs: null,
+ controlType: 'slider',
+ defaultValue: null,
+ parse: 'strict'
+ };
+ $.extend(this._defaults, this.regional['']);
+ };
+
+ $.extend(Timepicker.prototype, {
+ $input: null,
+ $altInput: null,
+ $timeObj: null,
+ inst: null,
+ hour_slider: null,
+ minute_slider: null,
+ second_slider: null,
+ millisec_slider: null,
+ microsec_slider: null,
+ timezone_select: null,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ microsec: 0,
+ timezone: null,
+ hourMinOriginal: null,
+ minuteMinOriginal: null,
+ secondMinOriginal: null,
+ millisecMinOriginal: null,
+ microsecMinOriginal: null,
+ hourMaxOriginal: null,
+ minuteMaxOriginal: null,
+ secondMaxOriginal: null,
+ millisecMaxOriginal: null,
+ microsecMaxOriginal: null,
+ ampm: '',
+ formattedDate: '',
+ formattedTime: '',
+ formattedDateTime: '',
+ timezoneList: null,
+ units: ['hour', 'minute', 'second', 'millisec', 'microsec'],
+ support: {},
+ control: null,
+
+ /*
+ * Override the default settings for all instances of the time picker.
+ * @param {Object} settings object - the new settings to use as defaults (anonymous object)
+ * @return {Object} the manager object
+ */
+ setDefaults: function (settings) {
+ extendRemove(this._defaults, settings || {});
+ return this;
+ },
+
+ /*
+ * Create a new Timepicker instance
+ */
+ _newInst: function ($input, opts) {
+ var tp_inst = new Timepicker(),
+ inlineSettings = {},
+ fns = {},
+ overrides, i;
+
+ for (var attrName in this._defaults) {
+ if (this._defaults.hasOwnProperty(attrName)) {
+ var attrValue = $input.attr('time:' + attrName);
+ if (attrValue) {
+ try {
+ inlineSettings[attrName] = eval(attrValue);
+ } catch (err) {
+ inlineSettings[attrName] = attrValue;
+ }
+ }
+ }
+ }
+
+ overrides = {
+ beforeShow: function (input, dp_inst) {
+ if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
+ return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
+ }
+ },
+ onChangeMonthYear: function (year, month, dp_inst) {
+ // Update the time as well : this prevents the time from disappearing from the $input field.
+ tp_inst._updateDateTime(dp_inst);
+ if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
+ tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
+ }
+ },
+ onClose: function (dateText, dp_inst) {
+ if (tp_inst.timeDefined === true && $input.val() !== '') {
+ tp_inst._updateDateTime(dp_inst);
+ }
+ if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
+ tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
+ }
+ }
+ };
+ for (i in overrides) {
+ if (overrides.hasOwnProperty(i)) {
+ fns[i] = opts[i] || null;
+ }
+ }
+
+ tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, {
+ evnts: fns,
+ timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
+ });
+ tp_inst.amNames = $.map(tp_inst._defaults.amNames, function (val) {
+ return val.toUpperCase();
+ });
+ tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function (val) {
+ return val.toUpperCase();
+ });
+
+ // detect which units are supported
+ tp_inst.support = detectSupport(
+ tp_inst._defaults.timeFormat +
+ (tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') +
+ (tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : ''));
+
+ // controlType is string - key to our this._controls
+ if (typeof(tp_inst._defaults.controlType) === 'string') {
+ if (tp_inst._defaults.controlType === 'slider' && typeof($.ui.slider) === 'undefined') {
+ tp_inst._defaults.controlType = 'select';
+ }
+ tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType];
+ }
+ // controlType is an object and must implement create, options, value methods
+ else {
+ tp_inst.control = tp_inst._defaults.controlType;
+ }
+
+ // prep the timezone options
+ var timezoneList = [-720, -660, -600, -570, -540, -480, -420, -360, -300, -270, -240, -210, -180, -120, -60,
+ 0, 60, 120, 180, 210, 240, 270, 300, 330, 345, 360, 390, 420, 480, 525, 540, 570, 600, 630, 660, 690, 720, 765, 780, 840];
+ if (tp_inst._defaults.timezoneList !== null) {
+ timezoneList = tp_inst._defaults.timezoneList;
+ }
+ var tzl = timezoneList.length, tzi = 0, tzv = null;
+ if (tzl > 0 && typeof timezoneList[0] !== 'object') {
+ for (; tzi < tzl; tzi++) {
+ tzv = timezoneList[tzi];
+ timezoneList[tzi] = { value: tzv, label: $.timepicker.timezoneOffsetString(tzv, tp_inst.support.iso8601) };
+ }
+ }
+ tp_inst._defaults.timezoneList = timezoneList;
+
+ // set the default units
+ tp_inst.timezone = tp_inst._defaults.timezone !== null ? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
+ ((new Date()).getTimezoneOffset() * -1);
+ tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin ? tp_inst._defaults.hourMin :
+ tp_inst._defaults.hour > tp_inst._defaults.hourMax ? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
+ tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin ? tp_inst._defaults.minuteMin :
+ tp_inst._defaults.minute > tp_inst._defaults.minuteMax ? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
+ tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin ? tp_inst._defaults.secondMin :
+ tp_inst._defaults.second > tp_inst._defaults.secondMax ? tp_inst._defaults.secondMax : tp_inst._defaults.second;
+ tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin ? tp_inst._defaults.millisecMin :
+ tp_inst._defaults.millisec > tp_inst._defaults.millisecMax ? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
+ tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin ? tp_inst._defaults.microsecMin :
+ tp_inst._defaults.microsec > tp_inst._defaults.microsecMax ? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec;
+ tp_inst.ampm = '';
+ tp_inst.$input = $input;
+
+ if (tp_inst._defaults.altField) {
+ tp_inst.$altInput = $(tp_inst._defaults.altField).css({
+ cursor: 'pointer'
+ }).focus(function () {
+ $input.trigger("focus");
+ });
+ }
+
+ if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) {
+ tp_inst._defaults.minDate = new Date();
+ }
+ if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) {
+ tp_inst._defaults.maxDate = new Date();
+ }
+
+ // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
+ if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) {
+ tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
+ }
+ if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) {
+ tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
+ }
+ if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) {
+ tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
+ }
+ if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
+ tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
+ }
+ tp_inst.$input.bind('focus', function () {
+ tp_inst._onFocus();
+ });
+
+ return tp_inst;
+ },
+
+ /*
+ * add our sliders to the calendar
+ */
+ _addTimePicker: function (dp_inst) {
+ var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val();
+
+ this.timeDefined = this._parseTime(currDT);
+ this._limitMinMaxDateTime(dp_inst, false);
+ this._injectTimePicker();
+ },
+
+ /*
+ * parse the time string from input value or _setTime
+ */
+ _parseTime: function (timeString, withDate) {
+ if (!this.inst) {
+ this.inst = $.datepicker._getInst(this.$input[0]);
+ }
+
+ if (withDate || !this._defaults.timeOnly) {
+ var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
+ try {
+ var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults);
+ if (!parseRes.timeObj) {
+ return false;
+ }
+ $.extend(this, parseRes.timeObj);
+ } catch (err) {
+ $.timepicker.log("Error parsing the date/time string: " + err +
+ "\ndate/time string = " + timeString +
+ "\ntimeFormat = " + this._defaults.timeFormat +
+ "\ndateFormat = " + dp_dateFormat);
+ return false;
+ }
+ return true;
+ } else {
+ var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults);
+ if (!timeObj) {
+ return false;
+ }
+ $.extend(this, timeObj);
+ return true;
+ }
+ },
+
+ /*
+ * generate and inject html for timepicker into ui datepicker
+ */
+ _injectTimePicker: function () {
+ var $dp = this.inst.dpDiv,
+ o = this.inst.settings,
+ tp_inst = this,
+ litem = '',
+ uitem = '',
+ show = null,
+ max = {},
+ gridSize = {},
+ size = null,
+ i = 0,
+ l = 0;
+
+ // Prevent displaying twice
+ if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
+ var noDisplay = ' style="display:none;"',
+ html = '<div class="ui-timepicker-div' + (o.isRTL ? ' ui-timepicker-rtl' : '') + '"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
+ '<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
+
+ // Create the markup
+ for (i = 0, l = this.units.length; i < l; i++) {
+ litem = this.units[i];
+ uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
+ show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
+
+ // Added by Peter Medeiros:
+ // - Figure out what the hour/minute/second max should be based on the step values.
+ // - Example: if stepMinute is 15, then minMax is 45.
+ max[litem] = parseInt((o[litem + 'Max'] - ((o[litem + 'Max'] - o[litem + 'Min']) % o['step' + uitem])), 10);
+ gridSize[litem] = 0;
+
+ html += '<dt class="ui_tpicker_' + litem + '_label"' + (show ? '' : noDisplay) + '>' + o[litem + 'Text'] + '</dt>' +
+ '<dd class="ui_tpicker_' + litem + '"><div class="ui_tpicker_' + litem + '_slider"' + (show ? '' : noDisplay) + '></div>';
+
+ if (show && o[litem + 'Grid'] > 0) {
+ html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
+
+ if (litem === 'hour') {
+ for (var h = o[litem + 'Min']; h <= max[litem]; h += parseInt(o[litem + 'Grid'], 10)) {
+ gridSize[litem]++;
+ var tmph = $.datepicker.formatTime(this.support.ampm ? 'hht' : 'HH', {hour: h}, o);
+ html += '<td data-for="' + litem + '">' + tmph + '</td>';
+ }
+ }
+ else {
+ for (var m = o[litem + 'Min']; m <= max[litem]; m += parseInt(o[litem + 'Grid'], 10)) {
+ gridSize[litem]++;
+ html += '<td data-for="' + litem + '">' + ((m < 10) ? '0' : '') + m + '</td>';
+ }
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+ }
+
+ // Timezone
+ var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone;
+ html += '<dt class="ui_tpicker_timezone_label"' + (showTz ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
+ html += '<dd class="ui_tpicker_timezone" ' + (showTz ? '' : noDisplay) + '></dd>';
+
+ // Create the elements from string
+ html += '</dl></div>';
+ var $tp = $(html);
+
+ // if we only want time picker...
+ if (o.timeOnly === true) {
+ $tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
+ $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
+ }
+
+ // add sliders, adjust grids, add events
+ for (i = 0, l = tp_inst.units.length; i < l; i++) {
+ litem = tp_inst.units[i];
+ uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
+ show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
+
+ // add the slider
+ tp_inst[litem + '_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_' + litem + '_slider'), litem, tp_inst[litem], o[litem + 'Min'], max[litem], o['step' + uitem]);
+
+ // adjust the grid and add click event
+ if (show && o[litem + 'Grid'] > 0) {
+ size = 100 * gridSize[litem] * o[litem + 'Grid'] / (max[litem] - o[litem + 'Min']);
+ $tp.find('.ui_tpicker_' + litem + ' table').css({
+ width: size + "%",
+ marginLeft: o.isRTL ? '0' : ((size / (-2 * gridSize[litem])) + "%"),
+ marginRight: o.isRTL ? ((size / (-2 * gridSize[litem])) + "%") : '0',
+ borderCollapse: 'collapse'
+ }).find("td").click(function (e) {
+ var $t = $(this),
+ h = $t.html(),
+ n = parseInt(h.replace(/[^0-9]/g), 10),
+ ap = h.replace(/[^apm]/ig),
+ f = $t.data('for'); // loses scope, so we use data-for
+
+ if (f === 'hour') {
+ if (ap.indexOf('p') !== -1 && n < 12) {
+ n += 12;
+ }
+ else {
+ if (ap.indexOf('a') !== -1 && n === 12) {
+ n = 0;
+ }
+ }
+ }
+
+ tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n);
+
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / gridSize[litem]) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ } // end if grid > 0
+ } // end for loop
+
+ // Add timezone options
+ this.timezone_select = $tp.find('.ui_tpicker_timezone').append('<select></select>').find("select");
+ $.fn.append.apply(this.timezone_select,
+ $.map(o.timezoneList, function (val, idx) {
+ return $("<option />").val(typeof val === "object" ? val.value : val).text(typeof val === "object" ? val.label : val);
+ }));
+ if (typeof(this.timezone) !== "undefined" && this.timezone !== null && this.timezone !== "") {
+ var local_timezone = (new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12)).getTimezoneOffset() * -1;
+ if (local_timezone === this.timezone) {
+ selectLocalTimezone(tp_inst);
+ } else {
+ this.timezone_select.val(this.timezone);
+ }
+ } else {
+ if (typeof(this.hour) !== "undefined" && this.hour !== null && this.hour !== "") {
+ this.timezone_select.val(o.timezone);
+ } else {
+ selectLocalTimezone(tp_inst);
+ }
+ }
+ this.timezone_select.change(function () {
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ });
+ // End timezone options
+
+ // inject timepicker into datepicker
+ var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
+ if ($buttonPanel.length) {
+ $buttonPanel.before($tp);
+ } else {
+ $dp.append($tp);
+ }
+
+ this.$timeObj = $tp.find('.ui_tpicker_time');
+
+ if (this.inst !== null) {
+ var timeDefined = this.timeDefined;
+ this._onTimeChange();
+ this.timeDefined = timeDefined;
+ }
+
+ // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
+ if (this._defaults.addSliderAccess) {
+ var sliderAccessArgs = this._defaults.sliderAccessArgs,
+ rtl = this._defaults.isRTL;
+ sliderAccessArgs.isRTL = rtl;
+
+ setTimeout(function () { // fix for inline mode
+ if ($tp.find('.ui-slider-access').length === 0) {
+ $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
+
+ // fix any grids since sliders are shorter
+ var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
+ if (sliderAccessWidth) {
+ $tp.find('table:visible').each(function () {
+ var $g = $(this),
+ oldWidth = $g.outerWidth(),
+ oldMarginLeft = $g.css(rtl ? 'marginRight' : 'marginLeft').toString().replace('%', ''),
+ newWidth = oldWidth - sliderAccessWidth,
+ newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%',
+ css = { width: newWidth, marginRight: 0, marginLeft: 0 };
+ css[rtl ? 'marginRight' : 'marginLeft'] = newMarginLeft;
+ $g.css(css);
+ });
+ }
+ }
+ }, 10);
+ }
+ // end slideAccess integration
+
+ tp_inst._limitMinMaxDateTime(this.inst, true);
+ }
+ },
+
+ /*
+ * This function tries to limit the ability to go outside the
+ * min/max date range
+ */
+ _limitMinMaxDateTime: function (dp_inst, adjustSliders) {
+ var o = this._defaults,
+ dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
+
+ if (!this._defaults.showTimepicker) {
+ return;
+ } // No time so nothing to check here
+
+ if ($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date) {
+ var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
+ minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
+
+ if (this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null || this.microsecMinOriginal === null) {
+ this.hourMinOriginal = o.hourMin;
+ this.minuteMinOriginal = o.minuteMin;
+ this.secondMinOriginal = o.secondMin;
+ this.millisecMinOriginal = o.millisecMin;
+ this.microsecMinOriginal = o.microsecMin;
+ }
+
+ if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() === dp_date.getTime()) {
+ this._defaults.hourMin = minDateTime.getHours();
+ if (this.hour <= this._defaults.hourMin) {
+ this.hour = this._defaults.hourMin;
+ this._defaults.minuteMin = minDateTime.getMinutes();
+ if (this.minute <= this._defaults.minuteMin) {
+ this.minute = this._defaults.minuteMin;
+ this._defaults.secondMin = minDateTime.getSeconds();
+ if (this.second <= this._defaults.secondMin) {
+ this.second = this._defaults.secondMin;
+ this._defaults.millisecMin = minDateTime.getMilliseconds();
+ if (this.millisec <= this._defaults.millisecMin) {
+ this.millisec = this._defaults.millisecMin;
+ this._defaults.microsecMin = minDateTime.getMicroseconds();
+ } else {
+ if (this.microsec < this._defaults.microsecMin) {
+ this.microsec = this._defaults.microsecMin;
+ }
+ this._defaults.microsecMin = this.microsecMinOriginal;
+ }
+ } else {
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ this._defaults.microsecMin = this.microsecMinOriginal;
+ }
+ } else {
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ this._defaults.microsecMin = this.microsecMinOriginal;
+ }
+ } else {
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ this._defaults.microsecMin = this.microsecMinOriginal;
+ }
+ } else {
+ this._defaults.hourMin = this.hourMinOriginal;
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ this._defaults.microsecMin = this.microsecMinOriginal;
+ }
+ }
+
+ if ($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date) {
+ var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
+ maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
+
+ if (this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null || this.millisecMaxOriginal === null) {
+ this.hourMaxOriginal = o.hourMax;
+ this.minuteMaxOriginal = o.minuteMax;
+ this.secondMaxOriginal = o.secondMax;
+ this.millisecMaxOriginal = o.millisecMax;
+ this.microsecMaxOriginal = o.microsecMax;
+ }
+
+ if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() === dp_date.getTime()) {
+ this._defaults.hourMax = maxDateTime.getHours();
+ if (this.hour >= this._defaults.hourMax) {
+ this.hour = this._defaults.hourMax;
+ this._defaults.minuteMax = maxDateTime.getMinutes();
+ if (this.minute >= this._defaults.minuteMax) {
+ this.minute = this._defaults.minuteMax;
+ this._defaults.secondMax = maxDateTime.getSeconds();
+ if (this.second >= this._defaults.secondMax) {
+ this.second = this._defaults.secondMax;
+ this._defaults.millisecMax = maxDateTime.getMilliseconds();
+ if (this.millisec >= this._defaults.millisecMax) {
+ this.millisec = this._defaults.millisecMax;
+ this._defaults.microsecMax = maxDateTime.getMicroseconds();
+ } else {
+ if (this.microsec > this._defaults.microsecMax) {
+ this.microsec = this._defaults.microsecMax;
+ }
+ this._defaults.microsecMax = this.microsecMaxOriginal;
+ }
+ } else {
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ this._defaults.microsecMax = this.microsecMaxOriginal;
+ }
+ } else {
+ this._defaults.secondMax = this.secondMaxOriginal;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ this._defaults.microsecMax = this.microsecMaxOriginal;
+ }
+ } else {
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ this._defaults.microsecMax = this.microsecMaxOriginal;
+ }
+ } else {
+ this._defaults.hourMax = this.hourMaxOriginal;
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ this._defaults.microsecMax = this.microsecMaxOriginal;
+ }
+ }
+
+ if (adjustSliders !== undefined && adjustSliders === true) {
+ var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
+ minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
+ secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
+ millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10),
+ microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
+
+ if (this.hour_slider) {
+ this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax });
+ this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
+ }
+ if (this.minute_slider) {
+ this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax });
+ this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
+ }
+ if (this.second_slider) {
+ this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax });
+ this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
+ }
+ if (this.millisec_slider) {
+ this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax });
+ this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
+ }
+ if (this.microsec_slider) {
+ this.control.options(this, this.microsec_slider, 'microsec', { min: this._defaults.microsecMin, max: microsecMax });
+ this.control.value(this, this.microsec_slider, 'microsec', this.microsec - (this.microsec % this._defaults.stepMicrosec));
+ }
+ }
+
+ },
+
+ /*
+ * when a slider moves, set the internal time...
+ * on time change is also called when the time is updated in the text field
+ */
+ _onTimeChange: function () {
+ if (!this._defaults.showTimepicker) {
+ return;
+ }
+ var hour = (this.hour_slider) ? this.control.value(this, this.hour_slider, 'hour') : false,
+ minute = (this.minute_slider) ? this.control.value(this, this.minute_slider, 'minute') : false,
+ second = (this.second_slider) ? this.control.value(this, this.second_slider, 'second') : false,
+ millisec = (this.millisec_slider) ? this.control.value(this, this.millisec_slider, 'millisec') : false,
+ microsec = (this.microsec_slider) ? this.control.value(this, this.microsec_slider, 'microsec') : false,
+ timezone = (this.timezone_select) ? this.timezone_select.val() : false,
+ o = this._defaults,
+ pickerTimeFormat = o.pickerTimeFormat || o.timeFormat,
+ pickerTimeSuffix = o.pickerTimeSuffix || o.timeSuffix;
+
+ if (typeof(hour) === 'object') {
+ hour = false;
+ }
+ if (typeof(minute) === 'object') {
+ minute = false;
+ }
+ if (typeof(second) === 'object') {
+ second = false;
+ }
+ if (typeof(millisec) === 'object') {
+ millisec = false;
+ }
+ if (typeof(microsec) === 'object') {
+ microsec = false;
+ }
+ if (typeof(timezone) === 'object') {
+ timezone = false;
+ }
+
+ if (hour !== false) {
+ hour = parseInt(hour, 10);
+ }
+ if (minute !== false) {
+ minute = parseInt(minute, 10);
+ }
+ if (second !== false) {
+ second = parseInt(second, 10);
+ }
+ if (millisec !== false) {
+ millisec = parseInt(millisec, 10);
+ }
+ if (microsec !== false) {
+ microsec = parseInt(microsec, 10);
+ }
+
+ var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
+
+ // If the update was done in the input field, the input field should not be updated.
+ // If the update was done using the sliders, update the input field.
+ var hasChanged = (hour !== this.hour || minute !== this.minute || second !== this.second || millisec !== this.millisec || microsec !== this.microsec ||
+ (this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) || (this.timezone !== null && timezone !== this.timezone));
+
+ if (hasChanged) {
+
+ if (hour !== false) {
+ this.hour = hour;
+ }
+ if (minute !== false) {
+ this.minute = minute;
+ }
+ if (second !== false) {
+ this.second = second;
+ }
+ if (millisec !== false) {
+ this.millisec = millisec;
+ }
+ if (microsec !== false) {
+ this.microsec = microsec;
+ }
+ if (timezone !== false) {
+ this.timezone = timezone;
+ }
+
+ if (!this.inst) {
+ this.inst = $.datepicker._getInst(this.$input[0]);
+ }
+
+ this._limitMinMaxDateTime(this.inst, true);
+ }
+ if (this.support.ampm) {
+ this.ampm = ampm;
+ }
+
+ // Updates the time within the timepicker
+ this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
+ if (this.$timeObj) {
+ if (pickerTimeFormat === o.timeFormat) {
+ this.$timeObj.text(this.formattedTime + pickerTimeSuffix);
+ }
+ else {
+ this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
+ }
+ }
+
+ this.timeDefined = true;
+ if (hasChanged) {
+ this._updateDateTime();
+ }
+ },
+
+ /*
+ * call custom onSelect.
+ * bind to sliders slidestop, and grid click.
+ */
+ _onSelectHandler: function () {
+ var onSelect = this._defaults.onSelect || this.inst.settings.onSelect;
+ var inputEl = this.$input ? this.$input[0] : null;
+ if (onSelect && inputEl) {
+ onSelect.apply(inputEl, [this.formattedDateTime, this]);
+ }
+ },
+
+ /*
+ * update our input with the new date time..
+ */
+ _updateDateTime: function (dp_inst) {
+ dp_inst = this.inst || dp_inst;
+ var dtTmp = (dp_inst.currentYear > 0?
+ new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) :
+ new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
+ dt = $.datepicker._daylightSavingAdjust(dtTmp),
+ //dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
+ //dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay)),
+ dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
+ formatCfg = $.datepicker._getFormatConfig(dp_inst),
+ timeAvailable = dt !== null && this.timeDefined;
+ this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
+ var formattedDateTime = this.formattedDate;
+
+ // if a slider was changed but datepicker doesn't have a value yet, set it
+ if (dp_inst.lastVa === "") {
+ dp_inst.currentYear = dp_inst.selectedYear;
+ dp_inst.currentMonth = dp_inst.selectedMonth;
+ dp_inst.currentDay = dp_inst.selectedDay;
+ }
+
+ /*
+ * remove following lines to force every changes in date picker to change the input value
+ * Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
+ * If the user manually empty the value in the input field, the date picker will never change selected value.
+ */
+ //if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
+ // return;
+ //}
+
+ if (this._defaults.timeOnly === true) {
+ formattedDateTime = this.formattedTime;
+ } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
+ formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
+ }
+
+ this.formattedDateTime = formattedDateTime;
+
+ if (!this._defaults.showTimepicker) {
+ this.$input.val(this.formattedDate);
+ } else if (this.$altInput && this._defaults.timeOnly === false && this._defaults.altFieldTimeOnly === true) {
+ this.$altInput.val(this.formattedTime);
+ this.$input.val(this.formattedDate);
+ } else if (this.$altInput) {
+ this.$input.val(formattedDateTime);
+ var altFormattedDateTime = '',
+ altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
+ altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
+
+ if (!this._defaults.timeOnly) {
+ if (this._defaults.altFormat) {
+ altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
+ }
+ else {
+ altFormattedDateTime = this.formattedDate;
+ }
+
+ if (altFormattedDateTime) {
+ altFormattedDateTime += altSeparator;
+ }
+ }
+
+ if (this._defaults.altTimeFormat) {
+ altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
+ }
+ else {
+ altFormattedDateTime += this.formattedTime + altTimeSuffix;
+ }
+ this.$altInput.val(altFormattedDateTime);
+ } else {
+ this.$input.val(formattedDateTime);
+ }
+
+ this.$input.trigger("change");
+ },
+
+ _onFocus: function () {
+ if (!this.$input.val() && this._defaults.defaultValue) {
+ this.$input.val(this._defaults.defaultValue);
+ var inst = $.datepicker._getInst(this.$input.get(0)),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+ if (tp_inst) {
+ if (tp_inst._defaults.timeOnly && (inst.input.val() !== inst.lastVal)) {
+ try {
+ $.datepicker._updateDatepicker(inst);
+ } catch (err) {
+ $.timepicker.log(err);
+ }
+ }
+ }
+ }
+ },
+
+ /*
+ * Small abstraction to control types
+ * We can add more, just be sure to follow the pattern: create, options, value
+ */
+ _controls: {
+ // slider methods
+ slider: {
+ create: function (tp_inst, obj, unit, val, min, max, step) {
+ var rtl = tp_inst._defaults.isRTL; // if rtl go -60->0 instead of 0->60
+ return obj.prop('slide', null).slider({
+ orientation: "horizontal",
+ value: rtl ? val * -1 : val,
+ min: rtl ? max * -1 : min,
+ max: rtl ? min * -1 : max,
+ step: step,
+ slide: function (event, ui) {
+ tp_inst.control.value(tp_inst, $(this), unit, rtl ? ui.value * -1 : ui.value);
+ tp_inst._onTimeChange();
+ },
+ stop: function (event, ui) {
+ tp_inst._onSelectHandler();
+ }
+ });
+ },
+ options: function (tp_inst, obj, unit, opts, val) {
+ if (tp_inst._defaults.isRTL) {
+ if (typeof(opts) === 'string') {
+ if (opts === 'min' || opts === 'max') {
+ if (val !== undefined) {
+ return obj.slider(opts, val * -1);
+ }
+ return Math.abs(obj.slider(opts));
+ }
+ return obj.slider(opts);
+ }
+ var min = opts.min,
+ max = opts.max;
+ opts.min = opts.max = null;
+ if (min !== undefined) {
+ opts.max = min * -1;
+ }
+ if (max !== undefined) {
+ opts.min = max * -1;
+ }
+ return obj.slider(opts);
+ }
+ if (typeof(opts) === 'string' && val !== undefined) {
+ return obj.slider(opts, val);
+ }
+ return obj.slider(opts);
+ },
+ value: function (tp_inst, obj, unit, val) {
+ if (tp_inst._defaults.isRTL) {
+ if (val !== undefined) {
+ return obj.slider('value', val * -1);
+ }
+ return Math.abs(obj.slider('value'));
+ }
+ if (val !== undefined) {
+ return obj.slider('value', val);
+ }
+ return obj.slider('value');
+ }
+ },
+ // select methods
+ select: {
+ create: function (tp_inst, obj, unit, val, min, max, step) {
+ var sel = '<select class="ui-timepicker-select" data-unit="' + unit + '" data-min="' + min + '" data-max="' + max + '" data-step="' + step + '">',
+ format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat;
+
+ for (var i = min; i <= max; i += step) {
+ sel += '<option value="' + i + '"' + (i === val ? ' selected' : '') + '>';
+ if (unit === 'hour') {
+ sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig, '')), {hour: i}, tp_inst._defaults);
+ }
+ else if (unit === 'millisec' || unit === 'microsec' || i >= 10) { sel += i; }
+ else {sel += '0' + i.toString(); }
+ sel += '</option>';
+ }
+ sel += '</select>';
+
+ obj.children('select').remove();
+
+ $(sel).appendTo(obj).change(function (e) {
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ });
+
+ return obj;
+ },
+ options: function (tp_inst, obj, unit, opts, val) {
+ var o = {},
+ $t = obj.children('select');
+ if (typeof(opts) === 'string') {
+ if (val === undefined) {
+ return $t.data(opts);
+ }
+ o[opts] = val;
+ }
+ else { o = opts; }
+ return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
+ },
+ value: function (tp_inst, obj, unit, val) {
+ var $t = obj.children('select');
+ if (val !== undefined) {
+ return $t.val(val);
+ }
+ return $t.val();
+ }
+ }
+ } // end _controls
+
+ });
+
+ $.fn.extend({
+ /*
+ * shorthand just to use timepicker.
+ */
+ timepicker: function (o) {
+ o = o || {};
+ var tmp_args = Array.prototype.slice.call(arguments);
+
+ if (typeof o === 'object') {
+ tmp_args[0] = $.extend(o, {
+ timeOnly: true
+ });
+ }
+
+ return $(this).each(function () {
+ $.fn.datetimepicker.apply($(this), tmp_args);
+ });
+ },
+
+ /*
+ * extend timepicker to datepicker
+ */
+ datetimepicker: function (o) {
+ o = o || {};
+ var tmp_args = arguments;
+
+ if (typeof(o) === 'string') {
+ if (o === 'getDate') {
+ return $.fn.datepicker.apply($(this[0]), tmp_args);
+ } else {
+ return this.each(function () {
+ var $t = $(this);
+ $t.datepicker.apply($t, tmp_args);
+ });
+ }
+ } else {
+ return this.each(function () {
+ var $t = $(this);
+ $t.datepicker($.timepicker._newInst($t, o)._defaults);
+ });
+ }
+ }
+ });
+
+ /*
+ * Public Utility to parse date and time
+ */
+ $.datepicker.parseDateTime = function (dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
+ var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
+ if (parseRes.timeObj) {
+ var t = parseRes.timeObj;
+ parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
+ parseRes.date.setMicroseconds(t.microsec);
+ }
+
+ return parseRes.date;
+ };
+
+ /*
+ * Public utility to parse time
+ */
+ $.datepicker.parseTime = function (timeFormat, timeString, options) {
+ var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {}),
+ iso8601 = (timeFormat.replace(/\'.*?\'/g, '').indexOf('Z') !== -1);
+
+ // Strict parse requires the timeString to match the timeFormat exactly
+ var strictParse = function (f, s, o) {
+
+ // pattern for standard and localized AM/PM markers
+ var getPatternAmpm = function (amNames, pmNames) {
+ var markers = [];
+ if (amNames) {
+ $.merge(markers, amNames);
+ }
+ if (pmNames) {
+ $.merge(markers, pmNames);
+ }
+ markers = $.map(markers, function (val) {
+ return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&');
+ });
+ return '(' + markers.join('|') + ')?';
+ };
+
+ // figure out position of time elements.. cause js cant do named captures
+ var getFormatPositions = function (timeFormat) {
+ var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),
+ orders = {
+ h: -1,
+ m: -1,
+ s: -1,
+ l: -1,
+ c: -1,
+ t: -1,
+ z: -1
+ };
+
+ if (finds) {
+ for (var i = 0; i < finds.length; i++) {
+ if (orders[finds[i].toString().charAt(0)] === -1) {
+ orders[finds[i].toString().charAt(0)] = i + 1;
+ }
+ }
+ }
+ return orders;
+ };
+
+ var regstr = '^' + f.toString()
+ .replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
+ var ml = match.length;
+ switch (match.charAt(0).toLowerCase()) {
+ case 'h':
+ return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
+ case 'm':
+ return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
+ case 's':
+ return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
+ case 'l':
+ return '(\\d?\\d?\\d)';
+ case 'c':
+ return '(\\d?\\d?\\d)';
+ case 'z':
+ return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
+ case 't':
+ return getPatternAmpm(o.amNames, o.pmNames);
+ default: // literal escaped in quotes
+ return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
+ }
+ })
+ .replace(/\s/g, '\\s?') +
+ o.timeSuffix + '$',
+ order = getFormatPositions(f),
+ ampm = '',
+ treg;
+
+ treg = s.match(new RegExp(regstr, 'i'));
+
+ var resTime = {
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ microsec: 0
+ };
+
+ if (treg) {
+ if (order.t !== -1) {
+ if (treg[order.t] === undefined || treg[order.t].length === 0) {
+ ampm = '';
+ resTime.ampm = '';
+ } else {
+ ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
+ resTime.ampm = o[ampm === 'AM' ? 'amNames' : 'pmNames'][0];
+ }
+ }
+
+ if (order.h !== -1) {
+ if (ampm === 'AM' && treg[order.h] === '12') {
+ resTime.hour = 0; // 12am = 0 hour
+ } else {
+ if (ampm === 'PM' && treg[order.h] !== '12') {
+ resTime.hour = parseInt(treg[order.h], 10) + 12; // 12pm = 12 hour, any other pm = hour + 12
+ } else {
+ resTime.hour = Number(treg[order.h]);
+ }
+ }
+ }
+
+ if (order.m !== -1) {
+ resTime.minute = Number(treg[order.m]);
+ }
+ if (order.s !== -1) {
+ resTime.second = Number(treg[order.s]);
+ }
+ if (order.l !== -1) {
+ resTime.millisec = Number(treg[order.l]);
+ }
+ if (order.c !== -1) {
+ resTime.microsec = Number(treg[order.c]);
+ }
+ if (order.z !== -1 && treg[order.z] !== undefined) {
+ resTime.timezone = $.timepicker.timezoneOffsetNumber(treg[order.z]);
+ }
+
+
+ return resTime;
+ }
+ return false;
+ };// end strictParse
+
+ // First try JS Date, if that fails, use strictParse
+ var looseParse = function (f, s, o) {
+ try {
+ var d = new Date('2012-01-01 ' + s);
+ if (isNaN(d.getTime())) {
+ d = new Date('2012-01-01T' + s);
+ if (isNaN(d.getTime())) {
+ d = new Date('01/01/2012 ' + s);
+ if (isNaN(d.getTime())) {
+ throw "Unable to parse time with native Date: " + s;
+ }
+ }
+ }
+
+ return {
+ hour: d.getHours(),
+ minute: d.getMinutes(),
+ second: d.getSeconds(),
+ millisec: d.getMilliseconds(),
+ microsec: d.getMicroseconds(),
+ timezone: d.getTimezoneOffset() * -1
+ };
+ }
+ catch (err) {
+ try {
+ return strictParse(f, s, o);
+ }
+ catch (err2) {
+ $.timepicker.log("Unable to parse \ntimeString: " + s + "\ntimeFormat: " + f);
+ }
+ }
+ return false;
+ }; // end looseParse
+
+ if (typeof o.parse === "function") {
+ return o.parse(timeFormat, timeString, o);
+ }
+ if (o.parse === 'loose') {
+ return looseParse(timeFormat, timeString, o);
+ }
+ return strictParse(timeFormat, timeString, o);
+ };
+
+ /**
+ * Public utility to format the time
+ * @param {string} format format of the time
+ * @param {Object} time Object not a Date for timezones
+ * @param {Object} [options] essentially the regional[].. amNames, pmNames, ampm
+ * @returns {string} the formatted time
+ */
+ $.datepicker.formatTime = function (format, time, options) {
+ options = options || {};
+ options = $.extend({}, $.timepicker._defaults, options);
+ time = $.extend({
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ microsec: 0,
+ timezone: null
+ }, time);
+
+ var tmptime = format,
+ ampmName = options.amNames[0],
+ hour = parseInt(time.hour, 10);
+
+ if (hour > 11) {
+ ampmName = options.pmNames[0];
+ }
+
+ tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
+ switch (match) {
+ case 'HH':
+ return ('0' + hour).slice(-2);
+ case 'H':
+ return hour;
+ case 'hh':
+ return ('0' + convert24to12(hour)).slice(-2);
+ case 'h':
+ return convert24to12(hour);
+ case 'mm':
+ return ('0' + time.minute).slice(-2);
+ case 'm':
+ return time.minute;
+ case 'ss':
+ return ('0' + time.second).slice(-2);
+ case 's':
+ return time.second;
+ case 'l':
+ return ('00' + time.millisec).slice(-3);
+ case 'c':
+ return ('00' + time.microsec).slice(-3);
+ case 'z':
+ return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, false);
+ case 'Z':
+ return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, true);
+ case 'T':
+ return ampmName.charAt(0).toUpperCase();
+ case 'TT':
+ return ampmName.toUpperCase();
+ case 't':
+ return ampmName.charAt(0).toLowerCase();
+ case 'tt':
+ return ampmName.toLowerCase();
+ default:
+ return match.replace(/'/g, "");
+ }
+ });
+
+ return tmptime;
+ };
+
+ /*
+ * the bad hack :/ override datepicker so it doesn't close on select
+ // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
+ */
+ $.datepicker._base_selectDate = $.datepicker._selectDate;
+ $.datepicker._selectDate = function (id, dateStr) {
+ var inst = this._getInst($(id)[0]),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ tp_inst._limitMinMaxDateTime(inst, true);
+ inst.inline = inst.stay_open = true;
+ //This way the onSelect handler called from calendarpicker get the full dateTime
+ this._base_selectDate(id, dateStr);
+ inst.inline = inst.stay_open = false;
+ this._notifyChange(inst);
+ this._updateDatepicker(inst);
+ } else {
+ this._base_selectDate(id, dateStr);
+ }
+ };
+
+ /*
+ * second bad hack :/ override datepicker so it triggers an event when changing the input field
+ * and does not redraw the datepicker on every selectDate event
+ */
+ $.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
+ $.datepicker._updateDatepicker = function (inst) {
+
+ // don't popup the datepicker if there is another instance already opened
+ var input = inst.input[0];
+ if ($.datepicker._curInst && $.datepicker._curInst !== inst && $.datepicker._datepickerShowing && $.datepicker._lastInput !== input) {
+ return;
+ }
+
+ if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
+
+ this._base_updateDatepicker(inst);
+
+ // Reload the time control when changing something in the input text field.
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ tp_inst._addTimePicker(inst);
+ }
+ }
+ };
+
+ /*
+ * third bad hack :/ override datepicker so it allows spaces and colon in the input field
+ */
+ $.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
+ $.datepicker._doKeyPress = function (event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if ($.datepicker._get(inst, 'constrainInput')) {
+ var ampm = tp_inst.support.ampm,
+ tz = tp_inst._defaults.showTimezone !== null ? tp_inst._defaults.showTimezone : tp_inst.support.timezone,
+ dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
+ datetimeChars = tp_inst._defaults.timeFormat.toString()
+ .replace(/[hms]/g, '')
+ .replace(/TT/g, ampm ? 'APM' : '')
+ .replace(/Tt/g, ampm ? 'AaPpMm' : '')
+ .replace(/tT/g, ampm ? 'AaPpMm' : '')
+ .replace(/T/g, ampm ? 'AP' : '')
+ .replace(/tt/g, ampm ? 'apm' : '')
+ .replace(/t/g, ampm ? 'ap' : '') +
+ " " + tp_inst._defaults.separator +
+ tp_inst._defaults.timeSuffix +
+ (tz ? tp_inst._defaults.timezoneList.join('') : '') +
+ (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
+ dateChars,
+ chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
+ return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
+ }
+ }
+
+ return $.datepicker._base_doKeyPress(event);
+ };
+
+ /*
+ * Fourth bad hack :/ override _updateAlternate function used in inline mode to init altField
+ * Update any alternate field to synchronise with the main field.
+ */
+ $.datepicker._base_updateAlternate = $.datepicker._updateAlternate;
+ $.datepicker._updateAlternate = function (inst) {
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var altField = tp_inst._defaults.altField;
+ if (altField) { // update alternate field too
+ var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
+ date = this._getDate(inst),
+ formatCfg = $.datepicker._getFormatConfig(inst),
+ altFormattedDateTime = '',
+ altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
+ altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
+ altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
+
+ altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
+ if (!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null) {
+ if (tp_inst._defaults.altFormat) {
+ altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
+ }
+ else {
+ altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
+ }
+ }
+ $(altField).val(altFormattedDateTime);
+ }
+ }
+ else {
+ $.datepicker._base_updateAlternate(inst);
+ }
+ };
+
+ /*
+ * Override key up event to sync manual input changes.
+ */
+ $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
+ $.datepicker._doKeyUp = function (event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if (tp_inst._defaults.timeOnly && (inst.input.val() !== inst.lastVal)) {
+ try {
+ $.datepicker._updateDatepicker(inst);
+ } catch (err) {
+ $.timepicker.log(err);
+ }
+ }
+ }
+
+ return $.datepicker._base_doKeyUp(event);
+ };
+
+ /*
+ * override "Today" button to also grab the time.
+ */
+ $.datepicker._base_gotoToday = $.datepicker._gotoToday;
+ $.datepicker._gotoToday = function (id) {
+ var inst = this._getInst($(id)[0]),
+ $dp = inst.dpDiv;
+ this._base_gotoToday(id);
+ var tp_inst = this._get(inst, 'timepicker');
+ selectLocalTimezone(tp_inst);
+ var now = new Date();
+ this._setTime(inst, now);
+ $('.ui-datepicker-today', $dp).click();
+ };
+
+ /*
+ * Disable & enable the Time in the datetimepicker
+ */
+ $.datepicker._disableTimepickerDatepicker = function (target) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ inst.settings.showTimepicker = false;
+ tp_inst._defaults.showTimepicker = false;
+ tp_inst._updateDateTime(inst);
+ }
+ };
+
+ $.datepicker._enableTimepickerDatepicker = function (target) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ inst.settings.showTimepicker = true;
+ tp_inst._defaults.showTimepicker = true;
+ tp_inst._addTimePicker(inst); // Could be disabled on page load
+ tp_inst._updateDateTime(inst);
+ }
+ };
+
+ /*
+ * Create our own set time function
+ */
+ $.datepicker._setTime = function (inst, date) {
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var defaults = tp_inst._defaults;
+
+ // calling _setTime with no date sets time to defaults
+ tp_inst.hour = date ? date.getHours() : defaults.hour;
+ tp_inst.minute = date ? date.getMinutes() : defaults.minute;
+ tp_inst.second = date ? date.getSeconds() : defaults.second;
+ tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
+ tp_inst.microsec = date ? date.getMicroseconds() : defaults.microsec;
+
+ //check if within min/max times..
+ tp_inst._limitMinMaxDateTime(inst, true);
+
+ tp_inst._onTimeChange();
+ tp_inst._updateDateTime(inst);
+ }
+ };
+
+ /*
+ * Create new public method to set only time, callable as $().datepicker('setTime', date)
+ */
+ $.datepicker._setTimeDatepicker = function (target, date, withDate) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ this._setDateFromField(inst);
+ var tp_date;
+ if (date) {
+ if (typeof date === "string") {
+ tp_inst._parseTime(date, withDate);
+ tp_date = new Date();
+ tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
+ tp_date.setMicroseconds(tp_inst.microsec);
+ } else {
+ tp_date = new Date(date.getTime());
+ tp_date.setMicroseconds(date.getMicroseconds());
+ }
+ if (tp_date.toString() === 'Invalid Date') {
+ tp_date = undefined;
+ }
+ this._setTime(inst, tp_date);
+ }
+ }
+
+ };
+
+ /*
+ * override setDate() to allow setting time too within Date object
+ */
+ $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
+ $.datepicker._setDateDatepicker = function (target, date) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ if (typeof(date) === 'string') {
+ date = new Date(date);
+ if (!date.getTime()) {
+ $.timepicker.log("Error creating Date object from string.");
+ }
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+ var tp_date;
+ if (date instanceof Date) {
+ tp_date = new Date(date.getTime());
+ tp_date.setMicroseconds(date.getMicroseconds());
+ } else {
+ tp_date = date;
+ }
+
+ // This is important if you are using the timezone option, javascript's Date
+ // object will only return the timezone offset for the current locale, so we
+ // adjust it accordingly. If not using timezone option this won't matter..
+ // If a timezone is different in tp, keep the timezone as is
+ if (tp_inst) {
+ // look out for DST if tz wasn't specified
+ if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
+ tp_inst.timezone = tp_date.getTimezoneOffset() * -1;
+ }
+ date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
+ tp_date = $.timepicker.timezoneAdjust(tp_date, tp_inst.timezone);
+ }
+
+ this._updateDatepicker(inst);
+ this._base_setDateDatepicker.apply(this, arguments);
+ this._setTimeDatepicker(target, tp_date, true);
+ };
+
+ /*
+ * override getDate() to allow getting time too within Date object
+ */
+ $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
+ $.datepicker._getDateDatepicker = function (target, noDefault) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ // if it hasn't yet been defined, grab from field
+ if (inst.lastVal === undefined) {
+ this._setDateFromField(inst, noDefault);
+ }
+
+ var date = this._getDate(inst);
+ if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) {
+ date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
+ date.setMicroseconds(tp_inst.microsec);
+
+ // This is important if you are using the timezone option, javascript's Date
+ // object will only return the timezone offset for the current locale, so we
+ // adjust it accordingly. If not using timezone option this won't matter..
+ if (tp_inst.timezone != null) {
+ // look out for DST if tz wasn't specified
+ if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
+ tp_inst.timezone = date.getTimezoneOffset() * -1;
+ }
+ date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
+ }
+ }
+ return date;
+ }
+ return this._base_getDateDatepicker(target, noDefault);
+ };
+
+ /*
+ * override parseDate() because UI 1.8.14 throws an error about "Extra characters"
+ * An option in datapicker to ignore extra format characters would be nicer.
+ */
+ $.datepicker._base_parseDate = $.datepicker.parseDate;
+ $.datepicker.parseDate = function (format, value, settings) {
+ var date;
+ try {
+ date = this._base_parseDate(format, value, settings);
+ } catch (err) {
+ // Hack! The error message ends with a colon, a space, and
+ // the "extra" characters. We rely on that instead of
+ // attempting to perfectly reproduce the parsing algorithm.
+ if (err.indexOf(":") >= 0) {
+ date = this._base_parseDate(format, value.substring(0, value.length - (err.length - err.indexOf(':') - 2)), settings);
+ $.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
+ } else {
+ throw err;
+ }
+ }
+ return date;
+ };
+
+ /*
+ * override formatDate to set date with time to the input
+ */
+ $.datepicker._base_formatDate = $.datepicker._formatDate;
+ $.datepicker._formatDate = function (inst, day, month, year) {
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ tp_inst._updateDateTime(inst);
+ return tp_inst.$input.val();
+ }
+ return this._base_formatDate(inst);
+ };
+
+ /*
+ * override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
+ */
+ $.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
+ $.datepicker._optionDatepicker = function (target, name, value) {
+ var inst = this._getInst(target),
+ name_clone;
+ if (!inst) {
+ return null;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var min = null,
+ max = null,
+ onselect = null,
+ overrides = tp_inst._defaults.evnts,
+ fns = {},
+ prop;
+ if (typeof name === 'string') { // if min/max was set with the string
+ if (name === 'minDate' || name === 'minDateTime') {
+ min = value;
+ } else if (name === 'maxDate' || name === 'maxDateTime') {
+ max = value;
+ } else if (name === 'onSelect') {
+ onselect = value;
+ } else if (overrides.hasOwnProperty(name)) {
+ if (typeof (value) === 'undefined') {
+ return overrides[name];
+ }
+ fns[name] = value;
+ name_clone = {}; //empty results in exiting function after overrides updated
+ }
+ } else if (typeof name === 'object') { //if min/max was set with the JSON
+ if (name.minDate) {
+ min = name.minDate;
+ } else if (name.minDateTime) {
+ min = name.minDateTime;
+ } else if (name.maxDate) {
+ max = name.maxDate;
+ } else if (name.maxDateTime) {
+ max = name.maxDateTime;
+ }
+ for (prop in overrides) {
+ if (overrides.hasOwnProperty(prop) && name[prop]) {
+ fns[prop] = name[prop];
+ }
+ }
+ }
+ for (prop in fns) {
+ if (fns.hasOwnProperty(prop)) {
+ overrides[prop] = fns[prop];
+ if (!name_clone) { name_clone = $.extend({}, name); }
+ delete name_clone[prop];
+ }
+ }
+ if (name_clone && isEmptyObject(name_clone)) { return; }
+ if (min) { //if min was set
+ if (min === 0) {
+ min = new Date();
+ } else {
+ min = new Date(min);
+ }
+ tp_inst._defaults.minDate = min;
+ tp_inst._defaults.minDateTime = min;
+ } else if (max) { //if max was set
+ if (max === 0) {
+ max = new Date();
+ } else {
+ max = new Date(max);
+ }
+ tp_inst._defaults.maxDate = max;
+ tp_inst._defaults.maxDateTime = max;
+ } else if (onselect) {
+ tp_inst._defaults.onSelect = onselect;
+ }
+ }
+ if (value === undefined) {
+ return this._base_optionDatepicker.call($.datepicker, target, name);
+ }
+ return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
+ };
+
+ /*
+ * jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
+ * it will return false for all objects
+ */
+ var isEmptyObject = function (obj) {
+ var prop;
+ for (prop in obj) {
+ if (obj.hasOwnProperty(prop)) {
+ return false;
+ }
+ }
+ return true;
+ };
+
+ /*
+ * jQuery extend now ignores nulls!
+ */
+ var extendRemove = function (target, props) {
+ $.extend(target, props);
+ for (var name in props) {
+ if (props[name] === null || props[name] === undefined) {
+ target[name] = props[name];
+ }
+ }
+ return target;
+ };
+
+ /*
+ * Determine by the time format which units are supported
+ * Returns an object of booleans for each unit
+ */
+ var detectSupport = function (timeFormat) {
+ var tf = timeFormat.replace(/'.*?'/g, '').toLowerCase(), // removes literals
+ isIn = function (f, t) { // does the format contain the token?
+ return f.indexOf(t) !== -1 ? true : false;
+ };
+ return {
+ hour: isIn(tf, 'h'),
+ minute: isIn(tf, 'm'),
+ second: isIn(tf, 's'),
+ millisec: isIn(tf, 'l'),
+ microsec: isIn(tf, 'c'),
+ timezone: isIn(tf, 'z'),
+ ampm: isIn(tf, 't') && isIn(timeFormat, 'h'),
+ iso8601: isIn(timeFormat, 'Z')
+ };
+ };
+
+ /*
+ * Converts 24 hour format into 12 hour
+ * Returns 12 hour without leading 0
+ */
+ var convert24to12 = function (hour) {
+ hour %= 12;
+
+ if (hour === 0) {
+ hour = 12;
+ }
+
+ return String(hour);
+ };
+
+ var computeEffectiveSetting = function (settings, property) {
+ return settings && settings[property] ? settings[property] : $.timepicker._defaults[property];
+ };
+
+ /*
+ * Splits datetime string into date and time substrings.
+ * Throws exception when date can't be parsed
+ * Returns {dateString: dateString, timeString: timeString}
+ */
+ var splitDateTime = function (dateTimeString, timeSettings) {
+ // The idea is to get the number separator occurrences in datetime and the time format requested (since time has
+ // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
+ var separator = computeEffectiveSetting(timeSettings, 'separator'),
+ format = computeEffectiveSetting(timeSettings, 'timeFormat'),
+ timeParts = format.split(separator), // how many occurrences of separator may be in our format?
+ timePartsLen = timeParts.length,
+ allParts = dateTimeString.split(separator),
+ allPartsLen = allParts.length;
+
+ if (allPartsLen > 1) {
+ return {
+ dateString: allParts.splice(0, allPartsLen - timePartsLen).join(separator),
+ timeString: allParts.splice(0, timePartsLen).join(separator)
+ };
+ }
+
+ return {
+ dateString: dateTimeString,
+ timeString: ''
+ };
+ };
+
+ /*
+ * Internal function to parse datetime interval
+ * Returns: {date: Date, timeObj: Object}, where
+ * date - parsed date without time (type Date)
+ * timeObj = {hour: , minute: , second: , millisec: , microsec: } - parsed time. Optional
+ */
+ var parseDateTimeInternal = function (dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
+ var date,
+ parts,
+ parsedTime;
+
+ parts = splitDateTime(dateTimeString, timeSettings);
+ date = $.datepicker._base_parseDate(dateFormat, parts.dateString, dateSettings);
+
+ if (parts.timeString === '') {
+ return {
+ date: date
+ };
+ }
+
+ parsedTime = $.datepicker.parseTime(timeFormat, parts.timeString, timeSettings);
+
+ if (!parsedTime) {
+ throw 'Wrong time format';
+ }
+
+ return {
+ date: date,
+ timeObj: parsedTime
+ };
+ };
+
+ /*
+ * Internal function to set timezone_select to the local timezone
+ */
+ var selectLocalTimezone = function (tp_inst, date) {
+ if (tp_inst && tp_inst.timezone_select) {
+ var now = date || new Date();
+ tp_inst.timezone_select.val(-now.getTimezoneOffset());
+ }
+ };
+
+ /*
+ * Create a Singleton Instance
+ */
+ $.timepicker = new Timepicker();
+
+ /**
+ * Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
+ * @param {number} tzMinutes if not a number, less than -720 (-1200), or greater than 840 (+1400) this value is returned
+ * @param {boolean} iso8601 if true formats in accordance to iso8601 "+12:45"
+ * @return {string}
+ */
+ $.timepicker.timezoneOffsetString = function (tzMinutes, iso8601) {
+ if (isNaN(tzMinutes) || tzMinutes > 840 || tzMinutes < -720) {
+ return tzMinutes;
+ }
+
+ var off = tzMinutes,
+ minutes = off % 60,
+ hours = (off - minutes) / 60,
+ iso = iso8601 ? ':' : '',
+ tz = (off >= 0 ? '+' : '-') + ('0' + Math.abs(hours)).slice(-2) + iso + ('0' + Math.abs(minutes)).slice(-2);
+
+ if (tz === '+00:00') {
+ return 'Z';
+ }
+ return tz;
+ };
+
+ /**
+ * Get the number in minutes that represents a timezone string
+ * @param {string} tzString formatted like "+0500", "-1245", "Z"
+ * @return {number} the offset minutes or the original string if it doesn't match expectations
+ */
+ $.timepicker.timezoneOffsetNumber = function (tzString) {
+ var normalized = tzString.toString().replace(':', ''); // excuse any iso8601, end up with "+1245"
+
+ if (normalized.toUpperCase() === 'Z') { // if iso8601 with Z, its 0 minute offset
+ return 0;
+ }
+
+ if (!/^(\-|\+)\d{4}$/.test(normalized)) { // possibly a user defined tz, so just give it back
+ return tzString;
+ }
+
+ return ((normalized.substr(0, 1) === '-' ? -1 : 1) * // plus or minus
+ ((parseInt(normalized.substr(1, 2), 10) * 60) + // hours (converted to minutes)
+ parseInt(normalized.substr(3, 2), 10))); // minutes
+ };
+
+ /**
+ * No way to set timezone in js Date, so we must adjust the minutes to compensate. (think setDate, getDate)
+ * @param {Date} date
+ * @param {string} toTimezone formatted like "+0500", "-1245"
+ * @return {Date}
+ */
+ $.timepicker.timezoneAdjust = function (date, toTimezone) {
+ var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
+ if (!isNaN(toTz)) {
+ date.setMinutes(date.getMinutes() + -date.getTimezoneOffset() - toTz);
+ }
+ return date;
+ };
+
+ /**
+ * Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
+ * enforce date range limits.
+ * n.b. The input value must be correctly formatted (reformatting is not supported)
+ * @param {Element} startTime
+ * @param {Element} endTime
+ * @param {Object} options Options for the timepicker() call
+ * @return {jQuery}
+ */
+ $.timepicker.timeRange = function (startTime, endTime, options) {
+ return $.timepicker.handleRange('timepicker', startTime, endTime, options);
+ };
+
+ /**
+ * Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
+ * enforce date range limits.
+ * @param {Element} startTime
+ * @param {Element} endTime
+ * @param {Object} options Options for the `timepicker()` call. Also supports `reformat`,
+ * a boolean value that can be used to reformat the input values to the `dateFormat`.
+ * @param {string} method Can be used to specify the type of picker to be added
+ * @return {jQuery}
+ */
+ $.timepicker.datetimeRange = function (startTime, endTime, options) {
+ $.timepicker.handleRange('datetimepicker', startTime, endTime, options);
+ };
+
+ /**
+ * Calls `datepicker` on the `startTime` and `endTime` elements, and configures them to
+ * enforce date range limits.
+ * @param {Element} startTime
+ * @param {Element} endTime
+ * @param {Object} options Options for the `timepicker()` call. Also supports `reformat`,
+ * a boolean value that can be used to reformat the input values to the `dateFormat`.
+ * @return {jQuery}
+ */
+ $.timepicker.dateRange = function (startTime, endTime, options) {
+ $.timepicker.handleRange('datepicker', startTime, endTime, options);
+ };
+
+ /**
+ * Calls `method` on the `startTime` and `endTime` elements, and configures them to
+ * enforce date range limits.
+ * @param {string} method Can be used to specify the type of picker to be added
+ * @param {Element} startTime
+ * @param {Element} endTime
+ * @param {Object} options Options for the `timepicker()` call. Also supports `reformat`,
+ * a boolean value that can be used to reformat the input values to the `dateFormat`.
+ * @return {jQuery}
+ */
+ $.timepicker.handleRange = function (method, startTime, endTime, options) {
+ options = $.extend({}, {
+ minInterval: 0, // min allowed interval in milliseconds
+ maxInterval: 0, // max allowed interval in milliseconds
+ start: {}, // options for start picker
+ end: {} // options for end picker
+ }, options);
+
+ function checkDates(changed, other) {
+ var startdt = startTime[method]('getDate'),
+ enddt = endTime[method]('getDate'),
+ changeddt = changed[method]('getDate');
+
+ if (startdt !== null) {
+ var minDate = new Date(startdt.getTime()),
+ maxDate = new Date(startdt.getTime());
+
+ minDate.setMilliseconds(minDate.getMilliseconds() + options.minInterval);
+ maxDate.setMilliseconds(maxDate.getMilliseconds() + options.maxInterval);
+
+ if (options.minInterval > 0 && minDate > enddt) { // minInterval check
+ endTime[method]('setDate', minDate);
+ }
+ else if (options.maxInterval > 0 && maxDate < enddt) { // max interval check
+ endTime[method]('setDate', maxDate);
+ }
+ else if (startdt > enddt) {
+ other[method]('setDate', changeddt);
+ }
+ }
+ }
+
+ function selected(changed, other, option) {
+ if (!changed.val()) {
+ return;
+ }
+ var date = changed[method].call(changed, 'getDate');
+ if (date !== null && options.minInterval > 0) {
+ if (option === 'minDate') {
+ date.setMilliseconds(date.getMilliseconds() + options.minInterval);
+ }
+ if (option === 'maxDate') {
+ date.setMilliseconds(date.getMilliseconds() - options.minInterval);
+ }
+ }
+ if (date.getTime) {
+ other[method].call(other, 'option', option, date);
+ }
+ }
+
+ $.fn[method].call(startTime, $.extend({
+ onClose: function (dateText, inst) {
+ checkDates($(this), endTime);
+ },
+ onSelect: function (selectedDateTime) {
+ selected($(this), endTime, 'minDate');
+ }
+ }, options, options.start));
+ $.fn[method].call(endTime, $.extend({
+ onClose: function (dateText, inst) {
+ checkDates($(this), startTime);
+ },
+ onSelect: function (selectedDateTime) {
+ selected($(this), startTime, 'maxDate');
+ }
+ }, options, options.end));
+
+ checkDates(startTime, endTime);
+ selected(startTime, endTime, 'minDate');
+ selected(endTime, startTime, 'maxDate');
+ return $([startTime.get(0), endTime.get(0)]);
+ };
+
+ /**
+ * Log error or data to the console during error or debugging
+ * @param {Object} err pass any type object to log to the console during error or debugging
+ * @return {void}
+ */
+ $.timepicker.log = function (err) {
+ if (window.console) {
+ window.console.log(err);
+ }
+ };
+
+ /*
+ * Add util object to allow access to private methods for testability.
+ */
+ $.timepicker._util = {
+ _extendRemove: extendRemove,
+ _isEmptyObject: isEmptyObject,
+ _convert24to12: convert24to12,
+ _detectSupport: detectSupport,
+ _selectLocalTimezone: selectLocalTimezone,
+ _computeEffectiveSetting: computeEffectiveSetting,
+ _splitDateTime: splitDateTime,
+ _parseDateTimeInternal: parseDateTimeInternal
+ };
+
+ /*
+ * Microsecond support
+ */
+ if (!Date.prototype.getMicroseconds) {
+ Date.prototype.microseconds = 0;
+ Date.prototype.getMicroseconds = function () { return this.microseconds; };
+ Date.prototype.setMicroseconds = function (m) {
+ this.setMilliseconds(this.getMilliseconds() + Math.floor(m / 1000));
+ this.microseconds = m % 1000;
+ return this;
+ };
+ }
+
+ /*
+ * Keep up with the version
+ */
+ $.timepicker.version = "1.4";
+
+})(jQuery);
diff --git a/dist/jquery-ui-timepicker-addon.min.css b/dist/jquery-ui-timepicker-addon.min.css
new file mode 100644
index 0000000..4de8c3d
--- /dev/null
+++ b/dist/jquery-ui-timepicker-addon.min.css
@@ -0,0 +1,5 @@
+/*! jQuery Timepicker Addon - v1.4 - 2013-08-11
+* http://trentrichardson.com/examples/timepicker
+* Copyright (c) 2013 Trent Richardson; Licensed MIT */
+
+.ui-timepicker-div .ui-widget-header{margin-bottom:8px}.ui-timepicker-div dl{text-align:left}.ui-timepicker-div dl dt{float:left;clear:left;padding:0 0 0 5px}.ui-timepicker-div dl dd{margin:0 10px 10px 40%}.ui-timepicker-div td{font-size:90%}.ui-tpicker-grid-label{background:0;border:0;margin:0;padding:0}.ui-timepicker-rtl{direction:rtl}.ui-timepicker-rtl dl{text-align:right;padding:0 5px 0 0}.ui-timepicker-rtl dl dt{float:right;clear:right}.ui-timepicker-rtl dl dd{margin:0 40% 10px 10px} \ No newline at end of file
diff --git a/dist/jquery-ui-timepicker-addon.min.js b/dist/jquery-ui-timepicker-addon.min.js
new file mode 100644
index 0000000..a7a934f
--- /dev/null
+++ b/dist/jquery-ui-timepicker-addon.min.js
@@ -0,0 +1,5 @@
+/*! jQuery Timepicker Addon - v1.4 - 2013-08-11
+* http://trentrichardson.com/examples/timepicker
+* Copyright (c) 2013 Trent Richardson; Licensed MIT */
+(function($){if($.ui.timepicker=$.ui.timepicker||{},!$.ui.timepicker.version){$.extend($.ui,{timepicker:{version:"1.4"}});var Timepicker=function(){this.regional=[],this.regional[""]={currentText:"Now",closeText:"Done",amNames:["AM","A"],pmNames:["PM","P"],timeFormat:"HH:mm",timeSuffix:"",timeOnlyTitle:"Choose Time",timeText:"Time",hourText:"Hour",minuteText:"Minute",secondText:"Second",millisecText:"Millisecond",microsecText:"Microsecond",timezoneText:"Time Zone",isRTL:!1},this._defaults={showButtonPanel:!0,timeOnly:!1,showHour:null,showMinute:null,showSecond:null,showMillisec:null,showMicrosec:null,showTimezone:null,showTime:!0,stepHour:1,stepMinute:1,stepSecond:1,stepMillisec:1,stepMicrosec:1,hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null,hourMin:0,minuteMin:0,secondMin:0,millisecMin:0,microsecMin:0,hourMax:23,minuteMax:59,secondMax:59,millisecMax:999,microsecMax:999,minDateTime:null,maxDateTime:null,onSelect:null,hourGrid:0,minuteGrid:0,secondGrid:0,millisecGrid:0,microsecGrid:0,alwaysSetTime:!0,separator:" ",altFieldTimeOnly:!0,altTimeFormat:null,altSeparator:null,altTimeSuffix:null,pickerTimeFormat:null,pickerTimeSuffix:null,showTimepicker:!0,timezoneList:null,addSliderAccess:!1,sliderAccessArgs:null,controlType:"slider",defaultValue:null,parse:"strict"},$.extend(this._defaults,this.regional[""])};$.extend(Timepicker.prototype,{$input:null,$altInput:null,$timeObj:null,inst:null,hour_slider:null,minute_slider:null,second_slider:null,millisec_slider:null,microsec_slider:null,timezone_select:null,hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null,hourMinOriginal:null,minuteMinOriginal:null,secondMinOriginal:null,millisecMinOriginal:null,microsecMinOriginal:null,hourMaxOriginal:null,minuteMaxOriginal:null,secondMaxOriginal:null,millisecMaxOriginal:null,microsecMaxOriginal:null,ampm:"",formattedDate:"",formattedTime:"",formattedDateTime:"",timezoneList:null,units:["hour","minute","second","millisec","microsec"],support:{},control:null,setDefaults:function(e){return extendRemove(this._defaults,e||{}),this},_newInst:function($input,opts){var tp_inst=new Timepicker,inlineSettings={},fns={},overrides,i;for(var attrName in this._defaults)if(this._defaults.hasOwnProperty(attrName)){var attrValue=$input.attr("time:"+attrName);if(attrValue)try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}overrides={beforeShow:function(e,t){return $.isFunction(tp_inst._defaults.evnts.beforeShow)?tp_inst._defaults.evnts.beforeShow.call($input[0],e,t,tp_inst):void 0},onChangeMonthYear:function(e,t,i){tp_inst._updateDateTime(i),$.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)&&tp_inst._defaults.evnts.onChangeMonthYear.call($input[0],e,t,i,tp_inst)},onClose:function(e,t){tp_inst.timeDefined===!0&&""!==$input.val()&&tp_inst._updateDateTime(t),$.isFunction(tp_inst._defaults.evnts.onClose)&&tp_inst._defaults.evnts.onClose.call($input[0],e,t,tp_inst)}};for(i in overrides)overrides.hasOwnProperty(i)&&(fns[i]=opts[i]||null);tp_inst._defaults=$.extend({},this._defaults,inlineSettings,opts,overrides,{evnts:fns,timepicker:tp_inst}),tp_inst.amNames=$.map(tp_inst._defaults.amNames,function(e){return e.toUpperCase()}),tp_inst.pmNames=$.map(tp_inst._defaults.pmNames,function(e){return e.toUpperCase()}),tp_inst.support=detectSupport(tp_inst._defaults.timeFormat+(tp_inst._defaults.pickerTimeFormat?tp_inst._defaults.pickerTimeFormat:"")+(tp_inst._defaults.altTimeFormat?tp_inst._defaults.altTimeFormat:"")),"string"==typeof tp_inst._defaults.controlType?("slider"===tp_inst._defaults.controlType&&$.ui.slider===void 0&&(tp_inst._defaults.controlType="select"),tp_inst.control=tp_inst._controls[tp_inst._defaults.controlType]):tp_inst.control=tp_inst._defaults.controlType;var timezoneList=[-720,-660,-600,-570,-540,-480,-420,-360,-300,-270,-240,-210,-180,-120,-60,0,60,120,180,210,240,270,300,330,345,360,390,420,480,525,540,570,600,630,660,690,720,765,780,840];null!==tp_inst._defaults.timezoneList&&(timezoneList=tp_inst._defaults.timezoneList);var tzl=timezoneList.length,tzi=0,tzv=null;if(tzl>0&&"object"!=typeof timezoneList[0])for(;tzl>tzi;tzi++)tzv=timezoneList[tzi],timezoneList[tzi]={value:tzv,label:$.timepicker.timezoneOffsetString(tzv,tp_inst.support.iso8601)};return tp_inst._defaults.timezoneList=timezoneList,tp_inst.timezone=null!==tp_inst._defaults.timezone?$.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone):-1*(new Date).getTimezoneOffset(),tp_inst.hour=tp_inst._defaults.hour<tp_inst._defaults.hourMin?tp_inst._defaults.hourMin:tp_inst._defaults.hour>tp_inst._defaults.hourMax?tp_inst._defaults.hourMax:tp_inst._defaults.hour,tp_inst.minute=tp_inst._defaults.minute<tp_inst._defaults.minuteMin?tp_inst._defaults.minuteMin:tp_inst._defaults.minute>tp_inst._defaults.minuteMax?tp_inst._defaults.minuteMax:tp_inst._defaults.minute,tp_inst.second=tp_inst._defaults.second<tp_inst._defaults.secondMin?tp_inst._defaults.secondMin:tp_inst._defaults.second>tp_inst._defaults.secondMax?tp_inst._defaults.secondMax:tp_inst._defaults.second,tp_inst.millisec=tp_inst._defaults.millisec<tp_inst._defaults.millisecMin?tp_inst._defaults.millisecMin:tp_inst._defaults.millisec>tp_inst._defaults.millisecMax?tp_inst._defaults.millisecMax:tp_inst._defaults.millisec,tp_inst.microsec=tp_inst._defaults.microsec<tp_inst._defaults.microsecMin?tp_inst._defaults.microsecMin:tp_inst._defaults.microsec>tp_inst._defaults.microsecMax?tp_inst._defaults.microsecMax:tp_inst._defaults.microsec,tp_inst.ampm="",tp_inst.$input=$input,tp_inst._defaults.altField&&(tp_inst.$altInput=$(tp_inst._defaults.altField).css({cursor:"pointer"}).focus(function(){$input.trigger("focus")})),(0===tp_inst._defaults.minDate||0===tp_inst._defaults.minDateTime)&&(tp_inst._defaults.minDate=new Date),(0===tp_inst._defaults.maxDate||0===tp_inst._defaults.maxDateTime)&&(tp_inst._defaults.maxDate=new Date),void 0!==tp_inst._defaults.minDate&&tp_inst._defaults.minDate instanceof Date&&(tp_inst._defaults.minDateTime=new Date(tp_inst._defaults.minDate.getTime())),void 0!==tp_inst._defaults.minDateTime&&tp_inst._defaults.minDateTime instanceof Date&&(tp_inst._defaults.minDate=new Date(tp_inst._defaults.minDateTime.getTime())),void 0!==tp_inst._defaults.maxDate&&tp_inst._defaults.maxDate instanceof Date&&(tp_inst._defaults.maxDateTime=new Date(tp_inst._defaults.maxDate.getTime())),void 0!==tp_inst._defaults.maxDateTime&&tp_inst._defaults.maxDateTime instanceof Date&&(tp_inst._defaults.maxDate=new Date(tp_inst._defaults.maxDateTime.getTime())),tp_inst.$input.bind("focus",function(){tp_inst._onFocus()}),tp_inst},_addTimePicker:function(e){var t=this.$altInput&&this._defaults.altFieldTimeOnly?this.$input.val()+" "+this.$altInput.val():this.$input.val();this.timeDefined=this._parseTime(t),this._limitMinMaxDateTime(e,!1),this._injectTimePicker()},_parseTime:function(e,t){if(this.inst||(this.inst=$.datepicker._getInst(this.$input[0])),t||!this._defaults.timeOnly){var i=$.datepicker._get(this.inst,"dateFormat");try{var s=parseDateTimeInternal(i,this._defaults.timeFormat,e,$.datepicker._getFormatConfig(this.inst),this._defaults);if(!s.timeObj)return!1;$.extend(this,s.timeObj)}catch(a){return $.timepicker.log("Error parsing the date/time string: "+a+"\ndate/time string = "+e+"\ntimeFormat = "+this._defaults.timeFormat+"\ndateFormat = "+i),!1}return!0}var n=$.datepicker.parseTime(this._defaults.timeFormat,e,this._defaults);return n?($.extend(this,n),!0):!1},_injectTimePicker:function(){var e=this.inst.dpDiv,t=this.inst.settings,i=this,s="",a="",n=null,r={},l={},o=null,c=0,u=0;if(0===e.find("div.ui-timepicker-div").length&&t.showTimepicker){var m=' style="display:none;"',d='<div class="ui-timepicker-div'+(t.isRTL?" ui-timepicker-rtl":"")+'"><dl>'+'<dt class="ui_tpicker_time_label"'+(t.showTime?"":m)+">"+t.timeText+"</dt>"+'<dd class="ui_tpicker_time"'+(t.showTime?"":m)+"></dd>";for(c=0,u=this.units.length;u>c;c++){if(s=this.units[c],a=s.substr(0,1).toUpperCase()+s.substr(1),n=null!==t["show"+a]?t["show"+a]:this.support[s],r[s]=parseInt(t[s+"Max"]-(t[s+"Max"]-t[s+"Min"])%t["step"+a],10),l[s]=0,d+='<dt class="ui_tpicker_'+s+'_label"'+(n?"":m)+">"+t[s+"Text"]+"</dt>"+'<dd class="ui_tpicker_'+s+'"><div class="ui_tpicker_'+s+'_slider"'+(n?"":m)+"></div>",n&&t[s+"Grid"]>0){if(d+='<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>',"hour"===s)for(var p=t[s+"Min"];r[s]>=p;p+=parseInt(t[s+"Grid"],10)){l[s]++;var h=$.datepicker.formatTime(this.support.ampm?"hht":"HH",{hour:p},t);d+='<td data-for="'+s+'">'+h+"</td>"}else for(var _=t[s+"Min"];r[s]>=_;_+=parseInt(t[s+"Grid"],10))l[s]++,d+='<td data-for="'+s+'">'+(10>_?"0":"")+_+"</td>";d+="</tr></table></div>"}d+="</dd>"}var f=null!==t.showTimezone?t.showTimezone:this.support.timezone;d+='<dt class="ui_tpicker_timezone_label"'+(f?"":m)+">"+t.timezoneText+"</dt>",d+='<dd class="ui_tpicker_timezone" '+(f?"":m)+"></dd>",d+="</dl></div>";var g=$(d);for(t.timeOnly===!0&&(g.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all"><div class="ui-datepicker-title">'+t.timeOnlyTitle+"</div>"+"</div>"),e.find(".ui-datepicker-header, .ui-datepicker-calendar").hide()),c=0,u=i.units.length;u>c;c++)s=i.units[c],a=s.substr(0,1).toUpperCase()+s.substr(1),n=null!==t["show"+a]?t["show"+a]:this.support[s],i[s+"_slider"]=i.control.create(i,g.find(".ui_tpicker_"+s+"_slider"),s,i[s],t[s+"Min"],r[s],t["step"+a]),n&&t[s+"Grid"]>0&&(o=100*l[s]*t[s+"Grid"]/(r[s]-t[s+"Min"]),g.find(".ui_tpicker_"+s+" table").css({width:o+"%",marginLeft:t.isRTL?"0":o/(-2*l[s])+"%",marginRight:t.isRTL?o/(-2*l[s])+"%":"0",borderCollapse:"collapse"}).find("td").click(function(){var e=$(this),t=e.html(),a=parseInt(t.replace(/[^0-9]/g),10),n=t.replace(/[^apm]/gi),r=e.data("for");"hour"===r&&(-1!==n.indexOf("p")&&12>a?a+=12:-1!==n.indexOf("a")&&12===a&&(a=0)),i.control.value(i,i[r+"_slider"],s,a),i._onTimeChange(),i._onSelectHandler()}).css({cursor:"pointer",width:100/l[s]+"%",textAlign:"center",overflow:"hidden"}));if(this.timezone_select=g.find(".ui_tpicker_timezone").append("<select></select>").find("select"),$.fn.append.apply(this.timezone_select,$.map(t.timezoneList,function(e){return $("<option />").val("object"==typeof e?e.value:e).text("object"==typeof e?e.label:e)})),this.timezone!==void 0&&null!==this.timezone&&""!==this.timezone){var M=-1*new Date(this.inst.selectedYear,this.inst.selectedMonth,this.inst.selectedDay,12).getTimezoneOffset();M===this.timezone?selectLocalTimezone(i):this.timezone_select.val(this.timezone)}else this.hour!==void 0&&null!==this.hour&&""!==this.hour?this.timezone_select.val(t.timezone):selectLocalTimezone(i);this.timezone_select.change(function(){i._onTimeChange(),i._onSelectHandler()});var v=e.find(".ui-datepicker-buttonpane");if(v.length?v.before(g):e.append(g),this.$timeObj=g.find(".ui_tpicker_time"),null!==this.inst){var k=this.timeDefined;this._onTimeChange(),this.timeDefined=k}if(this._defaults.addSliderAccess){var T=this._defaults.sliderAccessArgs,D=this._defaults.isRTL;T.isRTL=D,setTimeout(function(){if(0===g.find(".ui-slider-access").length){g.find(".ui-slider:visible").sliderAccess(T);var e=g.find(".ui-slider-access:eq(0)").outerWidth(!0);e&&g.find("table:visible").each(function(){var t=$(this),i=t.outerWidth(),s=(""+t.css(D?"marginRight":"marginLeft")).replace("%",""),a=i-e,n=s*a/i+"%",r={width:a,marginRight:0,marginLeft:0};r[D?"marginRight":"marginLeft"]=n,t.css(r)})}},10)}i._limitMinMaxDateTime(this.inst,!0)}},_limitMinMaxDateTime:function(e,t){var i=this._defaults,s=new Date(e.selectedYear,e.selectedMonth,e.selectedDay);if(this._defaults.showTimepicker){if(null!==$.datepicker._get(e,"minDateTime")&&void 0!==$.datepicker._get(e,"minDateTime")&&s){var a=$.datepicker._get(e,"minDateTime"),n=new Date(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0,0);(null===this.hourMinOriginal||null===this.minuteMinOriginal||null===this.secondMinOriginal||null===this.millisecMinOriginal||null===this.microsecMinOriginal)&&(this.hourMinOriginal=i.hourMin,this.minuteMinOriginal=i.minuteMin,this.secondMinOriginal=i.secondMin,this.millisecMinOriginal=i.millisecMin,this.microsecMinOriginal=i.microsecMin),e.settings.timeOnly||n.getTime()===s.getTime()?(this._defaults.hourMin=a.getHours(),this.hour<=this._defaults.hourMin?(this.hour=this._defaults.hourMin,this._defaults.minuteMin=a.getMinutes(),this.minute<=this._defaults.minuteMin?(this.minute=this._defaults.minuteMin,this._defaults.secondMin=a.getSeconds(),this.second<=this._defaults.secondMin?(this.second=this._defaults.secondMin,this._defaults.millisecMin=a.getMilliseconds(),this.millisec<=this._defaults.millisecMin?(this.millisec=this._defaults.millisecMin,this._defaults.microsecMin=a.getMicroseconds()):(this.microsec<this._defaults.microsecMin&&(this.microsec=this._defaults.microsecMin),this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.hourMin=this.hourMinOriginal,this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)}if(null!==$.datepicker._get(e,"maxDateTime")&&void 0!==$.datepicker._get(e,"maxDateTime")&&s){var r=$.datepicker._get(e,"maxDateTime"),l=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0,0);(null===this.hourMaxOriginal||null===this.minuteMaxOriginal||null===this.secondMaxOriginal||null===this.millisecMaxOriginal)&&(this.hourMaxOriginal=i.hourMax,this.minuteMaxOriginal=i.minuteMax,this.secondMaxOriginal=i.secondMax,this.millisecMaxOriginal=i.millisecMax,this.microsecMaxOriginal=i.microsecMax),e.settings.timeOnly||l.getTime()===s.getTime()?(this._defaults.hourMax=r.getHours(),this.hour>=this._defaults.hourMax?(this.hour=this._defaults.hourMax,this._defaults.minuteMax=r.getMinutes(),this.minute>=this._defaults.minuteMax?(this.minute=this._defaults.minuteMax,this._defaults.secondMax=r.getSeconds(),this.second>=this._defaults.secondMax?(this.second=this._defaults.secondMax,this._defaults.millisecMax=r.getMilliseconds(),this.millisec>=this._defaults.millisecMax?(this.millisec=this._defaults.millisecMax,this._defaults.microsecMax=r.getMicroseconds()):(this.microsec>this._defaults.microsecMax&&(this.microsec=this._defaults.microsecMax),this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.hourMax=this.hourMaxOriginal,this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)}if(void 0!==t&&t===!0){var o=parseInt(this._defaults.hourMax-(this._defaults.hourMax-this._defaults.hourMin)%this._defaults.stepHour,10),c=parseInt(this._defaults.minuteMax-(this._defaults.minuteMax-this._defaults.minuteMin)%this._defaults.stepMinute,10),u=parseInt(this._defaults.secondMax-(this._defaults.secondMax-this._defaults.secondMin)%this._defaults.stepSecond,10),m=parseInt(this._defaults.millisecMax-(this._defaults.millisecMax-this._defaults.millisecMin)%this._defaults.stepMillisec,10),d=parseInt(this._defaults.microsecMax-(this._defaults.microsecMax-this._defaults.microsecMin)%this._defaults.stepMicrosec,10);this.hour_slider&&(this.control.options(this,this.hour_slider,"hour",{min:this._defaults.hourMin,max:o}),this.control.value(this,this.hour_slider,"hour",this.hour-this.hour%this._defaults.stepHour)),this.minute_slider&&(this.control.options(this,this.minute_slider,"minute",{min:this._defaults.minuteMin,max:c}),this.control.value(this,this.minute_slider,"minute",this.minute-this.minute%this._defaults.stepMinute)),this.second_slider&&(this.control.options(this,this.second_slider,"second",{min:this._defaults.secondMin,max:u}),this.control.value(this,this.second_slider,"second",this.second-this.second%this._defaults.stepSecond)),this.millisec_slider&&(this.control.options(this,this.millisec_slider,"millisec",{min:this._defaults.millisecMin,max:m}),this.control.value(this,this.millisec_slider,"millisec",this.millisec-this.millisec%this._defaults.stepMillisec)),this.microsec_slider&&(this.control.options(this,this.microsec_slider,"microsec",{min:this._defaults.microsecMin,max:d}),this.control.value(this,this.microsec_slider,"microsec",this.microsec-this.microsec%this._defaults.stepMicrosec))}}},_onTimeChange:function(){if(this._defaults.showTimepicker){var e=this.hour_slider?this.control.value(this,this.hour_slider,"hour"):!1,t=this.minute_slider?this.control.value(this,this.minute_slider,"minute"):!1,i=this.second_slider?this.control.value(this,this.second_slider,"second"):!1,s=this.millisec_slider?this.control.value(this,this.millisec_slider,"millisec"):!1,a=this.microsec_slider?this.control.value(this,this.microsec_slider,"microsec"):!1,n=this.timezone_select?this.timezone_select.val():!1,r=this._defaults,l=r.pickerTimeFormat||r.timeFormat,o=r.pickerTimeSuffix||r.timeSuffix;"object"==typeof e&&(e=!1),"object"==typeof t&&(t=!1),"object"==typeof i&&(i=!1),"object"==typeof s&&(s=!1),"object"==typeof a&&(a=!1),"object"==typeof n&&(n=!1),e!==!1&&(e=parseInt(e,10)),t!==!1&&(t=parseInt(t,10)),i!==!1&&(i=parseInt(i,10)),s!==!1&&(s=parseInt(s,10)),a!==!1&&(a=parseInt(a,10));var c=r[12>e?"amNames":"pmNames"][0],u=e!==this.hour||t!==this.minute||i!==this.second||s!==this.millisec||a!==this.microsec||this.ampm.length>0&&12>e!=(-1!==$.inArray(this.ampm.toUpperCase(),this.amNames))||null!==this.timezone&&n!==this.timezone;u&&(e!==!1&&(this.hour=e),t!==!1&&(this.minute=t),i!==!1&&(this.second=i),s!==!1&&(this.millisec=s),a!==!1&&(this.microsec=a),n!==!1&&(this.timezone=n),this.inst||(this.inst=$.datepicker._getInst(this.$input[0])),this._limitMinMaxDateTime(this.inst,!0)),this.support.ampm&&(this.ampm=c),this.formattedTime=$.datepicker.formatTime(r.timeFormat,this,r),this.$timeObj&&(l===r.timeFormat?this.$timeObj.text(this.formattedTime+o):this.$timeObj.text($.datepicker.formatTime(l,this,r)+o)),this.timeDefined=!0,u&&this._updateDateTime()}},_onSelectHandler:function(){var e=this._defaults.onSelect||this.inst.settings.onSelect,t=this.$input?this.$input[0]:null;e&&t&&e.apply(t,[this.formattedDateTime,this])},_updateDateTime:function(e){e=this.inst||e;var t=e.currentYear>0?new Date(e.currentYear,e.currentMonth,e.currentDay):new Date(e.selectedYear,e.selectedMonth,e.selectedDay),i=$.datepicker._daylightSavingAdjust(t),s=$.datepicker._get(e,"dateFormat"),a=$.datepicker._getFormatConfig(e),n=null!==i&&this.timeDefined;this.formattedDate=$.datepicker.formatDate(s,null===i?new Date:i,a);var r=this.formattedDate;if(""===e.lastVa&&(e.currentYear=e.selectedYear,e.currentMonth=e.selectedMonth,e.currentDay=e.selectedDay),this._defaults.timeOnly===!0?r=this.formattedTime:this._defaults.timeOnly!==!0&&(this._defaults.alwaysSetTime||n)&&(r+=this._defaults.separator+this.formattedTime+this._defaults.timeSuffix),this.formattedDateTime=r,this._defaults.showTimepicker)if(this.$altInput&&this._defaults.timeOnly===!1&&this._defaults.altFieldTimeOnly===!0)this.$altInput.val(this.formattedTime),this.$input.val(this.formattedDate);else if(this.$altInput){this.$input.val(r);var l="",o=this._defaults.altSeparator?this._defaults.altSeparator:this._defaults.separator,c=this._defaults.altTimeSuffix?this._defaults.altTimeSuffix:this._defaults.timeSuffix;this._defaults.timeOnly||(l=this._defaults.altFormat?$.datepicker.formatDate(this._defaults.altFormat,null===i?new Date:i,a):this.formattedDate,l&&(l+=o)),l+=this._defaults.altTimeFormat?$.datepicker.formatTime(this._defaults.altTimeFormat,this,this._defaults)+c:this.formattedTime+c,this.$altInput.val(l)}else this.$input.val(r);else this.$input.val(this.formattedDate);this.$input.trigger("change")},_onFocus:function(){if(!this.$input.val()&&this._defaults.defaultValue){this.$input.val(this._defaults.defaultValue);var e=$.datepicker._getInst(this.$input.get(0)),t=$.datepicker._get(e,"timepicker");if(t&&t._defaults.timeOnly&&e.input.val()!==e.lastVal)try{$.datepicker._updateDatepicker(e)}catch(i){$.timepicker.log(i)}}},_controls:{slider:{create:function(e,t,i,s,a,n,r){var l=e._defaults.isRTL;return t.prop("slide",null).slider({orientation:"horizontal",value:l?-1*s:s,min:l?-1*n:a,max:l?-1*a:n,step:r,slide:function(t,s){e.control.value(e,$(this),i,l?-1*s.value:s.value),e._onTimeChange()},stop:function(){e._onSelectHandler()}})},options:function(e,t,i,s,a){if(e._defaults.isRTL){if("string"==typeof s)return"min"===s||"max"===s?void 0!==a?t.slider(s,-1*a):Math.abs(t.slider(s)):t.slider(s);var n=s.min,r=s.max;return s.min=s.max=null,void 0!==n&&(s.max=-1*n),void 0!==r&&(s.min=-1*r),t.slider(s)}return"string"==typeof s&&void 0!==a?t.slider(s,a):t.slider(s)},value:function(e,t,i,s){return e._defaults.isRTL?void 0!==s?t.slider("value",-1*s):Math.abs(t.slider("value")):void 0!==s?t.slider("value",s):t.slider("value")}},select:{create:function(e,t,i,s,a,n,r){for(var l='<select class="ui-timepicker-select" data-unit="'+i+'" data-min="'+a+'" data-max="'+n+'" data-step="'+r+'">',o=e._defaults.pickerTimeFormat||e._defaults.timeFormat,c=a;n>=c;c+=r)l+='<option value="'+c+'"'+(c===s?" selected":"")+">",l+="hour"===i?$.datepicker.formatTime($.trim(o.replace(/[^ht ]/gi,"")),{hour:c},e._defaults):"millisec"===i||"microsec"===i||c>=10?c:"0"+(""+c),l+="</option>";return l+="</select>",t.children("select").remove(),$(l).appendTo(t).change(function(){e._onTimeChange(),e._onSelectHandler()}),t},options:function(e,t,i,s,a){var n={},r=t.children("select");if("string"==typeof s){if(void 0===a)return r.data(s);n[s]=a}else n=s;return e.control.create(e,t,r.data("unit"),r.val(),n.min||r.data("min"),n.max||r.data("max"),n.step||r.data("step"))},value:function(e,t,i,s){var a=t.children("select");return void 0!==s?a.val(s):a.val()}}}}),$.fn.extend({timepicker:function(e){e=e||{};var t=Array.prototype.slice.call(arguments);return"object"==typeof e&&(t[0]=$.extend(e,{timeOnly:!0})),$(this).each(function(){$.fn.datetimepicker.apply($(this),t)})},datetimepicker:function(e){e=e||{};var t=arguments;return"string"==typeof e?"getDate"===e?$.fn.datepicker.apply($(this[0]),t):this.each(function(){var e=$(this);e.datepicker.apply(e,t)}):this.each(function(){var t=$(this);t.datepicker($.timepicker._newInst(t,e)._defaults)})}}),$.datepicker.parseDateTime=function(e,t,i,s,a){var n=parseDateTimeInternal(e,t,i,s,a);if(n.timeObj){var r=n.timeObj;n.date.setHours(r.hour,r.minute,r.second,r.millisec),n.date.setMicroseconds(r.microsec)}return n.date},$.datepicker.parseTime=function(e,t,i){var s=extendRemove(extendRemove({},$.timepicker._defaults),i||{});-1!==e.replace(/\'.*?\'/g,"").indexOf("Z");var a=function(e,t,i){var s,a=function(e,t){var i=[];return e&&$.merge(i,e),t&&$.merge(i,t),i=$.map(i,function(e){return e.replace(/[.*+?|()\[\]{}\\]/g,"\\$&")}),"("+i.join("|")+")?"},n=function(e){var t=e.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),i={h:-1,m:-1,s:-1,l:-1,c:-1,t:-1,z:-1};if(t)for(var s=0;t.length>s;s++)-1===i[(""+t[s]).charAt(0)]&&(i[(""+t[s]).charAt(0)]=s+1);return i},r="^"+(""+e).replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g,function(e){var t=e.length;switch(e.charAt(0).toLowerCase()){case"h":return 1===t?"(\\d?\\d)":"(\\d{"+t+"})";case"m":return 1===t?"(\\d?\\d)":"(\\d{"+t+"})";case"s":return 1===t?"(\\d?\\d)":"(\\d{"+t+"})";case"l":return"(\\d?\\d?\\d)";case"c":return"(\\d?\\d?\\d)";case"z":return"(z|[-+]\\d\\d:?\\d\\d|\\S+)?";case"t":return a(i.amNames,i.pmNames);default:return"("+e.replace(/\'/g,"").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g,function(e){return"\\"+e})+")?"}}).replace(/\s/g,"\\s?")+i.timeSuffix+"$",l=n(e),o="";s=t.match(RegExp(r,"i"));var c={hour:0,minute:0,second:0,millisec:0,microsec:0};return s?(-1!==l.t&&(void 0===s[l.t]||0===s[l.t].length?(o="",c.ampm=""):(o=-1!==$.inArray(s[l.t].toUpperCase(),i.amNames)?"AM":"PM",c.ampm=i["AM"===o?"amNames":"pmNames"][0])),-1!==l.h&&(c.hour="AM"===o&&"12"===s[l.h]?0:"PM"===o&&"12"!==s[l.h]?parseInt(s[l.h],10)+12:Number(s[l.h])),-1!==l.m&&(c.minute=Number(s[l.m])),-1!==l.s&&(c.second=Number(s[l.s])),-1!==l.l&&(c.millisec=Number(s[l.l])),-1!==l.c&&(c.microsec=Number(s[l.c])),-1!==l.z&&void 0!==s[l.z]&&(c.timezone=$.timepicker.timezoneOffsetNumber(s[l.z])),c):!1},n=function(e,t,i){try{var s=new Date("2012-01-01 "+t);if(isNaN(s.getTime())&&(s=new Date("2012-01-01T"+t),isNaN(s.getTime())&&(s=new Date("01/01/2012 "+t),isNaN(s.getTime()))))throw"Unable to parse time with native Date: "+t;return{hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),millisec:s.getMilliseconds(),microsec:s.getMicroseconds(),timezone:-1*s.getTimezoneOffset()}}catch(n){try{return a(e,t,i)}catch(r){$.timepicker.log("Unable to parse \ntimeString: "+t+"\ntimeFormat: "+e)}}return!1};return"function"==typeof s.parse?s.parse(e,t,s):"loose"===s.parse?n(e,t,s):a(e,t,s)},$.datepicker.formatTime=function(e,t,i){i=i||{},i=$.extend({},$.timepicker._defaults,i),t=$.extend({hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null},t);var s=e,a=i.amNames[0],n=parseInt(t.hour,10);return n>11&&(a=i.pmNames[0]),s=s.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g,function(e){switch(e){case"HH":return("0"+n).slice(-2);case"H":return n;case"hh":return("0"+convert24to12(n)).slice(-2);case"h":return convert24to12(n);case"mm":return("0"+t.minute).slice(-2);case"m":return t.minute;case"ss":return("0"+t.second).slice(-2);case"s":return t.second;case"l":return("00"+t.millisec).slice(-3);case"c":return("00"+t.microsec).slice(-3);case"z":return $.timepicker.timezoneOffsetString(null===t.timezone?i.timezone:t.timezone,!1);case"Z":return $.timepicker.timezoneOffsetString(null===t.timezone?i.timezone:t.timezone,!0);case"T":return a.charAt(0).toUpperCase();case"TT":return a.toUpperCase();case"t":return a.charAt(0).toLowerCase();case"tt":return a.toLowerCase();default:return e.replace(/'/g,"")}})},$.datepicker._base_selectDate=$.datepicker._selectDate,$.datepicker._selectDate=function(e,t){var i=this._getInst($(e)[0]),s=this._get(i,"timepicker");s?(s._limitMinMaxDateTime(i,!0),i.inline=i.stay_open=!0,this._base_selectDate(e,t),i.inline=i.stay_open=!1,this._notifyChange(i),this._updateDatepicker(i)):this._base_selectDate(e,t)},$.datepicker._base_updateDatepicker=$.datepicker._updateDatepicker,$.datepicker._updateDatepicker=function(e){var t=e.input[0];if(!($.datepicker._curInst&&$.datepicker._curInst!==e&&$.datepicker._datepickerShowing&&$.datepicker._lastInput!==t||"boolean"==typeof e.stay_open&&e.stay_open!==!1)){this._base_updateDatepicker(e);var i=this._get(e,"timepicker");i&&i._addTimePicker(e)}},$.datepicker._base_doKeyPress=$.datepicker._doKeyPress,$.datepicker._doKeyPress=function(e){var t=$.datepicker._getInst(e.target),i=$.datepicker._get(t,"timepicker");if(i&&$.datepicker._get(t,"constrainInput")){var s=i.support.ampm,a=null!==i._defaults.showTimezone?i._defaults.showTimezone:i.support.timezone,n=$.datepicker._possibleChars($.datepicker._get(t,"dateFormat")),r=(""+i._defaults.timeFormat).replace(/[hms]/g,"").replace(/TT/g,s?"APM":"").replace(/Tt/g,s?"AaPpMm":"").replace(/tT/g,s?"AaPpMm":"").replace(/T/g,s?"AP":"").replace(/tt/g,s?"apm":"").replace(/t/g,s?"ap":"")+" "+i._defaults.separator+i._defaults.timeSuffix+(a?i._defaults.timezoneList.join(""):"")+i._defaults.amNames.join("")+i._defaults.pmNames.join("")+n,l=String.fromCharCode(void 0===e.charCode?e.keyCode:e.charCode);return e.ctrlKey||" ">l||!n||r.indexOf(l)>-1}return $.datepicker._base_doKeyPress(e)},$.datepicker._base_updateAlternate=$.datepicker._updateAlternate,$.datepicker._updateAlternate=function(e){var t=this._get(e,"timepicker");if(t){var i=t._defaults.altField;if(i){var s=(t._defaults.altFormat||t._defaults.dateFormat,this._getDate(e)),a=$.datepicker._getFormatConfig(e),n="",r=t._defaults.altSeparator?t._defaults.altSeparator:t._defaults.separator,l=t._defaults.altTimeSuffix?t._defaults.altTimeSuffix:t._defaults.timeSuffix,o=null!==t._defaults.altTimeFormat?t._defaults.altTimeFormat:t._defaults.timeFormat;n+=$.datepicker.formatTime(o,t,t._defaults)+l,t._defaults.timeOnly||t._defaults.altFieldTimeOnly||null===s||(n=t._defaults.altFormat?$.datepicker.formatDate(t._defaults.altFormat,s,a)+r+n:t.formattedDate+r+n),$(i).val(n)}}else $.datepicker._base_updateAlternate(e)},$.datepicker._base_doKeyUp=$.datepicker._doKeyUp,$.datepicker._doKeyUp=function(e){var t=$.datepicker._getInst(e.target),i=$.datepicker._get(t,"timepicker");if(i&&i._defaults.timeOnly&&t.input.val()!==t.lastVal)try{$.datepicker._updateDatepicker(t)}catch(s){$.timepicker.log(s)}return $.datepicker._base_doKeyUp(e)},$.datepicker._base_gotoToday=$.datepicker._gotoToday,$.datepicker._gotoToday=function(e){var t=this._getInst($(e)[0]),i=t.dpDiv;this._base_gotoToday(e);var s=this._get(t,"timepicker");selectLocalTimezone(s);var a=new Date;this._setTime(t,a),$(".ui-datepicker-today",i).click()},$.datepicker._disableTimepickerDatepicker=function(e){var t=this._getInst(e);if(t){var i=this._get(t,"timepicker");$(e).datepicker("getDate"),i&&(t.settings.showTimepicker=!1,i._defaults.showTimepicker=!1,i._updateDateTime(t))}},$.datepicker._enableTimepickerDatepicker=function(e){var t=this._getInst(e);if(t){var i=this._get(t,"timepicker");$(e).datepicker("getDate"),i&&(t.settings.showTimepicker=!0,i._defaults.showTimepicker=!0,i._addTimePicker(t),i._updateDateTime(t))}},$.datepicker._setTime=function(e,t){var i=this._get(e,"timepicker");if(i){var s=i._defaults;i.hour=t?t.getHours():s.hour,i.minute=t?t.getMinutes():s.minute,i.second=t?t.getSeconds():s.second,i.millisec=t?t.getMilliseconds():s.millisec,i.microsec=t?t.getMicroseconds():s.microsec,i._limitMinMaxDateTime(e,!0),i._onTimeChange(),i._updateDateTime(e)}},$.datepicker._setTimeDatepicker=function(e,t,i){var s=this._getInst(e);if(s){var a=this._get(s,"timepicker");if(a){this._setDateFromField(s);var n;t&&("string"==typeof t?(a._parseTime(t,i),n=new Date,n.setHours(a.hour,a.minute,a.second,a.millisec),n.setMicroseconds(a.microsec)):(n=new Date(t.getTime()),n.setMicroseconds(t.getMicroseconds())),"Invalid Date"==""+n&&(n=void 0),this._setTime(s,n))}}},$.datepicker._base_setDateDatepicker=$.datepicker._setDateDatepicker,$.datepicker._setDateDatepicker=function(e,t){var i=this._getInst(e);if(i){"string"==typeof t&&(t=new Date(t),t.getTime()||$.timepicker.log("Error creating Date object from string."));var s,a=this._get(i,"timepicker");t instanceof Date?(s=new Date(t.getTime()),s.setMicroseconds(t.getMicroseconds())):s=t,a&&(a.support.timezone||null!==a._defaults.timezone||(a.timezone=-1*s.getTimezoneOffset()),t=$.timepicker.timezoneAdjust(t,a.timezone),s=$.timepicker.timezoneAdjust(s,a.timezone)),this._updateDatepicker(i),this._base_setDateDatepicker.apply(this,arguments),this._setTimeDatepicker(e,s,!0)}},$.datepicker._base_getDateDatepicker=$.datepicker._getDateDatepicker,$.datepicker._getDateDatepicker=function(e,t){var i=this._getInst(e);if(i){var s=this._get(i,"timepicker");if(s){void 0===i.lastVal&&this._setDateFromField(i,t);var a=this._getDate(i);return a&&s._parseTime($(e).val(),s.timeOnly)&&(a.setHours(s.hour,s.minute,s.second,s.millisec),a.setMicroseconds(s.microsec),null!=s.timezone&&(s.support.timezone||null!==s._defaults.timezone||(s.timezone=-1*a.getTimezoneOffset()),a=$.timepicker.timezoneAdjust(a,s.timezone))),a
+}return this._base_getDateDatepicker(e,t)}},$.datepicker._base_parseDate=$.datepicker.parseDate,$.datepicker.parseDate=function(e,t,i){var s;try{s=this._base_parseDate(e,t,i)}catch(a){if(!(a.indexOf(":")>=0))throw a;s=this._base_parseDate(e,t.substring(0,t.length-(a.length-a.indexOf(":")-2)),i),$.timepicker.log("Error parsing the date string: "+a+"\ndate string = "+t+"\ndate format = "+e)}return s},$.datepicker._base_formatDate=$.datepicker._formatDate,$.datepicker._formatDate=function(e){var t=this._get(e,"timepicker");return t?(t._updateDateTime(e),t.$input.val()):this._base_formatDate(e)},$.datepicker._base_optionDatepicker=$.datepicker._optionDatepicker,$.datepicker._optionDatepicker=function(e,t,i){var s,a=this._getInst(e);if(!a)return null;var n=this._get(a,"timepicker");if(n){var r,l=null,o=null,c=null,u=n._defaults.evnts,m={};if("string"==typeof t){if("minDate"===t||"minDateTime"===t)l=i;else if("maxDate"===t||"maxDateTime"===t)o=i;else if("onSelect"===t)c=i;else if(u.hasOwnProperty(t)){if(i===void 0)return u[t];m[t]=i,s={}}}else if("object"==typeof t){t.minDate?l=t.minDate:t.minDateTime?l=t.minDateTime:t.maxDate?o=t.maxDate:t.maxDateTime&&(o=t.maxDateTime);for(r in u)u.hasOwnProperty(r)&&t[r]&&(m[r]=t[r])}for(r in m)m.hasOwnProperty(r)&&(u[r]=m[r],s||(s=$.extend({},t)),delete s[r]);if(s&&isEmptyObject(s))return;l?(l=0===l?new Date:new Date(l),n._defaults.minDate=l,n._defaults.minDateTime=l):o?(o=0===o?new Date:new Date(o),n._defaults.maxDate=o,n._defaults.maxDateTime=o):c&&(n._defaults.onSelect=c)}return void 0===i?this._base_optionDatepicker.call($.datepicker,e,t):this._base_optionDatepicker.call($.datepicker,e,s||t,i)};var isEmptyObject=function(e){var t;for(t in e)if(e.hasOwnProperty(t))return!1;return!0},extendRemove=function(e,t){$.extend(e,t);for(var i in t)(null===t[i]||void 0===t[i])&&(e[i]=t[i]);return e},detectSupport=function(e){var t=e.replace(/'.*?'/g,"").toLowerCase(),i=function(e,t){return-1!==e.indexOf(t)?!0:!1};return{hour:i(t,"h"),minute:i(t,"m"),second:i(t,"s"),millisec:i(t,"l"),microsec:i(t,"c"),timezone:i(t,"z"),ampm:i(t,"t")&&i(e,"h"),iso8601:i(e,"Z")}},convert24to12=function(e){return e%=12,0===e&&(e=12),e+""},computeEffectiveSetting=function(e,t){return e&&e[t]?e[t]:$.timepicker._defaults[t]},splitDateTime=function(e,t){var i=computeEffectiveSetting(t,"separator"),s=computeEffectiveSetting(t,"timeFormat"),a=s.split(i),n=a.length,r=e.split(i),l=r.length;return l>1?{dateString:r.splice(0,l-n).join(i),timeString:r.splice(0,n).join(i)}:{dateString:e,timeString:""}},parseDateTimeInternal=function(e,t,i,s,a){var n,r,l;if(r=splitDateTime(i,a),n=$.datepicker._base_parseDate(e,r.dateString,s),""===r.timeString)return{date:n};if(l=$.datepicker.parseTime(t,r.timeString,a),!l)throw"Wrong time format";return{date:n,timeObj:l}},selectLocalTimezone=function(e,t){if(e&&e.timezone_select){var i=t||new Date;e.timezone_select.val(-i.getTimezoneOffset())}};$.timepicker=new Timepicker,$.timepicker.timezoneOffsetString=function(e,t){if(isNaN(e)||e>840||-720>e)return e;var i=e,s=i%60,a=(i-s)/60,n=t?":":"",r=(i>=0?"+":"-")+("0"+Math.abs(a)).slice(-2)+n+("0"+Math.abs(s)).slice(-2);return"+00:00"===r?"Z":r},$.timepicker.timezoneOffsetNumber=function(e){var t=(""+e).replace(":","");return"Z"===t.toUpperCase()?0:/^(\-|\+)\d{4}$/.test(t)?("-"===t.substr(0,1)?-1:1)*(60*parseInt(t.substr(1,2),10)+parseInt(t.substr(3,2),10)):e},$.timepicker.timezoneAdjust=function(e,t){var i=$.timepicker.timezoneOffsetNumber(t);return isNaN(i)||e.setMinutes(e.getMinutes()+-e.getTimezoneOffset()-i),e},$.timepicker.timeRange=function(e,t,i){return $.timepicker.handleRange("timepicker",e,t,i)},$.timepicker.datetimeRange=function(e,t,i){$.timepicker.handleRange("datetimepicker",e,t,i)},$.timepicker.dateRange=function(e,t,i){$.timepicker.handleRange("datepicker",e,t,i)},$.timepicker.handleRange=function(e,t,i,s){function a(a,n){var r=t[e]("getDate"),l=i[e]("getDate"),o=a[e]("getDate");if(null!==r){var c=new Date(r.getTime()),u=new Date(r.getTime());c.setMilliseconds(c.getMilliseconds()+s.minInterval),u.setMilliseconds(u.getMilliseconds()+s.maxInterval),s.minInterval>0&&c>l?i[e]("setDate",c):s.maxInterval>0&&l>u?i[e]("setDate",u):r>l&&n[e]("setDate",o)}}function n(t,i,a){if(t.val()){var n=t[e].call(t,"getDate");null!==n&&s.minInterval>0&&("minDate"===a&&n.setMilliseconds(n.getMilliseconds()+s.minInterval),"maxDate"===a&&n.setMilliseconds(n.getMilliseconds()-s.minInterval)),n.getTime&&i[e].call(i,"option",a,n)}}return s=$.extend({},{minInterval:0,maxInterval:0,start:{},end:{}},s),$.fn[e].call(t,$.extend({onClose:function(){a($(this),i)},onSelect:function(){n($(this),i,"minDate")}},s,s.start)),$.fn[e].call(i,$.extend({onClose:function(){a($(this),t)},onSelect:function(){n($(this),t,"maxDate")}},s,s.end)),a(t,i),n(t,i,"minDate"),n(i,t,"maxDate"),$([t.get(0),i.get(0)])},$.timepicker.log=function(e){window.console&&window.console.log(e)},$.timepicker._util={_extendRemove:extendRemove,_isEmptyObject:isEmptyObject,_convert24to12:convert24to12,_detectSupport:detectSupport,_selectLocalTimezone:selectLocalTimezone,_computeEffectiveSetting:computeEffectiveSetting,_splitDateTime:splitDateTime,_parseDateTimeInternal:parseDateTimeInternal},Date.prototype.getMicroseconds||(Date.prototype.microseconds=0,Date.prototype.getMicroseconds=function(){return this.microseconds},Date.prototype.setMicroseconds=function(e){return this.setMilliseconds(this.getMilliseconds()+Math.floor(e/1e3)),this.microseconds=e%1e3,this}),$.timepicker.version="1.4"}})(jQuery); \ No newline at end of file
diff --git a/index.html b/index.html
deleted file mode 100644
index d0569b8..0000000
--- a/index.html
+++ /dev/null
@@ -1,975 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>Adding a Timepicker to jQuery UI Datepicker</title>
- <meta name="Description" content="jQuery Timepicker Addon. Add a timepicker to your jQuery UI Datepicker. With options to show only time, format time, and much more." />
- <meta name="Keywords" content="jQuery, UI, datepicker, timepicker, datetime, time, format" />
-
- <style type="text/css">
- body,img,p,h1,h2,h3,h4,h5,h6,form,table,td,ul,ol,li,dl,dt,dd,pre,blockquote,fieldset,label{
- margin:0;
- padding:0;
- border:0;
- }
- body{ background-color: #777; border-top: solid 10px #7b94b2; font: 90% Arial, Helvetica, sans-serif; padding: 20px; }
- h1,h2,h3{ margin: 10px 0; }
- h1{}
- h2{ color: #f66; }
- h3{ color: #6b84a2; }
- p{ margin: 10px 0; }
- a{ color: #7b94b2; }
- ul,ol{ margin: 10px 0 10px 40px; }
- li{ margin: 4px 0; }
- dl.defs{ margin: 10px 0 10px 40px; }
- dl.defs dt{ font-weight: bold; line-height: 20px; margin: 10px 0 0 0; }
- dl.defs dd{ margin: -20px 0 10px 160px; padding-bottom: 10px; border-bottom: solid 1px #eee;}
- pre{ font-size: 12px; line-height: 16px; padding: 5px 5px 5px 10px; margin: 10px 0; background-color: #e4f4d4; border-left: solid 5px #9EC45F; overflow: auto; }
-
- .wrapper{ background-color: #ffffff; width: 800px; border: solid 1px #eeeeee; padding: 20px; margin: 0 auto; }
- #tabs{ margin: 20px -20px; border: none; }
- #tabs, #ui-datepicker-div, .ui-datepicker{ font-size: 85%; }
- .clear{ clear: both; }
-
- .example-container{ background-color: #f4f4f4; border-bottom: solid 2px #777777; margin: 0 0 20px 40px; padding: 20px; }
- .example-container input{ border: solid 1px #aaa; padding: 4px; width: 175px; }
- .ebook{}
- .ebook img.ebookimg{ float: left; margin: 0 15px 15px 0; width: 100px; }
- .ebook .buyp a iframe{ margin-bottom: -5px; }
- </style>
-
- <link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
- <link rel="stylesheet" media="all" type="text/css" href="jquery-ui-timepicker-addon.css" />
-
- </head>
- <body>
- <div class="wrapper">
- <h1>Adding a Timepicker to jQuery UI Datepicker</h1>
-
- <p>The timepicker addon adds a timepicker to jQuery UI Datepicker, thus the datepicker and slider components (jQueryUI) are required for using any of these. In addition all datepicker options are still available through the timepicker addon.</p>
-
- <p>If you are interested in contributing to Timepicker Addon please <a href="http://github.com/trentrichardson/jQuery-Timepicker-Addon" title="Check out Timepicker on GitHub">check it out on GitHub</a>. If you do make additions please keep in mind I enjoy tabs over spaces,.. But contributions are welcome in any form.</p>
-
- <p><a href="http://trentrichardson.com" title="Back to Blog">Back to Blog</a> or <a href="http://twitter.com/practicalweb" title="Follow Me on Twitter">Follow on Twitter</a></p>
-
- <a href="http://carbounce.com" title="Car Bounce" style="float: right;display: inline-block;width:380px;padding: 10px;background-color: #fbfbfb;border: dotted 4px #e8e8e8;color: #9EC45F;font-size: 16px;text-decoration:none;letter-spacing:1px;"><img src="http://carbounce.com/img/logo_small.png" alt="Car Bounce" align="left" style="margin-right: 20px;"/>Try my new app to keep you informed of your car's financing status and value.</a>
-
- <h2>Donation</h2>
- <p>Has this Timepicker Addon been helpful to you?</p>
- <div class="donation">
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
- <input type="hidden" name="cmd" value="_s-xclick">
- <input type="hidden" name="hosted_button_id" value="C2QQHR7JQGD28">
- <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
- <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
- </form>
- </div>
-
- <div id="tabs">
- <ul>
- <li><a href="#tp-getting-started" title="Getting Started">Getting Started</a></li>
- <li><a href="#tp-options" title="Options">Options</a></li>
- <li><a href="#tp-formatting" title="Examples">Formatting</a></li>
- <li><a href="#tp-localization" title="Examples">Localization</a></li>
- <li><a href="#tp-examples" title="Examples">Examples</a></li>
- </ul>
-
- <!-- ############################################################################# -->
- <!-- Getting Started
- <!-- ############################################################################# -->
- <div id="tp-getting-started">
- <h2>Getting Started</h2>
-
- <h3>Highly Recommended</h3>
-
- <h4>Handling Time eBook</h4>
- <div class="ebook">
- <p>Check out the <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook">Handling Time eBook</a> to learn from the basic setup to advanced i18n usage, and from client's javascript to the server's database.</p>
- <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook"><img src="http://trentrichardson.com/wp-content/uploads/2013/04/time-book-titlepage.jpg" alt="Handling Time eBook" style="float:left;width:100px;margin:0 15px 15px 0;" /></a>
- <p class="buyp"><a href="https://sellfy.com/p/8gxZ" id="8gxZ" class="sellfy-buy-button">buy</a> eBook + Example code</p>
- <p class="buyp"><a href="https://sellfy.com/p/LvAG" id="LvAG" class="sellfy-buy-button">buy</a> eBook</p>
- <p class="buyp"><a href="http://gum.co/ZWYO" class="gumroad-button">Handling Time</a></p>
- <div class="clear"></div>
- </div>
-
- <h4>Subscribe to Blog and Twitter</h4>
- <p><a href="http://trentrichardson.com" title="Subscribe to TrentRichardson.com via email">Subscribe to my blog via email</a> and follow <a href="http://twitter.com/practicalweb" title="Follow Me on Twitter">@PracticalWeb</a> on Twitter. I post for nearly every new version, so you know about updates.</p>
- <div class="clear"></div>
- <br />
-
- <h3>Download</h3>
- <p><a href="jquery-ui-timepicker-addon.js" title="Download Timepicker Addon">Download Timepicker Addon</a></p>
- <p><a href="http://github.com/trentrichardson/jQuery-Timepicker-Addon" title="Check out Timepicker on GitHub">Download/Contribute on GitHub</a> (Need the entire repo? Find a bug? See if its fixed here)</p>
- <p>There is a small bit of required CSS (<a href="jquery-ui-timepicker-addon.css" title="Download CSS">Download</a>):</p>
-<pre>/* css for timepicker */
-.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
-.ui-timepicker-div dl { text-align: left; }
-.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
-.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
-.ui-timepicker-div td { font-size: 90%; }
-.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
-
-.ui-timepicker-rtl{ direction: rtl; }
-.ui-timepicker-rtl dl { text-align: right; }
-.ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; }
-</pre>
- <br />
-
- <h3>Requirements</h3>
- <p>You also need to include jQuery and jQuery UI with datepicker and slider wigits. You should include them in your page in the following order:</p>
- <ol>
- <li>jQuery</li>
- <li>jQueryUI (with datepicker and slider wigits)</li>
- <li>Timepicker</li>
- </ol>
-
- <br />
- <h3>Version</h3>
- <p>Version 1.3.1</p>
-
- <p>Last updated on 07/07/2013</p>
- <p>jQuery Timepicker Addon is currently available for use in all personal or commercial projects under both MIT and GPL licenses. This means that you can choose the license that best suits your project, and use it accordingly. </p>
- <p><a href="http://trentrichardson.com/Impromptu/GPL-LICENSE.txt" title="GPL License">GPL License</a></p>
- <p><a href="http://trentrichardson.com/Impromptu/MIT-LICENSE.txt" title="MIT License">MIT License</a></p>
-
- </div>
-
- <!-- ############################################################################# -->
- <!-- Options
- <!-- ############################################################################# -->
- <div id="tp-options">
- <h2>Options</h2>
-
- <p>The timepicker does inherit all options from datepicker. However, there are many options that are shared by them both, and many timepicker only options:</p>
-
- <h3>Localization Options</h3>
- <dl class="defs">
- <dt>currentText</dt>
- <dd><em>Default: "Now", A Localization Setting</em> - Text for the Now button.</dd>
-
- <dt>closeText</dt>
- <dd><em>Default: "Done", A Localization Setting</em> - Text for the Close button.</dd>
-
- <dt>amNames</dt>
- <dd><em>Default: ['AM', 'A'], A Localization Setting</em> - Array of strings to try and parse against to determine AM.</dd>
-
- <dt>pmNames</dt>
- <dd><em>Default: ['PM', 'P'], A Localization Setting</em> - Array of strings to try and parse against to determine PM.</dd>
-
- <dt>timeFormat</dt>
- <dd><em>Default: "HH:mm", A Localization Setting</em> - String of format tokens to be replaced with the time. <a href="#tp-formatting" title="Formatting" onclick="$('#tabs').tabs('select',2);">See Formatting</a>.</dd>
-
- <dt>timeSuffix</dt>
- <dd><em>Default: "", A Localization Setting</em> - String to place after the formatted time.</dd>
-
- <dt>timeOnlyTitle</dt>
- <dd><em>Default: "Choose Time", A Localization Setting</em> - Title of the wigit when using only timepicker.</dd>
-
- <dt>timeText</dt>
- <dd><em>Default: "Time", A Localization Setting</em> - Label used within timepicker for the formatted time.</dd>
-
- <dt>hourText</dt>
- <dd><em>Default: "Hour", A Localization Setting</em> - Label used to identify the hour slider.</dd>
-
- <dt>minuteText</dt>
- <dd><em>Default: "Minute", A Localization Setting</em> - Label used to identify the minute slider.</dd>
-
- <dt>secondText</dt>
- <dd><em>Default: "Second", A Localization Setting</em> - Label used to identify the second slider.</dd>
-
- <dt>millisecText</dt>
- <dd><em>Default: "Millisecond", A Localization Setting</em> - Label used to identify the millisecond slider.</dd>
-
- <dt>microsecText</dt>
- <dd><em>Default: "Microsecond", A Localization Setting</em> - Label used to identify the microsecond slider.</dd>
-
- <dt>timezoneText</dt>
- <dd><em>Default: "Timezone", A Localization Setting</em> - Label used to identify the timezone slider.</dd>
-
- <dt>isRTL</dt>
- <dd><em>Default: false, A Localization Setting</em> - Right to Left support.</dd>
- </dl>
-
- <h3>Alt Field Options</h3>
- <dl class="defs">
-
- <dt>altFieldTimeOnly</dt>
- <dd><em>Default: true</em> - When altField is used from datepicker altField will only receive the formatted time and the original field only receives date.</dd>
-
- <dt>altSeparator</dt>
- <dd><em>Default: (separator option)</em> - String placed between formatted date and formatted time in the altField.</dd>
-
- <dt>altTimeSuffix</dt>
- <dd><em>Default: (timeSuffix option)</em> - String always placed after the formatted time in the altField.</dd>
-
- <dt>altTimeFormat</dt>
- <dd><em>Default: (timeFormat option)</em> - The time format to use with the altField.</dd>
- </dl>
-
- <h3>Timezone Options</h3>
- <dl class="defs">
-
- <dt>timezoneList</dt>
- <dd><em>Default: [generated timezones]</em> - An array of timezones used to populate the timezone select. Can be an array of values or an array of objects: { label: "EDT", value: -240 }. The value should be the offset number in minutes. So "-0400" which is the format "-hhmm", would equate to -240 minutes.</dd>
- </dl>
-
- <h3>Time Field Options</h3>
- <dl class="defs">
-
- <dt>controlType</dt>
- <dd><em>Default: 'slider'</em> - Whether to use 'slider' or 'select'. If 'slider' is unavailable through jQueryUI, 'select' will be used. For advanced usage you may pass an object which implements "create", "options", "value" methods to use controls other than sliders or selects. See the _controls property in the source code for more details.
-<pre>{
- create: function(tp_inst, obj, unit, val, min, max, step){
- // generate whatever controls you want here, just return obj
- },
- options: function(tp_inst, obj, unit, opts, val){
- // if val==undefined return the value, else return obj
- },
- value: function(tp_inst, obj, unit, val){
- // if val==undefined return the value, else return obj
- }
-}</pre>
- </dd>
-
- <dt>showHour</dt>
- <dd><em>Default: null</em> - Whether to show the hour control. The default of null will use detection from timeFormat.</dd>
-
- <dt>showMinute</dt>
- <dd><em>Default: null</em> - Whether to show the minute control. The default of null will use detection from timeFormat.</dd>
-
- <dt>showSecond</dt>
- <dd><em>Default: null</em> - Whether to show the second control. The default of null will use detection from timeFormat.</dd>
-
- <dt>showMillisec</dt>
- <dd><em>Default: null</em> - Whether to show the millisecond control. The default of null will use detection from timeFormat.</dd>
-
- <dt>showMicrosec</dt>
- <dd><em>Default: null</em> - Whether to show the microsecond control. The default of null will use detection from timeFormat.</dd>
-
- <dt>showTimezone</dt>
- <dd><em>Default: null</em> - Whether to show the timezone select.</dd>
-
- <dt>showTime</dt>
- <dd><em>Default: true</em> - Whether to show the time selected within the datetimepicker.</dd>
-
- <dt>stepHour</dt>
- <dd><em>Default: 1</em> - Hours per step the slider makes.</dd>
-
- <dt>stepMinute</dt>
- <dd><em>Default: 1</em> - Minutes per step the slider makes.</dd>
-
- <dt>stepSecond</dt>
- <dd><em>Default: 1</em> - Seconds per step the slider makes.</dd>
-
- <dt>stepMillisec</dt>
- <dd><em>Default: 1</em> - Milliseconds per step the slider makes.</dd>
-
- <dt>stepMicrosec</dt>
- <dd><em>Default: 1</em> - Microseconds per step the slider makes.</dd>
-
- <dt>hour</dt>
- <dd><em>Default: 0</em> - Initial hour set.</dd>
-
- <dt>minute</dt>
- <dd><em>Default: 0</em> - Initial minute set.</dd>
-
- <dt>second</dt>
- <dd><em>Default: 0</em> - Initial second set.</dd>
-
- <dt>millisec</dt>
- <dd><em>Default: 0</em> - Initial millisecond set.</dd>
-
- <dt>microsec</dt>
- <dd><em>Default: 0</em> - Initial microsecond set. Note: Javascript's native Date object does not natively support microseconds. Timepicker adds ability to simply Date.setMicroseconds(m) and Date.getMicroseconds(). Date comparisons will not acknowledge microseconds. Use this only for display purposes.</dd>
-
- <dt>timezone</dt>
- <dd><em>Default: null</em> - Initial timezone set. This is the offset in minutes. If null the browser's local timezone will be used. If you're timezone is "-0400" you would use -240. For backwards compatibility you may pass "-0400", however the timezone is stored in minutes and more reliable.</dd>
-
- <dt>hourMin</dt>
- <dd><em>Default: 0</em> - The minimum hour allowed for all dates.</dd>
-
- <dt>minuteMin</dt>
- <dd><em>Default: 0</em> - The minimum minute allowed for all dates.</dd>
-
- <dt>secondMin</dt>
- <dd><em>Default: 0</em> - The minimum second allowed for all dates.</dd>
-
- <dt>millisecMin</dt>
- <dd><em>Default: 0</em> - The minimum millisecond allowed for all dates.</dd>
-
- <dt>microsecMin</dt>
- <dd><em>Default: 0</em> - The minimum microsecond allowed for all dates.</dd>
-
- <dt>hourMax</dt>
- <dd><em>Default: 23</em> - The maximum hour allowed for all dates.</dd>
-
- <dt>minuteMax</dt>
- <dd><em>Default: 59</em> - The maximum minute allowed for all dates.</dd>
-
- <dt>secondMax</dt>
- <dd><em>Default: 59</em> - The maximum second allowed for all dates.</dd>
-
- <dt>millisecMax</dt>
- <dd><em>Default: 999</em> - The maximum millisecond allowed for all dates.</dd>
-
- <dt>microsecMax</dt>
- <dd><em>Default: 999</em> - The maximum microsecond allowed for all dates.</dd>
-
- <dt>hourGrid</dt>
- <dd><em>Default: 0</em> - When greater than 0 a label grid will be generated under the slider. This number represents the units (in hours) between labels.</dd>
-
- <dt>minuteGrid</dt>
- <dd><em>Default: 0</em> - When greater than 0 a label grid will be generated under the slider. This number represents the units (in minutes) between labels.</dd>
-
- <dt>secondGrid</dt>
- <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in seconds) between labels.</dd>
-
- <dt>millisecGrid</dt>
- <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in milliseconds) between labels.</dd>
-
- <dt>microsecGrid</dt>
- <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in microseconds) between labels.</dd>
- </dl>
-
- <h3>Other Options</h3>
- <dl class="defs">
- <dt>showButtonPanel</dt>
- <dd><em>Default: true</em> - Whether to show the button panel at the bottom. This is generally needed.</dd>
-
- <dt>timeOnly</dt>
- <dd><em>Default: false</em> - Hide the datepicker and only provide a time interface.</dd>
-
- <dt>onSelect</dt>
- <dd><em>Default: null</em> - Function to be called when a date is chosen or time has changed (parameters: datetimeText, datepickerInstance).</dd>
-
- <dt>alwaysSetTime</dt>
- <dd><em>Default: true</em> - Always have a time set internally, even before user has chosen one.</dd>
-
- <dt>separator</dt>
- <dd><em>Default: " "</em> - When formatting the time this string is placed between the formatted date and formatted time.</dd>
-
- <dt>pickerTimeFormat</dt>
- <dd><em>Default: (timeFormat option)</em> - How to format the time displayed within the timepicker.</dd>
-
- <dt>pickerTimeSuffix</dt>
- <dd><em>Default: (timeSuffix option)</em> - String to place after the formatted time within the timepicker.</dd>
-
- <dt>showTimepicker</dt>
- <dd><em>Default: true</em> - Whether to show the timepicker within the datepicker.</dd>
-
- <dt>addSliderAccess</dt>
- <dd><em>Default: false</em> - Adds the <a href="http://trentrichardson.com/examples/jQuery-SliderAccess/" title="jQueryUI Slider Access Plugin">sliderAccess plugin</a> to sliders within timepicker</dd>
-
- <dt>sliderAccessArgs</dt>
- <dd><em>Default: null</em> - Object to pass to sliderAccess when used.</dd>
-
- <dt>defaultValue</dt>
- <dd><em>Default: null</em> - String of the default time value placed in the input on focus when the input is empty.</dd>
-
- <dt>minDateTime</dt>
- <dd><em>Default: null</em> - Date object of the minimum datetime allowed. Also available as minDate.</dd>
-
- <dt>maxDateTime</dt>
- <dd><em>Default: null</em> - Date object of the maximum datetime allowed. Also Available as maxDate.</dd>
-
- <dt>parse</dt>
- <dd><em>Default: 'strict'</em> - How to parse the time string. Two methods are provided: 'strict' which must match the timeFormat exactly, and 'loose' which uses javascript's new Date(timeString) to guess the time. You may also pass in a function(timeFormat, timeString, options) to handle the parsing yourself, returning a simple object:
-<pre>{
- hour: 19,
- minute: 10,
- second: 23,
- millisec: 45,
- microsec: 23,
- timezone: '-0400'
-}</pre>
- </dd>
- </dl>
-
- </div>
-
-
- <!-- ############################################################################# -->
- <!-- Formatting
- <!-- ############################################################################# -->
- <div id="tp-formatting">
-
- <h2>Formatting Your Time</h2>
-
- <p>The default format is "HH:mm". To use 12 hour time use something similar to: "hh:mm tt". When both "t" and lower case "h" are present in the timeFormat, 12 hour time will be used.</p>
-
- <dl class="defs">
- <dt>H</dt><dd>Hour with no leading 0 (24 hour)</dd>
- <dt>HH</dt><dd>Hour with leading 0 (24 hour)</dd>
- <dt>h</dt><dd>Hour with no leading 0 (12 hour)</dd>
- <dt>hh</dt><dd>Hour with leading 0 (12 hour)</dd>
- <dt>m</dt><dd>Minute with no leading 0</dd>
- <dt>mm</dt><dd>Minute with leading 0</dd>
- <dt>s</dt><dd>Second with no leading 0</dd>
- <dt>ss</dt><dd>Second with leading 0</dd>
- <dt>l</dt><dd>Milliseconds always with leading 0</dd>
- <dt>c</dt><dd>Microseconds always with leading 0</dd>
- <dt>t</dt><dd>a or p for AM/PM</dd>
- <dt>T</dt><dd>A or P for AM/PM</dd>
- <dt>tt</dt><dd>am or pm for AM/PM</dd>
- <dt>TT</dt><dd>AM or PM for AM/PM</dd>
- <dt>z</dt><dd>Timezone as defined by timezoneList</dd>
- <dt>Z</dt><dd>Timezone in Iso 8601 format (+04:45)</dd>
- <dt>'...'</dt><dd>Literal text (Uses single quotes)</dd>
- </dl>
-
- <p>Formats are used in the following ways:</p>
- <ul>
- <li>timeFormat option</li>
- <li>altTimeFormat option</li>
- <li>pickerTimeFormat option</li>
- <li>$.datepicker.formatTime(format, timeObj, options) utility method</li>
- <li>$.datepicker.parseTime(format, timeStr, options) utility method</li>
- </ul>
-
- <p>For help with formatting the date portion, visit the datepicker documentation for <a href="http://docs.jquery.com/UI/Datepicker/formatDate" title="jQuery UI Datepicker Formatting">formatting dates</a>.</p>
- </div>
-
- <!-- ############################################################################# -->
- <!-- Localization
- <!-- ############################################################################# -->
- <div id="tp-localization">
-
- <h2>Working with Localizations</h2>
-
- <p>Timepicker comes with many translations and localizations, thanks to all the contributors. They can be found in the i18n folder in the git repo.</p>
-
- <p>The quick and cheap way to use localizations is to pass in options to a timepicker instance:</p>
-
-<pre>$('#example123').timepicker({
- timeOnlyTitle: 'Выберите время',
- timeText: 'Время',
- hourText: 'Часы',
- minuteText: 'Минуты',
- secondText: 'Секунды',
- currentText: 'Теперь',
- closeText: 'Закрыть'
-});
-</pre>
- <p>However, if you plan to use timepicker extensively you will need to include (build your own) localization. It is simply assigning those same variables to an object. As you see in the example below we maintain a separate object for timepicker. This way we aren't bound to any changes within datepicker.</p>
-
-<pre>$.datepicker.regional['ru'] = {
- closeText: 'Закрыть',
- prevText: '&#x3c;Пред',
- nextText: 'След&#x3e;',
- currentText: 'Сегодня',
- monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь',
- 'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
- monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн',
- 'Июл','Авг','Сен','Окт','Ноя','Дек'],
- dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
- dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'],
- dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
- weekHeader: 'Не',
- dateFormat: 'dd.mm.yy',
- firstDay: 1,
- isRTL: false,
- showMonthAfterYear: false,
- yearSuffix: ''
-};
-$.datepicker.setDefaults($.datepicker.regional['ru']);
-
-
-$.timepicker.regional['ru'] = {
- timeOnlyTitle: 'Выберите время',
- timeText: 'Время',
- hourText: 'Часы',
- minuteText: 'Минуты',
- secondText: 'Секунды',
- millisecText: 'Миллисекунды',
- timezoneText: 'Часовой пояс',
- currentText: 'Сейчас',
- closeText: 'Закрыть',
- timeFormat: 'HH:mm',
- amNames: ['AM', 'A'],
- pmNames: ['PM', 'P'],
- isRTL: false
-};
-$.timepicker.setDefaults($.timepicker.regional['ru']);
-</pre>
- <p>Now all you have to do is call timepicker and the Russian localization is used. Generally you only need to include the localization file, it will setDefaults() for you.</p>
- <p>You can also visit <a href="http://docs.jquery.com/UI/Datepicker/Localization" title="localization for datepicker" target="_BLANK">localization for datepicker</a> for more information about datepicker localizations.</p>
- </div>
-
- <!-- ############################################################################# -->
- <!-- Examples
- <!-- ############################################################################# -->
- <div id="tp-examples">
- <h2>Examples</h2>
-
- <ul>
- <li><a href="#basic_examples" title="Basic Initializations">Basic Initializations</a></li>
- <li><a href="#timezone_examples" title="Using Timezones">Using Timezones</a></li>
- <li><a href="#slider_examples" title="Slider Modifications">Slider Modifications</a></li>
- <li><a href="#alt_examples" title="Alternate Field">Alternate Fields</a></li>
- <li><a href="#rest_examples" title="Time Restraints">Time Restraints</a></li>
- <li><a href="#utility_examples" title="Utilities">Utilities</a></li>
- </ul>
-
- <h3 id="basic_examples">Basic Initializations</h3>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Add a simple datetimepicker to jQuery UI's datepicker</p>
- <div>
- <input type="text" name="basic_example_1" id="basic_example_1" value="" />
- </div>
-<pre>
-$('#basic_example_1').datetimepicker();
-</pre>
- </div>
-
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Add only a timepicker:</p>
- <div>
- <input type="text" name="basic_example_2" id="basic_example_2" value="" />
- </div>
-<pre>
-$('#basic_example_2').timepicker();
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Format the time:</p>
- <div>
- <input type="text" name="basic_example_3" id="basic_example_3" value="" />
- </div>
-<pre>
-$('#basic_example_3').datetimepicker({
- timeFormat: "hh:mm tt"
-});
-</pre>
- </div>
-
- <h3 id="timezone_examples">Using Timezones</h3>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Simplest timezone usage:</p>
- <div>
- <input type="text" name="timezone_example_1" id="timezone_example_1" value="" />
- </div>
-<pre>
-$('#timezone_example_1').datetimepicker({
- timeFormat: 'hh:mm tt z'
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Define your own timezone options:</p>
- <div>
- <input type="text" name="timezone_example_2" id="timezone_example_2" value="" />
- </div>
-<pre>
-$('#timezone_example_2').datetimepicker({
- timeFormat: 'HH:mm z',
- timezoneList: [
- { value: -300, label: 'Eastern'},
- { value: -360, label: 'Central' },
- { value: -420, label: 'Mountain' },
- { value: -480, label: 'Pacific' }
- ]
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>You may also use timezone string abbreviations for values. This should be used with caution. Computing accurate javascript Date objects may not be possible when trying to retrieve or set the date from timepicker (see setDate and getDate examples below). For simple input values however this should work.</p>
- <div>
- <input type="text" name="timezone_example_3" id="timezone_example_3" value="" />
- </div>
-<pre>
-$('#timezone_example_3').datetimepicker({
- timeFormat: 'HH:mm z',
- timezone: 'MT',
- timezoneList: [
- { value: 'ET', label: 'Eastern'},
- { value: 'CT', label: 'Central' },
- { value: 'MT', label: 'Mountain' },
- { value: 'PT', label: 'Pacific' }
- ]
-});
-
-</pre>
- </div>
-
- <h3 id="slider_examples">Slider Modifications</h3>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Add a grid to each slider:</p>
- <div>
- <input type="text" name="slider_example_1" id="slider_example_1" value="" />
- </div>
-<pre>
-$('#slider_example_1').timepicker({
- hourGrid: 4,
- minuteGrid: 10,
- timeFormat: 'hh:mm tt'
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Set the interval step of sliders:</p>
- <div>
- <input type="text" name="slider_example_2" id="slider_example_2" value="" />
- </div>
-<pre>
-$('#slider_example_2').datetimepicker({
- timeFormat: 'HH:mm:ss',
- stepHour: 2,
- stepMinute: 10,
- stepSecond: 10
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Add sliderAccess plugin for touch devices:</p>
- <div>
- <input type="text" name="slider_example_3" id="slider_example_3" value="" />
- </div>
-<pre>
-$('#slider_example_3').datetimepicker({
- addSliderAccess: true,
- sliderAccessArgs: { touchonly: false }
-});</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Use dropdowns instead of sliders. By default if slider is not available dropdowns will be used.</p>
- <div>
- <input type="text" name="slider_example_4" id="slider_example_4" value="" />
- </div>
-<pre>
-$('#slider_example_4').datetimepicker({
- controlType: 'select',
- timeFormat: 'hh:mm tt'
-});</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Create your own control by implementing the create, options, and value methods. If you want to use your new control for all instances use the $.timepicker.setDefaults({controlType:myControl}). Here we implement jQueryUI's spinner control (jQueryUI 1.9+).</p>
- <div>
- <input type="text" name="slider_example_5" id="slider_example_5" value="" />
- </div>
-<pre>var myControl= {
- create: function(tp_inst, obj, unit, val, min, max, step){
- $('&lt;input class="ui-timepicker-input" value="'+val+'" style="width:50%"&gt;')
- .appendTo(obj)
- .spinner({
- min: min,
- max: max,
- step: step,
- change: function(e,ui){ // key events
- // don't call if api was used and not key press
- if(e.originalEvent !== undefined)
- tp_inst._onTimeChange();
- tp_inst._onSelectHandler();
- },
- spin: function(e,ui){ // spin events
- tp_inst.control.value(tp_inst, obj, unit, ui.value);
- tp_inst._onTimeChange();
- tp_inst._onSelectHandler();
- }
- });
- return obj;
- },
- options: function(tp_inst, obj, unit, opts, val){
- if(typeof(opts) == 'string' && val !== undefined)
- return obj.find('.ui-timepicker-input').spinner(opts, val);
- return obj.find('.ui-timepicker-input').spinner(opts);
- },
- value: function(tp_inst, obj, unit, val){
- if(val !== undefined)
- return obj.find('.ui-timepicker-input').spinner('value', val);
- return obj.find('.ui-timepicker-input').spinner('value');
- }
-};
-
-$('#slider_example_5').datetimepicker({
- controlType: myControl
-});</pre>
- </div>
-
- <h3 id="alt_examples">Alternate Fields</h3>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Alt field in the simplest form:</p>
- <div>
- <input type="text" name="alt_example_1" id="alt_example_1" value="09/15/2012" />
- <input type="text" name="alt_example_1_alt" id="alt_example_1_alt" value="10:15" />
- </div>
-<pre>
-$('#alt_example_1').datetimepicker({
- altField: "#alt_example_1_alt"
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>With datetime in both:</p>
- <div>
- <input type="text" name="alt_example_2" id="alt_example_2" value="" />
- <input type="text" name="alt_example_2_alt" id="alt_example_2_alt" value="" />
- </div>
-<pre>
-$('#alt_example_2').datetimepicker({
- altField: "#alt_example_2_alt",
- altFieldTimeOnly: false
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Format the altField differently:</p>
- <div>
- <input type="text" name="alt_example_3" id="alt_example_3" value="" />
- <input type="text" name="alt_example_3_alt" id="alt_example_3_alt" value="" />
- </div>
-<pre>
-$('#alt_example_3').datetimepicker({
- altField: "#alt_example_3_alt",
- altFieldTimeOnly: false,
- altFormat: "yy-mm-dd",
- altTimeFormat: "h:m t",
- altSeparator: " @ "
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>With inline mode using altField:</p>
- <div>
- <input type="text" name="alt_example_4_alt" id="alt_example_4_alt" value="" />
- <span id="alt_example_4" ></span>
- </div>
-<pre>
-$('#alt_example_4').datetimepicker({
- altField: "#alt_example_4_alt",
- altFieldTimeOnly: false
-});
-</pre>
- </div>
-
- <h3 id="rest_examples">Time Restraints</h3>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Set the min/max hour of every date:</p>
- <div>
- <input type="text" name="rest_example_1" id="rest_example_1" value="" />
- </div>
-<pre>
-$('#rest_example_1').timepicker({
- hourMin: 8,
- hourMax: 16
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Set the min/max date numerically:</p>
- <div>
- <input type="text" name="rest_example_2" id="rest_example_2" value="" />
- </div>
-<pre>
-$('#rest_example_2').datetimepicker({
- numberOfMonths: 2,
- minDate: 0,
- maxDate: 30
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Set the min/max date and time with a Date object:</p>
- <div>
- <input type="text" name="rest_example_3" id="rest_example_3" value="" />
- </div>
-<pre>
-$('#rest_example_3').datetimepicker({
- minDate: new Date(2010, 11, 20, 8, 30),
- maxDate: new Date(2010, 11, 31, 17, 30)
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Restrict a start and end date by using onSelect and onClose events for more control over functionality:</p>
- <p>For more examples and advanced usage grab the <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook">Handling Time eBook</a>.</p>
- <div>
- <input type="text" name="rest_example_4_start" id="rest_example_4_start" value="" />
- <input type="text" name="rest_example_4_end" id="rest_example_4_end" value="" />
- </div>
-<pre>
-var startDateTextBox = $('#rest_example_4_start');
-var endDateTextBox = $('#rest_example_4_end');
-
-startDateTextBox.datetimepicker({
- timeFormat: 'HH:mm z',
- onClose: function(dateText, inst) {
- if (endDateTextBox.val() != '') {
- var testStartDate = startDateTextBox.datetimepicker('getDate');
- var testEndDate = endDateTextBox.datetimepicker('getDate');
- if (testStartDate > testEndDate)
- endDateTextBox.datetimepicker('setDate', testStartDate);
- }
- else {
- endDateTextBox.val(dateText);
- }
- },
- onSelect: function (selectedDateTime){
- endDateTextBox.datetimepicker('option', 'minDate', startDateTextBox.datetimepicker('getDate') );
- }
-});
-endDateTextBox.datetimepicker({
- timeFormat: 'HH:mm z',
- onClose: function(dateText, inst) {
- if (startDateTextBox.val() != '') {
- var testStartDate = startDateTextBox.datetimepicker('getDate');
- var testEndDate = endDateTextBox.datetimepicker('getDate');
- if (testStartDate > testEndDate)
- startDateTextBox.datetimepicker('setDate', testEndDate);
- }
- else {
- startDateTextBox.val(dateText);
- }
- },
- onSelect: function (selectedDateTime){
- startDateTextBox.datetimepicker('option', 'maxDate', endDateTextBox.datetimepicker('getDate') );
- }
-});
-</pre>
- </div>
-
- <h3 id="utility_examples">Utilities</h3>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Get and Set Datetime with the getDate and setDate methods. This example uses timezone to demonstrate the timepicker regonizes the timezones and computes the offsets when getting and setting.</p>
- <div>
- <input type="text" name="utility_example_1" id="utility_example_1" value="" />
- <button id="utility_example_1_setdt" value="1">Set Datetime</button>
- <button id="utility_example_1_getdt" value="1">Get Datetime</button>
- </div>
-
-<pre>
-var ex13 = $('#utility_example_1');
-
-ex13.datetimepicker({
- timeFormat: 'hh:mm tt z',
- separator: ' @ ',
- showTimezone: true
-});
-
-$('#utility_example_1_setdt').click(function(){
- ex13.datetimepicker('setDate', (new Date()) );
-});
-
-$('#utility_example_1_getdt').click(function(){
- alert(ex13.datetimepicker('getDate'));
-});
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Use the utility function to format your own time. $.datepicker.formatTime(format, time, options)</p>
- <dl class="defs">
- <dt>format</dt><dd>required - string represenation of the time format to use</dd>
- <dt>time</dt><dd>required - hash: { hour, minute, second, millisecond, timezone }</dd>
- <dt>options</dt><dd>optional - hash of any options in regional translation (ampm, amNames, pmNames..)</dd>
- </dl>
- <p>Returns a time string in the specified format.</p>
- <div>
- <div id="utility_example_2"></div>
- </div>
-
-<pre>
-$('#utility_example_2').text(
- $.datepicker.formatTime('HH:mm z', { hour: 14, minute: 36, timezone: '+2000' }, {})
-);
-</pre>
- </div>
-
- <!-- ============= example -->
- <div class="example-container">
- <p>Use the utility function to parses a formatted time. $.datepicker.parseTime(format, timeString, options)</p>
- <dl class="defs">
- <dt>format</dt><dd>required - string represenation of the time format to use</dd>
- <dt>time</dt><dd>required - time string matching the format given in parameter 1</dd>
- <dt>options</dt><dd>optional - hash of any options in regional translation (ampm, amNames, pmNames..)</dd>
- </dl>
- <p>Returns an object with hours, minutes, seconds, milliseconds, timezone.</p>
- <div>
- <div id="utility_example_3"></div>
- </div>
-
-<pre>
-$('#utility_example_3').text(JSON.stringify(
- $.datepicker.parseTime('HH:mm:ss:l z', "14:36:21:765 +2000", {})
-));
-</pre>
- </div>
-
- </div>
- </div>
-
-
- </div>
-
-
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
- <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
- <script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
- <script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
-
- <script type="text/javascript">
-
- $(function(){
- $('#tabs').tabs();
-
- $('.example-container > pre').each(function(i){
- eval($(this).text());
- });
- });
-
- </script>
-
- <script type="text/javascript" src="https://sellfy.com/js/api_buttons.js"></script>
- <script type="text/javascript" src="https://gumroad.com/js/gumroad.js"></script>
-
- <script type="text/javascript"> /*
- var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
- document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
- */</script>
- <script type="text/javascript"> /*
- try {
- var pageTracker = _gat._getTracker("UA-7602218-1");
- pageTracker._trackPageview();
- } catch(err) {}*/</script>
- </body>
-</html>
diff --git a/jquery-ui-timepicker-addon.css b/jquery-ui-timepicker-addon.css
deleted file mode 100644
index b93a85f..0000000
--- a/jquery-ui-timepicker-addon.css
+++ /dev/null
@@ -1,10 +0,0 @@
-.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
-.ui-timepicker-div dl { text-align: left; }
-.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
-.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
-.ui-timepicker-div td { font-size: 90%; }
-.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
-
-.ui-timepicker-rtl{ direction: rtl; }
-.ui-timepicker-rtl dl { text-align: right; }
-.ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; } \ No newline at end of file
diff --git a/jquery-ui-timepicker-addon.json b/jquery-ui-timepicker-addon.json
new file mode 100644
index 0000000..ef31a44
--- /dev/null
+++ b/jquery-ui-timepicker-addon.json
@@ -0,0 +1,27 @@
+{
+ "name": "jquery-ui-timepicker-addon",
+ "title": "jQuery Timepicker Addon",
+ "description": "A timepicker addon for jQueryUI datepicker.",
+ "version": "1.4",
+ "homepage": "http://trentrichardson.com/examples/timepicker",
+ "author": {
+ "name": "Trent Richardson",
+ "email": "trentdrichardson@gmail.com",
+ "url": "http://trentrichardson.com"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/trentrichardson/jQuery-Timepicker-Addon.git"
+ },
+ "bugs": "https://github.com/trentrichardson/jQuery-Timepicker-Addon/issues",
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "http://trentrichardson.com/examples/jQuery-Timepicker-Addon/blob/master/LICENSE-MIT"
+ }
+ ],
+ "dependencies": {
+ "jquery": "*"
+ },
+ "keywords": []
+} \ No newline at end of file
diff --git a/lib/jasmine-1.3.1/MIT.LICENSE b/lib/jasmine-1.3.1/MIT.LICENSE
new file mode 100644
index 0000000..7c435ba
--- /dev/null
+++ b/lib/jasmine-1.3.1/MIT.LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008-2011 Pivotal Labs
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/lib/jasmine-1.3.1/jasmine-html.js b/lib/jasmine-1.3.1/jasmine-html.js
new file mode 100644
index 0000000..543d569
--- /dev/null
+++ b/lib/jasmine-1.3.1/jasmine-html.js
@@ -0,0 +1,681 @@
+jasmine.HtmlReporterHelpers = {};
+
+jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
+ var el = document.createElement(type);
+
+ for (var i = 2; i < arguments.length; i++) {
+ var child = arguments[i];
+
+ if (typeof child === 'string') {
+ el.appendChild(document.createTextNode(child));
+ } else {
+ if (child) {
+ el.appendChild(child);
+ }
+ }
+ }
+
+ for (var attr in attrs) {
+ if (attr == "className") {
+ el[attr] = attrs[attr];
+ } else {
+ el.setAttribute(attr, attrs[attr]);
+ }
+ }
+
+ return el;
+};
+
+jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
+ var results = child.results();
+ var status = results.passed() ? 'passed' : 'failed';
+ if (results.skipped) {
+ status = 'skipped';
+ }
+
+ return status;
+};
+
+jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
+ var parentDiv = this.dom.summary;
+ var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
+ var parent = child[parentSuite];
+
+ if (parent) {
+ if (typeof this.views.suites[parent.id] == 'undefined') {
+ this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
+ }
+ parentDiv = this.views.suites[parent.id].element;
+ }
+
+ parentDiv.appendChild(childElement);
+};
+
+
+jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
+ for(var fn in jasmine.HtmlReporterHelpers) {
+ ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
+ }
+};
+
+jasmine.HtmlReporter = function(_doc) {
+ var self = this;
+ var doc = _doc || window.document;
+
+ var reporterView;
+
+ var dom = {};
+
+ // Jasmine Reporter Public Interface
+ self.logRunningSpecs = false;
+
+ self.reportRunnerStarting = function(runner) {
+ var specs = runner.specs() || [];
+
+ if (specs.length == 0) {
+ return;
+ }
+
+ createReporterDom(runner.env.versionString());
+ doc.body.appendChild(dom.reporter);
+ setExceptionHandling();
+
+ reporterView = new jasmine.HtmlReporter.ReporterView(dom);
+ reporterView.addSpecs(specs, self.specFilter);
+ };
+
+ self.reportRunnerResults = function(runner) {
+ reporterView && reporterView.complete();
+ };
+
+ self.reportSuiteResults = function(suite) {
+ reporterView.suiteComplete(suite);
+ };
+
+ self.reportSpecStarting = function(spec) {
+ if (self.logRunningSpecs) {
+ self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
+ }
+ };
+
+ self.reportSpecResults = function(spec) {
+ reporterView.specComplete(spec);
+ };
+
+ self.log = function() {
+ var console = jasmine.getGlobal().console;
+ if (console && console.log) {
+ if (console.log.apply) {
+ console.log.apply(console, arguments);
+ } else {
+ console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
+ }
+ }
+ };
+
+ self.specFilter = function(spec) {
+ if (!focusedSpecName()) {
+ return true;
+ }
+
+ return spec.getFullName().indexOf(focusedSpecName()) === 0;
+ };
+
+ return self;
+
+ function focusedSpecName() {
+ var specName;
+
+ (function memoizeFocusedSpec() {
+ if (specName) {
+ return;
+ }
+
+ var paramMap = [];
+ var params = jasmine.HtmlReporter.parameters(doc);
+
+ for (var i = 0; i < params.length; i++) {
+ var p = params[i].split('=');
+ paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
+ }
+
+ specName = paramMap.spec;
+ })();
+
+ return specName;
+ }
+
+ function createReporterDom(version) {
+ dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
+ dom.banner = self.createDom('div', { className: 'banner' },
+ self.createDom('span', { className: 'title' }, "Jasmine "),
+ self.createDom('span', { className: 'version' }, version)),
+
+ dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
+ dom.alert = self.createDom('div', {className: 'alert'},
+ self.createDom('span', { className: 'exceptions' },
+ self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
+ self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
+ dom.results = self.createDom('div', {className: 'results'},
+ dom.summary = self.createDom('div', { className: 'summary' }),
+ dom.details = self.createDom('div', { id: 'details' }))
+ );
+ }
+
+ function noTryCatch() {
+ return window.location.search.match(/catch=false/);
+ }
+
+ function searchWithCatch() {
+ var params = jasmine.HtmlReporter.parameters(window.document);
+ var removed = false;
+ var i = 0;
+
+ while (!removed && i < params.length) {
+ if (params[i].match(/catch=/)) {
+ params.splice(i, 1);
+ removed = true;
+ }
+ i++;
+ }
+ if (jasmine.CATCH_EXCEPTIONS) {
+ params.push("catch=false");
+ }
+
+ return params.join("&");
+ }
+
+ function setExceptionHandling() {
+ var chxCatch = document.getElementById('no_try_catch');
+
+ if (noTryCatch()) {
+ chxCatch.setAttribute('checked', true);
+ jasmine.CATCH_EXCEPTIONS = false;
+ }
+ chxCatch.onclick = function() {
+ window.location.search = searchWithCatch();
+ };
+ }
+};
+jasmine.HtmlReporter.parameters = function(doc) {
+ var paramStr = doc.location.search.substring(1);
+ var params = [];
+
+ if (paramStr.length > 0) {
+ params = paramStr.split('&');
+ }
+ return params;
+}
+jasmine.HtmlReporter.sectionLink = function(sectionName) {
+ var link = '?';
+ var params = [];
+
+ if (sectionName) {
+ params.push('spec=' + encodeURIComponent(sectionName));
+ }
+ if (!jasmine.CATCH_EXCEPTIONS) {
+ params.push("catch=false");
+ }
+ if (params.length > 0) {
+ link += params.join("&");
+ }
+
+ return link;
+};
+jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
+jasmine.HtmlReporter.ReporterView = function(dom) {
+ this.startedAt = new Date();
+ this.runningSpecCount = 0;
+ this.completeSpecCount = 0;
+ this.passedCount = 0;
+ this.failedCount = 0;
+ this.skippedCount = 0;
+
+ this.createResultsMenu = function() {
+ this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
+ this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
+ ' | ',
+ this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
+
+ this.summaryMenuItem.onclick = function() {
+ dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
+ };
+
+ this.detailsMenuItem.onclick = function() {
+ showDetails();
+ };
+ };
+
+ this.addSpecs = function(specs, specFilter) {
+ this.totalSpecCount = specs.length;
+
+ this.views = {
+ specs: {},
+ suites: {}
+ };
+
+ for (var i = 0; i < specs.length; i++) {
+ var spec = specs[i];
+ this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
+ if (specFilter(spec)) {
+ this.runningSpecCount++;
+ }
+ }
+ };
+
+ this.specComplete = function(spec) {
+ this.completeSpecCount++;
+
+ if (isUndefined(this.views.specs[spec.id])) {
+ this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
+ }
+
+ var specView = this.views.specs[spec.id];
+
+ switch (specView.status()) {
+ case 'passed':
+ this.passedCount++;
+ break;
+
+ case 'failed':
+ this.failedCount++;
+ break;
+
+ case 'skipped':
+ this.skippedCount++;
+ break;
+ }
+
+ specView.refresh();
+ this.refresh();
+ };
+
+ this.suiteComplete = function(suite) {
+ var suiteView = this.views.suites[suite.id];
+ if (isUndefined(suiteView)) {
+ return;
+ }
+ suiteView.refresh();
+ };
+
+ this.refresh = function() {
+
+ if (isUndefined(this.resultsMenu)) {
+ this.createResultsMenu();
+ }
+
+ // currently running UI
+ if (isUndefined(this.runningAlert)) {
+ this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
+ dom.alert.appendChild(this.runningAlert);
+ }
+ this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
+
+ // skipped specs UI
+ if (isUndefined(this.skippedAlert)) {
+ this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
+ }
+
+ this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
+
+ if (this.skippedCount === 1 && isDefined(dom.alert)) {
+ dom.alert.appendChild(this.skippedAlert);
+ }
+
+ // passing specs UI
+ if (isUndefined(this.passedAlert)) {
+ this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
+ }
+ this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
+
+ // failing specs UI
+ if (isUndefined(this.failedAlert)) {
+ this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
+ }
+ this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
+
+ if (this.failedCount === 1 && isDefined(dom.alert)) {
+ dom.alert.appendChild(this.failedAlert);
+ dom.alert.appendChild(this.resultsMenu);
+ }
+
+ // summary info
+ this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
+ this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
+ };
+
+ this.complete = function() {
+ dom.alert.removeChild(this.runningAlert);
+
+ this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
+
+ if (this.failedCount === 0) {
+ dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
+ } else {
+ showDetails();
+ }
+
+ dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
+ };
+
+ return this;
+
+ function showDetails() {
+ if (dom.reporter.className.search(/showDetails/) === -1) {
+ dom.reporter.className += " showDetails";
+ }
+ }
+
+ function isUndefined(obj) {
+ return typeof obj === 'undefined';
+ }
+
+ function isDefined(obj) {
+ return !isUndefined(obj);
+ }
+
+ function specPluralizedFor(count) {
+ var str = count + " spec";
+ if (count > 1) {
+ str += "s"
+ }
+ return str;
+ }
+
+};
+
+jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
+
+
+jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
+ this.spec = spec;
+ this.dom = dom;
+ this.views = views;
+
+ this.symbol = this.createDom('li', { className: 'pending' });
+ this.dom.symbolSummary.appendChild(this.symbol);
+
+ this.summary = this.createDom('div', { className: 'specSummary' },
+ this.createDom('a', {
+ className: 'description',
+ href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
+ title: this.spec.getFullName()
+ }, this.spec.description)
+ );
+
+ this.detail = this.createDom('div', { className: 'specDetail' },
+ this.createDom('a', {
+ className: 'description',
+ href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
+ title: this.spec.getFullName()
+ }, this.spec.getFullName())
+ );
+};
+
+jasmine.HtmlReporter.SpecView.prototype.status = function() {
+ return this.getSpecStatus(this.spec);
+};
+
+jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
+ this.symbol.className = this.status();
+
+ switch (this.status()) {
+ case 'skipped':
+ break;
+
+ case 'passed':
+ this.appendSummaryToSuiteDiv();
+ break;
+
+ case 'failed':
+ this.appendSummaryToSuiteDiv();
+ this.appendFailureDetail();
+ break;
+ }
+};
+
+jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
+ this.summary.className += ' ' + this.status();
+ this.appendToSummary(this.spec, this.summary);
+};
+
+jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
+ this.detail.className += ' ' + this.status();
+
+ var resultItems = this.spec.results().getItems();
+ var messagesDiv = this.createDom('div', { className: 'messages' });
+
+ for (var i = 0; i < resultItems.length; i++) {
+ var result = resultItems[i];
+
+ if (result.type == 'log') {
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
+ } else if (result.type == 'expect' && result.passed && !result.passed()) {
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
+
+ if (result.trace.stack) {
+ messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
+ }
+ }
+ }
+
+ if (messagesDiv.childNodes.length > 0) {
+ this.detail.appendChild(messagesDiv);
+ this.dom.details.appendChild(this.detail);
+ }
+};
+
+jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
+ this.suite = suite;
+ this.dom = dom;
+ this.views = views;
+
+ this.element = this.createDom('div', { className: 'suite' },
+ this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
+ );
+
+ this.appendToSummary(this.suite, this.element);
+};
+
+jasmine.HtmlReporter.SuiteView.prototype.status = function() {
+ return this.getSpecStatus(this.suite);
+};
+
+jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
+ this.element.className += " " + this.status();
+};
+
+jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
+
+/* @deprecated Use jasmine.HtmlReporter instead
+ */
+jasmine.TrivialReporter = function(doc) {
+ this.document = doc || document;
+ this.suiteDivs = {};
+ this.logRunningSpecs = false;
+};
+
+jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
+ var el = document.createElement(type);
+
+ for (var i = 2; i < arguments.length; i++) {
+ var child = arguments[i];
+
+ if (typeof child === 'string') {
+ el.appendChild(document.createTextNode(child));
+ } else {
+ if (child) { el.appendChild(child); }
+ }
+ }
+
+ for (var attr in attrs) {
+ if (attr == "className") {
+ el[attr] = attrs[attr];
+ } else {
+ el.setAttribute(attr, attrs[attr]);
+ }
+ }
+
+ return el;
+};
+
+jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
+ var showPassed, showSkipped;
+
+ this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
+ this.createDom('div', { className: 'banner' },
+ this.createDom('div', { className: 'logo' },
+ this.createDom('span', { className: 'title' }, "Jasmine"),
+ this.createDom('span', { className: 'version' }, runner.env.versionString())),
+ this.createDom('div', { className: 'options' },
+ "Show ",
+ showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
+ this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
+ showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
+ this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
+ )
+ ),
+
+ this.runnerDiv = this.createDom('div', { className: 'runner running' },
+ this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
+ this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
+ this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
+ );
+
+ this.document.body.appendChild(this.outerDiv);
+
+ var suites = runner.suites();
+ for (var i = 0; i < suites.length; i++) {
+ var suite = suites[i];
+ var suiteDiv = this.createDom('div', { className: 'suite' },
+ this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
+ this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
+ this.suiteDivs[suite.id] = suiteDiv;
+ var parentDiv = this.outerDiv;
+ if (suite.parentSuite) {
+ parentDiv = this.suiteDivs[suite.parentSuite.id];
+ }
+ parentDiv.appendChild(suiteDiv);
+ }
+
+ this.startedAt = new Date();
+
+ var self = this;
+ showPassed.onclick = function(evt) {
+ if (showPassed.checked) {
+ self.outerDiv.className += ' show-passed';
+ } else {
+ self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
+ }
+ };
+
+ showSkipped.onclick = function(evt) {
+ if (showSkipped.checked) {
+ self.outerDiv.className += ' show-skipped';
+ } else {
+ self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
+ }
+ };
+};
+
+jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
+ var results = runner.results();
+ var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
+ this.runnerDiv.setAttribute("class", className);
+ //do it twice for IE
+ this.runnerDiv.setAttribute("className", className);
+ var specs = runner.specs();
+ var specCount = 0;
+ for (var i = 0; i < specs.length; i++) {
+ if (this.specFilter(specs[i])) {
+ specCount++;
+ }
+ }
+ var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
+ message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
+ this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
+
+ this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
+};
+
+jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
+ var results = suite.results();
+ var status = results.passed() ? 'passed' : 'failed';
+ if (results.totalCount === 0) { // todo: change this to check results.skipped
+ status = 'skipped';
+ }
+ this.suiteDivs[suite.id].className += " " + status;
+};
+
+jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
+ if (this.logRunningSpecs) {
+ this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
+ }
+};
+
+jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
+ var results = spec.results();
+ var status = results.passed() ? 'passed' : 'failed';
+ if (results.skipped) {
+ status = 'skipped';
+ }
+ var specDiv = this.createDom('div', { className: 'spec ' + status },
+ this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
+ this.createDom('a', {
+ className: 'description',
+ href: '?spec=' + encodeURIComponent(spec.getFullName()),
+ title: spec.getFullName()
+ }, spec.description));
+
+
+ var resultItems = results.getItems();
+ var messagesDiv = this.createDom('div', { className: 'messages' });
+ for (var i = 0; i < resultItems.length; i++) {
+ var result = resultItems[i];
+
+ if (result.type == 'log') {
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
+ } else if (result.type == 'expect' && result.passed && !result.passed()) {
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
+
+ if (result.trace.stack) {
+ messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
+ }
+ }
+ }
+
+ if (messagesDiv.childNodes.length > 0) {
+ specDiv.appendChild(messagesDiv);
+ }
+
+ this.suiteDivs[spec.suite.id].appendChild(specDiv);
+};
+
+jasmine.TrivialReporter.prototype.log = function() {
+ var console = jasmine.getGlobal().console;
+ if (console && console.log) {
+ if (console.log.apply) {
+ console.log.apply(console, arguments);
+ } else {
+ console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
+ }
+ }
+};
+
+jasmine.TrivialReporter.prototype.getLocation = function() {
+ return this.document.location;
+};
+
+jasmine.TrivialReporter.prototype.specFilter = function(spec) {
+ var paramMap = {};
+ var params = this.getLocation().search.substring(1).split('&');
+ for (var i = 0; i < params.length; i++) {
+ var p = params[i].split('=');
+ paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
+ }
+
+ if (!paramMap.spec) {
+ return true;
+ }
+ return spec.getFullName().indexOf(paramMap.spec) === 0;
+};
diff --git a/lib/jasmine-1.3.1/jasmine.css b/lib/jasmine-1.3.1/jasmine.css
new file mode 100644
index 0000000..8c008dc
--- /dev/null
+++ b/lib/jasmine-1.3.1/jasmine.css
@@ -0,0 +1,82 @@
+body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
+
+#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
+#HTMLReporter a { text-decoration: none; }
+#HTMLReporter a:hover { text-decoration: underline; }
+#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
+#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
+#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
+#HTMLReporter .version { color: #aaaaaa; }
+#HTMLReporter .banner { margin-top: 14px; }
+#HTMLReporter .duration { color: #aaaaaa; float: right; }
+#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
+#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
+#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
+#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
+#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
+#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
+#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
+#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
+#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
+#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
+#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
+#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
+#HTMLReporter .runningAlert { background-color: #666666; }
+#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
+#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
+#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
+#HTMLReporter .passingAlert { background-color: #a6b779; }
+#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
+#HTMLReporter .failingAlert { background-color: #cf867e; }
+#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
+#HTMLReporter .results { margin-top: 14px; }
+#HTMLReporter #details { display: none; }
+#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
+#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
+#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
+#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
+#HTMLReporter.showDetails .summary { display: none; }
+#HTMLReporter.showDetails #details { display: block; }
+#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
+#HTMLReporter .summary { margin-top: 14px; }
+#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
+#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
+#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
+#HTMLReporter .description + .suite { margin-top: 0; }
+#HTMLReporter .suite { margin-top: 14px; }
+#HTMLReporter .suite a { color: #333333; }
+#HTMLReporter #details .specDetail { margin-bottom: 28px; }
+#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
+#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
+#HTMLReporter .resultMessage span.result { display: block; }
+#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
+
+#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
+#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
+#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
+#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
+#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
+#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
+#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
+#TrivialReporter .runner.running { background-color: yellow; }
+#TrivialReporter .options { text-align: right; font-size: .8em; }
+#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
+#TrivialReporter .suite .suite { margin: 5px; }
+#TrivialReporter .suite.passed { background-color: #dfd; }
+#TrivialReporter .suite.failed { background-color: #fdd; }
+#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
+#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
+#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
+#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
+#TrivialReporter .spec.skipped { background-color: #bbb; }
+#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
+#TrivialReporter .passed { background-color: #cfc; display: none; }
+#TrivialReporter .failed { background-color: #fbb; }
+#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
+#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
+#TrivialReporter .resultMessage .mismatch { color: black; }
+#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
+#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
+#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
+#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
+#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
diff --git a/lib/jasmine-1.3.1/jasmine.js b/lib/jasmine-1.3.1/jasmine.js
new file mode 100644
index 0000000..6b3459b
--- /dev/null
+++ b/lib/jasmine-1.3.1/jasmine.js
@@ -0,0 +1,2600 @@
+var isCommonJS = typeof window == "undefined" && typeof exports == "object";
+
+/**
+ * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
+ *
+ * @namespace
+ */
+var jasmine = {};
+if (isCommonJS) exports.jasmine = jasmine;
+/**
+ * @private
+ */
+jasmine.unimplementedMethod_ = function() {
+ throw new Error("unimplemented method");
+};
+
+/**
+ * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just
+ * a plain old variable and may be redefined by somebody else.
+ *
+ * @private
+ */
+jasmine.undefined = jasmine.___undefined___;
+
+/**
+ * Show diagnostic messages in the console if set to true
+ *
+ */
+jasmine.VERBOSE = false;
+
+/**
+ * Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
+ *
+ */
+jasmine.DEFAULT_UPDATE_INTERVAL = 250;
+
+/**
+ * Maximum levels of nesting that will be included when an object is pretty-printed
+ */
+jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
+
+/**
+ * Default timeout interval in milliseconds for waitsFor() blocks.
+ */
+jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
+
+/**
+ * By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
+ * Set to false to let the exception bubble up in the browser.
+ *
+ */
+jasmine.CATCH_EXCEPTIONS = true;
+
+jasmine.getGlobal = function() {
+ function getGlobal() {
+ return this;
+ }
+
+ return getGlobal();
+};
+
+/**
+ * Allows for bound functions to be compared. Internal use only.
+ *
+ * @ignore
+ * @private
+ * @param base {Object} bound 'this' for the function
+ * @param name {Function} function to find
+ */
+jasmine.bindOriginal_ = function(base, name) {
+ var original = base[name];
+ if (original.apply) {
+ return function() {
+ return original.apply(base, arguments);
+ };
+ } else {
+ // IE support
+ return jasmine.getGlobal()[name];
+ }
+};
+
+jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout');
+jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout');
+jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval');
+jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval');
+
+jasmine.MessageResult = function(values) {
+ this.type = 'log';
+ this.values = values;
+ this.trace = new Error(); // todo: test better
+};
+
+jasmine.MessageResult.prototype.toString = function() {
+ var text = "";
+ for (var i = 0; i < this.values.length; i++) {
+ if (i > 0) text += " ";
+ if (jasmine.isString_(this.values[i])) {
+ text += this.values[i];
+ } else {
+ text += jasmine.pp(this.values[i]);
+ }
+ }
+ return text;
+};
+
+jasmine.ExpectationResult = function(params) {
+ this.type = 'expect';
+ this.matcherName = params.matcherName;
+ this.passed_ = params.passed;
+ this.expected = params.expected;
+ this.actual = params.actual;
+ this.message = this.passed_ ? 'Passed.' : params.message;
+
+ var trace = (params.trace || new Error(this.message));
+ this.trace = this.passed_ ? '' : trace;
+};
+
+jasmine.ExpectationResult.prototype.toString = function () {
+ return this.message;
+};
+
+jasmine.ExpectationResult.prototype.passed = function () {
+ return this.passed_;
+};
+
+/**
+ * Getter for the Jasmine environment. Ensures one gets created
+ */
+jasmine.getEnv = function() {
+ var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
+ return env;
+};
+
+/**
+ * @ignore
+ * @private
+ * @param value
+ * @returns {Boolean}
+ */
+jasmine.isArray_ = function(value) {
+ return jasmine.isA_("Array", value);
+};
+
+/**
+ * @ignore
+ * @private
+ * @param value
+ * @returns {Boolean}
+ */
+jasmine.isString_ = function(value) {
+ return jasmine.isA_("String", value);
+};
+
+/**
+ * @ignore
+ * @private
+ * @param value
+ * @returns {Boolean}
+ */
+jasmine.isNumber_ = function(value) {
+ return jasmine.isA_("Number", value);
+};
+
+/**
+ * @ignore
+ * @private
+ * @param {String} typeName
+ * @param value
+ * @returns {Boolean}
+ */
+jasmine.isA_ = function(typeName, value) {
+ return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
+};
+
+/**
+ * Pretty printer for expecations. Takes any object and turns it into a human-readable string.
+ *
+ * @param value {Object} an object to be outputted
+ * @returns {String}
+ */
+jasmine.pp = function(value) {
+ var stringPrettyPrinter = new jasmine.StringPrettyPrinter();
+ stringPrettyPrinter.format(value);
+ return stringPrettyPrinter.string;
+};
+
+/**
+ * Returns true if the object is a DOM Node.
+ *
+ * @param {Object} obj object to check
+ * @returns {Boolean}
+ */
+jasmine.isDomNode = function(obj) {
+ return obj.nodeType > 0;
+};
+
+/**
+ * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter.
+ *
+ * @example
+ * // don't care about which function is passed in, as long as it's a function
+ * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function));
+ *
+ * @param {Class} clazz
+ * @returns matchable object of the type clazz
+ */
+jasmine.any = function(clazz) {
+ return new jasmine.Matchers.Any(clazz);
+};
+
+/**
+ * Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the
+ * attributes on the object.
+ *
+ * @example
+ * // don't care about any other attributes than foo.
+ * expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"});
+ *
+ * @param sample {Object} sample
+ * @returns matchable object for the sample
+ */
+jasmine.objectContaining = function (sample) {
+ return new jasmine.Matchers.ObjectContaining(sample);
+};
+
+/**
+ * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.
+ *
+ * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine
+ * expectation syntax. Spies can be checked if they were called or not and what the calling params were.
+ *
+ * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs).
+ *
+ * Spies are torn down at the end of every spec.
+ *
+ * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
+ *
+ * @example
+ * // a stub
+ * var myStub = jasmine.createSpy('myStub'); // can be used anywhere
+ *
+ * // spy example
+ * var foo = {
+ * not: function(bool) { return !bool; }
+ * }
+ *
+ * // actual foo.not will not be called, execution stops
+ * spyOn(foo, 'not');
+
+ // foo.not spied upon, execution will continue to implementation
+ * spyOn(foo, 'not').andCallThrough();
+ *
+ * // fake example
+ * var foo = {
+ * not: function(bool) { return !bool; }
+ * }
+ *
+ * // foo.not(val) will return val
+ * spyOn(foo, 'not').andCallFake(function(value) {return value;});
+ *
+ * // mock example
+ * foo.not(7 == 7);
+ * expect(foo.not).toHaveBeenCalled();
+ * expect(foo.not).toHaveBeenCalledWith(true);
+ *
+ * @constructor
+ * @see spyOn, jasmine.createSpy, jasmine.createSpyObj
+ * @param {String} name
+ */
+jasmine.Spy = function(name) {
+ /**
+ * The name of the spy, if provided.
+ */
+ this.identity = name || 'unknown';
+ /**
+ * Is this Object a spy?
+ */
+ this.isSpy = true;
+ /**
+ * The actual function this spy stubs.
+ */
+ this.plan = function() {
+ };
+ /**
+ * Tracking of the most recent call to the spy.
+ * @example
+ * var mySpy = jasmine.createSpy('foo');
+ * mySpy(1, 2);
+ * mySpy.mostRecentCall.args = [1, 2];
+ */
+ this.mostRecentCall = {};
+
+ /**
+ * Holds arguments for each call to the spy, indexed by call count
+ * @example
+ * var mySpy = jasmine.createSpy('foo');
+ * mySpy(1, 2);
+ * mySpy(7, 8);
+ * mySpy.mostRecentCall.args = [7, 8];
+ * mySpy.argsForCall[0] = [1, 2];
+ * mySpy.argsForCall[1] = [7, 8];
+ */
+ this.argsForCall = [];
+ this.calls = [];
+};
+
+/**
+ * Tells a spy to call through to the actual implemenatation.
+ *
+ * @example
+ * var foo = {
+ * bar: function() { // do some stuff }
+ * }
+ *
+ * // defining a spy on an existing property: foo.bar
+ * spyOn(foo, 'bar').andCallThrough();
+ */
+jasmine.Spy.prototype.andCallThrough = function() {
+ this.plan = this.originalValue;
+ return this;
+};
+
+/**
+ * For setting the return value of a spy.
+ *
+ * @example
+ * // defining a spy from scratch: foo() returns 'baz'
+ * var foo = jasmine.createSpy('spy on foo').andReturn('baz');
+ *
+ * // defining a spy on an existing property: foo.bar() returns 'baz'
+ * spyOn(foo, 'bar').andReturn('baz');
+ *
+ * @param {Object} value
+ */
+jasmine.Spy.prototype.andReturn = function(value) {
+ this.plan = function() {
+ return value;
+ };
+ return this;
+};
+
+/**
+ * For throwing an exception when a spy is called.
+ *
+ * @example
+ * // defining a spy from scratch: foo() throws an exception w/ message 'ouch'
+ * var foo = jasmine.createSpy('spy on foo').andThrow('baz');
+ *
+ * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch'
+ * spyOn(foo, 'bar').andThrow('baz');
+ *
+ * @param {String} exceptionMsg
+ */
+jasmine.Spy.prototype.andThrow = function(exceptionMsg) {
+ this.plan = function() {
+ throw exceptionMsg;
+ };
+ return this;
+};
+
+/**
+ * Calls an alternate implementation when a spy is called.
+ *
+ * @example
+ * var baz = function() {
+ * // do some stuff, return something
+ * }
+ * // defining a spy from scratch: foo() calls the function baz
+ * var foo = jasmine.createSpy('spy on foo').andCall(baz);
+ *
+ * // defining a spy on an existing property: foo.bar() calls an anonymnous function
+ * spyOn(foo, 'bar').andCall(function() { return 'baz';} );
+ *
+ * @param {Function} fakeFunc
+ */
+jasmine.Spy.prototype.andCallFake = function(fakeFunc) {
+ this.plan = fakeFunc;
+ return this;
+};
+
+/**
+ * Resets all of a spy's the tracking variables so that it can be used again.
+ *
+ * @example
+ * spyOn(foo, 'bar');
+ *
+ * foo.bar();
+ *
+ * expect(foo.bar.callCount).toEqual(1);
+ *
+ * foo.bar.reset();
+ *
+ * expect(foo.bar.callCount).toEqual(0);
+ */
+jasmine.Spy.prototype.reset = function() {
+ this.wasCalled = false;
+ this.callCount = 0;
+ this.argsForCall = [];
+ this.calls = [];
+ this.mostRecentCall = {};
+};
+
+jasmine.createSpy = function(name) {
+
+ var spyObj = function() {
+ spyObj.wasCalled = true;
+ spyObj.callCount++;
+ var args = jasmine.util.argsToArray(arguments);
+ spyObj.mostRecentCall.object = this;
+ spyObj.mostRecentCall.args = args;
+ spyObj.argsForCall.push(args);
+ spyObj.calls.push({object: this, args: args});
+ return spyObj.plan.apply(this, arguments);
+ };
+
+ var spy = new jasmine.Spy(name);
+
+ for (var prop in spy) {
+ spyObj[prop] = spy[prop];
+ }
+
+ spyObj.reset();
+
+ return spyObj;
+};
+
+/**
+ * Determines whether an object is a spy.
+ *
+ * @param {jasmine.Spy|Object} putativeSpy
+ * @returns {Boolean}
+ */
+jasmine.isSpy = function(putativeSpy) {
+ return putativeSpy && putativeSpy.isSpy;
+};
+
+/**
+ * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something
+ * large in one call.
+ *
+ * @param {String} baseName name of spy class
+ * @param {Array} methodNames array of names of methods to make spies
+ */
+jasmine.createSpyObj = function(baseName, methodNames) {
+ if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
+ throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
+ }
+ var obj = {};
+ for (var i = 0; i < methodNames.length; i++) {
+ obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
+ }
+ return obj;
+};
+
+/**
+ * All parameters are pretty-printed and concatenated together, then written to the current spec's output.
+ *
+ * Be careful not to leave calls to <code>jasmine.log</code> in production code.
+ */
+jasmine.log = function() {
+ var spec = jasmine.getEnv().currentSpec;
+ spec.log.apply(spec, arguments);
+};
+
+/**
+ * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.
+ *
+ * @example
+ * // spy example
+ * var foo = {
+ * not: function(bool) { return !bool; }
+ * }
+ * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops
+ *
+ * @see jasmine.createSpy
+ * @param obj
+ * @param methodName
+ * @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
+ */
+var spyOn = function(obj, methodName) {
+ return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
+};
+if (isCommonJS) exports.spyOn = spyOn;
+
+/**
+ * Creates a Jasmine spec that will be added to the current suite.
+ *
+ * // TODO: pending tests
+ *
+ * @example
+ * it('should be true', function() {
+ * expect(true).toEqual(true);
+ * });
+ *
+ * @param {String} desc description of this specification
+ * @param {Function} func defines the preconditions and expectations of the spec
+ */
+var it = function(desc, func) {
+ return jasmine.getEnv().it(desc, func);
+};
+if (isCommonJS) exports.it = it;
+
+/**
+ * Creates a <em>disabled</em> Jasmine spec.
+ *
+ * A convenience method that allows existing specs to be disabled temporarily during development.
+ *
+ * @param {String} desc description of this specification
+ * @param {Function} func defines the preconditions and expectations of the spec
+ */
+var xit = function(desc, func) {
+ return jasmine.getEnv().xit(desc, func);
+};
+if (isCommonJS) exports.xit = xit;
+
+/**
+ * Starts a chain for a Jasmine expectation.
+ *
+ * It is passed an Object that is the actual value and should chain to one of the many
+ * jasmine.Matchers functions.
+ *
+ * @param {Object} actual Actual value to test against and expected value
+ * @return {jasmine.Matchers}
+ */
+var expect = function(actual) {
+ return jasmine.getEnv().currentSpec.expect(actual);
+};
+if (isCommonJS) exports.expect = expect;
+
+/**
+ * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
+ *
+ * @param {Function} func Function that defines part of a jasmine spec.
+ */
+var runs = function(func) {
+ jasmine.getEnv().currentSpec.runs(func);
+};
+if (isCommonJS) exports.runs = runs;
+
+/**
+ * Waits a fixed time period before moving to the next block.
+ *
+ * @deprecated Use waitsFor() instead
+ * @param {Number} timeout milliseconds to wait
+ */
+var waits = function(timeout) {
+ jasmine.getEnv().currentSpec.waits(timeout);
+};
+if (isCommonJS) exports.waits = waits;
+
+/**
+ * Waits for the latchFunction to return true before proceeding to the next block.
+ *
+ * @param {Function} latchFunction
+ * @param {String} optional_timeoutMessage
+ * @param {Number} optional_timeout
+ */
+var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
+ jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
+};
+if (isCommonJS) exports.waitsFor = waitsFor;
+
+/**
+ * A function that is called before each spec in a suite.
+ *
+ * Used for spec setup, including validating assumptions.
+ *
+ * @param {Function} beforeEachFunction
+ */
+var beforeEach = function(beforeEachFunction) {
+ jasmine.getEnv().beforeEach(beforeEachFunction);
+};
+if (isCommonJS) exports.beforeEach = beforeEach;
+
+/**
+ * A function that is called after each spec in a suite.
+ *
+ * Used for restoring any state that is hijacked during spec execution.
+ *
+ * @param {Function} afterEachFunction
+ */
+var afterEach = function(afterEachFunction) {
+ jasmine.getEnv().afterEach(afterEachFunction);
+};
+if (isCommonJS) exports.afterEach = afterEach;
+
+/**
+ * Defines a suite of specifications.
+ *
+ * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared
+ * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization
+ * of setup in some tests.
+ *
+ * @example
+ * // TODO: a simple suite
+ *
+ * // TODO: a simple suite with a nested describe block
+ *
+ * @param {String} description A string, usually the class under test.
+ * @param {Function} specDefinitions function that defines several specs.
+ */
+var describe = function(description, specDefinitions) {
+ return jasmine.getEnv().describe(description, specDefinitions);
+};
+if (isCommonJS) exports.describe = describe;
+
+/**
+ * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
+ *
+ * @param {String} description A string, usually the class under test.
+ * @param {Function} specDefinitions function that defines several specs.
+ */
+var xdescribe = function(description, specDefinitions) {
+ return jasmine.getEnv().xdescribe(description, specDefinitions);
+};
+if (isCommonJS) exports.xdescribe = xdescribe;
+
+
+// Provide the XMLHttpRequest class for IE 5.x-6.x:
+jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
+ function tryIt(f) {
+ try {
+ return f();
+ } catch(e) {
+ }
+ return null;
+ }
+
+ var xhr = tryIt(function() {
+ return new ActiveXObject("Msxml2.XMLHTTP.6.0");
+ }) ||
+ tryIt(function() {
+ return new ActiveXObject("Msxml2.XMLHTTP.3.0");
+ }) ||
+ tryIt(function() {
+ return new ActiveXObject("Msxml2.XMLHTTP");
+ }) ||
+ tryIt(function() {
+ return new ActiveXObject("Microsoft.XMLHTTP");
+ });
+
+ if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
+
+ return xhr;
+} : XMLHttpRequest;
+/**
+ * @namespace
+ */
+jasmine.util = {};
+
+/**
+ * Declare that a child class inherit it's prototype from the parent class.
+ *
+ * @private
+ * @param {Function} childClass
+ * @param {Function} parentClass
+ */
+jasmine.util.inherit = function(childClass, parentClass) {
+ /**
+ * @private
+ */
+ var subclass = function() {
+ };
+ subclass.prototype = parentClass.prototype;
+ childClass.prototype = new subclass();
+};
+
+jasmine.util.formatException = function(e) {
+ var lineNumber;
+ if (e.line) {
+ lineNumber = e.line;
+ }
+ else if (e.lineNumber) {
+ lineNumber = e.lineNumber;
+ }
+
+ var file;
+
+ if (e.sourceURL) {
+ file = e.sourceURL;
+ }
+ else if (e.fileName) {
+ file = e.fileName;
+ }
+
+ var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
+
+ if (file && lineNumber) {
+ message += ' in ' + file + ' (line ' + lineNumber + ')';
+ }
+
+ return message;
+};
+
+jasmine.util.htmlEscape = function(str) {
+ if (!str) return str;
+ return str.replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;');
+};
+
+jasmine.util.argsToArray = function(args) {
+ var arrayOfArgs = [];
+ for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
+ return arrayOfArgs;
+};
+
+jasmine.util.extend = function(destination, source) {
+ for (var property in source) destination[property] = source[property];
+ return destination;
+};
+
+/**
+ * Environment for Jasmine
+ *
+ * @constructor
+ */
+jasmine.Env = function() {
+ this.currentSpec = null;
+ this.currentSuite = null;
+ this.currentRunner_ = new jasmine.Runner(this);
+
+ this.reporter = new jasmine.MultiReporter();
+
+ this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
+ this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;
+ this.lastUpdate = 0;
+ this.specFilter = function() {
+ return true;
+ };
+
+ this.nextSpecId_ = 0;
+ this.nextSuiteId_ = 0;
+ this.equalityTesters_ = [];
+
+ // wrap matchers
+ this.matchersClass = function() {
+ jasmine.Matchers.apply(this, arguments);
+ };
+ jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
+
+ jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
+};
+
+
+jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
+jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
+jasmine.Env.prototype.setInterval = jasmine.setInterval;
+jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
+
+/**
+ * @returns an object containing jasmine version build info, if set.
+ */
+jasmine.Env.prototype.version = function () {
+ if (jasmine.version_) {
+ return jasmine.version_;
+ } else {
+ throw new Error('Version not set');
+ }
+};
+
+/**
+ * @returns string containing jasmine version build info, if set.
+ */
+jasmine.Env.prototype.versionString = function() {
+ if (!jasmine.version_) {
+ return "version unknown";
+ }
+
+ var version = this.version();
+ var versionString = version.major + "." + version.minor + "." + version.build;
+ if (version.release_candidate) {
+ versionString += ".rc" + version.release_candidate;
+ }
+ versionString += " revision " + version.revision;
+ return versionString;
+};
+
+/**
+ * @returns a sequential integer starting at 0
+ */
+jasmine.Env.prototype.nextSpecId = function () {
+ return this.nextSpecId_++;
+};
+
+/**
+ * @returns a sequential integer starting at 0
+ */
+jasmine.Env.prototype.nextSuiteId = function () {
+ return this.nextSuiteId_++;
+};
+
+/**
+ * Register a reporter to receive status updates from Jasmine.
+ * @param {jasmine.Reporter} reporter An object which will receive status updates.
+ */
+jasmine.Env.prototype.addReporter = function(reporter) {
+ this.reporter.addReporter(reporter);
+};
+
+jasmine.Env.prototype.execute = function() {
+ this.currentRunner_.execute();
+};
+
+jasmine.Env.prototype.describe = function(description, specDefinitions) {
+ var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
+
+ var parentSuite = this.currentSuite;
+ if (parentSuite) {
+ parentSuite.add(suite);
+ } else {
+ this.currentRunner_.add(suite);
+ }
+
+ this.currentSuite = suite;
+
+ var declarationError = null;
+ try {
+ specDefinitions.call(suite);
+ } catch(e) {
+ declarationError = e;
+ }
+
+ if (declarationError) {
+ this.it("encountered a declaration exception", function() {
+ throw declarationError;
+ });
+ }
+
+ this.currentSuite = parentSuite;
+
+ return suite;
+};
+
+jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
+ if (this.currentSuite) {
+ this.currentSuite.beforeEach(beforeEachFunction);
+ } else {
+ this.currentRunner_.beforeEach(beforeEachFunction);
+ }
+};
+
+jasmine.Env.prototype.currentRunner = function () {
+ return this.currentRunner_;
+};
+
+jasmine.Env.prototype.afterEach = function(afterEachFunction) {
+ if (this.currentSuite) {
+ this.currentSuite.afterEach(afterEachFunction);
+ } else {
+ this.currentRunner_.afterEach(afterEachFunction);
+ }
+
+};
+
+jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
+ return {
+ execute: function() {
+ }
+ };
+};
+
+jasmine.Env.prototype.it = function(description, func) {
+ var spec = new jasmine.Spec(this, this.currentSuite, description);
+ this.currentSuite.add(spec);
+ this.currentSpec = spec;
+
+ if (func) {
+ spec.runs(func);
+ }
+
+ return spec;
+};
+
+jasmine.Env.prototype.xit = function(desc, func) {
+ return {
+ id: this.nextSpecId(),
+ runs: function() {
+ }
+ };
+};
+
+jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
+ if (a.source != b.source)
+ mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
+
+ if (a.ignoreCase != b.ignoreCase)
+ mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
+
+ if (a.global != b.global)
+ mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
+
+ if (a.multiline != b.multiline)
+ mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
+
+ if (a.sticky != b.sticky)
+ mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
+
+ return (mismatchValues.length === 0);
+};
+
+jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
+ if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
+ return true;
+ }
+
+ a.__Jasmine_been_here_before__ = b;
+ b.__Jasmine_been_here_before__ = a;
+
+ var hasKey = function(obj, keyName) {
+ return obj !== null && obj[keyName] !== jasmine.undefined;
+ };
+
+ for (var property in b) {
+ if (!hasKey(a, property) && hasKey(b, property)) {
+ mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
+ }
+ }
+ for (property in a) {
+ if (!hasKey(b, property) && hasKey(a, property)) {
+ mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
+ }
+ }
+ for (property in b) {
+ if (property == '__Jasmine_been_here_before__') continue;
+ if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
+ mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
+ }
+ }
+
+ if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
+ mismatchValues.push("arrays were not the same length");
+ }
+
+ delete a.__Jasmine_been_here_before__;
+ delete b.__Jasmine_been_here_before__;
+ return (mismatchKeys.length === 0 && mismatchValues.length === 0);
+};
+
+jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
+ mismatchKeys = mismatchKeys || [];
+ mismatchValues = mismatchValues || [];
+
+ for (var i = 0; i < this.equalityTesters_.length; i++) {
+ var equalityTester = this.equalityTesters_[i];
+ var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
+ if (result !== jasmine.undefined) return result;
+ }
+
+ if (a === b) return true;
+
+ if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
+ return (a == jasmine.undefined && b == jasmine.undefined);
+ }
+
+ if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
+ return a === b;
+ }
+
+ if (a instanceof Date && b instanceof Date) {
+ return a.getTime() == b.getTime();
+ }
+
+ if (a.jasmineMatches) {
+ return a.jasmineMatches(b);
+ }
+
+ if (b.jasmineMatches) {
+ return b.jasmineMatches(a);
+ }
+
+ if (a instanceof jasmine.Matchers.ObjectContaining) {
+ return a.matches(b);
+ }
+
+ if (b instanceof jasmine.Matchers.ObjectContaining) {
+ return b.matches(a);
+ }
+
+ if (jasmine.isString_(a) && jasmine.isString_(b)) {
+ return (a == b);
+ }
+
+ if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
+ return (a == b);
+ }
+
+ if (a instanceof RegExp && b instanceof RegExp) {
+ return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
+ }
+
+ if (typeof a === "object" && typeof b === "object") {
+ return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
+ }
+
+ //Straight check
+ return (a === b);
+};
+
+jasmine.Env.prototype.contains_ = function(haystack, needle) {
+ if (jasmine.isArray_(haystack)) {
+ for (var i = 0; i < haystack.length; i++) {
+ if (this.equals_(haystack[i], needle)) return true;
+ }
+ return false;
+ }
+ return haystack.indexOf(needle) >= 0;
+};
+
+jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
+ this.equalityTesters_.push(equalityTester);
+};
+/** No-op base class for Jasmine reporters.
+ *
+ * @constructor
+ */
+jasmine.Reporter = function() {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportSpecResults = function(spec) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.log = function(str) {
+};
+
+/**
+ * Blocks are functions with executable code that make up a spec.
+ *
+ * @constructor
+ * @param {jasmine.Env} env
+ * @param {Function} func
+ * @param {jasmine.Spec} spec
+ */
+jasmine.Block = function(env, func, spec) {
+ this.env = env;
+ this.func = func;
+ this.spec = spec;
+};
+
+jasmine.Block.prototype.execute = function(onComplete) {
+ if (!jasmine.CATCH_EXCEPTIONS) {
+ this.func.apply(this.spec);
+ }
+ else {
+ try {
+ this.func.apply(this.spec);
+ } catch (e) {
+ this.spec.fail(e);
+ }
+ }
+ onComplete();
+};
+/** JavaScript API reporter.
+ *
+ * @constructor
+ */
+jasmine.JsApiReporter = function() {
+ this.started = false;
+ this.finished = false;
+ this.suites_ = [];
+ this.results_ = {};
+};
+
+jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
+ this.started = true;
+ var suites = runner.topLevelSuites();
+ for (var i = 0; i < suites.length; i++) {
+ var suite = suites[i];
+ this.suites_.push(this.summarize_(suite));
+ }
+};
+
+jasmine.JsApiReporter.prototype.suites = function() {
+ return this.suites_;
+};
+
+jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
+ var isSuite = suiteOrSpec instanceof jasmine.Suite;
+ var summary = {
+ id: suiteOrSpec.id,
+ name: suiteOrSpec.description,
+ type: isSuite ? 'suite' : 'spec',
+ children: []
+ };
+
+ if (isSuite) {
+ var children = suiteOrSpec.children();
+ for (var i = 0; i < children.length; i++) {
+ summary.children.push(this.summarize_(children[i]));
+ }
+ }
+ return summary;
+};
+
+jasmine.JsApiReporter.prototype.results = function() {
+ return this.results_;
+};
+
+jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
+ return this.results_[specId];
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
+ this.finished = true;
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
+ this.results_[spec.id] = {
+ messages: spec.results().getItems(),
+ result: spec.results().failedCount > 0 ? "failed" : "passed"
+ };
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.log = function(str) {
+};
+
+jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
+ var results = {};
+ for (var i = 0; i < specIds.length; i++) {
+ var specId = specIds[i];
+ results[specId] = this.summarizeResult_(this.results_[specId]);
+ }
+ return results;
+};
+
+jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
+ var summaryMessages = [];
+ var messagesLength = result.messages.length;
+ for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
+ var resultMessage = result.messages[messageIndex];
+ summaryMessages.push({
+ text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,
+ passed: resultMessage.passed ? resultMessage.passed() : true,
+ type: resultMessage.type,
+ message: resultMessage.message,
+ trace: {
+ stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
+ }
+ });
+ }
+
+ return {
+ result : result.result,
+ messages : summaryMessages
+ };
+};
+
+/**
+ * @constructor
+ * @param {jasmine.Env} env
+ * @param actual
+ * @param {jasmine.Spec} spec
+ */
+jasmine.Matchers = function(env, actual, spec, opt_isNot) {
+ this.env = env;
+ this.actual = actual;
+ this.spec = spec;
+ this.isNot = opt_isNot || false;
+ this.reportWasCalled_ = false;
+};
+
+// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
+jasmine.Matchers.pp = function(str) {
+ throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
+};
+
+// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw]
+jasmine.Matchers.prototype.report = function(result, failing_message, details) {
+ throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
+};
+
+jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
+ for (var methodName in prototype) {
+ if (methodName == 'report') continue;
+ var orig = prototype[methodName];
+ matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
+ }
+};
+
+jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
+ return function() {
+ var matcherArgs = jasmine.util.argsToArray(arguments);
+ var result = matcherFunction.apply(this, arguments);
+
+ if (this.isNot) {
+ result = !result;
+ }
+
+ if (this.reportWasCalled_) return result;
+
+ var message;
+ if (!result) {
+ if (this.message) {
+ message = this.message.apply(this, arguments);
+ if (jasmine.isArray_(message)) {
+ message = message[this.isNot ? 1 : 0];
+ }
+ } else {
+ var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
+ message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
+ if (matcherArgs.length > 0) {
+ for (var i = 0; i < matcherArgs.length; i++) {
+ if (i > 0) message += ",";
+ message += " " + jasmine.pp(matcherArgs[i]);
+ }
+ }
+ message += ".";
+ }
+ }
+ var expectationResult = new jasmine.ExpectationResult({
+ matcherName: matcherName,
+ passed: result,
+ expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
+ actual: this.actual,
+ message: message
+ });
+ this.spec.addMatcherResult(expectationResult);
+ return jasmine.undefined;
+ };
+};
+
+
+
+
+/**
+ * toBe: compares the actual to the expected using ===
+ * @param expected
+ */
+jasmine.Matchers.prototype.toBe = function(expected) {
+ return this.actual === expected;
+};
+
+/**
+ * toNotBe: compares the actual to the expected using !==
+ * @param expected
+ * @deprecated as of 1.0. Use not.toBe() instead.
+ */
+jasmine.Matchers.prototype.toNotBe = function(expected) {
+ return this.actual !== expected;
+};
+
+/**
+ * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
+ *
+ * @param expected
+ */
+jasmine.Matchers.prototype.toEqual = function(expected) {
+ return this.env.equals_(this.actual, expected);
+};
+
+/**
+ * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
+ * @param expected
+ * @deprecated as of 1.0. Use not.toEqual() instead.
+ */
+jasmine.Matchers.prototype.toNotEqual = function(expected) {
+ return !this.env.equals_(this.actual, expected);
+};
+
+/**
+ * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
+ * a pattern or a String.
+ *
+ * @param expected
+ */
+jasmine.Matchers.prototype.toMatch = function(expected) {
+ return new RegExp(expected).test(this.actual);
+};
+
+/**
+ * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
+ * @param expected
+ * @deprecated as of 1.0. Use not.toMatch() instead.
+ */
+jasmine.Matchers.prototype.toNotMatch = function(expected) {
+ return !(new RegExp(expected).test(this.actual));
+};
+
+/**
+ * Matcher that compares the actual to jasmine.undefined.
+ */
+jasmine.Matchers.prototype.toBeDefined = function() {
+ return (this.actual !== jasmine.undefined);
+};
+
+/**
+ * Matcher that compares the actual to jasmine.undefined.
+ */
+jasmine.Matchers.prototype.toBeUndefined = function() {
+ return (this.actual === jasmine.undefined);
+};
+
+/**
+ * Matcher that compares the actual to null.
+ */
+jasmine.Matchers.prototype.toBeNull = function() {
+ return (this.actual === null);
+};
+
+/**
+ * Matcher that compares the actual to NaN.
+ */
+jasmine.Matchers.prototype.toBeNaN = function() {
+ this.message = function() {
+ return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
+ };
+
+ return (this.actual !== this.actual);
+};
+
+/**
+ * Matcher that boolean not-nots the actual.
+ */
+jasmine.Matchers.prototype.toBeTruthy = function() {
+ return !!this.actual;
+};
+
+
+/**
+ * Matcher that boolean nots the actual.
+ */
+jasmine.Matchers.prototype.toBeFalsy = function() {
+ return !this.actual;
+};
+
+
+/**
+ * Matcher that checks to see if the actual, a Jasmine spy, was called.
+ */
+jasmine.Matchers.prototype.toHaveBeenCalled = function() {
+ if (arguments.length > 0) {
+ throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
+ }
+
+ if (!jasmine.isSpy(this.actual)) {
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
+ }
+
+ this.message = function() {
+ return [
+ "Expected spy " + this.actual.identity + " to have been called.",
+ "Expected spy " + this.actual.identity + " not to have been called."
+ ];
+ };
+
+ return this.actual.wasCalled;
+};
+
+/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */
+jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled;
+
+/**
+ * Matcher that checks to see if the actual, a Jasmine spy, was not called.
+ *
+ * @deprecated Use expect(xxx).not.toHaveBeenCalled() instead
+ */
+jasmine.Matchers.prototype.wasNotCalled = function() {
+ if (arguments.length > 0) {
+ throw new Error('wasNotCalled does not take arguments');
+ }
+
+ if (!jasmine.isSpy(this.actual)) {
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
+ }
+
+ this.message = function() {
+ return [
+ "Expected spy " + this.actual.identity + " to not have been called.",
+ "Expected spy " + this.actual.identity + " to have been called."
+ ];
+ };
+
+ return !this.actual.wasCalled;
+};
+
+/**
+ * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
+ *
+ * @example
+ *
+ */
+jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
+ var expectedArgs = jasmine.util.argsToArray(arguments);
+ if (!jasmine.isSpy(this.actual)) {
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
+ }
+ this.message = function() {
+ var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
+ var positiveMessage = "";
+ if (this.actual.callCount === 0) {
+ positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
+ } else {
+ positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
+ }
+ return [positiveMessage, invertedMessage];
+ };
+
+ return this.env.contains_(this.actual.argsForCall, expectedArgs);
+};
+
+/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */
+jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith;
+
+/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */
+jasmine.Matchers.prototype.wasNotCalledWith = function() {
+ var expectedArgs = jasmine.util.argsToArray(arguments);
+ if (!jasmine.isSpy(this.actual)) {
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
+ }
+
+ this.message = function() {
+ return [
+ "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
+ "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
+ ];
+ };
+
+ return !this.env.contains_(this.actual.argsForCall, expectedArgs);
+};
+
+/**
+ * Matcher that checks that the expected item is an element in the actual Array.
+ *
+ * @param {Object} expected
+ */
+jasmine.Matchers.prototype.toContain = function(expected) {
+ return this.env.contains_(this.actual, expected);
+};
+
+/**
+ * Matcher that checks that the expected item is NOT an element in the actual Array.
+ *
+ * @param {Object} expected
+ * @deprecated as of 1.0. Use not.toContain() instead.
+ */
+jasmine.Matchers.prototype.toNotContain = function(expected) {
+ return !this.env.contains_(this.actual, expected);
+};
+
+jasmine.Matchers.prototype.toBeLessThan = function(expected) {
+ return this.actual < expected;
+};
+
+jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
+ return this.actual > expected;
+};
+
+/**
+ * Matcher that checks that the expected item is equal to the actual item
+ * up to a given level of decimal precision (default 2).
+ *
+ * @param {Number} expected
+ * @param {Number} precision, as number of decimal places
+ */
+jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
+ if (!(precision === 0)) {
+ precision = precision || 2;
+ }
+ return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2);
+};
+
+/**
+ * Matcher that checks that the expected exception was thrown by the actual.
+ *
+ * @param {String} [expected]
+ */
+jasmine.Matchers.prototype.toThrow = function(expected) {
+ var result = false;
+ var exception;
+ if (typeof this.actual != 'function') {
+ throw new Error('Actual is not a function');
+ }
+ try {
+ this.actual();
+ } catch (e) {
+ exception = e;
+ }
+ if (exception) {
+ result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
+ }
+
+ var not = this.isNot ? "not " : "";
+
+ this.message = function() {
+ if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
+ return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
+ } else {
+ return "Expected function to throw an exception.";
+ }
+ };
+
+ return result;
+};
+
+jasmine.Matchers.Any = function(expectedClass) {
+ this.expectedClass = expectedClass;
+};
+
+jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
+ if (this.expectedClass == String) {
+ return typeof other == 'string' || other instanceof String;
+ }
+
+ if (this.expectedClass == Number) {
+ return typeof other == 'number' || other instanceof Number;
+ }
+
+ if (this.expectedClass == Function) {
+ return typeof other == 'function' || other instanceof Function;
+ }
+
+ if (this.expectedClass == Object) {
+ return typeof other == 'object';
+ }
+
+ return other instanceof this.expectedClass;
+};
+
+jasmine.Matchers.Any.prototype.jasmineToString = function() {
+ return '<jasmine.any(' + this.expectedClass + ')>';
+};
+
+jasmine.Matchers.ObjectContaining = function (sample) {
+ this.sample = sample;
+};
+
+jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
+ mismatchKeys = mismatchKeys || [];
+ mismatchValues = mismatchValues || [];
+
+ var env = jasmine.getEnv();
+
+ var hasKey = function(obj, keyName) {
+ return obj != null && obj[keyName] !== jasmine.undefined;
+ };
+
+ for (var property in this.sample) {
+ if (!hasKey(other, property) && hasKey(this.sample, property)) {
+ mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
+ }
+ else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) {
+ mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual.");
+ }
+ }
+
+ return (mismatchKeys.length === 0 && mismatchValues.length === 0);
+};
+
+jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () {
+ return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>";
+};
+// Mock setTimeout, clearTimeout
+// Contributed by Pivotal Computer Systems, www.pivotalsf.com
+
+jasmine.FakeTimer = function() {
+ this.reset();
+
+ var self = this;
+ self.setTimeout = function(funcToCall, millis) {
+ self.timeoutsMade++;
+ self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
+ return self.timeoutsMade;
+ };
+
+ self.setInterval = function(funcToCall, millis) {
+ self.timeoutsMade++;
+ self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
+ return self.timeoutsMade;
+ };
+
+ self.clearTimeout = function(timeoutKey) {
+ self.scheduledFunctions[timeoutKey] = jasmine.undefined;
+ };
+
+ self.clearInterval = function(timeoutKey) {
+ self.scheduledFunctions[timeoutKey] = jasmine.undefined;
+ };
+
+};
+
+jasmine.FakeTimer.prototype.reset = function() {
+ this.timeoutsMade = 0;
+ this.scheduledFunctions = {};
+ this.nowMillis = 0;
+};
+
+jasmine.FakeTimer.prototype.tick = function(millis) {
+ var oldMillis = this.nowMillis;
+ var newMillis = oldMillis + millis;
+ this.runFunctionsWithinRange(oldMillis, newMillis);
+ this.nowMillis = newMillis;
+};
+
+jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
+ var scheduledFunc;
+ var funcsToRun = [];
+ for (var timeoutKey in this.scheduledFunctions) {
+ scheduledFunc = this.scheduledFunctions[timeoutKey];
+ if (scheduledFunc != jasmine.undefined &&
+ scheduledFunc.runAtMillis >= oldMillis &&
+ scheduledFunc.runAtMillis <= nowMillis) {
+ funcsToRun.push(scheduledFunc);
+ this.scheduledFunctions[timeoutKey] = jasmine.undefined;
+ }
+ }
+
+ if (funcsToRun.length > 0) {
+ funcsToRun.sort(function(a, b) {
+ return a.runAtMillis - b.runAtMillis;
+ });
+ for (var i = 0; i < funcsToRun.length; ++i) {
+ try {
+ var funcToRun = funcsToRun[i];
+ this.nowMillis = funcToRun.runAtMillis;
+ funcToRun.funcToCall();
+ if (funcToRun.recurring) {
+ this.scheduleFunction(funcToRun.timeoutKey,
+ funcToRun.funcToCall,
+ funcToRun.millis,
+ true);
+ }
+ } catch(e) {
+ }
+ }
+ this.runFunctionsWithinRange(oldMillis, nowMillis);
+ }
+};
+
+jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
+ this.scheduledFunctions[timeoutKey] = {
+ runAtMillis: this.nowMillis + millis,
+ funcToCall: funcToCall,
+ recurring: recurring,
+ timeoutKey: timeoutKey,
+ millis: millis
+ };
+};
+
+/**
+ * @namespace
+ */
+jasmine.Clock = {
+ defaultFakeTimer: new jasmine.FakeTimer(),
+
+ reset: function() {
+ jasmine.Clock.assertInstalled();
+ jasmine.Clock.defaultFakeTimer.reset();
+ },
+
+ tick: function(millis) {
+ jasmine.Clock.assertInstalled();
+ jasmine.Clock.defaultFakeTimer.tick(millis);
+ },
+
+ runFunctionsWithinRange: function(oldMillis, nowMillis) {
+ jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
+ },
+
+ scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
+ jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
+ },
+
+ useMock: function() {
+ if (!jasmine.Clock.isInstalled()) {
+ var spec = jasmine.getEnv().currentSpec;
+ spec.after(jasmine.Clock.uninstallMock);
+
+ jasmine.Clock.installMock();
+ }
+ },
+
+ installMock: function() {
+ jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
+ },
+
+ uninstallMock: function() {
+ jasmine.Clock.assertInstalled();
+ jasmine.Clock.installed = jasmine.Clock.real;
+ },
+
+ real: {
+ setTimeout: jasmine.getGlobal().setTimeout,
+ clearTimeout: jasmine.getGlobal().clearTimeout,
+ setInterval: jasmine.getGlobal().setInterval,
+ clearInterval: jasmine.getGlobal().clearInterval
+ },
+
+ assertInstalled: function() {
+ if (!jasmine.Clock.isInstalled()) {
+ throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
+ }
+ },
+
+ isInstalled: function() {
+ return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer;
+ },
+
+ installed: null
+};
+jasmine.Clock.installed = jasmine.Clock.real;
+
+//else for IE support
+jasmine.getGlobal().setTimeout = function(funcToCall, millis) {
+ if (jasmine.Clock.installed.setTimeout.apply) {
+ return jasmine.Clock.installed.setTimeout.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.setTimeout(funcToCall, millis);
+ }
+};
+
+jasmine.getGlobal().setInterval = function(funcToCall, millis) {
+ if (jasmine.Clock.installed.setInterval.apply) {
+ return jasmine.Clock.installed.setInterval.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.setInterval(funcToCall, millis);
+ }
+};
+
+jasmine.getGlobal().clearTimeout = function(timeoutKey) {
+ if (jasmine.Clock.installed.clearTimeout.apply) {
+ return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.clearTimeout(timeoutKey);
+ }
+};
+
+jasmine.getGlobal().clearInterval = function(timeoutKey) {
+ if (jasmine.Clock.installed.clearTimeout.apply) {
+ return jasmine.Clock.installed.clearInterval.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.clearInterval(timeoutKey);
+ }
+};
+
+/**
+ * @constructor
+ */
+jasmine.MultiReporter = function() {
+ this.subReporters_ = [];
+};
+jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);
+
+jasmine.MultiReporter.prototype.addReporter = function(reporter) {
+ this.subReporters_.push(reporter);
+};
+
+(function() {
+ var functionNames = [
+ "reportRunnerStarting",
+ "reportRunnerResults",
+ "reportSuiteResults",
+ "reportSpecStarting",
+ "reportSpecResults",
+ "log"
+ ];
+ for (var i = 0; i < functionNames.length; i++) {
+ var functionName = functionNames[i];
+ jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
+ return function() {
+ for (var j = 0; j < this.subReporters_.length; j++) {
+ var subReporter = this.subReporters_[j];
+ if (subReporter[functionName]) {
+ subReporter[functionName].apply(subReporter, arguments);
+ }
+ }
+ };
+ })(functionName);
+ }
+})();
+/**
+ * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
+ *
+ * @constructor
+ */
+jasmine.NestedResults = function() {
+ /**
+ * The total count of results
+ */
+ this.totalCount = 0;
+ /**
+ * Number of passed results
+ */
+ this.passedCount = 0;
+ /**
+ * Number of failed results
+ */
+ this.failedCount = 0;
+ /**
+ * Was this suite/spec skipped?
+ */
+ this.skipped = false;
+ /**
+ * @ignore
+ */
+ this.items_ = [];
+};
+
+/**
+ * Roll up the result counts.
+ *
+ * @param result
+ */
+jasmine.NestedResults.prototype.rollupCounts = function(result) {
+ this.totalCount += result.totalCount;
+ this.passedCount += result.passedCount;
+ this.failedCount += result.failedCount;
+};
+
+/**
+ * Adds a log message.
+ * @param values Array of message parts which will be concatenated later.
+ */
+jasmine.NestedResults.prototype.log = function(values) {
+ this.items_.push(new jasmine.MessageResult(values));
+};
+
+/**
+ * Getter for the results: message & results.
+ */
+jasmine.NestedResults.prototype.getItems = function() {
+ return this.items_;
+};
+
+/**
+ * Adds a result, tracking counts (total, passed, & failed)
+ * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
+ */
+jasmine.NestedResults.prototype.addResult = function(result) {
+ if (result.type != 'log') {
+ if (result.items_) {
+ this.rollupCounts(result);
+ } else {
+ this.totalCount++;
+ if (result.passed()) {
+ this.passedCount++;
+ } else {
+ this.failedCount++;
+ }
+ }
+ }
+ this.items_.push(result);
+};
+
+/**
+ * @returns {Boolean} True if <b>everything</b> below passed
+ */
+jasmine.NestedResults.prototype.passed = function() {
+ return this.passedCount === this.totalCount;
+};
+/**
+ * Base class for pretty printing for expectation results.
+ */
+jasmine.PrettyPrinter = function() {
+ this.ppNestLevel_ = 0;
+};
+
+/**
+ * Formats a value in a nice, human-readable string.
+ *
+ * @param value
+ */
+jasmine.PrettyPrinter.prototype.format = function(value) {
+ this.ppNestLevel_++;
+ try {
+ if (value === jasmine.undefined) {
+ this.emitScalar('undefined');
+ } else if (value === null) {
+ this.emitScalar('null');
+ } else if (value === jasmine.getGlobal()) {
+ this.emitScalar('<global>');
+ } else if (value.jasmineToString) {
+ this.emitScalar(value.jasmineToString());
+ } else if (typeof value === 'string') {
+ this.emitString(value);
+ } else if (jasmine.isSpy(value)) {
+ this.emitScalar("spy on " + value.identity);
+ } else if (value instanceof RegExp) {
+ this.emitScalar(value.toString());
+ } else if (typeof value === 'function') {
+ this.emitScalar('Function');
+ } else if (typeof value.nodeType === 'number') {
+ this.emitScalar('HTMLNode');
+ } else if (value instanceof Date) {
+ this.emitScalar('Date(' + value + ')');
+ } else if (value.__Jasmine_been_here_before__) {
+ this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
+ } else if (jasmine.isArray_(value) || typeof value == 'object') {
+ value.__Jasmine_been_here_before__ = true;
+ if (jasmine.isArray_(value)) {
+ this.emitArray(value);
+ } else {
+ this.emitObject(value);
+ }
+ delete value.__Jasmine_been_here_before__;
+ } else {
+ this.emitScalar(value.toString());
+ }
+ } finally {
+ this.ppNestLevel_--;
+ }
+};
+
+jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
+ for (var property in obj) {
+ if (!obj.hasOwnProperty(property)) continue;
+ if (property == '__Jasmine_been_here_before__') continue;
+ fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
+ obj.__lookupGetter__(property) !== null) : false);
+ }
+};
+
+jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
+jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
+jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
+jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
+
+jasmine.StringPrettyPrinter = function() {
+ jasmine.PrettyPrinter.call(this);
+
+ this.string = '';
+};
+jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);
+
+jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
+ this.append(value);
+};
+
+jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
+ this.append("'" + value + "'");
+};
+
+jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
+ if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
+ this.append("Array");
+ return;
+ }
+
+ this.append('[ ');
+ for (var i = 0; i < array.length; i++) {
+ if (i > 0) {
+ this.append(', ');
+ }
+ this.format(array[i]);
+ }
+ this.append(' ]');
+};
+
+jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
+ if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
+ this.append("Object");
+ return;
+ }
+
+ var self = this;
+ this.append('{ ');
+ var first = true;
+
+ this.iterateObject(obj, function(property, isGetter) {
+ if (first) {
+ first = false;
+ } else {
+ self.append(', ');
+ }
+
+ self.append(property);
+ self.append(' : ');
+ if (isGetter) {
+ self.append('<getter>');
+ } else {
+ self.format(obj[property]);
+ }
+ });
+
+ this.append(' }');
+};
+
+jasmine.StringPrettyPrinter.prototype.append = function(value) {
+ this.string += value;
+};
+jasmine.Queue = function(env) {
+ this.env = env;
+
+ // parallel to blocks. each true value in this array means the block will
+ // get executed even if we abort
+ this.ensured = [];
+ this.blocks = [];
+ this.running = false;
+ this.index = 0;
+ this.offset = 0;
+ this.abort = false;
+};
+
+jasmine.Queue.prototype.addBefore = function(block, ensure) {
+ if (ensure === jasmine.undefined) {
+ ensure = false;
+ }
+
+ this.blocks.unshift(block);
+ this.ensured.unshift(ensure);
+};
+
+jasmine.Queue.prototype.add = function(block, ensure) {
+ if (ensure === jasmine.undefined) {
+ ensure = false;
+ }
+
+ this.blocks.push(block);
+ this.ensured.push(ensure);
+};
+
+jasmine.Queue.prototype.insertNext = function(block, ensure) {
+ if (ensure === jasmine.undefined) {
+ ensure = false;
+ }
+
+ this.ensured.splice((this.index + this.offset + 1), 0, ensure);
+ this.blocks.splice((this.index + this.offset + 1), 0, block);
+ this.offset++;
+};
+
+jasmine.Queue.prototype.start = function(onComplete) {
+ this.running = true;
+ this.onComplete = onComplete;
+ this.next_();
+};
+
+jasmine.Queue.prototype.isRunning = function() {
+ return this.running;
+};
+
+jasmine.Queue.LOOP_DONT_RECURSE = true;
+
+jasmine.Queue.prototype.next_ = function() {
+ var self = this;
+ var goAgain = true;
+
+ while (goAgain) {
+ goAgain = false;
+
+ if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
+ var calledSynchronously = true;
+ var completedSynchronously = false;
+
+ var onComplete = function () {
+ if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
+ completedSynchronously = true;
+ return;
+ }
+
+ if (self.blocks[self.index].abort) {
+ self.abort = true;
+ }
+
+ self.offset = 0;
+ self.index++;
+
+ var now = new Date().getTime();
+ if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
+ self.env.lastUpdate = now;
+ self.env.setTimeout(function() {
+ self.next_();
+ }, 0);
+ } else {
+ if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
+ goAgain = true;
+ } else {
+ self.next_();
+ }
+ }
+ };
+ self.blocks[self.index].execute(onComplete);
+
+ calledSynchronously = false;
+ if (completedSynchronously) {
+ onComplete();
+ }
+
+ } else {
+ self.running = false;
+ if (self.onComplete) {
+ self.onComplete();
+ }
+ }
+ }
+};
+
+jasmine.Queue.prototype.results = function() {
+ var results = new jasmine.NestedResults();
+ for (var i = 0; i < this.blocks.length; i++) {
+ if (this.blocks[i].results) {
+ results.addResult(this.blocks[i].results());
+ }
+ }
+ return results;
+};
+
+
+/**
+ * Runner
+ *
+ * @constructor
+ * @param {jasmine.Env} env
+ */
+jasmine.Runner = function(env) {
+ var self = this;
+ self.env = env;
+ self.queue = new jasmine.Queue(env);
+ self.before_ = [];
+ self.after_ = [];
+ self.suites_ = [];
+};
+
+jasmine.Runner.prototype.execute = function() {
+ var self = this;
+ if (self.env.reporter.reportRunnerStarting) {
+ self.env.reporter.reportRunnerStarting(this);
+ }
+ self.queue.start(function () {
+ self.finishCallback();
+ });
+};
+
+jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
+ beforeEachFunction.typeName = 'beforeEach';
+ this.before_.splice(0,0,beforeEachFunction);
+};
+
+jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
+ afterEachFunction.typeName = 'afterEach';
+ this.after_.splice(0,0,afterEachFunction);
+};
+
+
+jasmine.Runner.prototype.finishCallback = function() {
+ this.env.reporter.reportRunnerResults(this);
+};
+
+jasmine.Runner.prototype.addSuite = function(suite) {
+ this.suites_.push(suite);
+};
+
+jasmine.Runner.prototype.add = function(block) {
+ if (block instanceof jasmine.Suite) {
+ this.addSuite(block);
+ }
+ this.queue.add(block);
+};
+
+jasmine.Runner.prototype.specs = function () {
+ var suites = this.suites();
+ var specs = [];
+ for (var i = 0; i < suites.length; i++) {
+ specs = specs.concat(suites[i].specs());
+ }
+ return specs;
+};
+
+jasmine.Runner.prototype.suites = function() {
+ return this.suites_;
+};
+
+jasmine.Runner.prototype.topLevelSuites = function() {
+ var topLevelSuites = [];
+ for (var i = 0; i < this.suites_.length; i++) {
+ if (!this.suites_[i].parentSuite) {
+ topLevelSuites.push(this.suites_[i]);
+ }
+ }
+ return topLevelSuites;
+};
+
+jasmine.Runner.prototype.results = function() {
+ return this.queue.results();
+};
+/**
+ * Internal representation of a Jasmine specification, or test.
+ *
+ * @constructor
+ * @param {jasmine.Env} env
+ * @param {jasmine.Suite} suite
+ * @param {String} description
+ */
+jasmine.Spec = function(env, suite, description) {
+ if (!env) {
+ throw new Error('jasmine.Env() required');
+ }
+ if (!suite) {
+ throw new Error('jasmine.Suite() required');
+ }
+ var spec = this;
+ spec.id = env.nextSpecId ? env.nextSpecId() : null;
+ spec.env = env;
+ spec.suite = suite;
+ spec.description = description;
+ spec.queue = new jasmine.Queue(env);
+
+ spec.afterCallbacks = [];
+ spec.spies_ = [];
+
+ spec.results_ = new jasmine.NestedResults();
+ spec.results_.description = description;
+ spec.matchersClass = null;
+};
+
+jasmine.Spec.prototype.getFullName = function() {
+ return this.suite.getFullName() + ' ' + this.description + '.';
+};
+
+
+jasmine.Spec.prototype.results = function() {
+ return this.results_;
+};
+
+/**
+ * All parameters are pretty-printed and concatenated together, then written to the spec's output.
+ *
+ * Be careful not to leave calls to <code>jasmine.log</code> in production code.
+ */
+jasmine.Spec.prototype.log = function() {
+ return this.results_.log(arguments);
+};
+
+jasmine.Spec.prototype.runs = function (func) {
+ var block = new jasmine.Block(this.env, func, this);
+ this.addToQueue(block);
+ return this;
+};
+
+jasmine.Spec.prototype.addToQueue = function (block) {
+ if (this.queue.isRunning()) {
+ this.queue.insertNext(block);
+ } else {
+ this.queue.add(block);
+ }
+};
+
+/**
+ * @param {jasmine.ExpectationResult} result
+ */
+jasmine.Spec.prototype.addMatcherResult = function(result) {
+ this.results_.addResult(result);
+};
+
+jasmine.Spec.prototype.expect = function(actual) {
+ var positive = new (this.getMatchersClass_())(this.env, actual, this);
+ positive.not = new (this.getMatchersClass_())(this.env, actual, this, true);
+ return positive;
+};
+
+/**
+ * Waits a fixed time period before moving to the next block.
+ *
+ * @deprecated Use waitsFor() instead
+ * @param {Number} timeout milliseconds to wait
+ */
+jasmine.Spec.prototype.waits = function(timeout) {
+ var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
+ this.addToQueue(waitsFunc);
+ return this;
+};
+
+/**
+ * Waits for the latchFunction to return true before proceeding to the next block.
+ *
+ * @param {Function} latchFunction
+ * @param {String} optional_timeoutMessage
+ * @param {Number} optional_timeout
+ */
+jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
+ var latchFunction_ = null;
+ var optional_timeoutMessage_ = null;
+ var optional_timeout_ = null;
+
+ for (var i = 0; i < arguments.length; i++) {
+ var arg = arguments[i];
+ switch (typeof arg) {
+ case 'function':
+ latchFunction_ = arg;
+ break;
+ case 'string':
+ optional_timeoutMessage_ = arg;
+ break;
+ case 'number':
+ optional_timeout_ = arg;
+ break;
+ }
+ }
+
+ var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this);
+ this.addToQueue(waitsForFunc);
+ return this;
+};
+
+jasmine.Spec.prototype.fail = function (e) {
+ var expectationResult = new jasmine.ExpectationResult({
+ passed: false,
+ message: e ? jasmine.util.formatException(e) : 'Exception',
+ trace: { stack: e.stack }
+ });
+ this.results_.addResult(expectationResult);
+};
+
+jasmine.Spec.prototype.getMatchersClass_ = function() {
+ return this.matchersClass || this.env.matchersClass;
+};
+
+jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
+ var parent = this.getMatchersClass_();
+ var newMatchersClass = function() {
+ parent.apply(this, arguments);
+ };
+ jasmine.util.inherit(newMatchersClass, parent);
+ jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass);
+ this.matchersClass = newMatchersClass;
+};
+
+jasmine.Spec.prototype.finishCallback = function() {
+ this.env.reporter.reportSpecResults(this);
+};
+
+jasmine.Spec.prototype.finish = function(onComplete) {
+ this.removeAllSpies();
+ this.finishCallback();
+ if (onComplete) {
+ onComplete();
+ }
+};
+
+jasmine.Spec.prototype.after = function(doAfter) {
+ if (this.queue.isRunning()) {
+ this.queue.add(new jasmine.Block(this.env, doAfter, this), true);
+ } else {
+ this.afterCallbacks.unshift(doAfter);
+ }
+};
+
+jasmine.Spec.prototype.execute = function(onComplete) {
+ var spec = this;
+ if (!spec.env.specFilter(spec)) {
+ spec.results_.skipped = true;
+ spec.finish(onComplete);
+ return;
+ }
+
+ this.env.reporter.reportSpecStarting(this);
+
+ spec.env.currentSpec = spec;
+
+ spec.addBeforesAndAftersToQueue();
+
+ spec.queue.start(function () {
+ spec.finish(onComplete);
+ });
+};
+
+jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
+ var runner = this.env.currentRunner();
+ var i;
+
+ for (var suite = this.suite; suite; suite = suite.parentSuite) {
+ for (i = 0; i < suite.before_.length; i++) {
+ this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
+ }
+ }
+ for (i = 0; i < runner.before_.length; i++) {
+ this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
+ }
+ for (i = 0; i < this.afterCallbacks.length; i++) {
+ this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true);
+ }
+ for (suite = this.suite; suite; suite = suite.parentSuite) {
+ for (i = 0; i < suite.after_.length; i++) {
+ this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);
+ }
+ }
+ for (i = 0; i < runner.after_.length; i++) {
+ this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);
+ }
+};
+
+jasmine.Spec.prototype.explodes = function() {
+ throw 'explodes function should not have been called';
+};
+
+jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
+ if (obj == jasmine.undefined) {
+ throw "spyOn could not find an object to spy upon for " + methodName + "()";
+ }
+
+ if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
+ throw methodName + '() method does not exist';
+ }
+
+ if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {
+ throw new Error(methodName + ' has already been spied upon');
+ }
+
+ var spyObj = jasmine.createSpy(methodName);
+
+ this.spies_.push(spyObj);
+ spyObj.baseObj = obj;
+ spyObj.methodName = methodName;
+ spyObj.originalValue = obj[methodName];
+
+ obj[methodName] = spyObj;
+
+ return spyObj;
+};
+
+jasmine.Spec.prototype.removeAllSpies = function() {
+ for (var i = 0; i < this.spies_.length; i++) {
+ var spy = this.spies_[i];
+ spy.baseObj[spy.methodName] = spy.originalValue;
+ }
+ this.spies_ = [];
+};
+
+/**
+ * Internal representation of a Jasmine suite.
+ *
+ * @constructor
+ * @param {jasmine.Env} env
+ * @param {String} description
+ * @param {Function} specDefinitions
+ * @param {jasmine.Suite} parentSuite
+ */
+jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
+ var self = this;
+ self.id = env.nextSuiteId ? env.nextSuiteId() : null;
+ self.description = description;
+ self.queue = new jasmine.Queue(env);
+ self.parentSuite = parentSuite;
+ self.env = env;
+ self.before_ = [];
+ self.after_ = [];
+ self.children_ = [];
+ self.suites_ = [];
+ self.specs_ = [];
+};
+
+jasmine.Suite.prototype.getFullName = function() {
+ var fullName = this.description;
+ for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
+ fullName = parentSuite.description + ' ' + fullName;
+ }
+ return fullName;
+};
+
+jasmine.Suite.prototype.finish = function(onComplete) {
+ this.env.reporter.reportSuiteResults(this);
+ this.finished = true;
+ if (typeof(onComplete) == 'function') {
+ onComplete();
+ }
+};
+
+jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
+ beforeEachFunction.typeName = 'beforeEach';
+ this.before_.unshift(beforeEachFunction);
+};
+
+jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
+ afterEachFunction.typeName = 'afterEach';
+ this.after_.unshift(afterEachFunction);
+};
+
+jasmine.Suite.prototype.results = function() {
+ return this.queue.results();
+};
+
+jasmine.Suite.prototype.add = function(suiteOrSpec) {
+ this.children_.push(suiteOrSpec);
+ if (suiteOrSpec instanceof jasmine.Suite) {
+ this.suites_.push(suiteOrSpec);
+ this.env.currentRunner().addSuite(suiteOrSpec);
+ } else {
+ this.specs_.push(suiteOrSpec);
+ }
+ this.queue.add(suiteOrSpec);
+};
+
+jasmine.Suite.prototype.specs = function() {
+ return this.specs_;
+};
+
+jasmine.Suite.prototype.suites = function() {
+ return this.suites_;
+};
+
+jasmine.Suite.prototype.children = function() {
+ return this.children_;
+};
+
+jasmine.Suite.prototype.execute = function(onComplete) {
+ var self = this;
+ this.queue.start(function () {
+ self.finish(onComplete);
+ });
+};
+jasmine.WaitsBlock = function(env, timeout, spec) {
+ this.timeout = timeout;
+ jasmine.Block.call(this, env, null, spec);
+};
+
+jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
+
+jasmine.WaitsBlock.prototype.execute = function (onComplete) {
+ if (jasmine.VERBOSE) {
+ this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
+ }
+ this.env.setTimeout(function () {
+ onComplete();
+ }, this.timeout);
+};
+/**
+ * A block which waits for some condition to become true, with timeout.
+ *
+ * @constructor
+ * @extends jasmine.Block
+ * @param {jasmine.Env} env The Jasmine environment.
+ * @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true.
+ * @param {Function} latchFunction A function which returns true when the desired condition has been met.
+ * @param {String} message The message to display if the desired condition hasn't been met within the given time period.
+ * @param {jasmine.Spec} spec The Jasmine spec.
+ */
+jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
+ this.timeout = timeout || env.defaultTimeoutInterval;
+ this.latchFunction = latchFunction;
+ this.message = message;
+ this.totalTimeSpentWaitingForLatch = 0;
+ jasmine.Block.call(this, env, null, spec);
+};
+jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
+
+jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
+
+jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
+ if (jasmine.VERBOSE) {
+ this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
+ }
+ var latchFunctionResult;
+ try {
+ latchFunctionResult = this.latchFunction.apply(this.spec);
+ } catch (e) {
+ this.spec.fail(e);
+ onComplete();
+ return;
+ }
+
+ if (latchFunctionResult) {
+ onComplete();
+ } else if (this.totalTimeSpentWaitingForLatch >= this.timeout) {
+ var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen');
+ this.spec.fail({
+ name: 'timeout',
+ message: message
+ });
+
+ this.abort = true;
+ onComplete();
+ } else {
+ this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
+ var self = this;
+ this.env.setTimeout(function() {
+ self.execute(onComplete);
+ }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
+ }
+};
+
+jasmine.version_= {
+ "major": 1,
+ "minor": 3,
+ "build": 1,
+ "revision": 1354556913
+};
diff --git a/lib/jasmine-jquery.js b/lib/jasmine-jquery.js
new file mode 100644
index 0000000..3a5a028
--- /dev/null
+++ b/lib/jasmine-jquery.js
@@ -0,0 +1,659 @@
+/*!
+ Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
+
+ Version 1.5.2
+
+ https://github.com/velesin/jasmine-jquery
+
+ Copyright (c) 2010-2013 Wojciech Zawistowski, Travis Jeffery
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+var readFixtures = function() {
+ return jasmine.getFixtures().proxyCallTo_('read', arguments)
+}
+
+var preloadFixtures = function() {
+ jasmine.getFixtures().proxyCallTo_('preload', arguments)
+}
+
+var loadFixtures = function() {
+ jasmine.getFixtures().proxyCallTo_('load', arguments)
+}
+
+var appendLoadFixtures = function() {
+ jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
+}
+
+var setFixtures = function(html) {
+ jasmine.getFixtures().proxyCallTo_('set', arguments)
+}
+
+var appendSetFixtures = function() {
+ jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
+}
+
+var sandbox = function(attributes) {
+ return jasmine.getFixtures().sandbox(attributes)
+}
+
+var spyOnEvent = function(selector, eventName) {
+ return jasmine.JQuery.events.spyOn(selector, eventName)
+}
+
+var preloadStyleFixtures = function() {
+ jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
+}
+
+var loadStyleFixtures = function() {
+ jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
+}
+
+var appendLoadStyleFixtures = function() {
+ jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
+}
+
+var setStyleFixtures = function(html) {
+ jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
+}
+
+var appendSetStyleFixtures = function(html) {
+ jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
+}
+
+var loadJSONFixtures = function() {
+ return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
+}
+
+var getJSONFixture = function(url) {
+ return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
+}
+
+jasmine.spiedEventsKey = function (selector, eventName) {
+ return [$(selector).selector, eventName].toString()
+}
+
+jasmine.getFixtures = function() {
+ return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
+}
+
+jasmine.getStyleFixtures = function() {
+ return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures()
+}
+
+jasmine.Fixtures = function() {
+ this.containerId = 'jasmine-fixtures'
+ this.fixturesCache_ = {}
+ this.fixturesPath = 'spec/javascripts/fixtures'
+}
+
+jasmine.Fixtures.prototype.set = function(html) {
+ this.cleanUp()
+ this.createContainer_(html)
+}
+
+jasmine.Fixtures.prototype.appendSet= function(html) {
+ this.addToContainer_(html)
+}
+
+jasmine.Fixtures.prototype.preload = function() {
+ this.read.apply(this, arguments)
+}
+
+jasmine.Fixtures.prototype.load = function() {
+ this.cleanUp()
+ this.createContainer_(this.read.apply(this, arguments))
+}
+
+jasmine.Fixtures.prototype.appendLoad = function() {
+ this.addToContainer_(this.read.apply(this, arguments))
+}
+
+jasmine.Fixtures.prototype.read = function() {
+ var htmlChunks = []
+
+ var fixtureUrls = arguments
+ for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
+ htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]))
+ }
+
+ return htmlChunks.join('')
+}
+
+jasmine.Fixtures.prototype.clearCache = function() {
+ this.fixturesCache_ = {}
+}
+
+jasmine.Fixtures.prototype.cleanUp = function() {
+ $('#' + this.containerId).remove()
+}
+
+jasmine.Fixtures.prototype.sandbox = function(attributes) {
+ var attributesToSet = attributes || {}
+ return $('<div id="sandbox" />').attr(attributesToSet)
+}
+
+jasmine.Fixtures.prototype.createContainer_ = function(html) {
+ var container
+ if(html instanceof $) {
+ container = $('<div id="' + this.containerId + '" />')
+ container.html(html)
+ } else {
+ container = '<div id="' + this.containerId + '">' + html + '</div>'
+ }
+ $(document.body).append(container)
+}
+
+jasmine.Fixtures.prototype.addToContainer_ = function(html){
+ var container = $(document.body).find('#'+this.containerId).append(html)
+ if(!container.length){
+ this.createContainer_(html)
+ }
+}
+
+jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
+ if (typeof this.fixturesCache_[url] === 'undefined') {
+ this.loadFixtureIntoCache_(url)
+ }
+ return this.fixturesCache_[url]
+}
+
+jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
+ var url = this.makeFixtureUrl_(relativeUrl)
+ var request = $.ajax({
+ type: "GET",
+ url: url + "?" + new Date().getTime(),
+ async: false
+ })
+ this.fixturesCache_[relativeUrl] = request.responseText
+}
+
+jasmine.Fixtures.prototype.makeFixtureUrl_ = function(relativeUrl){
+ return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
+}
+
+jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
+ return this[methodName].apply(this, passedArguments)
+}
+
+
+jasmine.StyleFixtures = function() {
+ this.fixturesCache_ = {}
+ this.fixturesNodes_ = []
+ this.fixturesPath = 'spec/javascripts/fixtures'
+}
+
+jasmine.StyleFixtures.prototype.set = function(css) {
+ this.cleanUp()
+ this.createStyle_(css)
+}
+
+jasmine.StyleFixtures.prototype.appendSet = function(css) {
+ this.createStyle_(css)
+}
+
+jasmine.StyleFixtures.prototype.preload = function() {
+ this.read_.apply(this, arguments)
+}
+
+jasmine.StyleFixtures.prototype.load = function() {
+ this.cleanUp()
+ this.createStyle_(this.read_.apply(this, arguments))
+}
+
+jasmine.StyleFixtures.prototype.appendLoad = function() {
+ this.createStyle_(this.read_.apply(this, arguments))
+}
+
+jasmine.StyleFixtures.prototype.cleanUp = function() {
+ while(this.fixturesNodes_.length) {
+ this.fixturesNodes_.pop().remove()
+ }
+}
+
+jasmine.StyleFixtures.prototype.createStyle_ = function(html) {
+ var styleText = $('<div></div>').html(html).text(),
+ style = $('<style>' + styleText + '</style>')
+
+ this.fixturesNodes_.push(style)
+
+ $('head').append(style)
+}
+
+jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
+
+jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read
+
+jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_
+
+jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_
+
+jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_
+
+jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
+
+jasmine.getJSONFixtures = function() {
+ return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
+}
+
+jasmine.JSONFixtures = function() {
+ this.fixturesCache_ = {}
+ this.fixturesPath = 'spec/javascripts/fixtures/json'
+}
+
+jasmine.JSONFixtures.prototype.load = function() {
+ this.read.apply(this, arguments)
+ return this.fixturesCache_
+}
+
+jasmine.JSONFixtures.prototype.read = function() {
+ var fixtureUrls = arguments
+ for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
+ this.getFixtureData_(fixtureUrls[urlIndex])
+ }
+ return this.fixturesCache_
+}
+
+jasmine.JSONFixtures.prototype.clearCache = function() {
+ this.fixturesCache_ = {}
+}
+
+jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) {
+ this.loadFixtureIntoCache_(url)
+ return this.fixturesCache_[url]
+}
+
+jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
+ var self = this
+ var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
+ $.ajax({
+ async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
+ cache: false,
+ dataType: 'json',
+ url: url,
+ success: function(data) {
+ self.fixturesCache_[relativeUrl] = data
+ },
+ error: function(jqXHR, status, errorThrown) {
+ throw Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
+ }
+ })
+}
+
+jasmine.JSONFixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
+ return this[methodName].apply(this, passedArguments)
+}
+
+jasmine.JQuery = function() {}
+
+jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
+ return $('<div/>').append(html).html()
+}
+
+jasmine.JQuery.elementToString = function(element) {
+ var domEl = $(element).get(0)
+ if (domEl == undefined || domEl.cloneNode)
+ return $('<div />').append($(element).clone()).html()
+ else
+ return element.toString()
+}
+
+jasmine.JQuery.matchersClass = {}
+
+!function(namespace) {
+ var data = {
+ spiedEvents: {},
+ handlers: []
+ }
+
+ namespace.events = {
+ spyOn: function(selector, eventName) {
+ var handler = function(e) {
+ data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments)
+ }
+ $(selector).on(eventName, handler)
+ data.handlers.push(handler)
+ return {
+ selector: selector,
+ eventName: eventName,
+ handler: handler,
+ reset: function(){
+ delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
+ }
+ }
+ },
+
+ args: function(selector, eventName) {
+ var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)];
+
+ if (!actualArgs) {
+ throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent.";
+ }
+
+ return actualArgs;
+ },
+
+ wasTriggered: function(selector, eventName) {
+ return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
+ },
+
+ wasTriggeredWith: function(selector, eventName, expectedArgs, env) {
+ var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1);
+ if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') {
+ actualArgs = actualArgs[0];
+ }
+ return env.equals_(expectedArgs, actualArgs);
+ },
+
+ wasPrevented: function(selector, eventName) {
+ var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)],
+ e = args ? args[0] : undefined;
+ return e && e.isDefaultPrevented()
+ },
+
+ wasStopped: function(selector, eventName) {
+ var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)],
+ e = args ? args[0] : undefined;
+ return e && e.isPropagationStopped()
+ },
+
+ cleanUp: function() {
+ data.spiedEvents = {}
+ data.handlers = []
+ }
+ }
+}(jasmine.JQuery)
+
+!function(){
+ var jQueryMatchers = {
+ toHaveClass: function(className) {
+ return this.actual.hasClass(className)
+ },
+
+ toHaveCss: function(css){
+ for (var prop in css){
+ if (this.actual.css(prop) !== css[prop]) return false
+ }
+ return true
+ },
+
+ toBeVisible: function() {
+ return this.actual.is(':visible')
+ },
+
+ toBeHidden: function() {
+ return this.actual.is(':hidden')
+ },
+
+ toBeSelected: function() {
+ return this.actual.is(':selected')
+ },
+
+ toBeChecked: function() {
+ return this.actual.is(':checked')
+ },
+
+ toBeEmpty: function() {
+ return this.actual.is(':empty')
+ },
+
+ toExist: function() {
+ return $(document).find(this.actual).length
+ },
+
+ toHaveLength: function(length) {
+ return this.actual.length === length
+ },
+
+ toHaveAttr: function(attributeName, expectedAttributeValue) {
+ return hasProperty(this.actual.attr(attributeName), expectedAttributeValue)
+ },
+
+ toHaveProp: function(propertyName, expectedPropertyValue) {
+ return hasProperty(this.actual.prop(propertyName), expectedPropertyValue)
+ },
+
+ toHaveId: function(id) {
+ return this.actual.attr('id') == id
+ },
+
+ toHaveHtml: function(html) {
+ return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html)
+ },
+
+ toContainHtml: function(html){
+ var actualHtml = this.actual.html()
+ var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html)
+ return (actualHtml.indexOf(expectedHtml) >= 0)
+ },
+
+ toHaveText: function(text) {
+ var trimmedText = $.trim(this.actual.text())
+ if (text && $.isFunction(text.test)) {
+ return text.test(trimmedText)
+ } else {
+ return trimmedText == text
+ }
+ },
+
+ toContainText: function(text) {
+ var trimmedText = $.trim(this.actual.text())
+ if (text && $.isFunction(text.test)) {
+ return text.test(trimmedText)
+ } else {
+ return trimmedText.indexOf(text) != -1;
+ }
+ },
+
+ toHaveValue: function(value) {
+ return this.actual.val() === value
+ },
+
+ toHaveData: function(key, expectedValue) {
+ return hasProperty(this.actual.data(key), expectedValue)
+ },
+
+ toBe: function(selector) {
+ return this.actual.is(selector)
+ },
+
+ toContain: function(selector) {
+ return this.actual.find(selector).length
+ },
+
+ toBeDisabled: function(selector){
+ return this.actual.is(':disabled')
+ },
+
+ toBeFocused: function(selector) {
+ return this.actual[0] === this.actual[0].ownerDocument.activeElement
+ },
+
+ toHandle: function(event) {
+
+ var events = $._data(this.actual.get(0), "events")
+
+ if(!events || !event || typeof event !== "string") {
+ return false
+ }
+
+ var namespaces = event.split(".")
+ var eventType = namespaces.shift()
+ var sortedNamespaces = namespaces.slice(0).sort()
+ var namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
+
+ if(events[eventType] && namespaces.length) {
+ for(var i = 0; i < events[eventType].length; i++) {
+ var namespace = events[eventType][i].namespace
+ if(namespaceRegExp.test(namespace)) {
+ return true
+ }
+ }
+ } else {
+ return events[eventType] && events[eventType].length > 0
+ }
+ },
+
+ // tests the existence of a specific event binding + handler
+ toHandleWith: function(eventName, eventHandler) {
+ var stack = $._data(this.actual.get(0), "events")[eventName]
+ for (var i = 0; i < stack.length; i++) {
+ if (stack[i].handler == eventHandler) return true
+ }
+ return false
+ }
+ }
+
+ var hasProperty = function(actualValue, expectedValue) {
+ if (expectedValue === undefined) return actualValue !== undefined
+ return actualValue == expectedValue
+ }
+
+ var bindMatcher = function(methodName) {
+ var builtInMatcher = jasmine.Matchers.prototype[methodName]
+
+ jasmine.JQuery.matchersClass[methodName] = function() {
+ if (this.actual
+ && (this.actual instanceof $
+ || jasmine.isDomNode(this.actual))) {
+ this.actual = $(this.actual)
+ var result = jQueryMatchers[methodName].apply(this, arguments)
+ var element
+ if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML")
+ this.actual = jasmine.JQuery.elementToString(this.actual)
+ return result
+ }
+
+ if (builtInMatcher) {
+ return builtInMatcher.apply(this, arguments)
+ }
+
+ return false
+ }
+ }
+
+ for(var methodName in jQueryMatchers) {
+ bindMatcher(methodName)
+ }
+}()
+
+beforeEach(function() {
+ this.addMatchers(jasmine.JQuery.matchersClass)
+ this.addMatchers({
+ toHaveBeenTriggeredOn: function(selector) {
+ this.message = function() {
+ return [
+ "Expected event " + this.actual + " to have been triggered on " + selector,
+ "Expected event " + this.actual + " not to have been triggered on " + selector
+ ]
+ }
+ return jasmine.JQuery.events.wasTriggered(selector, this.actual)
+ }
+ })
+ this.addMatchers({
+ toHaveBeenTriggered: function(){
+ var eventName = this.actual.eventName,
+ selector = this.actual.selector
+ this.message = function() {
+ return [
+ "Expected event " + eventName + " to have been triggered on " + selector,
+ "Expected event " + eventName + " not to have been triggered on " + selector
+ ]
+ }
+ return jasmine.JQuery.events.wasTriggered(selector, eventName)
+ }
+ })
+ this.addMatchers({
+ toHaveBeenTriggeredOnAndWith: function() {
+ var selector = arguments[0],
+ expectedArgs = arguments[1],
+ wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual);
+ this.message = function() {
+ if (wasTriggered) {
+ var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1];
+ return [
+ "Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs),
+ "Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
+ ]
+ } else {
+ return [
+ "Expected event " + this.actual + " to have been triggered on " + selector,
+ "Expected event " + this.actual + " not to have been triggered on " + selector
+ ]
+ }
+ }
+ return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env);
+ }
+ })
+ this.addMatchers({
+ toHaveBeenPreventedOn: function(selector) {
+ this.message = function() {
+ return [
+ "Expected event " + this.actual + " to have been prevented on " + selector,
+ "Expected event " + this.actual + " not to have been prevented on " + selector
+ ]
+ }
+ return jasmine.JQuery.events.wasPrevented(selector, this.actual)
+ }
+ })
+ this.addMatchers({
+ toHaveBeenPrevented: function() {
+ var eventName = this.actual.eventName,
+ selector = this.actual.selector
+ this.message = function() {
+ return [
+ "Expected event " + eventName + " to have been prevented on " + selector,
+ "Expected event " + eventName + " not to have been prevented on " + selector
+ ]
+ }
+ return jasmine.JQuery.events.wasPrevented(selector, eventName)
+ }
+ })
+ this.addMatchers({
+ toHaveBeenStoppedOn: function(selector) {
+ this.message = function() {
+ return [
+ "Expected event " + this.actual + " to have been stopped on " + selector,
+ "Expected event " + this.actual + " not to have been stopped on " + selector
+ ]
+ }
+ return jasmine.JQuery.events.wasStopped(selector, this.actual)
+ }
+ })
+ this.addMatchers({
+ toHaveBeenStopped: function() {
+ var eventName = this.actual.eventName,
+ selector = this.actual.selector
+ this.message = function() {
+ return [
+ "Expected event " + eventName + " to have been stopped on " + selector,
+ "Expected event " + eventName + " not to have been stopped on " + selector
+ ]
+ }
+ return jasmine.JQuery.events.wasStopped(selector, eventName)
+ }
+ })
+})
+
+afterEach(function() {
+ jasmine.getFixtures().cleanUp()
+ jasmine.getStyleFixtures().cleanUp()
+ jasmine.JQuery.events.cleanUp()
+})
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..b38a7f5
--- /dev/null
+++ b/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "jQuery-Timepicker-Addon",
+ "version": "0.0.0-ignored",
+ "engines": {
+ "node": ">= 0.8.0"
+ },
+ "scripts": {
+ "test": "grunt jasmine"
+ },
+ "devDependencies": {
+ "grunt-contrib-jshint": "~0.1.1",
+ "grunt-contrib-jasmine": "~0.5.1",
+ "grunt-contrib-concat": "~0.1.2",
+ "grunt-contrib-uglify": "~0.1.1",
+ "grunt-contrib-watch": "~0.2.0",
+ "grunt-contrib-clean": "~0.4.0",
+ "grunt-contrib-copy": "~0.4.0",
+ "grunt-contrib-cssmin": "~0.6.0",
+ "grunt-replace": "~0.4.4",
+ "grunt": "~0.4.1"
+ }
+} \ No newline at end of file
diff --git a/src/.jshintrc b/src/.jshintrc
new file mode 100644
index 0000000..d3d850f
--- /dev/null
+++ b/src/.jshintrc
@@ -0,0 +1,17 @@
+{
+ "evil": true,
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "sub": true,
+ "undef": true,
+ "unused": false,
+ "loopfunc": true,
+ "boss": true,
+ "eqnull": true,
+ "browser": true,
+ "predef": ["jQuery"]
+}
diff --git a/src/docs/examples.html b/src/docs/examples.html
new file mode 100644
index 0000000..77dd2ef
--- /dev/null
+++ b/src/docs/examples.html
@@ -0,0 +1,441 @@
+<!-- ############################################################################# -->
+<!-- Examples
+<!-- ############################################################################# -->
+<div id="tp-examples">
+ <h2>Examples</h2>
+
+ <ul>
+ <li><a href="#basic_examples" title="Basic Initializations">Basic Initializations</a></li>
+ <li><a href="#timezone_examples" title="Using Timezones">Using Timezones</a></li>
+ <li><a href="#slider_examples" title="Slider Modifications">Slider Modifications</a></li>
+ <li><a href="#alt_examples" title="Alternate Field">Alternate Fields</a></li>
+ <li><a href="#rest_examples" title="Time Restraints">Time Restraints</a></li>
+ <li><a href="#utility_examples" title="Utilities">Utilities</a></li>
+ </ul>
+
+ <h3 id="basic_examples">Basic Initializations</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Add a simple datetimepicker to jQuery UI's datepicker</p>
+ <div>
+ <input type="text" name="basic_example_1" id="basic_example_1" value="" />
+ </div>
+<pre>
+$('#basic_example_1').datetimepicker();
+</pre>
+ </div>
+
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Add only a timepicker:</p>
+ <div>
+ <input type="text" name="basic_example_2" id="basic_example_2" value="" />
+ </div>
+<pre>
+$('#basic_example_2').timepicker();
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Format the time:</p>
+ <div>
+ <input type="text" name="basic_example_3" id="basic_example_3" value="" />
+ </div>
+<pre>
+$('#basic_example_3').datetimepicker({
+ timeFormat: "hh:mm tt"
+});
+</pre>
+ </div>
+
+ <h3 id="timezone_examples">Using Timezones</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Simplest timezone usage:</p>
+ <div>
+ <input type="text" name="timezone_example_1" id="timezone_example_1" value="" />
+ </div>
+<pre>
+$('#timezone_example_1').datetimepicker({
+ timeFormat: 'hh:mm tt z'
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Define your own timezone options:</p>
+ <div>
+ <input type="text" name="timezone_example_2" id="timezone_example_2" value="" />
+ </div>
+<pre>
+$('#timezone_example_2').datetimepicker({
+ timeFormat: 'HH:mm z',
+ timezoneList: [
+ { value: -300, label: 'Eastern'},
+ { value: -360, label: 'Central' },
+ { value: -420, label: 'Mountain' },
+ { value: -480, label: 'Pacific' }
+ ]
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>You may also use timezone string abbreviations for values. This should be used with caution. Computing accurate javascript Date objects may not be possible when trying to retrieve or set the date from timepicker (see setDate and getDate examples below). For simple input values however this should work.</p>
+ <div>
+ <input type="text" name="timezone_example_3" id="timezone_example_3" value="" />
+ </div>
+<pre>
+$('#timezone_example_3').datetimepicker({
+ timeFormat: 'HH:mm z',
+ timezone: 'MT',
+ timezoneList: [
+ { value: 'ET', label: 'Eastern'},
+ { value: 'CT', label: 'Central' },
+ { value: 'MT', label: 'Mountain' },
+ { value: 'PT', label: 'Pacific' }
+ ]
+});
+
+</pre>
+ </div>
+
+ <h3 id="slider_examples">Slider Modifications</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Add a grid to each slider:</p>
+ <div>
+ <input type="text" name="slider_example_1" id="slider_example_1" value="" />
+ </div>
+<pre>
+$('#slider_example_1').timepicker({
+ hourGrid: 4,
+ minuteGrid: 10,
+ timeFormat: 'hh:mm tt'
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Set the interval step of sliders:</p>
+ <div>
+ <input type="text" name="slider_example_2" id="slider_example_2" value="" />
+ </div>
+<pre>
+$('#slider_example_2').datetimepicker({
+ timeFormat: 'HH:mm:ss',
+ stepHour: 2,
+ stepMinute: 10,
+ stepSecond: 10
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Add sliderAccess plugin for touch devices:</p>
+ <div>
+ <input type="text" name="slider_example_3" id="slider_example_3" value="" />
+ </div>
+<pre>
+$('#slider_example_3').datetimepicker({
+ addSliderAccess: true,
+ sliderAccessArgs: { touchonly: false }
+});</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Use dropdowns instead of sliders. By default if slider is not available dropdowns will be used.</p>
+ <div>
+ <input type="text" name="slider_example_4" id="slider_example_4" value="" />
+ </div>
+<pre>
+$('#slider_example_4').datetimepicker({
+ controlType: 'select',
+ timeFormat: 'hh:mm tt'
+});</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Create your own control by implementing the create, options, and value methods. If you want to use your new control for all instances use the $.timepicker.setDefaults({controlType:myControl}). Here we implement jQueryUI's spinner control (jQueryUI 1.9+).</p>
+ <div>
+ <input type="text" name="slider_example_5" id="slider_example_5" value="" />
+ </div>
+<pre>var myControl= {
+ create: function(tp_inst, obj, unit, val, min, max, step){
+ $('&lt;input class="ui-timepicker-input" value="'+val+'" style="width:50%"&gt;')
+ .appendTo(obj)
+ .spinner({
+ min: min,
+ max: max,
+ step: step,
+ change: function(e,ui){ // key events
+ // don't call if api was used and not key press
+ if(e.originalEvent !== undefined)
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ },
+ spin: function(e,ui){ // spin events
+ tp_inst.control.value(tp_inst, obj, unit, ui.value);
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }
+ });
+ return obj;
+ },
+ options: function(tp_inst, obj, unit, opts, val){
+ if(typeof(opts) == 'string' && val !== undefined)
+ return obj.find('.ui-timepicker-input').spinner(opts, val);
+ return obj.find('.ui-timepicker-input').spinner(opts);
+ },
+ value: function(tp_inst, obj, unit, val){
+ if(val !== undefined)
+ return obj.find('.ui-timepicker-input').spinner('value', val);
+ return obj.find('.ui-timepicker-input').spinner('value');
+ }
+};
+
+$('#slider_example_5').datetimepicker({
+ controlType: myControl
+});</pre>
+ </div>
+
+ <h3 id="alt_examples">Alternate Fields</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Alt field in the simplest form:</p>
+ <div>
+ <input type="text" name="alt_example_1" id="alt_example_1" value="09/15/2012" />
+ <input type="text" name="alt_example_1_alt" id="alt_example_1_alt" value="10:15" />
+ </div>
+<pre>
+$('#alt_example_1').datetimepicker({
+ altField: "#alt_example_1_alt"
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>With datetime in both:</p>
+ <div>
+ <input type="text" name="alt_example_2" id="alt_example_2" value="" />
+ <input type="text" name="alt_example_2_alt" id="alt_example_2_alt" value="" />
+ </div>
+<pre>
+$('#alt_example_2').datetimepicker({
+ altField: "#alt_example_2_alt",
+ altFieldTimeOnly: false
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Format the altField differently:</p>
+ <div>
+ <input type="text" name="alt_example_3" id="alt_example_3" value="" />
+ <input type="text" name="alt_example_3_alt" id="alt_example_3_alt" value="" />
+ </div>
+<pre>
+$('#alt_example_3').datetimepicker({
+ altField: "#alt_example_3_alt",
+ altFieldTimeOnly: false,
+ altFormat: "yy-mm-dd",
+ altTimeFormat: "h:m t",
+ altSeparator: " @ "
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>With inline mode using altField:</p>
+ <div>
+ <input type="text" name="alt_example_4_alt" id="alt_example_4_alt" value="" />
+ <span id="alt_example_4" ></span>
+ </div>
+<pre>
+$('#alt_example_4').datetimepicker({
+ altField: "#alt_example_4_alt",
+ altFieldTimeOnly: false
+});
+</pre>
+ </div>
+
+ <h3 id="rest_examples">Time Restraints</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Set the min/max hour of every date:</p>
+ <div>
+ <input type="text" name="rest_example_1" id="rest_example_1" value="" />
+ </div>
+<pre>
+$('#rest_example_1').timepicker({
+ hourMin: 8,
+ hourMax: 16
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Set the min/max date numerically:</p>
+ <div>
+ <input type="text" name="rest_example_2" id="rest_example_2" value="" />
+ </div>
+<pre>
+$('#rest_example_2').datetimepicker({
+ numberOfMonths: 2,
+ minDate: 0,
+ maxDate: 30
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Set the min/max date and time with a Date object:</p>
+ <div>
+ <input type="text" name="rest_example_3" id="rest_example_3" value="" />
+ </div>
+<pre>
+$('#rest_example_3').datetimepicker({
+ minDate: new Date(2010, 11, 20, 8, 30),
+ maxDate: new Date(2010, 11, 31, 17, 30)
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Restrict a start and end date by using onSelect and onClose events for more control over functionality:</p>
+ <p>For more examples and advanced usage grab the <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook">Handling Time eBook</a>.</p>
+ <div>
+ <input type="text" name="rest_example_4_start" id="rest_example_4_start" value="" />
+ <input type="text" name="rest_example_4_end" id="rest_example_4_end" value="" />
+ </div>
+<pre>
+var startDateTextBox = $('#rest_example_4_start');
+var endDateTextBox = $('#rest_example_4_end');
+
+startDateTextBox.datetimepicker({
+ timeFormat: 'HH:mm z',
+ onClose: function(dateText, inst) {
+ if (endDateTextBox.val() != '') {
+ var testStartDate = startDateTextBox.datetimepicker('getDate');
+ var testEndDate = endDateTextBox.datetimepicker('getDate');
+ if (testStartDate > testEndDate)
+ endDateTextBox.datetimepicker('setDate', testStartDate);
+ }
+ else {
+ endDateTextBox.val(dateText);
+ }
+ },
+ onSelect: function (selectedDateTime){
+ endDateTextBox.datetimepicker('option', 'minDate', startDateTextBox.datetimepicker('getDate') );
+ }
+});
+endDateTextBox.datetimepicker({
+ timeFormat: 'HH:mm z',
+ onClose: function(dateText, inst) {
+ if (startDateTextBox.val() != '') {
+ var testStartDate = startDateTextBox.datetimepicker('getDate');
+ var testEndDate = endDateTextBox.datetimepicker('getDate');
+ if (testStartDate > testEndDate)
+ startDateTextBox.datetimepicker('setDate', testEndDate);
+ }
+ else {
+ startDateTextBox.val(dateText);
+ }
+ },
+ onSelect: function (selectedDateTime){
+ startDateTextBox.datetimepicker('option', 'maxDate', endDateTextBox.datetimepicker('getDate') );
+ }
+});
+</pre>
+ </div>
+
+ <h3 id="utility_examples">Utilities</h3>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Get and Set Datetime with the getDate and setDate methods. This example uses timezone to demonstrate the timepicker regonizes the timezones and computes the offsets when getting and setting.</p>
+ <div>
+ <input type="text" name="utility_example_1" id="utility_example_1" value="" />
+ <button id="utility_example_1_setdt" value="1">Set Datetime</button>
+ <button id="utility_example_1_getdt" value="1">Get Datetime</button>
+ </div>
+
+<pre>
+var ex13 = $('#utility_example_1');
+
+ex13.datetimepicker({
+ timeFormat: 'hh:mm tt z',
+ separator: ' @ ',
+ showTimezone: true
+});
+
+$('#utility_example_1_setdt').click(function(){
+ ex13.datetimepicker('setDate', (new Date()) );
+});
+
+$('#utility_example_1_getdt').click(function(){
+ alert(ex13.datetimepicker('getDate'));
+});
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Use the utility function to format your own time. $.datepicker.formatTime(format, time, options)</p>
+ <dl class="defs">
+ <dt>format</dt><dd>required - string represenation of the time format to use</dd>
+ <dt>time</dt><dd>required - hash: { hour, minute, second, millisecond, timezone }</dd>
+ <dt>options</dt><dd>optional - hash of any options in regional translation (ampm, amNames, pmNames..)</dd>
+ </dl>
+ <p>Returns a time string in the specified format.</p>
+ <div>
+ <div id="utility_example_2"></div>
+ </div>
+
+<pre>
+$('#utility_example_2').text(
+ $.datepicker.formatTime('HH:mm z', { hour: 14, minute: 36, timezone: '+2000' }, {})
+);
+</pre>
+ </div>
+
+ <!-- ============= example -->
+ <div class="example-container">
+ <p>Use the utility function to parses a formatted time. $.datepicker.parseTime(format, timeString, options)</p>
+ <dl class="defs">
+ <dt>format</dt><dd>required - string represenation of the time format to use</dd>
+ <dt>time</dt><dd>required - time string matching the format given in parameter 1</dd>
+ <dt>options</dt><dd>optional - hash of any options in regional translation (ampm, amNames, pmNames..)</dd>
+ </dl>
+ <p>Returns an object with hours, minutes, seconds, milliseconds, timezone.</p>
+ <div>
+ <div id="utility_example_3"></div>
+ </div>
+
+<pre>
+$('#utility_example_3').text(JSON.stringify(
+ $.datepicker.parseTime('HH:mm:ss:l z', "14:36:21:765 +2000", {})
+));
+</pre>
+ </div>
+
+</div> \ No newline at end of file
diff --git a/src/docs/footer.html b/src/docs/footer.html
new file mode 100644
index 0000000..af20aa1
--- /dev/null
+++ b/src/docs/footer.html
@@ -0,0 +1,37 @@
+ </div>
+
+
+ </div>
+
+
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
+ <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
+ <script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
+ <script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
+
+ <script type="text/javascript">
+
+ $(function(){
+ $('#tabs').tabs();
+
+ $('.example-container > pre').each(function(i){
+ eval($(this).text());
+ });
+ });
+
+ </script>
+
+ <script type="text/javascript" src="https://sellfy.com/js/api_buttons.js"></script>
+ <script type="text/javascript" src="https://gumroad.com/js/gumroad.js"></script>
+
+ <script type="text/javascript"> /*
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ */</script>
+ <script type="text/javascript"> /*
+ try {
+ var pageTracker = _gat._getTracker("UA-7602218-1");
+ pageTracker._trackPageview();
+ } catch(err) {}*/</script>
+ </body>
+</html> \ No newline at end of file
diff --git a/src/docs/formatting.html b/src/docs/formatting.html
new file mode 100644
index 0000000..647a3d9
--- /dev/null
+++ b/src/docs/formatting.html
@@ -0,0 +1,40 @@
+<!-- ############################################################################# -->
+<!-- Formatting
+<!-- ############################################################################# -->
+<div id="tp-formatting">
+
+ <h2>Formatting Your Time</h2>
+
+ <p>The default format is "HH:mm". To use 12 hour time use something similar to: "hh:mm tt". When both "t" and lower case "h" are present in the timeFormat, 12 hour time will be used.</p>
+
+ <dl class="defs">
+ <dt>H</dt><dd>Hour with no leading 0 (24 hour)</dd>
+ <dt>HH</dt><dd>Hour with leading 0 (24 hour)</dd>
+ <dt>h</dt><dd>Hour with no leading 0 (12 hour)</dd>
+ <dt>hh</dt><dd>Hour with leading 0 (12 hour)</dd>
+ <dt>m</dt><dd>Minute with no leading 0</dd>
+ <dt>mm</dt><dd>Minute with leading 0</dd>
+ <dt>s</dt><dd>Second with no leading 0</dd>
+ <dt>ss</dt><dd>Second with leading 0</dd>
+ <dt>l</dt><dd>Milliseconds always with leading 0</dd>
+ <dt>c</dt><dd>Microseconds always with leading 0</dd>
+ <dt>t</dt><dd>a or p for AM/PM</dd>
+ <dt>T</dt><dd>A or P for AM/PM</dd>
+ <dt>tt</dt><dd>am or pm for AM/PM</dd>
+ <dt>TT</dt><dd>AM or PM for AM/PM</dd>
+ <dt>z</dt><dd>Timezone as defined by timezoneList</dd>
+ <dt>Z</dt><dd>Timezone in Iso 8601 format (+04:45)</dd>
+ <dt>'...'</dt><dd>Literal text (Uses single quotes)</dd>
+ </dl>
+
+ <p>Formats are used in the following ways:</p>
+ <ul>
+ <li>timeFormat option</li>
+ <li>altTimeFormat option</li>
+ <li>pickerTimeFormat option</li>
+ <li>$.datepicker.formatTime(format, timeObj, options) utility method</li>
+ <li>$.datepicker.parseTime(format, timeStr, options) utility method</li>
+ </ul>
+
+ <p>For help with formatting the date portion, visit the datepicker documentation for <a href="http://docs.jquery.com/UI/Datepicker/formatDate" title="jQuery UI Datepicker Formatting">formatting dates</a>.</p>
+</div>
diff --git a/src/docs/header.html b/src/docs/header.html
new file mode 100644
index 0000000..d509354
--- /dev/null
+++ b/src/docs/header.html
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Adding a Timepicker to jQuery UI Datepicker</title>
+ <meta name="Description" content="jQuery Timepicker Addon. Add a timepicker to your jQuery UI Datepicker. With options to show only time, format time, and much more." />
+ <meta name="Keywords" content="jQuery, UI, datepicker, timepicker, datetime, time, format" />
+
+ <style type="text/css">
+ body,img,p,h1,h2,h3,h4,h5,h6,form,table,td,ul,ol,li,dl,dt,dd,pre,blockquote,fieldset,label{
+ margin:0;
+ padding:0;
+ border:0;
+ }
+ body{ background-color: #777; border-top: solid 10px #7b94b2; font: 90% Arial, Helvetica, sans-serif; padding: 20px; }
+ h1,h2,h3{ margin: 10px 0; }
+ h1{}
+ h2{ color: #f66; }
+ h3{ color: #6b84a2; }
+ p{ margin: 10px 0; }
+ a{ color: #7b94b2; }
+ ul,ol{ margin: 10px 0 10px 40px; }
+ li{ margin: 4px 0; }
+ dl.defs{ margin: 10px 0 10px 40px; }
+ dl.defs dt{ font-weight: bold; line-height: 20px; margin: 10px 0 0 0; }
+ dl.defs dd{ margin: -20px 0 10px 160px; padding-bottom: 10px; border-bottom: solid 1px #eee;}
+ pre{ font-size: 12px; line-height: 16px; padding: 5px 5px 5px 10px; margin: 10px 0; background-color: #e4f4d4; border-left: solid 5px #9EC45F; overflow: auto; tab-size: 4; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; }
+
+ .wrapper{ background-color: #ffffff; width: 800px; border: solid 1px #eeeeee; padding: 20px; margin: 0 auto; }
+ #tabs{ margin: 20px -20px; border: none; }
+ #tabs, #ui-datepicker-div, .ui-datepicker{ font-size: 85%; }
+ .clear{ clear: both; }
+
+ .example-container{ background-color: #f4f4f4; border-bottom: solid 2px #777777; margin: 0 0 20px 40px; padding: 20px; }
+ .example-container input{ border: solid 1px #aaa; padding: 4px; width: 175px; }
+ .ebook{}
+ .ebook img.ebookimg{ float: left; margin: 0 15px 15px 0; width: 100px; }
+ .ebook .buyp a iframe{ margin-bottom: -5px; }
+ </style>
+
+ <link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
+ <link rel="stylesheet" media="all" type="text/css" href="jquery-ui-timepicker-addon.css" />
+
+ </head>
+ <body>
+ <div class="wrapper">
+ <h1>Adding a Timepicker to jQuery UI Datepicker</h1>
+
+ <p>The timepicker addon adds a timepicker to jQuery UI Datepicker, thus the datepicker and slider components (jQueryUI) are required for using any of these. In addition all datepicker options are still available through the timepicker addon.</p>
+
+ <p>If you are interested in contributing to Timepicker Addon please <a href="http://github.com/trentrichardson/jQuery-Timepicker-Addon" title="Check out Timepicker on GitHub">check it out on GitHub</a>. If you do make additions please keep in mind I enjoy tabs over spaces,.. But contributions are welcome in any form.</p>
+
+ <p><a href="http://trentrichardson.com" title="Back to Blog">Back to Blog</a> or <a href="http://twitter.com/practicalweb" title="Follow Me on Twitter">Follow on Twitter</a></p>
+
+ <a href="http://carbounce.com" title="Car Bounce" style="float: right;display: inline-block;width:380px;padding: 10px;background-color: #fbfbfb;border: dotted 4px #e8e8e8;color: #9EC45F;font-size: 16px;text-decoration:none;letter-spacing:1px;"><img src="http://carbounce.com/img/logo_small.png" alt="Car Bounce" align="left" style="margin-right: 20px;"/>Try my new app to keep you informed of your car's financing status and value.</a>
+
+ <h2>Donation</h2>
+ <p>Has this Timepicker Addon been helpful to you?</p>
+ <div class="donation">
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
+ <input type="hidden" name="cmd" value="_s-xclick">
+ <input type="hidden" name="hosted_button_id" value="C2QQHR7JQGD28">
+ <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+ <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
+ </form>
+ </div>
+
+ <div id="tabs">
+ <ul>
+ <li><a href="#tp-getting-started" title="Getting Started">Getting Started</a></li>
+ <li><a href="#tp-options" title="Options">Options</a></li>
+ <li><a href="#tp-formatting" title="Examples">Formatting</a></li>
+ <li><a href="#tp-localization" title="Examples">Localization</a></li>
+ <li><a href="#tp-examples" title="Examples">Examples</a></li>
+ </ul> \ No newline at end of file
diff --git a/src/docs/i18n.html b/src/docs/i18n.html
new file mode 100644
index 0000000..b9664c1
--- /dev/null
+++ b/src/docs/i18n.html
@@ -0,0 +1,65 @@
+<!-- ############################################################################# -->
+<!-- Localization
+<!-- ############################################################################# -->
+<div id="tp-localization">
+
+ <h2>Working with Localizations</h2>
+
+ <p>Timepicker comes with many translations and localizations, thanks to all the contributors. They can be found in the i18n folder in the git repo.</p>
+
+ <p>The quick and cheap way to use localizations is to pass in options to a timepicker instance:</p>
+
+<pre>$('#example123').timepicker({
+ timeOnlyTitle: 'Выберите время',
+ timeText: 'Время',
+ hourText: 'Часы',
+ minuteText: 'Минуты',
+ secondText: 'Секунды',
+ currentText: 'Теперь',
+ closeText: 'Закрыть'
+});
+</pre>
+ <p>However, if you plan to use timepicker extensively you will need to include (build your own) localization. It is simply assigning those same variables to an object. As you see in the example below we maintain a separate object for timepicker. This way we aren't bound to any changes within datepicker.</p>
+
+<pre>$.datepicker.regional['ru'] = {
+ closeText: 'Закрыть',
+ prevText: '&#x3c;Пред',
+ nextText: 'След&#x3e;',
+ currentText: 'Сегодня',
+ monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь',
+ 'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
+ monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн',
+ 'Июл','Авг','Сен','Окт','Ноя','Дек'],
+ dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
+ dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'],
+ dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
+ weekHeader: 'Не',
+ dateFormat: 'dd.mm.yy',
+ firstDay: 1,
+ isRTL: false,
+ showMonthAfterYear: false,
+ yearSuffix: ''
+};
+$.datepicker.setDefaults($.datepicker.regional['ru']);
+
+
+$.timepicker.regional['ru'] = {
+ timeOnlyTitle: 'Выберите время',
+ timeText: 'Время',
+ hourText: 'Часы',
+ minuteText: 'Минуты',
+ secondText: 'Секунды',
+ millisecText: 'Миллисекунды',
+ timezoneText: 'Часовой пояс',
+ currentText: 'Сейчас',
+ closeText: 'Закрыть',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+};
+$.timepicker.setDefaults($.timepicker.regional['ru']);
+</pre>
+ <p>Now all you have to do is call timepicker and the Russian localization is used. Generally you only need to include the localization file, it will setDefaults() for you.</p>
+ <p>You can also visit <a href="http://docs.jquery.com/UI/Datepicker/Localization" title="localization for datepicker" target="_BLANK">localization for datepicker</a> for more information about datepicker localizations.</p>
+</div>
diff --git a/src/docs/intro.html b/src/docs/intro.html
new file mode 100644
index 0000000..18c19e2
--- /dev/null
+++ b/src/docs/intro.html
@@ -0,0 +1,59 @@
+<!-- ############################################################################# -->
+<!-- Getting Started
+<!-- ############################################################################# -->
+<div id="tp-getting-started">
+ <h2>Getting Started</h2>
+
+ <h3>Highly Recommended</h3>
+
+ <h4>Handling Time eBook</h4>
+ <div class="ebook">
+ <p>Check out the <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook">Handling Time eBook</a> to learn from the basic setup to advanced i18n usage, and from client's javascript to the server's database.</p>
+ <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook"><img src="http://trentrichardson.com/wp-content/uploads/2013/04/time-book-titlepage.jpg" alt="Handling Time eBook" style="float:left;width:100px;margin:0 15px 15px 0;" /></a>
+ <p class="buyp"><a href="https://sellfy.com/p/8gxZ" id="8gxZ" class="sellfy-buy-button">buy</a> eBook + Example code</p>
+ <p class="buyp"><a href="https://sellfy.com/p/LvAG" id="LvAG" class="sellfy-buy-button">buy</a> eBook</p>
+ <p class="buyp"><a href="http://gum.co/ZWYO" class="gumroad-button">Handling Time</a></p>
+ <div class="clear"></div>
+ </div>
+
+ <h4>Subscribe to Blog and Twitter</h4>
+ <p><a href="http://trentrichardson.com" title="Subscribe to TrentRichardson.com via email">Subscribe to my blog via email</a> and follow <a href="http://twitter.com/practicalweb" title="Follow Me on Twitter">@PracticalWeb</a> on Twitter. I post for nearly every new version, so you know about updates.</p>
+ <div class="clear"></div>
+ <br />
+
+ <h3>Download</h3>
+ <p><a href="jquery-ui-timepicker-addon.js" title="Download Timepicker Addon">Download Timepicker Addon</a></p>
+ <p><a href="http://github.com/trentrichardson/jQuery-Timepicker-Addon" title="Check out Timepicker on GitHub">Download/Contribute on GitHub</a> (Need the entire repo? Find a bug? See if its fixed here)</p>
+ <p>There is a small bit of required CSS (<a href="jquery-ui-timepicker-addon.css" title="Download CSS">Download</a>):</p>
+<pre>/* css for timepicker */
+.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
+.ui-timepicker-div dl { text-align: left; }
+.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
+.ui-timepicker-div dl dd { margin: 0 10px 10px 45%; }
+.ui-timepicker-div td { font-size: 90%; }
+.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
+
+.ui-timepicker-rtl{ direction: rtl; }
+.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
+.ui-timepicker-rtl dl dt{ float: right; clear: right; }
+.ui-timepicker-rtl dl dd { margin: 0 45% 10px 10px; }
+</pre>
+ <br />
+
+ <h3>Requirements</h3>
+ <p>You also need to include jQuery and jQuery UI with datepicker and slider wigits. You should include them in your page in the following order:</p>
+ <ol>
+ <li>jQuery</li>
+ <li>jQueryUI (with datepicker and slider wigits)</li>
+ <li>Timepicker</li>
+ </ol>
+
+ <br />
+ <h3>Version</h3>
+ <p>Version @@version</p>
+
+ <p>Last updated on @@timestamp</p>
+ <p>jQuery Timepicker Addon is currently available for use in all personal or commercial projects under the MIT license.</p>
+ <p><a href="http://trentrichardson.com/Impromptu/MIT-LICENSE.txt" title="MIT License">MIT License</a></p>
+
+</div>
diff --git a/src/docs/options.html b/src/docs/options.html
new file mode 100644
index 0000000..4c62358
--- /dev/null
+++ b/src/docs/options.html
@@ -0,0 +1,252 @@
+<!-- ############################################################################# -->
+<!-- Options
+<!-- ############################################################################# -->
+<div id="tp-options">
+ <h2>Options</h2>
+
+ <p>The timepicker does inherit all options from datepicker. However, there are many options that are shared by them both, and many timepicker only options:</p>
+
+ <h3>Localization Options</h3>
+ <dl class="defs">
+ <dt>currentText</dt>
+ <dd><em>Default: "Now", A Localization Setting</em> - Text for the Now button.</dd>
+
+ <dt>closeText</dt>
+ <dd><em>Default: "Done", A Localization Setting</em> - Text for the Close button.</dd>
+
+ <dt>amNames</dt>
+ <dd><em>Default: ['AM', 'A'], A Localization Setting</em> - Array of strings to try and parse against to determine AM.</dd>
+
+ <dt>pmNames</dt>
+ <dd><em>Default: ['PM', 'P'], A Localization Setting</em> - Array of strings to try and parse against to determine PM.</dd>
+
+ <dt>timeFormat</dt>
+ <dd><em>Default: "HH:mm", A Localization Setting</em> - String of format tokens to be replaced with the time. <a href="#tp-formatting" title="Formatting" onclick="$('#tabs').tabs('select',2);">See Formatting</a>.</dd>
+
+ <dt>timeSuffix</dt>
+ <dd><em>Default: "", A Localization Setting</em> - String to place after the formatted time.</dd>
+
+ <dt>timeOnlyTitle</dt>
+ <dd><em>Default: "Choose Time", A Localization Setting</em> - Title of the wigit when using only timepicker.</dd>
+
+ <dt>timeText</dt>
+ <dd><em>Default: "Time", A Localization Setting</em> - Label used within timepicker for the formatted time.</dd>
+
+ <dt>hourText</dt>
+ <dd><em>Default: "Hour", A Localization Setting</em> - Label used to identify the hour slider.</dd>
+
+ <dt>minuteText</dt>
+ <dd><em>Default: "Minute", A Localization Setting</em> - Label used to identify the minute slider.</dd>
+
+ <dt>secondText</dt>
+ <dd><em>Default: "Second", A Localization Setting</em> - Label used to identify the second slider.</dd>
+
+ <dt>millisecText</dt>
+ <dd><em>Default: "Millisecond", A Localization Setting</em> - Label used to identify the millisecond slider.</dd>
+
+ <dt>microsecText</dt>
+ <dd><em>Default: "Microsecond", A Localization Setting</em> - Label used to identify the microsecond slider.</dd>
+
+ <dt>timezoneText</dt>
+ <dd><em>Default: "Timezone", A Localization Setting</em> - Label used to identify the timezone slider.</dd>
+
+ <dt>isRTL</dt>
+ <dd><em>Default: false, A Localization Setting</em> - Right to Left support.</dd>
+ </dl>
+
+ <h3>Alt Field Options</h3>
+ <dl class="defs">
+
+ <dt>altFieldTimeOnly</dt>
+ <dd><em>Default: true</em> - When altField is used from datepicker altField will only receive the formatted time and the original field only receives date.</dd>
+
+ <dt>altSeparator</dt>
+ <dd><em>Default: (separator option)</em> - String placed between formatted date and formatted time in the altField.</dd>
+
+ <dt>altTimeSuffix</dt>
+ <dd><em>Default: (timeSuffix option)</em> - String always placed after the formatted time in the altField.</dd>
+
+ <dt>altTimeFormat</dt>
+ <dd><em>Default: (timeFormat option)</em> - The time format to use with the altField.</dd>
+ </dl>
+
+ <h3>Timezone Options</h3>
+ <dl class="defs">
+
+ <dt>timezoneList</dt>
+ <dd><em>Default: [generated timezones]</em> - An array of timezones used to populate the timezone select. Can be an array of values or an array of objects: { label: "EDT", value: -240 }. The value should be the offset number in minutes. So "-0400" which is the format "-hhmm", would equate to -240 minutes.</dd>
+ </dl>
+
+ <h3>Time Field Options</h3>
+ <dl class="defs">
+
+ <dt>controlType</dt>
+ <dd><em>Default: 'slider'</em> - Whether to use 'slider' or 'select'. If 'slider' is unavailable through jQueryUI, 'select' will be used. For advanced usage you may pass an object which implements "create", "options", "value" methods to use controls other than sliders or selects. See the _controls property in the source code for more details.
+<pre>{
+ create: function(tp_inst, obj, unit, val, min, max, step){
+ // generate whatever controls you want here, just return obj
+ },
+ options: function(tp_inst, obj, unit, opts, val){
+ // if val==undefined return the value, else return obj
+ },
+ value: function(tp_inst, obj, unit, val){
+ // if val==undefined return the value, else return obj
+ }
+}</pre>
+ </dd>
+
+ <dt>showHour</dt>
+ <dd><em>Default: null</em> - Whether to show the hour control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showMinute</dt>
+ <dd><em>Default: null</em> - Whether to show the minute control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showSecond</dt>
+ <dd><em>Default: null</em> - Whether to show the second control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showMillisec</dt>
+ <dd><em>Default: null</em> - Whether to show the millisecond control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showMicrosec</dt>
+ <dd><em>Default: null</em> - Whether to show the microsecond control. The default of null will use detection from timeFormat.</dd>
+
+ <dt>showTimezone</dt>
+ <dd><em>Default: null</em> - Whether to show the timezone select.</dd>
+
+ <dt>showTime</dt>
+ <dd><em>Default: true</em> - Whether to show the time selected within the datetimepicker.</dd>
+
+ <dt>stepHour</dt>
+ <dd><em>Default: 1</em> - Hours per step the slider makes.</dd>
+
+ <dt>stepMinute</dt>
+ <dd><em>Default: 1</em> - Minutes per step the slider makes.</dd>
+
+ <dt>stepSecond</dt>
+ <dd><em>Default: 1</em> - Seconds per step the slider makes.</dd>
+
+ <dt>stepMillisec</dt>
+ <dd><em>Default: 1</em> - Milliseconds per step the slider makes.</dd>
+
+ <dt>stepMicrosec</dt>
+ <dd><em>Default: 1</em> - Microseconds per step the slider makes.</dd>
+
+ <dt>hour</dt>
+ <dd><em>Default: 0</em> - Initial hour set.</dd>
+
+ <dt>minute</dt>
+ <dd><em>Default: 0</em> - Initial minute set.</dd>
+
+ <dt>second</dt>
+ <dd><em>Default: 0</em> - Initial second set.</dd>
+
+ <dt>millisec</dt>
+ <dd><em>Default: 0</em> - Initial millisecond set.</dd>
+
+ <dt>microsec</dt>
+ <dd><em>Default: 0</em> - Initial microsecond set. Note: Javascript's native Date object does not natively support microseconds. Timepicker adds ability to simply Date.setMicroseconds(m) and Date.getMicroseconds(). Date comparisons will not acknowledge microseconds. Use this only for display purposes.</dd>
+
+ <dt>timezone</dt>
+ <dd><em>Default: null</em> - Initial timezone set. This is the offset in minutes. If null the browser's local timezone will be used. If you're timezone is "-0400" you would use -240. For backwards compatibility you may pass "-0400", however the timezone is stored in minutes and more reliable.</dd>
+
+ <dt>hourMin</dt>
+ <dd><em>Default: 0</em> - The minimum hour allowed for all dates.</dd>
+
+ <dt>minuteMin</dt>
+ <dd><em>Default: 0</em> - The minimum minute allowed for all dates.</dd>
+
+ <dt>secondMin</dt>
+ <dd><em>Default: 0</em> - The minimum second allowed for all dates.</dd>
+
+ <dt>millisecMin</dt>
+ <dd><em>Default: 0</em> - The minimum millisecond allowed for all dates.</dd>
+
+ <dt>microsecMin</dt>
+ <dd><em>Default: 0</em> - The minimum microsecond allowed for all dates.</dd>
+
+ <dt>hourMax</dt>
+ <dd><em>Default: 23</em> - The maximum hour allowed for all dates.</dd>
+
+ <dt>minuteMax</dt>
+ <dd><em>Default: 59</em> - The maximum minute allowed for all dates.</dd>
+
+ <dt>secondMax</dt>
+ <dd><em>Default: 59</em> - The maximum second allowed for all dates.</dd>
+
+ <dt>millisecMax</dt>
+ <dd><em>Default: 999</em> - The maximum millisecond allowed for all dates.</dd>
+
+ <dt>microsecMax</dt>
+ <dd><em>Default: 999</em> - The maximum microsecond allowed for all dates.</dd>
+
+ <dt>hourGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be generated under the slider. This number represents the units (in hours) between labels.</dd>
+
+ <dt>minuteGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be generated under the slider. This number represents the units (in minutes) between labels.</dd>
+
+ <dt>secondGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in seconds) between labels.</dd>
+
+ <dt>millisecGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in milliseconds) between labels.</dd>
+
+ <dt>microsecGrid</dt>
+ <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in microseconds) between labels.</dd>
+ </dl>
+
+ <h3>Other Options</h3>
+ <dl class="defs">
+ <dt>showButtonPanel</dt>
+ <dd><em>Default: true</em> - Whether to show the button panel at the bottom. This is generally needed.</dd>
+
+ <dt>timeOnly</dt>
+ <dd><em>Default: false</em> - Hide the datepicker and only provide a time interface.</dd>
+
+ <dt>onSelect</dt>
+ <dd><em>Default: null</em> - Function to be called when a date is chosen or time has changed (parameters: datetimeText, datepickerInstance).</dd>
+
+ <dt>alwaysSetTime</dt>
+ <dd><em>Default: true</em> - Always have a time set internally, even before user has chosen one.</dd>
+
+ <dt>separator</dt>
+ <dd><em>Default: " "</em> - When formatting the time this string is placed between the formatted date and formatted time.</dd>
+
+ <dt>pickerTimeFormat</dt>
+ <dd><em>Default: (timeFormat option)</em> - How to format the time displayed within the timepicker.</dd>
+
+ <dt>pickerTimeSuffix</dt>
+ <dd><em>Default: (timeSuffix option)</em> - String to place after the formatted time within the timepicker.</dd>
+
+ <dt>showTimepicker</dt>
+ <dd><em>Default: true</em> - Whether to show the timepicker within the datepicker.</dd>
+
+ <dt>addSliderAccess</dt>
+ <dd><em>Default: false</em> - Adds the <a href="http://trentrichardson.com/examples/jQuery-SliderAccess/" title="jQueryUI Slider Access Plugin">sliderAccess plugin</a> to sliders within timepicker</dd>
+
+ <dt>sliderAccessArgs</dt>
+ <dd><em>Default: null</em> - Object to pass to sliderAccess when used.</dd>
+
+ <dt>defaultValue</dt>
+ <dd><em>Default: null</em> - String of the default time value placed in the input on focus when the input is empty.</dd>
+
+ <dt>minDateTime</dt>
+ <dd><em>Default: null</em> - Date object of the minimum datetime allowed. Also available as minDate.</dd>
+
+ <dt>maxDateTime</dt>
+ <dd><em>Default: null</em> - Date object of the maximum datetime allowed. Also Available as maxDate.</dd>
+
+ <dt>parse</dt>
+ <dd><em>Default: 'strict'</em> - How to parse the time string. Two methods are provided: 'strict' which must match the timeFormat exactly, and 'loose' which uses javascript's new Date(timeString) to guess the time. You may also pass in a function(timeFormat, timeString, options) to handle the parsing yourself, returning a simple object:
+<pre>{
+ hour: 19,
+ minute: 10,
+ second: 23,
+ millisec: 45,
+ microsec: 23,
+ timezone: '-0400'
+}</pre>
+ </dd>
+ </dl>
+
+</div>
diff --git a/src/i18n/jquery-ui-timepicker-af.js b/src/i18n/jquery-ui-timepicker-af.js
new file mode 100644
index 0000000..fe9f8c5
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-af.js
@@ -0,0 +1,21 @@
+/* Afrikaans translation for the jQuery Timepicker Addon */
+/* Written by Deon Heyns */
+(function($) {
+ $.timepicker.regional['af'] = {
+ timeOnlyTitle: 'Kies Tyd',
+ timeText: 'Tyd ',
+ hourText: 'Ure ',
+ minuteText: 'Minute',
+ secondText: 'Sekondes',
+ millisecText: 'Millisekondes',
+ microsecText: 'Mikrosekondes',
+ timezoneText: 'Tydsone',
+ currentText: 'Huidige Tyd',
+ closeText: 'Klaar',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['af']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-bg.js b/src/i18n/jquery-ui-timepicker-bg.js
new file mode 100644
index 0000000..1efb439
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-bg.js
@@ -0,0 +1,21 @@
+/* Bulgarian translation for the jQuery Timepicker Addon */
+/* Written by Plamen Kovandjiev */
+(function($) {
+ $.timepicker.regional['bg'] = {
+ timeOnlyTitle: 'Изберете време',
+ timeText: 'Време',
+ hourText: 'Час',
+ minuteText: 'Минути',
+ secondText: 'Секунди',
+ millisecText: 'Милисекунди',
+ microsecText: 'Микросекунди',
+ timezoneText: 'Часови пояс',
+ currentText: 'Сега',
+ closeText: 'Затвори',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['bg']);
+})(jQuery); \ No newline at end of file
diff --git a/src/i18n/jquery-ui-timepicker-ca.js b/src/i18n/jquery-ui-timepicker-ca.js
new file mode 100644
index 0000000..25b4eed
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-ca.js
@@ -0,0 +1,21 @@
+/* Catalan translation for the jQuery Timepicker Addon */
+/* Written by Sergi Faber */
+(function($) {
+ $.timepicker.regional['ca'] = {
+ timeOnlyTitle: 'Escollir una hora',
+ timeText: 'Hora',
+ hourText: 'Hores',
+ minuteText: 'Minuts',
+ secondText: 'Segons',
+ millisecText: 'Milisegons',
+ microsecText: 'Microsegons',
+ timezoneText: 'Fus horari',
+ currentText: 'Ara',
+ closeText: 'Tancar',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['ca']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-cs.js b/src/i18n/jquery-ui-timepicker-cs.js
new file mode 100644
index 0000000..9d358fa
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-cs.js
@@ -0,0 +1,21 @@
+/* Czech translation for the jQuery Timepicker Addon */
+/* Written by Ondřej Vodáček */
+(function($) {
+ $.timepicker.regional['cs'] = {
+ timeOnlyTitle: 'Vyberte čas',
+ timeText: 'Čas',
+ hourText: 'Hodiny',
+ minuteText: 'Minuty',
+ secondText: 'Vteřiny',
+ millisecText: 'Milisekundy',
+ microsecText: 'Mikrosekundy',
+ timezoneText: 'Časové pásmo',
+ currentText: 'Nyní',
+ closeText: 'Zavřít',
+ timeFormat: 'HH:mm',
+ amNames: ['dop.', 'AM', 'A'],
+ pmNames: ['odp.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['cs']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-da.js b/src/i18n/jquery-ui-timepicker-da.js
new file mode 100644
index 0000000..7afb189
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-da.js
@@ -0,0 +1,21 @@
+/* Danish translation for the jQuery Timepicker Addon */
+/* Written by Lars H. Jensen (http://www.larshj.dk) */
+(function ($) {
+ $.timepicker.regional['da'] = {
+ timeOnlyTitle: 'Vælg tid',
+ timeText: 'Tid',
+ hourText: 'Time',
+ minuteText: 'Minut',
+ secondText: 'Sekund',
+ millisecText: 'Millisekund',
+ microsecText: 'Mikrosekund',
+ timezoneText: 'Tidszone',
+ currentText: 'Nu',
+ closeText: 'Luk',
+ timeFormat: 'HH:mm',
+ amNames: ['am', 'AM', 'A'],
+ pmNames: ['pm', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['da']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-de.js b/src/i18n/jquery-ui-timepicker-de.js
new file mode 100644
index 0000000..286be73
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-de.js
@@ -0,0 +1,21 @@
+/* German translation for the jQuery Timepicker Addon */
+/* Written by Marvin */
+(function($) {
+ $.timepicker.regional['de'] = {
+ timeOnlyTitle: 'Zeit Wählen',
+ timeText: 'Zeit',
+ hourText: 'Stunde',
+ minuteText: 'Minute',
+ secondText: 'Sekunde',
+ millisecText: 'Millisekunde',
+ microsecText: 'Mikrosekunde',
+ timezoneText: 'Zeitzone',
+ currentText: 'Jetzt',
+ closeText: 'Fertig',
+ timeFormat: 'HH:mm',
+ amNames: ['vorm.', 'AM', 'A'],
+ pmNames: ['nachm.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['de']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-el.js b/src/i18n/jquery-ui-timepicker-el.js
new file mode 100644
index 0000000..6b7e827
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-el.js
@@ -0,0 +1,21 @@
+/* Hellenic translation for the jQuery Timepicker Addon */
+/* Written by Christos Pontikis */
+(function($) {
+ $.timepicker.regional['el'] = {
+ timeOnlyTitle: 'Επιλογή ώρας',
+ timeText: 'Ώρα',
+ hourText: 'Ώρες',
+ minuteText: 'Λεπτά',
+ secondText: 'Δευτερόλεπτα',
+ millisecText: 'μιλιδευτερόλεπτο',
+ microsecText: 'Microseconds',
+ timezoneText: 'Ζώνη ώρας',
+ currentText: 'Τώρα',
+ closeText: 'Κλείσιμο',
+ timeFormat: 'HH:mm',
+ amNames: ['π.μ.', 'AM', 'A'],
+ pmNames: ['μ.μ.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['el']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-es.js b/src/i18n/jquery-ui-timepicker-es.js
new file mode 100644
index 0000000..d73a1e8
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-es.js
@@ -0,0 +1,21 @@
+/* Spanish translation for the jQuery Timepicker Addon */
+/* Written by Ianaré Sévi */
+(function($) {
+ $.timepicker.regional['es'] = {
+ timeOnlyTitle: 'Elegir una hora',
+ timeText: 'Hora',
+ hourText: 'Horas',
+ minuteText: 'Minutos',
+ secondText: 'Segundos',
+ millisecText: 'Milisegundos',
+ microsecText: 'Microsegundos',
+ timezoneText: 'Huso horario',
+ currentText: 'Ahora',
+ closeText: 'Cerrar',
+ timeFormat: 'HH:mm',
+ amNames: ['a.m.', 'AM', 'A'],
+ pmNames: ['p.m.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['es']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-et.js b/src/i18n/jquery-ui-timepicker-et.js
new file mode 100644
index 0000000..2e64cc8
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-et.js
@@ -0,0 +1,21 @@
+/* Estonian translation for the jQuery Timepicker Addon */
+/* Written by Karl Sutt (karl@sutt.ee) */
+(function($) {
+ $.timepicker.regional['et'] = {
+ timeOnlyTitle: 'Vali aeg',
+ timeText: 'Aeg',
+ hourText: 'Tund',
+ minuteText: 'Minut',
+ secondText: 'Sekund',
+ millisecText: 'Millisekundis',
+ microsecText: 'Mikrosekundis',
+ timezoneText: 'Ajavöönd',
+ currentText: 'Praegu',
+ closeText: 'Valmis',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['et']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-eu.js b/src/i18n/jquery-ui-timepicker-eu.js
new file mode 100644
index 0000000..41ba5a7
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-eu.js
@@ -0,0 +1,21 @@
+/* Basque trannslation for JQuery Timepicker Addon
+/* Translated by Xabi Fer */
+(function($) {
+ $.timepicker.regional['eu'] = {
+ timeOnlyTitle: 'Aukeratu ordua',
+ timeText: 'Ordua',
+ hourText: 'Orduak',
+ minuteText: 'Minutuak',
+ secondText: 'Segunduak',
+ millisecText: 'Milisegunduak',
+ microsecText: 'Mikrosegundotan',
+ timezoneText: 'Ordu-eremua',
+ currentText: 'Orain',
+ closeText: 'Itxi',
+ timeFormat: 'HH:mm',
+ amNames: ['a.m.', 'AM', 'A'],
+ pmNames: ['p.m.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['eu']);
+})(jQuery); \ No newline at end of file
diff --git a/src/i18n/jquery-ui-timepicker-fi.js b/src/i18n/jquery-ui-timepicker-fi.js
new file mode 100644
index 0000000..3f1d95e
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-fi.js
@@ -0,0 +1,21 @@
+/* Finnish translation for the jQuery Timepicker Addon */
+/* Written by Juga Paazmaya (http://github.com/paazmaya) */
+(function($) {
+ $.timepicker.regional['fi'] = {
+ timeOnlyTitle: 'Valitse aika',
+ timeText: 'Aika',
+ hourText: 'Tunti',
+ minuteText: 'Minuutti',
+ secondText: 'Sekunti',
+ millisecText: 'Millisekunnin',
+ microsecText: 'Mikrosekuntia',
+ timezoneText: 'Aikavyöhyke',
+ currentText: 'Nyt',
+ closeText: 'Sulje',
+ timeFormat: 'HH:mm',
+ amNames: ['ap.', 'AM', 'A'],
+ pmNames: ['ip.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['fi']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-fr.js b/src/i18n/jquery-ui-timepicker-fr.js
new file mode 100644
index 0000000..a8a46fe
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-fr.js
@@ -0,0 +1,21 @@
+/* French translation for the jQuery Timepicker Addon */
+/* Written by Thomas Lété */
+(function($) {
+ $.timepicker.regional['fr'] = {
+ timeOnlyTitle: 'Choisir une heure',
+ timeText: 'Heure',
+ hourText: 'Heures',
+ minuteText: 'Minutes',
+ secondText: 'Secondes',
+ millisecText: 'Millisecondes',
+ microsecText: 'Microsecondes',
+ timezoneText: 'Fuseau horaire',
+ currentText: 'Maintenant',
+ closeText: 'Terminé',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['fr']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-gl.js b/src/i18n/jquery-ui-timepicker-gl.js
new file mode 100644
index 0000000..900e377
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-gl.js
@@ -0,0 +1,21 @@
+/* Galician translation for the jQuery Timepicker Addon */
+/* Written by David Barral */
+(function($) {
+ $.timepicker.regional['gl'] = {
+ timeOnlyTitle: 'Elixir unha hora',
+ timeText: 'Hora',
+ hourText: 'Horas',
+ minuteText: 'Minutos',
+ secondText: 'Segundos',
+ millisecText: 'Milisegundos',
+ microsecText: 'Microssegundos',
+ timezoneText: 'Fuso horario',
+ currentText: 'Agora',
+ closeText: 'Pechar',
+ timeFormat: 'HH:mm',
+ amNames: ['a.m.', 'AM', 'A'],
+ pmNames: ['p.m.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['gl']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-he.js b/src/i18n/jquery-ui-timepicker-he.js
new file mode 100644
index 0000000..eb71018
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-he.js
@@ -0,0 +1,21 @@
+/* Hebrew translation for the jQuery Timepicker Addon */
+/* Written by Lior Lapid */
+(function($) {
+ $.timepicker.regional["he"] = {
+ timeOnlyTitle: "בחירת זמן",
+ timeText: "שעה",
+ hourText: "שעות",
+ minuteText: "דקות",
+ secondText: "שניות",
+ millisecText: "אלפית השנייה",
+ microsecText: "מיקרו",
+ timezoneText: "אזור זמן",
+ currentText: "עכשיו",
+ closeText:"סגור",
+ timeFormat: "HH:mm",
+ amNames: ['לפנה"צ', 'AM', 'A'],
+ pmNames: ['אחה"צ', 'PM', 'P'],
+ isRTL: true
+ };
+ $.timepicker.setDefaults($.timepicker.regional["he"]);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-hr.js b/src/i18n/jquery-ui-timepicker-hr.js
new file mode 100644
index 0000000..c314b8e
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-hr.js
@@ -0,0 +1,21 @@
+/* Croatian translation for the jQuery Timepicker Addon */
+/* Written by Mladen */
+(function($) {
+ $.timepicker.regional['hr'] = {
+ timeOnlyTitle: 'Odaberi vrijeme',
+ timeText: 'Vrijeme',
+ hourText: 'Sati',
+ minuteText: 'Minute',
+ secondText: 'Sekunde',
+ millisecText: 'Milisekunde',
+ microsecText: 'Mikrosekunde',
+ timezoneText: 'Vremenska zona',
+ currentText: 'Sada',
+ closeText: 'Gotovo',
+ timeFormat: 'HH:mm',
+ amNames: ['a.m.', 'AM', 'A'],
+ pmNames: ['p.m.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['hr']);
+})(jQuery); \ No newline at end of file
diff --git a/src/i18n/jquery-ui-timepicker-hu.js b/src/i18n/jquery-ui-timepicker-hu.js
new file mode 100644
index 0000000..fd1f5e1
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-hu.js
@@ -0,0 +1,21 @@
+/* Hungarian translation for the jQuery Timepicker Addon */
+/* Written by Vas Gábor */
+(function($) {
+ $.timepicker.regional['hu'] = {
+ timeOnlyTitle: 'Válasszon időpontot',
+ timeText: 'Idő',
+ hourText: 'Óra',
+ minuteText: 'Perc',
+ secondText: 'Másodperc',
+ millisecText: 'Milliszekundumos',
+ microsecText: 'Ezredmásodperc',
+ timezoneText: 'Időzóna',
+ currentText: 'Most',
+ closeText: 'Kész',
+ timeFormat: 'HH:mm',
+ amNames: ['de.', 'AM', 'A'],
+ pmNames: ['du.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['hu']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-id.js b/src/i18n/jquery-ui-timepicker-id.js
new file mode 100644
index 0000000..50a976b
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-id.js
@@ -0,0 +1,21 @@
+/* Indonesian translation for the jQuery Timepicker Addon */
+/* Written by Nia */
+(function($) {
+ $.timepicker.regional['id'] = {
+ timeOnlyTitle: 'Pilih Waktu',
+ timeText: 'Waktu',
+ hourText: 'Pukul',
+ minuteText: 'Menit',
+ secondText: 'Detik',
+ millisecText: 'Milidetik',
+ microsecText: 'Mikrodetik',
+ timezoneText: 'Zona Waktu',
+ currentText: 'Sekarang',
+ closeText: 'OK',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['id']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-it.js b/src/i18n/jquery-ui-timepicker-it.js
new file mode 100644
index 0000000..ea976fd
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-it.js
@@ -0,0 +1,21 @@
+/* Italian translation for the jQuery Timepicker Addon */
+/* Written by Marco "logicoder" Del Tongo */
+(function($) {
+ $.timepicker.regional['it'] = {
+ timeOnlyTitle: 'Scegli orario',
+ timeText: 'Orario',
+ hourText: 'Ora',
+ minuteText: 'Minuti',
+ secondText: 'Secondi',
+ millisecText: 'Millisecondi',
+ microsecText: 'Microsecondi',
+ timezoneText: 'Fuso orario',
+ currentText: 'Adesso',
+ closeText: 'Chiudi',
+ timeFormat: 'HH:mm',
+ amNames: ['m.', 'AM', 'A'],
+ pmNames: ['p.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['it']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-ja.js b/src/i18n/jquery-ui-timepicker-ja.js
new file mode 100644
index 0000000..15c7b79
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-ja.js
@@ -0,0 +1,21 @@
+/* Japanese translation for the jQuery Timepicker Addon */
+/* Written by Jun Omae */
+(function($) {
+ $.timepicker.regional['ja'] = {
+ timeOnlyTitle: '時間を選択',
+ timeText: '時間',
+ hourText: '時',
+ minuteText: '分',
+ secondText: '秒',
+ millisecText: 'ミリ秒',
+ microsecText: 'マイクロ秒',
+ timezoneText: 'タイムゾーン',
+ currentText: '現時刻',
+ closeText: '閉じる',
+ timeFormat: 'HH:mm',
+ amNames: ['午前', 'AM', 'A'],
+ pmNames: ['午後', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['ja']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-ko.js b/src/i18n/jquery-ui-timepicker-ko.js
new file mode 100644
index 0000000..0a41c5b
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-ko.js
@@ -0,0 +1,21 @@
+/* Korean translation for the jQuery Timepicker Addon */
+/* Written by Genie */
+(function($) {
+ $.timepicker.regional['ko'] = {
+ timeOnlyTitle: '시간 선택',
+ timeText: '시간',
+ hourText: '시',
+ minuteText: '분',
+ secondText: '초',
+ millisecText: '밀리초',
+ microsecText: '마이크로',
+ timezoneText: '표준 시간대',
+ currentText: '현재 시각',
+ closeText: '닫기',
+ timeFormat: 'tt h:mm',
+ amNames: ['오전', 'AM', 'A'],
+ pmNames: ['오후', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['ko']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-lt.js b/src/i18n/jquery-ui-timepicker-lt.js
new file mode 100644
index 0000000..eb7b3c7
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-lt.js
@@ -0,0 +1,21 @@
+/* Lithuanian translation for the jQuery Timepicker Addon */
+/* Written by Irmantas Šiupšinskas */
+(function($) {
+ $.timepicker.regional['lt'] = {
+ timeOnlyTitle: 'Pasirinkite laiką',
+ timeText: 'Laikas',
+ hourText: 'Valandos',
+ minuteText: 'Minutės',
+ secondText: 'Sekundės',
+ millisecText: 'Milisekundės',
+ microsecText: 'Mikrosekundės',
+ timezoneText: 'Laiko zona',
+ currentText: 'Dabar',
+ closeText: 'Uždaryti',
+ timeFormat: 'HH:mm',
+ amNames: ['priešpiet', 'AM', 'A'],
+ pmNames: ['popiet', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['lt']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-nl.js b/src/i18n/jquery-ui-timepicker-nl.js
new file mode 100644
index 0000000..8189cc4
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-nl.js
@@ -0,0 +1,21 @@
+/* Dutch translation for the jQuery Timepicker Addon */
+/* Written by Martijn van der Lee */
+(function($) {
+ $.timepicker.regional['nl'] = {
+ timeOnlyTitle: 'Tijdstip',
+ timeText: 'Tijd',
+ hourText: 'Uur',
+ minuteText: 'Minuut',
+ secondText: 'Seconde',
+ millisecText: 'Milliseconde',
+ microsecText: 'Microseconde',
+ timezoneText: 'Tijdzone',
+ currentText: 'Vandaag',
+ closeText: 'Sluiten',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['nl']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-no.js b/src/i18n/jquery-ui-timepicker-no.js
new file mode 100644
index 0000000..1eeee6d
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-no.js
@@ -0,0 +1,21 @@
+/* Norwegian translation for the jQuery Timepicker Addon */
+/* Written by Morten Hauan (http://hauan.me) */
+(function($) {
+ $.timepicker.regional['no'] = {
+ timeOnlyTitle: 'Velg tid',
+ timeText: 'Tid',
+ hourText: 'Time',
+ minuteText: 'Minutt',
+ secondText: 'Sekund',
+ millisecText: 'Millisekund',
+ microsecText: 'mikrosekund',
+ timezoneText: 'Tidssone',
+ currentText: 'Nå',
+ closeText: 'Lukk',
+ timeFormat: 'HH:mm',
+ amNames: ['am', 'AM', 'A'],
+ pmNames: ['pm', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['no']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-pl.js b/src/i18n/jquery-ui-timepicker-pl.js
new file mode 100644
index 0000000..5b7d4a9
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-pl.js
@@ -0,0 +1,21 @@
+/* Polish translation for the jQuery Timepicker Addon */
+/* Written by Michał Pena */
+(function($) {
+ $.timepicker.regional['pl'] = {
+ timeOnlyTitle: 'Wybierz godzinę',
+ timeText: 'Czas',
+ hourText: 'Godzina',
+ minuteText: 'Minuta',
+ secondText: 'Sekunda',
+ millisecText: 'Milisekunda',
+ microsecText: 'Mikrosekunda',
+ timezoneText: 'Strefa czasowa',
+ currentText: 'Teraz',
+ closeText: 'Gotowe',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['pl']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-pt-BR.js b/src/i18n/jquery-ui-timepicker-pt-BR.js
new file mode 100644
index 0000000..2c1b02f
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-pt-BR.js
@@ -0,0 +1,21 @@
+/* Brazilian Portuguese translation for the jQuery Timepicker Addon */
+/* Written by Diogo Damiani (diogodamiani@gmail.com) */
+(function ($) {
+ $.timepicker.regional['pt-BR'] = {
+ timeOnlyTitle: 'Escolha o horário',
+ timeText: 'Horário',
+ hourText: 'Hora',
+ minuteText: 'Minutos',
+ secondText: 'Segundos',
+ millisecText: 'Milissegundos',
+ microsecText: 'Microssegundos',
+ timezoneText: 'Fuso horário',
+ currentText: 'Agora',
+ closeText: 'Fechar',
+ timeFormat: 'HH:mm',
+ amNames: ['a.m.', 'AM', 'A'],
+ pmNames: ['p.m.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['pt-BR']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-pt.js b/src/i18n/jquery-ui-timepicker-pt.js
new file mode 100644
index 0000000..bc549e0
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-pt.js
@@ -0,0 +1,21 @@
+/* Portuguese translation for the jQuery Timepicker Addon */
+/* Written by Luan Almeida */
+(function($) {
+ $.timepicker.regional['pt'] = {
+ timeOnlyTitle: 'Escolha uma hora',
+ timeText: 'Hora',
+ hourText: 'Horas',
+ minuteText: 'Minutos',
+ secondText: 'Segundos',
+ millisecText: 'Milissegundos',
+ microsecText: 'Microssegundos',
+ timezoneText: 'Fuso horário',
+ currentText: 'Agora',
+ closeText: 'Fechar',
+ timeFormat: 'HH:mm',
+ amNames: ['a.m.', 'AM', 'A'],
+ pmNames: ['p.m.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['pt']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-ro.js b/src/i18n/jquery-ui-timepicker-ro.js
new file mode 100644
index 0000000..01acce7
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-ro.js
@@ -0,0 +1,21 @@
+/* Romanian translation for the jQuery Timepicker Addon */
+/* Written by Romeo Adrian Cioaba */
+(function($) {
+ $.timepicker.regional['ro'] = {
+ timeOnlyTitle: 'Alegeţi o oră',
+ timeText: 'Timp',
+ hourText: 'Ore',
+ minuteText: 'Minute',
+ secondText: 'Secunde',
+ millisecText: 'Milisecunde',
+ microsecText: 'Microsecunde',
+ timezoneText: 'Fus orar',
+ currentText: 'Acum',
+ closeText: 'Închide',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['ro']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-ru.js b/src/i18n/jquery-ui-timepicker-ru.js
new file mode 100644
index 0000000..d7169fa
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-ru.js
@@ -0,0 +1,21 @@
+/* Russian translation for the jQuery Timepicker Addon */
+/* Written by Trent Richardson */
+(function($) {
+ $.timepicker.regional['ru'] = {
+ timeOnlyTitle: 'Выберите время',
+ timeText: 'Время',
+ hourText: 'Часы',
+ minuteText: 'Минуты',
+ secondText: 'Секунды',
+ millisecText: 'Миллисекунды',
+ microsecText: 'Микросекунды',
+ timezoneText: 'Часовой пояс',
+ currentText: 'Сейчас',
+ closeText: 'Закрыть',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['ru']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-sk.js b/src/i18n/jquery-ui-timepicker-sk.js
new file mode 100644
index 0000000..15700e0
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-sk.js
@@ -0,0 +1,21 @@
+/* Slovak translation for the jQuery Timepicker Addon */
+/* Written by David Vallner */
+(function($) {
+ $.timepicker.regional['sk'] = {
+ timeOnlyTitle: 'Zvoľte čas',
+ timeText: 'Čas',
+ hourText: 'Hodiny',
+ minuteText: 'Minúty',
+ secondText: 'Sekundy',
+ millisecText: 'Milisekundy',
+ microsecText: 'Mikrosekundy',
+ timezoneText: 'Časové pásmo',
+ currentText: 'Teraz',
+ closeText: 'Zavrieť',
+ timeFormat: 'H:m',
+ amNames: ['dop.', 'AM', 'A'],
+ pmNames: ['pop.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['sk']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-sv.js b/src/i18n/jquery-ui-timepicker-sv.js
new file mode 100644
index 0000000..4540ac6
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-sv.js
@@ -0,0 +1,21 @@
+/* Swedish translation for the jQuery Timepicker Addon */
+/* Written by Nevon */
+(function($) {
+ $.timepicker.regional['sv'] = {
+ timeOnlyTitle: 'Välj en tid',
+ timeText: 'Tid',
+ hourText: 'Timme',
+ minuteText: 'Minut',
+ secondText: 'Sekund',
+ millisecText: 'Millisekund',
+ microsecText: 'Mikrosekund',
+ timezoneText: 'Tidszon',
+ currentText: 'Nu',
+ closeText: 'Stäng',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['sv']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-th.js b/src/i18n/jquery-ui-timepicker-th.js
new file mode 100644
index 0000000..7042e8c
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-th.js
@@ -0,0 +1,18 @@
+/* Thai translation for the jQuery Timepicker Addon */
+/* Written by Yote Wachirapornpongsa */
+(function($) {
+ $.timepicker.regional['th'] = {
+ timeOnlyTitle: 'เลือกเวลา',
+ timeText: 'เวลา ',
+ hourText: 'ชั่วโมง ',
+ minuteText: 'นาที',
+ secondText: 'วินาที',
+ millisecText: 'มิลลิวินาที',
+ microsecText: 'ไมโคริวินาที',
+ timezoneText: 'เขตเวลา',
+ currentText: 'เวลาปัจจุบัน',
+ closeText: 'ปิด',
+ timeFormat: 'hh:mm tt'
+ };
+ $.timepicker.setDefaults($.timepicker.regional['th']);
+})(jQuery); \ No newline at end of file
diff --git a/src/i18n/jquery-ui-timepicker-tr.js b/src/i18n/jquery-ui-timepicker-tr.js
new file mode 100644
index 0000000..51f89d6
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-tr.js
@@ -0,0 +1,21 @@
+/* Turkish translation for the jQuery Timepicker Addon */
+/* Written by Fehmi Can Saglam, Edited by Goktug Ozturk */
+(function($) {
+ $.timepicker.regional['tr'] = {
+ timeOnlyTitle: 'Zaman Seçiniz',
+ timeText: 'Zaman',
+ hourText: 'Saat',
+ minuteText: 'Dakika',
+ secondText: 'Saniye',
+ millisecText: 'Milisaniye',
+ microsecText: 'Mikrosaniye',
+ timezoneText: 'Zaman Dilimi',
+ currentText: 'Şu an',
+ closeText: 'Tamam',
+ timeFormat: 'HH:mm',
+ amNames: ['ÖÖ', 'Ö'],
+ pmNames: ['ÖS', 'S'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['tr']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-uk.js b/src/i18n/jquery-ui-timepicker-uk.js
new file mode 100644
index 0000000..a239fe2
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-uk.js
@@ -0,0 +1,21 @@
+/* Ukrainian translation for the jQuery Timepicker Addon */
+/* Written by Sergey Noskov */
+(function($) {
+ $.timepicker.regional['uk'] = {
+ timeOnlyTitle: 'Виберіть час',
+ timeText: 'Час',
+ hourText: 'Години',
+ minuteText: 'Хвилини',
+ secondText: 'Секунди',
+ millisecText: 'Мілісекунди',
+ microsecText: 'Мікросекунди',
+ timezoneText: 'Часовий пояс',
+ currentText: 'Зараз',
+ closeText: 'Закрити',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['uk']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-vi.js b/src/i18n/jquery-ui-timepicker-vi.js
new file mode 100644
index 0000000..48b05f1
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-vi.js
@@ -0,0 +1,21 @@
+/* Vietnamese translation for the jQuery Timepicker Addon */
+/* Written by Nguyen Dinh Trung */
+(function($) {
+ $.timepicker.regional['vi'] = {
+ timeOnlyTitle: 'Chọn giờ',
+ timeText: 'Thời gian',
+ hourText: 'Giờ',
+ minuteText: 'Phút',
+ secondText: 'Giây',
+ millisecText: 'Phần nghìn giây',
+ microsecText: 'Miligiây',
+ timezoneText: 'Múi giờ',
+ currentText: 'Hiện thời',
+ closeText: 'Đóng',
+ timeFormat: 'H:m',
+ amNames: ['SA', 'AM', 'A'],
+ pmNames: ['CH', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['vi']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-zh-CN.js b/src/i18n/jquery-ui-timepicker-zh-CN.js
new file mode 100644
index 0000000..7488c04
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-zh-CN.js
@@ -0,0 +1,21 @@
+/* Simplified Chinese translation for the jQuery Timepicker Addon /
+/ Written by Will Lu */
+(function($) {
+ $.timepicker.regional['zh-CN'] = {
+ timeOnlyTitle: '选择时间',
+ timeText: '时间',
+ hourText: '小时',
+ minuteText: '分钟',
+ secondText: '秒钟',
+ millisecText: '微秒',
+ microsecText: '微秒',
+ timezoneText: '时区',
+ currentText: '现在时间',
+ closeText: '关闭',
+ timeFormat: 'HH:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['zh-CN']);
+})(jQuery);
diff --git a/src/i18n/jquery-ui-timepicker-zh-TW.js b/src/i18n/jquery-ui-timepicker-zh-TW.js
new file mode 100644
index 0000000..9cbeabf
--- /dev/null
+++ b/src/i18n/jquery-ui-timepicker-zh-TW.js
@@ -0,0 +1,21 @@
+/* Chinese translation for the jQuery Timepicker Addon */
+/* Written by Alang.lin */
+(function($) {
+ $.timepicker.regional['zh-TW'] = {
+ timeOnlyTitle: '選擇時分秒',
+ timeText: '時間',
+ hourText: '時',
+ minuteText: '分',
+ secondText: '秒',
+ millisecText: '毫秒',
+ microsecText: '微秒',
+ timezoneText: '時區',
+ currentText: '現在時間',
+ closeText: '確定',
+ timeFormat: 'HH:mm',
+ amNames: ['上午', 'AM', 'A'],
+ pmNames: ['下午', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['zh-TW']);
+})(jQuery);
diff --git a/src/jquery-ui-sliderAccess.js b/src/jquery-ui-sliderAccess.js
new file mode 100644
index 0000000..b075c66
--- /dev/null
+++ b/src/jquery-ui-sliderAccess.js
@@ -0,0 +1,91 @@
+/*
+ * jQuery UI Slider Access
+ * By: Trent Richardson [http://trentrichardson.com]
+ * Version 0.3
+ * Last Modified: 10/20/2012
+ *
+ * Copyright 2011 Trent Richardson
+ * Dual licensed under the MIT and GPL licenses.
+ * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
+ * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
+ *
+ */
+ (function($){
+
+ $.fn.extend({
+ sliderAccess: function(options){
+ options = options || {};
+ options.touchonly = options.touchonly !== undefined? options.touchonly : true; // by default only show it if touch device
+
+ if(options.touchonly === true && !("ontouchend" in document)){
+ return $(this);
+ }
+
+ return $(this).each(function(i,obj){
+ var $t = $(this),
+ o = $.extend({},{
+ where: 'after',
+ step: $t.slider('option','step'),
+ upIcon: 'ui-icon-plus',
+ downIcon: 'ui-icon-minus',
+ text: false,
+ upText: '+',
+ downText: '-',
+ buttonset: true,
+ buttonsetTag: 'span',
+ isRTL: false
+ }, options),
+ $buttons = $('<'+ o.buttonsetTag +' class="ui-slider-access">'+
+ '<button data-icon="'+ o.downIcon +'" data-step="'+ (o.isRTL? o.step : o.step*-1) +'">'+ o.downText +'</button>'+
+ '<button data-icon="'+ o.upIcon +'" data-step="'+ (o.isRTL? o.step*-1 : o.step) +'">'+ o.upText +'</button>'+
+ '</'+ o.buttonsetTag +'>');
+
+ $buttons.children('button').each(function(j, jobj){
+ var $jt = $(this);
+ $jt.button({
+ text: o.text,
+ icons: { primary: $jt.data('icon') }
+ })
+ .click(function(e){
+ var step = $jt.data('step'),
+ curr = $t.slider('value'),
+ newval = curr += step*1,
+ minval = $t.slider('option','min'),
+ maxval = $t.slider('option','max'),
+ slidee = $t.slider("option", "slide") || function(){},
+ stope = $t.slider("option", "stop") || function(){};
+
+ e.preventDefault();
+
+ if(newval < minval || newval > maxval){
+ return;
+ }
+
+ $t.slider('value', newval);
+
+ slidee.call($t, null, { value: newval });
+ stope.call($t, null, { value: newval });
+ });
+ });
+
+ // before or after
+ $t[o.where]($buttons);
+
+ if(o.buttonset){
+ $buttons.removeClass('ui-corner-right').removeClass('ui-corner-left').buttonset();
+ $buttons.eq(0).addClass('ui-corner-left');
+ $buttons.eq(1).addClass('ui-corner-right');
+ }
+
+ // adjust the width so we don't break the original layout
+ var bOuterWidth = $buttons.css({
+ marginLeft: ((o.where === 'after' && !o.isRTL) || (o.where === 'before' && o.isRTL)? 10:0),
+ marginRight: ((o.where === 'before' && !o.isRTL) || (o.where === 'after' && o.isRTL)? 10:0)
+ }).outerWidth(true) + 5;
+ var tOuterWidth = $t.outerWidth(true);
+ $t.css('display','inline-block').width(tOuterWidth-bOuterWidth);
+ });
+ }
+ });
+
+})(jQuery); \ No newline at end of file
diff --git a/src/jquery-ui-timepicker-addon.css b/src/jquery-ui-timepicker-addon.css
new file mode 100644
index 0000000..da12d98
--- /dev/null
+++ b/src/jquery-ui-timepicker-addon.css
@@ -0,0 +1,11 @@
+.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
+.ui-timepicker-div dl { text-align: left; }
+.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
+.ui-timepicker-div dl dd { margin: 0 10px 10px 40%; }
+.ui-timepicker-div td { font-size: 90%; }
+.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
+
+.ui-timepicker-rtl{ direction: rtl; }
+.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
+.ui-timepicker-rtl dl dt{ float: right; clear: right; }
+.ui-timepicker-rtl dl dd { margin: 0 40% 10px 10px; } \ No newline at end of file
diff --git a/jquery-ui-timepicker-addon.js b/src/jquery-ui-timepicker-addon.js
index 1a22b0c..de84a99 100644
--- a/jquery-ui-timepicker-addon.js
+++ b/src/jquery-ui-timepicker-addon.js
@@ -1,18 +1,13 @@
/*
- * jQuery timepicker addon
+ * jQuery Timepicker Addon
* By: Trent Richardson [http://trentrichardson.com]
- * Version 1.3.1
- * Last Modified: 07/07/2013
*
* Copyright 2013 Trent Richardson
- * You may use this project under MIT or GPL licenses.
- * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
+ * You may use this project under MIT license.
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
*/
-/*jslint evil: true, white: false, undef: false, nomen: false */
-
-(function($) {
+(function ($) {
/*
* Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded"
@@ -27,7 +22,7 @@
*/
$.extend($.ui, {
timepicker: {
- version: "1.3.1"
+ version: "@@version"
}
});
@@ -37,7 +32,7 @@
* Settings for (groups of) time pickers are maintained in an instance object,
* allowing multiple different settings on the same page.
*/
- var Timepicker = function() {
+ var Timepicker = function () {
this.regional = []; // Available regional settings, indexed by language code
this.regional[''] = { // Default regional settings
currentText: 'Now',
@@ -146,16 +141,16 @@
formattedTime: '',
formattedDateTime: '',
timezoneList: null,
- units: ['hour','minute','second','millisec', 'microsec'],
+ units: ['hour', 'minute', 'second', 'millisec', 'microsec'],
support: {},
control: null,
/*
* Override the default settings for all instances of the time picker.
- * @param settings object - the new settings to use as defaults (anonymous object)
- * @return the manager object
+ * @param {Object} settings object - the new settings to use as defaults (anonymous object)
+ * @return {Object} the manager object
*/
- setDefaults: function(settings) {
+ setDefaults: function (settings) {
extendRemove(this._defaults, settings || {});
return this;
},
@@ -163,14 +158,14 @@
/*
* Create a new Timepicker instance
*/
- _newInst: function($input, opts) {
+ _newInst: function ($input, opts) {
var tp_inst = new Timepicker(),
inlineSettings = {},
- fns = {},
- overrides, i;
+ fns = {},
+ overrides, i;
for (var attrName in this._defaults) {
- if(this._defaults.hasOwnProperty(attrName)){
+ if (this._defaults.hasOwnProperty(attrName)) {
var attrValue = $input.attr('time:' + attrName);
if (attrValue) {
try {
@@ -182,72 +177,72 @@
}
}
- overrides = {
- beforeShow: function (input, dp_inst) {
- if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
- return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
- }
- },
- onChangeMonthYear: function (year, month, dp_inst) {
- // Update the time as well : this prevents the time from disappearing from the $input field.
- tp_inst._updateDateTime(dp_inst);
- if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
- tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
- }
- },
- onClose: function (dateText, dp_inst) {
- if (tp_inst.timeDefined === true && $input.val() !== '') {
- tp_inst._updateDateTime(dp_inst);
- }
- if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
- tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
- }
- }
- };
- for (i in overrides) {
- if (overrides.hasOwnProperty(i)) {
- fns[i] = opts[i] || null;
- }
- }
-
- tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, {
- evnts:fns,
- timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
- });
- tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) {
+ overrides = {
+ beforeShow: function (input, dp_inst) {
+ if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
+ return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
+ }
+ },
+ onChangeMonthYear: function (year, month, dp_inst) {
+ // Update the time as well : this prevents the time from disappearing from the $input field.
+ tp_inst._updateDateTime(dp_inst);
+ if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
+ tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
+ }
+ },
+ onClose: function (dateText, dp_inst) {
+ if (tp_inst.timeDefined === true && $input.val() !== '') {
+ tp_inst._updateDateTime(dp_inst);
+ }
+ if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
+ tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
+ }
+ }
+ };
+ for (i in overrides) {
+ if (overrides.hasOwnProperty(i)) {
+ fns[i] = opts[i] || null;
+ }
+ }
+
+ tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, {
+ evnts: fns,
+ timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
+ });
+ tp_inst.amNames = $.map(tp_inst._defaults.amNames, function (val) {
return val.toUpperCase();
});
- tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) {
+ tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function (val) {
return val.toUpperCase();
});
// detect which units are supported
tp_inst.support = detectSupport(
tp_inst._defaults.timeFormat +
- (tp_inst._defaults.pickerTimeFormat? tp_inst._defaults.pickerTimeFormat:'') +
- (tp_inst._defaults.altTimeFormat? tp_inst._defaults.altTimeFormat:''));
+ (tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') +
+ (tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : ''));
// controlType is string - key to our this._controls
- if(typeof(tp_inst._defaults.controlType) === 'string'){
- if(tp_inst._defaults.controlType == 'slider' && typeof(jQuery.ui.slider) === 'undefined'){
+ if (typeof(tp_inst._defaults.controlType) === 'string') {
+ if (tp_inst._defaults.controlType === 'slider' && typeof($.ui.slider) === 'undefined') {
tp_inst._defaults.controlType = 'select';
}
tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType];
}
// controlType is an object and must implement create, options, value methods
- else{
+ else {
tp_inst.control = tp_inst._defaults.controlType;
}
// prep the timezone options
- var timezoneList = [-720,-660,-600,-570,-540,-480,-420,-360,-300,-270,-240,-210,-180,-120,-60,
- 0,60,120,180,210,240,270,300,330,345,360,390,420,480,525,540,570,600,630,660,690,720,765,780,840];
+ var timezoneList = [-720, -660, -600, -570, -540, -480, -420, -360, -300, -270, -240, -210, -180, -120, -60,
+ 0, 60, 120, 180, 210, 240, 270, 300, 330, 345, 360, 390, 420, 480, 525, 540, 570, 600, 630, 660, 690, 720, 765, 780, 840];
if (tp_inst._defaults.timezoneList !== null) {
timezoneList = tp_inst._defaults.timezoneList;
}
- var tzl=timezoneList.length,tzi=0,tzv=null;
+ var tzl = timezoneList.length, tzi = 0, tzv = null;
if (tzl > 0 && typeof timezoneList[0] !== 'object') {
- for(; tzi<tzl; tzi++){
+ for (; tzi < tzl; tzi++) {
tzv = timezoneList[tzi];
timezoneList[tzi] = { value: tzv, label: $.timepicker.timezoneOffsetString(tzv, tp_inst.support.iso8601) };
}
@@ -255,25 +250,25 @@
tp_inst._defaults.timezoneList = timezoneList;
// set the default units
- tp_inst.timezone = tp_inst._defaults.timezone !== null? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
- ((new Date()).getTimezoneOffset()*-1);
- tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
- tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
- tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
- tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
- tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
- tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second;
- tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
- tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
- tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin? tp_inst._defaults.microsecMin :
- tp_inst._defaults.microsec > tp_inst._defaults.microsecMax? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec;
+ tp_inst.timezone = tp_inst._defaults.timezone !== null ? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
+ ((new Date()).getTimezoneOffset() * -1);
+ tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin ? tp_inst._defaults.hourMin :
+ tp_inst._defaults.hour > tp_inst._defaults.hourMax ? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
+ tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin ? tp_inst._defaults.minuteMin :
+ tp_inst._defaults.minute > tp_inst._defaults.minuteMax ? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
+ tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin ? tp_inst._defaults.secondMin :
+ tp_inst._defaults.second > tp_inst._defaults.secondMax ? tp_inst._defaults.secondMax : tp_inst._defaults.second;
+ tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin ? tp_inst._defaults.millisecMin :
+ tp_inst._defaults.millisec > tp_inst._defaults.millisecMax ? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
+ tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin ? tp_inst._defaults.microsecMin :
+ tp_inst._defaults.microsec > tp_inst._defaults.microsecMax ? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec;
tp_inst.ampm = '';
tp_inst.$input = $input;
if (tp_inst._defaults.altField) {
tp_inst.$altInput = $(tp_inst._defaults.altField).css({
cursor: 'pointer'
- }).focus(function() {
+ }).focus(function () {
$input.trigger("focus");
});
}
@@ -298,7 +293,7 @@
if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
}
- tp_inst.$input.bind('focus', function() {
+ tp_inst.$input.bind('focus', function () {
tp_inst._onFocus();
});
@@ -308,7 +303,7 @@
/*
* add our sliders to the calendar
*/
- _addTimePicker: function(dp_inst) {
+ _addTimePicker: function (dp_inst) {
var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val();
this.timeDefined = this._parseTime(currDT);
@@ -319,7 +314,7 @@
/*
* parse the time string from input value or _setTime
*/
- _parseTime: function(timeString, withDate) {
+ _parseTime: function (timeString, withDate) {
if (!this.inst) {
this.inst = $.datepicker._getInst(this.$input[0]);
}
@@ -353,7 +348,7 @@
/*
* generate and inject html for timepicker into ui datepicker
*/
- _injectTimePicker: function() {
+ _injectTimePicker: function () {
var $dp = this.inst.dpDiv,
o = this.inst.settings,
tp_inst = this,
@@ -363,44 +358,44 @@
max = {},
gridSize = {},
size = null,
- i=0,
- l=0;
+ i = 0,
+ l = 0;
// Prevent displaying twice
if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
var noDisplay = ' style="display:none;"',
- html = '<div class="ui-timepicker-div'+ (o.isRTL? ' ui-timepicker-rtl' : '') +'"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
+ html = '<div class="ui-timepicker-div' + (o.isRTL ? ' ui-timepicker-rtl' : '') + '"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
'<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
// Create the markup
- for(i=0,l=this.units.length; i<l; i++){
+ for (i = 0, l = this.units.length; i < l; i++) {
litem = this.units[i];
- uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
- show = o['show'+uitem] !== null? o['show'+uitem] : this.support[litem];
+ uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
+ show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
// Added by Peter Medeiros:
// - Figure out what the hour/minute/second max should be based on the step values.
// - Example: if stepMinute is 15, then minMax is 45.
- max[litem] = parseInt((o[litem+'Max'] - ((o[litem+'Max'] - o[litem+'Min']) % o['step'+uitem])), 10);
+ max[litem] = parseInt((o[litem + 'Max'] - ((o[litem + 'Max'] - o[litem + 'Min']) % o['step' + uitem])), 10);
gridSize[litem] = 0;
- html += '<dt class="ui_tpicker_'+ litem +'_label"' + (show ? '' : noDisplay) + '>' + o[litem +'Text'] + '</dt>' +
- '<dd class="ui_tpicker_'+ litem +'"><div class="ui_tpicker_'+ litem +'_slider"' + (show ? '' : noDisplay) + '></div>';
+ html += '<dt class="ui_tpicker_' + litem + '_label"' + (show ? '' : noDisplay) + '>' + o[litem + 'Text'] + '</dt>' +
+ '<dd class="ui_tpicker_' + litem + '"><div class="ui_tpicker_' + litem + '_slider"' + (show ? '' : noDisplay) + '></div>';
- if (show && o[litem+'Grid'] > 0) {
+ if (show && o[litem + 'Grid'] > 0) {
html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
- if(litem == 'hour'){
- for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
+ if (litem === 'hour') {
+ for (var h = o[litem + 'Min']; h <= max[litem]; h += parseInt(o[litem + 'Grid'], 10)) {
gridSize[litem]++;
- var tmph = $.datepicker.formatTime(this.support.ampm? 'hht':'HH', {hour:h}, o);
- html += '<td data-for="'+litem+'">' + tmph + '</td>';
+ var tmph = $.datepicker.formatTime(this.support.ampm ? 'hht' : 'HH', {hour: h}, o);
+ html += '<td data-for="' + litem + '">' + tmph + '</td>';
}
}
- else{
- for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) {
+ else {
+ for (var m = o[litem + 'Min']; m <= max[litem]; m += parseInt(o[litem + 'Grid'], 10)) {
gridSize[litem]++;
- html += '<td data-for="'+litem+'">' + ((m < 10) ? '0' : '') + m + '</td>';
+ html += '<td data-for="' + litem + '">' + ((m < 10) ? '0' : '') + m + '</td>';
}
}
@@ -410,7 +405,7 @@
}
// Timezone
- var showTz = o.showTimezone !== null? o.showTimezone : this.support.timezone;
+ var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone;
html += '<dt class="ui_tpicker_timezone_label"' + (showTz ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
html += '<dd class="ui_tpicker_timezone" ' + (showTz ? '' : noDisplay) + '></dd>';
@@ -425,41 +420,41 @@
}
// add sliders, adjust grids, add events
- for(i=0,l=tp_inst.units.length; i<l; i++){
+ for (i = 0, l = tp_inst.units.length; i < l; i++) {
litem = tp_inst.units[i];
- uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
- show = o['show'+uitem] !== null? o['show'+uitem] : this.support[litem];
+ uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
+ show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
// add the slider
- tp_inst[litem+'_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_'+litem+'_slider'), litem, tp_inst[litem], o[litem+'Min'], max[litem], o['step'+uitem]);
+ tp_inst[litem + '_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_' + litem + '_slider'), litem, tp_inst[litem], o[litem + 'Min'], max[litem], o['step' + uitem]);
// adjust the grid and add click event
- if (show && o[litem+'Grid'] > 0) {
- size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']);
- $tp.find('.ui_tpicker_'+litem+' table').css({
+ if (show && o[litem + 'Grid'] > 0) {
+ size = 100 * gridSize[litem] * o[litem + 'Grid'] / (max[litem] - o[litem + 'Min']);
+ $tp.find('.ui_tpicker_' + litem + ' table').css({
width: size + "%",
- marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"),
- marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0',
+ marginLeft: o.isRTL ? '0' : ((size / (-2 * gridSize[litem])) + "%"),
+ marginRight: o.isRTL ? ((size / (-2 * gridSize[litem])) + "%") : '0',
borderCollapse: 'collapse'
- }).find("td").click(function(e){
+ }).find("td").click(function (e) {
var $t = $(this),
h = $t.html(),
- n = parseInt(h.replace(/[^0-9]/g),10),
+ n = parseInt(h.replace(/[^0-9]/g), 10),
ap = h.replace(/[^apm]/ig),
f = $t.data('for'); // loses scope, so we use data-for
- if(f == 'hour'){
- if(ap.indexOf('p') !== -1 && n < 12){
+ if (f === 'hour') {
+ if (ap.indexOf('p') !== -1 && n < 12) {
n += 12;
}
- else{
- if(ap.indexOf('a') !== -1 && n === 12){
+ else {
+ if (ap.indexOf('a') !== -1 && n === 12) {
n = 0;
}
}
}
- tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n);
+ tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n);
tp_inst._onTimeChange();
tp_inst._onSelectHandler();
@@ -475,24 +470,24 @@
// Add timezone options
this.timezone_select = $tp.find('.ui_tpicker_timezone').append('<select></select>').find("select");
$.fn.append.apply(this.timezone_select,
- $.map(o.timezoneList, function(val, idx) {
- return $("<option />").val(typeof val == "object" ? val.value : val).text(typeof val == "object" ? val.label : val);
+ $.map(o.timezoneList, function (val, idx) {
+ return $("<option />").val(typeof val === "object" ? val.value : val).text(typeof val === "object" ? val.label : val);
}));
- if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
- var local_timezone = (new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12)).getTimezoneOffset()*-1;
- if (local_timezone == this.timezone) {
+ if (typeof(this.timezone) !== "undefined" && this.timezone !== null && this.timezone !== "") {
+ var local_timezone = (new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12)).getTimezoneOffset() * -1;
+ if (local_timezone === this.timezone) {
selectLocalTimezone(tp_inst);
} else {
this.timezone_select.val(this.timezone);
}
} else {
- if (typeof(this.hour) != "undefined" && this.hour !== null && this.hour !== "") {
+ if (typeof(this.hour) !== "undefined" && this.hour !== null && this.hour !== "") {
this.timezone_select.val(o.timezone);
} else {
selectLocalTimezone(tp_inst);
}
}
- this.timezone_select.change(function() {
+ this.timezone_select.change(function () {
tp_inst._onTimeChange();
tp_inst._onSelectHandler();
});
@@ -520,21 +515,21 @@
rtl = this._defaults.isRTL;
sliderAccessArgs.isRTL = rtl;
- setTimeout(function() { // fix for inline mode
+ setTimeout(function () { // fix for inline mode
if ($tp.find('.ui-slider-access').length === 0) {
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
// fix any grids since sliders are shorter
var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
if (sliderAccessWidth) {
- $tp.find('table:visible').each(function() {
+ $tp.find('table:visible').each(function () {
var $g = $(this),
oldWidth = $g.outerWidth(),
- oldMarginLeft = $g.css(rtl? 'marginRight':'marginLeft').toString().replace('%', ''),
+ oldMarginLeft = $g.css(rtl ? 'marginRight' : 'marginLeft').toString().replace('%', ''),
newWidth = oldWidth - sliderAccessWidth,
newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%',
css = { width: newWidth, marginRight: 0, marginLeft: 0 };
- css[rtl? 'marginRight':'marginLeft'] = newMarginLeft;
+ css[rtl ? 'marginRight' : 'marginLeft'] = newMarginLeft;
$g.css(css);
});
}
@@ -551,7 +546,7 @@
* This function tries to limit the ability to go outside the
* min/max date range
*/
- _limitMinMaxDateTime: function(dp_inst, adjustSliders) {
+ _limitMinMaxDateTime: function (dp_inst, adjustSliders) {
var o = this._defaults,
dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
@@ -571,7 +566,7 @@
this.microsecMinOriginal = o.microsecMin;
}
- if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
+ if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() === dp_date.getTime()) {
this._defaults.hourMin = minDateTime.getHours();
if (this.hour <= this._defaults.hourMin) {
this.hour = this._defaults.hourMin;
@@ -582,7 +577,7 @@
if (this.second <= this._defaults.secondMin) {
this.second = this._defaults.secondMin;
this._defaults.millisecMin = minDateTime.getMilliseconds();
- if(this.millisec <= this._defaults.millisecMin) {
+ if (this.millisec <= this._defaults.millisecMin) {
this.millisec = this._defaults.millisecMin;
this._defaults.microsecMin = minDateTime.getMicroseconds();
} else {
@@ -627,7 +622,7 @@
this.microsecMaxOriginal = o.microsecMax;
}
- if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()) {
+ if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() === dp_date.getTime()) {
this._defaults.hourMax = maxDateTime.getHours();
if (this.hour >= this._defaults.hourMax) {
this.hour = this._defaults.hourMax;
@@ -675,7 +670,7 @@
var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
- millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10);
+ millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10),
microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
if (this.hour_slider) {
@@ -706,7 +701,10 @@
* when a slider moves, set the internal time...
* on time change is also called when the time is updated in the text field
*/
- _onTimeChange: function() {
+ _onTimeChange: function () {
+ if (!this._defaults.showTimepicker) {
+ return;
+ }
var hour = (this.hour_slider) ? this.control.value(this, this.hour_slider, 'hour') : false,
minute = (this.minute_slider) ? this.control.value(this, this.minute_slider, 'minute') : false,
second = (this.second_slider) ? this.control.value(this, this.second_slider, 'second') : false,
@@ -717,22 +715,22 @@
pickerTimeFormat = o.pickerTimeFormat || o.timeFormat,
pickerTimeSuffix = o.pickerTimeSuffix || o.timeSuffix;
- if (typeof(hour) == 'object') {
+ if (typeof(hour) === 'object') {
hour = false;
}
- if (typeof(minute) == 'object') {
+ if (typeof(minute) === 'object') {
minute = false;
}
- if (typeof(second) == 'object') {
+ if (typeof(second) === 'object') {
second = false;
}
- if (typeof(millisec) == 'object') {
+ if (typeof(millisec) === 'object') {
millisec = false;
}
- if (typeof(microsec) == 'object') {
+ if (typeof(microsec) === 'object') {
microsec = false;
}
- if (typeof(timezone) == 'object') {
+ if (typeof(timezone) === 'object') {
timezone = false;
}
@@ -756,9 +754,8 @@
// If the update was done in the input field, the input field should not be updated.
// If the update was done using the sliders, update the input field.
- var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec || microsec != this.microsec
- || (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
- || (this.timezone !== null && timezone != this.timezone));
+ var hasChanged = (hour !== this.hour || minute !== this.minute || second !== this.second || millisec !== this.millisec || microsec !== this.microsec ||
+ (this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) || (this.timezone !== null && timezone !== this.timezone));
if (hasChanged) {
@@ -794,10 +791,10 @@
// Updates the time within the timepicker
this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
if (this.$timeObj) {
- if(pickerTimeFormat === o.timeFormat){
+ if (pickerTimeFormat === o.timeFormat) {
this.$timeObj.text(this.formattedTime + pickerTimeSuffix);
}
- else{
+ else {
this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
}
}
@@ -812,7 +809,7 @@
* call custom onSelect.
* bind to sliders slidestop, and grid click.
*/
- _onSelectHandler: function() {
+ _onSelectHandler: function () {
var onSelect = this._defaults.onSelect || this.inst.settings.onSelect;
var inputEl = this.$input ? this.$input[0] : null;
if (onSelect && inputEl) {
@@ -823,10 +820,14 @@
/*
* update our input with the new date time..
*/
- _updateDateTime: function(dp_inst) {
+ _updateDateTime: function (dp_inst) {
dp_inst = this.inst || dp_inst;
- //var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
- var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay)),
+ var dtTmp = (dp_inst.currentYear > 0?
+ new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) :
+ new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
+ dt = $.datepicker._daylightSavingAdjust(dtTmp),
+ //dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
+ //dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay)),
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
formatCfg = $.datepicker._getFormatConfig(dp_inst),
timeAvailable = dt !== null && this.timeDefined;
@@ -834,10 +835,10 @@
var formattedDateTime = this.formattedDate;
// if a slider was changed but datepicker doesn't have a value yet, set it
- if(dp_inst.lastVal===""){
- dp_inst.currentYear=dp_inst.selectedYear;
- dp_inst.currentMonth=dp_inst.selectedMonth;
- dp_inst.currentDay=dp_inst.selectedDay;
+ if (dp_inst.lastVa === "") {
+ dp_inst.currentYear = dp_inst.selectedYear;
+ dp_inst.currentMonth = dp_inst.selectedMonth;
+ dp_inst.currentDay = dp_inst.selectedDay;
}
/*
@@ -868,23 +869,23 @@
altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
- if(!this._defaults.timeOnly){
- if (this._defaults.altFormat){
+ if (!this._defaults.timeOnly) {
+ if (this._defaults.altFormat) {
altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
}
- else{
+ else {
altFormattedDateTime = this.formattedDate;
}
- if (altFormattedDateTime){
+ if (altFormattedDateTime) {
altFormattedDateTime += altSeparator;
}
}
- if(this._defaults.altTimeFormat){
+ if (this._defaults.altTimeFormat) {
altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
}
- else{
+ else {
altFormattedDateTime += this.formattedTime + altTimeSuffix;
}
this.$altInput.val(altFormattedDateTime);
@@ -895,13 +896,13 @@
this.$input.trigger("change");
},
- _onFocus: function() {
+ _onFocus: function () {
if (!this.$input.val() && this._defaults.defaultValue) {
this.$input.val(this._defaults.defaultValue);
var inst = $.datepicker._getInst(this.$input.get(0)),
tp_inst = $.datepicker._get(inst, 'timepicker');
if (tp_inst) {
- if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
+ if (tp_inst._defaults.timeOnly && (inst.input.val() !== inst.lastVal)) {
try {
$.datepicker._updateDatepicker(inst);
} catch (err) {
@@ -919,29 +920,29 @@
_controls: {
// slider methods
slider: {
- create: function(tp_inst, obj, unit, val, min, max, step){
+ create: function (tp_inst, obj, unit, val, min, max, step) {
var rtl = tp_inst._defaults.isRTL; // if rtl go -60->0 instead of 0->60
return obj.prop('slide', null).slider({
orientation: "horizontal",
- value: rtl? val*-1 : val,
- min: rtl? max*-1 : min,
- max: rtl? min*-1 : max,
+ value: rtl ? val * -1 : val,
+ min: rtl ? max * -1 : min,
+ max: rtl ? min * -1 : max,
step: step,
- slide: function(event, ui) {
- tp_inst.control.value(tp_inst, $(this), unit, rtl? ui.value*-1:ui.value);
+ slide: function (event, ui) {
+ tp_inst.control.value(tp_inst, $(this), unit, rtl ? ui.value * -1 : ui.value);
tp_inst._onTimeChange();
},
- stop: function(event, ui) {
+ stop: function (event, ui) {
tp_inst._onSelectHandler();
}
});
},
- options: function(tp_inst, obj, unit, opts, val){
- if(tp_inst._defaults.isRTL){
- if(typeof(opts) == 'string'){
- if(opts == 'min' || opts == 'max'){
- if(val !== undefined){
- return obj.slider(opts, val*-1);
+ options: function (tp_inst, obj, unit, opts, val) {
+ if (tp_inst._defaults.isRTL) {
+ if (typeof(opts) === 'string') {
+ if (opts === 'min' || opts === 'max') {
+ if (val !== undefined) {
+ return obj.slider(opts, val * -1);
}
return Math.abs(obj.slider(opts));
}
@@ -950,27 +951,27 @@
var min = opts.min,
max = opts.max;
opts.min = opts.max = null;
- if(min !== undefined){
+ if (min !== undefined) {
opts.max = min * -1;
}
- if(max !== undefined){
+ if (max !== undefined) {
opts.min = max * -1;
}
return obj.slider(opts);
}
- if(typeof(opts) == 'string' && val !== undefined){
- return obj.slider(opts, val);
+ if (typeof(opts) === 'string' && val !== undefined) {
+ return obj.slider(opts, val);
}
return obj.slider(opts);
},
- value: function(tp_inst, obj, unit, val){
- if(tp_inst._defaults.isRTL){
- if(val !== undefined){
- return obj.slider('value', val*-1);
+ value: function (tp_inst, obj, unit, val) {
+ if (tp_inst._defaults.isRTL) {
+ if (val !== undefined) {
+ return obj.slider('value', val * -1);
}
return Math.abs(obj.slider('value'));
}
- if(val !== undefined){
+ if (val !== undefined) {
return obj.slider('value', val);
}
return obj.slider('value');
@@ -978,45 +979,45 @@
},
// select methods
select: {
- create: function(tp_inst, obj, unit, val, min, max, step){
- var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
+ create: function (tp_inst, obj, unit, val, min, max, step) {
+ var sel = '<select class="ui-timepicker-select" data-unit="' + unit + '" data-min="' + min + '" data-max="' + max + '" data-step="' + step + '">',
format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat;
- for(var i=min; i<=max; i+=step){
- sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
- if(unit == 'hour'){
- sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig,'')), {hour:i}, tp_inst._defaults);
+ for (var i = min; i <= max; i += step) {
+ sel += '<option value="' + i + '"' + (i === val ? ' selected' : '') + '>';
+ if (unit === 'hour') {
+ sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig, '')), {hour: i}, tp_inst._defaults);
}
- else if(unit == 'millisec' || unit == 'microsec' || i >= 10){ sel += i; }
- else {sel += '0'+ i.toString(); }
+ else if (unit === 'millisec' || unit === 'microsec' || i >= 10) { sel += i; }
+ else {sel += '0' + i.toString(); }
sel += '</option>';
}
sel += '</select>';
obj.children('select').remove();
- $(sel).appendTo(obj).change(function(e){
+ $(sel).appendTo(obj).change(function (e) {
tp_inst._onTimeChange();
tp_inst._onSelectHandler();
});
return obj;
},
- options: function(tp_inst, obj, unit, opts, val){
+ options: function (tp_inst, obj, unit, opts, val) {
var o = {},
$t = obj.children('select');
- if(typeof(opts) == 'string'){
- if(val === undefined){
+ if (typeof(opts) === 'string') {
+ if (val === undefined) {
return $t.data(opts);
}
o[opts] = val;
}
- else{ o = opts; }
+ else { o = opts; }
return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
},
- value: function(tp_inst, obj, unit, val){
+ value: function (tp_inst, obj, unit, val) {
var $t = obj.children('select');
- if(val !== undefined){
+ if (val !== undefined) {
return $t.val(val);
}
return $t.val();
@@ -1028,19 +1029,19 @@
$.fn.extend({
/*
- * shorthand just to use timepicker..
+ * shorthand just to use timepicker.
*/
- timepicker: function(o) {
+ timepicker: function (o) {
o = o || {};
var tmp_args = Array.prototype.slice.call(arguments);
- if (typeof o == 'object') {
+ if (typeof o === 'object') {
tmp_args[0] = $.extend(o, {
timeOnly: true
});
}
- return $(this).each(function() {
+ return $(this).each(function () {
$.fn.datetimepicker.apply($(this), tmp_args);
});
},
@@ -1048,21 +1049,21 @@
/*
* extend timepicker to datepicker
*/
- datetimepicker: function(o) {
+ datetimepicker: function (o) {
o = o || {};
var tmp_args = arguments;
- if (typeof(o) == 'string') {
- if (o == 'getDate') {
+ if (typeof(o) === 'string') {
+ if (o === 'getDate') {
return $.fn.datepicker.apply($(this[0]), tmp_args);
} else {
- return this.each(function() {
+ return this.each(function () {
var $t = $(this);
$t.datepicker.apply($t, tmp_args);
});
}
} else {
- return this.each(function() {
+ return this.each(function () {
var $t = $(this);
$t.datepicker($.timepicker._newInst($t, o)._defaults);
});
@@ -1073,7 +1074,7 @@
/*
* Public Utility to parse date and time
*/
- $.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
+ $.datepicker.parseDateTime = function (dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
if (parseRes.timeObj) {
var t = parseRes.timeObj;
@@ -1087,15 +1088,15 @@
/*
* Public utility to parse time
*/
- $.datepicker.parseTime = function(timeFormat, timeString, options) {
+ $.datepicker.parseTime = function (timeFormat, timeString, options) {
var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {}),
- iso8601 = (timeFormat.replace(/\'.*?\'/g,'').indexOf('Z') !== -1);
+ iso8601 = (timeFormat.replace(/\'.*?\'/g, '').indexOf('Z') !== -1);
// Strict parse requires the timeString to match the timeFormat exactly
- var strictParse = function(f, s, o){
+ var strictParse = function (f, s, o) {
// pattern for standard and localized AM/PM markers
- var getPatternAmpm = function(amNames, pmNames) {
+ var getPatternAmpm = function (amNames, pmNames) {
var markers = [];
if (amNames) {
$.merge(markers, amNames);
@@ -1103,14 +1104,14 @@
if (pmNames) {
$.merge(markers, pmNames);
}
- markers = $.map(markers, function(val) {
+ markers = $.map(markers, function (val) {
return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&');
});
return '(' + markers.join('|') + ')?';
};
// figure out position of time elements.. cause js cant do named captures
- var getFormatPositions = function(timeFormat) {
+ var getFormatPositions = function (timeFormat) {
var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),
orders = {
h: -1,
@@ -1124,7 +1125,7 @@
if (finds) {
for (var i = 0; i < finds.length; i++) {
- if (orders[finds[i].toString().charAt(0)] == -1) {
+ if (orders[finds[i].toString().charAt(0)] === -1) {
orders[finds[i].toString().charAt(0)] = i + 1;
}
}
@@ -1136,15 +1137,22 @@
.replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
var ml = match.length;
switch (match.charAt(0).toLowerCase()) {
- case 'h': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
- case 'm': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
- case 's': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
- case 'l': return '(\\d?\\d?\\d)';
- case 'c': return '(\\d?\\d?\\d)';
- case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
- case 't': return getPatternAmpm(o.amNames, o.pmNames);
- default: // literal escaped in quotes
- return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
+ case 'h':
+ return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
+ case 'm':
+ return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
+ case 's':
+ return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
+ case 'l':
+ return '(\\d?\\d?\\d)';
+ case 'c':
+ return '(\\d?\\d?\\d)';
+ case 'z':
+ return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
+ case 't':
+ return getPatternAmpm(o.amNames, o.pmNames);
+ default: // literal escaped in quotes
+ return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
}
})
.replace(/\s/g, '\\s?') +
@@ -1170,15 +1178,15 @@
resTime.ampm = '';
} else {
ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
- resTime.ampm = o[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
+ resTime.ampm = o[ampm === 'AM' ? 'amNames' : 'pmNames'][0];
}
}
if (order.h !== -1) {
- if (ampm == 'AM' && treg[order.h] == '12') {
+ if (ampm === 'AM' && treg[order.h] === '12') {
resTime.hour = 0; // 12am = 0 hour
} else {
- if (ampm == 'PM' && treg[order.h] != '12') {
+ if (ampm === 'PM' && treg[order.h] !== '12') {
resTime.hour = parseInt(treg[order.h], 10) + 12; // 12pm = 12 hour, any other pm = hour + 12
} else {
resTime.hour = Number(treg[order.h]);
@@ -1209,15 +1217,15 @@
};// end strictParse
// First try JS Date, if that fails, use strictParse
- var looseParse = function(f,s,o){
- try{
- var d = new Date('2012-01-01 '+ s);
- if(isNaN(d.getTime())){
- d = new Date('2012-01-01T'+ s);
- if(isNaN(d.getTime())){
- d = new Date('01/01/2012 '+ s);
- if(isNaN(d.getTime())){
- throw "Unable to parse time with native Date: "+ s;
+ var looseParse = function (f, s, o) {
+ try {
+ var d = new Date('2012-01-01 ' + s);
+ if (isNaN(d.getTime())) {
+ d = new Date('2012-01-01T' + s);
+ if (isNaN(d.getTime())) {
+ d = new Date('01/01/2012 ' + s);
+ if (isNaN(d.getTime())) {
+ throw "Unable to parse time with native Date: " + s;
}
}
}
@@ -1228,36 +1236,37 @@
second: d.getSeconds(),
millisec: d.getMilliseconds(),
microsec: d.getMicroseconds(),
- timezone: d.getTimezoneOffset()*-1
+ timezone: d.getTimezoneOffset() * -1
};
}
- catch(err){
- try{
- return strictParse(f,s,o);
+ catch (err) {
+ try {
+ return strictParse(f, s, o);
}
- catch(err2){
- $.timepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f);
+ catch (err2) {
+ $.timepicker.log("Unable to parse \ntimeString: " + s + "\ntimeFormat: " + f);
}
}
return false;
}; // end looseParse
- if(typeof o.parse === "function"){
+ if (typeof o.parse === "function") {
return o.parse(timeFormat, timeString, o);
}
- if(o.parse === 'loose'){
+ if (o.parse === 'loose') {
return looseParse(timeFormat, timeString, o);
}
return strictParse(timeFormat, timeString, o);
};
- /*
- * Public utility to format the time
- * format = string format of the time
- * time = a {}, not a Date() for timezones
- * options = essentially the regional[].. amNames, pmNames, ampm
- */
- $.datepicker.formatTime = function(format, time, options) {
+ /**
+ * Public utility to format the time
+ * @param {string} format format of the time
+ * @param {Object} time Object not a Date for timezones
+ * @param {Object} [options] essentially the regional[].. amNames, pmNames, ampm
+ * @returns {string} the formatted time
+ */
+ $.datepicker.formatTime = function (format, time, options) {
options = options || {};
options = $.extend({}, $.timepicker._defaults, options);
time = $.extend({
@@ -1265,7 +1274,8 @@
minute: 0,
second: 0,
millisec: 0,
- timezone: 0
+ microsec: 0,
+ timezone: null
}, time);
var tmptime = format,
@@ -1276,8 +1286,8 @@
ampmName = options.pmNames[0];
}
- tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|('.*?'|".*?"))/g, function(match) {
- switch (match) {
+ tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
+ switch (match) {
case 'HH':
return ('0' + hour).slice(-2);
case 'H':
@@ -1299,32 +1309,31 @@
case 'c':
return ('00' + time.microsec).slice(-3);
case 'z':
- return $.timepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, false);
+ return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, false);
case 'Z':
- return $.timepicker.timezoneOffsetString(time.timezone === null? options.timezone : time.timezone, true);
- case 'T':
+ return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, true);
+ case 'T':
return ampmName.charAt(0).toUpperCase();
- case 'TT':
+ case 'TT':
return ampmName.toUpperCase();
case 't':
return ampmName.charAt(0).toLowerCase();
case 'tt':
return ampmName.toLowerCase();
default:
- return match.replace(/\'/g, "") || "'";
+ return match.replace(/'/g, "");
}
});
- tmptime = $.trim(tmptime);
return tmptime;
};
/*
- * the bad hack :/ override datepicker so it doesnt close on select
+ * the bad hack :/ override datepicker so it doesn't close on select
// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
*/
$.datepicker._base_selectDate = $.datepicker._selectDate;
- $.datepicker._selectDate = function(id, dateStr) {
+ $.datepicker._selectDate = function (id, dateStr) {
var inst = this._getInst($(id)[0]),
tp_inst = this._get(inst, 'timepicker');
@@ -1346,11 +1355,11 @@
* and does not redraw the datepicker on every selectDate event
*/
$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
- $.datepicker._updateDatepicker = function(inst) {
+ $.datepicker._updateDatepicker = function (inst) {
// don't popup the datepicker if there is another instance already opened
var input = inst.input[0];
- if ($.datepicker._curInst && $.datepicker._curInst != inst && $.datepicker._datepickerShowing && $.datepicker._lastInput != input) {
+ if ($.datepicker._curInst && $.datepicker._curInst !== inst && $.datepicker._datepickerShowing && $.datepicker._lastInput !== input) {
return;
}
@@ -1370,14 +1379,14 @@
* third bad hack :/ override datepicker so it allows spaces and colon in the input field
*/
$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
- $.datepicker._doKeyPress = function(event) {
+ $.datepicker._doKeyPress = function (event) {
var inst = $.datepicker._getInst(event.target),
tp_inst = $.datepicker._get(inst, 'timepicker');
if (tp_inst) {
if ($.datepicker._get(inst, 'constrainInput')) {
var ampm = tp_inst.support.ampm,
- tz = tp_inst._defaults.showTimezone !== null? tp_inst._defaults.showTimezone : tp_inst.support.timezone,
+ tz = tp_inst._defaults.showTimezone !== null ? tp_inst._defaults.showTimezone : tp_inst.support.timezone,
dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
datetimeChars = tp_inst._defaults.timeFormat.toString()
.replace(/[hms]/g, '')
@@ -1402,12 +1411,12 @@
/*
* Fourth bad hack :/ override _updateAlternate function used in inline mode to init altField
+ * Update any alternate field to synchronise with the main field.
*/
$.datepicker._base_updateAlternate = $.datepicker._updateAlternate;
- /* Update any alternate field to synchronise with the main field. */
- $.datepicker._updateAlternate = function(inst) {
+ $.datepicker._updateAlternate = function (inst) {
var tp_inst = this._get(inst, 'timepicker');
- if(tp_inst){
+ if (tp_inst) {
var altField = tp_inst._defaults.altField;
if (altField) { // update alternate field too
var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
@@ -1419,18 +1428,18 @@
altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
- if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
- if(tp_inst._defaults.altFormat){
+ if (!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null) {
+ if (tp_inst._defaults.altFormat) {
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
}
- else{
+ else {
altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
}
}
$(altField).val(altFormattedDateTime);
}
}
- else{
+ else {
$.datepicker._base_updateAlternate(inst);
}
};
@@ -1439,12 +1448,12 @@
* Override key up event to sync manual input changes.
*/
$.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
- $.datepicker._doKeyUp = function(event) {
+ $.datepicker._doKeyUp = function (event) {
var inst = $.datepicker._getInst(event.target),
tp_inst = $.datepicker._get(inst, 'timepicker');
if (tp_inst) {
- if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
+ if (tp_inst._defaults.timeOnly && (inst.input.val() !== inst.lastVal)) {
try {
$.datepicker._updateDatepicker(inst);
} catch (err) {
@@ -1460,7 +1469,7 @@
* override "Today" button to also grab the time.
*/
$.datepicker._base_gotoToday = $.datepicker._gotoToday;
- $.datepicker._gotoToday = function(id) {
+ $.datepicker._gotoToday = function (id) {
var inst = this._getInst($(id)[0]),
$dp = inst.dpDiv;
this._base_gotoToday(id);
@@ -1474,7 +1483,7 @@
/*
* Disable & enable the Time in the datetimepicker
*/
- $.datepicker._disableTimepickerDatepicker = function(target) {
+ $.datepicker._disableTimepickerDatepicker = function (target) {
var inst = this._getInst(target);
if (!inst) {
return;
@@ -1483,12 +1492,13 @@
var tp_inst = this._get(inst, 'timepicker');
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
if (tp_inst) {
+ inst.settings.showTimepicker = false;
tp_inst._defaults.showTimepicker = false;
tp_inst._updateDateTime(inst);
}
};
- $.datepicker._enableTimepickerDatepicker = function(target) {
+ $.datepicker._enableTimepickerDatepicker = function (target) {
var inst = this._getInst(target);
if (!inst) {
return;
@@ -1497,6 +1507,7 @@
var tp_inst = this._get(inst, 'timepicker');
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
if (tp_inst) {
+ inst.settings.showTimepicker = true;
tp_inst._defaults.showTimepicker = true;
tp_inst._addTimePicker(inst); // Could be disabled on page load
tp_inst._updateDateTime(inst);
@@ -1506,7 +1517,7 @@
/*
* Create our own set time function
*/
- $.datepicker._setTime = function(inst, date) {
+ $.datepicker._setTime = function (inst, date) {
var tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
var defaults = tp_inst._defaults;
@@ -1529,7 +1540,7 @@
/*
* Create new public method to set only time, callable as $().datepicker('setTime', date)
*/
- $.datepicker._setTimeDatepicker = function(target, date, withDate) {
+ $.datepicker._setTimeDatepicker = function (target, date, withDate) {
var inst = this._getInst(target);
if (!inst) {
return;
@@ -1541,7 +1552,7 @@
this._setDateFromField(inst);
var tp_date;
if (date) {
- if (typeof date == "string") {
+ if (typeof date === "string") {
tp_inst._parseTime(date, withDate);
tp_date = new Date();
tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
@@ -1550,7 +1561,7 @@
tp_date = new Date(date.getTime());
tp_date.setMicroseconds(date.getMicroseconds());
}
- if (tp_date.toString() == 'Invalid Date') {
+ if (tp_date.toString() === 'Invalid Date') {
tp_date = undefined;
}
this._setTime(inst, tp_date);
@@ -1563,15 +1574,15 @@
* override setDate() to allow setting time too within Date object
*/
$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
- $.datepicker._setDateDatepicker = function(target, date) {
+ $.datepicker._setDateDatepicker = function (target, date) {
var inst = this._getInst(target);
if (!inst) {
return;
}
- if(typeof(date) === 'string'){
+ if (typeof(date) === 'string') {
date = new Date(date);
- if(!date.getTime()){
+ if (!date.getTime()) {
$.timepicker.log("Error creating Date object from string.");
}
}
@@ -1589,10 +1600,10 @@
// object will only return the timezone offset for the current locale, so we
// adjust it accordingly. If not using timezone option this won't matter..
// If a timezone is different in tp, keep the timezone as is
- if(tp_inst){
+ if (tp_inst) {
// look out for DST if tz wasn't specified
- if(!tp_inst.support.timezone && tp_inst._defaults.timezone === null){
- tp_inst.timezone = tp_date.getTimezoneOffset()*-1;
+ if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
+ tp_inst.timezone = tp_date.getTimezoneOffset() * -1;
}
date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
tp_date = $.timepicker.timezoneAdjust(tp_date, tp_inst.timezone);
@@ -1607,7 +1618,7 @@
* override getDate() to allow getting time too within Date object
*/
$.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
- $.datepicker._getDateDatepicker = function(target, noDefault) {
+ $.datepicker._getDateDatepicker = function (target, noDefault) {
var inst = this._getInst(target);
if (!inst) {
return;
@@ -1617,7 +1628,7 @@
if (tp_inst) {
// if it hasn't yet been defined, grab from field
- if(inst.lastVal === undefined){
+ if (inst.lastVal === undefined) {
this._setDateFromField(inst, noDefault);
}
@@ -1629,10 +1640,10 @@
// This is important if you are using the timezone option, javascript's Date
// object will only return the timezone offset for the current locale, so we
// adjust it accordingly. If not using timezone option this won't matter..
- if(tp_inst.timezone != null){
+ if (tp_inst.timezone != null) {
// look out for DST if tz wasn't specified
- if(!tp_inst.support.timezone && tp_inst._defaults.timezone === null){
- tp_inst.timezone = date.getTimezoneOffset()*-1;
+ if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
+ tp_inst.timezone = date.getTimezoneOffset() * -1;
}
date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
}
@@ -1647,7 +1658,7 @@
* An option in datapicker to ignore extra format characters would be nicer.
*/
$.datepicker._base_parseDate = $.datepicker.parseDate;
- $.datepicker.parseDate = function(format, value, settings) {
+ $.datepicker.parseDate = function (format, value, settings) {
var date;
try {
date = this._base_parseDate(format, value, settings);
@@ -1656,7 +1667,7 @@
// the "extra" characters. We rely on that instead of
// attempting to perfectly reproduce the parsing algorithm.
if (err.indexOf(":") >= 0) {
- date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
+ date = this._base_parseDate(format, value.substring(0, value.length - (err.length - err.indexOf(':') - 2)), settings);
$.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
} else {
throw err;
@@ -1669,7 +1680,7 @@
* override formatDate to set date with time to the input
*/
$.datepicker._base_formatDate = $.datepicker._formatDate;
- $.datepicker._formatDate = function(inst, day, month, year) {
+ $.datepicker._formatDate = function (inst, day, month, year) {
var tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
tp_inst._updateDateTime(inst);
@@ -1682,9 +1693,9 @@
* override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
*/
$.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
- $.datepicker._optionDatepicker = function(target, name, value) {
+ $.datepicker._optionDatepicker = function (target, name, value) {
var inst = this._getInst(target),
- name_clone;
+ name_clone;
if (!inst) {
return null;
}
@@ -1697,63 +1708,63 @@
overrides = tp_inst._defaults.evnts,
fns = {},
prop;
- if (typeof name == 'string') { // if min/max was set with the string
- if (name === 'minDate' || name === 'minDateTime') {
- min = value;
- } else if (name === 'maxDate' || name === 'maxDateTime') {
- max = value;
- } else if (name === 'onSelect') {
- onselect = value;
- } else if (overrides.hasOwnProperty(name)) {
- if (typeof (value) === 'undefined') {
- return overrides[name];
- }
- fns[name] = value;
- name_clone = {}; //empty results in exiting function after overrides updated
- }
- } else if (typeof name == 'object') { //if min/max was set with the JSON
- if (name.minDate) {
- min = name.minDate;
- } else if (name.minDateTime) {
- min = name.minDateTime;
- } else if (name.maxDate) {
- max = name.maxDate;
- } else if (name.maxDateTime) {
- max = name.maxDateTime;
- }
- for (prop in overrides) {
- if (overrides.hasOwnProperty(prop) && name[prop]) {
- fns[prop] = name[prop];
- }
- }
- }
- for (prop in fns) {
- if (fns.hasOwnProperty(prop)) {
- overrides[prop] = fns[prop];
- if (!name_clone) { name_clone = $.extend({}, name);}
- delete name_clone[prop];
- }
- }
- if (name_clone && isEmptyObject(name_clone)) { return; }
- if (min) { //if min was set
- if (min === 0) {
- min = new Date();
- } else {
- min = new Date(min);
- }
- tp_inst._defaults.minDate = min;
- tp_inst._defaults.minDateTime = min;
- } else if (max) { //if max was set
- if (max === 0) {
- max = new Date();
- } else {
- max = new Date(max);
- }
- tp_inst._defaults.maxDate = max;
- tp_inst._defaults.maxDateTime = max;
- } else if (onselect) {
- tp_inst._defaults.onSelect = onselect;
- }
+ if (typeof name === 'string') { // if min/max was set with the string
+ if (name === 'minDate' || name === 'minDateTime') {
+ min = value;
+ } else if (name === 'maxDate' || name === 'maxDateTime') {
+ max = value;
+ } else if (name === 'onSelect') {
+ onselect = value;
+ } else if (overrides.hasOwnProperty(name)) {
+ if (typeof (value) === 'undefined') {
+ return overrides[name];
+ }
+ fns[name] = value;
+ name_clone = {}; //empty results in exiting function after overrides updated
+ }
+ } else if (typeof name === 'object') { //if min/max was set with the JSON
+ if (name.minDate) {
+ min = name.minDate;
+ } else if (name.minDateTime) {
+ min = name.minDateTime;
+ } else if (name.maxDate) {
+ max = name.maxDate;
+ } else if (name.maxDateTime) {
+ max = name.maxDateTime;
+ }
+ for (prop in overrides) {
+ if (overrides.hasOwnProperty(prop) && name[prop]) {
+ fns[prop] = name[prop];
+ }
+ }
+ }
+ for (prop in fns) {
+ if (fns.hasOwnProperty(prop)) {
+ overrides[prop] = fns[prop];
+ if (!name_clone) { name_clone = $.extend({}, name); }
+ delete name_clone[prop];
+ }
+ }
+ if (name_clone && isEmptyObject(name_clone)) { return; }
+ if (min) { //if min was set
+ if (min === 0) {
+ min = new Date();
+ } else {
+ min = new Date(min);
+ }
+ tp_inst._defaults.minDate = min;
+ tp_inst._defaults.minDateTime = min;
+ } else if (max) { //if max was set
+ if (max === 0) {
+ max = new Date();
+ } else {
+ max = new Date(max);
+ }
+ tp_inst._defaults.maxDate = max;
+ tp_inst._defaults.maxDateTime = max;
+ } else if (onselect) {
+ tp_inst._defaults.onSelect = onselect;
+ }
}
if (value === undefined) {
return this._base_optionDatepicker.call($.datepicker, target, name);
@@ -1765,10 +1776,10 @@
* jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
* it will return false for all objects
*/
- var isEmptyObject = function(obj) {
+ var isEmptyObject = function (obj) {
var prop;
for (prop in obj) {
- if (obj.hasOwnProperty(obj)) {
+ if (obj.hasOwnProperty(prop)) {
return false;
}
}
@@ -1778,7 +1789,7 @@
/*
* jQuery extend now ignores nulls!
*/
- var extendRemove = function(target, props) {
+ var extendRemove = function (target, props) {
$.extend(target, props);
for (var name in props) {
if (props[name] === null || props[name] === undefined) {
@@ -1792,19 +1803,19 @@
* Determine by the time format which units are supported
* Returns an object of booleans for each unit
*/
- var detectSupport = function(timeFormat){
- var tf = timeFormat.replace(/\'.*?\'/g,'').toLowerCase(), // removes literals
- isIn = function(f, t){ // does the format contain the token?
- return f.indexOf(t) !== -1? true:false;
+ var detectSupport = function (timeFormat) {
+ var tf = timeFormat.replace(/'.*?'/g, '').toLowerCase(), // removes literals
+ isIn = function (f, t) { // does the format contain the token?
+ return f.indexOf(t) !== -1 ? true : false;
};
return {
- hour: isIn(tf,'h'),
- minute: isIn(tf,'m'),
- second: isIn(tf,'s'),
- millisec: isIn(tf,'l'),
- microsec: isIn(tf,'c'),
- timezone: isIn(tf,'z'),
- ampm: isIn(tf,'t') && isIn(timeFormat,'h'),
+ hour: isIn(tf, 'h'),
+ minute: isIn(tf, 'm'),
+ second: isIn(tf, 's'),
+ millisec: isIn(tf, 'l'),
+ microsec: isIn(tf, 'c'),
+ timezone: isIn(tf, 'z'),
+ ampm: isIn(tf, 't') && isIn(timeFormat, 'h'),
iso8601: isIn(timeFormat, 'Z')
};
};
@@ -1813,10 +1824,8 @@
* Converts 24 hour format into 12 hour
* Returns 12 hour without leading 0
*/
- var convert24to12 = function(hour) {
- if (hour > 12) {
- hour = hour - 12;
- }
+ var convert24to12 = function (hour) {
+ hour %= 12;
if (hour === 0) {
hour = 12;
@@ -1825,51 +1834,36 @@
return String(hour);
};
+ var computeEffectiveSetting = function (settings, property) {
+ return settings && settings[property] ? settings[property] : $.timepicker._defaults[property];
+ };
+
/*
- * Splits datetime string into date ans time substrings.
+ * Splits datetime string into date and time substrings.
* Throws exception when date can't be parsed
- * Returns [dateString, timeString]
+ * Returns {dateString: dateString, timeString: timeString}
*/
- var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
- try {
- // The idea is to get the number separator occurances in datetime and the time format requested (since time has
- // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
- var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
- format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
- timeParts = format.split(separator), // how many occurances of separator may be in our format?
- timePartsLen = timeParts.length,
- allParts = dateTimeString.split(separator),
- allPartsLen = allParts.length;
-
- if (allPartsLen > 1) {
- return [
- allParts.splice(0,allPartsLen-timePartsLen).join(separator),
- allParts.splice(0,timePartsLen).join(separator)
- ];
- }
-
- } catch (err) {
- $.timepicker.log('Could not split the date from the time. Please check the following datetimepicker options' +
- "\nthrown error: " + err +
- "\ndateTimeString" + dateTimeString +
- "\ndateFormat = " + dateFormat +
- "\nseparator = " + timeSettings.separator +
- "\ntimeFormat = " + timeSettings.timeFormat);
-
- if (err.indexOf(":") >= 0) {
- // Hack! The error message ends with a colon, a space, and
- // the "extra" characters. We rely on that instead of
- // attempting to perfectly reproduce the parsing algorithm.
- var dateStringLength = dateTimeString.length - (err.length - err.indexOf(':') - 2),
- timeString = dateTimeString.substring(dateStringLength);
-
- return [$.trim(dateTimeString.substring(0, dateStringLength)), $.trim(dateTimeString.substring(dateStringLength))];
-
- } else {
- throw err;
- }
+ var splitDateTime = function (dateTimeString, timeSettings) {
+ // The idea is to get the number separator occurrences in datetime and the time format requested (since time has
+ // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
+ var separator = computeEffectiveSetting(timeSettings, 'separator'),
+ format = computeEffectiveSetting(timeSettings, 'timeFormat'),
+ timeParts = format.split(separator), // how many occurrences of separator may be in our format?
+ timePartsLen = timeParts.length,
+ allParts = dateTimeString.split(separator),
+ allPartsLen = allParts.length;
+
+ if (allPartsLen > 1) {
+ return {
+ dateString: allParts.splice(0, allPartsLen - timePartsLen).join(separator),
+ timeString: allParts.splice(0, timePartsLen).join(separator)
+ };
}
- return [dateTimeString, ''];
+
+ return {
+ dateString: dateTimeString,
+ timeString: ''
+ };
};
/*
@@ -1878,61 +1872,65 @@
* date - parsed date without time (type Date)
* timeObj = {hour: , minute: , second: , millisec: , microsec: } - parsed time. Optional
*/
- var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
- var date;
- var splitRes = splitDateTime(dateFormat, dateTimeString, dateSettings, timeSettings);
- date = $.datepicker._base_parseDate(dateFormat, splitRes[0], dateSettings);
- if (splitRes[1] !== '') {
- var timeString = splitRes[1],
- parsedTime = $.datepicker.parseTime(timeFormat, timeString, timeSettings);
+ var parseDateTimeInternal = function (dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
+ var date,
+ parts,
+ parsedTime;
- if (parsedTime === null) {
- throw 'Wrong time format';
- }
- return {
- date: date,
- timeObj: parsedTime
- };
- } else {
+ parts = splitDateTime(dateTimeString, timeSettings);
+ date = $.datepicker._base_parseDate(dateFormat, parts.dateString, dateSettings);
+
+ if (parts.timeString === '') {
return {
date: date
};
}
+
+ parsedTime = $.datepicker.parseTime(timeFormat, parts.timeString, timeSettings);
+
+ if (!parsedTime) {
+ throw 'Wrong time format';
+ }
+
+ return {
+ date: date,
+ timeObj: parsedTime
+ };
};
/*
* Internal function to set timezone_select to the local timezone
*/
- var selectLocalTimezone = function(tp_inst, date) {
+ var selectLocalTimezone = function (tp_inst, date) {
if (tp_inst && tp_inst.timezone_select) {
- var now = typeof date !== 'undefined' ? date : new Date();
- tp_inst.timezone_select.val(now.getTimezoneOffset()*-1);
+ var now = date || new Date();
+ tp_inst.timezone_select.val(-now.getTimezoneOffset());
}
};
/*
- * Create a Singleton Insance
+ * Create a Singleton Instance
*/
$.timepicker = new Timepicker();
/**
* Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
- * @param number if not a number this value is returned
- * @param boolean if true formats in accordance to iso8601 "+12:45"
- * @return string
+ * @param {number} tzMinutes if not a number, less than -720 (-1200), or greater than 840 (+1400) this value is returned
+ * @param {boolean} iso8601 if true formats in accordance to iso8601 "+12:45"
+ * @return {string}
*/
- $.timepicker.timezoneOffsetString = function(tzMinutes, iso8601) {
- if(isNaN(tzMinutes) || tzMinutes > 840){
+ $.timepicker.timezoneOffsetString = function (tzMinutes, iso8601) {
+ if (isNaN(tzMinutes) || tzMinutes > 840 || tzMinutes < -720) {
return tzMinutes;
}
var off = tzMinutes,
minutes = off % 60,
hours = (off - minutes) / 60,
- iso = iso8601? ':':'',
- tz = (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + iso + ('0' + (minutes * 101).toString()).slice(-2);
+ iso = iso8601 ? ':' : '',
+ tz = (off >= 0 ? '+' : '-') + ('0' + Math.abs(hours)).slice(-2) + iso + ('0' + Math.abs(minutes)).slice(-2);
- if(tz == '+00:00'){
+ if (tz === '+00:00') {
return 'Z';
}
return tz;
@@ -1940,35 +1938,35 @@
/**
* Get the number in minutes that represents a timezone string
- * @param string formated like "+0500", "-1245"
- * @return number
+ * @param {string} tzString formatted like "+0500", "-1245", "Z"
+ * @return {number} the offset minutes or the original string if it doesn't match expectations
*/
- $.timepicker.timezoneOffsetNumber = function(tzString) {
- tzString = tzString.toString().replace(':',''); // excuse any iso8601, end up with "+1245"
+ $.timepicker.timezoneOffsetNumber = function (tzString) {
+ var normalized = tzString.toString().replace(':', ''); // excuse any iso8601, end up with "+1245"
- if(tzString.toUpperCase() === 'Z'){ // if iso8601 with Z, its 0 minute offset
+ if (normalized.toUpperCase() === 'Z') { // if iso8601 with Z, its 0 minute offset
return 0;
}
- if(!/^(\-|\+)\d{4}$/.test(tzString)){ // possibly a user defined tz, so just give it back
+ if (!/^(\-|\+)\d{4}$/.test(normalized)) { // possibly a user defined tz, so just give it back
return tzString;
}
- return ((tzString.substr(0,1) =='-'? -1 : 1) * // plus or minus
- ((parseInt(tzString.substr(1,2),10)*60) + // hours (converted to minutes)
- parseInt(tzString.substr(3,2),10))); // minutes
+ return ((normalized.substr(0, 1) === '-' ? -1 : 1) * // plus or minus
+ ((parseInt(normalized.substr(1, 2), 10) * 60) + // hours (converted to minutes)
+ parseInt(normalized.substr(3, 2), 10))); // minutes
};
/**
* No way to set timezone in js Date, so we must adjust the minutes to compensate. (think setDate, getDate)
- * @param date
- * @param string formated like "+0500", "-1245"
- * @return date
+ * @param {Date} date
+ * @param {string} toTimezone formatted like "+0500", "-1245"
+ * @return {Date}
*/
- $.timepicker.timezoneAdjust = function(date, toTimezone) {
+ $.timepicker.timezoneAdjust = function (date, toTimezone) {
var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
- if(!isNaN(toTz)){
- date.setMinutes(date.getMinutes()*1 + (date.getTimezoneOffset()*-1 - toTz*1) );
+ if (!isNaN(toTz)) {
+ date.setMinutes(date.getMinutes() + -date.getTimezoneOffset() - toTz);
}
return date;
};
@@ -1977,53 +1975,53 @@
* Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
* enforce date range limits.
* n.b. The input value must be correctly formatted (reformatting is not supported)
- * @param Element startTime
- * @param Element endTime
- * @param obj options Options for the timepicker() call
- * @return jQuery
+ * @param {Element} startTime
+ * @param {Element} endTime
+ * @param {Object} options Options for the timepicker() call
+ * @return {jQuery}
*/
- $.timepicker.timeRange = function(startTime, endTime, options) {
+ $.timepicker.timeRange = function (startTime, endTime, options) {
return $.timepicker.handleRange('timepicker', startTime, endTime, options);
};
/**
* Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
* enforce date range limits.
- * @param Element startTime
- * @param Element endTime
- * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
+ * @param {Element} startTime
+ * @param {Element} endTime
+ * @param {Object} options Options for the `timepicker()` call. Also supports `reformat`,
* a boolean value that can be used to reformat the input values to the `dateFormat`.
- * @param string method Can be used to specify the type of picker to be added
- * @return jQuery
+ * @param {string} method Can be used to specify the type of picker to be added
+ * @return {jQuery}
*/
- $.timepicker.datetimeRange = function(startTime, endTime, options) {
+ $.timepicker.datetimeRange = function (startTime, endTime, options) {
$.timepicker.handleRange('datetimepicker', startTime, endTime, options);
};
/**
- * Calls `method` on the `startTime` and `endTime` elements, and configures them to
+ * Calls `datepicker` on the `startTime` and `endTime` elements, and configures them to
* enforce date range limits.
- * @param Element startTime
- * @param Element endTime
- * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
+ * @param {Element} startTime
+ * @param {Element} endTime
+ * @param {Object} options Options for the `timepicker()` call. Also supports `reformat`,
* a boolean value that can be used to reformat the input values to the `dateFormat`.
- * @return jQuery
+ * @return {jQuery}
*/
- $.timepicker.dateRange = function(startTime, endTime, options) {
+ $.timepicker.dateRange = function (startTime, endTime, options) {
$.timepicker.handleRange('datepicker', startTime, endTime, options);
};
/**
* Calls `method` on the `startTime` and `endTime` elements, and configures them to
* enforce date range limits.
- * @param string method Can be used to specify the type of picker to be added
- * @param Element startTime
- * @param Element endTime
- * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
+ * @param {string} method Can be used to specify the type of picker to be added
+ * @param {Element} startTime
+ * @param {Element} endTime
+ * @param {Object} options Options for the `timepicker()` call. Also supports `reformat`,
* a boolean value that can be used to reformat the input values to the `dateFormat`.
- * @return jQuery
+ * @return {jQuery}
*/
- $.timepicker.handleRange = function(method, startTime, endTime, options) {
+ $.timepicker.handleRange = function (method, startTime, endTime, options) {
options = $.extend({}, {
minInterval: 0, // min allowed interval in milliseconds
maxInterval: 0, // max allowed interval in milliseconds
@@ -2031,47 +2029,26 @@
end: {} // options for end picker
}, options);
- $.fn[method].call(startTime, $.extend({
- onClose: function(dateText, inst) {
- checkDates($(this), endTime);
- },
- onSelect: function(selectedDateTime) {
- selected($(this), endTime, 'minDate');
- }
- }, options, options.start));
- $.fn[method].call(endTime, $.extend({
- onClose: function(dateText, inst) {
- checkDates($(this), startTime);
- },
- onSelect: function(selectedDateTime) {
- selected($(this), startTime, 'maxDate');
- }
- }, options, options.end));
-
- checkDates(startTime, endTime);
- selected(startTime, endTime, 'minDate');
- selected(endTime, startTime, 'maxDate');
-
function checkDates(changed, other) {
var startdt = startTime[method]('getDate'),
enddt = endTime[method]('getDate'),
changeddt = changed[method]('getDate');
- if(startdt !== null){
+ if (startdt !== null) {
var minDate = new Date(startdt.getTime()),
maxDate = new Date(startdt.getTime());
minDate.setMilliseconds(minDate.getMilliseconds() + options.minInterval);
maxDate.setMilliseconds(maxDate.getMilliseconds() + options.maxInterval);
- if(options.minInterval > 0 && minDate > enddt){ // minInterval check
- endTime[method]('setDate',minDate);
+ if (options.minInterval > 0 && minDate > enddt) { // minInterval check
+ endTime[method]('setDate', minDate);
}
- else if(options.maxInterval > 0 && maxDate < enddt){ // max interval check
- endTime[method]('setDate',maxDate);
+ else if (options.maxInterval > 0 && maxDate < enddt) { // max interval check
+ endTime[method]('setDate', maxDate);
}
else if (startdt > enddt) {
- other[method]('setDate',changeddt);
+ other[method]('setDate', changeddt);
}
}
}
@@ -2081,11 +2058,11 @@
return;
}
var date = changed[method].call(changed, 'getDate');
- if(date !== null && options.minInterval > 0){
- if(option == 'minDate'){
- date.setMilliseconds(date.getMilliseconds() + options.minInterval);
+ if (date !== null && options.minInterval > 0) {
+ if (option === 'minDate') {
+ date.setMilliseconds(date.getMilliseconds() + options.minInterval);
}
- if(option == 'maxDate'){
+ if (option === 'maxDate') {
date.setMilliseconds(date.getMilliseconds() - options.minInterval);
}
}
@@ -2093,29 +2070,64 @@
other[method].call(other, 'option', option, date);
}
}
+
+ $.fn[method].call(startTime, $.extend({
+ onClose: function (dateText, inst) {
+ checkDates($(this), endTime);
+ },
+ onSelect: function (selectedDateTime) {
+ selected($(this), endTime, 'minDate');
+ }
+ }, options, options.start));
+ $.fn[method].call(endTime, $.extend({
+ onClose: function (dateText, inst) {
+ checkDates($(this), startTime);
+ },
+ onSelect: function (selectedDateTime) {
+ selected($(this), startTime, 'maxDate');
+ }
+ }, options, options.end));
+
+ checkDates(startTime, endTime);
+ selected(startTime, endTime, 'minDate');
+ selected(endTime, startTime, 'maxDate');
return $([startTime.get(0), endTime.get(0)]);
};
/**
* Log error or data to the console during error or debugging
- * @param Object err pass any type object to log to the console during error or debugging
- * @return void
+ * @param {Object} err pass any type object to log to the console during error or debugging
+ * @return {void}
*/
- $.timepicker.log = function(err){
- if(window.console){
- console.log(err);
+ $.timepicker.log = function (err) {
+ if (window.console) {
+ window.console.log(err);
}
};
/*
+ * Add util object to allow access to private methods for testability.
+ */
+ $.timepicker._util = {
+ _extendRemove: extendRemove,
+ _isEmptyObject: isEmptyObject,
+ _convert24to12: convert24to12,
+ _detectSupport: detectSupport,
+ _selectLocalTimezone: selectLocalTimezone,
+ _computeEffectiveSetting: computeEffectiveSetting,
+ _splitDateTime: splitDateTime,
+ _parseDateTimeInternal: parseDateTimeInternal
+ };
+
+ /*
* Microsecond support
*/
- if(!Date.prototype.getMicroseconds){
+ if (!Date.prototype.getMicroseconds) {
Date.prototype.microseconds = 0;
- Date.prototype.getMicroseconds = function(){ return this.microseconds; };
- Date.prototype.setMicroseconds = function(m){
- this.setMilliseconds(this.getMilliseconds() + Math.floor(m/1000));
- this.microseconds = m%1000;
+ Date.prototype.getMicroseconds = function () { return this.microseconds; };
+ Date.prototype.setMicroseconds = function (m) {
+ this.setMilliseconds(this.getMilliseconds() + Math.floor(m / 1000));
+ this.microseconds = m % 1000;
return this;
};
}
@@ -2123,6 +2135,6 @@
/*
* Keep up with the version
*/
- $.timepicker.version = "1.3.1";
+ $.timepicker.version = "@@version";
})(jQuery);
diff --git a/test/.jshintrc b/test/.jshintrc
new file mode 100644
index 0000000..744a6f2
--- /dev/null
+++ b/test/.jshintrc
@@ -0,0 +1,41 @@
+{
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "sub": true,
+ "undef": true,
+ "unused": true,
+ "boss": true,
+ "eqnull": true,
+ "browser": true,
+ "predef": [
+ "jQuery",
+ "$",
+ "QUnit",
+ "module",
+ "test",
+ "asyncTest",
+ "expect",
+ "start",
+ "stop",
+ "ok",
+ "equal",
+ "notEqual",
+ "deepEqual",
+ "notDeepEqual",
+ "strictEqual",
+ "notStrictEqual",
+ "throws",
+ "describe",
+ "it",
+ "beforeEach",
+ "afterEach",
+ "spyOn",
+ "affix",
+ "xdescribe",
+ "xit"
+ ]
+} \ No newline at end of file
diff --git a/test/SpecRunner.html b/test/SpecRunner.html
new file mode 100644
index 0000000..5c76f6f
--- /dev/null
+++ b/test/SpecRunner.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>jquery-ui-timepicker-addon Spec Runner</title>
+
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
+
+ <link rel="shortcut icon" type="image/png" href="../lib/jasmine-1.3.1/jasmine_favicon.png">
+ <link rel="stylesheet" type="text/css" href="../lib/jasmine-1.3.1/jasmine.css">
+ <script type="text/javascript" src="../lib/jasmine-1.3.1/jasmine.js"></script>
+ <script type="text/javascript" src="../lib/jasmine-1.3.1/jasmine-html.js"></script>
+ <script type="text/javascript" src="http://github.com/searls/jasmine-fixture/releases/1.0.5/1737/jasmine-fixture.js"></script>
+
+ <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
+ <script type="text/javascript" src="../src/jquery-ui-timepicker-addon.js"></script>
+
+ <script type="text/javascript" src="jquery-ui-timepicker-addon_spec.js"></script>
+
+ <script type="text/javascript">
+ (function() {
+ var jasmineEnv = jasmine.getEnv();
+ jasmineEnv.updateInterval = 1000;
+
+ var htmlReporter = new jasmine.HtmlReporter();
+
+ jasmineEnv.addReporter(htmlReporter);
+
+ jasmineEnv.specFilter = function(spec) {
+ return htmlReporter.specFilter(spec);
+ };
+
+ var currentWindowOnload = window.onload;
+
+ window.onload = function() {
+ if (currentWindowOnload) {
+ currentWindowOnload();
+ }
+ execJasmine();
+ };
+
+ function execJasmine() {
+ jasmineEnv.execute();
+ }
+
+ })();
+ </script>
+
+</head>
+<body>
+
+</body>
+</html> \ No newline at end of file
diff --git a/test/jquery-ui-timepicker-addon_spec.js b/test/jquery-ui-timepicker-addon_spec.js
new file mode 100644
index 0000000..c0cdc7b
--- /dev/null
+++ b/test/jquery-ui-timepicker-addon_spec.js
@@ -0,0 +1,651 @@
+describe('datetimepicker', function() {
+ describe('utility functions', function() {
+ var util = $.timepicker._util;
+
+ describe('extendRemove', function() {
+ var target,
+ props;
+
+ beforeEach(function() {
+ target = {};
+ props = {};
+ });
+
+ it('should add a nonexistent property to the target', function() {
+ var expectedValue = "set",
+ propertyName = "prop";
+ props[propertyName] = expectedValue;
+
+ var newTarget = util._extendRemove(target, props);
+
+ expect(target[propertyName]).toBe(expectedValue);
+ expect(newTarget).toBe(target);
+ });
+
+ it('should change the value of an existing property', function() {
+ var expectedValue = "new",
+ originalValue = "old",
+ propertyName = "prop";
+ target[propertyName] = originalValue;
+ props[propertyName] = expectedValue;
+
+ util._extendRemove(target, props);
+
+ expect(target[propertyName]).not.toBe(originalValue);
+ expect(target[propertyName]).toBe(expectedValue);
+ });
+
+ it('should null the value of an existing property', function() {
+ var expectedValue = null,
+ propertyName = "prop";
+ target[propertyName] = "original";
+ props[propertyName] = expectedValue;
+
+ util._extendRemove(target, props);
+
+ expect(target[propertyName]).toBeNull();
+ });
+ });
+
+ describe('isEmptyObject', function() {
+ it('should say an empty object is empty', function() {
+ expect(util._isEmptyObject({})).toBe(true);
+ });
+
+ it('should say an object with a property is not empty', function() {
+ var testObject = {"prop": "value"};
+
+ expect(util._isEmptyObject(testObject)).toBe(false);
+ });
+
+ it('should say object with a supplemental prototype property is empty', function() {
+ var testObject = function () {};
+ testObject.prototype["prop"] = "something";
+
+ expect(util._isEmptyObject(testObject)).toBe(true);
+ });
+ });
+
+ describe('convert24to12', function() {
+ it('should return the value for a non-zero value less than 12', function() {
+ var expectedHour = 6;
+
+ expect(util._convert24to12(expectedHour)).toBe("" + expectedHour);
+ });
+
+ it('should return 12 hours less if the value is greater than 12 and less than 24', function() {
+ var expectedHour = 7;
+
+ expect(util._convert24to12(expectedHour + 12)).toBe("" + expectedHour);
+ });
+
+ it('should return 12 if the normalized value is 0', function() {
+ expect(util._convert24to12(0)).toBe('12');
+ });
+
+ it('should normalize values that are clearly out of the expected range', function() {
+ var expectedValue = 11;
+
+ expect(util._convert24to12(expectedValue + 12 * 3)).toBe("" + expectedValue);
+ });
+ });
+
+ describe('detectSupport', function() {
+ it('should detect support for hours', function() {
+ expect(util._detectSupport('H').hour).toBe(true);
+ expect(util._detectSupport('HH').hour).toBe(true);
+ expect(util._detectSupport('h').hour).toBe(true);
+ expect(util._detectSupport('hh').hour).toBe(true);
+
+ expect(util._detectSupport('asdf').hour).toBe(false);
+ });
+
+ it('should detect support for minutes', function() {
+ expect(util._detectSupport('m').minute).toBe(true);
+ expect(util._detectSupport('mm').minute).toBe(true);
+
+ expect(util._detectSupport('asdf').minute).toBe(false);
+ });
+
+ it('should detect support for seconds', function() {
+ expect(util._detectSupport('s').second).toBe(true);
+ expect(util._detectSupport('ss').second).toBe(true);
+
+ expect(util._detectSupport('acdf').second).toBe(false);
+ });
+
+ it('should detect support for milliseconds', function() {
+ expect(util._detectSupport('l').millisec).toBe(true);
+
+ expect(util._detectSupport('acdf').millisec).toBe(false);
+ });
+
+ it('should detect support for microseconds', function() {
+ expect(util._detectSupport('c').microsec).toBe(true);
+
+ expect(util._detectSupport('asdf').microsec).toBe(false);
+ });
+
+ it('should detect support for AM/PM', function() {
+ expect(util._detectSupport('h t').ampm).toBe(true);
+ expect(util._detectSupport('h tt').ampm).toBe(true);
+ expect(util._detectSupport('h T').ampm).toBe(true);
+ expect(util._detectSupport('h TT').ampm).toBe(true);
+
+ expect(util._detectSupport('t').ampm).toBe(false);
+ expect(util._detectSupport('h').ampm).toBe(false);
+ expect(util._detectSupport('H t').ampm).toBe(false);
+ expect(util._detectSupport('acdf').ampm).toBe(false);
+ });
+
+ it('should detect support for timezone', function() {
+ expect(util._detectSupport('z').timezone).toBe(true);
+ expect(util._detectSupport('Z').timezone).toBe(true);
+
+ expect(util._detectSupport('acdf').timezone).toBe(false);
+ });
+
+ it('should detect support for iso8601', function() {
+ expect(util._detectSupport('Z').iso8601).toBe(true);
+
+ expect(util._detectSupport('z').iso8601).toBe(false);
+ expect(util._detectSupport('acdf').iso8601).toBe(false);
+ });
+ });
+
+ describe('selectLocalTimezone', function() {
+ var timepicker,
+ timezoneOffset,
+ defaultTimezoneOffset;
+
+ beforeEach(function() {
+ timepicker = {
+ timezone_select: affix('select')
+ };
+ var now = new Date();
+ timezoneOffset = String(-now.getTimezoneOffset());
+ defaultTimezoneOffset = String(timezoneOffset - 60);
+ timepicker.timezone_select.affix('option').text(defaultTimezoneOffset);
+ timepicker.timezone_select.affix('option').text(timezoneOffset);
+ timepicker.timezone_select.affix('option').text(timezoneOffset + 60);
+
+ });
+
+ it('should do nothing for a falsey timepicker', function() {
+ util._selectLocalTimezone(undefined);
+
+ expect(timepicker.timezone_select.val()).toBe(defaultTimezoneOffset);
+ });
+
+ it('should do nothing for a timepicker with a falsey timezone_select', function() {
+ util._selectLocalTimezone({});
+
+ expect(timepicker.timezone_select.val()).toBe(defaultTimezoneOffset);
+ });
+
+ it('should select the current timezone with a valid timezone_select and no date', function() {
+ util._selectLocalTimezone(timepicker);
+
+ expect(timepicker.timezone_select.val()).toBe(timezoneOffset);
+ });
+
+ it('should select the current timezone with a valid timezone_select and a date', function() {
+ util._selectLocalTimezone(timepicker, new Date());
+
+ expect(timepicker.timezone_select.val()).toBe(timezoneOffset);
+ });
+ });
+
+ describe('computeEffectiveSetting', function() {
+ it('pulls the setting from the passed settings object if it is there', function() {
+ var expectedUniqueValue = 'This is very unique',
+ settings = {
+ property: expectedUniqueValue
+ };
+
+ expect(util._computeEffectiveSetting(settings, 'property')).toBe(expectedUniqueValue);
+ });
+
+ it('pulls the setting from the timepicker defaults if there are no passed settings', function() {
+ var expectedValue = $.timepicker._defaults.separator;
+ expect(expectedValue).toBeDefined();
+
+ expect(util._computeEffectiveSetting(undefined, 'separator')).toBe(expectedValue);
+ });
+
+ it('pulls the setting from the timepicker defaults if not present in the passed settings', function() {
+ var expectedValue = $.timepicker._defaults.separator,
+ settings = {};
+ expect(expectedValue).toBeDefined();
+
+ expect(util._computeEffectiveSetting(settings, 'separator')).toBe(expectedValue);
+ });
+ });
+
+ describe('splitDateTime', function() {
+ var expectedDateString = '3/6/1967',
+ expectedTimeString = '07:32';
+
+ it('splits a date and time into its parts using the default separator', function() {
+ var inputDateTimeString = expectedDateString + $.timepicker._defaults.separator + expectedTimeString,
+ result;
+
+ result = $.timepicker._util._splitDateTime(inputDateTimeString, {});
+
+ expect(result).toEqual({dateString: expectedDateString, timeString: expectedTimeString});
+ });
+
+ it('splits a date and time into its parts using a supplied separator', function() {
+ var separator = '-',
+ inputDateTimeString = expectedDateString + separator + expectedTimeString,
+ result;
+
+ result = $.timepicker._util._splitDateTime(inputDateTimeString, {separator: separator});
+
+ expect(result).toEqual({dateString: expectedDateString, timeString: expectedTimeString});
+ });
+
+ it('splits a date and time into its parts when there are multiple separators in the time format', function() {
+ var timeFormat = 'hh mm tt',
+ separator = ' ',
+ alternateTimeString = '07 32 am',
+ inputDateTimeString = expectedDateString + separator + alternateTimeString,
+ timeSettings = {separator: separator, timeFormat: timeFormat},
+ result;
+
+ result = $.timepicker._util._splitDateTime(inputDateTimeString, timeSettings);
+
+ expect(result).toEqual({dateString: expectedDateString, timeString: alternateTimeString});
+ });
+
+ it('splits only a date into itself', function() {
+ var result = $.timepicker._util._splitDateTime(expectedDateString, {});
+
+ expect(result).toEqual({dateString: expectedDateString, timeString: ''});
+ });
+ });
+
+ describe('parseDateTimeInternal', function() {
+ var dateFormat = 'mm/dd/yy';
+
+ it('should return only a date if there is no time component', function() {
+ var inputDateString = '9/11/2001',
+ expectedDate = new Date(inputDateString),
+ result;
+
+ result = util._parseDateTimeInternal(dateFormat, undefined, inputDateString, undefined, undefined);
+
+ expect(result.date).toEqual(expectedDate);
+ expect(result.timeObj).toBeUndefined();
+ });
+
+ it('should return a date and a parsed time if a time is included', function() {
+ var expectedDateString = '7/4/1976',
+ expectedParsedTime = {
+ hour: 1,
+ minute: 23,
+ second: 45,
+ millisec: 678,
+ microsec: 0
+ },
+ inputDateTimeString = expectedDateString + ' ' +
+ expectedParsedTime.hour + ':' +
+ expectedParsedTime.minute + ':' +
+ expectedParsedTime.second + '.' +
+ expectedParsedTime.millisec,
+ expectedDate = new Date(expectedDateString),
+ result;
+
+ result = util._parseDateTimeInternal(dateFormat, 'H:m:s.l', inputDateTimeString, undefined, undefined);
+
+ expect(result.date).toEqual(expectedDate);
+ expect(result.timeObj).toEqual(expectedParsedTime);
+ });
+
+ it('should throw an exception if it cannot parse the time', function() {
+ var inputDateString = '4/17/2008 11:22:33';
+
+ expect(function() {
+ util._parseDateTimeInternal(dateFormat, 'q', inputDateString, undefined, undefined);
+ }).toThrow('Wrong time format');
+ });
+ });
+ });
+
+ describe('timepicker functions', function() {
+ describe('timezoneOffsetNumber', function() {
+ it('returns 0 if the time zone string is iso8601 Zulu', function() {
+ expect($.timepicker.timezoneOffsetNumber('Z')).toBe(0);
+ expect($.timepicker.timezoneOffsetNumber('z')).toBe(0);
+ expect($.timepicker.timezoneOffsetNumber(':Z')).toBe(0);
+ });
+
+ it('returns a string that does not match the expected representations', function() {
+ expect($.timepicker.timezoneOffsetNumber('EDT')).toBe('EDT');
+ expect($.timepicker.timezoneOffsetNumber('1234')).toBe('1234');
+ expect($.timepicker.timezoneOffsetNumber('+123')).toBe('+123');
+ expect($.timepicker.timezoneOffsetNumber('-123')).toBe('-123');
+ expect($.timepicker.timezoneOffsetNumber('abc:def')).toBe('abc:def');
+ });
+
+ it('returns the minute offset from a time zone offset string', function() {
+ expect($.timepicker.timezoneOffsetNumber('-0000')).toBe(0);
+ expect($.timepicker.timezoneOffsetNumber('+0000')).toBe(0);
+ expect($.timepicker.timezoneOffsetNumber('-0400')).toBe(-240);
+ expect($.timepicker.timezoneOffsetNumber('+0400')).toBe(240);
+ });
+ });
+
+ describe('timezoneOffsetString', function() {
+ it('returns NaN if the input is NaN', function() {
+ expect($.timepicker.timezoneOffsetString(NaN, false)).toBeNaN();
+ });
+
+ it('returns the input if the input is greater than 840 (+14:00)', function() {
+ var expectedMinutes = 850;
+
+ var actualMinutes = $.timepicker.timezoneOffsetString(expectedMinutes, false);
+
+ expect(actualMinutes).toBe(expectedMinutes);
+ });
+
+ it('returns the input if the input is less than -720 (-12:00)', function() {
+ var expectedMinutes = -730;
+
+ var actualMinutes = $.timepicker.timezoneOffsetString(expectedMinutes, false);
+
+ expect(actualMinutes).toBe(expectedMinutes);
+ });
+
+ it('returns "Z" if the offset is 0 and iso8601 is true', function() {
+ expect($.timepicker.timezoneOffsetString(0, true)).toBe('Z');
+ });
+
+ it('returns the expected offset string for non-iso8601 values', function() {
+ expect($.timepicker.timezoneOffsetString(0, false)).toBe('+0000');
+ expect($.timepicker.timezoneOffsetString(60, false)).toBe('+0100');
+ expect($.timepicker.timezoneOffsetString(480, false)).toBe('+0800');
+ expect($.timepicker.timezoneOffsetString(-60, false)).toBe('-0100');
+ expect($.timepicker.timezoneOffsetString(-480, false)).toBe('-0800');
+ expect($.timepicker.timezoneOffsetString(-720, false)).toBe('-1200');
+ expect($.timepicker.timezoneOffsetString(840, false)).toBe('+1400');
+ });
+
+ it('returns the expected offset string for iso8601 values', function() {
+ expect($.timepicker.timezoneOffsetString(60, true)).toBe('+01:00');
+ expect($.timepicker.timezoneOffsetString(480, true)).toBe('+08:00');
+ expect($.timepicker.timezoneOffsetString(-60, true)).toBe('-01:00');
+ expect($.timepicker.timezoneOffsetString(-480, true)).toBe('-08:00');
+ expect($.timepicker.timezoneOffsetString(-720, true)).toBe('-12:00');
+ expect($.timepicker.timezoneOffsetString(840, true)).toBe('+14:00');
+ });
+
+ it('handles abnormal values reasonably', function() {
+ expect($.timepicker.timezoneOffsetString(null, false)).toBe('+0000');
+ expect($.timepicker.timezoneOffsetString(null, true)).toBe('Z');
+
+ expect($.timepicker.timezoneOffsetString(undefined, false)).toBeUndefined();
+ expect($.timepicker.timezoneOffsetString(undefined, true)).toBeUndefined();
+ });
+ });
+
+ describe('timezoneAdjust', function() {
+ it('does not change the date if the timezone yields NaN for an offset', function() {
+ var expectedDate = new Date();
+
+ expect($.timepicker.timezoneAdjust(expectedDate, NaN)).toEqual(expectedDate);
+ });
+
+ it('changes the minutes by the time zone offset minutes', function() {
+ var inputDate,
+ originalMillis,
+ expectedDifference,
+ adjustedDate;
+
+ inputDate = new Date();
+ originalMillis = inputDate.getTime();
+ expectedDifference = -(inputDate.getTimezoneOffset() + 60) * 60 * 1000;
+
+ adjustedDate = $.timepicker.timezoneAdjust(inputDate, '+0100');
+
+ expect(adjustedDate.getTime() - originalMillis).toBe(expectedDifference);
+ });
+ });
+
+ describe('log', function() {
+ it('calls console.log with the message if the console exists', function() {
+ var expectedMessage = "Just what I expected!";
+ spyOn(window.console, "log");
+
+ $.timepicker.log(expectedMessage);
+
+ expect(window.console.log).toHaveBeenCalledWith(expectedMessage);
+ });
+
+ it('does not call console.log if there is no console', function() {
+ var originalConsole = window.console,
+ consoleLogSpy = spyOn(window.console, "log");
+ window.console = undefined;
+
+ $.timepicker.log("Don't care");
+
+ expect(consoleLogSpy).not.toHaveBeenCalled();
+
+ window.console = originalConsole;
+ });
+ });
+
+ describe('range functions', function() {
+ var startTime = $('<p>start</p>'),
+ endTime = $('<p>end</p>'),
+ options = {};
+
+ describe('convenience functions', function() {
+ beforeEach(function() {
+ spyOn($.timepicker, 'handleRange');
+ });
+
+ it('timeRange calls handleRange the right way', function() {
+ $.timepicker.timeRange(startTime, endTime, options);
+
+ expect($.timepicker.handleRange).toHaveBeenCalledWith('timepicker', startTime, endTime, options);
+ });
+
+ it('datetimeRange calls handleRange the right way', function() {
+ $.timepicker.datetimeRange(startTime, endTime, options);
+
+ expect($.timepicker.handleRange).toHaveBeenCalledWith('datetimepicker', startTime, endTime, options);
+ });
+
+ it('dateRange calls handleRange the right way', function() {
+ $.timepicker.dateRange(startTime, endTime, options);
+
+ expect($.timepicker.handleRange).toHaveBeenCalledWith('datepicker', startTime, endTime, options);
+ });
+ });
+
+ xdescribe('handleRange', function() {
+ // TODO: Difficult to test. Needs attention.
+ });
+ });
+ });
+
+ describe('datepicker functions', function() {
+ describe('formatTime', function() {
+ describe('single formats, default options', function() {
+ var emptyTime = {};
+
+ describe('hours', function() {
+ var earlyHour = {hour: 7},
+ lateHour = {hour: 17};
+
+ it('formats HH correctly', function() {
+ expect($.datepicker.formatTime('HH', emptyTime)).toBe('00');
+ expect($.datepicker.formatTime('HH', earlyHour)).toBe('07');
+ expect($.datepicker.formatTime('HH', lateHour)).toBe('17');
+ });
+
+ it('formats H correctly', function() {
+ expect($.datepicker.formatTime('H', emptyTime)).toBe('0');
+ expect($.datepicker.formatTime('H', earlyHour)).toBe('7');
+ expect($.datepicker.formatTime('H', lateHour)).toBe('17');
+ });
+
+ it('formats hh correctly', function() {
+ expect($.datepicker.formatTime('hh', emptyTime)).toBe('12');
+ expect($.datepicker.formatTime('hh', earlyHour)).toBe('07');
+ expect($.datepicker.formatTime('hh', lateHour)).toBe('05');
+ });
+
+ it('formats h correctly', function() {
+ expect($.datepicker.formatTime('h', emptyTime)).toBe('12');
+ expect($.datepicker.formatTime('h', earlyHour)).toBe('7');
+ expect($.datepicker.formatTime('h', lateHour)).toBe('5');
+ });
+ });
+
+ describe('minutes', function() {
+ var singleDigitMinute = {minute: 3},
+ doubleDigitMinute = {minute: 42};
+
+ it('formats mm correctly', function() {
+ expect($.datepicker.formatTime('mm', emptyTime)).toBe('00');
+ expect($.datepicker.formatTime('mm', singleDigitMinute)).toBe('03');
+ expect($.datepicker.formatTime('mm', doubleDigitMinute)).toBe('42');
+ });
+
+ it('formats m correctly', function() {
+ expect($.datepicker.formatTime('m', emptyTime)).toBe('0');
+ expect($.datepicker.formatTime('m', singleDigitMinute)).toBe('3');
+ expect($.datepicker.formatTime('m', doubleDigitMinute)).toBe('42');
+ });
+ });
+
+ describe('seconds', function() {
+ var singleDigitSecond = {second: 5},
+ doubleDigitSecond = {second: 31};
+
+ it('formats ss correctly', function() {
+ expect($.datepicker.formatTime('ss', emptyTime)).toBe('00');
+ expect($.datepicker.formatTime('ss', singleDigitSecond)).toBe('05');
+ expect($.datepicker.formatTime('ss', doubleDigitSecond)).toBe('31');
+ });
+
+ it('formats s correctly', function() {
+ expect($.datepicker.formatTime('s', emptyTime)).toBe('0');
+ expect($.datepicker.formatTime('s', singleDigitSecond)).toBe('5');
+ expect($.datepicker.formatTime('s', doubleDigitSecond)).toBe('31');
+ });
+ });
+
+ describe('milliseconds', function() {
+ it('formats l correctly', function() {
+ var singleDigitMillis = {millisec: 3},
+ doubleDigitMillis = {millisec: 17},
+ tripleDigitMillis = {millisec: 123};
+
+ expect($.datepicker.formatTime('l', emptyTime)).toBe('000');
+ expect($.datepicker.formatTime('l', singleDigitMillis)).toBe('003');
+ expect($.datepicker.formatTime('l', doubleDigitMillis)).toBe('017');
+ expect($.datepicker.formatTime('l', tripleDigitMillis)).toBe('123');
+ });
+ });
+
+ describe('microseconds', function() {
+ it('formats c correctly', function() {
+ var singleDigitMicros = {microsec: 3},
+ doubleDigitMicros = {microsec: 17},
+ tripleDigitMicros = {microsec: 123};
+
+ expect($.datepicker.formatTime('c', emptyTime)).toBe('000');
+ expect($.datepicker.formatTime('c', singleDigitMicros)).toBe('003');
+ expect($.datepicker.formatTime('c', doubleDigitMicros)).toBe('017');
+ expect($.datepicker.formatTime('c', tripleDigitMicros)).toBe('123');
+ });
+ });
+
+ describe('timezone', function() {
+ var nullTimezoneTime = {timezone: null},
+ noTimezoneTime = emptyTime,
+ timezoneTime = {timezone: -240},
+ noTimezoneOptions = {},
+ timezoneOptions = {timezone: 600};
+
+ it('handles z correctly', function() {
+ expect($.datepicker.formatTime('z', timezoneTime, noTimezoneOptions)).toBe('-0400');
+ expect($.datepicker.formatTime('z', timezoneTime, timezoneOptions)).toBe('-0400');
+
+ expect($.datepicker.formatTime('z', nullTimezoneTime, timezoneOptions)).toBe('+1000');
+ expect($.datepicker.formatTime('z', noTimezoneTime, timezoneOptions)).toBe('+1000');
+ expect($.datepicker.formatTime('z', nullTimezoneTime, noTimezoneOptions)).toBe('+0000');
+ expect($.datepicker.formatTime('z', noTimezoneTime, noTimezoneOptions)).toBe('+0000');
+ });
+
+ it('handles Z correctly', function() {
+ expect($.datepicker.formatTime('Z', timezoneTime, noTimezoneOptions)).toBe('-04:00');
+ expect($.datepicker.formatTime('Z', timezoneTime, timezoneOptions)).toBe('-04:00');
+
+ expect($.datepicker.formatTime('Z', nullTimezoneTime, timezoneOptions)).toBe('+10:00');
+ expect($.datepicker.formatTime('Z', noTimezoneTime, timezoneOptions)).toBe('+10:00');
+ expect($.datepicker.formatTime('Z', nullTimezoneTime, noTimezoneOptions)).toBe('Z');
+ expect($.datepicker.formatTime('Z', noTimezoneTime, noTimezoneOptions)).toBe('Z');
+ });
+ });
+
+ describe('am/pm', function() {
+ var morningHour = {hour: 3},
+ afternoonHour = {hour: 15};
+
+ it('formats t correctly', function() {
+ expect($.datepicker.formatTime('t', emptyTime)).toBe('a');
+ expect($.datepicker.formatTime('t', morningHour)).toBe('a');
+ expect($.datepicker.formatTime('t', afternoonHour)).toBe('p');
+ });
+
+ it('formats T correctly', function() {
+ expect($.datepicker.formatTime('T', emptyTime)).toBe('A');
+ expect($.datepicker.formatTime('T', morningHour)).toBe('A');
+ expect($.datepicker.formatTime('T', afternoonHour)).toBe('P');
+ });
+
+ it('formats tt correctly', function() {
+ expect($.datepicker.formatTime('tt', emptyTime)).toBe('am');
+ expect($.datepicker.formatTime('tt', morningHour)).toBe('am');
+ expect($.datepicker.formatTime('tt', afternoonHour)).toBe('pm');
+ });
+
+ it('formats TT correctly', function() {
+ expect($.datepicker.formatTime('TT', emptyTime)).toBe('AM');
+ expect($.datepicker.formatTime('TT', morningHour)).toBe('AM');
+ expect($.datepicker.formatTime('TT', afternoonHour)).toBe('PM');
+ });
+ });
+
+ describe('literals', function() {
+ it('handles literals correctly', function() {
+ expect($.datepicker.formatTime('', emptyTime)).toBe('');
+ expect($.datepicker.formatTime("'abc'", emptyTime)).toBe('abc');
+ expect($.datepicker.formatTime("'", emptyTime)).toBe("'");
+ expect($.datepicker.formatTime("''", emptyTime)).toBe("");
+ expect($.datepicker.formatTime("'abc' h 'def'", emptyTime)).toBe('abc 12 def');
+ });
+
+ it('does not treat double quotes as literals', function() {
+ expect($.datepicker.formatTime('"ab"', emptyTime)).toBe('"ab"');
+ expect($.datepicker.formatTime('"abc"', emptyTime)).toBe('"ab000"');
+ });
+ });
+ });
+
+ describe('preserves whitespace in formats', function() {
+ it('preserves leading whitespace', function() {
+ expect($.datepicker.formatTime(' H', {hour: 3})).toBe(' 3');
+ });
+
+ it('preserves trailing whitespace', function() {
+ expect($.datepicker.formatTime('H ', {hour: 3})).toBe('3 ');
+ });
+ });
+ });
+ });
+}); \ No newline at end of file