pickadate-rails 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6b81367f90f3d6dee7f72cf6d8a6e9a006fa352
4
- data.tar.gz: 1629cb671ef09e5e28c562796bcc9b03eaef468d
3
+ metadata.gz: 9a4960ce8c268fa246c31d341b14ffd516322b94
4
+ data.tar.gz: 47857e18fda875db3afbf6b33716b3f844661d53
5
5
  SHA512:
6
- metadata.gz: a107b42a2766e930a491fa7c8a195543ee59a31652b62d5c338f224abc8751d454bf4dec328c28580f7e29ad799c80e146b97a9ea532a7ac8bd952efd723aa83
7
- data.tar.gz: 8f20da9035b8a2891d76ba1cae06c97ed66f675f66befb45b7f6bc62ac7332dc328869c561f6e9778deaa6fd7a199da3609b9584b4a86e2400ce7581ee87530d
6
+ metadata.gz: d648c29457b37d37e9eb17a26a8dac0bef6ead19029eaa3d03732cb9dc3b6b0e53d43d144b11bddc5882b1f030a161884cecf61bd231ccb6c60eb4975c0c77fd
7
+ data.tar.gz: 9684c1c258d2a42543e682a9a5129ef1f4c4933cd4e1eb326b2bd142995fcb299b536c92b32110d617777189d60f942379806de6070eb8b5ec777e3c50e25eb5
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Pickadate-Rails
2
2
 
3
- ## Pickadate Version: 3.0.3
3
+ ## Pickadate Version: 3.0.4
4
4
 
