furatto 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/furatto.gemspec +21 -0
- data/lib/furatto.rb +16 -0
- data/lib/furatto/engine.rb +6 -0
- data/lib/furatto/version.rb +3 -0
- data/vendor/assets/fonts/fontawesome/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.svg +399 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/meteocons-webfont.eot +0 -0
- data/vendor/assets/fonts/meteocons-webfont.svg +81 -0
- data/vendor/assets/fonts/meteocons-webfont.ttf +0 -0
- data/vendor/assets/fonts/meteocons-webfont.woff +0 -0
- data/vendor/assets/images/icheck/aero.png +0 -0
- data/vendor/assets/images/icheck/aero@2x.png +0 -0
- data/vendor/assets/images/icheck/blue.png +0 -0
- data/vendor/assets/images/icheck/blue@2x.png +0 -0
- data/vendor/assets/images/icheck/flat.png +0 -0
- data/vendor/assets/images/icheck/flat@2x.png +0 -0
- data/vendor/assets/images/icheck/green.png +0 -0
- data/vendor/assets/images/icheck/green@2x.png +0 -0
- data/vendor/assets/images/icheck/grey.png +0 -0
- data/vendor/assets/images/icheck/grey@2x.png +0 -0
- data/vendor/assets/images/icheck/orange.png +0 -0
- data/vendor/assets/images/icheck/orange@2x.png +0 -0
- data/vendor/assets/images/icheck/pink.png +0 -0
- data/vendor/assets/images/icheck/pink@2x.png +0 -0
- data/vendor/assets/images/icheck/purple.png +0 -0
- data/vendor/assets/images/icheck/purple@2x.png +0 -0
- data/vendor/assets/images/icheck/red.png +0 -0
- data/vendor/assets/images/icheck/red@2x.png +0 -0
- data/vendor/assets/images/icheck/yellow.png +0 -0
- data/vendor/assets/images/icheck/yellow@2x.png +0 -0
- data/vendor/assets/images/icons/customize-icon150.png +0 -0
- data/vendor/assets/images/icons/flexible-icon.png +0 -0
- data/vendor/assets/images/icons/github-128-black.png +0 -0
- data/vendor/assets/images/icons/iphone-icon150.png +0 -0
- data/vendor/assets/images/icons/lock-icon128.png +0 -0
- data/vendor/assets/images/icons/rocket-icon128.png +0 -0
- data/vendor/assets/images/icons/rocket-icon150.png +0 -0
- data/vendor/assets/images/icons/screen-icon.png +0 -0
- data/vendor/assets/images/icons/screens-icon.png +0 -0
- data/vendor/assets/images/icons/screens2-icon.png +0 -0
- data/vendor/assets/images/next.png +0 -0
- data/vendor/assets/images/previous.png +0 -0
- data/vendor/assets/images/themes.gif +0 -0
- data/vendor/assets/images/toggle.png +0 -0
- data/vendor/assets/javascripts/dropdown.js +169 -0
- data/vendor/assets/javascripts/furatto.js +15 -0
- data/vendor/assets/javascripts/jpanel.js +547 -0
- data/vendor/assets/javascripts/jquery.avgrund.js +127 -0
- data/vendor/assets/javascripts/jquery.dropkick-1.0.0.js +400 -0
- data/vendor/assets/javascripts/jquery.icheck.js +462 -0
- data/vendor/assets/javascripts/jquery.tagsinput.js +354 -0
- data/vendor/assets/javascripts/jquery.toolbar.js +242 -0
- data/vendor/assets/javascripts/legacy.js +140 -0
- data/vendor/assets/javascripts/picker.date.js +957 -0
- data/vendor/assets/javascripts/picker.js +785 -0
- data/vendor/assets/javascripts/picker.time.js +651 -0
- data/vendor/assets/javascripts/rainbow-custom.min.js +13 -0
- data/vendor/assets/javascripts/responsive-tables.js +67 -0
- data/vendor/assets/javascripts/responsiveslides.js +391 -0
- data/vendor/assets/javascripts/tooltip.js +353 -0
- data/vendor/assets/stylesheets/furatto.scss +101 -0
- data/vendor/assets/stylesheets/furatto/_alerts.scss +81 -0
- data/vendor/assets/stylesheets/furatto/_base.scss +187 -0
- data/vendor/assets/stylesheets/furatto/_buttons.scss +100 -0
- data/vendor/assets/stylesheets/furatto/_code.scss +66 -0
- data/vendor/assets/stylesheets/furatto/_date_picker.date.scss +266 -0
- data/vendor/assets/stylesheets/furatto/_date_picker.scss +158 -0
- data/vendor/assets/stylesheets/furatto/_date_picker.time.scss +122 -0
- data/vendor/assets/stylesheets/furatto/_dropdown.scss +261 -0
- data/vendor/assets/stylesheets/furatto/_font-awesome-ie7.scss +1953 -0
- data/vendor/assets/stylesheets/furatto/_fonts.scss +614 -0
- data/vendor/assets/stylesheets/furatto/_footer.scss +44 -0
- data/vendor/assets/stylesheets/furatto/_forms.scss +290 -0
- data/vendor/assets/stylesheets/furatto/_grid.scss +56 -0
- data/vendor/assets/stylesheets/furatto/_images.scss +44 -0
- data/vendor/assets/stylesheets/furatto/_labels.scss +43 -0
- data/vendor/assets/stylesheets/furatto/_layout.scss +0 -0
- data/vendor/assets/stylesheets/furatto/_left_navbar.scss +100 -0
- data/vendor/assets/stylesheets/furatto/_mixins.scss +283 -0
- data/vendor/assets/stylesheets/furatto/_modal.scss +103 -0
- data/vendor/assets/stylesheets/furatto/_nav.scss +106 -0
- data/vendor/assets/stylesheets/furatto/_navbar.scss +187 -0
- data/vendor/assets/stylesheets/furatto/_pagination.scss +158 -0
- data/vendor/assets/stylesheets/furatto/_responsive-1200px-min.scss +21 -0
- data/vendor/assets/stylesheets/furatto/_responsive-767px-max.scss +82 -0
- data/vendor/assets/stylesheets/furatto/_responsive-768px-979px.scss +23 -0
- data/vendor/assets/stylesheets/furatto/_responsive_navbar.scss +184 -0
- data/vendor/assets/stylesheets/furatto/_responsive_tables.scss +28 -0
- data/vendor/assets/stylesheets/furatto/_responsiveslides.scss +202 -0
- data/vendor/assets/stylesheets/furatto/_select.scss +191 -0
- data/vendor/assets/stylesheets/furatto/_tables.scss +90 -0
- data/vendor/assets/stylesheets/furatto/_tags.scss +107 -0
- data/vendor/assets/stylesheets/furatto/_toolbars.scss +116 -0
- data/vendor/assets/stylesheets/furatto/_tooltips.scss +143 -0
- data/vendor/assets/stylesheets/furatto/_typography.scss +266 -0
- data/vendor/assets/stylesheets/furatto/_variables.scss +628 -0
- data/vendor/assets/stylesheets/furatto/_vrt_navbar.scss +61 -0
- data/vendor/assets/stylesheets/furatto/icheck/_aero.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_all.scss +20 -0
- data/vendor/assets/stylesheets/furatto/icheck/_blue.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_flat.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_green.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_grey.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_orange.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_pink.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_purple.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_red.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_yellow.scss +64 -0
- data/vendor/assets/stylesheets/normalize.scss +403 -0
- metadata +162 -0
@@ -0,0 +1,140 @@
|
|
1
|
+
|
2
|
+
/*jshint
|
3
|
+
asi: true,
|
4
|
+
unused: true,
|
5
|
+
boss: true,
|
6
|
+
loopfunc: true,
|
7
|
+
eqnull: true
|
8
|
+
*/
|
9
|
+
|
10
|
+
|
11
|
+
/*!
|
12
|
+
* Legacy browser support
|
13
|
+
*/
|
14
|
+
|
15
|
+
// isArray support
|
16
|
+
if ( !Array.isArray ) {
|
17
|
+
Array.isArray = function( value ) {
|
18
|
+
return {}.toString.call( value ) == '[object Array]'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
// Map array support
|
24
|
+
if ( ![].map ) {
|
25
|
+
Array.prototype.map = function ( callback, self ) {
|
26
|
+
var array = this, len = array.length, newArray = new Array( len )
|
27
|
+
for ( var i = 0; i < len; i++ ) {
|
28
|
+
if ( i in array ) {
|
29
|
+
newArray[ i ] = callback.call( self, array[ i ], i, array )
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return newArray
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
// Filter array support
|
38
|
+
if ( ![].filter ) {
|
39
|
+
Array.prototype.filter = function( callback ) {
|
40
|
+
if ( this == null ) throw new TypeError()
|
41
|
+
var t = Object( this ), len = t.length >>> 0
|
42
|
+
if ( typeof callback != 'function' ) throw new TypeError()
|
43
|
+
var newArray = [], thisp = arguments[ 1 ]
|
44
|
+
for ( var i = 0; i < len; i++ ) {
|
45
|
+
if ( i in t ) {
|
46
|
+
var val = t[ i ]
|
47
|
+
if ( callback.call( thisp, val, i, t ) ) newArray.push( val )
|
48
|
+
}
|
49
|
+
}
|
50
|
+
return newArray
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
|
55
|
+
// Index of array support
|
56
|
+
if ( ![].indexOf ) {
|
57
|
+
Array.prototype.indexOf = function( searchElement ) {
|
58
|
+
if ( this == null ) throw new TypeError()
|
59
|
+
var t = Object( this ), len = t.length >>> 0
|
60
|
+
if ( len === 0 ) return -1
|
61
|
+
var n = 0
|
62
|
+
if ( arguments.length > 1 ) {
|
63
|
+
n = Number( arguments[ 1 ] )
|
64
|
+
if ( n != n ) {
|
65
|
+
n = 0
|
66
|
+
}
|
67
|
+
else if ( n !== 0 && n != Infinity && n != -Infinity ) {
|
68
|
+
n = ( n > 0 || -1 ) * Math.floor( Math.abs( n ) )
|
69
|
+
}
|
70
|
+
}
|
71
|
+
if ( n >= len ) return -1
|
72
|
+
var k = n >= 0 ? n : Math.max( len - Math.abs( n ), 0 )
|
73
|
+
for ( ; k < len; k++ ) {
|
74
|
+
if ( k in t && t[ k ] === searchElement ) return k
|
75
|
+
}
|
76
|
+
return -1
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
/*!
|
82
|
+
* Cross-Browser Split 1.1.1
|
83
|
+
* Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
|
84
|
+
* Available under the MIT License
|
85
|
+
* http://blog.stevenlevithan.com/archives/cross-browser-split
|
86
|
+
*/
|
87
|
+
var nativeSplit = String.prototype.split, compliantExecNpcg = /()??/.exec('')[1] === undefined
|
88
|
+
String.prototype.split = function(separator, limit) {
|
89
|
+
var str = this
|
90
|
+
if (Object.prototype.toString.call(separator) !== '[object RegExp]') {
|
91
|
+
return nativeSplit.call(str, separator, limit)
|
92
|
+
}
|
93
|
+
var output = [],
|
94
|
+
flags = (separator.ignoreCase ? 'i' : '') +
|
95
|
+
(separator.multiline ? 'm' : '') +
|
96
|
+
(separator.extended ? 'x' : '') +
|
97
|
+
(separator.sticky ? 'y' : ''),
|
98
|
+
lastLastIndex = 0,
|
99
|
+
separator2, match, lastIndex, lastLength
|
100
|
+
separator = new RegExp(separator.source, flags + 'g')
|
101
|
+
str += ''
|
102
|
+
if (!compliantExecNpcg) {
|
103
|
+
separator2 = new RegExp('^' + separator.source + '$(?!\\s)', flags)
|
104
|
+
}
|
105
|
+
limit = limit === undefined ? -1 >>> 0 : limit >>> 0
|
106
|
+
while (match = separator.exec(str)) {
|
107
|
+
lastIndex = match.index + match[0].length
|
108
|
+
if (lastIndex > lastLastIndex) {
|
109
|
+
output.push(str.slice(lastLastIndex, match.index))
|
110
|
+
if (!compliantExecNpcg && match.length > 1) {
|
111
|
+
match[0].replace(separator2, function () {
|
112
|
+
for (var i = 1; i < arguments.length - 2; i++) {
|
113
|
+
if (arguments[i] === undefined) {
|
114
|
+
match[i] = undefined
|
115
|
+
}
|
116
|
+
}
|
117
|
+
})
|
118
|
+
}
|
119
|
+
if (match.length > 1 && match.index < str.length) {
|
120
|
+
Array.prototype.push.apply(output, match.slice(1))
|
121
|
+
}
|
122
|
+
lastLength = match[0].length
|
123
|
+
lastLastIndex = lastIndex
|
124
|
+
if (output.length >= limit) {
|
125
|
+
break
|
126
|
+
}
|
127
|
+
}
|
128
|
+
if (separator.lastIndex === match.index) {
|
129
|
+
separator.lastIndex++
|
130
|
+
}
|
131
|
+
}
|
132
|
+
if (lastLastIndex === str.length) {
|
133
|
+
if (lastLength || !separator.test('')) {
|
134
|
+
output.push('')
|
135
|
+
}
|
136
|
+
} else {
|
137
|
+
output.push(str.slice(lastLastIndex))
|
138
|
+
}
|
139
|
+
return output.length > limit ? output.slice(0, limit) : output
|
140
|
+
}
|
@@ -0,0 +1,957 @@
|
|
1
|
+
|
2
|
+
/*!
|
3
|
+
* Date picker for pickadate.js v3.1.1
|
4
|
+
* http://amsul.github.io/pickadate.js/date.htm
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*jshint
|
8
|
+
debug: true,
|
9
|
+
devel: true,
|
10
|
+
browser: true,
|
11
|
+
asi: true,
|
12
|
+
unused: true,
|
13
|
+
boss: true
|
14
|
+
*/
|
15
|
+
|
16
|
+
|
17
|
+
// Create a new scope.
|
18
|
+
(function() {
|
19
|
+
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Globals and constants
|
23
|
+
*/
|
24
|
+
var DAYS_IN_WEEK = 7,
|
25
|
+
WEEKS_IN_CALENDAR = 6
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
/**
|
30
|
+
* The date picker constructor
|
31
|
+
*/
|
32
|
+
function DatePicker( picker, settings ) {
|
33
|
+
|
34
|
+
var calendar = this,
|
35
|
+
elementValue = picker.$node[ 0 ].value,
|
36
|
+
elementDataValue = picker.$node.data( 'value' ),
|
37
|
+
valueString = elementDataValue || elementValue,
|
38
|
+
formatString = elementDataValue ? settings.formatSubmit : settings.format
|
39
|
+
|
40
|
+
calendar.settings = settings
|
41
|
+
|
42
|
+
// The queue of methods that will be used to build item objects.
|
43
|
+
calendar.queue = {
|
44
|
+
min: 'measure create',
|
45
|
+
max: 'measure create',
|
46
|
+
now: 'now create',
|
47
|
+
select: 'parse create validate',
|
48
|
+
highlight: 'navigate create validate',
|
49
|
+
view: 'create validate viewset',
|
50
|
+
disable: 'flipItem',
|
51
|
+
enable: 'flipItem'
|
52
|
+
}
|
53
|
+
|
54
|
+
// The component's item object.
|
55
|
+
calendar.item = {}
|
56
|
+
|
57
|
+
calendar.item.disable = ( settings.disable || [] ).slice( 0 )
|
58
|
+
calendar.item.enable = -(function( collectionDisabled ) {
|
59
|
+
return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1
|
60
|
+
})( calendar.item.disable )
|
61
|
+
|
62
|
+
calendar.
|
63
|
+
set( 'min', settings.min ).
|
64
|
+
set( 'max', settings.max ).
|
65
|
+
set( 'now' ).
|
66
|
+
|
67
|
+
// Setting the `select` also sets the `highlight` and `view`.
|
68
|
+
set( 'select',
|
69
|
+
|
70
|
+
// Use the value provided or default to selecting “today”.
|
71
|
+
valueString || calendar.item.now,
|
72
|
+
{
|
73
|
+
// Use the appropriate format.
|
74
|
+
format: formatString,
|
75
|
+
|
76
|
+
// Set user-provided month data as true when there is a
|
77
|
+
// “mm” or “m” used in the relative format string.
|
78
|
+
data: (function( formatArray ) {
|
79
|
+
return valueString && ( formatArray.indexOf( 'mm' ) > -1 || formatArray.indexOf( 'm' ) > -1 )
|
80
|
+
})( calendar.formats.toArray( formatString ) )
|
81
|
+
}
|
82
|
+
)
|
83
|
+
|
84
|
+
|
85
|
+
// The keycode to movement mapping.
|
86
|
+
calendar.key = {
|
87
|
+
40: 7, // Down
|
88
|
+
38: -7, // Up
|
89
|
+
39: 1, // Right
|
90
|
+
37: -1, // Left
|
91
|
+
go: function( timeChange ) {
|
92
|
+
calendar.set( 'highlight', [ calendar.item.highlight.year, calendar.item.highlight.month, calendar.item.highlight.date + timeChange ], { interval: timeChange } )
|
93
|
+
this.render()
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
// Bind some picker events.
|
99
|
+
picker.
|
100
|
+
on( 'render', function() {
|
101
|
+
picker.$root.find( '.' + settings.klass.selectMonth ).on( 'change', function() {
|
102
|
+
picker.set( 'highlight', [ picker.get( 'view' ).year, this.value, picker.get( 'highlight' ).date ] )
|
103
|
+
picker.$root.find( '.' + settings.klass.selectMonth ).focus()
|
104
|
+
})
|
105
|
+
picker.$root.find( '.' + settings.klass.selectYear ).on( 'change', function() {
|
106
|
+
picker.set( 'highlight', [ this.value, picker.get( 'view' ).month, picker.get( 'highlight' ).date ] )
|
107
|
+
picker.$root.find( '.' + settings.klass.selectYear ).focus()
|
108
|
+
})
|
109
|
+
}).
|
110
|
+
on( 'open', function() {
|
111
|
+
picker.$root.find( 'button, select' ).attr( 'disabled', false )
|
112
|
+
}).
|
113
|
+
on( 'close', function() {
|
114
|
+
picker.$root.find( 'button, select' ).attr( 'disabled', true )
|
115
|
+
})
|
116
|
+
|
117
|
+
} //DatePicker
|
118
|
+
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Set a datepicker item object.
|
122
|
+
*/
|
123
|
+
DatePicker.prototype.set = function( type, value, options ) {
|
124
|
+
|
125
|
+
var calendar = this
|
126
|
+
|
127
|
+
// Go through the queue of methods, and invoke the function. Update this
|
128
|
+
// as the time unit, and set the final resultant as this item type.
|
129
|
+
// * In the case of `enable`, keep the queue but set `disable` instead.
|
130
|
+
// And in the case of `flip`, keep the queue but set `enable` instead.
|
131
|
+
calendar.item[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = calendar.queue[ type ].split( ' ' ).map( function( method ) {
|
132
|
+
return value = calendar[ method ]( type, value, options )
|
133
|
+
}).pop()
|
134
|
+
|
135
|
+
// Check if we need to cascade through more updates.
|
136
|
+
if ( type == 'select' ) {
|
137
|
+
calendar.set( 'highlight', calendar.item.select, options )
|
138
|
+
}
|
139
|
+
else if ( type == 'highlight' ) {
|
140
|
+
calendar.set( 'view', calendar.item.highlight, options )
|
141
|
+
}
|
142
|
+
else if ( ( type == 'flip' || type == 'min' || type == 'max' || type == 'disable' || type == 'enable' ) && calendar.item.select && calendar.item.highlight ) {
|
143
|
+
calendar.
|
144
|
+
set( 'select', calendar.item.select, options ).
|
145
|
+
set( 'highlight', calendar.item.highlight, options )
|
146
|
+
}
|
147
|
+
|
148
|
+
return calendar
|
149
|
+
} //DatePicker.prototype.set
|
150
|
+
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Get a datepicker item object.
|
154
|
+
*/
|
155
|
+
DatePicker.prototype.get = function( type ) {
|
156
|
+
return this.item[ type ]
|
157
|
+
} //DatePicker.prototype.get
|
158
|
+
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Create a picker date object.
|
162
|
+
*/
|
163
|
+
DatePicker.prototype.create = function( type, value, options ) {
|
164
|
+
|
165
|
+
var isInfiniteValue,
|
166
|
+
calendar = this
|
167
|
+
|
168
|
+
// If there’s no value, use the type as the value.
|
169
|
+
value = value === undefined ? type : value
|
170
|
+
|
171
|
+
|
172
|
+
// If it’s infinity, update the value.
|
173
|
+
if ( value == -Infinity || value == Infinity ) {
|
174
|
+
isInfiniteValue = value
|
175
|
+
}
|
176
|
+
|
177
|
+
// If it’s an object, use the native date object.
|
178
|
+
else if ( Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
|
179
|
+
value = value.obj
|
180
|
+
}
|
181
|
+
|
182
|
+
// If it’s an array, convert it into a date and make sure
|
183
|
+
// that it’s a valid date – otherwise default to today.
|
184
|
+
else if ( Array.isArray( value ) ) {
|
185
|
+
value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] )
|
186
|
+
value = Picker._.isDate( value ) ? value : calendar.create().obj
|
187
|
+
}
|
188
|
+
|
189
|
+
// If it’s a number or date object, make a normalized date.
|
190
|
+
else if ( Picker._.isInteger( value ) || Picker._.isDate( value ) ) {
|
191
|
+
value = calendar.normalize( new Date( value ), options )
|
192
|
+
}
|
193
|
+
|
194
|
+
// If it’s a literal true or any other case, set it to now.
|
195
|
+
else /*if ( value === true )*/ {
|
196
|
+
value = calendar.now( type, value, options )
|
197
|
+
}
|
198
|
+
|
199
|
+
// Return the compiled object.
|
200
|
+
return {
|
201
|
+
year: isInfiniteValue || value.getFullYear(),
|
202
|
+
month: isInfiniteValue || value.getMonth(),
|
203
|
+
date: isInfiniteValue || value.getDate(),
|
204
|
+
day: isInfiniteValue || value.getDay(),
|
205
|
+
obj: isInfiniteValue || value,
|
206
|
+
pick: isInfiniteValue || value.getTime()
|
207
|
+
}
|
208
|
+
} //DatePicker.prototype.create
|
209
|
+
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Get the date today.
|
213
|
+
*/
|
214
|
+
DatePicker.prototype.now = function( type, value, options ) {
|
215
|
+
value = new Date()
|
216
|
+
if ( options && options.rel ) {
|
217
|
+
value.setDate( value.getDate() + options.rel )
|
218
|
+
}
|
219
|
+
return this.normalize( value, options )
|
220
|
+
} //DatePicker.prototype.now
|
221
|
+
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Navigate to next/prev month.
|
225
|
+
*/
|
226
|
+
DatePicker.prototype.navigate = function( type, value, options ) {
|
227
|
+
|
228
|
+
if ( Picker._.isObject( value ) ) {
|
229
|
+
|
230
|
+
var targetDateObject = new Date( value.year, value.month + ( options && options.nav ? options.nav : 0 ), 1 ),
|
231
|
+
year = targetDateObject.getFullYear(),
|
232
|
+
month = targetDateObject.getMonth(),
|
233
|
+
date = value.date
|
234
|
+
|
235
|
+
// Make sure the date is valid and if the month we’re going to doesn’t have enough
|
236
|
+
// days, keep decreasing the date until we reach the month’s last date.
|
237
|
+
while ( Picker._.isDate( targetDateObject ) && new Date( year, month, date ).getMonth() !== month ) {
|
238
|
+
date -= 1
|
239
|
+
}
|
240
|
+
|
241
|
+
value = [ year, month, date ]
|
242
|
+
}
|
243
|
+
|
244
|
+
return value
|
245
|
+
} //DatePicker.prototype.navigate
|
246
|
+
|
247
|
+
|
248
|
+
/**
|
249
|
+
* Normalize a date by setting the hours to midnight.
|
250
|
+
*/
|
251
|
+
DatePicker.prototype.normalize = function( value/*, options*/ ) {
|
252
|
+
value.setHours( 0, 0, 0, 0 )
|
253
|
+
return value
|
254
|
+
}
|
255
|
+
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Measure the range of dates.
|
259
|
+
*/
|
260
|
+
DatePicker.prototype.measure = function( type, value/*, options*/ ) {
|
261
|
+
|
262
|
+
var calendar = this
|
263
|
+
|
264
|
+
// If it's anything false-y, remove the limits.
|
265
|
+
if ( !value ) {
|
266
|
+
value = type == 'min' ? -Infinity : Infinity
|
267
|
+
}
|
268
|
+
|
269
|
+
// If it's an integer, get a date relative to today.
|
270
|
+
else if ( Picker._.isInteger( value ) ) {
|
271
|
+
value = calendar.now( type, value, { rel: value } )
|
272
|
+
}
|
273
|
+
|
274
|
+
return value
|
275
|
+
} ///DatePicker.prototype.measure
|
276
|
+
|
277
|
+
|
278
|
+
/**
|
279
|
+
* Create a viewset object based on navigation.
|
280
|
+
*/
|
281
|
+
DatePicker.prototype.viewset = function( type, dateObject/*, options*/ ) {
|
282
|
+
return this.create([ dateObject.year, dateObject.month, 1 ])
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
/**
|
287
|
+
* Validate a date as enabled and shift if needed.
|
288
|
+
*/
|
289
|
+
DatePicker.prototype.validate = function( type, dateObject, options ) {
|
290
|
+
|
291
|
+
var calendar = this,
|
292
|
+
|
293
|
+
// Keep a reference to the original date.
|
294
|
+
originalDateObject = dateObject,
|
295
|
+
|
296
|
+
// Make sure we have an interval.
|
297
|
+
interval = options && options.interval ? options.interval : 1,
|
298
|
+
|
299
|
+
// Check if the calendar enabled dates are inverted.
|
300
|
+
isInverted = calendar.item.enable === -1,
|
301
|
+
|
302
|
+
// Check if we have any enabled dates after/before now.
|
303
|
+
hasEnabledBeforeTarget, hasEnabledAfterTarget,
|
304
|
+
|
305
|
+
// The min & max limits.
|
306
|
+
minLimitObject = calendar.item.min,
|
307
|
+
maxLimitObject = calendar.item.max,
|
308
|
+
|
309
|
+
// Check if we’ve reached the limit during shifting.
|
310
|
+
reachedMin, reachedMax,
|
311
|
+
|
312
|
+
// Check if the calendar is inverted and at least one weekday is enabled.
|
313
|
+
hasEnabledWeekdays = isInverted && calendar.item.disable.filter( function( value ) {
|
314
|
+
|
315
|
+
// If there’s a date, check where it is relative to the target.
|
316
|
+
if ( Array.isArray( value ) ) {
|
317
|
+
var dateTime = calendar.create( value ).pick
|
318
|
+
if ( dateTime < dateObject.pick ) hasEnabledBeforeTarget = true
|
319
|
+
else if ( dateTime > dateObject.pick ) hasEnabledAfterTarget = true
|
320
|
+
}
|
321
|
+
|
322
|
+
// Return only integers for enabled weekdays.
|
323
|
+
return Picker._.isInteger( value )
|
324
|
+
}).length
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
// Cases to validate for:
|
329
|
+
// [1] Not inverted and date disabled.
|
330
|
+
// [2] Inverted and some dates enabled.
|
331
|
+
// [3] Out of range.
|
332
|
+
//
|
333
|
+
// Cases to **not** validate for:
|
334
|
+
// • Not inverted and date enabled.
|
335
|
+
// • Inverted and all dates disabled.
|
336
|
+
// • Navigating months.
|
337
|
+
// • ..and anything else.
|
338
|
+
if (
|
339
|
+
/* 1 */ ( !isInverted && calendar.disabled( dateObject ) ) ||
|
340
|
+
/* 2 */ ( isInverted && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
|
341
|
+
/* 3 */ ( dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick )
|
342
|
+
) {
|
343
|
+
|
344
|
+
|
345
|
+
// When inverted, flip the direction if there aren’t any enabled weekdays
|
346
|
+
// and there are no enabled dates in the direction of the interval.
|
347
|
+
if ( isInverted && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
|
348
|
+
interval *= -1
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
// Keep looping until we reach an enabled date.
|
353
|
+
while ( calendar.disabled( dateObject ) ) {
|
354
|
+
|
355
|
+
|
356
|
+
// If we’ve looped into the next/prev month, return to the original date and flatten the interval.
|
357
|
+
if ( Math.abs( interval ) > 1 && ( dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month ) ) {
|
358
|
+
dateObject = originalDateObject
|
359
|
+
interval = Math.abs( interval ) / interval
|
360
|
+
}
|
361
|
+
|
362
|
+
|
363
|
+
// If we’ve reached the min/max limit, reverse the direction and flatten the interval.
|
364
|
+
if ( dateObject.pick <= minLimitObject.pick ) {
|
365
|
+
reachedMin = true
|
366
|
+
interval = 1
|
367
|
+
}
|
368
|
+
else if ( dateObject.pick >= maxLimitObject.pick ) {
|
369
|
+
reachedMax = true
|
370
|
+
interval = -1
|
371
|
+
}
|
372
|
+
|
373
|
+
|
374
|
+
// If we’ve reached both limits, just break out of the loop.
|
375
|
+
if ( reachedMin && reachedMax ) {
|
376
|
+
break
|
377
|
+
}
|
378
|
+
|
379
|
+
|
380
|
+
// Finally, create the shifted date using the interval and keep looping.
|
381
|
+
dateObject = calendar.create([ dateObject.year, dateObject.month, dateObject.date + interval ])
|
382
|
+
}
|
383
|
+
|
384
|
+
} //endif
|
385
|
+
|
386
|
+
|
387
|
+
// Return the date object settled on.
|
388
|
+
return dateObject
|
389
|
+
} //DatePicker.prototype.validate
|
390
|
+
|
391
|
+
|
392
|
+
/**
|
393
|
+
* Check if an object is disabled.
|
394
|
+
*/
|
395
|
+
DatePicker.prototype.disabled = function( dateObject ) {
|
396
|
+
|
397
|
+
var calendar = this,
|
398
|
+
|
399
|
+
// Filter through the disabled dates to check if this is one.
|
400
|
+
isDisabledDate = calendar.item.disable.filter( function( dateToDisable ) {
|
401
|
+
|
402
|
+
// If the date is a number, match the weekday with 0index and `firstDay` check.
|
403
|
+
if ( Picker._.isInteger( dateToDisable ) ) {
|
404
|
+
return dateObject.day === ( calendar.settings.firstDay ? dateToDisable : dateToDisable - 1 ) % 7
|
405
|
+
}
|
406
|
+
|
407
|
+
// If it's an array, create the object and match the exact date.
|
408
|
+
if ( Array.isArray( dateToDisable ) ) {
|
409
|
+
return dateObject.pick === calendar.create( dateToDisable ).pick
|
410
|
+
}
|
411
|
+
}).length
|
412
|
+
|
413
|
+
|
414
|
+
// It’s disabled beyond the min/max limits. If within the limits, check the
|
415
|
+
// calendar “enabled” flag is flipped and respectively flip the condition.
|
416
|
+
return dateObject.pick < calendar.item.min.pick ||
|
417
|
+
dateObject.pick > calendar.item.max.pick ||
|
418
|
+
calendar.item.enable === -1 ? !isDisabledDate : isDisabledDate
|
419
|
+
} //DatePicker.prototype.disabled
|
420
|
+
|
421
|
+
|
422
|
+
/**
|
423
|
+
* Parse a string into a usable type.
|
424
|
+
*/
|
425
|
+
DatePicker.prototype.parse = function( type, value, options ) {
|
426
|
+
|
427
|
+
var calendar = this,
|
428
|
+
parsingObject = {}
|
429
|
+
|
430
|
+
if ( !value || Picker._.isInteger( value ) || Array.isArray( value ) || Picker._.isDate( value ) || Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
|
431
|
+
return value
|
432
|
+
}
|
433
|
+
|
434
|
+
// We need a `.format` to parse the value.
|
435
|
+
if ( !( options && options.format ) ) {
|
436
|
+
// should probably default to the default format.
|
437
|
+
throw "Need a formatting option to parse this.."
|
438
|
+
}
|
439
|
+
|
440
|
+
// Convert the format into an array and then map through it.
|
441
|
+
calendar.formats.toArray( options.format ).map( function( label ) {
|
442
|
+
|
443
|
+
var
|
444
|
+
// Grab the formatting label.
|
445
|
+
formattingLabel = calendar.formats[ label ],
|
446
|
+
|
447
|
+
// The format length is from the formatting label function or the
|
448
|
+
// label length without the escaping exclamation (!) mark.
|
449
|
+
formatLength = formattingLabel ? Picker._.trigger( formattingLabel, calendar, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length
|
450
|
+
|
451
|
+
// If there's a format label, split the value up to the format length.
|
452
|
+
// Then add it to the parsing object with appropriate label.
|
453
|
+
if ( formattingLabel ) {
|
454
|
+
parsingObject[ label ] = value.substr( 0, formatLength )
|
455
|
+
}
|
456
|
+
|
457
|
+
// Update the value as the substring from format length to end.
|
458
|
+
value = value.substr( formatLength )
|
459
|
+
})
|
460
|
+
|
461
|
+
// If it’s parsing a user provided month value, compensate for month 0index.
|
462
|
+
return [ parsingObject.yyyy || parsingObject.yy, +( parsingObject.mm || parsingObject.m ) - ( options.data ? 1 : 0 ), parsingObject.dd || parsingObject.d ]
|
463
|
+
} //DatePicker.prototype.parse
|
464
|
+
|
465
|
+
|
466
|
+
/**
|
467
|
+
* Various formats to display the object in.
|
468
|
+
*/
|
469
|
+
DatePicker.prototype.formats = (function() {
|
470
|
+
|
471
|
+
// Return the length of the first word in a collection.
|
472
|
+
function getWordLengthFromCollection( string, collection, dateObject ) {
|
473
|
+
|
474
|
+
// Grab the first word from the string.
|
475
|
+
var word = string.match( /\w+/ )[ 0 ]
|
476
|
+
|
477
|
+
// If there's no month index, add it to the date object
|
478
|
+
if ( !dateObject.mm && !dateObject.m ) {
|
479
|
+
dateObject.m = collection.indexOf( word )
|
480
|
+
}
|
481
|
+
|
482
|
+
// Return the length of the word.
|
483
|
+
return word.length
|
484
|
+
}
|
485
|
+
|
486
|
+
// Get the length of the first word in a string.
|
487
|
+
function getFirstWordLength( string ) {
|
488
|
+
return string.match( /\w+/ )[ 0 ].length
|
489
|
+
}
|
490
|
+
|
491
|
+
return {
|
492
|
+
|
493
|
+
d: function( string, dateObject ) {
|
494
|
+
|
495
|
+
// If there's string, then get the digits length.
|
496
|
+
// Otherwise return the selected date.
|
497
|
+
return string ? Picker._.digits( string ) : dateObject.date
|
498
|
+
},
|
499
|
+
dd: function( string, dateObject ) {
|
500
|
+
|
501
|
+
// If there's a string, then the length is always 2.
|
502
|
+
// Otherwise return the selected date with a leading zero.
|
503
|
+
return string ? 2 : Picker._.lead( dateObject.date )
|
504
|
+
},
|
505
|
+
ddd: function( string, dateObject ) {
|
506
|
+
|
507
|
+
// If there's a string, then get the length of the first word.
|
508
|
+
// Otherwise return the short selected weekday.
|
509
|
+
return string ? getFirstWordLength( string ) : this.settings.weekdaysShort[ dateObject.day ]
|
510
|
+
},
|
511
|
+
dddd: function( string, dateObject ) {
|
512
|
+
|
513
|
+
// If there's a string, then get the length of the first word.
|
514
|
+
// Otherwise return the full selected weekday.
|
515
|
+
return string ? getFirstWordLength( string ) : this.settings.weekdaysFull[ dateObject.day ]
|
516
|
+
},
|
517
|
+
m: function( string, dateObject ) {
|
518
|
+
|
519
|
+
// If there's a string, then get the length of the digits
|
520
|
+
// Otherwise return the selected month with 0index compensation.
|
521
|
+
return string ? Picker._.digits( string ) : dateObject.month + 1
|
522
|
+
},
|
523
|
+
mm: function( string, dateObject ) {
|
524
|
+
|
525
|
+
// If there's a string, then the length is always 2.
|
526
|
+
// Otherwise return the selected month with 0index and leading zero.
|
527
|
+
return string ? 2 : Picker._.lead( dateObject.month + 1 )
|
528
|
+
},
|
529
|
+
mmm: function( string, dateObject ) {
|
530
|
+
|
531
|
+
var collection = this.settings.monthsShort
|
532
|
+
|
533
|
+
// If there's a string, get length of the relevant month from the short
|
534
|
+
// months collection. Otherwise return the selected month from that collection.
|
535
|
+
return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
|
536
|
+
},
|
537
|
+
mmmm: function( string, dateObject ) {
|
538
|
+
|
539
|
+
var collection = this.settings.monthsFull
|
540
|
+
|
541
|
+
// If there's a string, get length of the relevant month from the full
|
542
|
+
// months collection. Otherwise return the selected month from that collection.
|
543
|
+
return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
|
544
|
+
},
|
545
|
+
yy: function( string, dateObject ) {
|
546
|
+
|
547
|
+
// If there's a string, then the length is always 2.
|
548
|
+
// Otherwise return the selected year by slicing out the first 2 digits.
|
549
|
+
return string ? 2 : ( '' + dateObject.year ).slice( 2 )
|
550
|
+
},
|
551
|
+
yyyy: function( string, dateObject ) {
|
552
|
+
|
553
|
+
// If there's a string, then the length is always 4.
|
554
|
+
// Otherwise return the selected year.
|
555
|
+
return string ? 4 : dateObject.year
|
556
|
+
},
|
557
|
+
|
558
|
+
// Create an array by splitting the formatting string passed.
|
559
|
+
toArray: function( formatString ) { return formatString.split( /(d{1,4}|m{1,4}|y{4}|yy|!.)/g ) },
|
560
|
+
|
561
|
+
// Format an object into a string using the formatting options.
|
562
|
+
toString: function ( formatString, itemObject ) {
|
563
|
+
var calendar = this
|
564
|
+
return calendar.formats.toArray( formatString ).map( function( label ) {
|
565
|
+
return Picker._.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' )
|
566
|
+
}).join( '' )
|
567
|
+
}
|
568
|
+
}
|
569
|
+
})() //DatePicker.prototype.formats
|
570
|
+
|
571
|
+
|
572
|
+
/**
|
573
|
+
* Flip an item as enabled or disabled.
|
574
|
+
*/
|
575
|
+
DatePicker.prototype.flipItem = function( type, value/*, options*/ ) {
|
576
|
+
|
577
|
+
var calendar = this,
|
578
|
+
collection = calendar.item.disable,
|
579
|
+
isInverted = calendar.item.enable === -1
|
580
|
+
|
581
|
+
// Flip the enabled and disabled dates.
|
582
|
+
if ( value == 'flip' ) {
|
583
|
+
calendar.item.enable = isInverted ? 1 : -1
|
584
|
+
}
|
585
|
+
|
586
|
+
// Check if we have to add/remove from collection.
|
587
|
+
else if ( !isInverted && type == 'enable' || isInverted && type == 'disable' ) {
|
588
|
+
collection = calendar.removeDisabled( collection, value )
|
589
|
+
}
|
590
|
+
else if ( !isInverted && type == 'disable' || isInverted && type == 'enable' ) {
|
591
|
+
collection = calendar.addDisabled( collection, value )
|
592
|
+
}
|
593
|
+
|
594
|
+
return collection
|
595
|
+
} //DatePicker.prototype.flipItem
|
596
|
+
|
597
|
+
|
598
|
+
/**
|
599
|
+
* Add an item to the disabled collection.
|
600
|
+
*/
|
601
|
+
DatePicker.prototype.addDisabled = function( collection, item ) {
|
602
|
+
var calendar = this
|
603
|
+
item.map( function( timeUnit ) {
|
604
|
+
if ( !calendar.filterDisabled( collection, timeUnit ).length ) {
|
605
|
+
collection.push( timeUnit )
|
606
|
+
}
|
607
|
+
})
|
608
|
+
return collection
|
609
|
+
} //DatePicker.prototype.addDisabled
|
610
|
+
|
611
|
+
|
612
|
+
/**
|
613
|
+
* Remove an item from the disabled collection.
|
614
|
+
*/
|
615
|
+
DatePicker.prototype.removeDisabled = function( collection, item ) {
|
616
|
+
var calendar = this
|
617
|
+
item.map( function( timeUnit ) {
|
618
|
+
collection = calendar.filterDisabled( collection, timeUnit, 1 )
|
619
|
+
})
|
620
|
+
return collection
|
621
|
+
} //DatePicker.prototype.removeDisabled
|
622
|
+
|
623
|
+
|
624
|
+
/**
|
625
|
+
* Filter through the disabled collection to find a time unit.
|
626
|
+
*/
|
627
|
+
DatePicker.prototype.filterDisabled = function( collection, timeUnit, isRemoving ) {
|
628
|
+
var timeIsArray = Array.isArray( timeUnit )
|
629
|
+
return collection.filter( function( disabledTimeUnit ) {
|
630
|
+
var isMatch = !timeIsArray && timeUnit === disabledTimeUnit ||
|
631
|
+
timeIsArray && Array.isArray( disabledTimeUnit ) && timeUnit.toString() === disabledTimeUnit.toString()
|
632
|
+
return isRemoving ? !isMatch : isMatch
|
633
|
+
})
|
634
|
+
} //DatePicker.prototype.filterDisabled
|
635
|
+
|
636
|
+
|
637
|
+
/**
|
638
|
+
* Create a string for the nodes in the picker.
|
639
|
+
*/
|
640
|
+
DatePicker.prototype.nodes = function( isOpen ) {
|
641
|
+
|
642
|
+
var
|
643
|
+
calendar = this,
|
644
|
+
settings = calendar.settings,
|
645
|
+
nowObject = calendar.item.now,
|
646
|
+
selectedObject = calendar.item.select,
|
647
|
+
highlightedObject = calendar.item.highlight,
|
648
|
+
viewsetObject = calendar.item.view,
|
649
|
+
disabledCollection = calendar.item.disable,
|
650
|
+
minLimitObject = calendar.item.min,
|
651
|
+
maxLimitObject = calendar.item.max,
|
652
|
+
|
653
|
+
|
654
|
+
// Create the calendar table head using a copy of weekday labels collection.
|
655
|
+
// * We do a copy so we don't mutate the original array.
|
656
|
+
tableHead = (function( collection ) {
|
657
|
+
|
658
|
+
// If the first day should be Monday, move Sunday to the end.
|
659
|
+
if ( settings.firstDay ) {
|
660
|
+
collection.push( collection.shift() )
|
661
|
+
}
|
662
|
+
|
663
|
+
// Create and return the table head group.
|
664
|
+
return Picker._.node(
|
665
|
+
'thead',
|
666
|
+
Picker._.group({
|
667
|
+
min: 0,
|
668
|
+
max: DAYS_IN_WEEK - 1,
|
669
|
+
i: 1,
|
670
|
+
node: 'th',
|
671
|
+
item: function( counter ) {
|
672
|
+
return [
|
673
|
+
collection[ counter ],
|
674
|
+
settings.klass.weekdays
|
675
|
+
]
|
676
|
+
}
|
677
|
+
})
|
678
|
+
) //endreturn
|
679
|
+
})( ( settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysShort ).slice( 0 ) ), //tableHead
|
680
|
+
|
681
|
+
|
682
|
+
// Create the nav for next/prev month.
|
683
|
+
createMonthNav = function( next ) {
|
684
|
+
|
685
|
+
// Otherwise, return the created month tag.
|
686
|
+
return Picker._.node(
|
687
|
+
'div',
|
688
|
+
' ',
|
689
|
+
settings.klass[ 'nav' + ( next ? 'Next' : 'Prev' ) ] + (
|
690
|
+
|
691
|
+
// If the focused month is outside the range, disabled the button.
|
692
|
+
( next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month ) ||
|
693
|
+
( !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ) ?
|
694
|
+
' ' + settings.klass.navDisabled : ''
|
695
|
+
),
|
696
|
+
'data-nav=' + ( next || -1 )
|
697
|
+
) //endreturn
|
698
|
+
}, //createMonthNav
|
699
|
+
|
700
|
+
|
701
|
+
// Create the month label.
|
702
|
+
createMonthLabel = function( monthsCollection ) {
|
703
|
+
|
704
|
+
// If there are months to select, add a dropdown menu.
|
705
|
+
if ( settings.selectMonths ) {
|
706
|
+
|
707
|
+
return Picker._.node( 'select', Picker._.group({
|
708
|
+
min: 0,
|
709
|
+
max: 11,
|
710
|
+
i: 1,
|
711
|
+
node: 'option',
|
712
|
+
item: function( loopedMonth ) {
|
713
|
+
|
714
|
+
return [
|
715
|
+
|
716
|
+
// The looped month and no classes.
|
717
|
+
monthsCollection[ loopedMonth ], 0,
|
718
|
+
|
719
|
+
// Set the value and selected index.
|
720
|
+
'value=' + loopedMonth +
|
721
|
+
( viewsetObject.month == loopedMonth ? ' selected' : '' ) +
|
722
|
+
(
|
723
|
+
(
|
724
|
+
( viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month ) ||
|
725
|
+
( viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month )
|
726
|
+
) ?
|
727
|
+
' disabled' : ''
|
728
|
+
)
|
729
|
+
]
|
730
|
+
}
|
731
|
+
}), settings.klass.selectMonth, isOpen ? '' : 'disabled' )
|
732
|
+
}
|
733
|
+
|
734
|
+
// If there's a need for a month selector
|
735
|
+
return Picker._.node( 'div', monthsCollection[ viewsetObject.month ], settings.klass.month )
|
736
|
+
}, //createMonthLabel
|
737
|
+
|
738
|
+
|
739
|
+
// Create the year label.
|
740
|
+
createYearLabel = function() {
|
741
|
+
|
742
|
+
var focusedYear = viewsetObject.year,
|
743
|
+
|
744
|
+
// If years selector is set to a literal "true", set it to 5. Otherwise
|
745
|
+
// divide in half to get half before and half after focused year.
|
746
|
+
numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 )
|
747
|
+
|
748
|
+
// If there are years to select, add a dropdown menu.
|
749
|
+
if ( numberYears ) {
|
750
|
+
|
751
|
+
var
|
752
|
+
minYear = minLimitObject.year,
|
753
|
+
maxYear = maxLimitObject.year,
|
754
|
+
lowestYear = focusedYear - numberYears,
|
755
|
+
highestYear = focusedYear + numberYears
|
756
|
+
|
757
|
+
// If the min year is greater than the lowest year, increase the highest year
|
758
|
+
// by the difference and set the lowest year to the min year.
|
759
|
+
if ( minYear > lowestYear ) {
|
760
|
+
highestYear += minYear - lowestYear
|
761
|
+
lowestYear = minYear
|
762
|
+
}
|
763
|
+
|
764
|
+
// If the max year is less than the highest year, decrease the lowest year
|
765
|
+
// by the lower of the two: available and needed years. Then set the
|
766
|
+
// highest year to the max year.
|
767
|
+
if ( maxYear < highestYear ) {
|
768
|
+
|
769
|
+
var availableYears = lowestYear - minYear,
|
770
|
+
neededYears = highestYear - maxYear
|
771
|
+
|
772
|
+
lowestYear -= availableYears > neededYears ? neededYears : availableYears
|
773
|
+
highestYear = maxYear
|
774
|
+
}
|
775
|
+
|
776
|
+
return Picker._.node( 'select', Picker._.group({
|
777
|
+
min: lowestYear,
|
778
|
+
max: highestYear,
|
779
|
+
i: 1,
|
780
|
+
node: 'option',
|
781
|
+
item: function( loopedYear ) {
|
782
|
+
return [
|
783
|
+
|
784
|
+
// The looped year and no classes.
|
785
|
+
loopedYear, 0,
|
786
|
+
|
787
|
+
// Set the value and selected index.
|
788
|
+
'value=' + loopedYear + ( focusedYear == loopedYear ? ' selected' : '' )
|
789
|
+
]
|
790
|
+
}
|
791
|
+
}), settings.klass.selectYear, isOpen ? '' : 'disabled' )
|
792
|
+
}
|
793
|
+
|
794
|
+
// Otherwise just return the year focused
|
795
|
+
return Picker._.node( 'div', focusedYear, settings.klass.year )
|
796
|
+
} //createYearLabel
|
797
|
+
|
798
|
+
|
799
|
+
// Create and return the entire calendar.
|
800
|
+
return Picker._.node(
|
801
|
+
'div',
|
802
|
+
createMonthNav() + createMonthNav( 1 ) +
|
803
|
+
createMonthLabel( settings.showMonthsShort ? settings.monthsShort : settings.monthsFull ) +
|
804
|
+
createYearLabel(),
|
805
|
+
settings.klass.header
|
806
|
+
) + Picker._.node(
|
807
|
+
'table',
|
808
|
+
tableHead +
|
809
|
+
Picker._.node(
|
810
|
+
'tbody',
|
811
|
+
Picker._.group({
|
812
|
+
min: 0,
|
813
|
+
max: WEEKS_IN_CALENDAR - 1,
|
814
|
+
i: 1,
|
815
|
+
node: 'tr',
|
816
|
+
item: function( rowCounter ) {
|
817
|
+
|
818
|
+
// If Monday is the first day and the month starts on Sunday, shift the date back a week.
|
819
|
+
var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0
|
820
|
+
|
821
|
+
return [
|
822
|
+
Picker._.group({
|
823
|
+
min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
|
824
|
+
max: function() {
|
825
|
+
return this.min + DAYS_IN_WEEK - 1
|
826
|
+
},
|
827
|
+
i: 1,
|
828
|
+
node: 'td',
|
829
|
+
item: function( targetDate ) {
|
830
|
+
|
831
|
+
// Convert the time date from a relative date to a target date.
|
832
|
+
targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
|
833
|
+
|
834
|
+
return [
|
835
|
+
Picker._.node(
|
836
|
+
'div',
|
837
|
+
targetDate.date,
|
838
|
+
(function( klasses ) {
|
839
|
+
|
840
|
+
// Add the `infocus` or `outfocus` classes based on month in view.
|
841
|
+
klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus )
|
842
|
+
|
843
|
+
// Add the `today` class if needed.
|
844
|
+
if ( nowObject.pick == targetDate.pick ) {
|
845
|
+
klasses.push( settings.klass.now )
|
846
|
+
}
|
847
|
+
|
848
|
+
// Add the `selected` class if something's selected and the time matches.
|
849
|
+
if ( selectedObject && selectedObject.pick == targetDate.pick ) {
|
850
|
+
klasses.push( settings.klass.selected )
|
851
|
+
}
|
852
|
+
|
853
|
+
// Add the `highlighted` class if something's highlighted and the time matches.
|
854
|
+
if ( highlightedObject && highlightedObject.pick == targetDate.pick ) {
|
855
|
+
klasses.push( settings.klass.highlighted )
|
856
|
+
}
|
857
|
+
|
858
|
+
// Add the `disabled` class if something's disabled and the object matches.
|
859
|
+
if ( disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick ) {
|
860
|
+
klasses.push( settings.klass.disabled )
|
861
|
+
}
|
862
|
+
|
863
|
+
return klasses.join( ' ' )
|
864
|
+
})([ settings.klass.day ]),
|
865
|
+
'data-pick=' + targetDate.pick
|
866
|
+
)
|
867
|
+
] //endreturn
|
868
|
+
}
|
869
|
+
})
|
870
|
+
] //endreturn
|
871
|
+
}
|
872
|
+
})
|
873
|
+
),
|
874
|
+
settings.klass.table
|
875
|
+
) +
|
876
|
+
|
877
|
+
Picker._.node(
|
878
|
+
'div',
|
879
|
+
Picker._.node( 'button', settings.today, settings.klass.buttonToday, 'data-pick=' + nowObject.pick + ( isOpen ? '' : ' disabled' ) ) +
|
880
|
+
Picker._.node( 'button', settings.clear, settings.klass.buttonClear, 'data-clear=1' + ( isOpen ? '' : ' disabled' ) ),
|
881
|
+
settings.klass.footer
|
882
|
+
) //endreturn
|
883
|
+
} //DatePicker.prototype.nodes
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
|
888
|
+
/**
|
889
|
+
* The date picker defaults.
|
890
|
+
*/
|
891
|
+
DatePicker.defaults = (function( prefix ) {
|
892
|
+
|
893
|
+
return {
|
894
|
+
|
895
|
+
// Months and weekdays
|
896
|
+
monthsFull: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
|
897
|
+
monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
|
898
|
+
weekdaysFull: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
|
899
|
+
weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
|
900
|
+
|
901
|
+
// Today and clear
|
902
|
+
today: 'Today',
|
903
|
+
clear: 'Clear',
|
904
|
+
|
905
|
+
// The format to show on the `input` element
|
906
|
+
format: 'd mmmm, yyyy',
|
907
|
+
|
908
|
+
// Classes
|
909
|
+
klass: {
|
910
|
+
|
911
|
+
table: prefix + 'table',
|
912
|
+
|
913
|
+
header: prefix + 'header',
|
914
|
+
|
915
|
+
navPrev: prefix + 'nav--prev',
|
916
|
+
navNext: prefix + 'nav--next',
|
917
|
+
navDisabled: prefix + 'nav--disabled',
|
918
|
+
|
919
|
+
month: prefix + 'month',
|
920
|
+
year: prefix + 'year',
|
921
|
+
|
922
|
+
selectMonth: prefix + 'select--month',
|
923
|
+
selectYear: prefix + 'select--year',
|
924
|
+
|
925
|
+
weekdays: prefix + 'weekday',
|
926
|
+
|
927
|
+
day: prefix + 'day',
|
928
|
+
disabled: prefix + 'day--disabled',
|
929
|
+
selected: prefix + 'day--selected',
|
930
|
+
highlighted: prefix + 'day--highlighted',
|
931
|
+
now: prefix + 'day--today',
|
932
|
+
infocus: prefix + 'day--infocus',
|
933
|
+
outfocus: prefix + 'day--outfocus',
|
934
|
+
|
935
|
+
footer: prefix + 'footer',
|
936
|
+
|
937
|
+
buttonClear: prefix + 'button--clear',
|
938
|
+
buttonToday: prefix + 'button--today'
|
939
|
+
}
|
940
|
+
}
|
941
|
+
})( Picker.klasses().picker + '__' )
|
942
|
+
|
943
|
+
|
944
|
+
|
945
|
+
|
946
|
+
|
947
|
+
/**
|
948
|
+
* Extend the picker to add the date picker.
|
949
|
+
*/
|
950
|
+
Picker.extend( 'pickadate', DatePicker )
|
951
|
+
|
952
|
+
|
953
|
+
// Close the scope.
|
954
|
+
})();
|
955
|
+
|
956
|
+
|
957
|
+
|