adminpanel 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/.rspec +2 -2
  2. data/.ruby-version +1 -0
  3. data/.travis.yml +8 -8
  4. data/Gemfile +26 -24
  5. data/README.md +57 -57
  6. data/adminpanel.gemspec +41 -39
  7. data/app/assets/fonts/fontawesome-webfont.svg +254 -254
  8. data/app/assets/javascripts/adminpanel/bootstrap-datepicker.js +1159 -1159
  9. data/app/assets/javascripts/adminpanel/bootstrap-timepicker.js +803 -803
  10. data/app/assets/javascripts/adminpanel/bootstrap.js +2170 -2170
  11. data/app/assets/javascripts/adminpanel/{products.js → images_form.js} +13 -13
  12. data/app/assets/javascripts/adminpanel/imagesloaded.js +12 -12
  13. data/app/assets/javascripts/adminpanel/jquery.dataTables.min.js +155 -155
  14. data/app/assets/javascripts/adminpanel/jquery.facybox.js +395 -395
  15. data/app/assets/javascripts/adminpanel/jquery.masonry.min.js +9 -9
  16. data/app/assets/javascripts/adminpanel/jquery.slimscroll.min.js +13 -13
  17. data/app/assets/javascripts/adminpanel/medium-editor.js +702 -702
  18. data/app/assets/javascripts/adminpanel/realm.js +87 -87
  19. data/app/assets/javascripts/adminpanel/tables.js +126 -126
  20. data/app/assets/javascripts/application-admin.js +15 -15
  21. data/app/assets/stylesheets/adminpanel/_clearfix.css.scss +7 -7
  22. data/app/assets/stylesheets/adminpanel/alertify.css +241 -241
  23. data/app/assets/stylesheets/adminpanel/bootstrap.css +6103 -6103
  24. data/app/assets/stylesheets/adminpanel/colorpicker.css +6 -6
  25. data/app/assets/stylesheets/adminpanel/datepicker.css +9 -9
  26. data/app/assets/stylesheets/adminpanel/elfinder.min.css +59 -59
  27. data/app/assets/stylesheets/adminpanel/facybox.css +146 -146
  28. data/app/assets/stylesheets/adminpanel/font-awesome.min.css +33 -33
  29. data/app/assets/stylesheets/adminpanel/fullcalendar.css +618 -618
  30. data/app/assets/stylesheets/adminpanel/fullcalendar.print.css +61 -61
  31. data/app/assets/stylesheets/adminpanel/select2.css +524 -524
  32. data/app/assets/stylesheets/adminpanel/theme.css +1571 -1571
  33. data/app/assets/stylesheets/adminpanel/timepicker.css +82 -82
  34. data/app/assets/stylesheets/application-admin.css +13 -13
  35. data/app/controllers/adminpanel/application_controller.rb +32 -17
  36. data/app/controllers/adminpanel/galleries_controller.rb +80 -80
  37. data/app/controllers/adminpanel/sections_controller.rb +45 -45
  38. data/app/controllers/adminpanel/sessions_controller.rb +26 -26
  39. data/app/controllers/adminpanel/users_controller.rb +84 -84
  40. data/app/helpers/adminpanel/application_helper.rb +41 -51
  41. data/app/helpers/adminpanel/breadcrumbs_helper.rb +16 -0
  42. data/app/helpers/adminpanel/custom_form_builder.rb +248 -0
  43. data/app/helpers/adminpanel/images_helper.rb +9 -9
  44. data/app/helpers/adminpanel/rest_actions_helper.rb +47 -0
  45. data/app/helpers/adminpanel/router_helper.rb +33 -0
  46. data/app/helpers/adminpanel/sessions_helper.rb +25 -25
  47. data/app/models/adminpanel/gallery.rb +60 -60
  48. data/app/models/adminpanel/image.rb +14 -14
  49. data/app/models/adminpanel/section.rb +22 -22
  50. data/app/models/adminpanel/user.rb +35 -35
  51. data/app/uploaders/adminpanel/gallery_uploader.rb +55 -55
  52. data/app/uploaders/adminpanel/image_uploader.rb +57 -57
  53. data/app/views/adminpanel/galleries/_galleries_table.html.erb +14 -14
  54. data/app/views/adminpanel/galleries/create.html.erb +2 -2
  55. data/app/views/adminpanel/galleries/delete.html.erb +2 -2
  56. data/app/views/adminpanel/galleries/edit.html.erb +25 -25
  57. data/app/views/adminpanel/galleries/index.html.erb +51 -51
  58. data/app/views/adminpanel/galleries/new.html.erb +17 -17
  59. data/app/views/adminpanel/galleries/show.html.erb +17 -17
  60. data/app/views/adminpanel/galleries/update.html.erb +2 -2
  61. data/app/views/adminpanel/sections/_image_fields.html.erb +23 -23
  62. data/app/views/adminpanel/sections/_sections_table.html.erb +16 -16
  63. data/app/views/adminpanel/sections/create.html.erb +2 -2
  64. data/app/views/adminpanel/sections/destroy.html.erb +2 -2
  65. data/app/views/adminpanel/sections/edit.html.erb +41 -41
  66. data/app/views/adminpanel/sections/index.html.erb +44 -44
  67. data/app/views/adminpanel/sections/new.html.erb +26 -26
  68. data/app/views/adminpanel/sections/show.html.erb +30 -30
  69. data/app/views/adminpanel/sections/update.html.erb +2 -2
  70. data/app/views/adminpanel/sessions/new.html.erb +25 -25
  71. data/app/views/adminpanel/users/_user_form.html.erb +20 -20
  72. data/app/views/adminpanel/users/edit.html.erb +5 -5
  73. data/app/views/adminpanel/users/index.html.erb +49 -49
  74. data/app/views/adminpanel/users/new.html.erb +5 -5
  75. data/app/views/adminpanel/users/show.html.erb +20 -20
  76. data/app/views/layouts/_shim.html.erb +3 -3
  77. data/app/views/layouts/_side_menu.html.erb +49 -43
  78. data/app/views/layouts/_top_bar.html.erb +43 -43
  79. data/app/views/layouts/admin-login.html.erb +28 -28
  80. data/app/views/layouts/admin.html.erb +41 -39
  81. data/app/views/shared/_breadcrumb.html.erb +6 -6
  82. data/app/views/shared/_error_messages.html.erb +16 -16
  83. data/app/views/shared/_form_fields.html.erb +25 -0
  84. data/app/views/{adminpanel/products → shared}/_image_fields.html.erb +23 -23
  85. data/app/views/shared/_init_editor.html.erb +24 -0
  86. data/app/views/shared/edit.html.erb +28 -0
  87. data/app/views/shared/index.html.erb +94 -0
  88. data/app/views/shared/new.html.erb +28 -0
  89. data/app/views/shared/show.html.erb +63 -0
  90. data/config/locales/en.yml +5 -5
  91. data/config/locales/es.yml +127 -129
  92. data/config/routes.rb +24 -16
  93. data/lib/adminpanel.rb +9 -7
  94. data/lib/adminpanel/active_record_extension.rb +38 -0
  95. data/lib/adminpanel/engine.rb +5 -5
  96. data/lib/adminpanel/version.rb +3 -3
  97. data/lib/generators/adminpanel/initialize/initialize_generator.rb +17 -0
  98. data/lib/generators/adminpanel/{install/templates/migrations → initialize/templates}/create_adminpanel_tables.rb +45 -64
  99. data/lib/generators/adminpanel/resource/resource_generator.rb +105 -0
  100. data/lib/generators/adminpanel/resource/templates/controller.rb +4 -0
  101. data/lib/generators/adminpanel/resource/templates/migration.rb +9 -0
  102. data/lib/generators/adminpanel/resource/templates/resource.rb +19 -0
  103. data/spec/dummy/.gitignore +17 -17
  104. data/spec/dummy/README.rdoc +261 -261
  105. data/spec/dummy/Rakefile +7 -7
  106. data/{app/views/adminpanel/categories/show.html.erb → spec/dummy/app/adminpanel/products.rb} +0 -0
  107. data/spec/dummy/app/assets/javascripts/application.js +13 -13
  108. data/spec/dummy/app/assets/stylesheets/application.css +13 -13
  109. data/spec/dummy/app/controllers/adminpanel/.gitkeep +0 -0
  110. data/spec/dummy/app/controllers/application_controller.rb +3 -11
  111. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  112. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  113. data/spec/dummy/config.ru +4 -4
  114. data/spec/dummy/config/application.rb +62 -62
  115. data/spec/dummy/config/boot.rb +9 -9
  116. data/spec/dummy/config/carrierwve.rb +5 -5
  117. data/spec/dummy/config/database.yml +24 -24
  118. data/spec/dummy/config/environment.rb +5 -5
  119. data/spec/dummy/config/environments/development.rb +41 -41
  120. data/spec/dummy/config/environments/production.rb +72 -72
  121. data/spec/dummy/config/environments/test.rb +41 -41
  122. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  123. data/spec/dummy/config/initializers/inflections.rb +15 -15
  124. data/spec/dummy/config/initializers/mime_types.rb +5 -5
  125. data/spec/dummy/config/initializers/secret_token.rb +8 -8
  126. data/spec/dummy/config/initializers/session_store.rb +8 -8
  127. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  128. data/spec/dummy/config/locales/en.yml +5 -5
  129. data/spec/dummy/config/routes.rb +4 -4
  130. data/spec/dummy/db/schema.rb +15 -15
  131. data/spec/dummy/public/404.html +26 -26
  132. data/spec/dummy/public/422.html +26 -26
  133. data/spec/dummy/public/500.html +25 -25
  134. data/spec/dummy/public/uploads/gallery/file/1/hipster.jpg +0 -0
  135. data/spec/dummy/public/uploads/gallery/file/1/thumb_hipster.jpg +0 -0
  136. data/spec/dummy/script/rails +6 -6
  137. data/spec/features/authentication_pages_spec.rb +43 -43
  138. data/spec/features/galleries_pages_spec.rb +124 -124
  139. data/spec/features/section_pages_spec.rb +37 -37
  140. data/spec/features/user_pages_spec.rb +48 -48
  141. data/spec/generators/initialize_spec.rb +9 -0
  142. data/spec/generators/resource_spec.rb +122 -0
  143. data/spec/models/gallery_spec.rb +21 -21
  144. data/spec/models/section_spec.rb +66 -66
  145. data/spec/models/user_spec.rb +105 -105
  146. data/spec/spec_helper.rb +32 -31
  147. data/spec/support/define_factory_models.rb +25 -36
  148. data/spec/support/helper_methods.rb +26 -26
  149. data/spec/support/submit_forms_without_button.rb +16 -16
  150. data/spec/support/test_database.rb +45 -58
  151. data/spec/uploaders/gallery_uploader_spec.rb +36 -30
  152. data/spec/uploaders/image_uploader_spec.rb +30 -29
  153. metadata +208 -64
  154. checksums.yaml +0 -7
  155. data/app/assets/javascripts/adminpanel/init_editor.js +0 -28
  156. data/app/controllers/adminpanel/categories_controller.rb +0 -41
  157. data/app/controllers/adminpanel/products_controller.rb +0 -88
  158. data/app/helpers/custom_form_builder.rb +0 -219
  159. data/app/models/adminpanel/category.rb +0 -7
  160. data/app/models/adminpanel/product.rb +0 -24
  161. data/app/views/adminpanel/categories/edit.html.erb +0 -18
  162. data/app/views/adminpanel/categories/index.html.erb +0 -55
  163. data/app/views/adminpanel/categories/new.html.erb +0 -18
  164. data/app/views/adminpanel/products/.DS_Store +0 -0
  165. data/app/views/adminpanel/products/_product_form.html.erb +0 -31
  166. data/app/views/adminpanel/products/edit.html.erb +0 -10
  167. data/app/views/adminpanel/products/index.html.erb +0 -51
  168. data/app/views/adminpanel/products/new.html.erb +0 -10
  169. data/app/views/adminpanel/products/show.html.erb +0 -61
  170. data/config/database.yml +0 -24
  171. data/lib/generators/adminpanel/install/install_generator.rb +0 -12
  172. data/spec/features/categories_pages_spec.rb +0 -44
  173. data/spec/features/product_pages_spec.rb +0 -64
  174. data/spec/models/category_spec.rb +0 -58
  175. data/spec/models/product_spec.rb +0 -51
