jquery-time_duration_picker-rails 0.1.7 → 0.1.8

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: 66bda6f14ee4650ff98de6fad6160450d86f5356
4
- data.tar.gz: 9d431ca8d16e7be2ad2a839c7c7b62206994bc9d
3
+ metadata.gz: ea6c7d520597c88d78c3e1b62f0ee50279f27065
4
+ data.tar.gz: d3bb5bd8378bad3c42e7f5c33d3f25b2666be4e0
5
5
  SHA512:
6
- metadata.gz: 476c999a7fd56bd4d25cc8dad5e46fa059491778ef49c4d05561f79a43a542e1d345be3d92567ac73c5646d6ef92a48a04e2b2074a1e3ab1a177732286d3c055
7
- data.tar.gz: a44d8c538af0032a06701278f788faa1c68c01cc051204761d27a70edb9d2d00cab47080c1a1e85b0056ae00bdaad675c5538a89c616f596cdd69343073f1887
6
+ metadata.gz: ee22d023d091173b8e08ebf143ab8474ec7778fb0515706dd1e0c4392d6a78ea0b851683dab3595f5adafaaddf328bbe84e9b5230145d62f25c9b07c90e08f9d
7
+ data.tar.gz: 0e48c484d0ef543a02a353cb52be792888f99ff941bbf13614dc2505f6b206f7efecb8bb793393b6f7a8c91cf9cfb1afae06e9df6f2d7184bd5bc54072101e6e
data/README.md CHANGED
@@ -28,27 +28,9 @@ Add this line in your application js:
28
28
  //= require jquery.timeDurationPicker
