active_frontend 13.3.0 → 14.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.fasterer.yml +19 -0
  4. data/.reek +27 -0
  5. data/.rubocop.yml +38 -0
  6. data/.scss-lint.yml +27 -0
  7. data/Rakefile +1 -1
  8. data/active_frontend.gemspec +21 -18
  9. data/app/.DS_Store +0 -0
  10. data/app/assets/.DS_Store +0 -0
  11. data/app/assets/fonts/.DS_Store +0 -0
  12. data/app/assets/fonts/dripicons/.DS_Store +0 -0
  13. data/app/assets/fonts/dripicons/dripicons.woff +0 -0
  14. data/app/assets/fonts/fakt-pro/.DS_Store +0 -0
  15. data/app/assets/fonts/fakt-pro/fakt-pro-bold.woff +0 -0
  16. data/app/assets/fonts/fakt-pro/fakt-pro-normal.woff +0 -0
  17. data/app/assets/fonts/fakt-pro/fakt-pro-semibold.woff +0 -0
  18. data/app/assets/fonts/fakt-pro/fakt-pro-semilight.woff +0 -0
  19. data/app/assets/fonts/fakt-soft-pro/.DS_Store +0 -0
  20. data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-bold.woff +0 -0
  21. data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-normal.woff +0 -0
  22. data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-semibold.woff +0 -0
  23. data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-semilight.woff +0 -0
  24. data/app/assets/images/.DS_Store +0 -0
  25. data/app/assets/images/.keep +0 -0
  26. data/app/assets/images/placeholders/.DS_Store +0 -0
  27. data/app/assets/images/placeholders/camera-large.png +0 -0
  28. data/app/assets/images/placeholders/camera-small.png +0 -0
  29. data/app/assets/images/placeholders/camera.png +0 -0
  30. data/app/assets/images/placeholders/document-large.png +0 -0
  31. data/app/assets/images/placeholders/document-small.png +0 -0
  32. data/app/assets/images/placeholders/document.png +0 -0
  33. data/app/assets/images/placeholders/photo-large.png +0 -0
  34. data/app/assets/images/placeholders/{picture-small.png → photo-small.png} +0 -0
  35. data/app/assets/images/placeholders/photo.png +0 -0
  36. data/app/assets/images/placeholders/store-large.png +0 -0
  37. data/app/assets/images/placeholders/store-small.png +0 -0
  38. data/app/assets/images/placeholders/store.png +0 -0
  39. data/app/assets/images/placeholders/user-large.png +0 -0
  40. data/app/assets/images/placeholders/user-small.png +0 -0
  41. data/app/assets/images/placeholders/user.png +0 -0
  42. data/app/helpers/active_frontend_helper.rb +22 -37
  43. data/lib/.DS_Store +0 -0
  44. data/lib/active_frontend.rb +3 -4
  45. data/lib/active_frontend/.DS_Store +0 -0
  46. data/lib/active_frontend/version.rb +1 -1
  47. data/lib/generators/active_frontend/install_generator.rb +3 -3
  48. data/lib/generators/active_frontend/templates/install.js +35 -30
  49. data/lib/generators/active_frontend/templates/install.scss +55 -58
  50. data/vendor/.DS_Store +0 -0
  51. data/vendor/assets/.DS_Store +0 -0
  52. data/vendor/assets/javascripts/.DS_Store +0 -0
  53. data/vendor/assets/javascripts/active_frontend.js +35 -30
  54. data/vendor/assets/javascripts/base/_affix.js +170 -0
  55. data/vendor/assets/javascripts/base/_alert.js +80 -0
  56. data/vendor/assets/javascripts/base/_animation.js +106 -0
  57. data/vendor/assets/javascripts/base/_button.js +123 -0
  58. data/vendor/assets/javascripts/base/_carousel.js +237 -0
  59. data/vendor/assets/javascripts/base/_collapse.js +200 -0
  60. data/vendor/assets/javascripts/base/_colorpicker.js +147 -0
  61. data/vendor/assets/javascripts/base/_datepicker.js +1411 -0
  62. data/vendor/assets/javascripts/base/_dropdown.js +154 -0
  63. data/vendor/assets/javascripts/base/_filepicker.js +235 -0
  64. data/vendor/assets/javascripts/base/_hoverdown.js +116 -0
  65. data/vendor/assets/javascripts/base/_layout.js +126 -0
  66. data/vendor/assets/javascripts/base/_list.js +103 -0
  67. data/vendor/assets/javascripts/{_modal.js → base/_modal.js} +170 -167
  68. data/vendor/assets/javascripts/base/_popover.js +101 -0
  69. data/vendor/assets/javascripts/base/_scrollspy.js +161 -0
  70. data/vendor/assets/javascripts/base/_switch.js +160 -0
  71. data/vendor/assets/javascripts/base/_tab.js +139 -0
  72. data/vendor/assets/javascripts/base/_table.js +224 -0
  73. data/vendor/assets/javascripts/base/_timeago.js +270 -0
  74. data/vendor/assets/javascripts/base/_timepicker.js +541 -0
  75. data/vendor/assets/javascripts/base/_tooltip.js +525 -0
  76. data/vendor/assets/javascripts/base/_tour.js +268 -0
  77. data/vendor/assets/javascripts/base/_transition.js +52 -0
  78. data/vendor/assets/javascripts/base/_typeahead.js +362 -0
  79. data/vendor/assets/javascripts/extensions/_calendar.js +4709 -0
  80. data/vendor/assets/javascripts/extensions/_chart.js +9371 -0
  81. data/vendor/assets/javascripts/extensions/_map.js +2153 -0
  82. data/vendor/assets/stylesheets/.DS_Store +0 -0
  83. data/vendor/assets/stylesheets/{_mixin.scss → _utility.scss} +96 -10
  84. data/vendor/assets/stylesheets/_variable.scss +201 -19
  85. data/vendor/assets/stylesheets/active_frontend.scss +55 -58
  86. data/vendor/assets/stylesheets/blocks/_anchor.scss +15 -0
  87. data/vendor/assets/stylesheets/blocks/_button.scss +278 -0
  88. data/vendor/assets/stylesheets/blocks/_code.scss +144 -0
  89. data/vendor/assets/stylesheets/blocks/_common.scss +127 -0
  90. data/vendor/assets/stylesheets/blocks/_form.scss +508 -0
  91. data/vendor/assets/stylesheets/blocks/_icon.scss +359 -0
  92. data/vendor/assets/stylesheets/blocks/_list.scss +76 -0
  93. data/vendor/assets/stylesheets/blocks/_multimedia.scss +62 -0
  94. data/vendor/assets/stylesheets/blocks/_reset.scss +179 -0
  95. data/vendor/assets/stylesheets/blocks/_table.scss +211 -0
  96. data/vendor/assets/stylesheets/blocks/_typography.scss +204 -0
  97. data/vendor/assets/stylesheets/components/_ad.scss +78 -0
  98. data/vendor/assets/stylesheets/components/_affix.scss +14 -0
  99. data/vendor/assets/stylesheets/components/_alert.scss +50 -0
  100. data/vendor/assets/stylesheets/components/_animation.scss +1670 -0
  101. data/vendor/assets/stylesheets/components/_breadcrumb.scss +17 -0
  102. data/vendor/assets/stylesheets/components/_calendar.scss +213 -0
  103. data/vendor/assets/stylesheets/components/_card.scss +30 -0
  104. data/vendor/assets/stylesheets/components/_carousel.scss +135 -0
  105. data/vendor/assets/stylesheets/components/_chart.scss +10 -0
  106. data/vendor/assets/stylesheets/components/_collapse.scss +17 -0
  107. data/vendor/assets/stylesheets/components/_colorpicker.scss +38 -0
  108. data/vendor/assets/stylesheets/components/_datepicker.scss +80 -0
  109. data/vendor/assets/stylesheets/components/_dropmenu.scss +151 -0
  110. data/vendor/assets/stylesheets/components/_footer.scss +11 -0
  111. data/vendor/assets/stylesheets/components/_grid.scss +144 -0
  112. data/vendor/assets/stylesheets/components/_header.scss +99 -0
  113. data/vendor/assets/stylesheets/components/_label_and_badge.scss +57 -0
  114. data/vendor/assets/stylesheets/components/_layout.scss +63 -0
  115. data/vendor/assets/stylesheets/components/_map.scss +14 -0
  116. data/vendor/assets/stylesheets/components/_milestone.scss +49 -0
  117. data/vendor/assets/stylesheets/components/_missive.scss +40 -0
  118. data/vendor/assets/stylesheets/components/_modal.scss +126 -0
  119. data/vendor/assets/stylesheets/components/_nav_and_tab.scss +202 -0
  120. data/vendor/assets/stylesheets/components/_navbar.scss +66 -0
  121. data/vendor/assets/stylesheets/components/_pagination.scss +79 -0
  122. data/vendor/assets/stylesheets/components/_placeholder.scss +23 -0
  123. data/vendor/assets/stylesheets/components/_popover.scss +167 -0
  124. data/vendor/assets/stylesheets/components/_progress.scss +62 -0
  125. data/vendor/assets/stylesheets/components/_sidebar.scss +74 -0
  126. data/vendor/assets/stylesheets/components/_spinner.scss +83 -0
  127. data/vendor/assets/stylesheets/components/_switch.scss +150 -0
  128. data/vendor/assets/stylesheets/components/_timepicker.scss +30 -0
  129. data/vendor/assets/stylesheets/components/_tooltip.scss +93 -0
  130. data/vendor/assets/stylesheets/components/_transition.scss +12 -0
  131. data/vendor/assets/stylesheets/components/_typeahead.scss +18 -0
  132. metadata +150 -94
  133. data/app/assets/fonts/gotham/gotham-bold.woff +0 -0
  134. data/app/assets/fonts/gotham/gotham-book.woff +0 -0
  135. data/app/assets/fonts/gotham/gotham-light.woff +0 -0
  136. data/app/assets/fonts/gotham/gotham-medium.woff +0 -0
  137. data/app/assets/fonts/gotham/gotham-rounded-bold.woff +0 -0
  138. data/app/assets/fonts/gotham/gotham-rounded-book.woff +0 -0
  139. data/app/assets/fonts/gotham/gotham-rounded-light.woff +0 -0
  140. data/app/assets/fonts/gotham/gotham-rounded-medium.woff +0 -0
  141. data/app/assets/images/placeholders/archive-large.png +0 -0
  142. data/app/assets/images/placeholders/archive-small.png +0 -0
  143. data/app/assets/images/placeholders/archive.png +0 -0
  144. data/app/assets/images/placeholders/picture-large.png +0 -0
  145. data/app/assets/images/placeholders/picture.png +0 -0
  146. data/vendor/assets/javascripts/_affix.js +0 -153
  147. data/vendor/assets/javascripts/_alert.js +0 -85
  148. data/vendor/assets/javascripts/_animation.js +0 -103
  149. data/vendor/assets/javascripts/_button.js +0 -107
  150. data/vendor/assets/javascripts/_carousel.js +0 -228
  151. data/vendor/assets/javascripts/_chart.js +0 -3742
  152. data/vendor/assets/javascripts/_collapse.js +0 -202
  153. data/vendor/assets/javascripts/_color_picker.js +0 -108
  154. data/vendor/assets/javascripts/_date_picker.js +0 -1650
  155. data/vendor/assets/javascripts/_dropdown.js +0 -156
  156. data/vendor/assets/javascripts/_file_input.js +0 -71
  157. data/vendor/assets/javascripts/_hoverdown.js +0 -109
  158. data/vendor/assets/javascripts/_inputmask.js +0 -341
  159. data/vendor/assets/javascripts/_loader.js +0 -361
  160. data/vendor/assets/javascripts/_map.js +0 -2401
  161. data/vendor/assets/javascripts/_popover.js +0 -99
  162. data/vendor/assets/javascripts/_scrollspy.js +0 -163
  163. data/vendor/assets/javascripts/_slider.js +0 -1572
  164. data/vendor/assets/javascripts/_sort.js +0 -1432
  165. data/vendor/assets/javascripts/_swoggle.js +0 -415
  166. data/vendor/assets/javascripts/_tab.js +0 -146
  167. data/vendor/assets/javascripts/_tablespy.js +0 -1883
  168. data/vendor/assets/javascripts/_time_ago.js +0 -206
  169. data/vendor/assets/javascripts/_time_picker.js +0 -1088
  170. data/vendor/assets/javascripts/_tooltip.js +0 -504
  171. data/vendor/assets/javascripts/_transition.js +0 -50
  172. data/vendor/assets/javascripts/_typeahead.js +0 -366
  173. data/vendor/assets/stylesheets/_ad.scss +0 -63
  174. data/vendor/assets/stylesheets/_affix.scss +0 -14
  175. data/vendor/assets/stylesheets/_alert.scss +0 -114
  176. data/vendor/assets/stylesheets/_animation.scss +0 -1370
  177. data/vendor/assets/stylesheets/_breadcrumb.scss +0 -100
  178. data/vendor/assets/stylesheets/_button.scss +0 -386
  179. data/vendor/assets/stylesheets/_canvas.scss +0 -182
  180. data/vendor/assets/stylesheets/_carousel.scss +0 -158
  181. data/vendor/assets/stylesheets/_chart.scss +0 -15
  182. data/vendor/assets/stylesheets/_code.scss +0 -150
  183. data/vendor/assets/stylesheets/_collapse.scss +0 -14
  184. data/vendor/assets/stylesheets/_color.scss +0 -55
  185. data/vendor/assets/stylesheets/_colorpicker.scss +0 -63
  186. data/vendor/assets/stylesheets/_datepicker.scss +0 -122
  187. data/vendor/assets/stylesheets/_dropdown.scss +0 -248
  188. data/vendor/assets/stylesheets/_footer.scss +0 -71
  189. data/vendor/assets/stylesheets/_form.scss +0 -661
  190. data/vendor/assets/stylesheets/_grid.scss +0 -184
  191. data/vendor/assets/stylesheets/_header.scss +0 -156
  192. data/vendor/assets/stylesheets/_icon.scss +0 -362
  193. data/vendor/assets/stylesheets/_image.scss +0 -33
  194. data/vendor/assets/stylesheets/_label_and_badge.scss +0 -104
  195. data/vendor/assets/stylesheets/_link.scss +0 -55
  196. data/vendor/assets/stylesheets/_list.scss +0 -122
  197. data/vendor/assets/stylesheets/_loader.scss +0 -71
  198. data/vendor/assets/stylesheets/_map.scss +0 -44
  199. data/vendor/assets/stylesheets/_missive.scss +0 -74
  200. data/vendor/assets/stylesheets/_modal.scss +0 -204
  201. data/vendor/assets/stylesheets/_nav_and_tab.scss +0 -230
  202. data/vendor/assets/stylesheets/_navbar.scss +0 -73
  203. data/vendor/assets/stylesheets/_pagination.scss +0 -79
  204. data/vendor/assets/stylesheets/_panel.scss +0 -80
  205. data/vendor/assets/stylesheets/_placeholder.scss +0 -63
  206. data/vendor/assets/stylesheets/_popover.scss +0 -128
  207. data/vendor/assets/stylesheets/_progress.scss +0 -86
  208. data/vendor/assets/stylesheets/_reset.scss +0 -140
  209. data/vendor/assets/stylesheets/_sidebar.scss +0 -148
  210. data/vendor/assets/stylesheets/_slider.scss +0 -151
  211. data/vendor/assets/stylesheets/_spinner.scss +0 -572
  212. data/vendor/assets/stylesheets/_subheader.scss +0 -112
  213. data/vendor/assets/stylesheets/_swoggle.scss +0 -120
  214. data/vendor/assets/stylesheets/_table.scss +0 -210
  215. data/vendor/assets/stylesheets/_timepicker.scss +0 -77
  216. data/vendor/assets/stylesheets/_toolbar.scss +0 -130
  217. data/vendor/assets/stylesheets/_tooltip.scss +0 -105
  218. data/vendor/assets/stylesheets/_transition.scss +0 -11
  219. data/vendor/assets/stylesheets/_trunk.scss +0 -147
  220. data/vendor/assets/stylesheets/_typeahead.scss +0 -18
  221. data/vendor/assets/stylesheets/_typography.scss +0 -233