5
5
  Easily add [pickadate.js](https://github.com/amsul/pickadate.js) to your Rails 3.1+ application using the asset pipeline.
6
6
 
@@ -18,13 +18,15 @@ And then execute:
18
18
 
19
19
  Pickadate has a number of files associated with it. They are documented on the [pickadate repository](https://github.com/amsul/pickadate.js). Files in this gem are namespaced into a `pickadate` folder, and otherwise match the filenames from the pickadate repo.
20
20
 
21
- ### Add the desired files to your javascript/coffeescript files (often `application.js` or `application.js.coffee`):
21
+ ### Add the desired files to your javascript/coffeescript
22
+ Often done in `application.js`:
22
23
 
23
24
  //= require pickadate/picker # required
24
25
  //= require pickadate/picker.date # for the date picker
25
26
  //= require pickadate/picker.time # for the time picker
26
27
 
27
- ### Add the stylesheets for the theme you want to your stylesheet file (often `application.css`)
28
+ ### Add the stylesheets for the theme you want
29
+ Often done in `application.css`.
28
30
 
29
31
  For the default theme:
30
32
 
@@ -38,7 +40,7 @@ For the classic theme:
38
40
  *= require pickadate/classic.date
39
41
  *= require pickadate/classic.time
40
42
 
41
- ### Localizations
43
+ ### Localization
42
44
 
43
45
  Translations are available by loading them in your javascript/coffeescript file. For example, in `application.js`
44
46
 
@@ -1,3 +1,3 @@
1
1
  module PickadateRails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*!
3
- * Date picker for pickadate.js v3.0.3
3
+ * Date picker for pickadate.js v3.0.4
4
4
  * http://amsul.github.io/pickadate.js/date.htm
5
5
  */
6
6
 
@@ -156,31 +156,31 @@ DatePicker.prototype.create = function( type, value, options ) {
156
156
  var isInfiniteValue,
157
157
  calendar = this
158
158
 
159
- // If there's no value, use the type as the value.
159
+ // If theres no value, use the type as the value.
160
160
  value = value === undefined ? type : value
161
161
 
162
162
 
163
- // If it's infinity, update the value.
163
+ // If its infinity, update the value.
164
164
  if ( value == -Infinity || value == Infinity ) {
165
165
  isInfiniteValue = value
166
166
  }
167
167
 
168
- // If it's an object, use the “time” value.
168
+ // If its an object, use the native date object.
169
169
  else if ( Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
170
170
  value = value.obj
171
171
  }
172
172
 
173
- // If it's an array, convert it into a date.
173
+ // If its an array, convert it into a date.
174
174
  else if ( Array.isArray( value ) ) {
175
175
  value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] )
176
176
  }
177
177
 
178
- // If it's a number or date object, make a normalized date.
178
+ // If its a number or date object, make a normalized date.
179
179
  else if ( Picker._.isInteger( value ) || Picker._.isDate( value ) ) {
180
180
  value = calendar.normalize( new Date( value ), options )
181
181
  }
182
182
 
183
- // If it's a literal true or any other case, set it to now.
183
+ // If its a literal true or any other case, set it to now.
184
184
  else /*if ( value === true )*/ {
185
185
  value = calendar.now( type, value, options )
186
186
  }
@@ -285,6 +285,9 @@ DatePicker.prototype.validate = function( type, dateObject, options ) {
285
285
  // Make sure we have an interval.
286
286
  interval = options && options.interval ? options.interval : 1,
287
287
 
288
+ // Check if the calendar enabled dates are inverted.
289
+ isInverted = calendar.item.enable === -1,
290
+
288
291
  // Check if we have any enabled dates after/before now.
289
292
  hasEnabledBeforeTarget, hasEnabledAfterTarget,
290
293
 
@@ -295,8 +298,8 @@ DatePicker.prototype.validate = function( type, dateObject, options ) {
295
298
  // Check if we’ve reached the limit during shifting.
296
299
  reachedMin, reachedMax,
297
300
 
298
- // Check if the calendar is flipped and at least one weekday is enabled.
299
- hasEnabledWeekdays = calendar.item.enable === -1 && calendar.item.disable.filter( function( value ) {
301
+ // Check if the calendar is inverted and at least one weekday is enabled.
302
+ hasEnabledWeekdays = isInverted && calendar.item.disable.filter( function( value ) {
300
303
 
301
304
  // If there’s a date, check where it is relative to the target.
302
305
  if ( Array.isArray( value ) ) {
@@ -311,16 +314,26 @@ DatePicker.prototype.validate = function( type, dateObject, options ) {
311
314
 
312
315
 
313
316
 
314
- // No need to validate if we’re navigating months or there are no enabled days.
317
+ // Cases to validate for:
318
+ // [1] Not inverted and date disabled.
319
+ // [2] Inverted and some dates enabled.
320
+ // [3] Out of range.
321
+ //
322
+ // Cases to **not** validate for:
323
+ // • Not inverted and date enabled.
324
+ // • Inverted and all dates disabled.
325
+ // • Navigating months.
326
+ // • ..and anything else.
315
327
  if (
316
- ( !( options && options.nav ) && !( !hasEnabledWeekdays && !hasEnabledBeforeTarget && !hasEnabledAfterTarget ) ) ||
317
- ( dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick )
328
+ /* 1 */ ( !isInverted && calendar.disabled( dateObject ) ) ||
329
+ /* 2 */ ( isInverted && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
330
+ /* 3 */ ( dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick )
318
331
  ) {
319
332
 
320
333
 
321
- // Flip the direction if there aren’t any enabled weekdays
334
+ // When inverted, flip the direction if there aren’t any enabled weekdays
322
335
  // and there are no enabled dates in the direction of the interval.
323
- if ( !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
336
+ if ( isInverted && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
324
337
  interval *= -1
325
338
  }
326
339
 
@@ -547,18 +560,18 @@ DatePicker.prototype.flipItem = function( type, value/*, options*/ ) {
547
560
 
548
561
  var calendar = this,
549
562
  collection = calendar.item.disable,
550
- isFlipped = calendar.item.enable === -1
563
+ isInverted = calendar.item.enable === -1
551
564
 
552
565
  // Flip the enabled and disabled dates.
553
566
  if ( value == 'flip' ) {
554
- calendar.item.enable = isFlipped ? 1 : -1
567
+ calendar.item.enable = isInverted ? 1 : -1
555
568
  }
556
569
 
557
570
  // Check if we have to add/remove from collection.
558
- else if ( !isFlipped && type == 'enable' || isFlipped && type == 'disable' ) {
571
+ else if ( !isInverted && type == 'enable' || isInverted && type == 'disable' ) {
559
572
  collection = calendar.removeDisabled( collection, value )
560
573
  }
561
- else if ( !isFlipped && type == 'disable' || isFlipped && type == 'enable' ) {
574
+ else if ( !isInverted && type == 'disable' || isInverted && type == 'enable' ) {
562
575
  collection = calendar.addDisabled( collection, value )
563
576
  }
564
577
 
@@ -669,7 +682,7 @@ DatePicker.prototype.nodes = function( isOpen ) {
669
682
  }, //createMonthNav
670
683
 
671
684
 
672
- // Create the month label
685
+ // Create the month label.
673
686
  createMonthLabel = function( monthsCollection ) {
674
687
 
675
688
  // If there are months to select, add a dropdown menu.
@@ -707,7 +720,7 @@ DatePicker.prototype.nodes = function( isOpen ) {
707
720
  }, //createMonthLabel
708
721
 
709
722
 
710
- // Create the year label
723
+ // Create the year label.
711
724
  createYearLabel = function() {
712
725
 
713
726
  var focusedYear = viewsetObject.year,
@@ -786,51 +799,54 @@ DatePicker.prototype.nodes = function( isOpen ) {
786
799
  node: 'tr',
787
800
  item: function( rowCounter ) {
788
801
 
802
+ // If Monday is the first day and the month starts on Sunday, shift the date back a week.
803
+ var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0
804
+
789
805
  return [
790
806
  Picker._.group({
791
- min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + 1, // Add 1 for weekday 0index
807
+ min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
792
808
  max: function() {
793
809
  return this.min + DAYS_IN_WEEK - 1
794
810
  },
795
811
  i: 1,
796
812
  node: 'td',
797
- item: function( timeDate ) {
813
+ item: function( targetDate ) {
798
814
 
799
- // Convert the time date from a relative date to a date object
800
- timeDate = calendar.create([ viewsetObject.year, viewsetObject.month, timeDate + ( settings.firstDay ? 1 : 0 ) ])
815
+ // Convert the time date from a relative date to a target date.
816
+ targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
801
817
 
802
818
  return [
803
819
  Picker._.node(
804
820
  'div',
805
- timeDate.date,
821
+ targetDate.date,
806
822
  (function( klasses ) {
807
823
 
808
824
  // Add the `infocus` or `outfocus` classes based on month in view.
809
- klasses.push( viewsetObject.month == timeDate.month ? settings.klass.infocus : settings.klass.outfocus )
825
+ klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus )
810
826
 
811
827
  // Add the `today` class if needed.
812
- if ( nowObject.pick == timeDate.pick ) {
828
+ if ( nowObject.pick == targetDate.pick ) {
813
829
  klasses.push( settings.klass.now )
814
830
  }
815
831
 
816
832
  // Add the `selected` class if something's selected and the time matches.
817
- if ( selectedObject && selectedObject.pick == timeDate.pick ) {
833
+ if ( selectedObject && selectedObject.pick == targetDate.pick ) {
818
834
  klasses.push( settings.klass.selected )
819
835
  }
820
836
 
821
837
  // Add the `highlighted` class if something's highlighted and the time matches.
822
- if ( highlightedObject && highlightedObject.pick == timeDate.pick ) {
838
+ if ( highlightedObject && highlightedObject.pick == targetDate.pick ) {
823
839
  klasses.push( settings.klass.highlighted )
824
840
  }
825
841
 
826
842
  // Add the `disabled` class if something's disabled and the object matches.
827
- if ( disabledCollection && calendar.disabled( timeDate ) || timeDate.pick < minLimitObject.pick || timeDate.pick > maxLimitObject.pick ) {
843
+ if ( disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick ) {
828
844
  klasses.push( settings.klass.disabled )
829
845
  }
830
846
 
831
847
  return klasses.join( ' ' )
832
848
  })([ settings.klass.day ]),
833
- 'data-pick=' + timeDate.pick
849
+ 'data-pick=' + targetDate.pick
834
850
  )
835
851
  ] //endreturn
836
852
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*!
3
- * pickadate.js v3.0.3, 2013/05/23
3
+ * pickadate.js v3.0.4, 2013/05/25
4
4
  * By Amsul, http://amsul.ca
5
5
  * Hosted on http://amsul.github.io/pickadate.js
6
6
  * Licensed under MIT
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*!
3
- * Time picker for pickadate.js v3.0.3
3
+ * Time picker for pickadate.js v3.0.4
4
4
  * http://amsul.github.io/pickadate.js/time.htm
5
5
  */
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pickadate-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Fraser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-23 00:00:00.000000000 Z
11
+ date: 2013-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties