Actualización

This commit is contained in:
Xes
2025-04-10 12:53:50 +02:00
parent f7a0ba2b2f
commit 2001ceddea
39284 changed files with 991962 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
{
"name": "datepair.js",
"version": "0.4.17",
"main": [
"dist/datepair.js",
"dist/jquery.datepair.js"
],
"ignore": [
"**/.*",
"node_modules",
"components",
"spec",
"Gruntfile.js",
"src",
"bower_components",
"test",
"tests"
],
"homepage": "http://jonthornton.github.com/Datepair.js",
"authors": [
"Jon Thornton"
],
"description": "A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.",
"keywords": [
"timepicker",
"datepicker",
"time",
"date",
"picker",
"ui",
"calendar",
"input",
"form"
],
"license": "MIT",
"_release": "0.4.17",
"_resolution": {
"type": "version",
"tag": "0.4.17",
"commit": "8ab365ca593b66062bf4b611ed74a4f50616d64f"
},
"_source": "https://github.com/jonthornton/Datepair.js.git",
"_target": "*",
"_originalSource": "datepair"
}

View File

@@ -0,0 +1,55 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/*!\n' +
' * <%= pkg.name %> v<%= pkg.version %> - <%= pkg.description %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> - <%= pkg.homepage %>\n' +
' * License: <%= pkg.license %>\n' +
' */\n\n'
},
rig: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
files: {
'dist/datepair.js': ['src/wrapper.js'],
'dist/jquery.datepair.js' : ['src/jquery.datepair.js'],
}
}
},
uglify: {
options: {
banner: '<%= meta.banner %>',
report: 'min'
},
dist: {
files: {
'dist/datepair.min.js': 'dist/datepair.js',
'dist/jquery.datepair.min.js': ['dist/datepair.js', 'dist/jquery.datepair.js'],
}
}
},
jshint: {
all: ['src/*.js']
},
watch: {
options : {
atBegin : true
},
files: ['src/*.js'],
tasks: ['rig']
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-rigger');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['rig', 'uglify']);
};

View File

@@ -0,0 +1,23 @@
{
"name": "datepair.js",
"version": "0.4.17",
"main": ["dist/datepair.js", "dist/jquery.datepair.js"],
"ignore": [
"**/.*",
"node_modules",
"components",
"spec",
"Gruntfile.js",
"src",
"bower_components",
"test",
"tests"
],
"homepage": "http://jonthornton.github.com/Datepair.js",
"authors": [
"Jon Thornton"
],
"description": "A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.",
"keywords": [ "timepicker", "datepicker", "time", "date", "picker", "ui", "calendar", "input", "form" ],
"license": "MIT"
}

View File

@@ -0,0 +1,27 @@
{
"name": "datepair",
"version": "0.4.10",
"title": "Datepair.js",
"description": "A plugin for intelligently selecting date and time ranges inspired by Google Calendar.",
"author": {
"name": "Jon Thornton",
"email": "thornton.jon@gmail.com",
"url": "https://github.com/jonthornton"
},
"licenses": [
{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
}
],
"dependencies": {
"jquery": ">=1.7"
},
"keywords": [ "timepicker", "datepicker", "time", "date", "picker", "ui", "calendar", "input", "form" ],
"homepage": "http://jonthornton.github.com/jquery-datepair/",
"bugs": {
"url": "https://github.com/jonthornton/jquery-datepair/issues"
},
"docs": "https://github.com/jonthornton/jquery-datepair",
"download": "https://github.com/jonthornton/jquery-datepair"
}

View File

