active_frontend 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +97 -0
  6. data/Rakefile +1 -0
  7. data/active_frontend.gemspec +23 -0
  8. data/app/assets/fonts/gotham/gotham-bold.eot +0 -0
  9. data/app/assets/fonts/gotham/gotham-bold.svg +2066 -0
  10. data/app/assets/fonts/gotham/gotham-bold.ttf +0 -0
  11. data/app/assets/fonts/gotham/gotham-bold.woff +0 -0
  12. data/app/assets/fonts/gotham/gotham-book.eot +0 -0
  13. data/app/assets/fonts/gotham/gotham-book.svg +631 -0
  14. data/app/assets/fonts/gotham/gotham-book.ttf +0 -0
  15. data/app/assets/fonts/gotham/gotham-book.woff +0 -0
  16. data/app/assets/fonts/gotham/gotham-light.eot +0 -0
  17. data/app/assets/fonts/gotham/gotham-light.svg +635 -0
  18. data/app/assets/fonts/gotham/gotham-light.ttf +0 -0
  19. data/app/assets/fonts/gotham/gotham-light.woff +0 -0
  20. data/app/assets/fonts/gotham/gotham-medium.eot +0 -0
  21. data/app/assets/fonts/gotham/gotham-medium.svg +629 -0
  22. data/app/assets/fonts/gotham/gotham-medium.ttf +0 -0
  23. data/app/assets/fonts/gotham/gotham-medium.woff +0 -0
  24. data/app/assets/fonts/ionicons/ionicons.eot +0 -0
  25. data/app/assets/fonts/ionicons/ionicons.svg +2232 -0
  26. data/app/assets/fonts/ionicons/ionicons.ttf +0 -0
  27. data/app/assets/fonts/ionicons/ionicons.woff +0 -0
  28. data/lib/active_frontend.rb +6 -0
  29. data/lib/active_frontend/version.rb +3 -0
  30. data/vendor/assets/javascripts/.keep +0 -0
  31. data/vendor/assets/javascripts/affix.js +153 -0
  32. data/vendor/assets/javascripts/alert.js +85 -0
  33. data/vendor/assets/javascripts/animation.js +45 -0
  34. data/vendor/assets/javascripts/button.js +107 -0
  35. data/vendor/assets/javascripts/carousel.js +228 -0
  36. data/vendor/assets/javascripts/chart.js +3309 -0
  37. data/vendor/assets/javascripts/collapse.js +202 -0
  38. data/vendor/assets/javascripts/date_picker.js +1649 -0
  39. data/vendor/assets/javascripts/dropdown.js +152 -0
  40. data/vendor/assets/javascripts/file_input.js +71 -0
  41. data/vendor/assets/javascripts/hoverdown.js +109 -0
  42. data/vendor/assets/javascripts/map.js +2174 -0
  43. data/vendor/assets/javascripts/modal.js +234 -0
  44. data/vendor/assets/javascripts/popover.js +99 -0
  45. data/vendor/assets/javascripts/scrollspy.js +163 -0
  46. data/vendor/assets/javascripts/sort.js +1432 -0
  47. data/vendor/assets/javascripts/swoggle.js +415 -0
  48. data/vendor/assets/javascripts/tab.js +144 -0
  49. data/vendor/assets/javascripts/tablespy.js +1883 -0
  50. data/vendor/assets/javascripts/time_ago.js +206 -0
  51. data/vendor/assets/javascripts/time_picker.js +1087 -0
  52. data/vendor/assets/javascripts/tooltip.js +466 -0
  53. data/vendor/assets/javascripts/transition.js +50 -0
  54. data/vendor/assets/javascripts/typeahead.js +368 -0
  55. data/vendor/assets/stylesheets/.keep +0 -0
  56. data/vendor/assets/stylesheets/ad.scss +72 -0
  57. data/vendor/assets/stylesheets/affix.scss +11 -0
  58. data/vendor/assets/stylesheets/alert.scss +57 -0
  59. data/vendor/assets/stylesheets/animation.scss +2388 -0
  60. data/vendor/assets/stylesheets/aside.scss +136 -0
  61. data/vendor/assets/stylesheets/breadcrumb.scss +23 -0
  62. data/vendor/assets/stylesheets/button.scss +581 -0
  63. data/vendor/assets/stylesheets/carousel.scss +152 -0
  64. data/vendor/assets/stylesheets/chart.scss +11 -0
  65. data/vendor/assets/stylesheets/code.scss +139 -0
  66. data/vendor/assets/stylesheets/collapse.scss +15 -0
  67. data/vendor/assets/stylesheets/datepicker.scss +136 -0
  68. data/vendor/assets/stylesheets/dropdown.scss +90 -0
  69. data/vendor/assets/stylesheets/footer.scss +68 -0
  70. data/vendor/assets/stylesheets/form.scss +346 -0
  71. data/vendor/assets/stylesheets/grid.scss +287 -0
  72. data/vendor/assets/stylesheets/header.scss +205 -0
  73. data/vendor/assets/stylesheets/icon.scss +1538 -0
  74. data/vendor/assets/stylesheets/image.scss +330 -0
  75. data/vendor/assets/stylesheets/label_and_badge.scss +110 -0
  76. data/vendor/assets/stylesheets/link.scss +25 -0
  77. data/vendor/assets/stylesheets/list.scss +60 -0
  78. data/vendor/assets/stylesheets/map.scss +13 -0
  79. data/vendor/assets/stylesheets/modal.scss +137 -0
  80. data/vendor/assets/stylesheets/nav_and_tab.scss +183 -0
  81. data/vendor/assets/stylesheets/pagination.scss +41 -0
  82. data/vendor/assets/stylesheets/panel.scss +62 -0
  83. data/vendor/assets/stylesheets/placeholder.scss +44 -0
  84. data/vendor/assets/stylesheets/popover.scss +117 -0
  85. data/vendor/assets/stylesheets/progress.scss +43 -0
  86. data/vendor/assets/stylesheets/reset.scss +88 -0
  87. data/vendor/assets/stylesheets/spinner.scss +767 -0
  88. data/vendor/assets/stylesheets/swoggle.scss +126 -0
  89. data/vendor/assets/stylesheets/table.scss +149 -0
  90. data/vendor/assets/stylesheets/timepicker.scss +75 -0
  91. data/vendor/assets/stylesheets/tooltip.scss +90 -0
  92. data/vendor/assets/stylesheets/transition.scss +12 -0
  93. data/vendor/assets/stylesheets/trunk.scss +116 -0
  94. data/vendor/assets/stylesheets/typeahead.scss +8 -0
  95. data/vendor/assets/stylesheets/typography.scss +191 -0
  96. metadata +167 -0
@@ -0,0 +1,206 @@
1
+ (function() {
2
+ var TimeAgo;
3
+
4
+ TimeAgo = (function() {
5
+ function TimeAgo(element, options) {
6
+ this.$element = $(element);
7
+ this.options = $.extend({}, $.fn.timeago.defaults, options);
8
+ this.refresh();
9
+ }
10
+
11
+ TimeAgo.prototype.startTimer = function() {
12
+ return this.interval = setTimeout((function(_this) {
13
+ return function() {
14
+ return _this.refresh();
15
+ };
16
+ })(this), this.startInterval);
17
+ };
18
+
19
+ TimeAgo.prototype.stopTimer = function() {
20
+ return clearTimeout(this.interval);
21
+ };
22
+
23
+ TimeAgo.prototype.restartTimer = function() {
24
+ this.stopTimer();
25
+ return this.startTimer();
26
+ };
27
+
28
+ TimeAgo.prototype.refresh = function() {
29
+ this.updateTime();
30
+ return this.updateInterval();
31
+ };
32
+
33
+ TimeAgo.prototype.updateTime = function() {
34
+ var timeAgoInWords;
35
+ timeAgoInWords = this.timeAgoInWords(this.$element.attr(this.options.attr));
36
+ return this.$element.html(timeAgoInWords);
37
+ };
38
+
39
+ TimeAgo.prototype.updateInterval = function() {
40
+ var dis, newestTime, newestTimeSrc;
41
+ newestTimeSrc = this.$element.attr(this.options.attr);
42
+ newestTime = this.parse(newestTimeSrc);
43
+ dis = this.getTimeDistanceInSeconds(newestTime);
44
+ if (this.options.maxRelative && dis >= this.options.maxRelative) {
45
+ return this.stopTimer();
46
+ } else if (this.options.showNow && dis < this.options.showNow) {
47
+ this.startInterval = (this.options.showNow - dis) * 1000;
48
+ return this.restartTimer();
49
+ } else if (this.options.showSeconds && dis < 60) {
50
+ this.startInterval = 1000;
51
+ return this.restartTimer();
52
+ } else if (dis < 2700) {
53
+ this.startInterval = (60 - dis % 60) * 1000;
54
+ return this.restartTimer();
55
+ } else if (dis < 5400) {
56
+ this.startInterval = (5400 - dis) * 1000;
57
+ return this.restartTimer();
58
+ } else if (dis < 151200) {
59
+ this.startInterval = (3600 - dis % 3600) * 1000;
60
+ return this.restartTimer();
61
+ } else {
62
+ this.startInterval = (86400 - dis % 86400) * 1000;
63
+ return this.restartTimer();
64
+ }
65
+ };
66
+
67
+ TimeAgo.prototype.timeAgoInWords = function(timeString) {
68
+ var absolutTime, dis;
69
+ absolutTime = this.parse(timeString);
70
+ dis = this.getTimeDistanceInSeconds(absolutTime);
71
+ if (this.options.showNow && this.options.showNow > dis) {
72
+ return this.options.lang.prefixes.now;
73
+ } else if (this.options.maxRelative && this.options.maxRelative <= dis) {
74
+ return this.options.absoluteDate(absolutTime, timeString);
75
+ } else {
76
+ return this.options.relativeDate(this.options.lang.prefixes.ago, this.distanceOfTimeInWords(dis), this.options.suffix || this.options.lang.suffix);
77
+ }
78
+ };
79
+
80
+ TimeAgo.prototype.parse = function(iso8601) {
81
+ var timeStr;
82
+ timeStr = $.trim(iso8601);
83
+ timeStr = timeStr.replace(/\.\d+/, "");
84
+ timeStr = timeStr.replace(/-/, "/").replace(/-/, "/");
85
+ timeStr = timeStr.replace(/T/, " ").replace(/Z/, " UTC");
86
+ timeStr = timeStr.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2");
87
+ return new Date(timeStr);
88
+ };
89
+
90
+ TimeAgo.prototype.getTimeDistanceInSeconds = function(absolutTime) {
91
+ var timeDistance;
92
+ timeDistance = new Date().getTime() - absolutTime.getTime();
93
+ return Math.round(Math.abs(timeDistance) / 1000);
94
+ };
95
+
96
+ TimeAgo.prototype.distanceOfTimeInWords = function(dis) {
97
+ var space;
98
+ space = this.options.spacing ? ' ' : '';
99
+ if (dis < 60) {
100
+ if (this.options.showSeconds) {
101
+ if (dis === 0 || dis === 1) {
102
+ return "1" + space + this.options.lang.units.second;
103
+ } else {
104
+ return "" + dis + space + this.options.lang.units.seconds;
105
+ }
106
+ } else {
107
+ return "" + (this.options.approximate ? this.options.lang.prefixes.lt + " " : "1" + space) + this.options.lang.units.minute;
108
+ }
109
+ } else if (dis < 120) {
110
+ return "1" + space + this.options.lang.units.minute;
111
+ } else if (dis < 2700) {
112
+ return "" + (Math.round(dis / 60)) + space + this.options.lang.units.minutes;
113
+ } else if (dis < 5400) {
114
+ return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + "1" + space + this.options.lang.units.hour;
115
+ } else if (dis < 86400) {
116
+ return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + (Math.round(dis / 3600)) + space + this.options.lang.units.hours;
117
+ } else if (dis < 151200) {
118
+ return "1" + space + this.options.lang.units.day;
119
+ } else if (dis < 2592000) {
120
+ return "" + (Math.round(dis / 86400)) + space + this.options.lang.units.days;
121
+ } else if (dis < 5184000) {
122
+ return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + "1" + space + this.options.lang.units.month;
123
+ } else if (dis < 31536000) {
124
+ return "" + (Math.round(dis / 2592000)) + space + this.options.lang.units.months;
125
+ } else if (dis < 39312000) {
126
+ return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + "1" + space + this.options.lang.units.year;
127
+ } else if (dis < 54864000) {
128
+ return "" + (this.options.approximate ? this.options.lang.prefixes.over + " " : "") + "1" + space + this.options.lang.units.year;
129
+ } else if (dis < 63072000) {
130
+ return "" + (this.options.approximate ? this.options.lang.prefixes.almost + " " : "") + "2" + space + this.options.lang.units.years;
131
+ } else {
132
+ return "" + (this.options.approximate ? this.options.lang.prefixes.about + " " : "") + (Math.round(dis / 31536000)) + space + this.options.lang.units.years;
133
+ }
134
+ };
135
+
136
+ return TimeAgo;
137
+
138
+ })();
139
+
140
+ $.fn.timeago = function(options) {
141
+ if (options == null) {
142
+ options = {};
143
+ }
144
+ return this.each(function() {
145
+ var $this, attr, data;
146
+ $this = $(this);
147
+ attr = $this.attr(options.attr || $.fn.timeago.defaults.attr);
148
+ if (attr === void 0 || attr === false) {
149
+ return;
150
+ }
151
+ data = $this.data("timeago");
152
+ if (!data) {
153
+ return $this.data("timeago", new TimeAgo(this, options));
154
+ } else if (typeof options === 'string') {
155
+ return data[options]();
156
+ }
157
+ });
158
+ };
159
+
160
+ $.fn.findAndSelf = function(selector) {
161
+ return this.find(selector).add(this.filter(selector));
162
+ };
163
+
164
+ $.fn.timeago.Constructor = TimeAgo;
165
+
166
+ $.fn.timeago.defaults = {
167
+ attr: 'datetime',
168
+ spacing: true,
169
+ approximate: true,
170
+ showSeconds: false,
171
+ showNow: false,
172
+ maxRelative: false,
173
+ absoluteDate: function(date, datetime) {
174
+ return datetime;
175
+ },
176
+ relativeDate: function(prefix, distance, suffix) {
177
+ return "" + prefix + distance + suffix;
178
+ },
179
+ lang: {
180
+ units: {
181
+ second: "second",
182
+ seconds: "seconds",
183
+ minute: "minute",
184
+ minutes: "minutes",
185
+ hour: "hour",
186
+ hours: "hours",
187
+ day: "day",
188
+ days: "days",
189
+ month: "month",
190
+ months: "months",
191
+ year: "year",
192
+ years: "years"
193
+ },
194
+ prefixes: {
195
+ now: "just now",
196
+ lt: "less than a",
197
+ about: "about",
198
+ over: "over",
199
+ almost: "almost",
200
+ ago: ""
201
+ },
202
+ suffix: ' ago'
203
+ }
204
+ };
205
+
206
+ }).call(this);
@@ -0,0 +1,1087 @@
1
+ (function($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ // TIMEPICKER PUBLIC CLASS DEFINITION
5
+ var Timepicker = function(element, options) {
6
+ this.widget = '';
7
+ this.$element = $(element);
8
+ this.defaultTime = options.defaultTime;
9
+ this.disableFocus = options.disableFocus;
10
+ this.disableMousewheel = options.disableMousewheel;
11
+ this.isOpen = options.isOpen;
12
+ this.minuteStep = options.minuteStep;
13
+ this.modalBackdrop = options.modalBackdrop;
14
+ this.orientation = options.orientation;
15
+ this.secondStep = options.secondStep;
16
+ this.showInputs = options.showInputs;
17
+ this.showMeridian = options.showMeridian;
18
+ this.showSeconds = options.showSeconds;
19
+ this.template = options.template;
20
+ this.appendWidgetTo = options.appendWidgetTo;
21
+ this.showWidgetOnAddonClick = options.showWidgetOnAddonClick;
22
+
23
+ this._init();
24
+ };
25
+
26
+ Timepicker.prototype = {
27
+
28
+ constructor: Timepicker,
29
+ _init: function() {
30
+ var self = this;
31
+
32
+ if (this.showWidgetOnAddonClick && (this.$element.parent().hasClass('input-append') || this.$element.parent().hasClass('input-prepend'))) {
33
+ this.$element.parent('.input-append, .input-prepend').find('.add-on').on({
34
+ 'click.timepicker': $.proxy(this.showWidget, this)
35
+ });
36
+ this.$element.on({
37
+ 'focus.timepicker': $.proxy(this.highlightUnit, this),
38
+ 'click.timepicker': $.proxy(this.highlightUnit, this),
39
+ 'keydown.timepicker': $.proxy(this.elementKeydown, this),
40
+ 'blur.timepicker': $.proxy(this.blurElement, this),
41
+ 'mousewheel.timepicker DOMMouseScroll.timepicker': $.proxy(this.mousewheel, this)
42
+ });
43
+ } else {
44
+ if (this.template) {
45
+ this.$element.on({
46
+ 'focus.timepicker': $.proxy(this.showWidget, this),
47
+ 'click.timepicker': $.proxy(this.showWidget, this),
48
+ 'blur.timepicker': $.proxy(this.blurElement, this),
49
+ 'mousewheel.timepicker DOMMouseScroll.timepicker': $.proxy(this.mousewheel, this)
50
+ });
51
+ } else {
52
+ this.$element.on({
53
+ 'focus.timepicker': $.proxy(this.highlightUnit, this),
54
+ 'click.timepicker': $.proxy(this.highlightUnit, this),
55
+ 'keydown.timepicker': $.proxy(this.elementKeydown, this),
56
+ 'blur.timepicker': $.proxy(this.blurElement, this),
57
+ 'mousewheel.timepicker DOMMouseScroll.timepicker': $.proxy(this.mousewheel, this)
58
+ });
59
+ }
60
+ }
61
+
62
+ if (this.template !== false) {
63
+ this.$widget = $(this.getTemplate()).on('click', $.proxy(this.widgetClick, this));
64
+ } else {
65
+ this.$widget = false;
66
+ }
67
+
68
+ if (this.showInputs && this.$widget !== false) {
69
+ this.$widget.find('input').each(function() {
70
+ $(this).on({
71
+ 'click.timepicker': function() { $(this).select(); },
72
+ 'keydown.timepicker': $.proxy(self.widgetKeydown, self),
73
+ 'keyup.timepicker': $.proxy(self.widgetKeyup, self)
74
+ });
75
+ });
76
+ }
77
+
78
+ this.setDefaultTime(this.defaultTime);
79
+ },
80
+
81
+ blurElement: function() {
82
+ this.highlightedUnit = null;
83
+ this.updateFromElementVal();
84
+ },
85
+
86
+ clear: function() {
87
+ this.hour = '';
88
+ this.minute = '';
89
+ this.second = '';
90
+ this.meridian = '';
91
+
92
+ this.$element.val('');
93
+ },
94
+
95
+ decrementHour: function() {
96
+ if (this.showMeridian) {
97
+ if (this.hour === 1) {
98
+ this.hour = 12;
99
+ } else if (this.hour === 12) {
100
+ this.hour--;
101
+
102
+ return this.toggleMeridian();
103
+ } else if (this.hour === 0) {
104
+ this.hour = 11;
105
+
106
+ return this.toggleMeridian();
107
+ } else {
108
+ this.hour--;
109
+ }
110
+ } else {
111
+ if (this.hour <= 0) {
112
+ this.hour = 23;
113
+ } else {
114
+ this.hour--;
115
+ }
116
+ }
117
+ },
118
+
119
+ decrementMinute: function(step) {
120
+ var newVal;
121
+
122
+ if (step) {
123
+ newVal = this.minute - step;
124
+ } else {
125
+ newVal = this.minute - this.minuteStep;
126
+ }
127
+
128
+ if (newVal < 0) {
129
+ this.decrementHour();
130
+ this.minute = newVal + 60;
131
+ } else {
132
+ this.minute = newVal;
133
+ }
134
+ },
135
+
136
+ decrementSecond: function() {
137
+ var newVal = this.second - this.secondStep;
138
+
139
+ if (newVal < 0) {
140
+ this.decrementMinute(true);
141
+ this.second = newVal + 60;
142
+ } else {
143
+ this.second = newVal;
144
+ }
145
+ },
146
+
147
+ elementKeydown: function(e) {
148
+ switch (e.keyCode) {
149
+ case 9: //tab
150
+ case 27: // escape
151
+ this.updateFromElementVal();
152
+ break;
153
+ case 37: // left arrow
154
+ e.preventDefault();
155
+ this.highlightPrevUnit();
156
+ break;
157
+ case 38: // up arrow
158
+ e.preventDefault();
159
+ switch (this.highlightedUnit) {
160
+ case 'hour':
161
+ this.incrementHour();
162
+ this.highlightHour();
163
+ break;
164
+ case 'minute':
165
+ this.incrementMinute();
166
+ this.highlightMinute();
167
+ break;
168
+ case 'second':
169
+ this.incrementSecond();
170
+ this.highlightSecond();
171
+ break;
172
+ case 'meridian':
173
+ this.toggleMeridian();
174
+ this.highlightMeridian();
175
+ break;
176
+ }
177
+ this.update();
178
+ break;
179
+ case 39: // right arrow
180
+ e.preventDefault();
181
+ this.highlightNextUnit();
182
+ break;
183
+ case 40: // down arrow
184
+ e.preventDefault();
185
+ switch (this.highlightedUnit) {
186
+ case 'hour':
187
+ this.decrementHour();
188
+ this.highlightHour();
189
+ break;
190
+ case 'minute':
191
+ this.decrementMinute();
192
+ this.highlightMinute();
193
+ break;
194
+ case 'second':
195
+ this.decrementSecond();
196
+ this.highlightSecond();
197
+ break;
198
+ case 'meridian':
199
+ this.toggleMeridian();
200
+ this.highlightMeridian();
201
+ break;
202
+ }
203
+
204
+ this.update();
205
+ break;
206
+ }
207
+ },
208
+
209
+ getCursorPosition: function() {
210
+ var input = this.$element.get(0);
211
+
212
+ if ('selectionStart' in input) {// Standard-compliant browsers
213
+
214
+ return input.selectionStart;
215
+ } else if (document.selection) {// IE fix
216
+ input.focus();
217
+ var sel = document.selection.createRange(),
218
+ selLen = document.selection.createRange().text.length;
219
+
220
+ sel.moveStart('character', - input.value.length);
221
+
222
+ return sel.text.length - selLen;
223
+ }
224
+ },
225
+
226
+ getTemplate: function() {
227
+ var template,
228
+ hourTemplate,
229
+ minuteTemplate,
230
+ secondTemplate,
231
+ meridianTemplate,
232
+ templateContent;
233
+
234
+ if (this.showInputs) {
235
+ hourTemplate = '<input type="text" class="timepicker-hour" maxlength="2"/>';
236
+ minuteTemplate = '<input type="text" class="timepicker-minute" maxlength="2"/>';
237
+ secondTemplate = '<input type="text" class="timepicker-second" maxlength="2"/>';
238
+ meridianTemplate = '<input type="text" class="timepicker-meridian" maxlength="2"/>';
239
+ } else {
240
+ hourTemplate = '<span class="timepicker-hour"></span>';
241
+ minuteTemplate = '<span class="timepicker-minute"></span>';
242
+ secondTemplate = '<span class="timepicker-second"></span>';
243
+ meridianTemplate = '<span class="timepicker-meridian"></span>';
244
+ }
245
+
246
+ templateContent = '<table>'+
247
+ '<tr>'+
248
+ '<td><a href="#" data-action="incrementHour"><i class="icon-chevron-up"></i></a></td>'+
249
+ '<td class="separator">&nbsp;</td>'+
250
+ '<td><a href="#" data-action="incrementMinute"><i class="icon-chevron-up"></i></a></td>'+
251
+ (this.showSeconds ?
252
+ '<td class="separator">&nbsp;</td>'+
253
+ '<td><a href="#" data-action="incrementSecond"><i class="icon-chevron-up"></i></a></td>'
254
+ : '') +
255
+ (this.showMeridian ?
256
+ '<td class="separator">&nbsp;</td>'+
257
+ '<td class="meridian-column"><a href="#" data-action="toggleMeridian"><i class="icon-chevron-up"></i></a></td>'
258
+ : '') +
259
+ '</tr>'+
260
+ '<tr>'+
261
+ '<td>'+ hourTemplate +'</td> '+
262
+ '<td class="separator">:</td>'+
263
+ '<td>'+ minuteTemplate +'</td> '+
264
+ (this.showSeconds ?
265
+ '<td class="separator">:</td>'+
266
+ '<td>'+ secondTemplate +'</td>'
267
+ : '') +
268
+ (this.showMeridian ?
269
+ '<td class="separator">&nbsp;</td>'+
270
+ '<td>'+ meridianTemplate +'</td>'
271
+ : '') +
272
+ '</tr>'+
273
+ '<tr>'+
274
+ '<td><a href="#" data-action="decrementHour"><i class="icon-chevron-down"></i></a></td>'+
275
+ '<td class="separator"></td>'+
276
+ '<td><a href="#" data-action="decrementMinute"><i class="icon-chevron-down"></i></a></td>'+
277
+ (this.showSeconds ?
278
+ '<td class="separator">&nbsp;</td>'+
279
+ '<td><a href="#" data-action="decrementSecond"><i class="icon-chevron-down"></i></a></td>'
280
+ : '') +
281
+ (this.showMeridian ?
282
+ '<td class="separator">&nbsp;</td>'+
283
+ '<td><a href="#" data-action="toggleMeridian"><i class="icon-chevron-down"></i></a></td>'
284
+ : '') +
285
+ '</tr>'+
286
+ '</table>';
287
+
288
+ switch(this.template) {
289
+ case 'modal':
290
+ template = '<div class="timepicker-widget modal hide fade in" data-backdrop="'+ (this.modalBackdrop ? 'true' : 'false') +'">'+
291
+ '<div class="modal-header">'+
292
+ '<a href="#" class="close" data-dismiss="modal">×</a>'+
293
+ '<h3>Pick a Time</h3>'+
294
+ '</div>'+
295
+ '<div class="modal-content">'+
296
+ templateContent +
297
+ '</div>'+
298
+ '<div class="modal-footer">'+
299
+ '<a href="#" class="btn btn-primary" data-dismiss="modal">OK</a>'+
300
+ '</div>'+
301
+ '</div>';
302
+ break;
303
+ case 'dropdown':
304
+ template = '<div class="timepicker-widget dropdown-menu">'+ templateContent +'</div>';
305
+ break;
306
+ }
307
+
308
+ return template;
309
+ },
310
+
311
+ getTime: function() {
312
+ if (this.hour === '') {
313
+ return '';
314
+ }
315
+
316
+ return this.hour + ':' + (this.minute.toString().length === 1 ? '0' + this.minute : this.minute) + (this.showSeconds ? ':' + (this.second.toString().length === 1 ? '0' + this.second : this.second) : '') + (this.showMeridian ? ' ' + this.meridian : '');
317
+ },
318
+
319
+ hideWidget: function() {
320
+ if (this.isOpen === false) {
321
+ return;
322
+ }
323
+
324
+ this.$element.trigger({
325
+ 'type': 'hide.timepicker',
326
+ 'time': {
327
+ 'value': this.getTime(),
328
+ 'hours': this.hour,
329
+ 'minutes': this.minute,
330
+ 'seconds': this.second,
331
+ 'meridian': this.meridian
332
+ }
333
+ });
334
+
335
+ if (this.template === 'modal' && this.$widget.modal) {
336
+ this.$widget.modal('hide');
337
+ } else {
338
+ this.$widget.removeClass('open');
339
+ }
340
+
341
+ $(document).off('mousedown.timepicker, touchend.timepicker');
342
+
343
+ this.isOpen = false;
344
+ // show/hide approach taken by datepicker
345
+ this.$widget.detach();
346
+ },
347
+
348
+ highlightUnit: function() {
349
+ this.position = this.getCursorPosition();
350
+ if (this.position >= 0 && this.position <= 2) {
351
+ this.highlightHour();
352
+ } else if (this.position >= 3 && this.position <= 5) {
353
+ this.highlightMinute();
354
+ } else if (this.position >= 6 && this.position <= 8) {
355
+ if (this.showSeconds) {
356
+ this.highlightSecond();
357
+ } else {
358
+ this.highlightMeridian();
359
+ }
360
+ } else if (this.position >= 9 && this.position <= 11) {
361
+ this.highlightMeridian();
362
+ }
363
+ },
364
+
365
+ highlightNextUnit: function() {
366
+ switch (this.highlightedUnit) {
367
+ case 'hour':
368
+ this.highlightMinute();
369
+ break;
370
+ case 'minute':
371
+ if (this.showSeconds) {
372
+ this.highlightSecond();
373
+ } else if (this.showMeridian){
374
+ this.highlightMeridian();
375
+ } else {
376
+ this.highlightHour();
377
+ }
378
+ break;
379
+ case 'second':
380
+ if (this.showMeridian) {
381
+ this.highlightMeridian();
382
+ } else {
383
+ this.highlightHour();
384
+ }
385
+ break;
386
+ case 'meridian':
387
+ this.highlightHour();
388
+ break;
389
+ }
390
+ },
391
+
392
+ highlightPrevUnit: function() {
393
+ switch (this.highlightedUnit) {
394
+ case 'hour':
395
+ if(this.showMeridian){
396
+ this.highlightMeridian();
397
+ } else if (this.showSeconds) {
398
+ this.highlightSecond();
399
+ } else {
400
+ this.highlightMinute();
401
+ }
402
+ break;
403
+ case 'minute':
404
+ this.highlightHour();
405
+ break;
406
+ case 'second':
407
+ this.highlightMinute();
408
+ break;
409
+ case 'meridian':
410
+ if (this.showSeconds) {
411
+ this.highlightSecond();
412
+ } else {
413
+ this.highlightMinute();
414
+ }
415
+ break;
416
+ }
417
+ },
418
+
419
+ highlightHour: function() {
420
+ var $element = this.$element.get(0),
421
+ self = this;
422
+
423
+ this.highlightedUnit = 'hour';
424
+
425
+ if ($element.setSelectionRange) {
426
+ setTimeout(function() {
427
+ if (self.hour < 10) {
428
+ $element.setSelectionRange(0,1);
429
+ } else {
430
+ $element.setSelectionRange(0,2);
431
+ }
432
+ }, 0);
433
+ }
434
+ },
435
+
436
+ highlightMinute: function() {
437
+ var $element = this.$element.get(0),
438
+ self = this;
439
+
440
+ this.highlightedUnit = 'minute';
441
+
442
+ if ($element.setSelectionRange) {
443
+ setTimeout(function() {
444
+ if (self.hour < 10) {
445
+ $element.setSelectionRange(2,4);
446
+ } else {
447
+ $element.setSelectionRange(3,5);
448
+ }
449
+ }, 0);
450
+ }
451
+ },
452
+
453
+ highlightSecond: function() {
454
+ var $element = this.$element.get(0),
455
+ self = this;
456
+
457
+ this.highlightedUnit = 'second';
458
+
459
+ if ($element.setSelectionRange) {
460
+ setTimeout(function() {
461
+ if (self.hour < 10) {
462
+ $element.setSelectionRange(5,7);
463
+ } else {
464
+ $element.setSelectionRange(6,8);
465
+ }
466
+ }, 0);
467
+ }
468
+ },
469
+
470
+ highlightMeridian: function() {
471
+ var $element = this.$element.get(0),
472
+ self = this;
473
+
474
+ this.highlightedUnit = 'meridian';
475
+
476
+ if ($element.setSelectionRange) {
477
+ if (this.showSeconds) {
478
+ setTimeout(function() {
479
+ if (self.hour < 10) {
480
+ $element.setSelectionRange(8,10);
481
+ } else {
482
+ $element.setSelectionRange(9,11);
483
+ }
484
+ }, 0);
485
+ } else {
486
+ setTimeout(function() {
487
+ if (self.hour < 10) {
488
+ $element.setSelectionRange(5,7);
489
+ } else {
490
+ $element.setSelectionRange(6,8);
491
+ }
492
+ }, 0);
493
+ }
494
+ }
495
+ },
496
+
497
+ incrementHour: function() {
498
+ if (this.showMeridian) {
499
+ if (this.hour === 11) {
500
+ this.hour++;
501
+ return this.toggleMeridian();
502
+ } else if (this.hour === 12) {
503
+ this.hour = 0;
504
+ }
505
+ }
506
+ if (this.hour === 23) {
507
+ this.hour = 0;
508
+
509
+ return;
510
+ }
511
+ this.hour++;
512
+ },
513
+
514
+ incrementMinute: function(step) {
515
+ var newVal;
516
+
517
+ if (step) {
518
+ newVal = this.minute + step;
519
+ } else {
520
+ newVal = this.minute + this.minuteStep - (this.minute % this.minuteStep);
521
+ }
522
+
523
+ if (newVal > 59) {
524
+ this.incrementHour();
525
+ this.minute = newVal - 60;
526
+ } else {
527
+ this.minute = newVal;
528
+ }
529
+ },
530
+
531
+ incrementSecond: function() {
532
+ var newVal = this.second + this.secondStep - (this.second % this.secondStep);
533
+
534
+ if (newVal > 59) {
535
+ this.incrementMinute(true);
536
+ this.second = newVal - 60;
537
+ } else {
538
+ this.second = newVal;
539
+ }
540
+ },
541
+
542
+ mousewheel: function(e) {
543
+ if (this.disableMousewheel) {
544
+ return;
545
+ }
546
+
547
+ e.preventDefault();
548
+ e.stopPropagation();
549
+
550
+ var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail,
551
+ scrollTo = null;
552
+
553
+ if (e.type === 'mousewheel') {
554
+ scrollTo = (e.originalEvent.wheelDelta * -1);
555
+ }
556
+ else if (e.type === 'DOMMouseScroll') {
557
+ scrollTo = 40 * e.originalEvent.detail;
558
+ }
559
+
560
+ if (scrollTo) {
561
+ e.preventDefault();
562
+ $(this).scrollTop(scrollTo + $(this).scrollTop());
563
+ }
564
+
565
+ switch (this.highlightedUnit) {
566
+ case 'minute':
567
+ if (delta > 0) {
568
+ this.incrementMinute();
569
+ } else {
570
+ this.decrementMinute();
571
+ }
572
+ this.highlightMinute();
573
+ break;
574
+ case 'second':
575
+ if (delta > 0) {
576
+ this.incrementSecond();
577
+ } else {
578
+ this.decrementSecond();
579
+ }
580
+ this.highlightSecond();
581
+ break;
582
+ case 'meridian':
583
+ this.toggleMeridian();
584
+ this.highlightMeridian();
585
+ break;
586
+ default:
587
+ if (delta > 0) {
588
+ this.incrementHour();
589
+ } else {
590
+ this.decrementHour();
591
+ }
592
+ this.highlightHour();
593
+ break;
594
+ }
595
+
596
+ return false;
597
+ },
598
+
599
+ // This method was adapted from datepicker.
600
+ place : function() {
601
+ if (this.isInline) {
602
+ return;
603
+ }
604
+ var widgetWidth = this.$widget.outerWidth(), widgetHeight = this.$widget.outerHeight(), visualPadding = 10, windowWidth =
605
+ $(window).width(), windowHeight = $(window).height(), scrollTop = $(window).scrollTop();
606
+
607
+ var zIndex = parseInt(this.$element.parents().filter(function() {}).first().css('z-index'), 10) + 10;
608
+ var offset = this.component ? this.component.parent().offset() : this.$element.offset();
609
+ var height = this.component ? this.component.outerHeight(true) : this.$element.outerHeight(false);
610
+ var width = this.component ? this.component.outerWidth(true) : this.$element.outerWidth(false);
611
+ var left = offset.left, top = offset.top;
612
+
613
+ this.$widget.removeClass('timepicker-orient-top timepicker-orient-bottom timepicker-orient-right timepicker-orient-left');
614
+
615
+ if (this.orientation.x !== 'auto') {
616
+ this.picker.addClass('datepicker-orient-' + this.orientation.x);
617
+ if (this.orientation.x === 'right') {
618
+ left -= widgetWidth - width;
619
+ }
620
+ } else{
621
+ // auto x orientation is best-placement: if it crosses a window edge, fudge it sideways
622
+ // Default to left
623
+ this.$widget.addClass('timepicker-orient-left');
624
+ if (offset.left < 0) {
625
+ left -= offset.left - visualPadding;
626
+ } else if (offset.left + widgetWidth > windowWidth) {
627
+ left = windowWidth - widgetWidth - visualPadding;
628
+ }
629
+ }
630
+ // auto y orientation is best-situation: top or bottom, no fudging, decision based on which shows more of the widget
631
+ var yorient = this.orientation.y, topOverflow, bottomOverflow;
632
+ if (yorient === 'auto') {
633
+ topOverflow = -scrollTop + offset.top - widgetHeight;
634
+ bottomOverflow = scrollTop + windowHeight - (offset.top + height + widgetHeight);
635
+ if (Math.max(topOverflow, bottomOverflow) === bottomOverflow) {
636
+ yorient = 'top';
637
+ } else {
638
+ yorient = 'bottom';
639
+ }
640
+ }
641
+ this.$widget.addClass('timepicker-orient-' + yorient);
642
+ if (yorient === 'top'){
643
+ top += height;
644
+ } else{
645
+ top -= widgetHeight + parseInt(this.$widget.css('padding-top'), 10);
646
+ }
647
+
648
+ this.$widget.css({
649
+ top : top,
650
+ left : left,
651
+ zIndex : zIndex
652
+ });
653
+ },
654
+
655
+ remove: function() {
656
+ $('document').off('.timepicker');
657
+ if (this.$widget) {
658
+ this.$widget.remove();
659
+ }
660
+ delete this.$element.data().timepicker;
661
+ },
662
+
663
+ setDefaultTime: function(defaultTime) {
664
+ if (!this.$element.val()) {
665
+ if (defaultTime === 'current') {
666
+ var dTime = new Date(),
667
+ hours = dTime.getHours(),
668
+ minutes = dTime.getMinutes(),
669
+ seconds = dTime.getSeconds(),
670
+ meridian = 'AM';
671
+
672
+ if (seconds !== 0) {
673
+ seconds = Math.ceil(dTime.getSeconds() / this.secondStep) * this.secondStep;
674
+ if (seconds === 60) {
675
+ minutes += 1;
676
+ seconds = 0;
677
+ }
678
+ }
679
+
680
+ if (minutes !== 0) {
681
+ minutes = Math.ceil(dTime.getMinutes() / this.minuteStep) * this.minuteStep;
682
+ if (minutes === 60) {
683
+ hours += 1;
684
+ minutes = 0;
685
+ }
686
+ }
687
+
688
+ if (this.showMeridian) {
689
+ if (hours === 0) {
690
+ hours = 12;
691
+ } else if (hours >= 12) {
692
+ if (hours > 12) {
693
+ hours = hours - 12;
694
+ }
695
+ meridian = 'PM';
696
+ } else {
697
+ meridian = 'AM';
698
+ }
699
+ }
700
+
701
+ this.hour = hours;
702
+ this.minute = minutes;
703
+ this.second = seconds;
704
+ this.meridian = meridian;
705
+
706
+ this.update();
707
+
708
+ } else if (defaultTime === false) {
709
+ this.hour = 0;
710
+ this.minute = 0;
711
+ this.second = 0;
712
+ this.meridian = 'AM';
713
+ } else {
714
+ this.setTime(defaultTime);
715
+ }
716
+ } else {
717
+ this.updateFromElementVal();
718
+ }
719
+ },
720
+
721
+ setTime: function(time, ignoreWidget) {
722
+ if (!time) {
723
+ this.clear();
724
+ return;
725
+ }
726
+
727
+ var timeArray,
728
+ hour,
729
+ minute,
730
+ second,
731
+ meridian;
732
+
733
+ if (typeof time === 'object' && time.getMonth){
734
+ // this is a date object
735
+ hour = time.getHours();
736
+ minute = time.getMinutes();
737
+ second = time.getSeconds();
738
+
739
+ if (this.showMeridian){
740
+ meridian = 'AM';
741
+ if (hour > 12){
742
+ meridian = 'PM';
743
+ hour = hour % 12;
744
+ }
745
+
746
+ if (hour === 12){
747
+ meridian = 'PM';
748
+ }
749
+ }
750
+ } else {
751
+ if (time.match(/p/i) !== null) {
752
+ meridian = 'PM';
753
+ } else {
754
+ meridian = 'AM';
755
+ }
756
+
757
+ time = time.replace(/[^0-9\:]/g, '');
758
+
759
+ timeArray = time.split(':');
760
+
761
+ hour = timeArray[0] ? timeArray[0].toString() : timeArray.toString();
762
+ minute = timeArray[1] ? timeArray[1].toString() : '';
763
+ second = timeArray[2] ? timeArray[2].toString() : '';
764
+
765
+ // idiot proofing
766
+ if (hour.length > 4) {
767
+ second = hour.substr(4, 2);
768
+ }
769
+ if (hour.length > 2) {
770
+ minute = hour.substr(2, 2);
771
+ hour = hour.substr(0, 2);
772
+ }
773
+ if (minute.length > 2) {
774
+ second = minute.substr(2, 2);
775
+ minute = minute.substr(0, 2);
776
+ }
777
+ if (second.length > 2) {
778
+ second = second.substr(2, 2);
779
+ }
780
+
781
+ hour = parseInt(hour, 10);
782
+ minute = parseInt(minute, 10);
783
+ second = parseInt(second, 10);
784
+
785
+ if (isNaN(hour)) {
786
+ hour = 0;
787
+ }
788
+ if (isNaN(minute)) {
789
+ minute = 0;
790
+ }
791
+ if (isNaN(second)) {
792
+ second = 0;
793
+ }
794
+
795
+ if (this.showMeridian) {
796
+ if (hour < 1) {
797
+ hour = 1;
798
+ } else if (hour > 12) {
799
+ hour = 12;
800
+ }
801
+ } else {
802
+ if (hour >= 24) {
803
+ hour = 23;
804
+ } else if (hour < 0) {
805
+ hour = 0;
806
+ }
807
+ if (hour < 13 && meridian === 'PM') {
808
+ hour = hour + 12;
809
+ }
810
+ }
811
+
812
+ if (minute < 0) {
813
+ minute = 0;
814
+ } else if (minute >= 60) {
815
+ minute = 59;
816
+ }
817
+
818
+ if (this.showSeconds) {
819
+ if (isNaN(second)) {
820
+ second = 0;
821
+ } else if (second < 0) {
822
+ second = 0;
823
+ } else if (second >= 60) {
824
+ second = 59;
825
+ }
826
+ }
827
+ }
828
+
829
+ this.hour = hour;
830
+ this.minute = minute;
831
+ this.second = second;
832
+ this.meridian = meridian;
833
+
834
+ this.update(ignoreWidget);
835
+ },
836
+
837
+ showWidget: function() {
838
+ if (this.isOpen) {
839
+ return;
840
+ }
841
+
842
+ if (this.$element.is(':disabled')) {
843
+ return;
844
+ }
845
+
846
+ // show/hide approach taken by datepicker
847
+ this.$widget.appendTo(this.appendWidgetTo);
848
+ var self = this;
849
+ $(document).on('mousedown.timepicker, touchend.timepicker', function (e) {
850
+ // This condition was inspired by datepicker.
851
+ // The element the timepicker is invoked on is the input but it has a sibling for addon/button.
852
+ if (!(self.$element.parent().find(e.target).length ||
853
+ self.$widget.is(e.target) ||
854
+ self.$widget.find(e.target).length)) {
855
+ self.hideWidget();
856
+ }
857
+ });
858
+
859
+ this.$element.trigger({
860
+ 'type': 'show.timepicker',
861
+ 'time': {
862
+ 'value': this.getTime(),
863
+ 'hours': this.hour,
864
+ 'minutes': this.minute,
865
+ 'seconds': this.second,
866
+ 'meridian': this.meridian
867
+ }
868
+ });
869
+
870
+ this.place();
871
+ if (this.disableFocus) {
872
+ this.$element.blur();
873
+ }
874
+
875
+ // widget shouldn't be empty on open
876
+ if (this.hour === '') {
877
+ if (this.defaultTime) {
878
+ this.setDefaultTime(this.defaultTime);
879
+ } else {
880
+ this.setTime('0:0:0');
881
+ }
882
+ }
883
+
884
+ if (this.template === 'modal' && this.$widget.modal) {
885
+ this.$widget.modal('show').on('hidden', $.proxy(this.hideWidget, this));
886
+ } else {
887
+ if (this.isOpen === false) {
888
+ this.$widget.addClass('open');
889
+ }
890
+ }
891
+
892
+ this.isOpen = true;
893
+ },
894
+
895
+ toggleMeridian: function() {
896
+ this.meridian = this.meridian === 'AM' ? 'PM' : 'AM';
897
+ },
898
+
899
+ update: function(ignoreWidget) {
900
+ this.updateElement();
901
+ if (!ignoreWidget) {
902
+ this.updateWidget();
903
+ }
904
+
905
+ this.$element.trigger({
906
+ 'type': 'changeTime.timepicker',
907
+ 'time': {
908
+ 'value': this.getTime(),
909
+ 'hours': this.hour,
910
+ 'minutes': this.minute,
911
+ 'seconds': this.second,
912
+ 'meridian': this.meridian
913
+ }
914
+ });
915
+ },
916
+
917
+ updateElement: function() {
918
+ this.$element.val(this.getTime()).change();
919
+ },
920
+
921
+ updateFromElementVal: function() {
922
+ this.setTime(this.$element.val());
923
+ },
924
+
925
+ updateWidget: function() {
926
+ if (this.$widget === false) {
927
+ return;
928
+ }
929
+
930
+ var hour = this.hour,
931
+ minute = this.minute.toString().length === 1 ? '0' + this.minute : this.minute,
932
+ second = this.second.toString().length === 1 ? '0' + this.second : this.second;
933
+
934
+ if (this.showInputs) {
935
+ this.$widget.find('input.timepicker-hour').val(hour);
936
+ this.$widget.find('input.timepicker-minute').val(minute);
937
+
938
+ if (this.showSeconds) {
939
+ this.$widget.find('input.timepicker-second').val(second);
940
+ }
941
+ if (this.showMeridian) {
942
+ this.$widget.find('input.timepicker-meridian').val(this.meridian);
943
+ }
944
+ } else {
945
+ this.$widget.find('span.timepicker-hour').text(hour);
946
+ this.$widget.find('span.timepicker-minute').text(minute);
947
+
948
+ if (this.showSeconds) {
949
+ this.$widget.find('span.timepicker-second').text(second);
950
+ }
951
+ if (this.showMeridian) {
952
+ this.$widget.find('span.timepicker-meridian').text(this.meridian);
953
+ }
954
+ }
955
+ },
956
+
957
+ updateFromWidgetInputs: function() {
958
+ if (this.$widget === false) {
959
+ return;
960
+ }
961
+
962
+ var t = this.$widget.find('input.timepicker-hour').val() + ':' +
963
+ this.$widget.find('input.timepicker-minute').val() +
964
+ (this.showSeconds ? ':' + this.$widget.find('input.timepicker-second').val() : '') +
965
+ (this.showMeridian ? this.$widget.find('input.timepicker-meridian').val() : '')
966
+ ;
967
+
968
+ this.setTime(t, true);
969
+ },
970
+
971
+ widgetClick: function(e) {
972
+ e.stopPropagation();
973
+ e.preventDefault();
974
+
975
+ var $input = $(e.target),
976
+ action = $input.closest('a').data('action');
977
+
978
+ if (action) {
979
+ this[action]();
980
+ }
981
+ this.update();
982
+
983
+ if ($input.is('input')) {
984
+ $input.get(0).setSelectionRange(0,2);
985
+ }
986
+ },
987
+
988
+ widgetKeydown: function(e) {
989
+ var $input = $(e.target),
990
+ name = $input.attr('class').replace('timepicker-', '');
991
+
992
+ switch (e.keyCode) {
993
+ case 9: //tab
994
+ if ((this.showMeridian && name === 'meridian') || (this.showSeconds && name === 'second') || (!this.showMeridian && !this.showSeconds && name === 'minute')) {
995
+ return this.hideWidget();
996
+ }
997
+ break;
998
+ case 27: // escape
999
+ this.hideWidget();
1000
+ break;
1001
+ case 38: // up arrow
1002
+ e.preventDefault();
1003
+ switch (name) {
1004
+ case 'hour':
1005
+ this.incrementHour();
1006
+ break;
1007
+ case 'minute':
1008
+ this.incrementMinute();
1009
+ break;
1010
+ case 'second':
1011
+ this.incrementSecond();
1012
+ break;
1013
+ case 'meridian':
1014
+ this.toggleMeridian();
1015
+ break;
1016
+ }
1017
+ this.setTime(this.getTime());
1018
+ $input.get(0).setSelectionRange(0,2);
1019
+ break;
1020
+ case 40: // down arrow
1021
+ e.preventDefault();
1022
+ switch (name) {
1023
+ case 'hour':
1024
+ this.decrementHour();
1025
+ break;
1026
+ case 'minute':
1027
+ this.decrementMinute();
1028
+ break;
1029
+ case 'second':
1030
+ this.decrementSecond();
1031
+ break;
1032
+ case 'meridian':
1033
+ this.toggleMeridian();
1034
+ break;
1035
+ }
1036
+ this.setTime(this.getTime());
1037
+ $input.get(0).setSelectionRange(0,2);
1038
+ break;
1039
+ }
1040
+ },
1041
+
1042
+ widgetKeyup: function(e) {
1043
+ if ((e.keyCode === 65) || (e.keyCode === 77) || (e.keyCode === 80) || (e.keyCode === 46) || (e.keyCode === 8) || (e.keyCode >= 46 && e.keyCode <= 57)) {
1044
+ this.updateFromWidgetInputs();
1045
+ }
1046
+ }
1047
+ };
1048
+
1049
+ //TIMEPICKER PLUGIN DEFINITION
1050
+ $.fn.timepicker = function(option) {
1051
+ var args = Array.apply(null, arguments);
1052
+ args.shift();
1053
+ return this.each(function() {
1054
+ var $this = $(this),
1055
+ data = $this.data('timepicker'),
1056
+ options = typeof option === 'object' && option;
1057
+
1058
+ if (!data) {
1059
+ $this.data('timepicker', (data = new Timepicker(this, $.extend({}, $.fn.timepicker.defaults, options, $(this).data()))));
1060
+ }
1061
+
1062
+ if (typeof option === 'string') {
1063
+ data[option].apply(data, args);
1064
+ }
1065
+ });
1066
+ };
1067
+
1068
+ $.fn.timepicker.defaults = {
1069
+ defaultTime: 'current',
1070
+ disableFocus: false,
1071
+ disableMousewheel: false,
1072
+ isOpen: false,
1073
+ minuteStep: 15,
1074
+ modalBackdrop: false,
1075
+ orientation: { x: 'auto', y: 'auto'},
1076
+ secondStep: 15,
1077
+ showSeconds: false,
1078
+ showInputs: true,
1079
+ showMeridian: true,
1080
+ template: 'dropdown',
1081
+ appendWidgetTo: 'body',
1082
+ showWidgetOnAddonClick: true
1083
+ };
1084
+
1085
+ $.fn.timepicker.Constructor = Timepicker;
1086
+
1087
+ })(jQuery, window, document);