@@ -0,0 +1,268 @@
1
+ +function ($) {
2
+ 'use strict';
3
+
4
+ // TOUR CLASS DEFINITION
5
+ // =====================
6
+
7
+ var Tour = function (element, options) {
8
+ this.$element = $(element);
9
+ this.options = $.extend({}, Tour.DEFAULTS, options);
10
+
11
+ this.$active = false;
12
+ this.$interval = null;
13
+ this.$timeout = null;
14
+ this.$totalItems = this.options.items.length;
15
+
16
+ this.initCurrentItem();
17
+ this.init();
18
+ };
19
+
20
+ if (!$.fn.popover) throw new Error('Tour requires popover.js');
21
+
22
+ Tour.VERSION = '1.0.0';
23
+ Tour.OFFSET = 200;
24
+ Tour.DEFAULTS = {
25
+ buttonClass: 'btn btn-size-s',
26
+ delay: 3000,
27
+ items: [],
28
+ manual: true,
29
+ onMissCallback: function (item) { return item; },
30
+ onShowCallback: function (item) { return item; },
31
+ onShownCallback: function (item) { return item; },
32
+ parent: 'html, body',
33
+ skip: true,
34
+ storage: false,
35
+ storageKey: 'storage.bs.tour',
36
+ text: {
37
+ end: 'End',
38
+ endTour: 'End Tour',
39
+ next: 'Next',
40
+ prev: 'Prev',
41
+ stop: 'Stop'
42
+ }
43
+ };
44
+
45
+ Tour.prototype.constructor = Tour;
46
+
47
+ Tour.prototype.init = function () {
48
+ var _self = this;
49
+
50
+ this.$element.click(function () {
51
+ if (_self.$totalItems === 0) return this;
52
+
53
+ if (_self.$active) {
54
+ _self.endTour();
55
+ } else {
56
+ _self.startTour();
57
+
58
+ if (!_self.options.manual) _self.cycleItems();
59
+ }
60
+ });
61
+
62
+ $('body')
63
+ .on('click', '[data-tour="next"]', function () {
64
+ _self.nextItem();
65
+ })
66
+ .on('click', '[data-tour="prev"]', function () {
67
+ _self.prevItem();
68
+ })
69
+ .on('click', '[data-tour="stop"]', function () {
70
+ _self.stopCycling();
71
+ $(this).remove();
72
+ })
73
+ .on('click', '[data-tour="end"]', function () {
74
+ _self.endTour();
75
+ });
76
+ };
77
+
78
+ Tour.prototype.startTour = function () {
79
+ this.nextItem();
80
+ this.$startText = this.$element.text();
81
+ this.$element.text(this.options.text.endTour);
82
+ this.$active = true;
83
+ };
84
+
85
+ Tour.prototype.nextItem = function () {
86
+ this.incr();
87
+ this.displayItem(this.getItem());
88
+ };
89
+
90
+ Tour.prototype.prevItem = function () {
91
+ this.decr();
92
+ this.displayItem(this.getItem());
93
+ };
94
+
95
+ Tour.prototype.endTour = function () {
96
+ this.stopCycling();
97
+ this.removeItems();
98
+ this.$currentItem = 0;
99
+ this.$active = false;
100
+ this.setCurrentItem();
101
+ this.$element.text(this.$startText);
102
+ this.$element.scrollToItem(this.options.parent, 'top');
103
+ };
104
+
105
+ Tour.prototype.incr = function () {
106
+ if (this.$currentItem < this.$totalItems) this.$currentItem++;
107
+ this.setCurrentItem();
108
+ };
109
+
110
+ Tour.prototype.decr = function () {
111
+ if (this.$currentItem > 1) this.$currentItem--;
112
+ this.setCurrentItem();
113
+ };
114
+
115
+ Tour.prototype.popoverTemplate = function () {
116
+ var stopBtn = '<button class="' + this.options.buttonClass + '" data-tour="stop">' + this.options.text.stop + '</button>';
117
+ var prevBtn = '<button class="' + this.options.buttonClass + '" data-tour="prev">' + this.options.text.prev + '</button>';
118
+ var nextBtn = '<button class="' + this.options.buttonClass + '" data-tour="next">' + this.options.text.next + '</button>';
119
+ var endBtn = '<button class="' + this.options.buttonClass + ' pull-right" data-tour="end">' + this.options.text.end + '</button>';
120
+ var btnGroup = $('<div class="btn-group pull-left">');
121
+ var navigation = $('<div class="popover-nav row">');
122
+ var popover = $('<div class="popover" role="tooltip">')
123
+ .append('<div class="arrow"></div>')
124
+ .append('<strong class="popover-title"></strong>')
125
+ .append('<div class="popover-content"></div>');
126
+
127
+ if (this.options.manual) {
128
+ if (this.$currentItem > 1) btnGroup.append(prevBtn);
129
+ if (this.$currentItem < this.$totalItems) btnGroup.append(nextBtn);
130
+ } else {
131
+ btnGroup.append(stopBtn);
132
+ }
133
+
134
+ navigation.append(btnGroup);
135
+ navigation.append(endBtn);
136
+ popover.append(navigation);
137
+
138
+ return popover;
139
+ };
140
+
141
+ Tour.prototype.displayItem = function (item) {
142
+ var element = $(item.id);
143
+
144
+ this.removeItems();
145
+
146
+ this.options.onShowCallback(item);
147
+
148
+ if (element.length !== 0 && element.is(':visible')) {
149
+ $(item.id + ':first').popover({
150
+ container: item.container || false,
151
+ content: item.content,
152
+ html: true,
153
+ placement: item.placement || 'top',
154
+ title: item.title,
155
+ template: this.popoverTemplate(),
156
+ trigger: 'manual'
157
+ });
158
+
159
+ element.scrollToItem(item.parent || this.options.parent, item.placement);
160
+
161
+ setTimeout(function () {
162
+ element.popover('show');
163
+ }, 225);
164
+
165
+ this.options.onShownCallback(item);
166
+ } else {
167
+ if (this.options.skip) this.nextItem();
168
+ this.options.onMissCallback(item);
169
+ }
170
+ };
171
+
172
+ Tour.prototype.getItem = function () {
173
+ return this.options.items[this.$currentItem - 1];
174
+ };
175
+
176
+ Tour.prototype.initCurrentItem = function () {
177
+ if (this.options.storage) {
178
+ this.$currentItem = this.storageGetStep();
179
+ } else {
180
+ this.$currentItem = 0;
181
+ }
182
+ };
183
+
184
+ Tour.prototype.setCurrentItem = function () {
185
+ if (this.options.storage) this.storageSetStep();
186
+ };
187
+
188
+ Tour.prototype.cycleItems = function () {
189
+ var _self = this;
190
+
191
+ this.$interval = setInterval(function () {
192
+ _self.nextItem();
193
+
194
+ if (_self.$currentItem === _self.$totalItems) {
195
+ _self.$timeout = setTimeout(function () {
196
+ _self.endTour();
197
+ }, _self.options.delay);
198
+
199
+ clearInterval(_self.$interval);
200
+ }
201
+ }, this.options.delay);
202
+ };
203
+
204
+ Tour.prototype.removeItems = function () {
205
+ $('.popover').remove();
206
+ };
207
+
208
+ Tour.prototype.stopCycling = function () {
209
+ clearInterval(this.$interval);
210
+ clearTimeout(this.$timeout);
211
+ };
212
+
213
+ Tour.prototype.storageNotAccessible = function () {
214
+ return typeof(Storage) === 'undefined';
215
+ };
216
+
217
+ Tour.prototype.storageGetStep = function () {
218
+ if (this.storageNotAccessible()) return;
219
+ return localStorage.getItem(this.options.storageKey);
220
+ };
221
+
222
+ Tour.prototype.storageSetStep = function () {
223
+ if (this.storageNotAccessible()) return;
224
+ localStorage.setItem(this.options.storageKey, this.$currentItem);
225
+ };
226
+
227
+ $.fn.scrollToItem = function (parent, placement) {
228
+ var offset = Tour.OFFSET;
229
+
230
+ if (placement === 'bottom') {
231
+ offset = -offset;
232
+ }
233
+
234
+ $(parent).animate({
235
+ scrollTop: $(this).position().top - offset + 'px'
236
+ }, 200);
237
+
238
+ return this;
239
+ };
240
+
241
+ // TOUR PLUGIN DEFINITION
242
+ // ======================
243
+
244
+ function Plugin(option) {
245
+ return this.each(function () {
246
+ var $this = $(this);
247
+ var data = $this.data('bs.tour');
248
+ var options = typeof option === 'object' && option;
249
+
250
+ if (!data) $this.data('bs.tour', (data = new Tour(this, options)));
251
+ if (typeof option === 'string') data[option]();
252
+ });
253
+ }
254
+
255
+ var old = $.fn.tour;
256
+
257
+ $.fn.tour = Plugin;
258
+ $.fn.tour.Constructor = Tour;
259
+
260
+ // TOUR NO CONFLICT
261
+ // ================
262
+
263
+ $.fn.tour.noConflict = function () {
264
+ $.fn.tour = old;
265
+ return this;
266
+ };
267
+
268
+ }(jQuery);
@@ -0,0 +1,52 @@
1
+ +function ($) {
2
+ 'use strict';
3
+
4
+ // CSS TRANSITION SUPPORT
5
+ // ======================
6
+
7
+ function transitionEnd() {
8
+ var el = document.createElement('bootstrap');
9
+ var transEndEventNames = {
10
+ WebkitTransition: 'webkitTransitionEnd',
11
+ MozTransition: 'transitionend',
12
+ OTransition: 'oTransitionEnd otransitionend',
13
+ transition: 'transitionend'
14
+ };
15
+
16
+ for (var name in transEndEventNames) {
17
+ if (el.style[name] !== undefined) {
18
+ return { end: transEndEventNames[name] };
19
+ }
20
+ }
21
+
22
+ return false;
23
+ }
24
+
25
+ $.fn.emulateTransitionEnd = function (duration) {
26
+ var called = false;
27
+ var $el = this;
28
+
29
+ $(this).one('bsTransitionEnd', function () { called = true; });
30
+
31
+ var callback = function () { if (!called) $($el).trigger($.support.transition.end); };
32
+
33
+ setTimeout(callback, duration);
34
+
35
+ return this;
36
+ };
37
+
38
+ $(function () {
39
+ $.support.transition = transitionEnd();
40
+
41
+ if (!$.support.transition) return;
42
+
43
+ $.event.special.bsTransitionEnd = {
44
+ bindType: $.support.transition.end,
45
+ delegateType: $.support.transition.end,
46
+ handle: function (e) {
47
+ if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments);
48
+ }
49
+ };
50
+ });
51
+
52
+ }(jQuery);
@@ -0,0 +1,362 @@
1
+ +function ($) {
2
+ 'use strict';
3
+
4
+ // TYPEAHEAD PUBLIC CLASS DEFINITION
5
+ // =================================
6
+
7
+ var Typeahead = function (element, options) {
8
+ this.$element = $(element);
9
+ this.options = $.extend({}, Typeahead.DEFAULTS, options);
10
+
11
+ this.$menu = $(this.options.menu);
12
+ this.shown = false;
13
+
14
+ this.init();
15
+ };
16
+
17
+ Typeahead.VERSION = '1.0.0';
18
+ Typeahead.DEFAULTS = {
19
+ autoSelect: true,
20
+ item: '<li><a href="#"></a></li>',
21
+ items: 8,
22
+ menu: '<ul class="typeahead dropmenu caret"></ul>',
23
+ minLength: 1,
24
+ scrollHeight: 0,
25
+ source: []
26
+ };
27
+
28
+ Typeahead.prototype.constructor = Typeahead;
29
+
30
+ Typeahead.prototype.select = function () {
31
+ var val = this.$menu.find('.active').data('value');
32
+
33
+ if(this.options.autoSelect || val) {
34
+ this.$element
35
+ .val(this.updater(val))
36
+ .change();
37
+ }
38
+
39
+ return this.hide();
40
+ };
41
+
42
+ Typeahead.prototype.updater = function (item) {
43
+ return item;
44
+ };
45
+
46
+ Typeahead.prototype.setSource = function (source) {
47
+ this.options.source = source;
48
+ };
49
+
50
+ Typeahead.prototype.show = function () {
51
+ var scrollHeight;
52
+ var pos = $.extend({}, this.$element.position(), {
53
+ height: this.$element[0].offsetHeight
54
+ });
55
+
56
+ scrollHeight = typeof this.options.scrollHeight === 'function' ?
57
+ this.options.scrollHeight.call() :
58
+ this.options.scrollHeight;
59
+
60
+ this.$menu
61
+ .insertAfter(this.$element)
62
+ .css({
63
+ top: pos.top + pos.height + scrollHeight,
64
+ left: pos.left
65
+ })
66
+ .show();
67
+
68
+ this.shown = true;
69
+ return this;
70
+ };
71
+
72
+ Typeahead.prototype.hide = function () {
73
+ this.$menu.hide();
74
+ this.shown = false;
75
+ return this;
76
+ };
77
+
78
+ Typeahead.prototype.lookup = function (query) {
79
+ var items;
80
+
81
+ if (typeof(query) !== 'undefined' && query !== null) {
82
+ this.query = query;
83
+ } else {
84
+ this.query = this.$element.val() || '';
85
+ }
86
+
87
+ if (this.query.length < this.options.minLength) {
88
+ return this.shown ? this.hide() : this;
89
+ }
90
+
91
+ items = $.isFunction(this.options.source) ?
92
+ this.options.source(this.query, $.proxy(this.process, this)) :
93
+ this.options.source;
94
+
95
+ return items ? this.process(items) : this;
96
+ };
97
+
98
+ Typeahead.prototype.process = function (items) {
99
+ var that = this;
100
+
101
+ items = $.grep(items, function (item) {
102
+ return that.matcher(item);
103
+ });
104
+
105
+ items = this.sorter(items);
106
+
107
+ if (!items.length) {
108
+ return this.shown ? this.hide() : this;
109
+ }
110
+
111
+ if (this.options.items === 'all' || this.options.minLength === 0 && !this.$element.val()) {
112
+ return this.render(items).show();
113
+ } else {
114
+ return this.render(items.slice(0, this.options.items)).show();
115
+ }
116
+ };
117
+
118
+ Typeahead.prototype.matcher = function (item) {
119
+ return ~item.toLowerCase().indexOf(this.query.toLowerCase());
120
+ };
121
+
122
+ Typeahead.prototype.sorter = function (items) {
123
+ var beginswith = [];
124
+ var caseSensitive = [];
125
+ var caseInsensitive = [];
126
+ var item;
127
+
128
+ while ((item = items.shift())) {
129
+ if (!item.toLowerCase().indexOf(this.query.toLowerCase())) {
130
+ beginswith.push(item);
131
+ } else if (~item.indexOf(this.query)) {
132
+ caseSensitive.push(item);
133
+ } else {
134
+ caseInsensitive.push(item);
135
+ }
136
+ }
137
+
138
+ return beginswith.concat(caseSensitive, caseInsensitive);
139
+ };
140
+
141
+ Typeahead.prototype.highlighter = function (item) {
142
+ var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
143
+
144
+ return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
145
+ return '<b>' + match + '</b>';
146
+ });
147
+ };
148
+
149
+ Typeahead.prototype.render = function (items) {
150
+ var that = this;
151
+
152
+ items = $(items).map(function (i, item) {
153
+ i = $(that.options.item).data('value', item);
154
+ i.find('a').html(that.highlighter(item));
155
+ return i[0];
156
+ });
157
+
158
+ if (this.options.autoSelect) {
159
+ items.first()
160
+ .addClass('active');
161
+ }
162
+
163
+ this.$menu.html(items);
164
+ return this;
165
+ };
166
+
167
+ Typeahead.prototype.next = function (event) {
168
+ var active = this.$menu.find('.active').removeClass('active');
169
+ var next = active.next();
170
+
171
+ if (!next.length) {
172
+ next = $(this.$menu.find('li')[0]);
173
+ }
174
+
175
+ next.addClass('active');
176
+ };
177
+
178
+ Typeahead.prototype.prev = function (event) {
179
+ var active = this.$menu.find('.active').removeClass('active');
180
+ var prev = active.prev();
181
+
182
+ if (!prev.length) {
183
+ prev = this.$menu.find('li').last();
184
+ }
185
+
186
+ prev.addClass('active');
187
+ };
188
+
189
+ Typeahead.prototype.init = function () {
190
+ this.$element
191
+ .on('focus', $.proxy(this.focus, this))
192
+ .on('blur', $.proxy(this.blur, this))
193
+ .on('keypress', $.proxy(this.keypress, this))
194
+ .on('keyup', $.proxy(this.keyup, this));
195
+
196
+ if (this.eventSupported('keydown')) {
197
+ this.$element.on('keydown', $.proxy(this.keydown, this));
198
+ }
199
+
200
+ this.$menu
201
+ .on('click', $.proxy(this.click, this))
202
+ .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
203
+ .on('mouseleave', 'li', $.proxy(this.mouseleave, this));
204
+ };
205
+
206
+ Typeahead.prototype.destroy = function () {
207
+ this.$element.data('typeahead',null);
208
+ this.$element
209
+ .off('focus')
210
+ .off('blur')
211
+ .off('keypress')
212
+ .off('keyup');
213
+
214
+ if (this.eventSupported('keydown')) this.$element.off('keydown');
215
+ this.$menu.remove();
216
+ };
217
+
218
+ Typeahead.prototype.eventSupported = function (eventName) {
219
+ var isSupported = eventName in this.$element;
220
+
221
+ if (!isSupported) {
222
+ this.$element.setAttribute(eventName, 'return;');
223
+ isSupported = typeof this.$element[eventName] === 'function';
224
+ }
225
+
226
+ return isSupported;
227
+ };
228
+
229
+ Typeahead.prototype.move = function (e) {
230
+ if (!this.shown) return;
231
+
232
+ switch(e.keyCode) {
233
+ case 9:
234
+ case 13:
235
+ case 27:
236
+ e.preventDefault();
237
+ break;
238
+
239
+ case 38:
240
+ e.preventDefault();
241
+ this.prev();
242
+ break;
243
+
244
+ case 40:
245
+ e.preventDefault();
246
+ this.next();
247
+ break;
248
+ }
249
+
250
+ e.stopPropagation();
251
+ };
252
+
253
+ Typeahead.prototype.keydown = function (e) {
254
+ this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27]);
255
+
256
+ if (!this.shown && e.keyCode === 40) {
257
+ this.lookup('');
258
+ } else {
259
+ this.move(e);
260
+ }
261
+ };
262
+
263
+ Typeahead.prototype.keypress = function (e) {
264
+ if (this.suppressKeyPressRepeat) return;
265
+ this.move(e);
266
+ };
267
+
268
+ Typeahead.prototype.keyup = function (e) {
269
+ switch(e.keyCode) {
270
+ case 40:
271
+ case 38:
272
+ case 16:
273
+ case 17:
274
+ case 18:
275
+ break;
276
+
277
+ case 9:
278
+ case 13:
279
+ if (!this.shown) return;
280
+ this.select();
281
+ break;
282
+
283
+ case 27:
284
+ if (!this.shown) return;
285
+ this.hide();
286
+ break;
287
+
288
+ default:
289
+ this.lookup();
290
+ }
291
+
292
+ e.stopPropagation();
293
+ e.preventDefault();
294
+ };
295
+
296
+ Typeahead.prototype.focus = function (e) {
297
+ if (!this.focused) {
298
+ this.focused = true;
299
+ if (this.options.minLength === 0 && !this.$element.val()) this.lookup();
300
+ }
301
+ };
302
+
303
+ Typeahead.prototype.blur = function (e) {
304
+ this.focused = false;
305
+ if (!this.mousedover && this.shown) this.hide();
306
+ };
307
+
308
+ Typeahead.prototype.click = function (e) {
309
+ e.stopPropagation();
310
+ e.preventDefault();
311
+ this.select();
312
+ this.$element.focus();
313
+ };
314
+
315
+ Typeahead.prototype.mouseenter = function (e) {
316
+ this.mousedover = true;
317
+ this.$menu.find('.active').removeClass('active');
318
+ $(e.currentTarget).addClass('active');
319
+ };
320
+
321
+ Typeahead.prototype.mouseleave = function (e) {
322
+ this.mousedover = false;
323
+ if (!this.focused && this.shown) this.hide();
324
+ };
325
+
326
+ // TYPEAHEAD PLUGIN DEFINITION
327
+ // ===========================
328
+
329
+ function Plugin(option) {
330
+ return this.each(function () {
331
+ var $this = $(this);
332
+ var data = $this.data('bs.typeahead');
333
+ var options = typeof option === 'object' && option;
334
+
335
+ if (!data) $this.data('bs.typeahead', (data = new Typeahead(this, options)));
336
+ if (typeof option === 'string') data[option]();
337
+ });
338
+ }
339
+
340
+ var old = $.fn.typeahead;
341
+
342
+ $.fn.typeahead = Plugin;
343
+ $.fn.typeahead.Constructor = Typeahead;
344
+
345
+ // TYPEAHEAD NO CONFLICT
346
+ // =====================
347
+
348
+ $.fn.typeahead.noConflict = function () {
349
+ $.fn.typeahead = old;
350
+ return this;
351
+ };
352
+
353
+ // TYPEAHEAD DATA-API
354
+ // ==================
355
+
356
+ $(document).on('focus.bs.typeahead.data-api click.bs.typeahead.data-api', '[data-toggle="typeahead"]', function (e) {
357
+ var $this = $(this);
358
+ if ($this.data('typeahead')) return;
359
+ Plugin.call($this, $this.data());
360
+ });
361
+
362
+ }(jQuery);