@@ -0,0 +1,365 @@
/*!
* datepair.js v0.4.17 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* Copyright (c) 2021 Jon Thornton - http://jonthornton.github.com/Datepair.js
* License: MIT
*/
(function(window, document) {
'use strict';
var _ONE_DAY = 86400000;
var jq = window.Zepto || window.jQuery;
function simpleExtend(obj1, obj2) {
var out = obj2 || {};
for (var i in obj1) {
if (!(i in out)) {
out[i] = obj1[i];
}
}
return out;
}
// IE's custom event support is totally borked.
// Use jQuery if possible
function triggerSimpleCustomEvent(el, eventName) {
if (jq) {
jq(el).trigger(eventName);
} else {
var event = document.createEvent('CustomEvent');
event.initCustomEvent(eventName, true, true, {});
el.dispatchEvent(event);
}
}
// el.classList not supported by < IE10
// use jQuery if available
function hasClass(el, className) {
if (jq) {
return jq(el).hasClass(className);
} else {
return el.classList.contains(className);
}
}
function Datepair(container, options) {
this.dateDelta = null;
this.timeDelta = null;
this._defaults = {
startClass: 'start',
endClass: 'end',
timeClass: 'time',
dateClass: 'date',
defaultDateDelta: 0,
defaultTimeDelta: 3600000,
anchor: 'start',
// defaults for jquery-timepicker; override when using other input widgets
parseTime: function(input){
return jq(input).timepicker('getTime');
},
updateTime: function(input, dateObj){
jq(input).timepicker('setTime', dateObj);
},
setMinTime: function(input, dateObj){
jq(input).timepicker('option', 'minTime', dateObj);
},
// defaults for bootstrap datepicker; override when using other input widgets
parseDate: function(input){
return input.value && jq(input).datepicker('getDate');
},
updateDate: function(input, dateObj){
jq(input).datepicker('update', dateObj);
}
};
this.container = container;
this.settings = simpleExtend(this._defaults, options);
this.startDateInput = this.container.querySelector('.'+this.settings.startClass+'.'+this.settings.dateClass);
this.endDateInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.dateClass);
this.startTimeInput = this.container.querySelector('.'+this.settings.startClass+'.'+this.settings.timeClass);
this.endTimeInput = this.container.querySelector('.'+this.settings.endClass+'.'+this.settings.timeClass);
// initialize date and time deltas
this.refresh();
// init starts here
this._bindChangeHandler();
}
Datepair.prototype = {
constructor: Datepair,
option: function(key, value)
{
if (typeof key == 'object') {
this.settings = simpleExtend(this.settings, key);
} else if (typeof key == 'string' && typeof value != 'undefined') {
this.settings[key] = value;
} else if (typeof key == 'string') {
return this.settings[key];
}
this._updateEndMintime();
},
getTimeDiff: function()
{
// due to the fact that times can wrap around, timeDiff for any
// time-only pair will always be >= 0
var delta = this.dateDelta + this.timeDelta;
if (delta < 0 && (!this.startDateInput || !this.endDateInput) ) {
delta += _ONE_DAY;
}
return delta;
},
refresh: function()
{
if (this.startDateInput && this.startDateInput.value && this.endDateInput && this.endDateInput.value) {
var startDate = this.settings.parseDate(this.startDateInput);
var endDate = this.settings.parseDate(this.endDateInput);
if (startDate && endDate) {
this.dateDelta = endDate.getTime() - startDate.getTime();
}
}
if (this.startTimeInput && this.startTimeInput.value && this.endTimeInput && this.endTimeInput.value) {
var startTime = this.settings.parseTime(this.startTimeInput);
var endTime = this.settings.parseTime(this.endTimeInput);
if (startTime && endTime) {
this.timeDelta = endTime.getTime() - startTime.getTime();
this._updateEndMintime();
}
}
},
remove: function()
{
this._unbindChangeHandler();
},
_bindChangeHandler: function(){
// addEventListener doesn't work with synthetic "change" events
// fired by jQuery's trigger() functioin. If jQuery is present,
// use that for event binding
if (jq) {
jq(this.container).on('change.datepair', jq.proxy(this.handleEvent, this));
} else {
this.container.addEventListener('change', this, false);
}
},
_unbindChangeHandler: function(){
if (jq) {
jq(this.container).off('change.datepair');
} else {
this.container.removeEventListener('change', this, false);
}
},
// This function will be called when passing 'this' to addEventListener
handleEvent: function(e){
// temporarily unbind the change handler to prevent triggering this
// if we update other inputs
this._unbindChangeHandler();
if (hasClass(e.target, this.settings.dateClass)) {
if (e.target.value != '') {
this._dateChanged(e.target);
this._timeChanged(e.target);
} else {
this.dateDelta = null;
}
} else if (hasClass(e.target, this.settings.timeClass)) {
if (e.target.value != '') {
this._timeChanged(e.target);
} else {
this.timeDelta = null;
}
}
this._validateRanges();
this._updateEndMintime();
this._bindChangeHandler();
},
_dateChanged: function(target){
if (!this.startDateInput || !this.endDateInput) {
return;
}
var startDate = this.settings.parseDate(this.startDateInput);
var endDate = this.settings.parseDate(this.endDateInput);
if (!startDate || !endDate) {
if (this.settings.defaultDateDelta !== null) {
if (startDate) {
var newEnd = new Date(startDate.getTime() + this.settings.defaultDateDelta * _ONE_DAY);
this.settings.updateDate(this.endDateInput, newEnd);
} else if (endDate) {
var newStart = new Date(endDate.getTime() - this.settings.defaultDateDelta * _ONE_DAY);
this.settings.updateDate(this.startDateInput, newStart);
}
this.dateDelta = this.settings.defaultDateDelta * _ONE_DAY;
} else {
this.dateDelta = null;
}
return;
}
if (Math.abs(endDate.getFullYear() - startDate.getFullYear()) > 1000) {
console.log('here')
return;
}
if (this.settings.anchor == 'start' && hasClass(target, this.settings.startClass)) {
var newDate = new Date(startDate.getTime() + this.dateDelta);
this.settings.updateDate(this.endDateInput, newDate);
} else if (this.settings.anchor == 'end' && hasClass(target, this.settings.endClass)) {
var newDate = new Date(endDate.getTime() - this.dateDelta);
this.settings.updateDate(this.startDateInput, newDate);
} else {
if (endDate < startDate) {
var otherInput = hasClass(target, this.settings.startClass) ? this.endDateInput : this.startDateInput;
var selectedDate = this.settings.parseDate(target);
this.dateDelta = 0;
this.settings.updateDate(otherInput, selectedDate);
} else {
this.dateDelta = endDate.getTime() - startDate.getTime();
}
}
},
_timeChanged: function(target){
if (!this.startTimeInput || !this.endTimeInput) {
return;
}
var startTime = this.settings.parseTime(this.startTimeInput);
var endTime = this.settings.parseTime(this.endTimeInput);
if (!startTime || !endTime) {
if (this.settings.defaultTimeDelta !== null) {
this.timeDelta = this.settings.defaultTimeDelta;
if (startTime) {
endTime = this._setTimeAndReturn(this.endTimeInput, new Date(startTime.getTime() + this.settings.defaultTimeDelta));
this._doMidnightRollover(startTime, endTime);
} else if (endTime) {
startTime = this._setTimeAndReturn(this.startTimeInput, new Date(endTime.getTime() - this.settings.defaultTimeDelta));
this._doMidnightRollover(startTime, endTime);
}
} else {
this.timeDelta = null;
}
return;
}
if (this.settings.anchor == 'start' && hasClass(target, this.settings.startClass)) {
endTime = this._setTimeAndReturn(this.endTimeInput, new Date(startTime.getTime() + this.timeDelta));
this._doMidnightRollover(startTime, endTime);
} else if (this.settings.anchor == 'end' && hasClass(target, this.settings.endClass)) {
startTime = this._setTimeAndReturn(this.startTimeInput, new Date(endTime.getTime() - this.timeDelta));
this._doMidnightRollover(startTime, endTime);
} else {
this._doMidnightRollover(startTime, endTime);
var startDate, endDate;
if (this.startDateInput && this.endDateInput) {
startDate = this.settings.parseDate(this.startDateInput);
endDate = this.settings.parseDate(this.endDateInput);
}
if ((+startDate == +endDate) && (endTime < startTime)) {
var thisInput = hasClass(target, this.settings.endClass) ? this.endTimeInput : this.startTimeInput;
var otherInput = hasClass(target, this.settings.startClass) ? this.endTimeInput : this.startTimeInput;
var selectedTime = this.settings.parseTime(thisInput);
this.timeDelta = 0;
this.settings.updateTime(otherInput, selectedTime);
} else {
this.timeDelta = endTime.getTime() - startTime.getTime();
}
}
},
_setTimeAndReturn: function(input, newTime) {
this.settings.updateTime(input, newTime);
return this.settings.parseTime(input);
},
_doMidnightRollover: function(startTime, endTime) {
if (!this.startDateInput || !this.endDateInput) {
return;
}
var endDate = this.settings.parseDate(this.endDateInput);
var startDate = this.settings.parseDate(this.startDateInput);
var newDelta = endTime.getTime() - startTime.getTime();
var offset = (endTime < startTime) ? _ONE_DAY : -1 * _ONE_DAY;
if (this.dateDelta !== null
&& this.dateDelta + this.timeDelta <= _ONE_DAY
&& this.dateDelta + newDelta != 0
&& (offset > 0 || this.dateDelta != 0)
&& ((newDelta >= 0 && this.timeDelta < 0) || (newDelta < 0 && this.timeDelta >= 0))) {
if (this.settings.anchor == 'start') {
this.settings.updateDate(this.endDateInput, new Date(endDate.getTime() + offset));
this._dateChanged(this.endDateInput);
} else if (this.settings.anchor == 'end') {
this.settings.updateDate(this.startDateInput, new Date(startDate.getTime() - offset));
this._dateChanged(this.startDateInput);
}
}
this.timeDelta = newDelta;
},
_updateEndMintime: function(){
if (typeof this.settings.setMinTime != 'function') return;
var baseTime = null;
if (this.settings.anchor == 'start' && (!this.dateDelta || this.dateDelta < _ONE_DAY || (this.timeDelta && this.dateDelta + this.timeDelta < _ONE_DAY))) {
baseTime = this.settings.parseTime(this.startTimeInput);
}
this.settings.setMinTime(this.endTimeInput, baseTime);
},
_validateRanges: function(){
if (this.startTimeInput && this.endTimeInput && this.timeDelta === null) {
triggerSimpleCustomEvent(this.container, 'rangeIncomplete');
return;
}
if (this.startDateInput && this.endDateInput && this.dateDelta === null) {
triggerSimpleCustomEvent(this.container, 'rangeIncomplete');
return;
}
// due to the fact that times can wrap around, any time-only pair will be considered valid
if (!this.startDateInput || !this.endDateInput || this.dateDelta + this.timeDelta >= 0) {
triggerSimpleCustomEvent(this.container, 'rangeSelected');
} else {
triggerSimpleCustomEvent(this.container, 'rangeError');
}
}
};
window.Datepair = Datepair;
}(window, document));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,51 @@
/*!
* datepair.js v0.4.17 - A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.
* Copyright (c) 2021 Jon Thornton - http://jonthornton.github.com/Datepair.js
* License: MIT
*/
(function($) {
if(!$) {
return;
}
////////////
// Plugin //
////////////
$.fn.datepair = function(option) {
var out;
this.each(function() {
var $this = $(this);
var data = $this.data('datepair');
var options = typeof option === 'object' && option;
if (!data) {
data = new Datepair(this, options);
$this.data('datepair', data);
}
if (option === 'remove') {
out = data['remove']();
$this.removeData('datepair', data);
}
if (typeof option === 'string') {
out = data[option]();
}
});
return out || this;
};
//////////////
// Data API //
//////////////
$('[data-datepair]').each(function() {
var $this = $(this);
$this.datepair($this.data());
});
}(window.Zepto || window.jQuery));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,83 @@
/**
* FILE: jquery.ptTileSelect.css
* Default style for the timeselect container.
*
* LAST UPDATED:
*
* - $Date: 2009/04/12 20:23:02 $
* - $Author: paulinho4u $
* - $Revision: 1.1 $
*/
#ptTimeSelectCntr {
width: 250px;
font-size: .9em;
position: absolute;
z-index: 10;
display: none;
}
#ptTimeSelectCntr .ui-widget{
padding: .2em;
}
#ptTimeSelectCntr .ui-widget-header {
padding: .2em;
}
#ptTimeSelectCntr #ptTimeSelectUserTime {
font-size: larger;
padding: .2em;
padding-left: 1em;
text-align: center;
}
#ptTimeSelectCntr #ptTimeSelectCloseCntr {
display: block;
padding: .2em;
}
#ptTimeSelectCntr #ptTimeSelectCloseCntr a {
display: block;
padding: .2em;
}
#ptTimeSelectCntr .ui-widget-content {
margin-top: .1em;
margin-bottom: .1em;
padding: .2em;
}
#ptTimeSelectCntr .ui-widget.ui-widget-content {
margin-top: 0;
}
#ptTimeSelectCntr .ptTimeSelectLeftPane.ui-widget-content {
border-top:none;
border-bottom:none;
border-left:none;
border-right-width: 2px;
}
#ptTimeSelectCntr .ptTimeSelectRightPane.ui-widget-content {
border: none;
}
#ptTimeSelectCntr .ptTimeSelectHrCntr a,
#ptTimeSelectCntr .ptTimeSelectMinCntr a {
display: block;
float: left;
padding: .2em;
width: 1.9em;
margin: 1px;
text-align: center;
text-decoration: none;
}
#ptTimeSelectCntr .ptTimeSelectHrAmPmCntr a {
text-align: center;
margin: 1px;
}
#ptTimeSelectCntr .ptTimeSelectTimeLabelsCntr {
font-weight: bold;
font-size: .9em;
}
#ptTimeSelectCntr #ptTimeSelectSetButton {
padding-top: .2em;
padding-bottom: .2em;
}
#ptTimeSelectCntr #ptTimeSelectSetButton a {
display: block;
padding: .2em;
width: 30%;
text-align: center;
float: right;
}

