web_admin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +32 -0
  6. data/Gemfile.lock +335 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.rdoc +3 -0
  9. data/Rakefile +22 -0
  10. data/app/assets/images/web_admin/.keep +0 -0
  11. data/app/assets/images/web_admin/avatar.jpg +0 -0
  12. data/app/assets/images/web_admin/first_icon.png +0 -0
  13. data/app/assets/images/web_admin/render-1-thumb.jpg +0 -0
  14. data/app/assets/images/web_admin/render-1.jpg +0 -0
  15. data/app/assets/images/web_admin/render-2-thumb.jpg +0 -0
  16. data/app/assets/images/web_admin/render-2.jpg +0 -0
  17. data/app/assets/images/web_admin/render-3-thumb.jpg +0 -0
  18. data/app/assets/images/web_admin/render-3.jpg +0 -0
  19. data/app/assets/images/web_admin/render-4-thumb.jpg +0 -0
  20. data/app/assets/images/web_admin/render-4.jpg +0 -0
  21. data/app/assets/images/web_admin/responsive.png +0 -0
  22. data/app/assets/javascripts/web_admin/app.data.js +336 -0
  23. data/app/assets/javascripts/web_admin/app.js +172 -0
  24. data/app/assets/javascripts/web_admin/app.plugin.js +220 -0
  25. data/app/assets/javascripts/web_admin/application.js +20 -0
  26. data/app/assets/javascripts/web_admin/bootstrap-filestyle.min.js +1 -0
  27. data/app/assets/javascripts/web_admin/bootstrap.js +1951 -0
  28. data/app/assets/javascripts/web_admin/charts/easypiechart/jquery.easy-pie-chart.js +184 -0
  29. data/app/assets/javascripts/web_admin/charts/sparkline/jquery.sparkline.min.js +5 -0
  30. data/app/assets/javascripts/web_admin/combodate/combodate.js +453 -0
  31. data/app/assets/javascripts/web_admin/combodate/moment.min.js +6 -0
  32. data/app/assets/javascripts/web_admin/data/datagrid.json +1900 -0
  33. data/app/assets/javascripts/web_admin/data/datatable.json +401 -0
  34. data/app/assets/javascripts/web_admin/datatables/jquery.dataTables.min.js +155 -0
  35. data/app/assets/javascripts/web_admin/datepicker/bootstrap-datepicker.js +474 -0
  36. data/app/assets/javascripts/web_admin/datepicker.js +3 -0
  37. data/app/assets/javascripts/web_admin/fuelux/fuelux.js +1645 -0
  38. data/app/assets/javascripts/web_admin/fullcalendar/fullcalendar.min.js +7 -0
  39. data/app/assets/javascripts/web_admin/grid/gallery.js +14 -0
  40. data/app/assets/javascripts/web_admin/grid/jquery.grid-a-licious.min.js +15 -0
  41. data/app/assets/javascripts/web_admin/grid/masonry.pkgd.min.js +9 -0
  42. data/app/assets/javascripts/web_admin/ie/excanvas.js +924 -0
  43. data/app/assets/javascripts/web_admin/ie/html5.js +9 -0
  44. data/app/assets/javascripts/web_admin/ie/respond.min.js +6 -0
  45. data/app/assets/javascripts/web_admin/jquery-ui-1.10.3.custom.min.js +6 -0
  46. data/app/assets/javascripts/web_admin/jquery.datetimepicker.js +1851 -0
  47. data/app/assets/javascripts/web_admin/jquery.ui.touch-punch.min.js +11 -0
  48. data/app/assets/javascripts/web_admin/parsley/parsley.min.js +35 -0
  49. data/app/assets/javascripts/web_admin/prettyphoto/default/default_thumb.png +0 -0
  50. data/app/assets/javascripts/web_admin/prettyphoto/default/loader.gif +0 -0
  51. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite.png +0 -0
  52. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_next.png +0 -0
  53. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_prev.png +0 -0
  54. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_x.png +0 -0
  55. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_y.png +0 -0
  56. data/app/assets/javascripts/web_admin/prettyphoto/jquery.prettyPhoto.js +7 -0
  57. data/app/assets/javascripts/web_admin/prettyphoto/prettyPhoto.css +170 -0
  58. data/app/assets/javascripts/web_admin/select2/select2.css +652 -0
  59. data/app/assets/javascripts/web_admin/select2/select2.min.js +22 -0
  60. data/app/assets/javascripts/web_admin/slider/bootstrap-slider.js +388 -0
  61. data/app/assets/javascripts/web_admin/underscore-min.js +7 -0
  62. data/app/assets/javascripts/web_admin/underscore-min.map +1 -0
  63. data/app/assets/javascripts/web_admin/upload_image.js +39 -0
  64. data/app/assets/stylesheets/web_admin/application.css +15 -0
  65. data/app/assets/stylesheets/web_admin/bootstrap.css +5784 -0
  66. data/app/assets/stylesheets/web_admin/font-awesome.min.css +4 -0
  67. data/app/assets/stylesheets/web_admin/font.css +18 -0
  68. data/app/assets/stylesheets/web_admin/fonts/FontAwesome.otf +0 -0
  69. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.eot +0 -0
  70. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.svg +414 -0
  71. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.ttf +0 -0
  72. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.woff +0 -0
  73. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.eot +0 -0
  74. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.svg +229 -0
  75. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.ttf +0 -0
  76. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.woff +0 -0
  77. data/app/assets/stylesheets/web_admin/fonts/opensans/opensans-bold-webfont.woff +0 -0
  78. data/app/assets/stylesheets/web_admin/fonts/opensans/opensans-light-webfont.woff +0 -0
  79. data/app/assets/stylesheets/web_admin/fonts/opensans/opensans-webfont.woff +0 -0
  80. data/app/assets/stylesheets/web_admin/landing.css +272 -0
  81. data/app/assets/stylesheets/web_admin/plugin.css +1132 -0
  82. data/app/assets/stylesheets/web_admin/style.css +613 -0
  83. data/app/assets/stylesheets/web_admin/style2.css +21 -0
  84. data/app/controllers/web_admin/albums_controller.rb +8 -0
  85. data/app/controllers/web_admin/application_controller.rb +10 -0
  86. data/app/controllers/web_admin/crud_controller.rb +61 -0
  87. data/app/controllers/web_admin/events_controller.rb +9 -0
  88. data/app/controllers/web_admin/images_controller.rb +8 -0
  89. data/app/controllers/web_admin/institutionals_controller.rb +8 -0
  90. data/app/controllers/web_admin/main_controller.rb +7 -0
  91. data/app/controllers/web_admin/posts_controller.rb +19 -0
  92. data/app/controllers/web_admin/users_controller.rb +15 -0
  93. data/app/controllers/web_admin/videos_controller.rb +8 -0
  94. data/app/enumerations/web_admin/permission_type.rb +5 -0
  95. data/app/enumerations/web_admin/user_type.rb +6 -0
  96. data/app/helpers/web_admin/application_helper.rb +20 -0
  97. data/app/models/ability.rb +14 -0
  98. data/app/models/ckeditor/asset.rb +7 -0
  99. data/app/models/ckeditor/attachment_file.rb +7 -0
  100. data/app/models/ckeditor/picture.rb +7 -0
  101. data/app/models/web_admin/album.rb +13 -0
  102. data/app/models/web_admin/event.rb +20 -0
  103. data/app/models/web_admin/image.rb +10 -0
  104. data/app/models/web_admin/institutional.rb +11 -0
  105. data/app/models/web_admin/permission.rb +9 -0
  106. data/app/models/web_admin/post.rb +14 -0
  107. data/app/models/web_admin/user.rb +25 -0
  108. data/app/models/web_admin/video.rb +17 -0
  109. data/app/uploaders/ckeditor_attachment_file_uploader.rb +36 -0
  110. data/app/uploaders/ckeditor_picture_uploader.rb +47 -0
  111. data/app/uploaders/web_admin/image_post_uploader.rb +55 -0
  112. data/app/uploaders/web_admin/image_uploader.rb +52 -0
  113. data/app/views/devise/confirmations/new.html.erb +12 -0
  114. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  115. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  116. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  117. data/app/views/devise/passwords/edit.html.erb +16 -0
  118. data/app/views/devise/passwords/new.html.erb +12 -0
  119. data/app/views/devise/registrations/edit.html.erb +29 -0
  120. data/app/views/devise/registrations/new.html.erb +18 -0
  121. data/app/views/devise/sessions/new.html.erb +16 -0
  122. data/app/views/devise/shared/_links.html.erb +25 -0
  123. data/app/views/devise/unlocks/new.html.erb +12 -0
  124. data/app/views/layouts/web_admin/devise.html.erb +42 -0
  125. data/app/views/shared/403.html +57 -0
  126. data/app/views/shared/_header.html.erb +16 -0
  127. data/app/views/shared/_navbar.html.erb +23 -0
  128. data/app/views/shared/_notice.html.erb +12 -0
  129. data/app/views/web_admin/albums/_form.html.erb +23 -0
  130. data/app/views/web_admin/albums/edit.html.erb +4 -0
  131. data/app/views/web_admin/albums/index.html.erb +39 -0
  132. data/app/views/web_admin/albums/new.html.erb +4 -0
  133. data/app/views/web_admin/albums/show.html.erb +4 -0
  134. data/app/views/web_admin/events/_form.html.erb +37 -0
  135. data/app/views/web_admin/events/edit.html.erb +4 -0
  136. data/app/views/web_admin/events/index.html.erb +39 -0
  137. data/app/views/web_admin/events/new.html.erb +4 -0
  138. data/app/views/web_admin/images/_form.html.erb +23 -0
  139. data/app/views/web_admin/images/_images.html.erb +10 -0
  140. data/app/views/web_admin/images/create.js.erb +2 -0
  141. data/app/views/web_admin/images/update.js.erb +2 -0
  142. data/app/views/web_admin/institutionals/_form.html.erb +22 -0
  143. data/app/views/web_admin/institutionals/edit.html.erb +4 -0
  144. data/app/views/web_admin/institutionals/index.html.erb +35 -0
  145. data/app/views/web_admin/institutionals/new.html.erb +4 -0
  146. data/app/views/web_admin/layouts/application.html.erb +77 -0
  147. data/app/views/web_admin/main/index.html.erb +1 -0
  148. data/app/views/web_admin/posts/_form.html.erb +27 -0
  149. data/app/views/web_admin/posts/edit.html.erb +4 -0
  150. data/app/views/web_admin/posts/index.html.erb +37 -0
  151. data/app/views/web_admin/posts/new.html.erb +4 -0
  152. data/app/views/web_admin/users/_form.html.erb +49 -0
  153. data/app/views/web_admin/users/edit.html.erb +4 -0
  154. data/app/views/web_admin/users/index.html.erb +35 -0
  155. data/app/views/web_admin/users/new.html.erb +4 -0
  156. data/app/views/web_admin/videos/_form.html.erb +22 -0
  157. data/app/views/web_admin/videos/edit.html.erb +4 -0
  158. data/app/views/web_admin/videos/index.html.erb +37 -0
  159. data/app/views/web_admin/videos/new.html.erb +4 -0
  160. data/bin/rails +12 -0
  161. data/config/initializers/ckeditor.rb +39 -0
  162. data/config/initializers/devise.rb +261 -0
  163. data/config/initializers/enumerate_it.rb +1 -0
  164. data/config/initializers/simple_form.rb +145 -0
  165. data/config/initializers/simple_form_bootstrap.rb +46 -0
  166. data/config/locales/buttons.yml +3 -0
  167. data/config/locales/controllers.yml +9 -0
  168. data/config/locales/devise.en.yml +62 -0
  169. data/config/locales/devise.pt.yml +62 -0
  170. data/config/locales/models.yml +54 -0
  171. data/config/locales/rails.yml +219 -0
  172. data/config/locales/responders.yml +10 -0
  173. data/config/locales/simple_form.en.yml +26 -0
  174. data/config/routes.rb +13 -0
  175. data/db/migrate/20141023223026_devise_create_admin_web_users.rb +42 -0
  176. data/db/migrate/20141023223656_create_admin_web_posts.rb +15 -0
  177. data/db/migrate/20141026181117_create_ckeditor_assets.rb +26 -0
  178. data/db/migrate/20141028020102_create_admin_web_institutionals.rb +10 -0
  179. data/db/migrate/20141028135201_create_admin_web_videos.rb +10 -0
  180. data/db/migrate/20141114020551_create_admin_web_albums.rb +12 -0
  181. data/db/migrate/20141117183405_create_admin_web_images.rb +11 -0
  182. data/db/migrate/20141130203155_add_user_type_to_users.rb +5 -0
  183. data/db/migrate/20141224221959_create_admin_web_events.rb +18 -0
  184. data/db/migrate/20150130140502_create_admin_web_permissions.rb +13 -0
  185. data/db/migrate/20150510191213_rename_tables.rb +12 -0
  186. data/lib/application_responder.rb +12 -0
  187. data/lib/tasks/web_admin_tasks.rake +4 -0
  188. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  189. data/lib/web_admin/engine.rb +15 -0
  190. data/lib/web_admin/version.rb +3 -0
  191. data/lib/web_admin.rb +18 -0
  192. data/spec/factories/admin_web_users.rb +24 -0
  193. data/spec/features/admin_web/albums_spec.rb +74 -0
  194. data/spec/features/admin_web/event_spec.rb +85 -0
  195. data/spec/features/admin_web/institutionals_spec.rb +47 -0
  196. data/spec/features/admin_web/login_spec.rb +18 -0
  197. data/spec/features/admin_web/permissions_spec.rb +40 -0
  198. data/spec/features/admin_web/posts_spec.rb +55 -0
  199. data/spec/features/admin_web/users_spec.rb +73 -0
  200. data/spec/features/admin_web/videos_spec.rb +51 -0
  201. data/spec/fixtures/p3-single.jpg +0 -0
  202. data/spec/models/admin_web/album_spec.rb +20 -0
  203. data/spec/models/admin_web/event_spec.rb +42 -0
  204. data/spec/models/admin_web/image_spec.rb +14 -0
  205. data/spec/models/admin_web/institutional_spec.rb +19 -0
  206. data/spec/models/admin_web/permission_spec.rb +14 -0
  207. data/spec/models/admin_web/post_spec.rb +25 -0
  208. data/spec/models/admin_web/user_spec.rb +18 -0
  209. data/spec/models/admin_web/video_spec.rb +26 -0
  210. data/spec/rails_helper.rb +52 -0
  211. data/spec/spec_helper.rb +85 -0
  212. data/spec/support/capybara.rb +53 -0
  213. data/spec/support/database_cleaner.rb +25 -0
  214. data/spec/support/devise.rb +5 -0
  215. data/spec/support/factory_girl.rb +4 -0
  216. data/spec/support/helpers.rb +82 -0
  217. data/spec/support/shared_connection.rb +10 -0
  218. data/spec/test_app/README.rdoc +28 -0
  219. data/spec/test_app/Rakefile +6 -0
  220. data/spec/test_app/app/assets/images/.keep +0 -0
  221. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  222. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  223. data/spec/test_app/app/controllers/application_controller.rb +5 -0
  224. data/spec/test_app/app/controllers/concerns/.keep +0 -0
  225. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  226. data/spec/test_app/app/mailers/.keep +0 -0
  227. data/spec/test_app/app/models/.keep +0 -0
  228. data/spec/test_app/app/models/concerns/.keep +0 -0
  229. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  230. data/spec/test_app/bin/bundle +3 -0
  231. data/spec/test_app/bin/rails +4 -0
  232. data/spec/test_app/bin/rake +4 -0
  233. data/spec/test_app/config/application.rb +29 -0
  234. data/spec/test_app/config/boot.rb +5 -0
  235. data/spec/test_app/config/database.yml +85 -0
  236. data/spec/test_app/config/environment.rb +5 -0
  237. data/spec/test_app/config/environments/development.rb +37 -0
  238. data/spec/test_app/config/environments/production.rb +78 -0
  239. data/spec/test_app/config/environments/test.rb +39 -0
  240. data/spec/test_app/config/initializers/assets.rb +8 -0
  241. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  242. data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
  243. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  244. data/spec/test_app/config/initializers/inflections.rb +16 -0
  245. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  246. data/spec/test_app/config/initializers/session_store.rb +3 -0
  247. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  248. data/spec/test_app/config/locales/en.yml +23 -0
  249. data/spec/test_app/config/routes.rb +4 -0
  250. data/spec/test_app/config/secrets.yml +22 -0
  251. data/spec/test_app/config.ru +4 -0
  252. data/spec/test_app/db/schema.rb +121 -0
  253. data/spec/test_app/lib/assets/.keep +0 -0
  254. data/spec/test_app/log/.keep +0 -0
  255. data/spec/test_app/public/404.html +67 -0
  256. data/spec/test_app/public/422.html +67 -0
  257. data/spec/test_app/public/500.html +66 -0
  258. data/spec/test_app/public/favicon.ico +0 -0
  259. data/spec/test_app/spec/factories/admin_web_albums.rb +7 -0
  260. data/spec/test_app/spec/factories/admin_web_users.rb +24 -0
  261. data/spec/test_app/spec/factories/permissions.rb +36 -0
  262. data/web_admin.gemspec +38 -0
  263. data/wercker.yml +16 -0
  264. metadata +530 -0