@@ -1,2170 +1,2170 @@
1
- /* ===================================================
2
- * bootstrap-transition.js v2.2.2
3
- * http://twitter.github.com/bootstrap/javascript.html#transitions
4
- * ===================================================
5
- * Copyright 2012 Twitter, Inc.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- * ========================================================== */
19
-
20
-
21
- !function ($) {
22
-
23
- "use strict"; // jshint ;_;
24
-
25
-
26
- /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
27
- * ======================================================= */
28
-
29
- $(function () {
30
-
31
- $.support.transition = (function () {
32
-
33
- var transitionEnd = (function () {
34
-
35
- var el = document.createElement('bootstrap')
36
- , transEndEventNames = {
37
- 'WebkitTransition' : 'webkitTransitionEnd'
38
- , 'MozTransition' : 'transitionend'
39
- , 'OTransition' : 'oTransitionEnd otransitionend'
40
- , 'transition' : 'transitionend'
41
- }
42
- , name
43
-
44
- for (name in transEndEventNames){
45
- if (el.style[name] !== undefined) {
46
- return transEndEventNames[name]
47
- }
48
- }
49
-
50
- }())
51
-
52
- return transitionEnd && {
53
- end: transitionEnd
54
- }
55
-
56
- })()
57
-
58
- })
59
-
60
- }(window.jQuery);
61
- /* =========================================================
62
- * bootstrap-modal.js v2.2.2
63
- * http://twitter.github.com/bootstrap/javascript.html#modals
64
- * =========================================================
65
- * Copyright 2012 Twitter, Inc.
66
- *
67
- * Licensed under the Apache License, Version 2.0 (the "License");
68
- * you may not use this file except in compliance with the License.
69
- * You may obtain a copy of the License at
70
- *
71
- * http://www.apache.org/licenses/LICENSE-2.0
72
- *
73
- * Unless required by applicable law or agreed to in writing, software
74
- * distributed under the License is distributed on an "AS IS" BASIS,
75
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76
- * See the License for the specific language governing permissions and
77
- * limitations under the License.
78
- * ========================================================= */
79
-
80
-
81
- !function ($) {
82
-
83
- "use strict"; // jshint ;_;
84
-
85
-
86
- /* MODAL CLASS DEFINITION
87
- * ====================== */
88
-
89
- var Modal = function (element, options) {
90
- this.options = options
91
- this.$element = $(element)
92
- .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
93
- this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
94
- }
95
-
96
- Modal.prototype = {
97
-
98
- constructor: Modal
99
-
100
- , toggle: function () {
101
- return this[!this.isShown ? 'show' : 'hide']()
102
- }
103
-
104
- , show: function () {
105
- var that = this
106
- , e = $.Event('show')
107
-
108
- this.$element.trigger(e)
109
-
110
- if (this.isShown || e.isDefaultPrevented()) return
111
-
112
- this.isShown = true
113
-
114
- this.escape()
115
-
116
- this.backdrop(function () {
117
- var transition = $.support.transition && that.$element.hasClass('fade')
118
-
119
- if (!that.$element.parent().length) {
120
- that.$element.appendTo(document.body) //don't move modals dom position
121
- }
122
-
123
- that.$element
124
- .show()
125
-
126
- if (transition) {
127
- that.$element[0].offsetWidth // force reflow
128
- }
129
-
130
- that.$element
131
- .addClass('in')
132
- .attr('aria-hidden', false)
133
-
134
- that.enforceFocus()
135
-
136
- transition ?
137
- that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
138
- that.$element.focus().trigger('shown')
139
-
140
- })
141
- }
142
-
143
- , hide: function (e) {
144
- e && e.preventDefault()
145
-
146
- var that = this
147
-
148
- e = $.Event('hide')
149
-
150
- this.$element.trigger(e)
151
-
152
- if (!this.isShown || e.isDefaultPrevented()) return
153
-
154
- this.isShown = false
155
-
156
- this.escape()
157
-
158
- $(document).off('focusin.modal')
159
-
160
- this.$element
161
- .removeClass('in')
162
- .attr('aria-hidden', true)
163
-
164
- $.support.transition && this.$element.hasClass('fade') ?
165
- this.hideWithTransition() :
166
- this.hideModal()
167
- }
168
-
169
- , enforceFocus: function () {
170
- var that = this
171
- $(document).on('focusin.modal', function (e) {
172
- if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
173
- that.$element.focus()
174
- }
175
- })
176
- }
177
-
178
- , escape: function () {
179
- var that = this
180
- if (this.isShown && this.options.keyboard) {
181
- this.$element.on('keyup.dismiss.modal', function ( e ) {
182
- e.which == 27 && that.hide()
183
- })
184
- } else if (!this.isShown) {
185
- this.$element.off('keyup.dismiss.modal')
186
- }
187
- }
188
-
189
- , hideWithTransition: function () {
190
- var that = this
191
- , timeout = setTimeout(function () {
192
- that.$element.off($.support.transition.end)
193
- that.hideModal()
194
- }, 500)
195
-
196
- this.$element.one($.support.transition.end, function () {
197
- clearTimeout(timeout)
198
- that.hideModal()
199
- })
200
- }
201
-
202
- , hideModal: function (that) {
203
- this.$element
204
- .hide()
205
- .trigger('hidden')
206
-
207
- this.backdrop()
208
- }
209
-
210
- , removeBackdrop: function () {
211
- this.$backdrop.remove()
212
- this.$backdrop = null
213
- }
214
-
215
- , backdrop: function (callback) {
216
- var that = this
217
- , animate = this.$element.hasClass('fade') ? 'fade' : ''
218
-
219
- if (this.isShown && this.options.backdrop) {
220
- var doAnimate = $.support.transition && animate
221
-
222
- this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
223
- .appendTo(document.body)
224
-
225
- this.$backdrop.click(
226
- this.options.backdrop == 'static' ?
227
- $.proxy(this.$element[0].focus, this.$element[0])
228
- : $.proxy(this.hide, this)
229
- )
230
-
231
- if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
232
-
233
- this.$backdrop.addClass('in')
234
-
235
- doAnimate ?
236
- this.$backdrop.one($.support.transition.end, callback) :
237
- callback()
238
-
239
- } else if (!this.isShown && this.$backdrop) {
240
- this.$backdrop.removeClass('in')
241
-
242
- $.support.transition && this.$element.hasClass('fade')?
243
- this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
244
- this.removeBackdrop()
245
-
246
- } else if (callback) {
247
- callback()
248
- }
249
- }
250
- }
251
-
252
-
253
- /* MODAL PLUGIN DEFINITION
254
- * ======================= */
255
-
256
- var old = $.fn.modal
257
-
258
- $.fn.modal = function (option) {
259
- return this.each(function () {
260
- var $this = $(this)
261
- , data = $this.data('modal')
262
- , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
263
- if (!data) $this.data('modal', (data = new Modal(this, options)))
264
- if (typeof option == 'string') data[option]()
265
- else if (options.show) data.show()
266
- })
267
- }
268
-
269
- $.fn.modal.defaults = {
270
- backdrop: true
271
- , keyboard: true
272
- , show: true
273
- }
274
-
275
- $.fn.modal.Constructor = Modal
276
-
277
-
278
- /* MODAL NO CONFLICT
279
- * ================= */
280
-
281
- $.fn.modal.noConflict = function () {
282
- $.fn.modal = old
283
- return this
284
- }
285
-
286
-
287
- /* MODAL DATA-API
288
- * ============== */
289
-
290
- $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
291
- var $this = $(this)
292
- , href = $this.attr('href')
293
- , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
294
- , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
295
-
296
- e.preventDefault()
297
-
298
- $target
299
- .modal(option)
300
- .one('hide', function () {
301
- $this.focus()
302
- })
303
- })
304
-
305
- }(window.jQuery);
306
-
307
- /* ============================================================
308
- * bootstrap-dropdown.js v2.2.2
309
- * http://twitter.github.com/bootstrap/javascript.html#dropdowns
310
- * ============================================================
311
- * Copyright 2012 Twitter, Inc.
312
- *
313
- * Licensed under the Apache License, Version 2.0 (the "License");
314
- * you may not use this file except in compliance with the License.
315
- * You may obtain a copy of the License at
316
- *
317
- * http://www.apache.org/licenses/LICENSE-2.0
318
- *
319
- * Unless required by applicable law or agreed to in writing, software
320
- * distributed under the License is distributed on an "AS IS" BASIS,
321
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
322
- * See the License for the specific language governing permissions and
323
- * limitations under the License.
324
- * ============================================================ */
325
-
326
-
327
- !function ($) {
328
-
329
- "use strict"; // jshint ;_;
330
-
331
-
332
- /* DROPDOWN CLASS DEFINITION
333
- * ========================= */
334
-
335
- var toggle = '[data-toggle=dropdown]'
336
- , Dropdown = function (element) {
337
- var $el = $(element).on('click.dropdown.data-api', this.toggle)
338
- $('html').on('click.dropdown.data-api', function () {
339
- $el.parent().removeClass('open')
340
- })
341
- }
342
-
343
- Dropdown.prototype = {
344
-
345
- constructor: Dropdown
346
-
347
- , toggle: function (e) {
348
- var $this = $(this)
349
- , $parent
350
- , isActive
351
-
352
- if ($this.is('.disabled, :disabled')) return
353
-
354
- $parent = getParent($this)
355
-
356
- isActive = $parent.hasClass('open')
357
-
358
- clearMenus()
359
-
360
- if (!isActive) {
361
- $parent.toggleClass('open')
362
- }
363
-
364
- $this.focus()
365
-
366
- return false
367
- }
368
-
369
- , keydown: function (e) {
370
- var $this
371
- , $items
372
- , $active
373
- , $parent
374
- , isActive
375
- , index
376
-
377
- if (!/(38|40|27)/.test(e.keyCode)) return
378
-
379
- $this = $(this)
380
-
381
- e.preventDefault()
382
- e.stopPropagation()
383
-
384
- if ($this.is('.disabled, :disabled')) return
385
-
386
- $parent = getParent($this)
387
-
388
- isActive = $parent.hasClass('open')
389
-
390
- if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
391
-
392
- $items = $('[role=menu] li:not(.divider):visible a', $parent)
393
-
394
- if (!$items.length) return
395
-
396
- index = $items.index($items.filter(':focus'))
397
-
398
- if (e.keyCode == 38 && index > 0) index-- // up
399
- if (e.keyCode == 40 && index < $items.length - 1) index++ // down
400
- if (!~index) index = 0
401
-
402
- $items
403
- .eq(index)
404
- .focus()
405
- }
406
-
407
- }
408
-
409
- function clearMenus() {
410
- $(toggle).each(function () {
411
- getParent($(this)).removeClass('open')
412
- })
413
- }
414
-
415
- function getParent($this) {
416
- var selector = $this.attr('data-target')
417
- , $parent
418
-
419
- if (!selector) {
420
- selector = $this.attr('href')
421
- selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
422
- }
423
-
424
- $parent = $(selector)
425
- $parent.length || ($parent = $this.parent())
426
-
427
- return $parent
428
- }
429
-
430
-
431
- /* DROPDOWN PLUGIN DEFINITION
432
- * ========================== */
433
-
434
- var old = $.fn.dropdown
435
-
436
- $.fn.dropdown = function (option) {
437
- return this.each(function () {
438
- var $this = $(this)
439
- , data = $this.data('dropdown')
440
- if (!data) $this.data('dropdown', (data = new Dropdown(this)))
441
- if (typeof option == 'string') data[option].call($this)
442
- })
443
- }
444
-
445
- $.fn.dropdown.Constructor = Dropdown
446
-
447
-
448
- /* DROPDOWN NO CONFLICT
449
- * ==================== */
450
-
451
- $.fn.dropdown.noConflict = function () {
452
- $.fn.dropdown = old
453
- return this
454
- }
455
-
456
-
457
- /* APPLY TO STANDARD DROPDOWN ELEMENTS
458
- * =================================== */
459
-
460
- $(document)
461
- .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
462
- .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
463
- .on('touchstart.dropdown.data-api', '.dropdown-menu', function (e) { e.stopPropagation() })
464
- .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
465
- .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
466
-
467
- }(window.jQuery);
468
- /* =============================================================
469
- * bootstrap-scrollspy.js v2.2.2
470
- * http://twitter.github.com/bootstrap/javascript.html#scrollspy
471
- * =============================================================
472
- * Copyright 2012 Twitter, Inc.
473
- *
474
- * Licensed under the Apache License, Version 2.0 (the "License");
475
- * you may not use this file except in compliance with the License.
476
- * You may obtain a copy of the License at
477
- *
478
- * http://www.apache.org/licenses/LICENSE-2.0
479
- *
480
- * Unless required by applicable law or agreed to in writing, software
481
- * distributed under the License is distributed on an "AS IS" BASIS,
482
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
483
- * See the License for the specific language governing permissions and
484
- * limitations under the License.
485
- * ============================================================== */
486
-
487
-
488
- !function ($) {
489
-
490
- "use strict"; // jshint ;_;
491
-
492
-
493
- /* SCROLLSPY CLASS DEFINITION
494
- * ========================== */
495
-
496
- function ScrollSpy(element, options) {
497
- var process = $.proxy(this.process, this)
498
- , $element = $(element).is('body') ? $(window) : $(element)
499
- , href
500
- this.options = $.extend({}, $.fn.scrollspy.defaults, options)
501
- this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
502
- this.selector = (this.options.target
503
- || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
504
- || '') + ' .nav li > a'
505
- this.$body = $('body')
506
- this.refresh()
507
- this.process()
508
- }
509
-
510
- ScrollSpy.prototype = {
511
-
512
- constructor: ScrollSpy
513
-
514
- , refresh: function () {
515
- var self = this
516
- , $targets
517
-
518
- this.offsets = $([])
519
- this.targets = $([])
520
-
521
- $targets = this.$body
522
- .find(this.selector)
523
- .map(function () {
524
- var $el = $(this)
525
- , href = $el.data('target') || $el.attr('href')
526
- , $href = /^#\w/.test(href) && $(href)
527
- return ( $href
528
- && $href.length
529
- && [[ $href.position().top + self.$scrollElement.scrollTop(), href ]] ) || null
530
- })
531
- .sort(function (a, b) { return a[0] - b[0] })
532
- .each(function () {
533
- self.offsets.push(this[0])
534
- self.targets.push(this[1])
535
- })
536
- }
537
-
538
- , process: function () {
539
- var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
540
- , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
541
- , maxScroll = scrollHeight - this.$scrollElement.height()
542
- , offsets = this.offsets
543
- , targets = this.targets
544
- , activeTarget = this.activeTarget
545
- , i
546
-
547
- if (scrollTop >= maxScroll) {
548
- return activeTarget != (i = targets.last()[0])
549
- && this.activate ( i )
550
- }
551
-
552
- for (i = offsets.length; i--;) {
553
- activeTarget != targets[i]
554
- && scrollTop >= offsets[i]
555
- && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
556
- && this.activate( targets[i] )
557
- }
558
- }
559
-
560
- , activate: function (target) {
561
- var active
562
- , selector
563
-
564
- this.activeTarget = target
565
-
566
- $(this.selector)
567
- .parent('.active')
568
- .removeClass('active')
569
-
570
- selector = this.selector
571
- + '[data-target="' + target + '"],'
572
- + this.selector + '[href="' + target + '"]'
573
-
574
- active = $(selector)
575
- .parent('li')
576
- .addClass('active')
577
-
578
- if (active.parent('.dropdown-menu').length) {
579
- active = active.closest('li.dropdown').addClass('active')
580
- }
581
-
582
- active.trigger('activate')
583
- }
584
-
585
- }
586
-
587
-
588
- /* SCROLLSPY PLUGIN DEFINITION
589
- * =========================== */
590
-
591
- var old = $.fn.scrollspy
592
-
593
- $.fn.scrollspy = function (option) {
594
- return this.each(function () {
595
- var $this = $(this)
596
- , data = $this.data('scrollspy')
597
- , options = typeof option == 'object' && option
598
- if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
599
- if (typeof option == 'string') data[option]()
600
- })
601
- }
602
-
603
- $.fn.scrollspy.Constructor = ScrollSpy
604
-
605
- $.fn.scrollspy.defaults = {
606
- offset: 10
607
- }
608
-
609
-
610
- /* SCROLLSPY NO CONFLICT
611
- * ===================== */
612
-
613
- $.fn.scrollspy.noConflict = function () {
614
- $.fn.scrollspy = old
615
- return this
616
- }
617
-
618
-
619
- /* SCROLLSPY DATA-API
620
- * ================== */
621
-
622
- $(window).on('load', function () {
623
- $('[data-spy="scroll"]').each(function () {
624
- var $spy = $(this)
625
- $spy.scrollspy($spy.data())
626
- })
627
- })
628
-
629
- }(window.jQuery);
630
- /* ========================================================
631
- * bootstrap-tab.js v2.2.2
632
- * http://twitter.github.com/bootstrap/javascript.html#tabs
633
- * ========================================================
634
- * Copyright 2012 Twitter, Inc.
635
- *
636
- * Licensed under the Apache License, Version 2.0 (the "License");
637
- * you may not use this file except in compliance with the License.
638
- * You may obtain a copy of the License at
639
- *
640
- * http://www.apache.org/licenses/LICENSE-2.0
641
- *
642
- * Unless required by applicable law or agreed to in writing, software
643
- * distributed under the License is distributed on an "AS IS" BASIS,
644
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
645
- * See the License for the specific language governing permissions and
646
- * limitations under the License.
647
- * ======================================================== */
648
-
649
-
650
- !function ($) {
651
-
652
- "use strict"; // jshint ;_;
653
-
654
-
655
- /* TAB CLASS DEFINITION
656
- * ==================== */
657
-
658
- var Tab = function (element) {
659
- this.element = $(element)
660
- }
661
-
662
- Tab.prototype = {
663
-
664
- constructor: Tab
665
-
666
- , show: function () {
667
- var $this = this.element
668
- , $ul = $this.closest('ul:not(.dropdown-menu)')
669
- , selector = $this.attr('data-target')
670
- , previous
671
- , $target
672
- , e
673
-
674
- if (!selector) {
675
- selector = $this.attr('href')
676
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
677
- }
678
-
679
- if ( $this.parent('li').hasClass('active') ) return
680
-
681
- previous = $ul.find('.active:last a')[0]
682
-
683
- e = $.Event('show', {
684
- relatedTarget: previous
685
- })
686
-
687
- $this.trigger(e)
688
-
689
- if (e.isDefaultPrevented()) return
690
-
691
- $target = $(selector)
692
-
693
- this.activate($this.parent('li'), $ul)
694
- this.activate($target, $target.parent(), function () {
695
- $this.trigger({
696
- type: 'shown'
697
- , relatedTarget: previous
698
- })
699
- })
700
- }
701
-
702
- , activate: function ( element, container, callback) {
703
- var $active = container.find('> .active')
704
- , transition = callback
705
- && $.support.transition
706
- && $active.hasClass('fade')
707
-
708
- function next() {
709
- $active
710
- .removeClass('active')
711
- .find('> .dropdown-menu > .active')
712
- .removeClass('active')
713
-
714
- element.addClass('active')
715
-
716
- if (transition) {
717
- element[0].offsetWidth // reflow for transition
718
- element.addClass('in')
719
- } else {
720
- element.removeClass('fade')
721
- }
722
-
723
- if ( element.parent('.dropdown-menu') ) {
724
- element.closest('li.dropdown').addClass('active')
725
- }
726
-
727
- callback && callback()
728
- }
729
-
730
- transition ?
731
- $active.one($.support.transition.end, next) :
732
- next()
733
-
734
- $active.removeClass('in')
735
- }
736
- }
737
-
738
-
739
- /* TAB PLUGIN DEFINITION
740
- * ===================== */
741
-
742
- var old = $.fn.tab
743
-
744
- $.fn.tab = function ( option ) {
745
- return this.each(function () {
746
- var $this = $(this)
747
- , data = $this.data('tab')
748
- if (!data) $this.data('tab', (data = new Tab(this)))
749
- if (typeof option == 'string') data[option]()
750
- })
751
- }
752
-
753
- $.fn.tab.Constructor = Tab
754
-
755
-
756
- /* TAB NO CONFLICT
757
- * =============== */
758
-
759
- $.fn.tab.noConflict = function () {
760
- $.fn.tab = old
761
- return this
762
- }
763
-
764
-
765
- /* TAB DATA-API
766
- * ============ */
767
-
768
- $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
769
- e.preventDefault()
770
- $(this).tab('show')
771
- })
772
-
773
- }(window.jQuery);
774
- /* ===========================================================
775
- * bootstrap-tooltip.js v2.2.2
776
- * http://twitter.github.com/bootstrap/javascript.html#tooltips
777
- * Inspired by the original jQuery.tipsy by Jason Frame
778
- * ===========================================================
779
- * Copyright 2012 Twitter, Inc.
780
- *
781
- * Licensed under the Apache License, Version 2.0 (the "License");
782
- * you may not use this file except in compliance with the License.
783
- * You may obtain a copy of the License at
784
- *
785
- * http://www.apache.org/licenses/LICENSE-2.0
786
- *
787
- * Unless required by applicable law or agreed to in writing, software
788
- * distributed under the License is distributed on an "AS IS" BASIS,
789
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
790
- * See the License for the specific language governing permissions and
791
- * limitations under the License.
792
- * ========================================================== */
793
-
794
-
795
- !function ($) {
796
-
797
- "use strict"; // jshint ;_;
798
-
799
-
800
- /* TOOLTIP PUBLIC CLASS DEFINITION
801
- * =============================== */
802
-
803
- var Tooltip = function (element, options) {
804
- this.init('tooltip', element, options)
805
- }
806
-
807
- Tooltip.prototype = {
808
-
809
- constructor: Tooltip
810
-
811
- , init: function (type, element, options) {
812
- var eventIn
813
- , eventOut
814
-
815
- this.type = type
816
- this.$element = $(element)
817
- this.options = this.getOptions(options)
818
- this.enabled = true
819
-
820
- if (this.options.trigger == 'click') {
821
- this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
822
- } else if (this.options.trigger != 'manual') {
823
- eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
824
- eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
825
- this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
826
- this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
827
- }
828
-
829
- this.options.selector ?
830
- (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
831
- this.fixTitle()
832
- }
833
-
834
- , getOptions: function (options) {
835
- options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
836
-
837
- if (options.delay && typeof options.delay == 'number') {
838
- options.delay = {
839
- show: options.delay
840
- , hide: options.delay
841
- }
842
- }
843
-
844
- return options
845
- }
846
-
847
- , enter: function (e) {
848
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
849
-
850
- if (!self.options.delay || !self.options.delay.show) return self.show()
851
-
852
- clearTimeout(this.timeout)
853
- self.hoverState = 'in'
854
- this.timeout = setTimeout(function() {
855
- if (self.hoverState == 'in') self.show()
856
- }, self.options.delay.show)
857
- }
858
-
859
- , leave: function (e) {
860
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
861
-
862
- if (this.timeout) clearTimeout(this.timeout)
863
- if (!self.options.delay || !self.options.delay.hide) return self.hide()
864
-
865
- self.hoverState = 'out'
866
- this.timeout = setTimeout(function() {
867
- if (self.hoverState == 'out') self.hide()
868
- }, self.options.delay.hide)
869
- }
870
-
871
- , show: function () {
872
- var $tip
873
- , inside
874
- , pos
875
- , actualWidth
876
- , actualHeight
877
- , placement
878
- , tp
879
-
880
- if (this.hasContent() && this.enabled) {
881
- $tip = this.tip()
882
- this.setContent()
883
-
884
- if (this.options.animation) {
885
- $tip.addClass('fade')
886
- }
887
-
888
- placement = typeof this.options.placement == 'function' ?
889
- this.options.placement.call(this, $tip[0], this.$element[0]) :
890
- this.options.placement
891
-
892
- inside = /in/.test(placement)
893
-
894
- $tip
895
- .detach()
896
- .css({ top: 0, left: 0, display: 'block' })
897
- .insertAfter(this.$element)
898
-
899
- pos = this.getPosition(inside)
900
-
901
- actualWidth = $tip[0].offsetWidth
902
- actualHeight = $tip[0].offsetHeight
903
-
904
- switch (inside ? placement.split(' ')[1] : placement) {
905
- case 'bottom':
906
- tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
907
- break
908
- case 'top':
909
- tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
910
- break
911
- case 'left':
912
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
913
- break
914
- case 'right':
915
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
916
- break
917
- }
918
-
919
- $tip
920
- .offset(tp)
921
- .addClass(placement)
922
- .addClass('in')
923
- }
924
- }
925
-
926
- , setContent: function () {
927
- var $tip = this.tip()
928
- , title = this.getTitle()
929
-
930
- $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
931
- $tip.removeClass('fade in top bottom left right')
932
- }
933
-
934
- , hide: function () {
935
- var that = this
936
- , $tip = this.tip()
937
-
938
- $tip.removeClass('in')
939
-
940
- function removeWithAnimation() {
941
- var timeout = setTimeout(function () {
942
- $tip.off($.support.transition.end).detach()
943
- }, 500)
944
-
945
- $tip.one($.support.transition.end, function () {
946
- clearTimeout(timeout)
947
- $tip.detach()
948
- })
949
- }
950
-
951
- $.support.transition && this.$tip.hasClass('fade') ?
952
- removeWithAnimation() :
953
- $tip.detach()
954
-
955
- return this
956
- }
957
-
958
- , fixTitle: function () {
959
- var $e = this.$element
960
- if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
961
- $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
962
- }
963
- }
964
-
965
- , hasContent: function () {
966
- return this.getTitle()
967
- }
968
-
969
- , getPosition: function (inside) {
970
- return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
971
- width: this.$element[0].offsetWidth
972
- , height: this.$element[0].offsetHeight
973
- })
974
- }
975
-
976
- , getTitle: function () {
977
- var title
978
- , $e = this.$element
979
- , o = this.options
980
-
981
- title = $e.attr('data-original-title')
982
- || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
983
-
984
- return title
985
- }
986
-
987
- , tip: function () {
988
- return this.$tip = this.$tip || $(this.options.template)
989
- }
990
-
991
- , validate: function () {
992
- if (!this.$element[0].parentNode) {
993
- this.hide()
994
- this.$element = null
995
- this.options = null
996
- }
997
- }
998
-
999
- , enable: function () {
1000
- this.enabled = true
1001
- }
1002
-
1003
- , disable: function () {
1004
- this.enabled = false
1005
- }
1006
-
1007
- , toggleEnabled: function () {
1008
- this.enabled = !this.enabled
1009
- }
1010
-
1011
- , toggle: function (e) {
1012
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
1013
- self[self.tip().hasClass('in') ? 'hide' : 'show']()
1014
- }
1015
-
1016
- , destroy: function () {
1017
- this.hide().$element.off('.' + this.type).removeData(this.type)
1018
- }
1019
-
1020
- }
1021
-
1022
-
1023
- /* TOOLTIP PLUGIN DEFINITION
1024
- * ========================= */
1025
-
1026
- var old = $.fn.tooltip
1027
-
1028
- $.fn.tooltip = function ( option ) {
1029
- return this.each(function () {
1030
- var $this = $(this)
1031
- , data = $this.data('tooltip')
1032
- , options = typeof option == 'object' && option
1033
- if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
1034
- if (typeof option == 'string') data[option]()
1035
- })
1036
- }
1037
-
1038
- $.fn.tooltip.Constructor = Tooltip
1039
-
1040
- $.fn.tooltip.defaults = {
1041
- animation: true
1042
- , placement: 'top'
1043
- , selector: false
1044
- , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1045
- , trigger: 'hover'
1046
- , title: ''
1047
- , delay: 0
1048
- , html: false
1049
- }
1050
-
1051
-
1052
- /* TOOLTIP NO CONFLICT
1053
- * =================== */
1054
-
1055
- $.fn.tooltip.noConflict = function () {
1056
- $.fn.tooltip = old
1057
- return this
1058
- }
1059
-
1060
- }(window.jQuery);
1061
- /* ===========================================================
1062
- * bootstrap-popover.js v2.2.2
1063
- * http://twitter.github.com/bootstrap/javascript.html#popovers
1064
- * ===========================================================
1065
- * Copyright 2012 Twitter, Inc.
1066
- *
1067
- * Licensed under the Apache License, Version 2.0 (the "License");
1068
- * you may not use this file except in compliance with the License.
1069
- * You may obtain a copy of the License at
1070
- *
1071
- * http://www.apache.org/licenses/LICENSE-2.0
1072
- *
1073
- * Unless required by applicable law or agreed to in writing, software
1074
- * distributed under the License is distributed on an "AS IS" BASIS,
1075
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1076
- * See the License for the specific language governing permissions and
1077
- * limitations under the License.
1078
- * =========================================================== */
1079
-
1080
-
1081
- !function ($) {
1082
-
1083
- "use strict"; // jshint ;_;
1084
-
1085
-
1086
- /* POPOVER PUBLIC CLASS DEFINITION
1087
- * =============================== */
1088
-
1089
- var Popover = function (element, options) {
1090
- this.init('popover', element, options)
1091
- }
1092
-
1093
-
1094
- /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
1095
- ========================================== */
1096
-
1097
- Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
1098
-
1099
- constructor: Popover
1100
-
1101
- , setContent: function () {
1102
- var $tip = this.tip()
1103
- , title = this.getTitle()
1104
- , content = this.getContent()
1105
-
1106
- $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1107
- $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
1108
-
1109
- $tip.removeClass('fade top bottom left right in')
1110
- }
1111
-
1112
- , hasContent: function () {
1113
- return this.getTitle() || this.getContent()
1114
- }
1115
-
1116
- , getContent: function () {
1117
- var content
1118
- , $e = this.$element
1119
- , o = this.options
1120
-
1121
- content = $e.attr('data-content')
1122
- || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
1123
-
1124
- return content
1125
- }
1126
-
1127
- , tip: function () {
1128
- if (!this.$tip) {
1129
- this.$tip = $(this.options.template)
1130
- }
1131
- return this.$tip
1132
- }
1133
-
1134
- , destroy: function () {
1135
- this.hide().$element.off('.' + this.type).removeData(this.type)
1136
- }
1137
-
1138
- })
1139
-
1140
-
1141
- /* POPOVER PLUGIN DEFINITION
1142
- * ======================= */
1143
-
1144
- var old = $.fn.popover
1145
-
1146
- $.fn.popover = function (option) {
1147
- return this.each(function () {
1148
- var $this = $(this)
1149
- , data = $this.data('popover')
1150
- , options = typeof option == 'object' && option
1151
- if (!data) $this.data('popover', (data = new Popover(this, options)))
1152
- if (typeof option == 'string') data[option]()
1153
- })
1154
- }
1155
-
1156
- $.fn.popover.Constructor = Popover
1157
-
1158
- $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
1159
- placement: 'right'
1160
- , trigger: 'click'
1161
- , content: ''
1162
- , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"></div></div></div>'
1163
- })
1164
-
1165
-
1166
- /* POPOVER NO CONFLICT
1167
- * =================== */
1168
-
1169
- $.fn.popover.noConflict = function () {
1170
- $.fn.popover = old
1171
- return this
1172
- }
1173
-
1174
- }(window.jQuery);
1175
- /* ==========================================================
1176
- * bootstrap-affix.js v2.2.2
1177
- * http://twitter.github.com/bootstrap/javascript.html#affix
1178
- * ==========================================================
1179
- * Copyright 2012 Twitter, Inc.
1180
- *
1181
- * Licensed under the Apache License, Version 2.0 (the "License");
1182
- * you may not use this file except in compliance with the License.
1183
- * You may obtain a copy of the License at
1184
- *
1185
- * http://www.apache.org/licenses/LICENSE-2.0
1186
- *
1187
- * Unless required by applicable law or agreed to in writing, software
1188
- * distributed under the License is distributed on an "AS IS" BASIS,
1189
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1190
- * See the License for the specific language governing permissions and
1191
- * limitations under the License.
1192
- * ========================================================== */
1193
-
1194
-
1195
- !function ($) {
1196
-
1197
- "use strict"; // jshint ;_;
1198
-
1199
-
1200
- /* AFFIX CLASS DEFINITION
1201
- * ====================== */
1202
-
1203
- var Affix = function (element, options) {
1204
- this.options = $.extend({}, $.fn.affix.defaults, options)
1205
- this.$window = $(window)
1206
- .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
1207
- .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
1208
- this.$element = $(element)
1209
- this.checkPosition()
1210
- }
1211
-
1212
- Affix.prototype.checkPosition = function () {
1213
- if (!this.$element.is(':visible')) return
1214
-
1215
- var scrollHeight = $(document).height()
1216
- , scrollTop = this.$window.scrollTop()
1217
- , position = this.$element.offset()
1218
- , offset = this.options.offset
1219
- , offsetBottom = offset.bottom
1220
- , offsetTop = offset.top
1221
- , reset = 'affix affix-top affix-bottom'
1222
- , affix
1223
-
1224
- if (typeof offset != 'object') offsetBottom = offsetTop = offset
1225
- if (typeof offsetTop == 'function') offsetTop = offset.top()
1226
- if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
1227
-
1228
- affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
1229
- false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
1230
- 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
1231
- 'top' : false
1232
-
1233
- if (this.affixed === affix) return
1234
-
1235
- this.affixed = affix
1236
- this.unpin = affix == 'bottom' ? position.top - scrollTop : null
1237
-
1238
- this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
1239
- }
1240
-
1241
-
1242
- /* AFFIX PLUGIN DEFINITION
1243
- * ======================= */
1244
-
1245
- var old = $.fn.affix
1246
-
1247
- $.fn.affix = function (option) {
1248
- return this.each(function () {
1249
- var $this = $(this)
1250
- , data = $this.data('affix')
1251
- , options = typeof option == 'object' && option
1252
- if (!data) $this.data('affix', (data = new Affix(this, options)))
1253
- if (typeof option == 'string') data[option]()
1254
- })
1255
- }
1256
-
1257
- $.fn.affix.Constructor = Affix
1258
-
1259
- $.fn.affix.defaults = {
1260
- offset: 0
1261
- }
1262
-
1263
-
1264
- /* AFFIX NO CONFLICT
1265
- * ================= */
1266
-
1267
- $.fn.affix.noConflict = function () {
1268
- $.fn.affix = old
1269
- return this
1270
- }
1271
-
1272
-
1273
- /* AFFIX DATA-API
1274
- * ============== */
1275
-
1276
- $(window).on('load', function () {
1277
- $('[data-spy="affix"]').each(function () {
1278
- var $spy = $(this)
1279
- , data = $spy.data()
1280
-
1281
- data.offset = data.offset || {}
1282
-
1283
- data.offsetBottom && (data.offset.bottom = data.offsetBottom)
1284
- data.offsetTop && (data.offset.top = data.offsetTop)
1285
-
1286
- $spy.affix(data)
1287
- })
1288
- })
1289
-
1290
-
1291
- }(window.jQuery);
1292
- /* ==========================================================
1293
- * bootstrap-alert.js v2.2.2
1294
- * http://twitter.github.com/bootstrap/javascript.html#alerts
1295
- * ==========================================================
1296
- * Copyright 2012 Twitter, Inc.
1297
- *
1298
- * Licensed under the Apache License, Version 2.0 (the "License");
1299
- * you may not use this file except in compliance with the License.
1300
- * You may obtain a copy of the License at
1301
- *
1302
- * http://www.apache.org/licenses/LICENSE-2.0
1303
- *
1304
- * Unless required by applicable law or agreed to in writing, software
1305
- * distributed under the License is distributed on an "AS IS" BASIS,
1306
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1307
- * See the License for the specific language governing permissions and
1308
- * limitations under the License.
1309
- * ========================================================== */
1310
-
1311
-
1312
- !function ($) {
1313
-
1314
- "use strict"; // jshint ;_;
1315
-
1316
-
1317
- /* ALERT CLASS DEFINITION
1318
- * ====================== */
1319
-
1320
- var dismiss = '[data-dismiss="alert"]'
1321
- , Alert = function (el) {
1322
- $(el).on('click', dismiss, this.close)
1323
- }
1324
-
1325
- Alert.prototype.close = function (e) {
1326
- var $this = $(this)
1327
- , selector = $this.attr('data-target')
1328
- , $parent
1329
-
1330
- if (!selector) {
1331
- selector = $this.attr('href')
1332
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1333
- }
1334
-
1335
- $parent = $(selector)
1336
-
1337
- e && e.preventDefault()
1338
-
1339
- $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
1340
-
1341
- $parent.trigger(e = $.Event('close'))
1342
-
1343
- if (e.isDefaultPrevented()) return
1344
-
1345
- $parent.removeClass('in')
1346
-
1347
- function removeElement() {
1348
- $parent
1349
- .trigger('closed')
1350
- .remove()
1351
- }
1352
-
1353
- $.support.transition && $parent.hasClass('fade') ?
1354
- $parent.on($.support.transition.end, removeElement) :
1355
- removeElement()
1356
- }
1357
-
1358
-
1359
- /* ALERT PLUGIN DEFINITION
1360
- * ======================= */
1361
-
1362
- var old = $.fn.alert
1363
-
1364
- $.fn.alert = function (option) {
1365
- return this.each(function () {
1366
- var $this = $(this)
1367
- , data = $this.data('alert')
1368
- if (!data) $this.data('alert', (data = new Alert(this)))
1369
- if (typeof option == 'string') data[option].call($this)
1370
- })
1371
- }
1372
-
1373
- $.fn.alert.Constructor = Alert
1374
-
1375
-
1376
- /* ALERT NO CONFLICT
1377
- * ================= */
1378
-
1379
- $.fn.alert.noConflict = function () {
1380
- $.fn.alert = old
1381
- return this
1382
- }
1383
-
1384
-
1385
- /* ALERT DATA-API
1386
- * ============== */
1387
-
1388
- $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
1389
-
1390
- }(window.jQuery);
1391
- /* ============================================================
1392
- * bootstrap-button.js v2.2.2
1393
- * http://twitter.github.com/bootstrap/javascript.html#buttons
1394
- * ============================================================
1395
- * Copyright 2012 Twitter, Inc.
1396
- *
1397
- * Licensed under the Apache License, Version 2.0 (the "License");
1398
- * you may not use this file except in compliance with the License.
1399
- * You may obtain a copy of the License at
1400
- *
1401
- * http://www.apache.org/licenses/LICENSE-2.0
1402
- *
1403
- * Unless required by applicable law or agreed to in writing, software
1404
- * distributed under the License is distributed on an "AS IS" BASIS,
1405
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1406
- * See the License for the specific language governing permissions and
1407
- * limitations under the License.
1408
- * ============================================================ */
1409
-
1410
-
1411
- !function ($) {
1412
-
1413
- "use strict"; // jshint ;_;
1414
-
1415
-
1416
- /* BUTTON PUBLIC CLASS DEFINITION
1417
- * ============================== */
1418
-
1419
- var Button = function (element, options) {
1420
- this.$element = $(element)
1421
- this.options = $.extend({}, $.fn.button.defaults, options)
1422
- }
1423
-
1424
- Button.prototype.setState = function (state) {
1425
- var d = 'disabled'
1426
- , $el = this.$element
1427
- , data = $el.data()
1428
- , val = $el.is('input') ? 'val' : 'html'
1429
-
1430
- state = state + 'Text'
1431
- data.resetText || $el.data('resetText', $el[val]())
1432
-
1433
- $el[val](data[state] || this.options[state])
1434
-
1435
- // push to event loop to allow forms to submit
1436
- setTimeout(function () {
1437
- state == 'loadingText' ?
1438
- $el.addClass(d).attr(d, d) :
1439
- $el.removeClass(d).removeAttr(d)
1440
- }, 0)
1441
- }
1442
-
1443
- Button.prototype.toggle = function () {
1444
- var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
1445
-
1446
- $parent && $parent
1447
- .find('.active')
1448
- .removeClass('active')
1449
-
1450
- this.$element.toggleClass('active')
1451
- }
1452
-
1453
-
1454
- /* BUTTON PLUGIN DEFINITION
1455
- * ======================== */
1456
-
1457
- var old = $.fn.button
1458
-
1459
- $.fn.button = function (option) {
1460
- return this.each(function () {
1461
- var $this = $(this)
1462
- , data = $this.data('button')
1463
- , options = typeof option == 'object' && option
1464
- if (!data) $this.data('button', (data = new Button(this, options)))
1465
- if (option == 'toggle') data.toggle()
1466
- else if (option) data.setState(option)
1467
- })
1468
- }
1469
-
1470
- $.fn.button.defaults = {
1471
- loadingText: 'loading...'
1472
- }
1473
-
1474
- $.fn.button.Constructor = Button
1475
-
1476
-
1477
- /* BUTTON NO CONFLICT
1478
- * ================== */
1479
-
1480
- $.fn.button.noConflict = function () {
1481
- $.fn.button = old
1482
- return this
1483
- }
1484
-
1485
-
1486
- /* BUTTON DATA-API
1487
- * =============== */
1488
-
1489
- $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
1490
- var $btn = $(e.target)
1491
- if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
1492
- $btn.button('toggle')
1493
- })
1494
-
1495
- }(window.jQuery);
1496
- /* =============================================================
1497
- * bootstrap-collapse.js v2.2.2
1498
- * http://twitter.github.com/bootstrap/javascript.html#collapse
1499
- * =============================================================
1500
- * Copyright 2012 Twitter, Inc.
1501
- *
1502
- * Licensed under the Apache License, Version 2.0 (the "License");
1503
- * you may not use this file except in compliance with the License.
1504
- * You may obtain a copy of the License at
1505
- *
1506
- * http://www.apache.org/licenses/LICENSE-2.0
1507
- *
1508
- * Unless required by applicable law or agreed to in writing, software
1509
- * distributed under the License is distributed on an "AS IS" BASIS,
1510
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1511
- * See the License for the specific language governing permissions and
1512
- * limitations under the License.
1513
- * ============================================================ */
1514
-
1515
-
1516
- !function ($) {
1517
-
1518
- "use strict"; // jshint ;_;
1519
-
1520
-
1521
- /* COLLAPSE PUBLIC CLASS DEFINITION
1522
- * ================================ */
1523
-
1524
- var Collapse = function (element, options) {
1525
- this.$element = $(element)
1526
- this.options = $.extend({}, $.fn.collapse.defaults, options)
1527
-
1528
- if (this.options.parent) {
1529
- this.$parent = $(this.options.parent)
1530
- }
1531
-
1532
- this.options.toggle && this.toggle()
1533
- }
1534
-
1535
- Collapse.prototype = {
1536
-
1537
- constructor: Collapse
1538
-
1539
- , dimension: function () {
1540
- var hasWidth = this.$element.hasClass('width')
1541
- return hasWidth ? 'width' : 'height'
1542
- }
1543
-
1544
- , show: function () {
1545
- var dimension
1546
- , scroll
1547
- , actives
1548
- , hasData
1549
-
1550
- if (this.transitioning) return
1551
-
1552
- dimension = this.dimension()
1553
- scroll = $.camelCase(['scroll', dimension].join('-'))
1554
- actives = this.$parent && this.$parent.find('> .accordion-group > .in')
1555
-
1556
- if (actives && actives.length) {
1557
- hasData = actives.data('collapse')
1558
- if (hasData && hasData.transitioning) return
1559
- actives.collapse('hide')
1560
- hasData || actives.data('collapse', null)
1561
- }
1562
-
1563
- this.$element[dimension](0)
1564
- this.transition('addClass', $.Event('show'), 'shown')
1565
- $.support.transition && this.$element[dimension](this.$element[0][scroll])
1566
- }
1567
-
1568
- , hide: function () {
1569
- var dimension
1570
- if (this.transitioning) return
1571
- dimension = this.dimension()
1572
- this.reset(this.$element[dimension]())
1573
- this.transition('removeClass', $.Event('hide'), 'hidden')
1574
- this.$element[dimension](0)
1575
- }
1576
-
1577
- , reset: function (size) {
1578
- var dimension = this.dimension()
1579
-
1580
- this.$element
1581
- .removeClass('collapse')
1582
- [dimension](size || 'auto')
1583
- [0].offsetWidth
1584
-
1585
- this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
1586
-
1587
- return this
1588
- }
1589
-
1590
- , transition: function (method, startEvent, completeEvent) {
1591
- var that = this
1592
- , complete = function () {
1593
- if (startEvent.type == 'show') that.reset()
1594
- that.transitioning = 0
1595
- that.$element.trigger(completeEvent)
1596
- }
1597
-
1598
- this.$element.trigger(startEvent)
1599
-
1600
- if (startEvent.isDefaultPrevented()) return
1601
-
1602
- this.transitioning = 1
1603
-
1604
- this.$element[method]('in')
1605
-
1606
- $.support.transition && this.$element.hasClass('collapse') ?
1607
- this.$element.one($.support.transition.end, complete) :
1608
- complete()
1609
- }
1610
-
1611
- , toggle: function () {
1612
- this[this.$element.hasClass('in') ? 'hide' : 'show']()
1613
- }
1614
-
1615
- }
1616
-
1617
-
1618
- /* COLLAPSE PLUGIN DEFINITION
1619
- * ========================== */
1620
-
1621
- var old = $.fn.collapse
1622
-
1623
- $.fn.collapse = function (option) {
1624
- return this.each(function () {
1625
- var $this = $(this)
1626
- , data = $this.data('collapse')
1627
- , options = typeof option == 'object' && option
1628
- if (!data) $this.data('collapse', (data = new Collapse(this, options)))
1629
- if (typeof option == 'string') data[option]()
1630
- })
1631
- }
1632
-
1633
- $.fn.collapse.defaults = {
1634
- toggle: true
1635
- }
1636
-
1637
- $.fn.collapse.Constructor = Collapse
1638
-
1639
-
1640
- /* COLLAPSE NO CONFLICT
1641
- * ==================== */
1642
-
1643
- $.fn.collapse.noConflict = function () {
1644
- $.fn.collapse = old
1645
- return this
1646
- }
1647
-
1648
-
1649
- /* COLLAPSE DATA-API
1650
- * ================= */
1651
-
1652
- $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
1653
- var $this = $(this), href
1654
- , target = $this.attr('data-target')
1655
- || e.preventDefault()
1656
- || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
1657
- , option = $(target).data('collapse') ? 'toggle' : $this.data()
1658
- $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
1659
- $(target).collapse(option)
1660
- })
1661
-
1662
- }(window.jQuery);
1663
- /* ==========================================================
1664
- * bootstrap-carousel.js v2.2.2
1665
- * http://twitter.github.com/bootstrap/javascript.html#carousel
1666
- * ==========================================================
1667
- * Copyright 2012 Twitter, Inc.
1668
- *
1669
- * Licensed under the Apache License, Version 2.0 (the "License");
1670
- * you may not use this file except in compliance with the License.
1671
- * You may obtain a copy of the License at
1672
- *
1673
- * http://www.apache.org/licenses/LICENSE-2.0
1674
- *
1675
- * Unless required by applicable law or agreed to in writing, software
1676
- * distributed under the License is distributed on an "AS IS" BASIS,
1677
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1678
- * See the License for the specific language governing permissions and
1679
- * limitations under the License.
1680
- * ========================================================== */
1681
-
1682
-
1683
- !function ($) {
1684
-
1685
- "use strict"; // jshint ;_;
1686
-
1687
-
1688
- /* CAROUSEL CLASS DEFINITION
1689
- * ========================= */
1690
-
1691
- var Carousel = function (element, options) {
1692
- this.$element = $(element)
1693
- this.options = options
1694
- this.options.pause == 'hover' && this.$element
1695
- .on('mouseenter', $.proxy(this.pause, this))
1696
- .on('mouseleave', $.proxy(this.cycle, this))
1697
- }
1698
-
1699
- Carousel.prototype = {
1700
-
1701
- cycle: function (e) {
1702
- if (!e) this.paused = false
1703
- this.options.interval
1704
- && !this.paused
1705
- && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
1706
- return this
1707
- }
1708
-
1709
- , to: function (pos) {
1710
- var $active = this.$element.find('.item.active')
1711
- , children = $active.parent().children()
1712
- , activePos = children.index($active)
1713
- , that = this
1714
-
1715
- if (pos > (children.length - 1) || pos < 0) return
1716
-
1717
- if (this.sliding) {
1718
- return this.$element.one('slid', function () {
1719
- that.to(pos)
1720
- })
1721
- }
1722
-
1723
- if (activePos == pos) {
1724
- return this.pause().cycle()
1725
- }
1726
-
1727
- return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
1728
- }
1729
-
1730
- , pause: function (e) {
1731
- if (!e) this.paused = true
1732
- if (this.$element.find('.next, .prev').length && $.support.transition.end) {
1733
- this.$element.trigger($.support.transition.end)
1734
- this.cycle()
1735
- }
1736
- clearInterval(this.interval)
1737
- this.interval = null
1738
- return this
1739
- }
1740
-
1741
- , next: function () {
1742
- if (this.sliding) return
1743
- return this.slide('next')
1744
- }
1745
-
1746
- , prev: function () {
1747
- if (this.sliding) return
1748
- return this.slide('prev')
1749
- }
1750
-
1751
- , slide: function (type, next) {
1752
- var $active = this.$element.find('.item.active')
1753
- , $next = next || $active[type]()
1754
- , isCycling = this.interval
1755
- , direction = type == 'next' ? 'left' : 'right'
1756
- , fallback = type == 'next' ? 'first' : 'last'
1757
- , that = this
1758
- , e
1759
-
1760
- this.sliding = true
1761
-
1762
- isCycling && this.pause()
1763
-
1764
- $next = $next.length ? $next : this.$element.find('.item')[fallback]()
1765
-
1766
- e = $.Event('slide', {
1767
- relatedTarget: $next[0]
1768
- })
1769
-
1770
- if ($next.hasClass('active')) return
1771
-
1772
- if ($.support.transition && this.$element.hasClass('slide')) {
1773
- this.$element.trigger(e)
1774
- if (e.isDefaultPrevented()) return
1775
- $next.addClass(type)
1776
- $next[0].offsetWidth // force reflow
1777
- $active.addClass(direction)
1778
- $next.addClass(direction)
1779
- this.$element.one($.support.transition.end, function () {
1780
- $next.removeClass([type, direction].join(' ')).addClass('active')
1781
- $active.removeClass(['active', direction].join(' '))
1782
- that.sliding = false
1783
- setTimeout(function () { that.$element.trigger('slid') }, 0)
1784
- })
1785
- } else {
1786
- this.$element.trigger(e)
1787
- if (e.isDefaultPrevented()) return
1788
- $active.removeClass('active')
1789
- $next.addClass('active')
1790
- this.sliding = false
1791
- this.$element.trigger('slid')
1792
- }
1793
-
1794
- isCycling && this.cycle()
1795
-
1796
- return this
1797
- }
1798
-
1799
- }
1800
-
1801
-
1802
- /* CAROUSEL PLUGIN DEFINITION
1803
- * ========================== */
1804
-
1805
- var old = $.fn.carousel
1806
-
1807
- $.fn.carousel = function (option) {
1808
- return this.each(function () {
1809
- var $this = $(this)
1810
- , data = $this.data('carousel')
1811
- , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
1812
- , action = typeof option == 'string' ? option : options.slide
1813
- if (!data) $this.data('carousel', (data = new Carousel(this, options)))
1814
- if (typeof option == 'number') data.to(option)
1815
- else if (action) data[action]()
1816
- else if (options.interval) data.cycle()
1817
- })
1818
- }
1819
-
1820
- $.fn.carousel.defaults = {
1821
- interval: 5000
1822
- , pause: 'hover'
1823
- }
1824
-
1825
- $.fn.carousel.Constructor = Carousel
1826
-
1827
-
1828
- /* CAROUSEL NO CONFLICT
1829
- * ==================== */
1830
-
1831
- $.fn.carousel.noConflict = function () {
1832
- $.fn.carousel = old
1833
- return this
1834
- }
1835
-
1836
- /* CAROUSEL DATA-API
1837
- * ================= */
1838
-
1839
- $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
1840
- var $this = $(this), href
1841
- , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1842
- , options = $.extend({}, $target.data(), $this.data())
1843
- $target.carousel(options)
1844
- e.preventDefault()
1845
- })
1846
-
1847
- }(window.jQuery);
1848
- /* =============================================================
1849
- * bootstrap-typeahead.js v2.2.2
1850
- * http://twitter.github.com/bootstrap/javascript.html#typeahead
1851
- * =============================================================
1852
- * Copyright 2012 Twitter, Inc.
1853
- *
1854
- * Licensed under the Apache License, Version 2.0 (the "License");
1855
- * you may not use this file except in compliance with the License.
1856
- * You may obtain a copy of the License at
1857
- *
1858
- * http://www.apache.org/licenses/LICENSE-2.0
1859
- *
1860
- * Unless required by applicable law or agreed to in writing, software
1861
- * distributed under the License is distributed on an "AS IS" BASIS,
1862
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1863
- * See the License for the specific language governing permissions and
1864
- * limitations under the License.
1865
- * ============================================================ */
1866
-
1867
-
1868
- !function($){
1869
-
1870
- "use strict"; // jshint ;_;
1871
-
1872
-
1873
- /* TYPEAHEAD PUBLIC CLASS DEFINITION
1874
- * ================================= */
1875
-
1876
- var Typeahead = function (element, options) {
1877
- this.$element = $(element)
1878
- this.options = $.extend({}, $.fn.typeahead.defaults, options)
1879
- this.matcher = this.options.matcher || this.matcher
1880
- this.sorter = this.options.sorter || this.sorter
1881
- this.highlighter = this.options.highlighter || this.highlighter
1882
- this.updater = this.options.updater || this.updater
1883
- this.source = this.options.source
1884
- this.$menu = $(this.options.menu)
1885
- this.shown = false
1886
- this.listen()
1887
- }
1888
-
1889
- Typeahead.prototype = {
1890
-
1891
- constructor: Typeahead
1892
-
1893
- , select: function () {
1894
- var val = this.$menu.find('.active').attr('data-value')
1895
- this.$element
1896
- .val(this.updater(val))
1897
- .change()
1898
- return this.hide()
1899
- }
1900
-
1901
- , updater: function (item) {
1902
- return item
1903
- }
1904
-
1905
- , show: function () {
1906
- var pos = $.extend({}, this.$element.position(), {
1907
- height: this.$element[0].offsetHeight
1908
- })
1909
-
1910
- this.$menu
1911
- .insertAfter(this.$element)
1912
- .css({
1913
- top: pos.top + pos.height
1914
- , left: pos.left
1915
- })
1916
- .show()
1917
-
1918
- this.shown = true
1919
- return this
1920
- }
1921
-
1922
- , hide: function () {
1923
- this.$menu.hide()
1924
- this.shown = false
1925
- return this
1926
- }
1927
-
1928
- , lookup: function (event) {
1929
- var items
1930
-
1931
- this.query = this.$element.val()
1932
-
1933
- if (!this.query || this.query.length < this.options.minLength) {
1934
- return this.shown ? this.hide() : this
1935
- }
1936
-
1937
- items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
1938
-
1939
- return items ? this.process(items) : this
1940
- }
1941
-
1942
- , process: function (items) {
1943
- var that = this
1944
-
1945
- items = $.grep(items, function (item) {
1946
- return that.matcher(item)
1947
- })
1948
-
1949
- items = this.sorter(items)
1950
-
1951
- if (!items.length) {
1952
- return this.shown ? this.hide() : this
1953
- }
1954
-
1955
- return this.render(items.slice(0, this.options.items)).show()
1956
- }
1957
-
1958
- , matcher: function (item) {
1959
- return ~item.toLowerCase().indexOf(this.query.toLowerCase())
1960
- }
1961
-
1962
- , sorter: function (items) {
1963
- var beginswith = []
1964
- , caseSensitive = []
1965
- , caseInsensitive = []
1966
- , item
1967
-
1968
- while (item = items.shift()) {
1969
- if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
1970
- else if (~item.indexOf(this.query)) caseSensitive.push(item)
1971
- else caseInsensitive.push(item)
1972
- }
1973
-
1974
- return beginswith.concat(caseSensitive, caseInsensitive)
1975
- }
1976
-
1977
- , highlighter: function (item) {
1978
- var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
1979
- return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
1980
- return '<strong>' + match + '</strong>'
1981
- })
1982
- }
1983
-
1984
- , render: function (items) {
1985
- var that = this
1986
-
1987
- items = $(items).map(function (i, item) {
1988
- i = $(that.options.item).attr('data-value', item)
1989
- i.find('a').html(that.highlighter(item))
1990
- return i[0]
1991
- })
1992
-
1993
- items.first().addClass('active')
1994
- this.$menu.html(items)
1995
- return this
1996
- }
1997
-
1998
- , next: function (event) {
1999
- var active = this.$menu.find('.active').removeClass('active')
2000
- , next = active.next()
2001
-
2002
- if (!next.length) {
2003
- next = $(this.$menu.find('li')[0])
2004
- }
2005
-
2006
- next.addClass('active')
2007
- }
2008
-
2009
- , prev: function (event) {
2010
- var active = this.$menu.find('.active').removeClass('active')
2011
- , prev = active.prev()
2012
-
2013
- if (!prev.length) {
2014
- prev = this.$menu.find('li').last()
2015
- }
2016
-
2017
- prev.addClass('active')
2018
- }
2019
-
2020
- , listen: function () {
2021
- this.$element
2022
- .on('blur', $.proxy(this.blur, this))
2023
- .on('keypress', $.proxy(this.keypress, this))
2024
- .on('keyup', $.proxy(this.keyup, this))
2025
-
2026
- if (this.eventSupported('keydown')) {
2027
- this.$element.on('keydown', $.proxy(this.keydown, this))
2028
- }
2029
-
2030
- this.$menu
2031
- .on('click', $.proxy(this.click, this))
2032
- .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
2033
- }
2034
-
2035
- , eventSupported: function(eventName) {
2036
- var isSupported = eventName in this.$element
2037
- if (!isSupported) {
2038
- this.$element.setAttribute(eventName, 'return;')
2039
- isSupported = typeof this.$element[eventName] === 'function'
2040
- }
2041
- return isSupported
2042
- }
2043
-
2044
- , move: function (e) {
2045
- if (!this.shown) return
2046
-
2047
- switch(e.keyCode) {
2048
- case 9: // tab
2049
- case 13: // enter
2050
- case 27: // escape
2051
- e.preventDefault()
2052
- break
2053
-
2054
- case 38: // up arrow
2055
- e.preventDefault()
2056
- this.prev()
2057
- break
2058
-
2059
- case 40: // down arrow
2060
- e.preventDefault()
2061
- this.next()
2062
- break
2063
- }
2064
-
2065
- e.stopPropagation()
2066
- }
2067
-
2068
- , keydown: function (e) {
2069
- this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
2070
- this.move(e)
2071
- }
2072
-
2073
- , keypress: function (e) {
2074
- if (this.suppressKeyPressRepeat) return
2075
- this.move(e)
2076
- }
2077
-
2078
- , keyup: function (e) {
2079
- switch(e.keyCode) {
2080
- case 40: // down arrow
2081
- case 38: // up arrow
2082
- case 16: // shift
2083
- case 17: // ctrl
2084
- case 18: // alt
2085
- break
2086
-
2087
- case 9: // tab
2088
- case 13: // enter
2089
- if (!this.shown) return
2090
- this.select()
2091
- break
2092
-
2093
- case 27: // escape
2094
- if (!this.shown) return
2095
- this.hide()
2096
- break
2097
-
2098
- default:
2099
- this.lookup()
2100
- }
2101
-
2102
- e.stopPropagation()
2103
- e.preventDefault()
2104
- }
2105
-
2106
- , blur: function (e) {
2107
- var that = this
2108
- setTimeout(function () { that.hide() }, 150)
2109
- }
2110
-
2111
- , click: function (e) {
2112
- e.stopPropagation()
2113
- e.preventDefault()
2114
- this.select()
2115
- }
2116
-
2117
- , mouseenter: function (e) {
2118
- this.$menu.find('.active').removeClass('active')
2119
- $(e.currentTarget).addClass('active')
2120
- }
2121
-
2122
- }
2123
-
2124
-
2125
- /* TYPEAHEAD PLUGIN DEFINITION
2126
- * =========================== */
2127
-
2128
- var old = $.fn.typeahead
2129
-
2130
- $.fn.typeahead = function (option) {
2131
- return this.each(function () {
2132
- var $this = $(this)
2133
- , data = $this.data('typeahead')
2134
- , options = typeof option == 'object' && option
2135
- if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
2136
- if (typeof option == 'string') data[option]()
2137
- })
2138
- }
2139
-
2140
- $.fn.typeahead.defaults = {
2141
- source: []
2142
- , items: 8
2143
- , menu: '<ul class="typeahead dropdown-menu"></ul>'
2144
- , item: '<li><a href="#"></a></li>'
2145
- , minLength: 1
2146
- }
2147
-
2148
- $.fn.typeahead.Constructor = Typeahead
2149
-
2150
-
2151
- /* TYPEAHEAD NO CONFLICT
2152
- * =================== */
2153
-
2154
- $.fn.typeahead.noConflict = function () {
2155
- $.fn.typeahead = old
2156
- return this
2157
- }
2158
-
2159
-
2160
- /* TYPEAHEAD DATA-API
2161
- * ================== */
2162
-
2163
- $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
2164
- var $this = $(this)
2165
- if ($this.data('typeahead')) return
2166
- e.preventDefault()
2167
- $this.typeahead($this.data())
2168
- })
2169
-
2170
- }(window.jQuery);
1
+ /* ===================================================
2
+ * bootstrap-transition.js v2.2.2
3
+ * http://twitter.github.com/bootstrap/javascript.html#transitions
4
+ * ===================================================
5
+ * Copyright 2012 Twitter, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * ========================================================== */
19
+
20
+
21
+ !function ($) {
22
+
23
+ "use strict"; // jshint ;_;
24
+
25
+
26
+ /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
27
+ * ======================================================= */
28
+
29
+ $(function () {
30
+
31
+ $.support.transition = (function () {
32
+
33
+ var transitionEnd = (function () {
34
+
35
+ var el = document.createElement('bootstrap')
36
+ , transEndEventNames = {
37
+ 'WebkitTransition' : 'webkitTransitionEnd'
38
+ , 'MozTransition' : 'transitionend'
39
+ , 'OTransition' : 'oTransitionEnd otransitionend'
40
+ , 'transition' : 'transitionend'
41
+ }
42
+ , name
43
+
44
+ for (name in transEndEventNames){
45
+ if (el.style[name] !== undefined) {
46
+ return transEndEventNames[name]
47
+ }
48
+ }
49
+
50
+ }())
51
+
52
+ return transitionEnd && {
53
+ end: transitionEnd
54
+ }
55
+
56
+ })()
57
+
58
+ })
59
+
60
+ }(window.jQuery);
61
+ /* =========================================================
62
+ * bootstrap-modal.js v2.2.2
63
+ * http://twitter.github.com/bootstrap/javascript.html#modals
64
+ * =========================================================
65
+ * Copyright 2012 Twitter, Inc.
66
+ *
67
+ * Licensed under the Apache License, Version 2.0 (the "License");
68
+ * you may not use this file except in compliance with the License.
69
+ * You may obtain a copy of the License at
70
+ *
71
+ * http://www.apache.org/licenses/LICENSE-2.0
72
+ *
73
+ * Unless required by applicable law or agreed to in writing, software
74
+ * distributed under the License is distributed on an "AS IS" BASIS,
75
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76
+ * See the License for the specific language governing permissions and
77
+ * limitations under the License.
78
+ * ========================================================= */
79
+
80
+
81
+ !function ($) {
82
+
83
+ "use strict"; // jshint ;_;
84
+
85
+
86
+ /* MODAL CLASS DEFINITION
87
+ * ====================== */
88
+
89
+ var Modal = function (element, options) {
90
+ this.options = options
91
+ this.$element = $(element)
92
+ .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
93
+ this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
94
+ }
95
+
96
+ Modal.prototype = {
97
+
98
+ constructor: Modal
99
+
100
+ , toggle: function () {
101
+ return this[!this.isShown ? 'show' : 'hide']()
102
+ }
103
+
104
+ , show: function () {
105
+ var that = this
106
+ , e = $.Event('show')
107
+
108
+ this.$element.trigger(e)
109
+
110
+ if (this.isShown || e.isDefaultPrevented()) return
111
+
112
+ this.isShown = true
113
+
114
+ this.escape()
115
+
116
+ this.backdrop(function () {
117
+ var transition = $.support.transition && that.$element.hasClass('fade')
118
+
119
+ if (!that.$element.parent().length) {
120
+ that.$element.appendTo(document.body) //don't move modals dom position
121
+ }
122
+
123
+ that.$element
124
+ .show()
125
+
126
+ if (transition) {
127
+ that.$element[0].offsetWidth // force reflow
128
+ }
129
+
130
+ that.$element
131
+ .addClass('in')
132
+ .attr('aria-hidden', false)
133
+
134
+ that.enforceFocus()
135
+
136
+ transition ?
137
+ that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
138
+ that.$element.focus().trigger('shown')
139
+
140
+ })
141
+ }
142
+
143
+ , hide: function (e) {
144
+ e && e.preventDefault()
145
+
146
+ var that = this
147
+
148
+ e = $.Event('hide')
149
+
150
+ this.$element.trigger(e)
151
+
152
+ if (!this.isShown || e.isDefaultPrevented()) return
153
+
154
+ this.isShown = false
155
+
156
+ this.escape()
157
+
158
+ $(document).off('focusin.modal')
159
+
160
+ this.$element
161
+ .removeClass('in')
162
+ .attr('aria-hidden', true)
163
+
164
+ $.support.transition && this.$element.hasClass('fade') ?
165
+ this.hideWithTransition() :
166
+ this.hideModal()
167
+ }
168
+
169
+ , enforceFocus: function () {
170
+ var that = this
171
+ $(document).on('focusin.modal', function (e) {
172
+ if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
173
+ that.$element.focus()
174
+ }
175
+ })
176
+ }
177
+
178
+ , escape: function () {
179
+ var that = this
180
+ if (this.isShown && this.options.keyboard) {
181
+ this.$element.on('keyup.dismiss.modal', function ( e ) {
182
+ e.which == 27 && that.hide()
183
+ })
184
+ } else if (!this.isShown) {
185
+ this.$element.off('keyup.dismiss.modal')
186
+ }
187
+ }
188
+
189
+ , hideWithTransition: function () {
190
+ var that = this
191
+ , timeout = setTimeout(function () {
192
+ that.$element.off($.support.transition.end)
193
+ that.hideModal()
194
+ }, 500)
195
+
196
+ this.$element.one($.support.transition.end, function () {
197
+ clearTimeout(timeout)
198
+ that.hideModal()
199
+ })
200
+ }
201
+
202
+ , hideModal: function (that) {
203
+ this.$element
204
+ .hide()
205
+ .trigger('hidden')
206
+
207
+ this.backdrop()
208
+ }
209
+
210
+ , removeBackdrop: function () {
211
+ this.$backdrop.remove()
212
+ this.$backdrop = null
213
+ }
214
+
215
+ , backdrop: function (callback) {
216
+ var that = this
217
+ , animate = this.$element.hasClass('fade') ? 'fade' : ''
218
+
219
+ if (this.isShown && this.options.backdrop) {
220
+ var doAnimate = $.support.transition && animate
221
+
222
+ this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
223
+ .appendTo(document.body)
224
+
225
+ this.$backdrop.click(
226
+ this.options.backdrop == 'static' ?
227
+ $.proxy(this.$element[0].focus, this.$element[0])
228
+ : $.proxy(this.hide, this)
229
+ )
230
+
231
+ if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
232
+
233
+ this.$backdrop.addClass('in')
234
+
235
+ doAnimate ?
236
+ this.$backdrop.one($.support.transition.end, callback) :
237
+ callback()
238
+
239
+ } else if (!this.isShown && this.$backdrop) {
240
+ this.$backdrop.removeClass('in')
241
+
242
+ $.support.transition && this.$element.hasClass('fade')?
243
+ this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
244
+ this.removeBackdrop()
245
+
246
+ } else if (callback) {
247
+ callback()
248
+ }
249
+ }
250
+ }
251
+
252
+
253
+ /* MODAL PLUGIN DEFINITION
254
+ * ======================= */
255
+
256
+ var old = $.fn.modal
257
+
258
+ $.fn.modal = function (option) {
259
+ return this.each(function () {
260
+ var $this = $(this)
261
+ , data = $this.data('modal')
262
+ , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
263
+ if (!data) $this.data('modal', (data = new Modal(this, options)))
264
+ if (typeof option == 'string') data[option]()
265
+ else if (options.show) data.show()
266
+ })
267
+ }
268
+
269
+ $.fn.modal.defaults = {
270
+ backdrop: true
271
+ , keyboard: true
272
+ , show: true
273
+ }
274
+
275
+ $.fn.modal.Constructor = Modal
276
+
277
+
278
+ /* MODAL NO CONFLICT
279
+ * ================= */
280
+
281
+ $.fn.modal.noConflict = function () {
282
+ $.fn.modal = old
283
+ return this
284
+ }
285
+
286
+
287
+ /* MODAL DATA-API
288
+ * ============== */
289
+
290
+ $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
291
+ var $this = $(this)
292
+ , href = $this.attr('href')
293
+ , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
294
+ , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
295
+
296
+ e.preventDefault()
297
+
298
+ $target
299
+ .modal(option)
300
+ .one('hide', function () {
301
+ $this.focus()
302
+ })
303
+ })
304
+
305
+ }(window.jQuery);
306
+
307
+ /* ============================================================
308
+ * bootstrap-dropdown.js v2.2.2
309
+ * http://twitter.github.com/bootstrap/javascript.html#dropdowns
310
+ * ============================================================
311
+ * Copyright 2012 Twitter, Inc.
312
+ *
313
+ * Licensed under the Apache License, Version 2.0 (the "License");
314
+ * you may not use this file except in compliance with the License.
315
+ * You may obtain a copy of the License at
316
+ *
317
+ * http://www.apache.org/licenses/LICENSE-2.0
318
+ *
319
+ * Unless required by applicable law or agreed to in writing, software
320
+ * distributed under the License is distributed on an "AS IS" BASIS,
321
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
322
+ * See the License for the specific language governing permissions and
323
+ * limitations under the License.
324
+ * ============================================================ */
325
+
326
+
327
+ !function ($) {
328
+
329
+ "use strict"; // jshint ;_;
330
+
331
+
332
+ /* DROPDOWN CLASS DEFINITION
333
+ * ========================= */
334
+
335
+ var toggle = '[data-toggle=dropdown]'
336
+ , Dropdown = function (element) {
337
+ var $el = $(element).on('click.dropdown.data-api', this.toggle)
338
+ $('html').on('click.dropdown.data-api', function () {
339
+ $el.parent().removeClass('open')
340
+ })
341
+ }
342
+
343
+ Dropdown.prototype = {
344
+
345
+ constructor: Dropdown
346
+
347
+ , toggle: function (e) {
348
+ var $this = $(this)
349
+ , $parent
350
+ , isActive
351
+
352
+ if ($this.is('.disabled, :disabled')) return
353
+
354
+ $parent = getParent($this)
355
+
356
+ isActive = $parent.hasClass('open')
357
+
358
+ clearMenus()
359
+
360
+ if (!isActive) {
361
+ $parent.toggleClass('open')
362
+ }
363
+
364
+ $this.focus()
365
+
366
+ return false
367
+ }
368
+
369
+ , keydown: function (e) {
370
+ var $this
371
+ , $items
372
+ , $active
373
+ , $parent
374
+ , isActive
375
+ , index
376
+
377
+ if (!/(38|40|27)/.test(e.keyCode)) return
378
+
379
+ $this = $(this)
380
+
381
+ e.preventDefault()
382
+ e.stopPropagation()
383
+
384
+ if ($this.is('.disabled, :disabled')) return
385
+
386
+ $parent = getParent($this)
387
+
388
+ isActive = $parent.hasClass('open')
389
+
390
+ if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
391
+
392
+ $items = $('[role=menu] li:not(.divider):visible a', $parent)
393
+
394
+ if (!$items.length) return
395
+
396
+ index = $items.index($items.filter(':focus'))
397
+
398
+ if (e.keyCode == 38 && index > 0) index-- // up
399
+ if (e.keyCode == 40 && index < $items.length - 1) index++ // down
400
+ if (!~index) index = 0
401
+
402
+ $items
403
+ .eq(index)
404
+ .focus()
405
+ }
406
+
407
+ }
408
+
409
+ function clearMenus() {
410
+ $(toggle).each(function () {
411
+ getParent($(this)).removeClass('open')
412
+ })
413
+ }
414
+
415
+ function getParent($this) {
416
+ var selector = $this.attr('data-target')
417
+ , $parent
418
+
419
+ if (!selector) {
420
+ selector = $this.attr('href')
421
+ selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
422
+ }
423
+
424
+ $parent = $(selector)
425
+ $parent.length || ($parent = $this.parent())
426
+
427
+ return $parent
428
+ }
429
+
430
+
431
+ /* DROPDOWN PLUGIN DEFINITION
432
+ * ========================== */
433
+
434
+ var old = $.fn.dropdown
435
+
436
+ $.fn.dropdown = function (option) {
437
+ return this.each(function () {
438
+ var $this = $(this)
439
+ , data = $this.data('dropdown')
440
+ if (!data) $this.data('dropdown', (data = new Dropdown(this)))
441
+ if (typeof option == 'string') data[option].call($this)
442
+ })
443
+ }
444
+
445
+ $.fn.dropdown.Constructor = Dropdown
446
+
447
+
448
+ /* DROPDOWN NO CONFLICT
449
+ * ==================== */
450
+
451
+ $.fn.dropdown.noConflict = function () {
452
+ $.fn.dropdown = old
453
+ return this
454
+ }
455
+
456
+
457
+ /* APPLY TO STANDARD DROPDOWN ELEMENTS
458
+ * =================================== */
459
+
460
+ $(document)
461
+ .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
462
+ .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
463
+ .on('touchstart.dropdown.data-api', '.dropdown-menu', function (e) { e.stopPropagation() })
464
+ .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
465
+ .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
466
+
467
+ }(window.jQuery);
468
+ /* =============================================================
469
+ * bootstrap-scrollspy.js v2.2.2
470
+ * http://twitter.github.com/bootstrap/javascript.html#scrollspy
471
+ * =============================================================
472
+ * Copyright 2012 Twitter, Inc.
473
+ *
474
+ * Licensed under the Apache License, Version 2.0 (the "License");
475
+ * you may not use this file except in compliance with the License.
476
+ * You may obtain a copy of the License at
477
+ *
478
+ * http://www.apache.org/licenses/LICENSE-2.0
479
+ *
480
+ * Unless required by applicable law or agreed to in writing, software
481
+ * distributed under the License is distributed on an "AS IS" BASIS,
482
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
483
+ * See the License for the specific language governing permissions and
484
+ * limitations under the License.
485
+ * ============================================================== */
486
+
487
+
488
+ !function ($) {
489
+
490
+ "use strict"; // jshint ;_;
491
+
492
+
493
+ /* SCROLLSPY CLASS DEFINITION
494
+ * ========================== */
495
+
496
+ function ScrollSpy(element, options) {
497
+ var process = $.proxy(this.process, this)
498
+ , $element = $(element).is('body') ? $(window) : $(element)
499
+ , href
500
+ this.options = $.extend({}, $.fn.scrollspy.defaults, options)
501
+ this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
502
+ this.selector = (this.options.target
503
+ || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
504
+ || '') + ' .nav li > a'
505
+ this.$body = $('body')
506
+ this.refresh()
507
+ this.process()
508
+ }
509
+
510
+ ScrollSpy.prototype = {
511
+
512
+ constructor: ScrollSpy
513
+
514
+ , refresh: function () {
515
+ var self = this
516
+ , $targets
517
+
518
+ this.offsets = $([])
519
+ this.targets = $([])
520
+
521
+ $targets = this.$body
522
+ .find(this.selector)
523
+ .map(function () {
524
+ var $el = $(this)
525
+ , href = $el.data('target') || $el.attr('href')
526
+ , $href = /^#\w/.test(href) && $(href)
527
+ return ( $href
528
+ && $href.length
529
+ && [[ $href.position().top + self.$scrollElement.scrollTop(), href ]] ) || null
530
+ })
531
+ .sort(function (a, b) { return a[0] - b[0] })
532
+ .each(function () {
533
+ self.offsets.push(this[0])
534
+ self.targets.push(this[1])
535
+ })
536
+ }
537
+
538
+ , process: function () {
539
+ var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
540
+ , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
541
+ , maxScroll = scrollHeight - this.$scrollElement.height()
542
+ , offsets = this.offsets
543
+ , targets = this.targets
544
+ , activeTarget = this.activeTarget
545
+ , i
546
+
547
+ if (scrollTop >= maxScroll) {
548
+ return activeTarget != (i = targets.last()[0])
549
+ && this.activate ( i )
550
+ }
551
+
552
+ for (i = offsets.length; i--;) {
553
+ activeTarget != targets[i]
554
+ && scrollTop >= offsets[i]
555
+ && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
556
+ && this.activate( targets[i] )
557
+ }
558
+ }
559
+
560
+ , activate: function (target) {
561
+ var active
562
+ , selector
563
+
564
+ this.activeTarget = target
565
+
566
+ $(this.selector)
567
+ .parent('.active')
568
+ .removeClass('active')
569
+
570
+ selector = this.selector
571
+ + '[data-target="' + target + '"],'
572
+ + this.selector + '[href="' + target + '"]'
573
+
574
+ active = $(selector)
575
+ .parent('li')
576
+ .addClass('active')
577
+
578
+ if (active.parent('.dropdown-menu').length) {
579
+ active = active.closest('li.dropdown').addClass('active')
580
+ }
581
+
582
+ active.trigger('activate')
583
+ }
584
+
585
+ }
586
+
587
+
588
+ /* SCROLLSPY PLUGIN DEFINITION
589
+ * =========================== */
590
+
591
+ var old = $.fn.scrollspy
592
+
593
+ $.fn.scrollspy = function (option) {
594
+ return this.each(function () {
595
+ var $this = $(this)
596
+ , data = $this.data('scrollspy')
597
+ , options = typeof option == 'object' && option
598
+ if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
599
+ if (typeof option == 'string') data[option]()
600
+ })
601
+ }
602
+
603
+ $.fn.scrollspy.Constructor = ScrollSpy
604
+
605
+ $.fn.scrollspy.defaults = {
606
+ offset: 10
607
+ }
608
+
609
+
610
+ /* SCROLLSPY NO CONFLICT
611
+ * ===================== */
612
+
613
+ $.fn.scrollspy.noConflict = function () {
614
+ $.fn.scrollspy = old
615
+ return this
616
+ }
617
+
618
+
619
+ /* SCROLLSPY DATA-API
620
+ * ================== */
621
+
622
+ $(window).on('load', function () {
623
+ $('[data-spy="scroll"]').each(function () {
624
+ var $spy = $(this)
625
+ $spy.scrollspy($spy.data())
626
+ })
627
+ })
628
+
629
+ }(window.jQuery);
630
+ /* ========================================================
631
+ * bootstrap-tab.js v2.2.2
632
+ * http://twitter.github.com/bootstrap/javascript.html#tabs
633
+ * ========================================================
634
+ * Copyright 2012 Twitter, Inc.
635
+ *
636
+ * Licensed under the Apache License, Version 2.0 (the "License");
637
+ * you may not use this file except in compliance with the License.
638
+ * You may obtain a copy of the License at
639
+ *
640
+ * http://www.apache.org/licenses/LICENSE-2.0
641
+ *
642
+ * Unless required by applicable law or agreed to in writing, software
643
+ * distributed under the License is distributed on an "AS IS" BASIS,
644
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
645
+ * See the License for the specific language governing permissions and
646
+ * limitations under the License.
647
+ * ======================================================== */
648
+
649
+
650
+ !function ($) {
651
+
652
+ "use strict"; // jshint ;_;
653
+
654
+
655
+ /* TAB CLASS DEFINITION
656
+ * ==================== */
657
+
658
+ var Tab = function (element) {
659
+ this.element = $(element)
660
+ }
661
+
662
+ Tab.prototype = {
663
+
664
+ constructor: Tab
665
+
666
+ , show: function () {
667
+ var $this = this.element
668
+ , $ul = $this.closest('ul:not(.dropdown-menu)')
669
+ , selector = $this.attr('data-target')
670
+ , previous
671
+ , $target
672
+ , e
673
+
674
+ if (!selector) {
675
+ selector = $this.attr('href')
676
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
677
+ }
678
+
679
+ if ( $this.parent('li').hasClass('active') ) return
680
+
681
+ previous = $ul.find('.active:last a')[0]
682
+
683
+ e = $.Event('show', {
684
+ relatedTarget: previous
685
+ })
686
+
687
+ $this.trigger(e)
688
+
689
+ if (e.isDefaultPrevented()) return
690
+
691
+ $target = $(selector)
692
+
693
+ this.activate($this.parent('li'), $ul)
694
+ this.activate($target, $target.parent(), function () {
695
+ $this.trigger({
696
+ type: 'shown'
697
+ , relatedTarget: previous
698
+ })
699
+ })
700
+ }
701
+
702
+ , activate: function ( element, container, callback) {
703
+ var $active = container.find('> .active')
704
+ , transition = callback
705
+ && $.support.transition
706
+ && $active.hasClass('fade')
707
+
708
+ function next() {
709
+ $active
710
+ .removeClass('active')
711
+ .find('> .dropdown-menu > .active')
712
+ .removeClass('active')
713
+
714
+ element.addClass('active')
715
+
716
+ if (transition) {
717
+ element[0].offsetWidth // reflow for transition
718
+ element.addClass('in')
719
+ } else {
720
+ element.removeClass('fade')
721
+ }
722
+
723
+ if ( element.parent('.dropdown-menu') ) {
724
+ element.closest('li.dropdown').addClass('active')
725
+ }
726
+
727
+ callback && callback()
728
+ }
729
+
730
+ transition ?
731
+ $active.one($.support.transition.end, next) :
732
+ next()
733
+
734
+ $active.removeClass('in')
735
+ }
736
+ }
737
+
738
+
739
+ /* TAB PLUGIN DEFINITION
740
+ * ===================== */
741
+
742
+ var old = $.fn.tab
743
+
744
+ $.fn.tab = function ( option ) {
745
+ return this.each(function () {
746
+ var $this = $(this)
747
+ , data = $this.data('tab')
748
+ if (!data) $this.data('tab', (data = new Tab(this)))
749
+ if (typeof option == 'string') data[option]()
750
+ })
751
+ }
752
+
753
+ $.fn.tab.Constructor = Tab
754
+
755
+
756
+ /* TAB NO CONFLICT
757
+ * =============== */
758
+
759
+ $.fn.tab.noConflict = function () {
760
+ $.fn.tab = old
761
+ return this
762
+ }
763
+
764
+
765
+ /* TAB DATA-API
766
+ * ============ */
767
+
768
+ $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
769
+ e.preventDefault()
770
+ $(this).tab('show')
771
+ })
772
+
773
+ }(window.jQuery);
774
+ /* ===========================================================
775
+ * bootstrap-tooltip.js v2.2.2
776
+ * http://twitter.github.com/bootstrap/javascript.html#tooltips
777
+ * Inspired by the original jQuery.tipsy by Jason Frame
778
+ * ===========================================================
779
+ * Copyright 2012 Twitter, Inc.
780
+ *
781
+ * Licensed under the Apache License, Version 2.0 (the "License");
782
+ * you may not use this file except in compliance with the License.
783
+ * You may obtain a copy of the License at
784
+ *
785
+ * http://www.apache.org/licenses/LICENSE-2.0
786
+ *
787
+ * Unless required by applicable law or agreed to in writing, software
788
+ * distributed under the License is distributed on an "AS IS" BASIS,
789
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
790
+ * See the License for the specific language governing permissions and
791
+ * limitations under the License.
792
+ * ========================================================== */
793
+
794
+
795
+ !function ($) {
796
+
797
+ "use strict"; // jshint ;_;
798
+
799
+
800
+ /* TOOLTIP PUBLIC CLASS DEFINITION
801
+ * =============================== */
802
+
803
+ var Tooltip = function (element, options) {
804
+ this.init('tooltip', element, options)
805
+ }
806
+
807
+ Tooltip.prototype = {
808
+
809
+ constructor: Tooltip
810
+
811
+ , init: function (type, element, options) {
812
+ var eventIn
813
+ , eventOut
814
+
815
+ this.type = type
816
+ this.$element = $(element)
817
+ this.options = this.getOptions(options)
818
+ this.enabled = true
819
+
820
+ if (this.options.trigger == 'click') {
821
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
822
+ } else if (this.options.trigger != 'manual') {
823
+ eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
824
+ eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
825
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
826
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
827
+ }
828
+
829
+ this.options.selector ?
830
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
831
+ this.fixTitle()
832
+ }
833
+
834
+ , getOptions: function (options) {
835
+ options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
836
+
837
+ if (options.delay && typeof options.delay == 'number') {
838
+ options.delay = {
839
+ show: options.delay
840
+ , hide: options.delay
841
+ }
842
+ }
843
+
844
+ return options
845
+ }
846
+
847
+ , enter: function (e) {
848
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
849
+
850
+ if (!self.options.delay || !self.options.delay.show) return self.show()
851
+
852
+ clearTimeout(this.timeout)
853
+ self.hoverState = 'in'
854
+ this.timeout = setTimeout(function() {
855
+ if (self.hoverState == 'in') self.show()
856
+ }, self.options.delay.show)
857
+ }
858
+
859
+ , leave: function (e) {
860
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
861
+
862
+ if (this.timeout) clearTimeout(this.timeout)
863
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
864
+
865
+ self.hoverState = 'out'
866
+ this.timeout = setTimeout(function() {
867
+ if (self.hoverState == 'out') self.hide()
868
+ }, self.options.delay.hide)
869
+ }
870
+
871
+ , show: function () {
872
+ var $tip
873
+ , inside
874
+ , pos
875
+ , actualWidth
876
+ , actualHeight
877
+ , placement
878
+ , tp
879
+
880
+ if (this.hasContent() && this.enabled) {
881
+ $tip = this.tip()
882
+ this.setContent()
883
+
884
+ if (this.options.animation) {
885
+ $tip.addClass('fade')
886
+ }
887
+
888
+ placement = typeof this.options.placement == 'function' ?
889
+ this.options.placement.call(this, $tip[0], this.$element[0]) :
890
+ this.options.placement
891
+
892
+ inside = /in/.test(placement)
893
+
894
+ $tip
895
+ .detach()
896
+ .css({ top: 0, left: 0, display: 'block' })
897
+ .insertAfter(this.$element)
898
+
899
+ pos = this.getPosition(inside)
900
+
901
+ actualWidth = $tip[0].offsetWidth
902
+ actualHeight = $tip[0].offsetHeight
903
+
904
+ switch (inside ? placement.split(' ')[1] : placement) {
905
+ case 'bottom':
906
+ tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
907
+ break
908
+ case 'top':
909
+ tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
910
+ break
911
+ case 'left':
912
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
913
+ break
914
+ case 'right':
915
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
916
+ break
917
+ }
918
+
919
+ $tip
920
+ .offset(tp)
921
+ .addClass(placement)
922
+ .addClass('in')
923
+ }
924
+ }
925
+
926
+ , setContent: function () {
927
+ var $tip = this.tip()
928
+ , title = this.getTitle()
929
+
930
+ $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
931
+ $tip.removeClass('fade in top bottom left right')
932
+ }
933
+
934
+ , hide: function () {
935
+ var that = this
936
+ , $tip = this.tip()
937
+
938
+ $tip.removeClass('in')
939
+
940
+ function removeWithAnimation() {
941
+ var timeout = setTimeout(function () {
942
+ $tip.off($.support.transition.end).detach()
943
+ }, 500)
944
+
945
+ $tip.one($.support.transition.end, function () {
946
+ clearTimeout(timeout)
947
+ $tip.detach()
948
+ })
949
+ }
950
+
951
+ $.support.transition && this.$tip.hasClass('fade') ?
952
+ removeWithAnimation() :
953
+ $tip.detach()
954
+
955
+ return this
956
+ }
957
+
958
+ , fixTitle: function () {
959
+ var $e = this.$element
960
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
961
+ $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
962
+ }
963
+ }
964
+
965
+ , hasContent: function () {
966
+ return this.getTitle()
967
+ }
968
+
969
+ , getPosition: function (inside) {
970
+ return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
971
+ width: this.$element[0].offsetWidth
972
+ , height: this.$element[0].offsetHeight
973
+ })
974
+ }
975
+
976
+ , getTitle: function () {
977
+ var title
978
+ , $e = this.$element
979
+ , o = this.options
980
+
981
+ title = $e.attr('data-original-title')
982
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
983
+
984
+ return title
985
+ }
986
+
987
+ , tip: function () {
988
+ return this.$tip = this.$tip || $(this.options.template)
989
+ }
990
+
991
+ , validate: function () {
992
+ if (!this.$element[0].parentNode) {
993
+ this.hide()
994
+ this.$element = null
995
+ this.options = null
996
+ }
997
+ }
998
+
999
+ , enable: function () {
1000
+ this.enabled = true
1001
+ }
1002
+
1003
+ , disable: function () {
1004
+ this.enabled = false
1005
+ }
1006
+
1007
+ , toggleEnabled: function () {
1008
+ this.enabled = !this.enabled
1009
+ }
1010
+
1011
+ , toggle: function (e) {
1012
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
1013
+ self[self.tip().hasClass('in') ? 'hide' : 'show']()
1014
+ }
1015
+
1016
+ , destroy: function () {
1017
+ this.hide().$element.off('.' + this.type).removeData(this.type)
1018
+ }
1019
+
1020
+ }
1021
+
1022
+
1023
+ /* TOOLTIP PLUGIN DEFINITION
1024
+ * ========================= */
1025
+
1026
+ var old = $.fn.tooltip
1027
+
1028
+ $.fn.tooltip = function ( option ) {
1029
+ return this.each(function () {
1030
+ var $this = $(this)
1031
+ , data = $this.data('tooltip')
1032
+ , options = typeof option == 'object' && option
1033
+ if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
1034
+ if (typeof option == 'string') data[option]()
1035
+ })
1036
+ }
1037
+
1038
+ $.fn.tooltip.Constructor = Tooltip
1039
+
1040
+ $.fn.tooltip.defaults = {
1041
+ animation: true
1042
+ , placement: 'top'
1043
+ , selector: false
1044
+ , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1045
+ , trigger: 'hover'
1046
+ , title: ''
1047
+ , delay: 0
1048
+ , html: false
1049
+ }
1050
+
1051
+
1052
+ /* TOOLTIP NO CONFLICT
1053
+ * =================== */
1054
+
1055
+ $.fn.tooltip.noConflict = function () {
1056
+ $.fn.tooltip = old
1057
+ return this
1058
+ }
1059
+
1060
+ }(window.jQuery);
1061
+ /* ===========================================================
1062
+ * bootstrap-popover.js v2.2.2
1063
+ * http://twitter.github.com/bootstrap/javascript.html#popovers
1064
+ * ===========================================================
1065
+ * Copyright 2012 Twitter, Inc.
1066
+ *
1067
+ * Licensed under the Apache License, Version 2.0 (the "License");
1068
+ * you may not use this file except in compliance with the License.
1069
+ * You may obtain a copy of the License at
1070
+ *
1071
+ * http://www.apache.org/licenses/LICENSE-2.0
1072
+ *
1073
+ * Unless required by applicable law or agreed to in writing, software
1074
+ * distributed under the License is distributed on an "AS IS" BASIS,
1075
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1076
+ * See the License for the specific language governing permissions and
1077
+ * limitations under the License.
1078
+ * =========================================================== */
1079
+
1080
+
1081
+ !function ($) {
1082
+
1083
+ "use strict"; // jshint ;_;
1084
+
1085
+
1086
+ /* POPOVER PUBLIC CLASS DEFINITION
1087
+ * =============================== */
1088
+
1089
+ var Popover = function (element, options) {
1090
+ this.init('popover', element, options)
1091
+ }
1092
+
1093
+
1094
+ /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
1095
+ ========================================== */
1096
+
1097
+ Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
1098
+
1099
+ constructor: Popover
1100
+
1101
+ , setContent: function () {
1102
+ var $tip = this.tip()
1103
+ , title = this.getTitle()
1104
+ , content = this.getContent()
1105
+
1106
+ $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1107
+ $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
1108
+
1109
+ $tip.removeClass('fade top bottom left right in')
1110
+ }
1111
+
1112
+ , hasContent: function () {
1113
+ return this.getTitle() || this.getContent()
1114
+ }
1115
+
1116
+ , getContent: function () {
1117
+ var content
1118
+ , $e = this.$element
1119
+ , o = this.options
1120
+
1121
+ content = $e.attr('data-content')
1122
+ || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
1123
+
1124
+ return content
1125
+ }
1126
+
1127
+ , tip: function () {
1128
+ if (!this.$tip) {
1129
+ this.$tip = $(this.options.template)
1130
+ }
1131
+ return this.$tip
1132
+ }
1133
+
1134
+ , destroy: function () {
1135
+ this.hide().$element.off('.' + this.type).removeData(this.type)
1136
+ }
1137
+
1138
+ })
1139
+
1140
+
1141
+ /* POPOVER PLUGIN DEFINITION
1142
+ * ======================= */
1143
+
1144
+ var old = $.fn.popover
1145
+
1146
+ $.fn.popover = function (option) {
1147
+ return this.each(function () {
1148
+ var $this = $(this)
1149
+ , data = $this.data('popover')
1150
+ , options = typeof option == 'object' && option
1151
+ if (!data) $this.data('popover', (data = new Popover(this, options)))
1152
+ if (typeof option == 'string') data[option]()
1153
+ })
1154
+ }
1155
+
1156
+ $.fn.popover.Constructor = Popover
1157
+
1158
+ $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
1159
+ placement: 'right'
1160
+ , trigger: 'click'
1161
+ , content: ''
1162
+ , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"></div></div></div>'
1163
+ })
1164
+
1165
+
1166
+ /* POPOVER NO CONFLICT
1167
+ * =================== */
1168
+
1169
+ $.fn.popover.noConflict = function () {
1170
+ $.fn.popover = old
1171
+ return this
1172
+ }
1173
+
1174
+ }(window.jQuery);
1175
+ /* ==========================================================
1176
+ * bootstrap-affix.js v2.2.2
1177
+ * http://twitter.github.com/bootstrap/javascript.html#affix
1178
+ * ==========================================================
1179
+ * Copyright 2012 Twitter, Inc.
1180
+ *
1181
+ * Licensed under the Apache License, Version 2.0 (the "License");
1182
+ * you may not use this file except in compliance with the License.
1183
+ * You may obtain a copy of the License at
1184
+ *
1185
+ * http://www.apache.org/licenses/LICENSE-2.0
1186
+ *
1187
+ * Unless required by applicable law or agreed to in writing, software
1188
+ * distributed under the License is distributed on an "AS IS" BASIS,
1189
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1190
+ * See the License for the specific language governing permissions and
1191
+ * limitations under the License.
1192
+ * ========================================================== */
1193
+
1194
+
1195
+ !function ($) {
1196
+
1197
+ "use strict"; // jshint ;_;
1198
+
1199
+
1200
+ /* AFFIX CLASS DEFINITION
1201
+ * ====================== */
1202
+
1203
+ var Affix = function (element, options) {
1204
+ this.options = $.extend({}, $.fn.affix.defaults, options)
1205
+ this.$window = $(window)
1206
+ .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
1207
+ .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
1208
+ this.$element = $(element)
1209
+ this.checkPosition()
1210
+ }
1211
+
1212
+ Affix.prototype.checkPosition = function () {
1213
+ if (!this.$element.is(':visible')) return
1214
+
1215
+ var scrollHeight = $(document).height()
1216
+ , scrollTop = this.$window.scrollTop()
1217
+ , position = this.$element.offset()
1218
+ , offset = this.options.offset
1219
+ , offsetBottom = offset.bottom
1220
+ , offsetTop = offset.top
1221
+ , reset = 'affix affix-top affix-bottom'
1222
+ , affix
1223
+
1224
+ if (typeof offset != 'object') offsetBottom = offsetTop = offset
1225
+ if (typeof offsetTop == 'function') offsetTop = offset.top()
1226
+ if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
1227
+
1228
+ affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
1229
+ false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
1230
+ 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
1231
+ 'top' : false
1232
+
1233
+ if (this.affixed === affix) return
1234
+
1235
+ this.affixed = affix
1236
+ this.unpin = affix == 'bottom' ? position.top - scrollTop : null
1237
+
1238
+ this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
1239
+ }
1240
+
1241
+
1242
+ /* AFFIX PLUGIN DEFINITION
1243
+ * ======================= */
1244
+
1245
+ var old = $.fn.affix
1246
+
1247
+ $.fn.affix = function (option) {
1248
+ return this.each(function () {
1249
+ var $this = $(this)
1250
+ , data = $this.data('affix')
1251
+ , options = typeof option == 'object' && option
1252
+ if (!data) $this.data('affix', (data = new Affix(this, options)))
1253
+ if (typeof option == 'string') data[option]()
1254
+ })
1255
+ }
1256
+
1257
+ $.fn.affix.Constructor = Affix
1258
+
1259
+ $.fn.affix.defaults = {
1260
+ offset: 0
1261
+ }
1262
+
1263
+
1264
+ /* AFFIX NO CONFLICT
1265
+ * ================= */
1266
+
1267
+ $.fn.affix.noConflict = function () {
1268
+ $.fn.affix = old
1269
+ return this
1270
+ }
1271
+
1272
+
1273
+ /* AFFIX DATA-API
1274
+ * ============== */
1275
+
1276
+ $(window).on('load', function () {
1277
+ $('[data-spy="affix"]').each(function () {
1278
+ var $spy = $(this)
1279
+ , data = $spy.data()
1280
+
1281
+ data.offset = data.offset || {}
1282
+
1283
+ data.offsetBottom && (data.offset.bottom = data.offsetBottom)
1284
+ data.offsetTop && (data.offset.top = data.offsetTop)
1285
+
1286
+ $spy.affix(data)
1287
+ })
1288
+ })
1289
+
1290
+
1291
+ }(window.jQuery);
1292
+ /* ==========================================================
1293
+ * bootstrap-alert.js v2.2.2
1294
+ * http://twitter.github.com/bootstrap/javascript.html#alerts
1295
+ * ==========================================================
1296
+ * Copyright 2012 Twitter, Inc.
1297
+ *
1298
+ * Licensed under the Apache License, Version 2.0 (the "License");
1299
+ * you may not use this file except in compliance with the License.
1300
+ * You may obtain a copy of the License at
1301
+ *
1302
+ * http://www.apache.org/licenses/LICENSE-2.0
1303
+ *
1304
+ * Unless required by applicable law or agreed to in writing, software
1305
+ * distributed under the License is distributed on an "AS IS" BASIS,
1306
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1307
+ * See the License for the specific language governing permissions and
1308
+ * limitations under the License.
1309
+ * ========================================================== */
1310
+
1311
+
1312
+ !function ($) {
1313
+
1314
+ "use strict"; // jshint ;_;
1315
+
1316
+
1317
+ /* ALERT CLASS DEFINITION
1318
+ * ====================== */
1319
+
1320
+ var dismiss = '[data-dismiss="alert"]'
1321
+ , Alert = function (el) {
1322
+ $(el).on('click', dismiss, this.close)
1323
+ }
1324
+
1325
+ Alert.prototype.close = function (e) {
1326
+ var $this = $(this)
1327
+ , selector = $this.attr('data-target')
1328
+ , $parent
1329
+
1330
+ if (!selector) {
1331
+ selector = $this.attr('href')
1332
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1333
+ }
1334
+
1335
+ $parent = $(selector)
1336
+
1337
+ e && e.preventDefault()
1338
+
1339
+ $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
1340
+
1341
+ $parent.trigger(e = $.Event('close'))
1342
+
1343
+ if (e.isDefaultPrevented()) return
1344
+
1345
+ $parent.removeClass('in')
1346
+
1347
+ function removeElement() {
1348
+ $parent
1349
+ .trigger('closed')
1350
+ .remove()
1351
+ }
1352
+
1353
+ $.support.transition && $parent.hasClass('fade') ?
1354
+ $parent.on($.support.transition.end, removeElement) :
1355
+ removeElement()
1356
+ }
1357
+
1358
+
1359
+ /* ALERT PLUGIN DEFINITION
1360
+ * ======================= */
1361
+
1362
+ var old = $.fn.alert
1363
+
1364
+ $.fn.alert = function (option) {
1365
+ return this.each(function () {
1366
+ var $this = $(this)
1367
+ , data = $this.data('alert')
1368
+ if (!data) $this.data('alert', (data = new Alert(this)))
1369
+ if (typeof option == 'string') data[option].call($this)
1370
+ })
1371
+ }
1372
+
1373
+ $.fn.alert.Constructor = Alert
1374
+
1375
+
1376
+ /* ALERT NO CONFLICT
1377
+ * ================= */
1378
+
1379
+ $.fn.alert.noConflict = function () {
1380
+ $.fn.alert = old
1381
+ return this
1382
+ }
1383
+
1384
+
1385
+ /* ALERT DATA-API
1386
+ * ============== */
1387
+
1388
+ $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
1389
+
1390
+ }(window.jQuery);
1391
+ /* ============================================================
1392
+ * bootstrap-button.js v2.2.2
1393
+ * http://twitter.github.com/bootstrap/javascript.html#buttons
1394
+ * ============================================================
1395
+ * Copyright 2012 Twitter, Inc.
1396
+ *
1397
+ * Licensed under the Apache License, Version 2.0 (the "License");
1398
+ * you may not use this file except in compliance with the License.
1399
+ * You may obtain a copy of the License at
1400
+ *
1401
+ * http://www.apache.org/licenses/LICENSE-2.0
1402
+ *
1403
+ * Unless required by applicable law or agreed to in writing, software
1404
+ * distributed under the License is distributed on an "AS IS" BASIS,
1405
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1406
+ * See the License for the specific language governing permissions and
1407
+ * limitations under the License.
1408
+ * ============================================================ */
1409
+
1410
+
1411
+ !function ($) {
1412
+
1413
+ "use strict"; // jshint ;_;
1414
+
1415
+
1416
+ /* BUTTON PUBLIC CLASS DEFINITION
1417
+ * ============================== */
1418
+
1419
+ var Button = function (element, options) {
1420
+ this.$element = $(element)
1421
+ this.options = $.extend({}, $.fn.button.defaults, options)
1422
+ }
1423
+
1424
+ Button.prototype.setState = function (state) {
1425
+ var d = 'disabled'
1426
+ , $el = this.$element
1427
+ , data = $el.data()
1428
+ , val = $el.is('input') ? 'val' : 'html'
1429
+
1430
+ state = state + 'Text'
1431
+ data.resetText || $el.data('resetText', $el[val]())
1432
+
1433
+ $el[val](data[state] || this.options[state])
1434
+
1435
+ // push to event loop to allow forms to submit
1436
+ setTimeout(function () {
1437
+ state == 'loadingText' ?
1438
+ $el.addClass(d).attr(d, d) :
1439
+ $el.removeClass(d).removeAttr(d)
1440
+ }, 0)
1441
+ }
1442
+
1443
+ Button.prototype.toggle = function () {
1444
+ var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
1445
+
1446
+ $parent && $parent
1447
+ .find('.active')
1448
+ .removeClass('active')
1449
+
1450
+ this.$element.toggleClass('active')
1451
+ }
1452
+
1453
+
1454
+ /* BUTTON PLUGIN DEFINITION
1455
+ * ======================== */
1456
+
1457
+ var old = $.fn.button
1458
+
1459
+ $.fn.button = function (option) {
1460
+ return this.each(function () {
1461
+ var $this = $(this)
1462
+ , data = $this.data('button')
1463
+ , options = typeof option == 'object' && option
1464
+ if (!data) $this.data('button', (data = new Button(this, options)))
1465
+ if (option == 'toggle') data.toggle()
1466
+ else if (option) data.setState(option)
1467
+ })
1468
+ }
1469
+
1470
+ $.fn.button.defaults = {
1471
+ loadingText: 'loading...'
1472
+ }
1473
+
1474
+ $.fn.button.Constructor = Button
1475
+
1476
+
1477
+ /* BUTTON NO CONFLICT
1478
+ * ================== */
1479
+
1480
+ $.fn.button.noConflict = function () {
1481
+ $.fn.button = old
1482
+ return this
1483
+ }
1484
+
1485
+
1486
+ /* BUTTON DATA-API
1487
+ * =============== */
1488
+
1489
+ $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
1490
+ var $btn = $(e.target)
1491
+ if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
1492
+ $btn.button('toggle')
1493
+ })
1494
+
1495
+ }(window.jQuery);
1496
+ /* =============================================================
1497
+ * bootstrap-collapse.js v2.2.2
1498
+ * http://twitter.github.com/bootstrap/javascript.html#collapse
1499
+ * =============================================================
1500
+ * Copyright 2012 Twitter, Inc.
1501
+ *
1502
+ * Licensed under the Apache License, Version 2.0 (the "License");
1503
+ * you may not use this file except in compliance with the License.
1504
+ * You may obtain a copy of the License at
1505
+ *
1506
+ * http://www.apache.org/licenses/LICENSE-2.0
1507
+ *
1508
+ * Unless required by applicable law or agreed to in writing, software
1509
+ * distributed under the License is distributed on an "AS IS" BASIS,
1510
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1511
+ * See the License for the specific language governing permissions and
1512
+ * limitations under the License.
1513
+ * ============================================================ */
1514
+
1515
+
1516
+ !function ($) {
1517
+
1518
+ "use strict"; // jshint ;_;
1519
+
1520
+
1521
+ /* COLLAPSE PUBLIC CLASS DEFINITION
1522
+ * ================================ */
1523
+
1524
+ var Collapse = function (element, options) {
1525
+ this.$element = $(element)
1526
+ this.options = $.extend({}, $.fn.collapse.defaults, options)
1527
+
1528
+ if (this.options.parent) {
1529
+ this.$parent = $(this.options.parent)
1530
+ }
1531
+
1532
+ this.options.toggle && this.toggle()
1533
+ }
1534
+
1535
+ Collapse.prototype = {
1536
+
1537
+ constructor: Collapse
1538
+
1539
+ , dimension: function () {
1540
+ var hasWidth = this.$element.hasClass('width')
1541
+ return hasWidth ? 'width' : 'height'
1542
+ }
1543
+
1544
+ , show: function () {
1545
+ var dimension
1546
+ , scroll
1547
+ , actives
1548
+ , hasData
1549
+
1550
+ if (this.transitioning) return
1551
+
1552
+ dimension = this.dimension()
1553
+ scroll = $.camelCase(['scroll', dimension].join('-'))
1554
+ actives = this.$parent && this.$parent.find('> .accordion-group > .in')
1555
+
1556
+ if (actives && actives.length) {
1557
+ hasData = actives.data('collapse')
1558
+ if (hasData && hasData.transitioning) return
1559
+ actives.collapse('hide')
1560
+ hasData || actives.data('collapse', null)
1561
+ }
1562
+
1563
+ this.$element[dimension](0)
1564
+ this.transition('addClass', $.Event('show'), 'shown')
1565
+ $.support.transition && this.$element[dimension](this.$element[0][scroll])
1566
+ }
1567
+
1568
+ , hide: function () {
1569
+ var dimension
1570
+ if (this.transitioning) return
1571
+ dimension = this.dimension()
1572
+ this.reset(this.$element[dimension]())
1573
+ this.transition('removeClass', $.Event('hide'), 'hidden')
1574
+ this.$element[dimension](0)
1575
+ }
1576
+
1577
+ , reset: function (size) {
1578
+ var dimension = this.dimension()
1579
+
1580
+ this.$element
1581
+ .removeClass('collapse')
1582
+ [dimension](size || 'auto')
1583
+ [0].offsetWidth
1584
+
1585
+ this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
1586
+
1587
+ return this
1588
+ }
1589
+
1590
+ , transition: function (method, startEvent, completeEvent) {
1591
+ var that = this
1592
+ , complete = function () {
1593
+ if (startEvent.type == 'show') that.reset()
1594
+ that.transitioning = 0
1595
+ that.$element.trigger(completeEvent)
1596
+ }
1597
+
1598
+ this.$element.trigger(startEvent)
1599
+
1600
+ if (startEvent.isDefaultPrevented()) return
1601
+
1602
+ this.transitioning = 1
1603
+
1604
+ this.$element[method]('in')
1605
+
1606
+ $.support.transition && this.$element.hasClass('collapse') ?
1607
+ this.$element.one($.support.transition.end, complete) :
1608
+ complete()
1609
+ }
1610
+
1611
+ , toggle: function () {
1612
+ this[this.$element.hasClass('in') ? 'hide' : 'show']()
1613
+ }
1614
+
1615
+ }
1616
+
1617
+
1618
+ /* COLLAPSE PLUGIN DEFINITION
1619
+ * ========================== */
1620
+
1621
+ var old = $.fn.collapse
1622
+
1623
+ $.fn.collapse = function (option) {
1624
+ return this.each(function () {
1625
+ var $this = $(this)
1626
+ , data = $this.data('collapse')
1627
+ , options = typeof option == 'object' && option
1628
+ if (!data) $this.data('collapse', (data = new Collapse(this, options)))
1629
+ if (typeof option == 'string') data[option]()
1630
+ })
1631
+ }
1632
+
1633
+ $.fn.collapse.defaults = {
1634
+ toggle: true
1635
+ }
1636
+
1637
+ $.fn.collapse.Constructor = Collapse
1638
+
1639
+
1640
+ /* COLLAPSE NO CONFLICT
1641
+ * ==================== */
1642
+
1643
+ $.fn.collapse.noConflict = function () {
1644
+ $.fn.collapse = old
1645
+ return this
1646
+ }
1647
+
1648
+
1649
+ /* COLLAPSE DATA-API
1650
+ * ================= */
1651
+
1652
+ $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
1653
+ var $this = $(this), href
1654
+ , target = $this.attr('data-target')
1655
+ || e.preventDefault()
1656
+ || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
1657
+ , option = $(target).data('collapse') ? 'toggle' : $this.data()
1658
+ $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
1659
+ $(target).collapse(option)
1660
+ })
1661
+
1662
+ }(window.jQuery);
1663
+ /* ==========================================================
1664
+ * bootstrap-carousel.js v2.2.2
1665
+ * http://twitter.github.com/bootstrap/javascript.html#carousel
1666
+ * ==========================================================
1667
+ * Copyright 2012 Twitter, Inc.
1668
+ *
1669
+ * Licensed under the Apache License, Version 2.0 (the "License");
1670
+ * you may not use this file except in compliance with the License.
1671
+ * You may obtain a copy of the License at
1672
+ *
1673
+ * http://www.apache.org/licenses/LICENSE-2.0
1674
+ *
1675
+ * Unless required by applicable law or agreed to in writing, software
1676
+ * distributed under the License is distributed on an "AS IS" BASIS,
1677
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1678
+ * See the License for the specific language governing permissions and
1679
+ * limitations under the License.
1680
+ * ========================================================== */
1681
+
1682
+
1683
+ !function ($) {
1684
+
1685
+ "use strict"; // jshint ;_;
1686
+
1687
+
1688
+ /* CAROUSEL CLASS DEFINITION
1689
+ * ========================= */
1690
+
1691
+ var Carousel = function (element, options) {
1692
+ this.$element = $(element)
1693
+ this.options = options
1694
+ this.options.pause == 'hover' && this.$element
1695
+ .on('mouseenter', $.proxy(this.pause, this))
1696
+ .on('mouseleave', $.proxy(this.cycle, this))
1697
+ }
1698
+
1699
+ Carousel.prototype = {
1700
+
1701
+ cycle: function (e) {
1702
+ if (!e) this.paused = false
1703
+ this.options.interval
1704
+ && !this.paused
1705
+ && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
1706
+ return this
1707
+ }
1708
+
1709
+ , to: function (pos) {
1710
+ var $active = this.$element.find('.item.active')
1711
+ , children = $active.parent().children()
1712
+ , activePos = children.index($active)
1713
+ , that = this
1714
+
1715
+ if (pos > (children.length - 1) || pos < 0) return
1716
+
1717
+ if (this.sliding) {
1718
+ return this.$element.one('slid', function () {
1719
+ that.to(pos)
1720
+ })
1721
+ }
1722
+
1723
+ if (activePos == pos) {
1724
+ return this.pause().cycle()
1725
+ }
1726
+
1727
+ return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
1728
+ }
1729
+
1730
+ , pause: function (e) {
1731
+ if (!e) this.paused = true
1732
+ if (this.$element.find('.next, .prev').length && $.support.transition.end) {
1733
+ this.$element.trigger($.support.transition.end)
1734
+ this.cycle()
1735
+ }
1736
+ clearInterval(this.interval)
1737
+ this.interval = null
1738
+ return this
1739
+ }
1740
+
1741
+ , next: function () {
1742
+ if (this.sliding) return
1743
+ return this.slide('next')
1744
+ }
1745
+
1746
+ , prev: function () {
1747
+ if (this.sliding) return
1748
+ return this.slide('prev')
1749
+ }
1750
+
1751
+ , slide: function (type, next) {
1752
+ var $active = this.$element.find('.item.active')
1753
+ , $next = next || $active[type]()
1754
+ , isCycling = this.interval
1755
+ , direction = type == 'next' ? 'left' : 'right'
1756
+ , fallback = type == 'next' ? 'first' : 'last'
1757
+ , that = this
1758
+ , e
1759
+
1760
+ this.sliding = true
1761
+
1762
+ isCycling && this.pause()
1763
+
1764
+ $next = $next.length ? $next : this.$element.find('.item')[fallback]()
1765
+
1766
+ e = $.Event('slide', {
1767
+ relatedTarget: $next[0]
1768
+ })
1769
+
1770
+ if ($next.hasClass('active')) return
1771
+
1772
+ if ($.support.transition && this.$element.hasClass('slide')) {
1773
+ this.$element.trigger(e)
1774
+ if (e.isDefaultPrevented()) return
1775
+ $next.addClass(type)
1776
+ $next[0].offsetWidth // force reflow
1777
+ $active.addClass(direction)
1778
+ $next.addClass(direction)
1779
+ this.$element.one($.support.transition.end, function () {
1780
+ $next.removeClass([type, direction].join(' ')).addClass('active')
1781
+ $active.removeClass(['active', direction].join(' '))
1782
+ that.sliding = false
1783
+ setTimeout(function () { that.$element.trigger('slid') }, 0)
1784
+ })
1785
+ } else {
1786
+ this.$element.trigger(e)
1787
+ if (e.isDefaultPrevented()) return
1788
+ $active.removeClass('active')
1789
+ $next.addClass('active')
1790
+ this.sliding = false
1791
+ this.$element.trigger('slid')
1792
+ }
1793
+
1794
+ isCycling && this.cycle()
1795
+
1796
+ return this
1797
+ }
1798
+
1799
+ }
1800
+
1801
+
1802
+ /* CAROUSEL PLUGIN DEFINITION
1803
+ * ========================== */
1804
+
1805
+ var old = $.fn.carousel
1806
+
1807
+ $.fn.carousel = function (option) {
1808
+ return this.each(function () {
1809
+ var $this = $(this)
1810
+ , data = $this.data('carousel')
1811
+ , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
1812
+ , action = typeof option == 'string' ? option : options.slide
1813
+ if (!data) $this.data('carousel', (data = new Carousel(this, options)))
1814
+ if (typeof option == 'number') data.to(option)
1815
+ else if (action) data[action]()
1816
+ else if (options.interval) data.cycle()
1817
+ })
1818
+ }
1819
+
1820
+ $.fn.carousel.defaults = {
1821
+ interval: 5000
1822
+ , pause: 'hover'
1823
+ }
1824
+
1825
+ $.fn.carousel.Constructor = Carousel
1826
+
1827
+
1828
+ /* CAROUSEL NO CONFLICT
1829
+ * ==================== */
1830
+
1831
+ $.fn.carousel.noConflict = function () {
1832
+ $.fn.carousel = old
1833
+ return this
1834
+ }
1835
+
1836
+ /* CAROUSEL DATA-API
1837
+ * ================= */
1838
+
1839
+ $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
1840
+ var $this = $(this), href
1841
+ , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1842
+ , options = $.extend({}, $target.data(), $this.data())
1843
+ $target.carousel(options)
1844
+ e.preventDefault()
1845
+ })
1846
+
1847
+ }(window.jQuery);
1848
+ /* =============================================================
1849
+ * bootstrap-typeahead.js v2.2.2
1850
+ * http://twitter.github.com/bootstrap/javascript.html#typeahead
1851
+ * =============================================================
1852
+ * Copyright 2012 Twitter, Inc.
1853
+ *
1854
+ * Licensed under the Apache License, Version 2.0 (the "License");
1855
+ * you may not use this file except in compliance with the License.
1856
+ * You may obtain a copy of the License at
1857
+ *
1858
+ * http://www.apache.org/licenses/LICENSE-2.0
1859
+ *
1860
+ * Unless required by applicable law or agreed to in writing, software
1861
+ * distributed under the License is distributed on an "AS IS" BASIS,
1862
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1863
+ * See the License for the specific language governing permissions and
1864
+ * limitations under the License.
1865
+ * ============================================================ */
1866
+
1867
+
1868
+ !function($){
1869
+
1870
+ "use strict"; // jshint ;_;
1871
+
1872
+
1873
+ /* TYPEAHEAD PUBLIC CLASS DEFINITION
1874
+ * ================================= */
1875
+
1876
+ var Typeahead = function (element, options) {
1877
+ this.$element = $(element)
1878
+ this.options = $.extend({}, $.fn.typeahead.defaults, options)
1879
+ this.matcher = this.options.matcher || this.matcher
1880
+ this.sorter = this.options.sorter || this.sorter
1881
+ this.highlighter = this.options.highlighter || this.highlighter
1882
+ this.updater = this.options.updater || this.updater
1883
+ this.source = this.options.source
1884
+ this.$menu = $(this.options.menu)
1885
+ this.shown = false
1886
+ this.listen()
1887
+ }
1888
+
1889
+ Typeahead.prototype = {
1890
+
1891
+ constructor: Typeahead
1892
+
1893
+ , select: function () {
1894
+ var val = this.$menu.find('.active').attr('data-value')
1895
+ this.$element
1896
+ .val(this.updater(val))
1897
+ .change()
1898
+ return this.hide()
1899
+ }
1900
+
1901
+ , updater: function (item) {
1902
+ return item
1903
+ }
1904
+
1905
+ , show: function () {
1906
+ var pos = $.extend({}, this.$element.position(), {
1907
+ height: this.$element[0].offsetHeight
1908
+ })
1909
+
1910
+ this.$menu
1911
+ .insertAfter(this.$element)
1912
+ .css({
1913
+ top: pos.top + pos.height
1914
+ , left: pos.left
1915
+ })
1916
+ .show()
1917
+
1918
+ this.shown = true
1919
+ return this
1920
+ }
1921
+
1922
+ , hide: function () {
1923
+ this.$menu.hide()
1924
+ this.shown = false
1925
+ return this
1926
+ }
1927
+
1928
+ , lookup: function (event) {
1929
+ var items
1930
+
1931
+ this.query = this.$element.val()
1932
+
1933
+ if (!this.query || this.query.length < this.options.minLength) {
1934
+ return this.shown ? this.hide() : this
1935
+ }
1936
+
1937
+ items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
1938
+
1939
+ return items ? this.process(items) : this
1940
+ }
1941
+
1942
+ , process: function (items) {
1943
+ var that = this
1944
+
1945
+ items = $.grep(items, function (item) {
1946
+ return that.matcher(item)
1947
+ })
1948
+
1949
+ items = this.sorter(items)
1950
+
1951
+ if (!items.length) {
1952
+ return this.shown ? this.hide() : this
1953
+ }
1954
+
1955
+ return this.render(items.slice(0, this.options.items)).show()
1956
+ }
1957
+
1958
+ , matcher: function (item) {
1959
+ return ~item.toLowerCase().indexOf(this.query.toLowerCase())
1960
+ }
1961
+
1962
+ , sorter: function (items) {
1963
+ var beginswith = []
1964
+ , caseSensitive = []
1965
+ , caseInsensitive = []
1966
+ , item
1967
+
1968
+ while (item = items.shift()) {
1969
+ if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
1970
+ else if (~item.indexOf(this.query)) caseSensitive.push(item)
1971
+ else caseInsensitive.push(item)
1972
+ }
1973
+
1974
+ return beginswith.concat(caseSensitive, caseInsensitive)
1975
+ }
1976
+
1977
+ , highlighter: function (item) {
1978
+ var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
1979
+ return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
1980
+ return '<strong>' + match + '</strong>'
1981
+ })
1982
+ }
1983
+
1984
+ , render: function (items) {
1985
+ var that = this
1986
+
1987
+ items = $(items).map(function (i, item) {
1988
+ i = $(that.options.item).attr('data-value', item)
1989
+ i.find('a').html(that.highlighter(item))
1990
+ return i[0]
1991
+ })
1992
+
1993
+ items.first().addClass('active')
1994
+ this.$menu.html(items)
1995
+ return this
1996
+ }
1997
+
1998
+ , next: function (event) {
1999
+ var active = this.$menu.find('.active').removeClass('active')
2000
+ , next = active.next()
2001
+
2002
+ if (!next.length) {
2003
+ next = $(this.$menu.find('li')[0])
2004
+ }
2005
+
2006
+ next.addClass('active')
2007
+ }
2008
+
2009
+ , prev: function (event) {
2010
+ var active = this.$menu.find('.active').removeClass('active')
2011
+ , prev = active.prev()
2012
+
2013
+ if (!prev.length) {
2014
+ prev = this.$menu.find('li').last()
2015
+ }
2016
+
2017
+ prev.addClass('active')
2018
+ }
2019
+
2020
+ , listen: function () {
2021
+ this.$element
2022
+ .on('blur', $.proxy(this.blur, this))
2023
+ .on('keypress', $.proxy(this.keypress, this))
2024
+ .on('keyup', $.proxy(this.keyup, this))
2025
+
2026
+ if (this.eventSupported('keydown')) {
2027
+ this.$element.on('keydown', $.proxy(this.keydown, this))
2028
+ }
2029
+
2030
+ this.$menu
2031
+ .on('click', $.proxy(this.click, this))
2032
+ .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
2033
+ }
2034
+
2035
+ , eventSupported: function(eventName) {
2036
+ var isSupported = eventName in this.$element
2037
+ if (!isSupported) {
2038
+ this.$element.setAttribute(eventName, 'return;')
2039
+ isSupported = typeof this.$element[eventName] === 'function'
2040
+ }
2041
+ return isSupported
2042
+ }
2043
+
2044
+ , move: function (e) {
2045
+ if (!this.shown) return
2046
+
2047
+ switch(e.keyCode) {
2048
+ case 9: // tab
2049
+ case 13: // enter
2050
+ case 27: // escape
2051
+ e.preventDefault()
2052
+ break
2053
+
2054
+ case 38: // up arrow
2055
+ e.preventDefault()
2056
+ this.prev()
2057
+ break
2058
+
2059
+ case 40: // down arrow
2060
+ e.preventDefault()
2061
+ this.next()
2062
+ break
2063
+ }
2064
+
2065
+ e.stopPropagation()
2066
+ }
2067
+
2068
+ , keydown: function (e) {
2069
+ this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
2070
+ this.move(e)
2071
+ }
2072
+
2073
+ , keypress: function (e) {
2074
+ if (this.suppressKeyPressRepeat) return
2075
+ this.move(e)
2076
+ }
2077
+
2078
+ , keyup: function (e) {
2079
+ switch(e.keyCode) {
2080
+ case 40: // down arrow
2081
+ case 38: // up arrow
2082
+ case 16: // shift
2083
+ case 17: // ctrl
2084
+ case 18: // alt
2085
+ break
2086
+
2087
+ case 9: // tab
2088
+ case 13: // enter
2089
+ if (!this.shown) return
2090
+ this.select()
2091
+ break
2092
+
2093
+ case 27: // escape
2094
+ if (!this.shown) return
2095
+ this.hide()
2096
+ break
2097
+
2098
+ default:
2099
+ this.lookup()
2100
+ }
2101
+
2102
+ e.stopPropagation()
2103
+ e.preventDefault()
2104
+ }
2105
+
2106
+ , blur: function (e) {
2107
+ var that = this
2108
+ setTimeout(function () { that.hide() }, 150)
2109
+ }
2110
+
2111
+ , click: function (e) {
2112
+ e.stopPropagation()
2113
+ e.preventDefault()
2114
+ this.select()
2115
+ }
2116
+
2117
+ , mouseenter: function (e) {
2118
+ this.$menu.find('.active').removeClass('active')
2119
+ $(e.currentTarget).addClass('active')
2120
+ }
2121
+
2122
+ }
2123
+
2124
+
2125
+ /* TYPEAHEAD PLUGIN DEFINITION
2126
+ * =========================== */
2127
+
2128
+ var old = $.fn.typeahead
2129
+
2130
+ $.fn.typeahead = function (option) {
2131
+ return this.each(function () {
2132
+ var $this = $(this)
2133
+ , data = $this.data('typeahead')
2134
+ , options = typeof option == 'object' && option
2135
+ if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
2136
+ if (typeof option == 'string') data[option]()
2137
+ })
2138
+ }
2139
+
2140
+ $.fn.typeahead.defaults = {
2141
+ source: []
2142
+ , items: 8
2143
+ , menu: '<ul class="typeahead dropdown-menu"></ul>'
2144
+ , item: '<li><a href="#"></a></li>'
2145
+ , minLength: 1
2146
+ }
2147
+
2148
+ $.fn.typeahead.Constructor = Typeahead
2149
+
2150
+
2151
+ /* TYPEAHEAD NO CONFLICT
2152
+ * =================== */
2153
+
2154
+ $.fn.typeahead.noConflict = function () {
2155
+ $.fn.typeahead = old
2156
+ return this
2157
+ }
2158
+
2159
+
2160
+ /* TYPEAHEAD DATA-API
2161
+ * ================== */
2162
+
2163
+ $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
2164
+ var $this = $(this)
2165
+ if ($this.data('typeahead')) return
2166
+ e.preventDefault()
2167
+ $this.typeahead($this.data())
2168
+ })
2169
+
2170
+ }(window.jQuery);