View File

@@ -0,0 +1,478 @@
/**
* FILE: jQuery.ptTileSelect.js
*
* @fileOverview
* jQuery plugin for displaying a popup that allows a user
* to define a time and set that time back to a form's input
* field.
*
* @version 0.8
* @author Paul Tavares, www.purtuga.com
* @see http://pttimeselect.sourceforge.net
*
* @requires jQuery {@link http://www.jquery.com}
*
*
* LICENSE:
*
* Copyright (c) 2007 Paul T. (purtuga.com)
* Dual licensed under the:
*
* - MIT
* <http://www.opensource.org/licenses/mit-license.php>
*
* - GPL
* <http://www.opensource.org/licenses/gpl-license.php>
*
* User can pick whichever one applies best for their project
* and doesn not have to contact me.
*
*
* INSTALLATION:
*
* There are two files (.css and .js) delivered with this plugin and
* that must be included in your html page after the jquery.js library
* and the jQuery UI style sheet (the jQuery UI javascript library is
* not necessary).
* Both of these are to be included inside of the 'head' element of
* the document. Example below demonstrates this along side the jQuery
* libraries.
*
* | <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
* | <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.22/themes/redmond/jquery-ui.css" />
* |
* | <link rel="stylesheet" type="text/css" href="jquery.ptTimeSelect.css" />
* | <script type="text/javascript" src="jquery.ptTimeSelect.js"></script>
* |
*
* USAGE:
*
* - See <$(ele).ptTimeSelect()>
*
*
*
* LAST UPDATED:
*
* - $Date: 2012/08/05 19:40:21 $
* - $Author: paulinho4u $
* - $Revision: 1.8 $
*
*/
(function($){
/**
* jQuery definition
*
* @see http://jquery.com/
* @name jQuery
* @class jQuery Library
*/
/**
* jQuery 'fn' definition to anchor all public plugin methods.
*
* @see http://jquery.com/
* @name fn
* @class jQuery Library public method anchor
* @memberOf jQuery
*/
/**
* Namespace for all properties and methods
*
* @namespace ptTimeSelect
* @memberOf jQuery
*/
jQuery.ptTimeSelect = {};
jQuery.ptTimeSelect.version = "__BUILD_VERSION_NUMBER__";
/**
* The default options for all calls to ptTimeSelect. Can be
* overwriten with each individual call to {@link jQuery.fn.ptTimeSelect}
*
* @type {Object} options
* @memberOf jQuery.ptTimeSelect
* @see jQuery.fn.ptTimeSelect
*/
jQuery.ptTimeSelect.options = {
containerClass: undefined,
containerWidth: '22em',
hoursLabel: 'Hour',
minutesLabel: 'Minutes',
setButtonLabel: 'Set',
popupImage: undefined,
onFocusDisplay: true,
zIndex: 10,
onBeforeShow: undefined,
onClose: undefined
};
/**
* Internal method. Called when page is initialized to add the time
* selection area to the DOM.
*
* @private
* @memberOf jQuery.ptTimeSelect
* @return {undefined}
*/
jQuery.ptTimeSelect._ptTimeSelectInit = function () {
jQuery(document).ready(
function () {
//if the html is not yet created in the document, then do it now
if (!jQuery('#ptTimeSelectCntr').length) {
jQuery("body").append(
'<div id="ptTimeSelectCntr" class="">'
+ ' <div class="ui-widget ui-widget-content ui-corner-all">'
+ ' <div class="ui-widget-header ui-corner-all">'
+ ' <div id="ptTimeSelectCloseCntr" style="float: right;">'
+ ' <a href="javascript: void(0);" onclick="jQuery.ptTimeSelect.closeCntr();" '
+ ' onmouseover="jQuery(this).removeClass(\'ui-state-default\').addClass(\'ui-state-hover\');" '
+ ' onmouseout="jQuery(this).removeClass(\'ui-state-hover\').addClass(\'ui-state-default\');"'
+ ' class="ui-corner-all ui-state-default">'
+ ' <span class="ui-icon ui-icon-circle-close">X</span>'
+ ' </a>'
+ ' </div>'
+ ' <div id="ptTimeSelectUserTime" style="float: left;">'
+ ' <span id="ptTimeSelectUserSelHr">1</span> : '
+ ' <span id="ptTimeSelectUserSelMin">00</span> '
+ ' <span id="ptTimeSelectUserSelAmPm">AM</span>'
+ ' </div>'
+ ' <br style="clear: both;" /><div></div>'
+ ' </div>'
+ ' <div class="ui-widget-content ui-corner-all">'
+ ' <div>'
+ ' <div class="ptTimeSelectTimeLabelsCntr">'
+ ' <div class="ptTimeSelectLeftPane" style="width: 50%; text-align: center; float: left;" class="">Hour</div>'
+ ' <div class="ptTimeSelectRightPane" style="width: 50%; text-align: center; float: left;">Minutes</div>'
+ ' </div>'
+ ' <div>'
+ ' <div style="float: left; width: 50%;">'
+ ' <div class="ui-widget-content ptTimeSelectLeftPane">'
+ ' <div class="ptTimeSelectHrAmPmCntr">'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);" '
+ ' style="display: block; width: 45%; float: left;">AM</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);" '
+ ' style="display: block; width: 45%; float: left;">PM</a>'
+ ' <br style="clear: left;" /><div></div>'
+ ' </div>'
+ ' <div class="ptTimeSelectHrCntr">'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">1</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">2</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">3</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">4</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">5</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">6</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">7</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">8</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">9</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">10</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">11</a>'
+ ' <a class="ptTimeSelectHr ui-state-default" href="javascript: void(0);">12</a>'
+ ' <br style="clear: left;" /><div></div>'
+ ' </div>'
+ ' </div>'
+ ' </div>'
+ ' <div style="width: 50%; float: left;">'
+ ' <div class="ui-widget-content ptTimeSelectRightPane">'
+ ' <div class="ptTimeSelectMinCntr">'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">00</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">05</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">10</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">15</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">20</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">25</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">30</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">35</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">40</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">45</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">50</a>'
+ ' <a class="ptTimeSelectMin ui-state-default" href="javascript: void(0);">55</a>'
+ ' <br style="clear: left;" /><div></div>'
+ ' </div>'
+ ' </div>'
+ ' </div>'
+ ' </div>'
+ ' </div>'
+ ' <div style="clear: left;"></div>'
+ ' </div>'
+ ' <div id="ptTimeSelectSetButton">'
+ ' <a href="javascript: void(0);" onclick="jQuery.ptTimeSelect.setTime()"'
+ ' onmouseover="jQuery(this).removeClass(\'ui-state-default\').addClass(\'ui-state-hover\');" '
+ ' onmouseout="jQuery(this).removeClass(\'ui-state-hover\').addClass(\'ui-state-default\');"'
+ ' class="ui-corner-all ui-state-default">'
+ ' SET'
+ ' </a>'
+ ' <br style="clear: both;" /><div></div>'
+ ' </div>'
+ ' <!--[if lte IE 6.5]>'
+ ' <iframe style="display:block; position:absolute;top: 0;left:0;z-index:-1;'
+ ' filter:Alpha(Opacity=\'0\');width:3000px;height:3000px"></iframe>'
+ ' <![endif]-->'
+ ' </div></div>'
);
var e = jQuery('#ptTimeSelectCntr');
// Add the events to the functions
e.find('.ptTimeSelectMin')
.bind("click", function(){
jQuery.ptTimeSelect.setMin($(this).text());
});
e.find('.ptTimeSelectHr')
.bind("click", function(){
jQuery.ptTimeSelect.setHr($(this).text());
});
$(document).mousedown(jQuery.ptTimeSelect._doCheckMouseClick);
}//end if
}
);
}();// jQuery.ptTimeSelectInit()
/**
* Sets the hour selected by the user on the popup.
*
* @private
* @param {Integer} h - Interger indicating the hour. This value
* is the same as the text value displayed on the
* popup under the hour. This value can also be the
* words AM or PM.
* @return {undefined}
*
*/
jQuery.ptTimeSelect.setHr = function(h) {
if ( h.toLowerCase() == "am"
|| h.toLowerCase() == "pm"
) {
jQuery('#ptTimeSelectUserSelAmPm').empty().append(h);
} else {
jQuery('#ptTimeSelectUserSelHr').empty().append(h);
}
};// END setHr() function
/**
* Sets the minutes selected by the user on the popup.
*
* @private
* @param {Integer} m - interger indicating the minutes. This
* value is the same as the text value displayed on the popup
* under the minutes.
* @return {undefined}
*/
jQuery.ptTimeSelect.setMin = function(m) {
jQuery('#ptTimeSelectUserSelMin').empty().append(m);
};// END setMin() function
/**
* Takes the time defined by the user and sets it to the input
* element that the popup is currently opened for.
*
* @private
* @return {undefined}
*/
jQuery.ptTimeSelect.setTime = function() {
var tSel = jQuery('#ptTimeSelectUserSelHr').text()
+ ":"
+ jQuery('#ptTimeSelectUserSelMin').text()
+ " "
+ jQuery('#ptTimeSelectUserSelAmPm').text();
jQuery(".isPtTimeSelectActive").val(tSel);
this.closeCntr();
};// END setTime() function
/**
* Displays the time definition area on the page, right below
* the input field. Also sets the custom colors/css on the
* displayed area to what ever the input element options were
* set with.
*
* @private
* @param {String} uId - Id of the element for whom the area will
* be displayed. This ID was created when the
* ptTimeSelect() method was called.
* @return {undefined}
*
*/
jQuery.ptTimeSelect.openCntr = function (ele) {
jQuery.ptTimeSelect.closeCntr();
jQuery(".isPtTimeSelectActive").removeClass("isPtTimeSelectActive");
var cntr = jQuery("#ptTimeSelectCntr");
var i = jQuery(ele).eq(0).addClass("isPtTimeSelectActive");
var opt = i.data("ptTimeSelectOptions");
var style = i.offset();
style['z-index'] = opt.zIndex;
style.top = (style.top + i.outerHeight());
if (opt.containerWidth) {
style.width = opt.containerWidth;
}
if (opt.containerClass) {
cntr.addClass(opt.containerClass);
}
cntr.css(style);
var hr = 1;
var min = '00';
var tm = 'AM';
if (i.val()) {
var re = /([0-9]{1,2}).*:.*([0-9]{2}).*(PM|AM)/i;
var match = re.exec(i.val());
if (match) {
hr = match[1] || 1;
min = match[2] || '00';
tm = match[3] || 'AM';
}
}
cntr.find("#ptTimeSelectUserSelHr").empty().append(hr);
cntr.find("#ptTimeSelectUserSelMin").empty().append(min);
cntr.find("#ptTimeSelectUserSelAmPm").empty().append(tm);
cntr.find(".ptTimeSelectTimeLabelsCntr .ptTimeSelectLeftPane")
.empty().append(opt.hoursLabel);
cntr.find(".ptTimeSelectTimeLabelsCntr .ptTimeSelectRightPane")
.empty().append(opt.minutesLabel);
cntr.find("#ptTimeSelectSetButton a").empty().append(opt.setButtonLabel);
if (opt.onBeforeShow) {
opt.onBeforeShow(i, cntr);
}
cntr.slideDown("fast");
};// END openCntr()
/**
* Closes (hides it) the popup container.
* @private
* @param {Object} i - Optional. The input field for which the
* container is being closed.
* @return {undefined}
*/
jQuery.ptTimeSelect.closeCntr = function(i) {
var e = $("#ptTimeSelectCntr");
if (e.is(":visible") == true) {
// If IE, then check to make sure it is realy visible
if (jQuery.support.tbody == false) {
if (!(e[0].offsetWidth > 0) && !(e[0].offsetHeight > 0) ) {
return;
}
}
jQuery('#ptTimeSelectCntr')
.css("display", "none")
.removeClass()
.css("width", "");
if (!i) {
i = $(".isPtTimeSelectActive");
}
if (i) {
var opt = i.removeClass("isPtTimeSelectActive")
.data("ptTimeSelectOptions");
if (opt && opt.onClose) {
opt.onClose(i);
}
}
}
return;
};//end closeCntr()
/**
* Closes the timePicker popup if user is not longer focused on the
* input field or the timepicker
*
* @private
* @param {jQueryEvent} ev - Event passed in by jQuery
* @return {undefined}
*/
jQuery.ptTimeSelect._doCheckMouseClick = function(ev){
if (!$("#ptTimeSelectCntr:visible").length) {
return;
}
if ( !jQuery(ev.target).closest("#ptTimeSelectCntr").length
&& jQuery(ev.target).not("input.isPtTimeSelectActive").length ){
jQuery.ptTimeSelect.closeCntr();
}
};// jQuery.ptTimeSelect._doCheckMouseClick
/**
* FUNCTION: $().ptTimeSelect()
* Attaches a ptTimeSelect widget to each matched element. Matched
* elements must be input fields that accept a values (input field).
* Each element, when focused upon, will display a time selection
* popoup where the user can define a time.
*
* @memberOf jQuery
*
* PARAMS:
*
* @param {Object} [opt] - An object with the options for the time selection widget.
*
* @param {String} [opt.containerClass=""] - A class to be associated with the popup widget.
*
* @param {String} [opt.containerWidth=""] - Css width for the container.
*
* @param {String} [opt.hoursLabel="Hours"] - Label for the Hours.
*
* @param {String} [opt.minutesLabel="Minutes"] - Label for the Mintues container.
*
* @param {String} [opt.setButtonLabel="Set"] - Label for the Set button.
*
* @param {String} [opt.popupImage=""] - The html element (ex. img or text) to be appended next to each
* input field and that will display the time select widget upon
* click.
*
* @param {Integer} [opt.zIndex=10] - Integer for the popup widget z-index.
*
* @param {Function} [opt.onBeforeShow=undefined] - Function to be called before the widget is made visible to the
* user. Function is passed 2 arguments: 1) the input field as a
* jquery object and 2) the popup widget as a jquery object.
*
* @param {Function} [opt.onClose=undefined] - Function to be called after closing the popup widget. Function
* is passed 1 argument: the input field as a jquery object.
*
* @param {Bollean} [opt.onFocusDisplay=true] - True or False indicating if popup is auto displayed upon focus
* of the input field.
*
*
* RETURN:
* @return {jQuery} selection
*
*
*
* EXAMPLE:
* @example
* $('#fooTime').ptTimeSelect();
*
*/
jQuery.fn.ptTimeSelect = function (opt) {
return this.each(function(){
if(this.nodeName.toLowerCase() != 'input') return;
var e = jQuery(this);
if (e.hasClass('hasPtTimeSelect')){
return this;
}
var thisOpt = {};
thisOpt = $.extend(thisOpt, jQuery.ptTimeSelect.options, opt);
e.addClass('hasPtTimeSelect').data("ptTimeSelectOptions", thisOpt);
//Wrap the input field in a <div> element with
// a unique id for later referencing.
if (thisOpt.popupImage || !thisOpt.onFocusDisplay) {
var img = jQuery('<span>&nbsp;</span><a href="javascript:" onclick="' +
'jQuery.ptTimeSelect.openCntr(jQuery(this).data(\'ptTimeSelectEle\'));">' +
thisOpt.popupImage + '</a>'
)
.data("ptTimeSelectEle", e);
e.after(img);
}
if (thisOpt.onFocusDisplay){
e.focus(function(){
jQuery.ptTimeSelect.openCntr(this);
});
}
return this;
});
};// End of jQuery.fn.ptTimeSelect
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,173 @@
@charset "UTF-8";
/*!
* Pikaday
* Copyright © 2014 David Bushell | BSD & MIT license | http://dbushell.com/
*/
.pika-single {
z-index: 9999;
display: block;
position: relative;
width: 240px;
padding: 8px;
color: #333;
background: #fff;
border: 1px solid #ccc;
border-bottom-color: #bbb;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.pika-single.is-hidden {
display: none;
}
.pika-single.is-bound {
position: absolute;
box-shadow: 0 5px 15px -5px rgba(0,0,0,.5);
}
.pika-title {
position: relative;
text-align: center;
}
.pika-label {
display: inline-block;
*display: inline;
position: relative;
z-index: 9999;
overflow: hidden;
margin: 0;
padding: 5px 3px;
font-size: 14px;
line-height: 20px;
font-weight: bold;
background-color: #fff;
}
.pika-title select {
cursor: pointer;
position: absolute;
z-index: 9998;
margin: 0;
left: 0;
top: 5px;
filter: alpha(opacity=0);
opacity: 0;
}
.pika-prev,
.pika-next {
display: block;
cursor: pointer;
position: relative;
outline: none;
border: 0;
padding: 0;
width: 20px;
height: 30px;
/* hide text using text-indent trick, using width value (it's enough) */
text-indent: 20px;
white-space: nowrap;
overflow: hidden;
background-color: transparent;
background-position: center center;
background-repeat: no-repeat;
background-size: 75% 75%;
opacity: .5;
*position: absolute;
*top: 0;
}
.pika-prev:hover,
.pika-next:hover {
opacity: 1;
}
.pika-prev,
.is-rtl .pika-next {
float: left;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAUklEQVR42u3VMQoAIBADQf8Pgj+OD9hG2CtONJB2ymQkKe0HbwAP0xucDiQWARITIDEBEnMgMQ8S8+AqBIl6kKgHiXqQqAeJepBo/z38J/U0uAHlaBkBl9I4GwAAAABJRU5ErkJggg==');
*left: 0;
}
.pika-next,
.is-rtl .pika-prev {
float: right;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAU0lEQVR42u3VOwoAMAgE0dwfAnNjU26bYkBCFGwfiL9VVWoO+BJ4Gf3gtsEKKoFBNTCoCAYVwaAiGNQGMUHMkjGbgjk2mIONuXo0nC8XnCf1JXgArVIZAQh5TKYAAAAASUVORK5CYII=');
*right: 0;
}
.pika-prev.is-disabled,
.pika-next.is-disabled {
cursor: default;
opacity: .2;
}
.pika-select {
display: inline-block;
*display: inline;
}
.pika-table {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
border: 0;
}
.pika-table th,
.pika-table td {
width: 14.285714285714286%;
padding: 0;
}
.pika-table th {
color: #999;
font-size: 12px;
line-height: 25px;
font-weight: bold;
text-align: center;
}
.pika-button {
cursor: pointer;
display: block;
outline: none;
border: 0;
margin: 0;
width: 100%;
padding: 5px;
color: #666;
font-size: 12px;
line-height: 15px;
text-align: right;
background: #f5f5f5;
}
.is-today .pika-button {
color: #33aaff;
font-weight: bold;
}
.is-selected .pika-button {
color: #fff;
font-weight: bold;
background: #33aaff;
box-shadow: inset 0 1px 3px #178fe5;
border-radius: 3px;
}
.is-disabled .pika-button {
pointer-events: none;
cursor: default;
color: #999;
opacity: .3;
}
.pika-button:hover {
color: #fff !important;
background: #ff8000 !important;
box-shadow: none !important;
border-radius: 3px !important;
}

View File

@@ -0,0 +1,973 @@
/*!
* Pikaday
*
* Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
*/
(function (root, factory)
{
'use strict';
var moment;
if (typeof exports === 'object') {
// CommonJS module
// Load moment.js as an optional dependency
try { moment = require('moment'); } catch (e) {}
module.exports = factory(moment);
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(function (req)
{
// Load moment.js as an optional dependency
var id = 'moment';
moment = req.defined && req.defined(id) ? req(id) : undefined;
return factory(moment);
});
} else {
root.Pikaday = factory(root.moment);
}
}(this, function (moment)
{
'use strict';
/**
* feature detection and helper functions
*/
var hasMoment = typeof moment === 'function',
hasEventListeners = !!window.addEventListener,
document = window.document,
sto = window.setTimeout,
addEvent = function(el, e, callback, capture)
{
if (hasEventListeners) {
el.addEventListener(e, callback, !!capture);
} else {
el.attachEvent('on' + e, callback);
}
},
removeEvent = function(el, e, callback, capture)
{
if (hasEventListeners) {
el.removeEventListener(e, callback, !!capture);
} else {
el.detachEvent('on' + e, callback);
}
},
fireEvent = function(el, eventName, data)
{
var ev;
if (document.createEvent) {
ev = document.createEvent('HTMLEvents');
ev.initEvent(eventName, true, false);
ev = extend(ev, data);
el.dispatchEvent(ev);
} else if (document.createEventObject) {
ev = document.createEventObject();
ev = extend(ev, data);
el.fireEvent('on' + eventName, ev);
}
},
trim = function(str)
{
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,'');
},
hasClass = function(el, cn)
{
return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
},
addClass = function(el, cn)
{
if (!hasClass(el, cn)) {
el.className = (el.className === '') ? cn : el.className + ' ' + cn;
}
},
removeClass = function(el, cn)
{
el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
},
isArray = function(obj)
{
return (/Array/).test(Object.prototype.toString.call(obj));
},
isDate = function(obj)
{
return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
},
isLeapYear = function(year)
{
// solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
},
getDaysInMonth = function(year, month)
{
return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
},
setToStartOfDay = function(date)
{
if (isDate(date)) date.setHours(0,0,0,0);
},
compareDates = function(a,b)
{
// weak date comparison (use setToStartOfDay(date) to ensure correct result)
return a.getTime() === b.getTime();
},
extend = function(to, from, overwrite)
{
var prop, hasProp;
for (prop in from) {
hasProp = to[prop] !== undefined;
if (hasProp && typeof from[prop] === 'object' && from[prop].nodeName === undefined) {
if (isDate(from[prop])) {
if (overwrite) {
to[prop] = new Date(from[prop].getTime());
}
}
else if (isArray(from[prop])) {
if (overwrite) {
to[prop] = from[prop].slice(0);
}
} else {
to[prop] = extend({}, from[prop], overwrite);
}
} else if (overwrite || !hasProp) {
to[prop] = from[prop];
}
}
return to;
},
/**
* defaults and localisation
*/
defaults = {
// bind the picker to a form field
field: null,
// automatically show/hide the picker on `field` focus (default `true` if `field` is set)
bound: undefined,
// position of the datepicker, relative to the field (default to bottom & left)
// ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
position: 'bottom left',
// the default output format for `.toString()` and `field` value
format: 'YYYY-MM-DD',
// the initial date to view when first opened
defaultDate: null,
// make the `defaultDate` the initial selected value
setDefaultDate: false,
// first day of week (0: Sunday, 1: Monday etc)
firstDay: 0,
// the minimum/earliest date that can be selected
minDate: null,
// the maximum/latest date that can be selected
maxDate: null,
// number of years either side, or array of upper/lower range
yearRange: 10,
// used internally (don't config outside)
minYear: 0,
maxYear: 9999,
minMonth: undefined,
maxMonth: undefined,
isRTL: false,
// Additional text to append to the year in the calendar title
yearSuffix: '',
// Render the month after year in the calendar title
showMonthAfterYear: false,
// how many months are visible (not implemented yet)
numberOfMonths: 1,
// internationalization
i18n: {
previousMonth : 'Previous Month',
nextMonth : 'Next Month',
months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
},
// callback function
onSelect: null,
onOpen: null,
onClose: null,
onDraw: null
},
/**
* templating functions to abstract HTML rendering
*/
renderDayName = function(opts, day, abbr)
{
day += opts.firstDay;
while (day >= 7) {
day -= 7;
}
return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
},
renderDay = function(i, isSelected, isToday, isDisabled, isEmpty)
{
if (isEmpty) {
return '<td class="is-empty"></td>';
}
var arr = [];
if (isDisabled) {
arr.push('is-disabled');
}
if (isToday) {
arr.push('is-today');
}
if (isSelected) {
arr.push('is-selected');
}
return '<td data-day="' + i + '" class="' + arr.join(' ') + '"><button class="pika-button" type="button">' + i + '</button>' + '</td>';
},
renderRow = function(days, isRTL)
{
return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>';
},
renderBody = function(rows)
{
return '<tbody>' + rows.join('') + '</tbody>';
},
renderHead = function(opts)
{
var i, arr = [];
for (i = 0; i < 7; i++) {
arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
}
return '<thead>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</thead>';
},
renderTitle = function(instance)
{
var i, j, arr,
opts = instance._o,
month = instance._m,
year = instance._y,
isMinYear = year === opts.minYear,
isMaxYear = year === opts.maxYear,
html = '<div class="pika-title">',
monthHtml,
yearHtml,
prev = true,
next = true;
for (arr = [], i = 0; i < 12; i++) {
arr.push('<option value="' + i + '"' +
(i === month ? ' selected': '') +
((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled' : '') + '>' +
opts.i18n.months[i] + '</option>');
}
monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month">' + arr.join('') + '</select></div>';
if (isArray(opts.yearRange)) {
i = opts.yearRange[0];
j = opts.yearRange[1] + 1;
} else {
i = year - opts.yearRange;
j = 1 + year + opts.yearRange;
}
for (arr = []; i < j && i <= opts.maxYear; i++) {
if (i >= opts.minYear) {
arr.push('<option value="' + i + '"' + (i === year ? ' selected': '') + '>' + (i) + '</option>');
}
}
yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year">' + arr.join('') + '</select></div>';
if (opts.showMonthAfterYear) {
html += yearHtml + monthHtml;
} else {
html += monthHtml + yearHtml;
}
if (isMinYear && (month === 0 || opts.minMonth >= month)) {
prev = false;
}
if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
next = false;
}
html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
return html += '</div>';
},
renderTable = function(opts, data)
{
return '<table cellpadding="0" cellspacing="0" class="pika-table">' + renderHead(opts) + renderBody(data) + '</table>';
},
/**
* Pikaday constructor
*/
Pikaday = function(options)
{
var self = this,
opts = self.config(options);
self._onMouseDown = function(e)
{
if (!self._v) {
return;
}
e = e || window.event;
var target = e.target || e.srcElement;
if (!target) {
return;
}
if (!hasClass(target, 'is-disabled')) {
if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty')) {
self.setDate(new Date(self._y, self._m, parseInt(target.innerHTML, 10)));
if (opts.bound) {
sto(function() {
self.hide();
}, 100);
}
return;
}
else if (hasClass(target, 'pika-prev')) {
self.prevMonth();
}
else if (hasClass(target, 'pika-next')) {
self.nextMonth();
}
}
if (!hasClass(target, 'pika-select')) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
return false;
}
} else {
self._c = true;
}
};
self._onChange = function(e)
{
e = e || window.event;
var target = e.target || e.srcElement;
if (!target) {
return;
}
if (hasClass(target, 'pika-select-month')) {
self.gotoMonth(target.value);
}
else if (hasClass(target, 'pika-select-year')) {
self.gotoYear(target.value);
}
};
self._onInputChange = function(e)
{
var date;
if (e.firedBy === self) {
return;
}
if (hasMoment) {
date = moment(opts.field.value, opts.format);
date = (date && date.isValid()) ? date.toDate() : null;
}
else {
date = new Date(Date.parse(opts.field.value));
}
self.setDate(isDate(date) ? date : null);
if (!self._v) {
self.show();
}
};
self._onInputFocus = function()
{
self.show();
};
self._onInputClick = function()
{
self.show();
};
self._onInputBlur = function()
{
if (!self._c) {
self._b = sto(function() {
self.hide();
}, 50);
}
self._c = false;
};
self._onClick = function(e)
{
e = e || window.event;
var target = e.target || e.srcElement,
pEl = target;
if (!target) {
return;
}
if (!hasEventListeners && hasClass(target, 'pika-select')) {
if (!target.onchange) {
target.setAttribute('onchange', 'return;');
addEvent(target, 'change', self._onChange);
}
}
do {
if (hasClass(pEl, 'pika-single')) {
return;
}
}
while ((pEl = pEl.parentNode));
if (self._v && target !== opts.trigger) {
self.hide();
}
};
self.el = document.createElement('div');
self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '');
addEvent(self.el, 'mousedown', self._onMouseDown, true);
addEvent(self.el, 'change', self._onChange);
if (opts.field) {
if (opts.bound) {
document.body.appendChild(self.el);
} else {
opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
}
addEvent(opts.field, 'change', self._onInputChange);
if (!opts.defaultDate) {
if (hasMoment && opts.field.value) {
opts.defaultDate = moment(opts.field.value, opts.format).toDate();
} else {
opts.defaultDate = new Date(Date.parse(opts.field.value));
}
opts.setDefaultDate = true;
}
}
var defDate = opts.defaultDate;
if (isDate(defDate)) {
if (opts.setDefaultDate) {
self.setDate(defDate, true);
} else {
self.gotoDate(defDate);
}
} else {
self.gotoDate(new Date());
}
if (opts.bound) {
this.hide();
self.el.className += ' is-bound';
addEvent(opts.trigger, 'click', self._onInputClick);
addEvent(opts.trigger, 'focus', self._onInputFocus);
addEvent(opts.trigger, 'blur', self._onInputBlur);
} else {
this.show();
}
};
/**
* public Pikaday API
*/
Pikaday.prototype = {
/**
* configure functionality
*/
config: function(options)
{
if (!this._o) {
this._o = extend({}, defaults, true);
}
var opts = extend(this._o, options, true);
opts.isRTL = !!opts.isRTL;
opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
var nom = parseInt(opts.numberOfMonths, 10) || 1;
opts.numberOfMonths = nom > 4 ? 4 : nom;
if (!isDate(opts.minDate)) {
opts.minDate = false;
}
if (!isDate(opts.maxDate)) {
opts.maxDate = false;
}
if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
opts.maxDate = opts.minDate = false;
}
if (opts.minDate) {
setToStartOfDay(opts.minDate);
opts.minYear = opts.minDate.getFullYear();
opts.minMonth = opts.minDate.getMonth();
}
if (opts.maxDate) {
setToStartOfDay(opts.maxDate);
opts.maxYear = opts.maxDate.getFullYear();
opts.maxMonth = opts.maxDate.getMonth();
}
if (isArray(opts.yearRange)) {
var fallback = new Date().getFullYear() - 10;
opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
} else {
opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
if (opts.yearRange > 100) {
opts.yearRange = 100;
}
}
return opts;
},
/**
* return a formatted string of the current selection (using Moment.js if available)
*/
toString: function(format)
{
return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString();
},
/**
* return a Moment.js object of the current selection (if available)
*/
getMoment: function()
{
return hasMoment ? moment(this._d) : null;
},
/**
* set the current selection from a Moment.js object (if available)
*/
setMoment: function(date, preventOnSelect)
{
if (hasMoment && moment.isMoment(date)) {
this.setDate(date.toDate(), preventOnSelect);
}
},
/**
* return a Date object of the current selection
*/
getDate: function()
{
return isDate(this._d) ? new Date(this._d.getTime()) : null;
},
/**
* set the current selection
*/
setDate: function(date, preventOnSelect)
{
if (!date) {
this._d = null;
return this.draw();
}
if (typeof date === 'string') {
date = new Date(Date.parse(date));
}
if (!isDate(date)) {
return;
}
var min = this._o.minDate,
max = this._o.maxDate;
if (isDate(min) && date < min) {
date = min;
} else if (isDate(max) && date > max) {
date = max;
}
this._d = new Date(date.getTime());
setToStartOfDay(this._d);
this.gotoDate(this._d);
if (this._o.field) {
this._o.field.value = this.toString();
fireEvent(this._o.field, 'change', { firedBy: this });
}
if (!preventOnSelect && typeof this._o.onSelect === 'function') {
this._o.onSelect.call(this, this.getDate());
}
},
/**
* change view to a specific date
*/
gotoDate: function(date)
{
if (!isDate(date)) {
return;
}
this._y = date.getFullYear();
this._m = date.getMonth();
this.draw();
},
gotoToday: function()
{
this.gotoDate(new Date());
},
/**
* change view to a specific month (zero-index, e.g. 0: January)
*/
gotoMonth: function(month)
{
if (!isNaN( (month = parseInt(month, 10)) )) {
this._m = month < 0 ? 0 : month > 11 ? 11 : month;
this.draw();
}
},
nextMonth: function()
{
if (++this._m > 11) {
this._m = 0;
this._y++;
}
this.draw();
},
prevMonth: function()
{
if (--this._m < 0) {
this._m = 11;
this._y--;
}
this.draw();
},
/**
* change view to a specific full year (e.g. "2012")
*/
gotoYear: function(year)
{
if (!isNaN(year)) {
this._y = parseInt(year, 10);
this.draw();
}
},
/**
* change the minDate
*/
setMinDate: function(value)
{
this._o.minDate = value;
},
/**
* change the maxDate
*/
setMaxDate: function(value)
{
this._o.maxDate = value;
},
/**
* refresh the HTML
*/
draw: function(force)
{
if (!this._v && !force) {
return;
}
var opts = this._o,
minYear = opts.minYear,
maxYear = opts.maxYear,
minMonth = opts.minMonth,
maxMonth = opts.maxMonth;
if (this._y <= minYear) {
this._y = minYear;
if (!isNaN(minMonth) && this._m < minMonth) {
this._m = minMonth;
}
}
if (this._y >= maxYear) {
this._y = maxYear;
if (!isNaN(maxMonth) && this._m > maxMonth) {
this._m = maxMonth;
}
}
this.el.innerHTML = renderTitle(this) + this.render(this._y, this._m);
if (opts.bound) {
this.adjustPosition();
if(opts.field.type !== 'hidden') {
sto(function() {
opts.trigger.focus();
}, 1);
}
}
if (typeof this._o.onDraw === 'function') {
var self = this;
sto(function() {
self._o.onDraw.call(self);
}, 0);
}
},
adjustPosition: function()
{
var field = this._o.trigger, pEl = field,
width = this.el.offsetWidth, height = this.el.offsetHeight,
viewportWidth = window.innerWidth || document.documentElement.clientWidth,
viewportHeight = window.innerHeight || document.documentElement.clientHeight,
scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop,
left, top, clientRect;
if (typeof field.getBoundingClientRect === 'function') {
clientRect = field.getBoundingClientRect();
left = clientRect.left + window.pageXOffset;
top = clientRect.bottom + window.pageYOffset;
} else {
left = pEl.offsetLeft;
top = pEl.offsetTop + pEl.offsetHeight;
while((pEl = pEl.offsetParent)) {
left += pEl.offsetLeft;
top += pEl.offsetTop;
}
}
// default position is bottom & left
if (left + width > viewportWidth ||
(
this._o.position.indexOf('right') > -1 &&
left - width + field.offsetWidth > 0
)
) {
left = left - width + field.offsetWidth;
}
if (top + height > viewportHeight + scrollTop ||
(
this._o.position.indexOf('top') > -1 &&
top - height - field.offsetHeight > 0
)
) {
top = top - height - field.offsetHeight;
}
this.el.style.cssText = [
'position: absolute',
'left: ' + left + 'px',
'top: ' + top + 'px'
].join(';');
},
/**
* render HTML for a particular month
*/
render: function(year, month)
{
var opts = this._o,
now = new Date(),
days = getDaysInMonth(year, month),
before = new Date(year, month, 1).getDay(),
data = [],
row = [];
setToStartOfDay(now);
if (opts.firstDay > 0) {
before -= opts.firstDay;
if (before < 0) {
before += 7;
}
}
var cells = days + before,
after = cells;
while(after > 7) {
after -= 7;
}
cells += 7 - after;
for (var i = 0, r = 0; i < cells; i++)
{
var day = new Date(year, month, 1 + (i - before)),
isDisabled = (opts.minDate && day < opts.minDate) || (opts.maxDate && day > opts.maxDate),
isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
isToday = compareDates(day, now),
isEmpty = i < before || i >= (days + before);
row.push(renderDay(1 + (i - before), isSelected, isToday, isDisabled, isEmpty));
if (++r === 7) {
data.push(renderRow(row, opts.isRTL));
row = [];
r = 0;
}
}
return renderTable(opts, data);
},
isVisible: function()
{
return this._v;
},
show: function()
{
if (!this._v) {
if (this._o.bound) {
addEvent(document, 'click', this._onClick);
}
removeClass(this.el, 'is-hidden');
this._v = true;
this.draw();
if (typeof this._o.onOpen === 'function') {
this._o.onOpen.call(this);
}
}
},
hide: function()
{
var v = this._v;
if (v !== false) {
if (this._o.bound) {
removeEvent(document, 'click', this._onClick);
}
this.el.style.cssText = '';
addClass(this.el, 'is-hidden');
this._v = false;
if (v !== undefined && typeof this._o.onClose === 'function') {
this._o.onClose.call(this);
}
}
},
/**
* GAME OVER
*/
destroy: function()
{
this.hide();
removeEvent(this.el, 'mousedown', this._onMouseDown, true);
removeEvent(this.el, 'change', this._onChange);
if (this._o.field) {
removeEvent(this._o.field, 'change', this._onInputChange);
if (this._o.bound) {
removeEvent(this._o.trigger, 'click', this._onInputClick);
removeEvent(this._o.trigger, 'focus', this._onInputFocus);
removeEvent(this._o.trigger, 'blur', this._onInputBlur);
}
}
if (this.el.parentNode) {
this.el.parentNode.removeChild(this.el);
}
}
};
return Pikaday;
}));
/*!
* Pikaday jQuery plugin.
*
* Copyright © 2013 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
*/
(function (root, factory)
{
'use strict';
if (typeof exports === 'object') {
// CommonJS module
factory(require('jquery'), require('../pikaday'));
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'pikaday'], factory);
} else {
// Browser globals
factory(root.jQuery, root.Pikaday);
}
}(this, function ($, Pikaday)
{
'use strict';
$.fn.pikaday = function()
{
var args = arguments;
if (!args || !args.length) {
args = [{ }];
}
return this.each(function()
{
var self = $(this),
plugin = self.data('pikaday');
if (!(plugin instanceof Pikaday)) {
if (typeof args[0] === 'object') {
var options = $.extend({}, args[0]);
options.field = self[0];
self.data('pikaday', new Pikaday(options));
}
} else {
if (typeof args[0] === 'string' && typeof plugin[args[0]] === 'function') {
plugin[args[0]].apply(plugin, Array.prototype.slice.call(args,1));
}
}
});
};
}));

