jquery-time_duration_picker-rails 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -20
- data/lib/jquery/time_duration_picker/rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.timeDurationPicker.js +249 -225
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea6c7d520597c88d78c3e1b62f0ee50279f27065
|
4
|
+
data.tar.gz: d3bb5bd8378bad3c42e7f5c33d3f25b2666be4e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* jQuery TimeDurationPicker Plugin v1.0.
|
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(
|
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:
|
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]
|
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(
|
43
|
-
|
44
|
-
|
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(
|
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]
|
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(
|
73
|
+
|
74
|
+
$.widget( "custom.timeDurationPicker", {
|
71
75
|
options: {
|
72
76
|
},
|
73
77
|
_langs: {
|
74
78
|
en: {
|
75
|
-
seconds:
|
76
|
-
minutes:
|
77
|
-
hours:
|
78
|
-
days:
|
79
|
-
months:
|
80
|
-
years:
|
81
|
-
human_years:
|
82
|
-
human_months:
|
83
|
-
human_days:
|
84
|
-
human_hours:
|
85
|
-
human_minutes:
|
86
|
-
human_seconds:
|
87
|
-
and:
|
88
|
-
button_ok:
|
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
|
-
|
128
|
+
var self = this;
|
125
129
|
|
126
|
-
|
130
|
+
this.options = $.extend(
|
131
|
+
{}, $.timeDurationPicker.defaults, this.options
|
132
|
+
);
|
127
133
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
|
140
|
-
|
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
|
-
|
143
|
-
this.
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
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
|
-
|
175
|
+
this._initUnits();
|
163
176
|
|
164
|
-
|
177
|
+
instances.push( this );
|
165
178
|
},
|
166
179
|
_initUnits: function() {
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
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.
|
193
|
-
this.
|
211
|
+
if ( this.setDuration( value ) ) {
|
212
|
+
this.element.val( this.getHumanDuration() );
|
194
213
|
}
|
214
|
+
}
|
195
215
|
},
|
196
|
-
_createSelectWithOptions: function(min, max) {
|
197
|
-
|
198
|
-
|
216
|
+
_createSelectWithOptions: function( min, max ) {
|
217
|
+
var select = $( "<select />" ).addClass(
|
218
|
+
"ui-widget ui-state-default ui-corner-all"
|
219
|
+
);
|
199
220
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
221
|
+
select.hover( function() {
|
222
|
+
$( this ).addClass( "ui-state-hover" );
|
223
|
+
}, function() {
|
224
|
+
$( this ).removeClass( "ui-state-hover" );
|
225
|
+
} );
|
205
226
|
|
206
|
-
|
207
|
-
|
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($(
|
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 = $(
|
216
|
-
$(
|
217
|
-
width:
|
218
|
-
padding:
|
219
|
-
"text-align":
|
220
|
-
"vertical-align":
|
221
|
-
}).append($(
|
222
|
-
.text(text))
|
223
|
-
.appendTo(row);
|
224
|
-
$(
|
225
|
-
width:
|
226
|
-
padding:
|
227
|
-
"text-align":
|
228
|
-
"vertical-align":
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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
|
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 +
|
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.
|
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-
|
11
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|