@@ -0,0 +1,1645 @@
1
+
2
+ /*
3
+ * Fuel UX Checkbox
4
+ * https://github.com/ExactTarget/fuelux
5
+ *
6
+ * Copyright (c) 2012 ExactTarget
7
+ * Licensed under the MIT license.
8
+ */
9
+
10
+ +function ($) { "use strict";
11
+
12
+
13
+ // CHECKBOX CONSTRUCTOR AND PROTOTYPE
14
+
15
+ var Checkbox = function (element, options) {
16
+
17
+ this.$element = $(element);
18
+ this.options = $.extend({}, $.fn.checkbox.defaults, options);
19
+
20
+ // cache elements
21
+ this.$label = this.$element.parent();
22
+ this.$icon = this.$label.find('i');
23
+ this.$chk = this.$label.find('input[type=checkbox]');
24
+
25
+ // set default state
26
+ this.setState(this.$chk);
27
+
28
+ // handle events
29
+ this.$chk.on('change', $.proxy(this.itemchecked, this));
30
+ };
31
+
32
+ Checkbox.prototype = {
33
+
34
+ constructor: Checkbox,
35
+
36
+ setState: function ($chk) {
37
+ var checked = $chk.is(':checked');
38
+ var disabled = $chk.is(':disabled');
39
+
40
+ // reset classes
41
+ this.$icon.removeClass('checked').removeClass('disabled');
42
+
43
+ // set state of checkbox
44
+ if (checked === true) {
45
+ this.$icon.addClass('checked');
46
+ }
47
+ if (disabled === true) {
48
+ this.$icon.addClass('disabled');
49
+ }
50
+ },
51
+
52
+ enable: function () {
53
+ this.$chk.attr('disabled', false);
54
+ this.$icon.removeClass('disabled');
55
+ },
56
+
57
+ disable: function () {
58
+ this.$chk.attr('disabled', true);
59
+ this.$icon.addClass('disabled');
60
+ },
61
+
62
+ toggle: function () {
63
+ this.$chk.click();
64
+ },
65
+
66
+ itemchecked: function (e) {
67
+ var chk = $(e.target);
68
+ this.setState(chk);
69
+ }
70
+ };
71
+
72
+
73
+ // CHECKBOX PLUGIN DEFINITION
74
+
75
+ $.fn.checkbox = function (option, value) {
76
+ var methodReturn;
77
+
78
+ var $set = this.each(function () {
79
+ var $this = $(this);
80
+ var data = $this.data('checkbox');
81
+ var options = typeof option === 'object' && option;
82
+
83
+ if (!data) $this.data('checkbox', (data = new Checkbox(this, options)));
84
+ if (typeof option === 'string') methodReturn = data[option](value);
85
+ });
86
+
87
+ return (methodReturn === undefined) ? $set : methodReturn;
88
+ };
89
+
90
+ $.fn.checkbox.defaults = {};
91
+
92
+ $.fn.checkbox.Constructor = Checkbox;
93
+
94
+
95
+ // CHECKBOX DATA-API
96
+
97
+ $(function () {
98
+ $(window).on('load', function () {
99
+ //$('i.checkbox').each(function () {
100
+ $('.checkbox-custom > input[type=checkbox]').each(function () {
101
+ var $this = $(this);
102
+ if ($this.data('checkbox')) return;
103
+ $this.checkbox($this.data());
104
+ });
105
+ });
106
+ });
107
+
108
+ }(window.jQuery);
109
+
110
+ /*
111
+ * Fuel UX Utilities
112
+ * https://github.com/ExactTarget/fuelux
113
+ *
114
+ * Copyright (c) 2012 ExactTarget
115
+ * Licensed under the MIT license.
116
+ */
117
+
118
+ +function ($) { "use strict";
119
+
120
+ // custom case-insensitive match expression
121
+ function fuelTextExactCI(elem, text) {
122
+ return (elem.textContent || elem.innerText || $(elem).text() || '').toLowerCase() === (text || '').toLowerCase();
123
+ }
124
+
125
+ $.expr[':'].fuelTextExactCI = $.expr.createPseudo ?
126
+ $.expr.createPseudo(function (text) {
127
+ return function (elem) {
128
+ return fuelTextExactCI(elem, text);
129
+ };
130
+ }) :
131
+ function (elem, i, match) {
132
+ return fuelTextExactCI(elem, match[3]);
133
+ };
134
+
135
+ }(window.jQuery);
136
+ /*
137
+ * Fuel UX Combobox
138
+ * https://github.com/ExactTarget/fuelux
139
+ *
140
+ * Copyright (c) 2012 ExactTarget
141
+ * Licensed under the MIT license.
142
+ */
143
+
144
+ +function ($) { "use strict";
145
+
146
+ // COMBOBOX CONSTRUCTOR AND PROTOTYPE
147
+
148
+ var Combobox = function (element, options) {
149
+ this.$element = $(element);
150
+ this.options = $.extend({}, $.fn.combobox.defaults, options);
151
+ this.$element.on('click', 'a', $.proxy(this.itemclicked, this));
152
+ this.$element.on('change', 'input', $.proxy(this.inputchanged, this));
153
+ this.$input = this.$element.find('input');
154
+ this.$button = this.$element.find('.btn');
155
+
156
+ // set default selection
157
+ this.setDefaultSelection();
158
+ };
159
+
160
+ Combobox.prototype = {
161
+
162
+ constructor: Combobox,
163
+
164
+ selectedItem: function () {
165
+ var item = this.$selectedItem;
166
+ var data = {};
167
+
168
+ if (item) {
169
+ var txt = this.$selectedItem.text();
170
+ data = $.extend({ text: txt }, this.$selectedItem.data());
171
+ }
172
+ else {
173
+ data = { text: this.$input.val()};
174
+ }
175
+
176
+ return data;
177
+ },
178
+
179
+ selectByText: function (text) {
180
+ var selector = 'li:fuelTextExactCI(' + text + ')';
181
+ this.selectBySelector(selector);
182
+ },
183
+
184
+ selectByValue: function (value) {
185
+ var selector = 'li[data-value="' + value + '"]';
186
+ this.selectBySelector(selector);
187
+ },
188
+
189
+ selectByIndex: function (index) {
190
+ // zero-based index
191
+ var selector = 'li:eq(' + index + ')';
192
+ this.selectBySelector(selector);
193
+ },
194
+
195
+ selectBySelector: function (selector) {
196
+ var $item = this.$element.find(selector);
197
+
198
+ if (typeof $item[0] !== 'undefined') {
199
+ this.$selectedItem = $item;
200
+ this.$input.val(this.$selectedItem.text());
201
+ }
202
+ else {
203
+ this.$selectedItem = null;
204
+ }
205
+ },
206
+
207
+ setDefaultSelection: function () {
208
+ var selector = 'li[data-selected=true]:first';
209
+ var item = this.$element.find(selector);
210
+
211
+ if (item.length > 0) {
212
+ // select by data-attribute
213
+ this.selectBySelector(selector);
214
+ item.removeData('selected');
215
+ item.removeAttr('data-selected');
216
+ }
217
+ },
218
+
219
+ enable: function () {
220
+ this.$input.removeAttr('disabled');
221
+ this.$button.removeClass('disabled');
222
+ },
223
+
224
+ disable: function () {
225
+ this.$input.attr('disabled', true);
226
+ this.$button.addClass('disabled');
227
+ },
228
+
229
+ itemclicked: function (e) {
230
+ this.$selectedItem = $(e.target).parent();
231
+
232
+ // set input text and trigger input change event marked as synthetic
233
+ this.$input.val(this.$selectedItem.text()).trigger('change', { synthetic: true });
234
+
235
+ // pass object including text and any data-attributes
236
+ // to onchange event
237
+ var data = this.selectedItem();
238
+
239
+ // trigger changed event
240
+ this.$element.trigger('changed', data);
241
+
242
+ e.preventDefault();
243
+ },
244
+
245
+ inputchanged: function (e, extra) {
246
+
247
+ // skip processing for internally-generated synthetic event
248
+ // to avoid double processing
249
+ if (extra && extra.synthetic) return;
250
+
251
+ var val = $(e.target).val();
252
+ this.selectByText(val);
253
+
254
+ // find match based on input
255
+ // if no match, pass the input value
256
+ var data = this.selectedItem();
257
+ if (data.text.length === 0) {
258
+ data = { text: val };
259
+ }
260
+
261
+ // trigger changed event
262
+ this.$element.trigger('changed', data);
263
+
264
+ }
265
+
266
+ };
267
+
268
+
269
+ // COMBOBOX PLUGIN DEFINITION
270
+
271
+ $.fn.combobox = function (option, value) {
272
+ var methodReturn;
273
+
274
+ var $set = this.each(function () {
275
+ var $this = $(this);
276
+ var data = $this.data('combobox');
277
+ var options = typeof option === 'object' && option;
278
+
279
+ if (!data) $this.data('combobox', (data = new Combobox(this, options)));
280
+ if (typeof option === 'string') methodReturn = data[option](value);
281
+ });
282
+
283
+ return (methodReturn === undefined) ? $set : methodReturn;
284
+ };
285
+
286
+ $.fn.combobox.defaults = {};
287
+
288
+ $.fn.combobox.Constructor = Combobox;
289
+
290
+
291
+ // COMBOBOX DATA-API
292
+
293
+ $(function () {
294
+
295
+ $(window).on('load', function () {
296
+ $('.combobox').each(function () {
297
+ var $this = $(this);
298
+ if ($this.data('combobox')) return;
299
+ $this.combobox($this.data());
300
+ });
301
+ });
302
+
303
+ $('body').on('mousedown.combobox.data-api', '.combobox', function (e) {
304
+ var $this = $(this);
305
+ if ($this.data('combobox')) return;
306
+ $this.combobox($this.data());
307
+ });
308
+ });
309
+
310
+ }(window.jQuery);
311
+
312
+ /*
313
+ * Fuel UX Datagrid
314
+ * https://github.com/ExactTarget/fuelux
315
+ *
316
+ * Copyright (c) 2012 ExactTarget
317
+ * Licensed under the MIT license.
318
+ */
319
+
320
+ +function ($) { "use strict";
321
+
322
+ // Relates to thead .sorted styles in datagrid.less
323
+ var SORTED_HEADER_OFFSET = 22;
324
+
325
+ // DATAGRID CONSTRUCTOR AND PROTOTYPE
326
+
327
+ var Datagrid = function (element, options) {
328
+ this.$element = $(element);
329
+ this.$thead = this.$element.find('thead');
330
+ this.$tfoot = this.$element.find('tfoot');
331
+ this.$footer = this.$element.find('tfoot th');
332
+ this.$footerchildren = this.$footer.children().show().css('visibility', 'hidden');
333
+ this.$topheader = this.$element.find('thead th');
334
+ this.$searchcontrol = this.$element.find('.datagrid-search');
335
+ this.$filtercontrol = this.$element.find('.filter');
336
+ this.$pagesize = this.$element.find('.grid-pagesize');
337
+ this.$pageinput = this.$element.find('.grid-pager input');
338
+ this.$pagedropdown = this.$element.find('.grid-pager .dropdown-menu');
339
+ this.$prevpagebtn = this.$element.find('.grid-prevpage');
340
+ this.$nextpagebtn = this.$element.find('.grid-nextpage');
341
+ this.$pageslabel = this.$element.find('.grid-pages');
342
+ this.$countlabel = this.$element.find('.grid-count');
343
+ this.$startlabel = this.$element.find('.grid-start');
344
+ this.$endlabel = this.$element.find('.grid-end');
345
+
346
+ this.$tbody = $('<tbody>').insertAfter(this.$thead);
347
+ this.$colheader = $('<tr>').appendTo(this.$thead);
348
+
349
+ this.options = $.extend(true, {}, $.fn.datagrid.defaults, options);
350
+
351
+ // Shim until v3 -- account for FuelUX select or native select for page size:
352
+ if (this.$pagesize.hasClass('select')) {
353
+ this.options.dataOptions.pageSize = parseInt(this.$pagesize.select('selectedItem').value, 10);
354
+ } else {
355
+ this.options.dataOptions.pageSize = parseInt(this.$pagesize.val(), 10);
356
+ }
357
+
358
+ // Shim until v3 -- account for older search class:
359
+ if (this.$searchcontrol.length <= 0) {
360
+ this.$searchcontrol = this.$element.find('.search');
361
+ }
362
+
363
+ this.columns = this.options.dataSource.columns();
364
+
365
+ this.$nextpagebtn.on('click', $.proxy(this.next, this));
366
+ this.$prevpagebtn.on('click', $.proxy(this.previous, this));
367
+ this.$searchcontrol.on('searched cleared', $.proxy(this.searchChanged, this));
368
+ this.$filtercontrol.on('changed', $.proxy(this.filterChanged, this));
369
+ this.$colheader.on('click', 'th', $.proxy(this.headerClicked, this));
370
+
371
+ if(this.$pagesize.hasClass('select')) {
372
+ this.$pagesize.on('changed', $.proxy(this.pagesizeChanged, this));
373
+ } else {
374
+ this.$pagesize.on('change', $.proxy(this.pagesizeChanged, this));
375
+ }
376
+
377
+ this.$pageinput.on('change', $.proxy(this.pageChanged, this));
378
+
379
+ this.renderColumns();
380
+
381
+ if (this.options.stretchHeight) this.initStretchHeight();
382
+
383
+ this.renderData();
384
+ };
385
+
386
+ Datagrid.prototype = {
387
+
388
+ constructor: Datagrid,
389
+
390
+ renderColumns: function () {
391
+ var self = this;
392
+
393
+ this.$footer.attr('colspan', this.columns.length);
394
+ this.$topheader.attr('colspan', this.columns.length);
395
+
396
+ var colHTML = '';
397
+
398
+ $.each(this.columns, function (index, column) {
399
+ colHTML += '<th data-property="' + column.property + '"';
400
+ if (column.sortable) colHTML += ' class="sortable"';
401
+ colHTML += '>' + column.label + '</th>';
402
+ });
403
+
404
+ self.$colheader.append(colHTML);
405
+ },
406
+
407
+ updateColumns: function ($target, direction) {
408
+ this._updateColumns(this.$colheader, $target, direction);
409
+
410
+ if (this.$sizingHeader) {
411
+ this._updateColumns(this.$sizingHeader, this.$sizingHeader.find('th').eq($target.index()), direction);
412
+ }
413
+ },
414
+
415
+ _updateColumns: function ($header, $target, direction) {
416
+ var className = (direction === 'asc') ? 'fa fa-chevron-up' : 'fa fa-chevron-down';
417
+ $header.find('i.datagrid-sort').remove();
418
+ $header.find('th').removeClass('sorted');
419
+ $('<i>').addClass(className + ' datagrid-sort').appendTo($target);
420
+ $target.addClass('sorted');
421
+ },
422
+
423
+ updatePageDropdown: function (data) {
424
+ var pageHTML = '';
425
+
426
+ for (var i = 1; i <= data.pages; i++) {
427
+ pageHTML += '<li><a>' + i + '</a></li>';
428
+ }
429
+
430
+ this.$pagedropdown.html(pageHTML);
431
+ },
432
+
433
+ updatePageButtons: function (data) {
434
+ if (data.page === 1) {
435
+ this.$prevpagebtn.attr('disabled', 'disabled');
436
+ } else {
437
+ this.$prevpagebtn.removeAttr('disabled');
438
+ }
439
+
440
+ if (data.page === data.pages) {
441
+ this.$nextpagebtn.attr('disabled', 'disabled');
442
+ } else {
443
+ this.$nextpagebtn.removeAttr('disabled');
444
+ }
445
+ },
446
+
447
+ renderData: function () {
448
+ var self = this;
449
+
450
+ this.$tbody.html(this.placeholderRowHTML(this.options.loadingHTML));
451
+
452
+ this.options.dataSource.data(this.options.dataOptions, function (data) {
453
+ var itemdesc = (data.count === 1) ? self.options.itemText : self.options.itemsText;
454
+ var rowHTML = '';
455
+
456
+ self.$footerchildren.css('visibility', function () {
457
+ return (data.count > 0) ? 'visible' : 'hidden';
458
+ });
459
+
460
+ self.$pageinput.val(data.page);
461
+ self.$pageslabel.text(data.pages);
462
+ self.$countlabel.text(data.count + ' ' + itemdesc);
463
+ self.$startlabel.text(data.start);
464
+ self.$endlabel.text(data.end);
465
+
466
+ self.updatePageDropdown(data);
467
+ self.updatePageButtons(data);
468
+
469
+ $.each(data.data, function (index, row) {
470
+ rowHTML += '<tr>';
471
+ $.each(self.columns, function (index, column) {
472
+ rowHTML += '<td>' + row[column.property] + '</td>';
473
+ });
474
+ rowHTML += '</tr>';
475
+ });
476
+
477
+ if (!rowHTML) rowHTML = self.placeholderRowHTML('0 ' + self.options.itemsText);
478
+
479
+ self.$tbody.html(rowHTML);
480
+ self.stretchHeight();
481
+
482
+ self.$element.trigger('loaded');
483
+ });
484
+
485
+ },
486
+
487
+ placeholderRowHTML: function (content) {
488
+ return '<tr><td style="text-align:center;padding:20px;border-bottom:none;" colspan="' +
489
+ this.columns.length + '">' + content + '</td></tr>';
490
+ },
491
+
492
+ headerClicked: function (e) {
493
+ var $target = $(e.target);
494
+ if (!$target.hasClass('sortable')) return;
495
+
496
+ var direction = this.options.dataOptions.sortDirection;
497
+ var sort = this.options.dataOptions.sortProperty;
498
+ var property = $target.data('property');
499
+
500
+ if (sort === property) {
501
+ this.options.dataOptions.sortDirection = (direction === 'asc') ? 'desc' : 'asc';
502
+ } else {
503
+ this.options.dataOptions.sortDirection = 'asc';
504
+ this.options.dataOptions.sortProperty = property;
505
+ }
506
+
507
+ this.options.dataOptions.pageIndex = 0;
508
+ this.updateColumns($target, this.options.dataOptions.sortDirection);
509
+ this.renderData();
510
+ },
511
+
512
+ pagesizeChanged: function (e, pageSize) {
513
+ if(pageSize) {
514
+ this.options.dataOptions.pageSize = parseInt(pageSize.value, 10);
515
+ } else {
516
+ this.options.dataOptions.pageSize = parseInt($(e.target).val(), 10);
517
+ }
518
+
519
+ this.options.dataOptions.pageIndex = 0;
520
+ this.renderData();
521
+ },
522
+
523
+ pageChanged: function (e) {
524
+ var pageRequested = parseInt($(e.target).val(), 10);
525
+ pageRequested = (isNaN(pageRequested)) ? 1 : pageRequested;
526
+ var maxPages = this.$pageslabel.text();
527
+
528
+ this.options.dataOptions.pageIndex =
529
+ (pageRequested > maxPages) ? maxPages - 1 : pageRequested - 1;
530
+
531
+ this.renderData();
532
+ },
533
+
534
+ searchChanged: function (e, search) {
535
+ this.options.dataOptions.search = search;
536
+ this.options.dataOptions.pageIndex = 0;
537
+ this.renderData();
538
+ },
539
+
540
+ filterChanged: function (e, filter) {
541
+ this.options.dataOptions.filter = filter;
542
+ this.options.dataOptions.pageIndex = 0;
543
+ this.renderData();
544
+ },
545
+
546
+ previous: function () {
547
+ this.options.dataOptions.pageIndex--;
548
+ this.renderData();
549
+ },
550
+
551
+ next: function () {
552
+ this.options.dataOptions.pageIndex++;
553
+ this.renderData();
554
+ },
555
+
556
+ reload: function () {
557
+ this.options.dataOptions.pageIndex = 0;
558
+ this.renderData();
559
+ },
560
+
561
+ initStretchHeight: function () {
562
+ this.$gridContainer = this.$element.parent();
563
+
564
+ this.$element.wrap('<div class="datagrid-stretch-wrapper">');
565
+ this.$stretchWrapper = this.$element.parent();
566
+
567
+ this.$headerTable = $('<table>').attr('class', this.$element.attr('class'));
568
+ this.$footerTable = this.$headerTable.clone();
569
+
570
+ this.$headerTable.prependTo(this.$gridContainer).addClass('datagrid-stretch-header');
571
+ this.$thead.detach().appendTo(this.$headerTable);
572
+
573
+ this.$sizingHeader = this.$thead.clone();
574
+ this.$sizingHeader.find('tr:first').remove();
575
+
576
+ this.$footerTable.appendTo(this.$gridContainer).addClass('datagrid-stretch-footer');
577
+ this.$tfoot.detach().appendTo(this.$footerTable);
578
+ },
579
+
580
+ stretchHeight: function () {
581
+ if (!this.$gridContainer) return;
582
+
583
+ this.setColumnWidths();
584
+
585
+ var targetHeight = this.$gridContainer.height();
586
+ var headerHeight = this.$headerTable.outerHeight();
587
+ var footerHeight = this.$footerTable.outerHeight();
588
+ var overhead = headerHeight + footerHeight;
589
+
590
+ this.$stretchWrapper.height(targetHeight - overhead);
591
+ },
592
+
593
+ setColumnWidths: function () {
594
+ if (!this.$sizingHeader) return;
595
+
596
+ this.$element.prepend(this.$sizingHeader);
597
+
598
+ var $sizingCells = this.$sizingHeader.find('th');
599
+ var columnCount = $sizingCells.length;
600
+
601
+ function matchSizingCellWidth(i, el) {
602
+ if (i === columnCount - 1) return;
603
+
604
+ var $el = $(el);
605
+ var $sourceCell = $sizingCells.eq(i);
606
+ var width = $sourceCell.width();
607
+
608
+ // TD needs extra width to match sorted column header
609
+ if ($sourceCell.hasClass('sorted') && $el.prop('tagName') === 'TD') width = width + SORTED_HEADER_OFFSET;
610
+
611
+ $el.width(width);
612
+ }
613
+
614
+ this.$colheader.find('th').each(matchSizingCellWidth);
615
+ this.$tbody.find('tr:first > td').each(matchSizingCellWidth);
616
+
617
+ this.$sizingHeader.detach();
618
+ }
619
+ };
620
+
621
+
622
+ // DATAGRID PLUGIN DEFINITION
623
+
624
+ $.fn.datagrid = function (option) {
625
+ return this.each(function () {
626
+ var $this = $(this);
627
+ var data = $this.data('datagrid');
628
+ var options = typeof option === 'object' && option;
629
+
630
+ if (!data) $this.data('datagrid', (data = new Datagrid(this, options)));
631
+ if (typeof option === 'string') data[option]();
632
+ });
633
+ };
634
+
635
+ $.fn.datagrid.defaults = {
636
+ dataOptions: { pageIndex: 0, pageSize: 10 },
637
+ loadingHTML: '<div class="progress progress-striped active" style="width:50%;margin:auto;"><div class="bar" style="width:100%;"></div></div>',
638
+ itemsText: 'items',
639
+ itemText: 'item'
640
+ };
641
+
642
+ $.fn.datagrid.Constructor = Datagrid;
643
+
644
+ }(window.jQuery);
645
+
646
+ /*
647
+ * Fuel UX Pillbox
648
+ * https://github.com/ExactTarget/fuelux
649
+ *
650
+ * Copyright (c) 2012 ExactTarget
651
+ * Licensed under the MIT license.
652
+ */
653
+
654
+ +function ($) { "use strict";
655
+
656
+ // PILLBOX CONSTRUCTOR AND PROTOTYPE
657
+
658
+ var Pillbox = function (element, options) {
659
+ this.$element = $(element);
660
+ this.options = $.extend({}, $.fn.pillbox.defaults, options);
661
+ this.$element.on('click', 'li', $.proxy(this.itemclicked, this));
662
+ };
663
+
664
+ Pillbox.prototype = {
665
+ constructor: Pillbox,
666
+
667
+ items: function() {
668
+ return this.$element.find('li').map(function() {
669
+ var $this = $(this);
670
+ return $.extend({ text: $this.text() }, $this.data());
671
+ }).get();
672
+ },
673
+
674
+ itemclicked: function (e) {
675
+ $(e.currentTarget).remove();
676
+ e.preventDefault();
677
+ }
678
+ };
679
+
680
+
681
+ // PILLBOX PLUGIN DEFINITION
682
+
683
+ $.fn.pillbox = function (option) {
684
+ var methodReturn;
685
+
686
+ var $set = this.each(function () {
687
+ var $this = $(this);
688
+ var data = $this.data('pillbox');
689
+ var options = typeof option === 'object' && option;
690
+
691
+ if (!data) $this.data('pillbox', (data = new Pillbox(this, options)));
692
+ if (typeof option === 'string') methodReturn = data[option]();
693
+ });
694
+
695
+ return (methodReturn === undefined) ? $set : methodReturn;
696
+ };
697
+
698
+ $.fn.pillbox.defaults = {};
699
+
700
+ $.fn.pillbox.Constructor = Pillbox;
701
+
702
+
703
+ // PILLBOX DATA-API
704
+
705
+ $(function () {
706
+ $('body').on('mousedown.pillbox.data-api', '.pillbox', function (e) {
707
+ var $this = $(this);
708
+ if ($this.data('pillbox')) return;
709
+ $this.pillbox($this.data());
710
+ });
711
+ });
712
+
713
+ }(window.jQuery);
714
+
715
+
716
+ /*
717
+ * Fuel UX Radio
718
+ * https://github.com/ExactTarget/fuelux
719
+ *
720
+ * Copyright (c) 2012 ExactTarget
721
+ * Licensed under the MIT license.
722
+ */
723
+
724
+ +function ($) { "use strict";
725
+
726
+ // RADIO CONSTRUCTOR AND PROTOTYPE
727
+
728
+ var Radio = function (element, options) {
729
+ this.$element = $(element);
730
+ this.options = $.extend({}, $.fn.radio.defaults, options);
731
+
732
+ // cache elements
733
+ this.$label = this.$element.parent();
734
+ this.$icon = this.$label.find('i');
735
+ this.$radio = this.$label.find('input[type=radio]');
736
+ this.groupName = this.$radio.attr('name');
737
+
738
+ // set default state
739
+ this.setState(this.$radio);
740
+
741
+ // handle events
742
+ this.$radio.on('change', $.proxy(this.itemchecked, this));
743
+ };
744
+
745
+ Radio.prototype = {
746
+
747
+ constructor: Radio,
748
+
749
+ setState: function ($radio, resetGroupState) {
750
+ var checked = $radio.is(':checked');
751
+ var disabled = $radio.is(':disabled');
752
+
753
+ // set state of radio
754
+ if (checked === true) {
755
+ this.$icon.addClass('checked');
756
+ }
757
+ if (disabled === true) {
758
+ this.$icon.addClass('disabled');
759
+ }
760
+ },
761
+
762
+ resetGroup: function () {
763
+ // reset all radio buttons in group
764
+ $('input[name=' + this.groupName + ']').next().removeClass('checked');
765
+ },
766
+
767
+ enable: function () {
768
+ this.$radio.attr('disabled', false);
769
+ this.$icon.removeClass('disabled');
770
+ },
771
+
772
+ disable: function () {
773
+ this.$radio.attr('disabled', true);
774
+ this.$icon.addClass('disabled');
775
+ },
776
+
777
+ itemchecked: function (e) {
778
+ var radio = $(e.target);
779
+
780
+ this.resetGroup();
781
+ this.setState(radio);
782
+ }
783
+ };
784
+
785
+
786
+ // RADIO PLUGIN DEFINITION
787
+
788
+ $.fn.radio = function (option, value) {
789
+ var methodReturn;
790
+
791
+ var $set = this.each(function () {
792
+ var $this = $(this);
793
+ var data = $this.data('radio');
794
+ var options = typeof option === 'object' && option;
795
+
796
+ if (!data) $this.data('radio', (data = new Radio(this, options)));
797
+ if (typeof option === 'string') methodReturn = data[option](value);
798
+ });
799
+
800
+ return (methodReturn === undefined) ? $set : methodReturn;
801
+ };
802
+
803
+ $.fn.radio.defaults = {};
804
+
805
+ $.fn.radio.Constructor = Radio;
806
+
807
+
808
+ // RADIO DATA-API
809
+
810
+ $(function () {
811
+ $(window).on('load', function () {
812
+ //$('i.radio').each(function () {
813
+ $('.radio-custom > input[type=radio]').each(function () {
814
+ var $this = $(this);
815
+ if ($this.data('radio')) return;
816
+ $this.radio($this.data());
817
+ });
818
+ });
819
+ });
820
+
821
+ }(window.jQuery);
822
+
823
+ /*
824
+ * Fuel UX Search
825
+ * https://github.com/ExactTarget/fuelux
826
+ *
827
+ * Copyright (c) 2012 ExactTarget
828
+ * Licensed under the MIT license.
829
+ */
830
+
831
+ +function ($) { "use strict";
832
+
833
+ // SEARCH CONSTRUCTOR AND PROTOTYPE
834
+
835
+ var Search = function (element, options) {
836
+ this.$element = $(element);
837
+ this.options = $.extend({}, $.fn.search.defaults, options);
838
+
839
+ this.$button = this.$element.find('button')
840
+ .on('click', $.proxy(this.buttonclicked, this));
841
+
842
+ this.$input = this.$element.find('input')
843
+ .on('keydown', $.proxy(this.keypress, this))
844
+ .on('keyup', $.proxy(this.keypressed, this));
845
+
846
+ this.$icon = this.$element.find('i');
847
+ this.activeSearch = '';
848
+ };
849
+
850
+ Search.prototype = {
851
+
852
+ constructor: Search,
853
+
854
+ search: function (searchText) {
855
+ this.$icon.attr('class', 'fa fa-times');
856
+ this.activeSearch = searchText;
857
+ this.$element.trigger('searched', searchText);
858
+ },
859
+
860
+ clear: function () {
861
+ this.$icon.attr('class', 'fa fa-search');
862
+ this.activeSearch = '';
863
+ this.$input.val('');
864
+ this.$element.trigger('cleared');
865
+ },
866
+
867
+ action: function () {
868
+ var val = this.$input.val();
869
+ var inputEmptyOrUnchanged = val === '' || val === this.activeSearch;
870
+
871
+ if (this.activeSearch && inputEmptyOrUnchanged) {
872
+ this.clear();
873
+ } else if (val) {
874
+ this.search(val);
875
+ }
876
+ },
877
+
878
+ buttonclicked: function (e) {
879
+ e.preventDefault();
880
+ if ($(e.currentTarget).is('.disabled, :disabled')) return;
881
+ this.action();
882
+ },
883
+
884
+ keypress: function (e) {
885
+ if (e.which === 13) {
886
+ e.preventDefault();
887
+ }
888
+ },
889
+
890
+ keypressed: function (e) {
891
+ var val, inputPresentAndUnchanged;
892
+
893
+ if (e.which === 13) {
894
+ e.preventDefault();
895
+ this.action();
896
+ } else {
897
+ val = this.$input.val();
898
+ inputPresentAndUnchanged = val && (val === this.activeSearch);
899
+ this.$icon.attr('class', inputPresentAndUnchanged ? 'fa fa-times' : 'fa fa-search');
900
+ }
901
+ },
902
+
903
+ disable: function () {
904
+ this.$input.attr('disabled', 'disabled');
905
+ this.$button.addClass('disabled');
906
+ },
907
+
908
+ enable: function () {
909
+ this.$input.removeAttr('disabled');
910
+ this.$button.removeClass('disabled');
911
+ }
912
+
913
+ };
914
+
915
+
916
+ // SEARCH PLUGIN DEFINITION
917
+
918
+ $.fn.search = function (option) {
919
+ return this.each(function () {
920
+ var $this = $(this);
921
+ var data = $this.data('search');
922
+ var options = typeof option === 'object' && option;
923
+
924
+ if (!data) $this.data('search', (data = new Search(this, options)));
925
+ if (typeof option === 'string') data[option]();
926
+ });
927
+ };
928
+
929
+ $.fn.search.defaults = {};
930
+
931
+ $.fn.search.Constructor = Search;
932
+
933
+
934
+ // SEARCH DATA-API
935
+
936
+ $(function () {
937
+ $('body').on('mousedown.search.data-api', '.search', function () {
938
+ var $this = $(this);
939
+ if ($this.data('search')) return;
940
+ $this.search($this.data());
941
+ });
942
+ });
943
+
944
+ }(window.jQuery);
945
+
946
+ /*
947
+ * Fuel UX Spinner
948
+ * https://github.com/ExactTarget/fuelux
949
+ *
950
+ * Copyright (c) 2012 ExactTarget
951
+ * Licensed under the MIT license.
952
+ */
953
+
954
+ +function ($) { "use strict";
955
+
956
+ // SPINNER CONSTRUCTOR AND PROTOTYPE
957
+
958
+ var Spinner = function (element, options) {
959
+ this.$element = $(element);
960
+ this.options = $.extend({}, $.fn.spinner.defaults, options);
961
+ this.$input = this.$element.find('.spinner-input');
962
+ this.$element.on('keyup', this.$input, $.proxy(this.change, this));
963
+
964
+ if (this.options.hold) {
965
+ this.$element.on('mousedown', '.spinner-up', $.proxy(function() { this.startSpin(true); } , this));
966
+ this.$element.on('mouseup', '.spinner-up, .spinner-down', $.proxy(this.stopSpin, this));
967
+ this.$element.on('mouseout', '.spinner-up, .spinner-down', $.proxy(this.stopSpin, this));
968
+ this.$element.on('mousedown', '.spinner-down', $.proxy(function() {this.startSpin(false);} , this));
969
+ } else {
970
+ this.$element.on('click', '.spinner-up', $.proxy(function() { this.step(true); } , this));
971
+ this.$element.on('click', '.spinner-down', $.proxy(function() { this.step(false); }, this));
972
+ }
973
+
974
+ this.switches = {
975
+ count: 1,
976
+ enabled: true
977
+ };
978
+
979
+ if (this.options.speed === 'medium') {
980
+ this.switches.speed = 300;
981
+ } else if (this.options.speed === 'fast') {
982
+ this.switches.speed = 100;
983
+ } else {
984
+ this.switches.speed = 500;
985
+ }
986
+
987
+ this.lastValue = null;
988
+
989
+ this.render();
990
+
991
+ if (this.options.disabled) {
992
+ this.disable();
993
+ }
994
+ };
995
+
996
+ Spinner.prototype = {
997
+ constructor: Spinner,
998
+
999
+ render: function () {
1000
+ this.$input.val(this.options.value);
1001
+ this.$input.attr('maxlength',(this.options.max + '').split('').length);
1002
+ },
1003
+
1004
+ change: function () {
1005
+ var newVal = this.$input.val();
1006
+
1007
+ if(newVal/1){
1008
+ this.options.value = newVal/1;
1009
+ }else{
1010
+ newVal = newVal.replace(/[^0-9]/g,'');
1011
+ this.$input.val(newVal);
1012
+ this.options.value = newVal/1;
1013
+ }
1014
+
1015
+ this.triggerChangedEvent();
1016
+ },
1017
+
1018
+ stopSpin: function () {
1019
+ clearTimeout(this.switches.timeout);
1020
+ this.switches.count = 1;
1021
+ this.triggerChangedEvent();
1022
+ },
1023
+
1024
+ triggerChangedEvent: function () {
1025
+ var currentValue = this.value();
1026
+ if (currentValue === this.lastValue) return;
1027
+
1028
+ this.lastValue = currentValue;
1029
+
1030
+ // Primary changed event
1031
+ this.$element.trigger('changed', currentValue);
1032
+
1033
+ // Undocumented, kept for backward compatibility
1034
+ this.$element.trigger('change');
1035
+ },
1036
+
1037
+ startSpin: function (type) {
1038
+
1039
+ if (!this.options.disabled) {
1040
+ var divisor = this.switches.count;
1041
+
1042
+ if (divisor === 1) {
1043
+ this.step(type);
1044
+ divisor = 1;
1045
+ } else if (divisor < 3){
1046
+ divisor = 1.5;
1047
+ } else if (divisor < 8){
1048
+ divisor = 2.5;
1049
+ } else {
1050
+ divisor = 4;
1051
+ }
1052
+
1053
+ this.switches.timeout = setTimeout($.proxy(function() {this.iterator(type);} ,this),this.switches.speed/divisor);
1054
+ this.switches.count++;
1055
+ }
1056
+ },
1057
+
1058
+ iterator: function (type) {
1059
+ this.step(type);
1060
+ this.startSpin(type);
1061
+ },
1062
+
1063
+ step: function (dir) {
1064
+ var curValue = this.options.value;
1065
+ var limValue = dir ? this.options.max : this.options.min;
1066
+
1067
+ if ((dir ? curValue < limValue : curValue > limValue)) {
1068
+ var newVal = curValue + (dir ? 1 : -1) * this.options.step;
1069
+
1070
+ if (dir ? newVal > limValue : newVal < limValue) {
1071
+ this.value(limValue);
1072
+ } else {
1073
+ this.value(newVal);
1074
+ }
1075
+ }
1076
+ },
1077
+
1078
+ value: function (value) {
1079
+ if (!isNaN(parseFloat(value)) && isFinite(value)) {
1080
+ value = parseFloat(value);
1081
+ this.options.value = value;
1082
+ this.$input.val(value);
1083
+ return this;
1084
+ } else {
1085
+ return this.options.value;
1086
+ }
1087
+ },
1088
+
1089
+ disable: function () {
1090
+ this.options.disabled = true;
1091
+ this.$input.attr('disabled','');
1092
+ this.$element.find('button').addClass('disabled');
1093
+ },
1094
+
1095
+ enable: function () {
1096
+ this.options.disabled = false;
1097
+ this.$input.removeAttr("disabled");
1098
+ this.$element.find('button').removeClass('disabled');
1099
+ }
1100
+ };
1101
+
1102
+
1103
+ // SPINNER PLUGIN DEFINITION
1104
+
1105
+ $.fn.spinner = function (option,value) {
1106
+ var methodReturn;
1107
+
1108
+ var $set = this.each(function () {
1109
+ var $this = $(this);
1110
+ var data = $this.data('spinner');
1111
+ var options = typeof option === 'object' && option;
1112
+
1113
+ if (!data) $this.data('spinner', (data = new Spinner(this, options)));
1114
+ if (typeof option === 'string') methodReturn = data[option](value);
1115
+ });
1116
+
1117
+ return (methodReturn === undefined) ? $set : methodReturn;
1118
+ };
1119
+
1120
+ $.fn.spinner.defaults = {
1121
+ value: 1,
1122
+ min: 1,
1123
+ max: 999,
1124
+ step: 1,
1125
+ hold: true,
1126
+ speed: 'medium',
1127
+ disabled: false
1128
+ };
1129
+
1130
+ $.fn.spinner.Constructor = Spinner;
1131
+
1132
+
1133
+ // SPINNER DATA-API
1134
+
1135
+ $(function () {
1136
+ $('body').on('mousedown.spinner.data-api', '.spinner', function (e) {
1137
+ var $this = $(this);
1138
+ if ($this.data('spinner')) return;
1139
+ $this.spinner($this.data());
1140
+ });
1141
+ });
1142
+
1143
+ }(window.jQuery);
1144
+
1145
+ /*
1146
+ * Fuel UX Select
1147
+ * https://github.com/ExactTarget/fuelux
1148
+ *
1149
+ * Copyright (c) 2012 ExactTarget
1150
+ * Licensed under the MIT license.
1151
+ */
1152
+
1153
+ +function ($) { "use strict";
1154
+
1155
+ // SELECT CONSTRUCTOR AND PROTOTYPE
1156
+
1157
+ var Select = function (element, options) {
1158
+ this.$element = $(element);
1159
+ this.options = $.extend({}, $.fn.select.defaults, options);
1160
+ this.$element.on('click', 'a', $.proxy(this.itemclicked, this));
1161
+ this.$button = this.$element.find('.btn');
1162
+ this.$label = this.$element.find('.dropdown-label');
1163
+ this.setDefaultSelection();
1164
+
1165
+ if (options.resize === 'auto') {
1166
+ this.resize();
1167
+ }
1168
+ };
1169
+
1170
+ Select.prototype = {
1171
+
1172
+ constructor: Select,
1173
+
1174
+ itemclicked: function (e) {
1175
+ this.$selectedItem = $(e.target).parent();
1176
+ this.$label.text(this.$selectedItem.text());
1177
+
1178
+ // pass object including text and any data-attributes
1179
+ // to onchange event
1180
+ var data = this.selectedItem();
1181
+
1182
+ // trigger changed event
1183
+ this.$element.trigger('changed', data);
1184
+
1185
+ e.preventDefault();
1186
+ },
1187
+
1188
+ resize: function() {
1189
+ var el = $('#selectTextSize')[0];
1190
+
1191
+ // create element if it doesn't exist
1192
+ // used to calculate the length of the longest string
1193
+ if(!el) {
1194
+ $('<div/>').attr({id:'selectTextSize'}).appendTo('body');
1195
+ }
1196
+
1197
+ var width = 0;
1198
+ var newWidth = 0;
1199
+
1200
+ // iterate through each item to find longest string
1201
+ this.$element.find('a').each(function () {
1202
+ var $this = $(this);
1203
+ var txt = $this.text();
1204
+ var $txtSize = $('#selectTextSize');
1205
+ $txtSize.text(txt);
1206
+ newWidth = $txtSize.outerWidth();
1207
+ if(newWidth > width) {
1208
+ width = newWidth;
1209
+ }
1210
+ });
1211
+
1212
+ this.$label.width(width);
1213
+ },
1214
+
1215
+ selectedItem: function() {
1216
+ var txt = this.$selectedItem.text();
1217
+ return $.extend({ text: txt }, this.$selectedItem.data());
1218
+ },
1219
+
1220
+ selectByText: function(text) {
1221
+ var selector = 'li a:fuelTextExactCI(' + text + ')';
1222
+ this.selectBySelector(selector);
1223
+ },
1224
+
1225
+ selectByValue: function(value) {
1226
+ var selector = 'li[data-value="' + value + '"]';
1227
+ this.selectBySelector(selector);
1228
+ },
1229
+
1230
+ selectByIndex: function(index) {
1231
+ // zero-based index
1232
+ var selector = 'li:eq(' + index + ')';
1233
+ this.selectBySelector(selector);
1234
+ },
1235
+
1236
+ selectBySelector: function(selector) {
1237
+ var item = this.$element.find(selector);
1238
+
1239
+ this.$selectedItem = item;
1240
+ this.$label.text(this.$selectedItem.text());
1241
+ },
1242
+
1243
+ setDefaultSelection: function() {
1244
+ var selector = 'li[data-selected=true]:first';
1245
+ var item = this.$element.find(selector);
1246
+ if(item.length === 0) {
1247
+ // select first item
1248
+ this.selectByIndex(0);
1249
+ }
1250
+ else {
1251
+ // select by data-attribute
1252
+ this.selectBySelector(selector);
1253
+ item.removeData('selected');
1254
+ item.removeAttr('data-selected');
1255
+ }
1256
+ },
1257
+
1258
+ enable: function() {
1259
+ this.$button.removeClass('disabled');
1260
+ },
1261
+
1262
+ disable: function() {
1263
+ this.$button.addClass('disabled');
1264
+ }
1265
+
1266
+ };
1267
+
1268
+
1269
+ // SELECT PLUGIN DEFINITION
1270
+
1271
+ $.fn.select = function (option,value) {
1272
+ var methodReturn;
1273
+
1274
+ var $set = this.each(function () {
1275
+ var $this = $(this);
1276
+ var data = $this.data('select');
1277
+ var options = typeof option === 'object' && option;
1278
+
1279
+ if (!data) $this.data('select', (data = new Select(this, options)));
1280
+ if (typeof option === 'string') methodReturn = data[option](value);
1281
+ });
1282
+
1283
+ return (methodReturn === undefined) ? $set : methodReturn;
1284
+ };
1285
+
1286
+ $.fn.select.defaults = {};
1287
+
1288
+ $.fn.select.Constructor = Select;
1289
+
1290
+
1291
+ // SELECT DATA-API
1292
+
1293
+ $(function () {
1294
+
1295
+ $(window).on('load', function () {
1296
+ $('.select').each(function () {
1297
+ var $this = $(this);
1298
+ if ($this.data('select')) return;
1299
+ $this.select($this.data());
1300
+ });
1301
+ });
1302
+
1303
+ $('body').on('mousedown.select.data-api', '.select', function (e) {
1304
+ var $this = $(this);
1305
+ if ($this.data('select')) return;
1306
+ $this.select($this.data());
1307
+ });
1308
+ });
1309
+
1310
+ }(window.jQuery);
1311
+
1312
+ /*
1313
+ * Fuel UX Tree
1314
+ * https://github.com/ExactTarget/fuelux
1315
+ *
1316
+ * Copyright (c) 2012 ExactTarget
1317
+ * Licensed under the MIT license.
1318
+ */
1319
+
1320
+ +function ($) { "use strict";
1321
+
1322
+ // TREE CONSTRUCTOR AND PROTOTYPE
1323
+
1324
+ var Tree = function (element, options) {
1325
+ this.$element = $(element);
1326
+ this.options = $.extend({}, $.fn.tree.defaults, options);
1327
+
1328
+ this.$element.on('click', '.tree-item', $.proxy( function(ev) { this.selectItem(ev.currentTarget); } ,this));
1329
+ this.$element.on('click', '.tree-folder-header', $.proxy( function(ev) { this.selectFolder(ev.currentTarget); }, this));
1330
+
1331
+ this.render();
1332
+ };
1333
+
1334
+ Tree.prototype = {
1335
+ constructor: Tree,
1336
+
1337
+ render: function () {
1338
+ this.populate(this.$element);
1339
+ },
1340
+
1341
+ populate: function ($el) {
1342
+ var self = this;
1343
+ var loader = $el.parent().find('.tree-loader:eq(0)');
1344
+
1345
+ loader.show();
1346
+ this.options.dataSource.data($el.data(), function (items) {
1347
+ loader.hide();
1348
+
1349
+ $.each( items.data, function(index, value) {
1350
+ var $entity;
1351
+
1352
+ if(value.type === "folder") {
1353
+ $entity = self.$element.find('.tree-folder:eq(0)').clone().show();
1354
+ $entity.find('.tree-folder-name').html(value.name);
1355
+ $entity.find('.tree-loader').html(self.options.loadingHTML);
1356
+ $entity.find('.tree-folder-header').data(value);
1357
+ } else if (value.type === "item") {
1358
+ $entity = self.$element.find('.tree-item:eq(0)').clone().show();
1359
+ $entity.find('.tree-item-name').html(value.name);
1360
+ $entity.data(value);
1361
+ }
1362
+
1363
+ if($el.hasClass('tree-folder-header')) {
1364
+ $el.parent().find('.tree-folder-content:eq(0)').append($entity);
1365
+ } else {
1366
+ $el.append($entity);
1367
+ }
1368
+ });
1369
+
1370
+ self.$element.trigger('loaded');
1371
+ });
1372
+ },
1373
+
1374
+ selectItem: function (el) {
1375
+ var $el = $(el);
1376
+ var $all = this.$element.find('.tree-selected');
1377
+ var data = [];
1378
+
1379
+ if (this.options.multiSelect) {
1380
+ $.each($all, function(index, value) {
1381
+ var $val = $(value);
1382
+ if($val[0] !== $el[0]) {
1383
+ data.push( $(value).data() );
1384
+ }
1385
+ });
1386
+ } else if ($all[0] !== $el[0]) {
1387
+ $all.removeClass('tree-selected')
1388
+ .find('i').removeClass('icon-ok').addClass('tree-dot');
1389
+ data.push($el.data());
1390
+ }
1391
+
1392
+ if($el.hasClass('tree-selected')) {
1393
+ $el.removeClass('tree-selected');
1394
+ $el.find('i').removeClass('icon-ok').addClass('tree-dot');
1395
+ } else {
1396
+ $el.addClass ('tree-selected');
1397
+ $el.find('i').removeClass('tree-dot').addClass('icon-ok');
1398
+ if (this.options.multiSelect) {
1399
+ data.push( $el.data() );
1400
+ }
1401
+ }
1402
+
1403
+ if(data.length) {
1404
+ this.$element.trigger('selected', {info: data});
1405
+ }
1406
+
1407
+ },
1408
+
1409
+ selectFolder: function (el) {
1410
+ var $el = $(el);
1411
+ var $par = $el.parent();
1412
+
1413
+ if($el.find('.icon-folder-close').length) {
1414
+ if ($par.find('.tree-folder-content').children().length) {
1415
+ $par.find('.tree-folder-content:eq(0)').show();
1416
+ } else {
1417
+ this.populate( $el );
1418
+ }
1419
+
1420
+ $par.find('.icon-folder-close:eq(0)')
1421
+ .removeClass('icon-folder-close')
1422
+ .addClass('icon-folder-open');
1423
+
1424
+ this.$element.trigger('opened', $el.data());
1425
+ } else {
1426
+ if(this.options.cacheItems) {
1427
+ $par.find('.tree-folder-content:eq(0)').hide();
1428
+ } else {
1429
+ $par.find('.tree-folder-content:eq(0)').empty();
1430
+ }
1431
+
1432
+ $par.find('.icon-folder-open:eq(0)')
1433
+ .removeClass('icon-folder-open')
1434
+ .addClass('icon-folder-close');
1435
+
1436
+ this.$element.trigger('closed', $el.data());
1437
+ }
1438
+ },
1439
+
1440
+ selectedItems: function () {
1441
+ var $sel = this.$element.find('.tree-selected');
1442
+ var data = [];
1443
+
1444
+ $.each($sel, function (index, value) {
1445
+ data.push($(value).data());
1446
+ });
1447
+ return data;
1448
+ }
1449
+ };
1450
+
1451
+
1452
+ // TREE PLUGIN DEFINITION
1453
+
1454
+ $.fn.tree = function (option, value) {
1455
+ var methodReturn;
1456
+
1457
+ var $set = this.each(function () {
1458
+ var $this = $(this);
1459
+ var data = $this.data('tree');
1460
+ var options = typeof option === 'object' && option;
1461
+
1462
+ if (!data) $this.data('tree', (data = new Tree(this, options)));
1463
+ if (typeof option === 'string') methodReturn = data[option](value);
1464
+ });
1465
+
1466
+ return (methodReturn === undefined) ? $set : methodReturn;
1467
+ };
1468
+
1469
+ $.fn.tree.defaults = {
1470
+ multiSelect: false,
1471
+ loadingHTML: '<div>Loading...</div>',
1472
+ cacheItems: true
1473
+ };
1474
+
1475
+ $.fn.tree.Constructor = Tree;
1476
+
1477
+ }(window.jQuery);
1478
+
1479
+ /*
1480
+ * Fuel UX Wizard
1481
+ * https://github.com/ExactTarget/fuelux
1482
+ *
1483
+ * Copyright (c) 2012 ExactTarget
1484
+ * Licensed under the MIT license.
1485
+ */
1486
+
1487
+ +function ($) { "use strict";
1488
+
1489
+ // WIZARD CONSTRUCTOR AND PROTOTYPE
1490
+
1491
+ var Wizard = function (element, options) {
1492
+ var kids;
1493
+
1494
+ this.$element = $(element);
1495
+ this.options = $.extend({}, $.fn.wizard.defaults, options);
1496
+ this.currentStep = 1;
1497
+ this.numSteps = this.$element.find('li').length;
1498
+ this.$prevBtn = this.$element.find('button.btn-prev');
1499
+ this.$nextBtn = this.$element.find('button.btn-next');
1500
+
1501
+ kids = this.$nextBtn.children().detach();
1502
+ this.nextText = $.trim(this.$nextBtn.text());
1503
+ this.$nextBtn.append(kids);
1504
+
1505
+ // handle events
1506
+ this.$prevBtn.on('click', $.proxy(this.previous, this));
1507
+ this.$nextBtn.on('click', $.proxy(this.next, this));
1508
+ this.$element.on('click', 'li.complete', $.proxy(this.stepclicked, this));
1509
+ };
1510
+
1511
+ Wizard.prototype = {
1512
+
1513
+ constructor: Wizard,
1514
+
1515
+ setState: function () {
1516
+ var canMovePrev = (this.currentStep > 1);
1517
+ var firstStep = (this.currentStep === 1);
1518
+ var lastStep = (this.currentStep === this.numSteps);
1519
+
1520
+ // disable buttons based on current step
1521
+ this.$prevBtn.attr('disabled', (firstStep === true || canMovePrev === false));
1522
+
1523
+ // change button text of last step, if specified
1524
+ var data = this.$nextBtn.data();
1525
+ if (data && data.last) {
1526
+ this.lastText = data.last;
1527
+ if (typeof this.lastText !== 'undefined') {
1528
+ // replace text
1529
+ var text = (lastStep !== true) ? this.nextText : this.lastText;
1530
+ var kids = this.$nextBtn.children().detach();
1531
+ this.$nextBtn.text(text).append(kids);
1532
+ }
1533
+ }
1534
+
1535
+ // reset classes for all steps
1536
+ var $steps = this.$element.find('li');
1537
+ $steps.removeClass('active').removeClass('complete');
1538
+ $steps.find('span.badge').removeClass('badge-info').removeClass('badge-success');
1539
+
1540
+ // set class for all previous steps
1541
+ var prevSelector = 'li:lt(' + (this.currentStep - 1) + ')';
1542
+ var $prevSteps = this.$element.find(prevSelector);
1543
+ $prevSteps.addClass('complete');
1544
+ $prevSteps.find('span.badge').addClass('badge-success');
1545
+
1546
+ // set class for current step
1547
+ var currentSelector = 'li:eq(' + (this.currentStep - 1) + ')';
1548
+ var $currentStep = this.$element.find(currentSelector);
1549
+ $currentStep.addClass('active');
1550
+ $currentStep.find('span.badge').addClass('badge-info');
1551
+
1552
+ // set display of target element
1553
+ var target = $currentStep.data().target;
1554
+ // Dillon changed for support multi wizard
1555
+ $('.step-pane', $(target).parent()).removeClass('active');
1556
+ $(target).addClass('active');
1557
+
1558
+ this.$element.trigger('changed');
1559
+ },
1560
+
1561
+ stepclicked: function (e) {
1562
+ var li = $(e.currentTarget);
1563
+
1564
+ // Dillon changed for support multi wizard
1565
+ var index = li.parent().find('li').index(li);
1566
+
1567
+ var evt = $.Event('stepclick');
1568
+ this.$element.trigger(evt, {step: index + 1});
1569
+ if (evt.isDefaultPrevented()) return;
1570
+
1571
+ this.currentStep = (index + 1);
1572
+ this.setState();
1573
+ },
1574
+
1575
+ previous: function () {
1576
+ var canMovePrev = (this.currentStep > 1);
1577
+ if (canMovePrev) {
1578
+ var e = $.Event('change');
1579
+ this.$element.trigger(e, {step: this.currentStep, direction: 'previous'});
1580
+ if (e.isDefaultPrevented()) return;
1581
+
1582
+ this.currentStep -= 1;
1583
+ this.setState();
1584
+ }
1585
+ },
1586
+
1587
+ next: function () {
1588
+ var canMoveNext = (this.currentStep + 1 <= this.numSteps);
1589
+ var lastStep = (this.currentStep === this.numSteps);
1590
+
1591
+ if (canMoveNext) {
1592
+ var e = $.Event('change');
1593
+ this.$element.trigger(e, {step: this.currentStep, direction: 'next'});
1594
+
1595
+ if (e.isDefaultPrevented()) return;
1596
+
1597
+ this.currentStep += 1;
1598
+ this.setState();
1599
+ }
1600
+ else if (lastStep) {
1601
+ this.$element.trigger('finished');
1602
+ }
1603
+ },
1604
+
1605
+ selectedItem: function (val) {
1606
+ return {
1607
+ step: this.currentStep
1608
+ };
1609
+ }
1610
+ };
1611
+
1612
+
1613
+ // WIZARD PLUGIN DEFINITION
1614
+
1615
+ $.fn.wizard = function (option, value) {
1616
+ var methodReturn;
1617
+
1618
+ var $set = this.each(function () {
1619
+ var $this = $(this);
1620
+ var data = $this.data('wizard');
1621
+ var options = typeof option === 'object' && option;
1622
+
1623
+ if (!data) $this.data('wizard', (data = new Wizard(this, options)));
1624
+ if (typeof option === 'string') methodReturn = data[option](value);
1625
+ });
1626
+
1627
+ return (methodReturn === undefined) ? $set : methodReturn;
1628
+ };
1629
+
1630
+ $.fn.wizard.defaults = {};
1631
+
1632
+ $.fn.wizard.Constructor = Wizard;
1633
+
1634
+
1635
+ // WIZARD DATA-API
1636
+
1637
+ $(function () {
1638
+ $('body').on('mousedown.wizard.data-api', '.wizard', function () {
1639
+ var $this = $(this);
1640
+ if ($this.data('wizard')) return;
1641
+ $this.wizard($this.data());
1642
+ });
1643
+ });
1644
+
1645
+ }(window.jQuery);