View File

@@ -0,0 +1,200 @@
body {
background: #015;
color: #bbb;
font-family: helvetica, arial, sans-serif;
font-size: 15px;
line-height: 1.3;
margin: 0;
padding: 0;
}
header,
section,
footer {
padding: 20px;
}
header,
footer {
background: #111;
color: #666;
position: relative;
}
header h1 {
margin: 0;
padding: 0;
}
header h1 a {
font-family: Lucida Sans Unicode, Lucida Grande, sans-serif;
font-size: 60px;
font-weight: 200;
text-decoration: none;
}
header p {
font-size: 23px;
}
#header-links {
margin: 0;
padding: 0;
list-style: none;
position: absolute;
right: 20px;
top: 30px;
text-align: right;
}
#header-links a {
color: #888;
}
#header-links a:hover {
color: #06c;
}
h2 {
color: #eee;
font-size: 35px;
font-weight: normal;
margin: 0;
line-height: 1.1
}
p {
margin: 20px 0 0 0;
}
p:first-child {
margin-top: 0;
}
input {
font-size: 13px;
-webkit-border-radius: 3px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 3px;
background: #dde;
border: 1px solid #aac;
}
input.time {
width: 80px;
}
input.date {
width: 90px;
}
a {
color: #06c;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
image {
border: 0;
}
#examples article {
padding-top: 100px;
clear: both;
}
#examples article:first-child {
padding-top: 0;
}
#examples .demo {
width: 450px;
float: left;
}
#examples .code {
font-size: 12px;
margin: 0 0 0 470px;
}
footer {
font-size: 12px;
}
div.ui-datepicker { font-size: 11px; }
#alternateUiWidgetsExample .date { width: 120px; }
/**
* Blackboard theme
*
* Adapted from Domenico Carbotta's TextMate theme of the same name
*
* @author Domenico Carbotta
* @author Craig Campbell
* @version 1.0.2
*/
pre {
background: #0B1022;
word-wrap: break-word;
margin: 0px;
padding: 0px;
padding: 10px;
color: #fff;
font-size: 12px;
margin: 0;
overflow-y: auto;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
pre, code {
font-family: Consolas, 'Monaco', courier, monospace;
}
pre .comment {
color: #727272;
}
pre .constant {
color: #D8FA3C;
}
pre .storage {
color: #FBDE2D;
}
pre .string, pre .comment.docstring {
color: #61CE3C;
}
pre .string.regexp, pre .support.tag.script, pre .support.tag.style {
color: #fff;
}
pre .keyword, pre .selector {
color: #FBDE2D;
}
pre .inherited-class {
font-style: italic;
}
pre .entity {
color: #FF6400;
}
pre .support, *[data-language="c"] .function.call {
color: #8DA6CE;
}
pre .variable.global, pre .variable.class, pre .variable.instance {
color: #FF6400;
}

View File

@@ -0,0 +1,10 @@
/* Rainbow v1.1.8 rainbowco.de | included languages: generic, javascript */
window.Rainbow=function(){function q(a){var b,c=a.getAttribute&&a.getAttribute("data-language")||0;if(!c){a=a.attributes;for(b=0;b<a.length;++b)if("data-language"===a[b].nodeName)return a[b].nodeValue}return c}function B(a){var b=q(a)||q(a.parentNode);if(!b){var c=/\blang(?:uage)?-(\w+)/;(a=a.className.match(c)||a.parentNode.className.match(c))&&(b=a[1])}return b}function C(a,b){for(var c in e[d]){c=parseInt(c,10);if(a==c&&b==e[d][c]?0:a<=c&&b>=e[d][c])delete e[d][c],delete j[d][c];if(a>=c&&a<e[d][c]||
b>c&&b<e[d][c])return!0}return!1}function r(a,b){return'<span class="'+a.replace(/\./g," ")+(l?" "+l:"")+'">'+b+"</span>"}function s(a,b,c,h){var f=a.exec(c);if(f){++t;!b.name&&"string"==typeof b.matches[0]&&(b.name=b.matches[0],delete b.matches[0]);var k=f[0],i=f.index,u=f[0].length+i,g=function(){function f(){s(a,b,c,h)}t%100>0?f():setTimeout(f,0)};if(C(i,u))g();else{var m=v(b.matches),l=function(a,c,h){if(a>=c.length)h(k);else{var d=f[c[a]];if(d){var e=b.matches[c[a]],i=e.language,g=e.name&&e.matches?
e.matches:e,j=function(b,d,e){var i;i=0;var g;for(g=1;g<c[a];++g)f[g]&&(i=i+f[g].length);d=e?r(e,d):d;k=k.substr(0,i)+k.substr(i).replace(b,d);l(++a,c,h)};i?n(d,i,function(a){j(d,a)}):typeof e==="string"?j(d,d,e):w(d,g.length?g:[g],function(a){j(d,a,e.matches?e.name:0)})}else l(++a,c,h)}};l(0,m,function(a){b.name&&(a=r(b.name,a));if(!j[d]){j[d]={};e[d]={}}j[d][i]={replace:f[0],"with":a};e[d][i]=u;g()})}}else h()}function v(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b.sort(function(a,
b){return b-a})}function w(a,b,c){function h(b,k){k<b.length?s(b[k].pattern,b[k],a,function(){h(b,++k)}):D(a,function(a){delete j[d];delete e[d];--d;c(a)})}++d;h(b,0)}function D(a,b){function c(a,b,h,e){if(h<b.length){++x;var g=b[h],l=j[d][g],a=a.substr(0,g)+a.substr(g).replace(l.replace,l["with"]),g=function(){c(a,b,++h,e)};0<x%250?g():setTimeout(g,0)}else e(a)}var h=v(j[d]);c(a,h,0,b)}function n(a,b,c){var d=m[b]||[],f=m[y]||[],b=z[b]?d:d.concat(f);w(a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/&(?![\w\#]+;)/g,
"&amp;"),b,c)}function o(a,b,c){if(b<a.length){var d=a[b],f=B(d);return!(-1<(" "+d.className+" ").indexOf(" rainbow "))&&f?(f=f.toLowerCase(),d.className+=d.className?" rainbow":"rainbow",n(d.innerHTML,f,function(k){d.innerHTML=k;j={};e={};p&&p(d,f);setTimeout(function(){o(a,++b,c)},0)})):o(a,++b,c)}c&&c()}function A(a,b){var a=a&&"function"==typeof a.getElementsByTagName?a:document,c=a.getElementsByTagName("pre"),d=a.getElementsByTagName("code"),f,e=[];for(f=0;f<d.length;++f)e.push(d[f]);for(f=0;f<
c.length;++f)c[f].getElementsByTagName("code").length||e.push(c[f]);o(e,0,b)}var j={},e={},m={},z={},d=0,y=0,t=0,x=0,l,p;return{extend:function(a,b,c){1==arguments.length&&(b=a,a=y);z[a]=c;m[a]=b.concat(m[a]||[])},b:function(a){p=a},a:function(a){l=a},color:function(a,b,c){if("string"==typeof a)return n(a,b,c);if("function"==typeof a)return A(0,a);A(a,b)}}}();window.addEventListener?window.addEventListener("load",Rainbow.color,!1):window.attachEvent("onload",Rainbow.color);Rainbow.onHighlight=Rainbow.b;
Rainbow.addClass=Rainbow.a;Rainbow.extend([{matches:{1:{name:"keyword.operator",pattern:/\=/g},2:{name:"string",matches:{name:"constant.character.escape",pattern:/\\('|"){1}/g}}},pattern:/(\(|\s|\[|\=|:)(('|")([^\\\1]|\\.)*?(\3))/gm},{name:"comment",pattern:/\/\*[\s\S]*?\*\/|(\/\/|\#)[\s\S]*?$/gm},{name:"constant.numeric",pattern:/\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi},{matches:{1:"keyword"},pattern:/\b(and|array|as|bool(ean)?|c(atch|har|lass|onst)|d(ef|elete|o(uble)?)|e(cho|lse(if)?|xit|xtends|xcept)|f(inally|loat|or(each)?|unction)|global|if|import|int(eger)?|long|new|object|or|pr(int|ivate|otected)|public|return|self|st(ring|ruct|atic)|switch|th(en|is|row)|try|(un)?signed|var|void|while)(?=\(|\b)/gi},
{name:"constant.language",pattern:/true|false|null/g},{name:"keyword.operator",pattern:/\+|\!|\-|&(gt|lt|amp);|\||\*|\=/g},{matches:{1:"function.call"},pattern:/(\w+?)(?=\()/g},{matches:{1:"storage.function",2:"entity.name.function"},pattern:/(function)\s(.*?)(?=\()/g}]);Rainbow.extend("javascript",[{name:"selector",pattern:/(\s|^)\$(?=\.|\()/g},{name:"support",pattern:/\b(window|document)\b/g},{matches:{1:"support.property"},pattern:/\.(length|node(Name|Value))\b/g},{matches:{1:"support.function"},pattern:/(setTimeout|setInterval)(?=\()/g},{matches:{1:"support.method"},pattern:/\.(getAttribute|push|getElementById|getElementsByClassName|log|setTimeout|setInterval)(?=\()/g},{matches:{1:"support.tag.script",2:[{name:"string",pattern:/('|")(.*?)(\1)/g},{name:"entity.tag.script",
pattern:/(\w+)/g}],3:"support.tag.script"},pattern:/(&lt;\/?)(script.*?)(&gt;)/g},{name:"string.regexp",matches:{1:"string.regexp.open",2:{name:"constant.regexp.escape",pattern:/\\(.){1}/g},3:"string.regexp.close",4:"string.regexp.modifier"},pattern:/(\/)(?!\*)(.+)(\/)([igm]{0,3})/g},{matches:{1:"storage",3:"entity.function"},pattern:/(var)?(\s|^)(.*)(?=\s?=\s?function\()/g},{name:"entity.function",pattern:/(\w+)(?=:\s{0,}function)/g}]);

View File

@@ -0,0 +1,24 @@
{
"name": "datepair.js",
"description": "A javascript plugin for intelligently selecting date and time ranges inspired by Google Calendar.",
"homepage": "http://jonthornton.github.com/Datepair.js",
"version": "0.4.17",
"main": "dist/datepair.js",
"author": {
"name": "Jon Thornton",
"url": "https://github.com/jonthornton"
},
"repository": {
"type" : "git",
"url" : "https://github.com/jonthornton/Datepair.js.git"
},
"license": "MIT",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.4.0",
"grunt-rigger": "~0.5.0",
"grunt-contrib-jshint": "^0.11.3",
"grunt-contrib-watch": "~0.5.1"
},
"keywords": [ "timepicker", "datepicker", "time", "date", "picker", "ui", "calendar", "input", "form" ]
}