29
29
  ```
30
30
 
31
- In your view:
32
-
33
- ```html
34
- <input type="text" name="duration" id="duration" readonly="readonly" />
35
- <input type="hidden" name="seconds" id="seconds" value="0" />
36
-
37
- ...
38
-
39
- <script type="text/javascript">
40
- $(document).ready(function() {
41
- $('#duration').timeDurationPicker({
42
- onselect: function(element, seconds, duration) {
43
- $('#seconds').val(seconds);
44
- $('#duration').val(duration);
45
- }
46
- });
47
- });
48
- </script>
49
- ```
31
+ ## Example
50
32
 
51
- Also see [this example] (https://jsfiddle.net/k10ggor8/1/).
33
+ See [this example] (https://github.com/digaev/jquery-time-duration-picker/blob/master/example/index.html).
52
34
 
53
35
  ## Contributing
54
36
 
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module TimeDurationPicker
3
3
  module Rails
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jQuery TimeDurationPicker Plugin v1.0.4
2
+ * jQuery TimeDurationPicker Plugin v1.0.7
3
3
  *
4
4
  * https://github.com/digaev/jQuery-timeDurationPicker
5
5
  *
@@ -7,354 +7,378 @@
7
7
  * Released under the MIT license
8
8
  */
9
9
 
10
- (function($) {
11
- $.timeDurationPicker = function(options) {
12
- $.timeDurationPicker.defaults = $.extend({}, $.timeDurationPicker.defaults, options);
13
- }
10
+ ( function( $ ) {
11
+ $.timeDurationPicker = function( options ) {
12
+ $.timeDurationPicker.defaults = $.extend(
13
+ {}, $.timeDurationPicker.defaults, options
14
+ );
15
+ };
14
16
 
15
17
  $.timeDurationPicker.defaults = {
16
- lang: 'en',
18
+ lang: "en",
19
+ position: "fixed", // https://github.com/digaev/jQuery-timeDurationPicker/issues/1
17
20
  seconds: false,
18
21
  minutes: true,
19
22
  hours: true,
20
23
  days: true,
21
24
  months: true,
22
25
  years: true
23
- }
24
- })(jQuery);
26
+ };
27
+ } )( jQuery );
25
28
 
26
- (function($) {
29
+ ( function( $ ) {
27
30
  var instances = [];
28
31
 
29
- $(document).focusin(function(e) {
30
- for (var i = 0, c = instances.length; i < c; ++i) {
31
- var inst = instances[i];
32
- for (var j = 0, l = inst.element.length; j < l; ++j) {
33
- if (inst.element[j] == e.target) {
34
- var offset = $(e.target).offset();
35
- offset.top += $(e.target).outerHeight();
36
- offset.top -= $(window).scrollTop();
37
- offset.left -= $(window).scrollLeft();
38
- inst._content.div.css(offset).fadeIn();
32
+ $( document ).focusin( function( e ) {
33
+ for ( var i = 0, c = instances.length; i < c; ++i ) {
34
+ var inst = instances[ i ];
35
+ for ( var j = 0, l = inst.element.length; j < l; ++j ) {
36
+ if ( inst.element[ j ] === e.target ) {
37
+ var offset = $( e.target ).offset();
38
+ offset.top += $( e.target ).outerHeight();
39
+ offset.top -= $( window ).scrollTop();
40
+ offset.left -= $( window ).scrollLeft();
41
+ inst._content.div.css( offset ).fadeIn();
39
42
  }
40
43
  }
41
44
  }
42
- }).focusout(function(e) {
43
- // FIXME
44
- setTimeout(function() {
45
+ } ).focusout( function() {
46
+
47
+ // FIXME: how to correctly detect that the element has lost focus?
48
+ setTimeout( function() {
45
49
  var el = document.activeElement;
46
- if ($(el).parents('.time-duration-picker-content').length == 0) {
47
- for (var i = 0, c = instances.length; i < c; ++i) {
50
+ if ( $( el ).parents( ".time-duration-picker-content" ).length === 0 ) {
51
+ for ( var i = 0, c = instances.length; i < c; ++i ) {
48
52
  var hide = true;
49
- var inst = instances[i];
50
- for (var j = 0, l = inst.element.length; j < l; ++j) {
51
- if (inst.element[j] == el) {
53
+ var inst = instances[ i ];
54
+ for ( var j = 0, l = inst.element.length; j < l; ++j ) {
55
+ if ( inst.element[ j ] === el ) {
52
56
  hide = false;
53
57
  break;
54
58
  }
55
59
  }
56
- if (hide) {
60
+ if ( hide ) {
57
61
  inst._content.div.fadeOut();
58
62
  }
59
63
  }
60
64
  }
61
- }, 10);
62
- });
63
-
65
+ }, 10 );
66
+ } );
67
+
64
68
  var YEAR = 12 * 30 * 24 * 60 * 60;
65
69
  var MONTH = 30 * 24 * 60 * 60;
66
70
  var DAY = 24 * 60 * 60;
67
71
  var HOUR = 60 * 60;
68
72
  var MINUTE = 60;
69
-
70
- $.widget('custom.timeDurationPicker', {
73
+
74
+ $.widget( "custom.timeDurationPicker", {
71
75
  options: {
72
76
  },
73
77
  _langs: {
74
78
  en: {
75
- seconds: 'Seconds',
76
- minutes: 'Minutes',
77
- hours: 'Hours',
78
- days: 'Days',
79
- months: 'Months',
80
- years: 'Years',
81
- human_years: 'years',
82
- human_months: 'months',
83
- human_days: 'days',
84
- human_hours: 'hours',
85
- human_minutes: 'minutes',
86
- human_seconds: 'seconds',
87
- and: 'and',
88
- button_ok: 'Done'
79
+ seconds: "Seconds",
80
+ minutes: "Minutes",
81
+ hours: "Hours",
82
+ days: "Days",
83
+ months: "Months",
84
+ years: "Years",
85
+ human_years: "years",
86
+ human_months: "months",
87
+ human_days: "days",
88
+ human_hours: "hours",
89
+ human_minutes: "minutes",
90
+ human_seconds: "seconds",
91
+ and: "and",
92
+ button_ok: "Done"
89
93
  },
90
94
  ru: {
91
- seconds: 'Секунды',
92
- minutes: 'Минуты',
93
- hours: 'Часы',
94
- days: 'Дни',
95
- months: 'Месяцы',
96
- years: 'Годы',
97
- human_years: 'лет',
98
- human_months: 'месяцев',
99
- human_days: 'дней',
100
- human_hours: 'часов',
101
- human_minutes: 'минут',
102
- human_seconds: 'секунд',
103
- and: 'и',
104
- button_ok: 'Выбрать'
95
+ seconds: "Секунды",
96
+ minutes: "Минуты",
97
+ hours: "Часы",
98
+ days: "Дни",
99
+ months: "Месяцы",
100
+ years: "Годы",
101
+ human_years: "лет",
102
+ human_months: "месяцев",
103
+ human_days: "дней",
104
+ human_hours: "часов",
105
+ human_minutes: "минут",
106
+ human_seconds: "секунд",
107
+ and: "и",
108
+ button_ok: "Выбрать"
105
109
  },
106
110
  ru_short: {
107
- seconds: 'Секунды',
108
- minutes: 'Минуты',
109
- hours: 'Часы',
110
- days: 'Дни',
111
- months: 'Месяцы',
112
- years: 'Годы',
113
- human_years: 'г.',
114
- human_months: 'мес.',
115
- human_days: 'д.',
116
- human_hours: 'час.',
117
- human_minutes: 'мин.',
118
- human_seconds: 'сек.',
119
- and: 'и',
120
- button_ok: 'Выбрать'
111
+ seconds: "Секунды",
112
+ minutes: "Минуты",
113
+ hours: "Часы",
114
+ days: "Дни",
115
+ months: "Месяцы",
116
+ years: "Годы",
117
+ human_years: "г.",
118
+ human_months: "мес.",
119
+ human_days: "д.",
120
+ human_hours: "час.",
121
+ human_minutes: "мин.",
122
+ human_seconds: "сек.",
123
+ and: "и",
124
+ button_ok: "Выбрать"
121
125
  }
122
126
  },
123
127
  _create: function() {
124
- var self = this;
128
+ var self = this;
125
129
 
126
- this.options = $.extend({}, $.timeDurationPicker.defaults, this.options);
130
+ this.options = $.extend(
131
+ {}, $.timeDurationPicker.defaults, this.options
132
+ );
127
133
 
128
- this._content = {};
129
- this._content.div = $('<div />');
130
- this._content.div.addClass('ui-widget ui-widget-content ui-helper-clearfix ui-corner-all');
131
- this._content.div.addClass('time-duration-picker-content');
132
- this._content.div.css({
133
- display: 'none',
134
- position: 'fixed',
135
- "z-index": 401
136
- });
137
- this._content.div.appendTo(document.body);
134
+ this._content = {};
135
+ this._content.div = $( "<div />" );
136
+ this._content.div.addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" );
137
+ this._content.div.addClass( "time-duration-picker-content" );
138
+ this._content.div.css( {
139
+ display: "none",
140
+ position: this.options.position,
141
+ "z-index": 401
142
+ } );
143
+ this._content.div.appendTo( document.body );
138
144
 
139
- this._content.table = $('<table style="width: 100%;"><tbody /></table>').appendTo(this._content.div);
140
- this._content.tableBody = $('tbody', this._content.table);
145
+ this._content.table = $(
146
+ "<table style='width: 100%;'><tbody /></table>"
147
+ ).appendTo( this._content.div );
148
+ this._content.tableBody = $( "tbody", this._content.table );
141
149
 
142
- this._content.button = $('<input type="button" />').val(this._tr('button_ok'));
143
- this._content.button.addClass('ui-button ui-widget ui-state-default ui-corner-all');
144
- this._content.button.css({
145
- display: 'block',
146
- margin: '0.5em auto',
147
- padding: '0.5em 1em'
148
- });
149
- this._content.button.hover(function() {
150
- $(this).addClass('ui-state-hover');
151
- }, function() {
152
- $(this).removeClass('ui-state-hover');
153
- });
154
- this._content.button.on('click', function(e) {
155
- self._content.div.fadeOut();
156
- if (self.options.onselect) {
157
- self.options.onselect(self.element, self.getDuration(), self.getHumanDuration());
158
- }
159
- });
160
- this._content.button.appendTo(this._content.div);
150
+ this._content.button = $( "<input type='button' />" )
151
+ .val( this._tr( "button_ok" ) );
152
+ this._content.button.addClass(
153
+ "ui-button ui-widget ui-state-default ui-corner-all"
154
+ );
155
+ this._content.button.css( {
156
+ display: "block",
157
+ margin: "0.5em auto",
158
+ padding: "0.5em 1em"
159
+ } );
160
+ this._content.button.hover( function() {
161
+ $( this ).addClass( "ui-state-hover" );
162
+ }, function() {
163
+ $( this ).removeClass( "ui-state-hover" );
164
+ } );
165
+ this._content.button.on( "click", function() {
166
+ self._content.div.fadeOut();
167
+ if ( self.options.onselect ) {
168
+ self.options.onselect(
169
+ self.element, self.getDuration(), self.getHumanDuration()
170
+ );
171
+ }
172
+ } );
173
+ this._content.button.appendTo( this._content.div );
161
174
 
162
- this._initUnits();
175
+ this._initUnits();
163
176
 
164
- instances.push(this);
177
+ instances.push( this );
165
178
  },
166
179
  _initUnits: function() {
167
- var i;
168
- if (this.options.seconds) {
169
- this._content.seconds = this._createSelectWithOptions(0, 59);
170
- this._appendRow(this._tr('seconds'), this._content.seconds);
171
- }
172
- if (this.options.minutes) {
173
- this._content.minutes = this._createSelectWithOptions(0, 59);
174
- this._appendRow(this._tr('minutes'), this._content.minutes);
175
- }
176
- if (this.options.hours) {
177
- this._content.hours = this._createSelectWithOptions(0, 23);
178
- this._appendRow(this._tr('hours'), this._content.hours);
179
- }
180
- if (this.options.days) {
181
- this._content.days = this._createSelectWithOptions(0, 29);
182
- this._appendRow(this._tr('days'), this._content.days);
183
- }
184
- if (this.options.months) {
185
- this._content.months = this._createSelectWithOptions(0, 11);
186
- this._appendRow(this._tr('months'), this._content.months);
187
- }
188
- if (this.options.years) {
189
- this._content.years = this._createSelectWithOptions(0, 10);
190
- this._appendRow(this._tr('years'), this._content.years);
180
+ if ( this.options.seconds ) {
181
+ this._content.seconds = this._createSelectWithOptions( 0, 59 );
182
+ this._appendRow( this._tr( "seconds" ), this._content.seconds );
183
+ }
184
+ if ( this.options.minutes ) {
185
+ this._content.minutes = this._createSelectWithOptions( 0, 59 );
186
+ this._appendRow( this._tr( "minutes" ), this._content.minutes );
187
+ }
188
+ if ( this.options.hours ) {
189
+ this._content.hours = this._createSelectWithOptions( 0, 23 );
190
+ this._appendRow( this._tr( "hours" ), this._content.hours );
191
+ }
192
+ if ( this.options.days ) {
193
+ this._content.days = this._createSelectWithOptions( 0, 29 );
194
+ this._appendRow( this._tr( "days" ), this._content.days );
195
+ }
196
+ if ( this.options.months ) {
197
+ this._content.months = this._createSelectWithOptions( 0, 11 );
198
+ this._appendRow( this._tr( "months" ), this._content.months );
199
+ }
200
+ if ( this.options.years ) {
201
+ this._content.years = this._createSelectWithOptions( 0, 10 );
202
+ this._appendRow( this._tr( "years" ), this._content.years );
203
+ }
204
+ if ( this.options.defaultValue ) {
205
+ var value;
206
+ if ( typeof this.options.defaultValue === "function" ) {
207
+ value = this.options.defaultValue.call( this );
208
+ } else {
209
+ value = this.options.defaultValue;
191
210
  }
192
- if (this.options.defaultValue) {
193
- this.setDuration(this.options.defaultValue);
211
+ if ( this.setDuration( value ) ) {
212
+ this.element.val( this.getHumanDuration() );
194
213
  }
214
+ }
195
215
  },
196
- _createSelectWithOptions: function(min, max) {
197
- var select = $('<select />')
198
- .addClass('ui-widget ui-state-default ui-corner-all')
216
+ _createSelectWithOptions: function( min, max ) {
217
+ var select = $( "<select />" ).addClass(
218
+ "ui-widget ui-state-default ui-corner-all"
219
+ );
199
220
 
200
- select.hover(function() {
201
- $(this).addClass('ui-state-hover');
202
- }, function() {
203
- $(this).removeClass('ui-state-hover');
204
- });
221
+ select.hover( function() {
222
+ $( this ).addClass( "ui-state-hover" );
223
+ }, function() {
224
+ $( this ).removeClass( "ui-state-hover" );
225
+ } );
205
226
 
206
- this._createOptionsForSelect(select, min, max);
207
- return select;
227
+ this._createOptionsForSelect( select, min, max );
228
+ return select;
208
229
  },
209
- _createOptionsForSelect: function(select, min, max) {
210
- for (var i = min; i <= max; ++i) {
211
- select.append($('<option />').val(i).text(i < 10 ? ('0' + i) : i));
230
+ _createOptionsForSelect: function( select, min, max ) {
231
+ for ( var i = min; i <= max; ++i ) {
232
+ select.append( $( "<option />" ).val( i ).text(
233
+ i < 10 ? ( "0" + i ) : i
234
+ ) );
212
235
  }
213
236
  },
214
- _appendRow: function(text, el) {
215
- var row = $('<tr />').appendTo(this._content.tableBody);
216
- $('<td />').css({
217
- width: '50%',
218
- padding: '.5em 1em',
219
- "text-align": 'right',
220
- "vertical-align": 'middle'
221
- }).append($('<strong />')
222
- .text(text))
223
- .appendTo(row);
224
- $('<td />').css({
225
- width: '50%',
226
- padding: '.5em 1em',
227
- "text-align": 'right',
228
- "vertical-align": 'middle'
229
- }).append(el)
230
- .appendTo(row);
237
+ _appendRow: function( text, el ) {
238
+ var row = $( "<tr />" ).appendTo( this._content.tableBody );
239
+ $( "<td />" ).css( {
240
+ width: "50%",
241
+ padding: ".5em 1em",
242
+ "text-align": "right",
243
+ "vertical-align": "middle"
244
+ } ).append( $( "<strong />" )
245
+ .text( text ) )
246
+ .appendTo( row );
247
+ $( "<td />" ).css( {
248
+ width: "50%",
249
+ padding: ".5em 1em",
250
+ "text-align": "right",
251
+ "vertical-align": "middle"
252
+ } ).append( el )
253
+ .appendTo( row );
231
254
  },
232
- _tr: function(key) {
233
- return this._langs[this.options.lang][key];
255
+ _tr: function( key ) {
256
+ return this._langs[ this.options.lang ][ key ];
234
257
  },
235
258
  getSeconds: function() {
236
- return parseInt(this._content.seconds.val());
259
+ return parseInt( this._content.seconds.val() );
237
260
  },
238
261
  getMinutes: function() {
239
- return parseInt(this._content.minutes.val());
262
+ return parseInt( this._content.minutes.val() );
240
263
  },
241
264
  getHours: function() {
242
- return parseInt(this._content.hours.val());
265
+ return parseInt( this._content.hours.val() );
243
266
  },
244
267
  getDays: function() {
245
- return parseInt(this._content.days.val());
268
+ return parseInt( this._content.days.val() );
246
269
  },
247
270
  getMonths: function() {
248
- return parseInt(this._content.months.val());
271
+ return parseInt( this._content.months.val() );
249
272
  },
250
273
  getYears: function() {
251
- return parseInt(this._content.years.val());
274
+ return parseInt( this._content.years.val() );
252
275
  },
253
- setDuration: function(value) {
254
- value = parseInt(value);
255
- if (isNaN(value)) {
276
+ setDuration: function( value ) {
277
+ value = parseInt( value );
278
+ if ( isNaN( value ) ) {
256
279
  return false;
257
280
  }
258
281
 
259
282
  var i;
260
- if (this.options.years) {
261
- i = Math.floor(value / YEAR);
283
+ if ( this.options.years ) {
284
+ i = Math.floor( value / YEAR );
262
285
  value -= i * YEAR;
263
- this._content.years.val(i);
286
+ this._content.years.val( i );
264
287
  }
265
- if (this.options.months) {
266
- i = Math.floor(value / MONTH);
267
- if (i >= 12) {
288
+ if ( this.options.months ) {
289
+ i = Math.floor( value / MONTH );
290
+ if ( i >= 12 ) {
268
291
  i = 0;
269
292
  }
270
293
  value -= i * MONTH;
271
- this._content.months.val(i);
294
+ this._content.months.val( i );
272
295
  }
273
- if (this.options.days) {
274
- i = Math.floor(value / DAY);
275
- if (i >= 30) {
296
+ if ( this.options.days ) {
297
+ i = Math.floor( value / DAY );
298
+ if ( i >= 30 ) {
276
299
  i = 0;
277
300
  }
278
301
  value -= i * DAY;
279
- this._content.days.val(i);
302
+ this._content.days.val( i );
280
303
  }
281
- if (this.options.hours) {
282
- i = Math.floor(value / HOUR);
283
- if (i >= 24) {
304
+ if ( this.options.hours ) {
305
+ i = Math.floor( value / HOUR );
306
+ if ( i >= 24 ) {
284
307
  i = 0;
285
308
  }
286
309
  value -= i * HOUR;
287
- this._content.hours.val(i);
310
+ this._content.hours.val( i );
288
311
  }
289
- if (this.options.minutes) {
290
- i = Math.floor(value / MINUTE);
291
- if (i >= 60) {
312
+ if ( this.options.minutes ) {
313
+ i = Math.floor( value / MINUTE );
314
+ if ( i >= 60 ) {
292
315
  i = 0;
293
316
  }
294
317
  value -= i * MINUTE;
295
- this._content.minutes.val(i);
318
+ this._content.minutes.val( i );
296
319
  }
297
- if (this.options.seconds) {
298
- i = Math.floor(value);
299
- if (i >= 60) {
320
+ if ( this.options.seconds ) {
321
+ i = Math.floor( value );
322
+ if ( i >= 60 ) {
300
323
  i = 0;
301
324
  }
302
- this._content.seconds.val(i);
325
+ this._content.seconds.val( i );
303
326
  }
304
327
  return value;
305
328
  },
306
329
  getDuration: function() {
307
330
  var seconds = 0;
308
- if (this.options.seconds) {
331
+ if ( this.options.seconds ) {
309
332
  seconds += this.getSeconds();
310
333
  }
311
- if (this.options.minutes) {
334
+ if ( this.options.minutes ) {
312
335
  seconds += this.getMinutes() * MINUTE;
313
336
  }
314
- if (this.options.hours) {
337
+ if ( this.options.hours ) {
315
338
  seconds += this.getHours() * HOUR;
316
339
  }
317
- if (this.options.days) {
340
+ if ( this.options.days ) {
318
341
  seconds += this.getDays() * DAY;
319
342
  }
320
- if (this.options.months) {
343
+ if ( this.options.months ) {
321
344
  seconds += this.getMonths() * MONTH;
322
345
  }
323
- if (this.options.years) {
346
+ if ( this.options.years ) {
324
347
  seconds += this.getYears() * YEAR;
325
348
  }
326
349
  return seconds;
327
350
  },
328
351
  getHumanDuration: function() {
329
352
  var units = [];
330
- var duration = '';
353
+ var duration = "";
331
354
 
332
- if (this.options.years && this.getYears() > 0) {
333
- units.push({value: this.getYears(), name: this._tr('human_years')});
355
+ if ( this.options.years && this.getYears() > 0 ) {
356
+ units.push( { value: this.getYears(), name: this._tr( "human_years" ) } );
334
357
  }
335
- if (this.options.months && this.getMonths() > 0) {
336
- units.push({value: this.getMonths(), name: this._tr('human_months')});
358
+ if ( this.options.months && this.getMonths() > 0 ) {
359
+ units.push( { value: this.getMonths(), name: this._tr( "human_months" ) } );
337
360
  }
338
- if (this.options.days && this.getDays() > 0) {
339
- units.push({value: this.getDays(), name: this._tr('human_days')});
361
+ if ( this.options.days && this.getDays() > 0 ) {
362
+ units.push( { value: this.getDays(), name: this._tr( "human_days" ) } );
340
363
  }
341
- if (this.options.hours && this.getHours() > 0) {
342
- units.push({value: this.getHours(), name: this._tr('human_hours')});
364
+ if ( this.options.hours && this.getHours() > 0 ) {
365
+ units.push( { value: this.getHours(), name: this._tr( "human_hours" ) } );
343
366
  }
344
- if (this.options.minutes && this.getMinutes() > 0) {
345
- units.push({value: this.getMinutes(), name: this._tr('human_minutes')});
367
+ if ( this.options.minutes && this.getMinutes() > 0 ) {
368
+ units.push( { value: this.getMinutes(), name: this._tr( "human_minutes" ) } );
346
369
  }
347
- if (this.options.seconds && this.getSeconds() > 0) {
348
- units.push({value: this.getSeconds(), name: this._tr('human_seconds')});
370
+ if ( this.options.seconds && this.getSeconds() > 0 ) {
371
+ units.push( { value: this.getSeconds(), name: this._tr( "human_seconds" ) } );
349
372
  }
350
373
 
351
- for (var i = 0, l = units.length; i < l; ++i) {
352
- var unit = units[i];
353
- var separator = i == l - 1 ? '' : (i == l - 2 ? ' ' + this._tr('and') + ' ' : ', ');
374
+ for ( var i = 0, l = units.length; i < l; ++i ) {
375
+ var unit = units[ i ];
376
+ var end = ( i === l - 2 ? " " + this._tr( "and" ) + " " : ", " );
377
+ end = i === l - 1 ? "" : end;
354
378
 
355
- duration += unit.value + ' ' + unit.name + separator;
379
+ duration += unit.value + " " + unit.name + end;
356
380
  }
357
381
  return duration;
358
382
  }
359
- });
360
- })(jQuery);
383
+ } );
384
+ } )( jQuery );
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-time_duration_picker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikolay Digaev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-31 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler