knitkit 2.1.15 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +7 -0
  2. data/app/controllers/knitkit/base_controller.rb +1 -1
  3. data/app/controllers/knitkit/comments_controller.rb +7 -2
  4. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +78 -98
  5. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +65 -45
  6. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +22 -12
  7. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +1 -1
  8. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +28 -16
  9. data/app/controllers/knitkit/erp_app/desktop/inquiries_controller.rb +15 -49
  10. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +4 -3
  11. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +69 -11
  12. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +63 -60
  13. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +98 -82
  14. data/app/controllers/knitkit/erp_app/desktop/website_host_controller.rb +77 -0
  15. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +64 -44
  16. data/app/controllers/knitkit/erp_app/desktop/website_nav_item_controller.rb +147 -0
  17. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +81 -45
  18. data/app/controllers/knitkit/mobile_controller.rb +15 -0
  19. data/app/controllers/knitkit/online_document_sections_controller.rb +2 -1
  20. data/app/controllers/knitkit/unauthorized_controller.rb +0 -1
  21. data/app/controllers/knitkit/website_sections_controller.rb +7 -4
  22. data/app/mailers/website_inquiry_mailer.rb +8 -7
  23. data/app/models/content.rb +11 -2
  24. data/app/models/document.rb +2 -17
  25. data/app/models/published_website.rb +96 -59
  26. data/app/models/theme.rb +100 -14
  27. data/app/models/website.rb +260 -28
  28. data/app/models/website_inquiry.rb +5 -12
  29. data/app/models/website_section.rb +9 -1
  30. data/app/views/knitkit/blogs/_add_comment.html.erb +44 -23
  31. data/app/views/knitkit/blogs/_comment.html.erb +4 -6
  32. data/app/views/knitkit/blogs/index.html.erb +63 -49
  33. data/app/views/knitkit/blogs/show.html.erb +17 -12
  34. data/app/views/knitkit/mobile/index.html.erb +162 -0
  35. data/app/views/knitkit/online_document_sections/index.html.erb +7 -5
  36. data/app/views/knitkit/unauthorized/index.html.erb +8 -4
  37. data/app/views/knitkit/website_sections/index.html.erb +8 -4
  38. data/app/views/layouts/knitkit/base.html.erb +79 -63
  39. data/app/views/layouts/knitkit/online_document_sections.html.erb +74 -52
  40. data/app/views/menus/knitkit/_default_menu.html.erb +4 -4
  41. data/app/views/menus/knitkit/_default_section_menu.html.erb +22 -23
  42. data/app/views/shared/knitkit/_bread_crumb.html.erb +10 -7
  43. data/app/views/shared/knitkit/_footer.html.erb +2 -2
  44. data/app/views/website_inquiry_mailer/inquiry.erb +23 -2
  45. data/app/widgets/contact_us/base.rb +25 -50
  46. data/app/widgets/contact_us/javascript/contact_us.js +7 -7
  47. data/app/widgets/contact_us/views/error.html.erb +6 -8
  48. data/app/widgets/contact_us/views/index.html.erb +28 -1
  49. data/app/widgets/contact_us/views/layouts/base.html.erb +9 -6
  50. data/app/widgets/contact_us/views/success.html.erb +3 -3
  51. data/app/widgets/google_map/views/index.html.erb +36 -36
  52. data/app/widgets/login/base.rb +1 -0
  53. data/app/widgets/login/javascript/login.js +3 -3
  54. data/app/widgets/login/views/index.html.erb +46 -26
  55. data/app/widgets/login/views/layouts/base.html.erb +15 -13
  56. data/app/widgets/login/views/login_header.html.erb +7 -9
  57. data/app/widgets/manage_profile/base.rb +116 -164
  58. data/app/widgets/manage_profile/views/_address.html.erb +184 -0
  59. data/app/widgets/manage_profile/views/_contact_information_form.html.erb +23 -192
  60. data/app/widgets/manage_profile/views/_email_address.html.erb +163 -0
  61. data/app/widgets/manage_profile/views/_password_form.html.erb +23 -20
  62. data/app/widgets/manage_profile/views/_phone_number.html.erb +165 -0
  63. data/app/widgets/manage_profile/views/_user_information_form.html.erb +49 -33
  64. data/app/widgets/manage_profile/views/error.html.erb +6 -0
  65. data/app/widgets/manage_profile/views/index.html.erb +44 -46
  66. data/app/widgets/manage_profile/views/layouts/base.html.erb +3 -1
  67. data/app/widgets/manage_profile/views/success.html.erb +5 -0
  68. data/app/widgets/reset_password/views/index.html.erb +33 -28
  69. data/app/widgets/reset_password/views/layouts/base.html.erb +10 -1
  70. data/app/widgets/search/base.rb +37 -25
  71. data/app/widgets/search/views/_inline_search_form.html.erb +12 -0
  72. data/app/widgets/search/views/_search_form.html.erb +41 -0
  73. data/app/widgets/search/views/index.html.erb +5 -3
  74. data/app/widgets/search/views/layouts/base.html.erb +13 -23
  75. data/app/widgets/search/views/show.html.erb +32 -47
  76. data/app/widgets/signup/base.rb +1 -1
  77. data/app/widgets/signup/javascript/signup.js +7 -9
  78. data/app/widgets/signup/views/_signup_form.html.erb +34 -29
  79. data/app/widgets/signup/views/error.html.erb +11 -11
  80. data/app/widgets/signup/views/index.html.erb +3 -2
  81. data/app/widgets/signup/views/layouts/base.html.erb +8 -5
  82. data/app/widgets/signup/views/success.html.erb +5 -4
  83. data/config/routes.rb +39 -28
  84. data/db/data_migrations/20120809020508_update_website_and_configuration.rb +3 -0
  85. data/db/migrate/20110211002317_setup_knitkit.rb +0 -1
  86. data/db/migrate/20131112013052_add_knitkit_missing_indexes.rb +33 -0
  87. data/db/migrate/20140622212723_update_website_inquiries.rb +22 -0
  88. data/db/migrate/20140911185022_add_publishing_to_website.rb +5 -0
  89. data/db/migrate/20141013073349_add_custom_fields_to_documents.rb +12 -0
  90. data/db/migrate/20141016101936_upgrade_remove_dynamic_attributes.rb +13 -0
  91. data/lib/knitkit.rb +0 -1
  92. data/lib/knitkit/engine.rb +1 -0
  93. data/lib/knitkit/extensions.rb +4 -0
  94. data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +33 -0
  95. data/lib/knitkit/extensions/active_record/acts_as_document.rb +0 -12
  96. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +7 -10
  97. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +2 -4
  98. data/lib/knitkit/extensions/compass_ae/widgets/widget_proxy_controller.rb +4 -1
  99. data/lib/knitkit/extensions/railties/action_view/helpers/blog_helper.rb +16 -13
  100. data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +10 -8
  101. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +123 -108
  102. data/lib/knitkit/extensions/will_paginate/link_renderer.rb +67 -0
  103. data/lib/knitkit/routing_filter/section_router.rb +10 -8
  104. data/lib/knitkit/syntax_validator.rb +2 -2
  105. data/lib/knitkit/version.rb +7 -3
  106. data/public/images/inline_edit/close.png +0 -0
  107. data/public/images/knitkit/close_window.png +0 -0
  108. data/public/images/knitkit/logo.png +0 -0
  109. data/public/images/knitkit/splash/images/add-site.png +0 -0
  110. data/public/images/knitkit/splash/images/adjust-site.png +0 -0
  111. data/public/images/knitkit/splash/images/browse-site.png +0 -0
  112. data/public/images/knitkit/splash/images/find-themes.png +0 -0
  113. data/public/images/knitkit/splash/images/settings.png +0 -0
  114. data/public/images/knitkit/splash/images/tutorials.png +0 -0
  115. data/public/images/knitkit/splash/splash.png +0 -0
  116. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +656 -627
  117. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +444 -333
  118. data/public/javascripts/erp_app/desktop/applications/knitkit/{east_region.js → east_region/east_region.js} +33 -33
  119. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/file_assets_panel.js +332 -0
  120. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_data_view.js +144 -0
  121. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_panel.js +335 -0
  122. data/public/javascripts/erp_app/desktop/applications/knitkit/{widgets_panel.js → east_region/widgets_panel.js} +55 -55
  123. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +150 -37
  124. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +228 -96
  125. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +89 -85
  126. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +238 -217
  127. data/public/javascripts/erp_app/desktop/applications/knitkit/select_roles_window.js +59 -54
  128. data/public/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +170 -0
  129. data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/main_menu.js +1168 -0
  130. data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/websites_combo.js +71 -0
  131. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +301 -306
  132. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/article.js +216 -0
  133. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +182 -153
  134. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +48 -65
  135. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +93 -94
  136. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +523 -197
  137. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +20 -34
  138. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/hosts_tree_panel.js +74 -0
  139. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/menu_tree_panel.js +245 -0
  140. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/site_contents_tree_panel.js +360 -0
  141. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/themes_tree_panel.js +348 -0
  142. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +106 -1132
  143. data/public/javascripts/knitkit/bootstrap-datepicker.js +474 -0
  144. data/public/javascripts/knitkit/bootstrap.min.js +7 -0
  145. data/public/javascripts/knitkit/confirm-bootstrap.js +110 -0
  146. data/public/javascripts/knitkit/inline_editing.js +73 -50
  147. data/public/javascripts/knitkit/jquery.maskedinput.min.js +7 -0
  148. data/public/javascripts/knitkit/mobile/app/view/Main.js +108 -0
  149. data/public/javascripts/knitkit/mobile/ux/slidenavigation/View.js +734 -0
  150. data/public/javascripts/knitkit/theme.js +76 -0
  151. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +95 -35
  152. data/public/stylesheets/knitkit/bootstrap-responsive.min.css +10 -0
  153. data/public/stylesheets/knitkit/bootstrap.min.css +7 -0
  154. data/public/stylesheets/knitkit/custom.css +122 -0
  155. data/public/stylesheets/knitkit/datepicker.css +182 -0
  156. data/public/stylesheets/knitkit/inline_editing.css +58 -58
  157. data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +1 -1
  158. data/spec/dummy/config/application.rb +1 -1
  159. data/spec/models/article_spec.rb +3 -3
  160. data/spec/models/content_spec.rb +9 -9
  161. data/spec/models/website_spec.rb +1 -1
  162. metadata +100 -114
  163. data/app/helpers/application_helper.rb +0 -134
  164. data/app/views/knitkit/articles/index.html.erb +0 -3
  165. data/app/views/knitkit/articles/show.html.erb +0 -4
  166. data/app/views/menus/knitkit/_default_sub_menu.html.erb +0 -43
  167. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +0 -47
  168. data/app/widgets/contact_us/views/_contact_form.html.erb +0 -36
  169. data/app/widgets/dynamic_forms/base.rb +0 -139
  170. data/app/widgets/dynamic_forms/javascript/dynamic_forms.js +0 -110
  171. data/app/widgets/dynamic_forms/views/error.html.erb +0 -5
  172. data/app/widgets/dynamic_forms/views/index.html.erb +0 -8
  173. data/app/widgets/dynamic_forms/views/success.html.erb +0 -4
  174. data/app/widgets/dynamic_grid/base.rb +0 -130
  175. data/app/widgets/dynamic_grid/helpers/controller/dynamic_grid_controller_helper.rb +0 -3
  176. data/app/widgets/dynamic_grid/helpers/view/dynamic_grid_view_helper.rb +0 -3
  177. data/app/widgets/dynamic_grid/javascript/dynamic_grid.js +0 -177
  178. data/app/widgets/dynamic_grid/views/index.html.erb +0 -14
  179. data/app/widgets/login/views/reset_password.html.erb +0 -26
  180. data/app/widgets/manage_profile/views/default_type_error.html.erb +0 -5
  181. data/app/widgets/scaffold/base.rb +0 -87
  182. data/app/widgets/scaffold/helpers/controller/scaffold_controller_helper.rb +0 -3
  183. data/app/widgets/scaffold/helpers/view/scaffold_view_helper.rb +0 -3
  184. data/app/widgets/scaffold/javascript/scaffold.js +0 -337
  185. data/app/widgets/scaffold/views/index.html.erb +0 -15
  186. data/app/widgets/search/views/_search.html.erb +0 -39
  187. data/public/images/knitkit/bullet.png +0 -0
  188. data/public/images/knitkit/close.png +0 -0
  189. data/public/images/knitkit/content.png +0 -0
  190. data/public/images/knitkit/footer.png +0 -0
  191. data/public/images/knitkit/graphic.png +0 -0
  192. data/public/images/knitkit/greyFadeDown.png +0 -0
  193. data/public/images/knitkit/link.png +0 -0
  194. data/public/images/knitkit/menu.png +0 -0
  195. data/public/images/knitkit/menu_select.png +0 -0
  196. data/public/images/knitkit/search.png +0 -0
  197. data/public/images/knitkit/tooltip.gif +0 -0
  198. data/public/javascripts/ajax_pagination.js +0 -33
  199. data/public/javascripts/datepicker.js +0 -445
  200. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +0 -341
  201. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +0 -31
  202. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +0 -263
  203. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +0 -722
  204. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +0 -585
  205. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website.js +0 -155
  206. data/public/javascripts/knitkit/helpers.js +0 -26
  207. data/public/stylesheets/datepicker.css +0 -121
  208. data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +0 -233
  209. data/public/stylesheets/knitkit/style.css +0 -426
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Bootstrap v3.0.3 (http://getbootstrap.com)
3
+ * Copyright 2013 Twitter, Inc.
4
+ * Licensed under http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+
7
+ if("undefined"==typeof jQuery)throw new Error("Bootstrap requires jQuery");+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]}}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one(a.support.transition.end,function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b()})}(jQuery),+function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function c(){f.trigger("closed.bs.alert").remove()}var d=a(this),e=d.attr("data-target");e||(e=d.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,""));var f=a(e);b&&b.preventDefault(),f.length||(f=d.hasClass("alert")?d:d.parent()),f.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.one(a.support.transition.end,c).emulateTransitionEnd(150):c())};var d=a.fn.alert;a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("bs.alert");e||d.data("bs.alert",e=new c(this)),"string"==typeof b&&e[b].call(d)})},a.fn.alert.Constructor=c,a.fn.alert.noConflict=function(){return a.fn.alert=d,this},a(document).on("click.bs.alert.data-api",b,c.prototype.close)}(jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d)};b.DEFAULTS={loadingText:"loading..."},b.prototype.setState=function(a){var b="disabled",c=this.$element,d=c.is("input")?"val":"html",e=c.data();a+="Text",e.resetText||c.data("resetText",c[d]()),c[d](e[a]||this.options[a]),setTimeout(function(){"loadingText"==a?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},b.prototype.toggle=function(){var a=this.$element.closest('[data-toggle="buttons"]'),b=!0;if(a.length){var c=this.$element.find("input");"radio"===c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?b=!1:a.find(".active").removeClass("active")),b&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}b&&this.$element.toggleClass("active")};var c=a.fn.button;a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof c&&c;e||d.data("bs.button",e=new b(this,f)),"toggle"==c?e.toggle():c&&e.setState(c)})},a.fn.button.Constructor=b,a.fn.button.noConflict=function(){return a.fn.button=c,this},a(document).on("click.bs.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle"),b.preventDefault()})}(jQuery),+function(a){"use strict";var b=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter",a.proxy(this.pause,this)).on("mouseleave",a.proxy(this.cycle,this))};b.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},b.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},b.prototype.getActiveIndex=function(){return this.$active=this.$element.find(".item.active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},b.prototype.to=function(b){var c=this,d=this.getActiveIndex();return b>this.$items.length-1||0>b?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){c.to(b)}):d==b?this.pause().cycle():this.slide(b>d?"next":"prev",a(this.$items[b]))},b.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition.end&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},b.prototype.next=function(){return this.sliding?void 0:this.slide("next")},b.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},b.prototype.slide=function(b,c){var d=this.$element.find(".item.active"),e=c||d[b](),f=this.interval,g="next"==b?"left":"right",h="next"==b?"first":"last",i=this;if(!e.length){if(!this.options.wrap)return;e=this.$element.find(".item")[h]()}this.sliding=!0,f&&this.pause();var j=a.Event("slide.bs.carousel",{relatedTarget:e[0],direction:g});if(!e.hasClass("active")){if(this.$indicators.length&&(this.$indicators.find(".active").removeClass("active"),this.$element.one("slid.bs.carousel",function(){var b=a(i.$indicators.children()[i.getActiveIndex()]);b&&b.addClass("active")})),a.support.transition&&this.$element.hasClass("slide")){if(this.$element.trigger(j),j.isDefaultPrevented())return;e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),d.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid.bs.carousel")},0)}).emulateTransitionEnd(600)}else{if(this.$element.trigger(j),j.isDefaultPrevented())return;d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid.bs.carousel")}return f&&this.cycle(),this}};var c=a.fn.carousel;a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c),g="string"==typeof c?c:f.slide;e||d.data("bs.carousel",e=new b(this,f)),"number"==typeof c?e.to(c):g?e[g]():f.interval&&e.pause().cycle()})},a.fn.carousel.Constructor=b,a.fn.carousel.noConflict=function(){return a.fn.carousel=c,this},a(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",function(b){var c,d=a(this),e=a(d.attr("data-target")||(c=d.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"")),f=a.extend({},e.data(),d.data()),g=d.attr("data-slide-to");g&&(f.interval=!1),e.carousel(f),(g=d.attr("data-slide-to"))&&e.data("bs.carousel").to(g),b.preventDefault()}),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var b=a(this);b.carousel(b.data())})})}(jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d),this.transitioning=null,this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.DEFAULTS={toggle:!0},b.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},b.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b=a.Event("show.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.$parent&&this.$parent.find("> .panel > .in");if(c&&c.length){var d=c.data("bs.collapse");if(d&&d.transitioning)return;c.collapse("hide"),d||c.data("bs.collapse",null)}var e=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[e](0),this.transitioning=1;var f=function(){this.$element.removeClass("collapsing").addClass("in")[e]("auto"),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return f.call(this);var g=a.camelCase(["scroll",e].join("-"));this.$element.one(a.support.transition.end,a.proxy(f,this)).emulateTransitionEnd(350)[e](this.$element[0][g])}}},b.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var d=function(){this.transitioning=0,this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse")};return a.support.transition?(this.$element[c](0).one(a.support.transition.end,a.proxy(d,this)).emulateTransitionEnd(350),void 0):d.call(this)}}},b.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var c=a.fn.collapse;a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("bs.collapse"),f=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c);e||d.data("bs.collapse",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.collapse.Constructor=b,a.fn.collapse.noConflict=function(){return a.fn.collapse=c,this},a(document).on("click.bs.collapse.data-api","[data-toggle=collapse]",function(b){var c,d=a(this),e=d.attr("data-target")||b.preventDefault()||(c=d.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,""),f=a(e),g=f.data("bs.collapse"),h=g?"toggle":d.data(),i=d.attr("data-parent"),j=i&&a(i);g&&g.transitioning||(j&&j.find('[data-toggle=collapse][data-parent="'+i+'"]').not(d).addClass("collapsed"),d[f.hasClass("in")?"addClass":"removeClass"]("collapsed")),f.collapse(h)})}(jQuery),+function(a){"use strict";function b(){a(d).remove(),a(e).each(function(b){var d=c(a(this));d.hasClass("open")&&(d.trigger(b=a.Event("hide.bs.dropdown")),b.isDefaultPrevented()||d.removeClass("open").trigger("hidden.bs.dropdown"))})}function c(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}var d=".dropdown-backdrop",e="[data-toggle=dropdown]",f=function(b){a(b).on("click.bs.dropdown",this.toggle)};f.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=c(e),g=f.hasClass("open");if(b(),!g){if("ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a('<div class="dropdown-backdrop"/>').insertAfter(a(this)).on("click",b),f.trigger(d=a.Event("show.bs.dropdown")),d.isDefaultPrevented())return;f.toggleClass("open").trigger("shown.bs.dropdown"),e.focus()}return!1}},f.prototype.keydown=function(b){if(/(38|40|27)/.test(b.keyCode)){var d=a(this);if(b.preventDefault(),b.stopPropagation(),!d.is(".disabled, :disabled")){var f=c(d),g=f.hasClass("open");if(!g||g&&27==b.keyCode)return 27==b.which&&f.find(e).focus(),d.click();var h=a("[role=menu] li:not(.divider):visible a",f);if(h.length){var i=h.index(h.filter(":focus"));38==b.keyCode&&i>0&&i--,40==b.keyCode&&i<h.length-1&&i++,~i||(i=0),h.eq(i).focus()}}}};var g=a.fn.dropdown;a.fn.dropdown=function(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new f(this)),"string"==typeof b&&d[b].call(c)})},a.fn.dropdown.Constructor=f,a.fn.dropdown.noConflict=function(){return a.fn.dropdown=g,this},a(document).on("click.bs.dropdown.data-api",b).on("click.bs.dropdown.data-api",".dropdown form",function(a){a.stopPropagation()}).on("click.bs.dropdown.data-api",e,f.prototype.toggle).on("keydown.bs.dropdown.data-api",e+", [role=menu]",f.prototype.keydown)}(jQuery),+function(a){"use strict";var b=function(b,c){this.options=c,this.$element=a(b),this.$backdrop=this.isShown=null,this.options.remote&&this.$element.load(this.options.remote)};b.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},b.prototype.toggle=function(a){return this[this.isShown?"hide":"show"](a)},b.prototype.show=function(b){var c=this,d=a.Event("show.bs.modal",{relatedTarget:b});this.$element.trigger(d),this.isShown||d.isDefaultPrevented()||(this.isShown=!0,this.escape(),this.$element.on("click.dismiss.modal",'[data-dismiss="modal"]',a.proxy(this.hide,this)),this.backdrop(function(){var d=a.support.transition&&c.$element.hasClass("fade");c.$element.parent().length||c.$element.appendTo(document.body),c.$element.show(),d&&c.$element[0].offsetWidth,c.$element.addClass("in").attr("aria-hidden",!1),c.enforceFocus();var e=a.Event("shown.bs.modal",{relatedTarget:b});d?c.$element.find(".modal-dialog").one(a.support.transition.end,function(){c.$element.focus().trigger(e)}).emulateTransitionEnd(300):c.$element.focus().trigger(e)}))},b.prototype.hide=function(b){b&&b.preventDefault(),b=a.Event("hide.bs.modal"),this.$element.trigger(b),this.isShown&&!b.isDefaultPrevented()&&(this.isShown=!1,this.escape(),a(document).off("focusin.bs.modal"),this.$element.removeClass("in").attr("aria-hidden",!0).off("click.dismiss.modal"),a.support.transition&&this.$element.hasClass("fade")?this.$element.one(a.support.transition.end,a.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal())},b.prototype.enforceFocus=function(){a(document).off("focusin.bs.modal").on("focusin.bs.modal",a.proxy(function(a){this.$element[0]===a.target||this.$element.has(a.target).length||this.$element.focus()},this))},b.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.bs.modal",a.proxy(function(a){27==a.which&&this.hide()},this)):this.isShown||this.$element.off("keyup.dismiss.bs.modal")},b.prototype.hideModal=function(){var a=this;this.$element.hide(),this.backdrop(function(){a.removeBackdrop(),a.$element.trigger("hidden.bs.modal")})},b.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},b.prototype.backdrop=function(b){var c=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var d=a.support.transition&&c;if(this.$backdrop=a('<div class="modal-backdrop '+c+'" />').appendTo(document.body),this.$element.on("click.dismiss.modal",a.proxy(function(a){a.target===a.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus.call(this.$element[0]):this.hide.call(this))},this)),d&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!b)return;d?this.$backdrop.one(a.support.transition.end,b).emulateTransitionEnd(150):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,b).emulateTransitionEnd(150):b()):b&&b()};var c=a.fn.modal;a.fn.modal=function(c,d){return this.each(function(){var e=a(this),f=e.data("bs.modal"),g=a.extend({},b.DEFAULTS,e.data(),"object"==typeof c&&c);f||e.data("bs.modal",f=new b(this,g)),"string"==typeof c?f[c](d):g.show&&f.show(d)})},a.fn.modal.Constructor=b,a.fn.modal.noConflict=function(){return a.fn.modal=c,this},a(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d=c.attr("href"),e=a(c.attr("data-target")||d&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({remote:!/#/.test(d)&&d},e.data(),c.data());b.preventDefault(),e.modal(f,this).one("hide",function(){c.is(":visible")&&c.focus()})}),a(document).on("show.bs.modal",".modal",function(){a(document.body).addClass("modal-open")}).on("hidden.bs.modal",".modal",function(){a(document.body).removeClass("modal-open")})}(jQuery),+function(a){"use strict";var b=function(a,b){this.type=this.options=this.enabled=this.timeout=this.hoverState=this.$element=null,this.init("tooltip",a,b)};b.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1},b.prototype.init=function(b,c,d){this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d);for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focus",i="hover"==g?"mouseleave":"blur";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},b.prototype.getDefaults=function(){return b.DEFAULTS},b.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},b.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},b.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type);return clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show),void 0):c.show()},b.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type);return clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide),void 0):c.hide()},b.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){if(this.$element.trigger(b),b.isDefaultPrevented())return;var c=this.tip();this.setContent(),this.options.animation&&c.addClass("fade");var d="function"==typeof this.options.placement?this.options.placement.call(this,c[0],this.$element[0]):this.options.placement,e=/\s?auto?\s?/i,f=e.test(d);f&&(d=d.replace(e,"")||"top"),c.detach().css({top:0,left:0,display:"block"}).addClass(d),this.options.container?c.appendTo(this.options.container):c.insertAfter(this.$element);var g=this.getPosition(),h=c[0].offsetWidth,i=c[0].offsetHeight;if(f){var j=this.$element.parent(),k=d,l=document.documentElement.scrollTop||document.body.scrollTop,m="body"==this.options.container?window.innerWidth:j.outerWidth(),n="body"==this.options.container?window.innerHeight:j.outerHeight(),o="body"==this.options.container?0:j.offset().left;d="bottom"==d&&g.top+g.height+i-l>n?"top":"top"==d&&g.top-l-i<0?"bottom":"right"==d&&g.right+h>m?"left":"left"==d&&g.left-h<o?"right":d,c.removeClass(k).addClass(d)}var p=this.getCalculatedOffset(d,g,h,i);this.applyPlacement(p,d),this.$element.trigger("shown.bs."+this.type)}},b.prototype.applyPlacement=function(a,b){var c,d=this.tip(),e=d[0].offsetWidth,f=d[0].offsetHeight,g=parseInt(d.css("margin-top"),10),h=parseInt(d.css("margin-left"),10);isNaN(g)&&(g=0),isNaN(h)&&(h=0),a.top=a.top+g,a.left=a.left+h,d.offset(a).addClass("in");var i=d[0].offsetWidth,j=d[0].offsetHeight;if("top"==b&&j!=f&&(c=!0,a.top=a.top+f-j),/bottom|top/.test(b)){var k=0;a.left<0&&(k=-2*a.left,a.left=0,d.offset(a),i=d[0].offsetWidth,j=d[0].offsetHeight),this.replaceArrow(k-e+i,i,"left")}else this.replaceArrow(j-f,j,"top");c&&d.offset(a)},b.prototype.replaceArrow=function(a,b,c){this.arrow().css(c,a?50*(1-a/b)+"%":"")},b.prototype.setContent=function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},b.prototype.hide=function(){function b(){"in"!=c.hoverState&&d.detach()}var c=this,d=this.tip(),e=a.Event("hide.bs."+this.type);return this.$element.trigger(e),e.isDefaultPrevented()?void 0:(d.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?d.one(a.support.transition.end,b).emulateTransitionEnd(150):b(),this.$element.trigger("hidden.bs."+this.type),this)},b.prototype.fixTitle=function(){var a=this.$element;(a.attr("title")||"string"!=typeof a.attr("data-original-title"))&&a.attr("data-original-title",a.attr("title")||"").attr("title","")},b.prototype.hasContent=function(){return this.getTitle()},b.prototype.getPosition=function(){var b=this.$element[0];return a.extend({},"function"==typeof b.getBoundingClientRect?b.getBoundingClientRect():{width:b.offsetWidth,height:b.offsetHeight},this.$element.offset())},b.prototype.getCalculatedOffset=function(a,b,c,d){return"bottom"==a?{top:b.top+b.height,left:b.left+b.width/2-c/2}:"top"==a?{top:b.top-d,left:b.left+b.width/2-c/2}:"left"==a?{top:b.top+b.height/2-d/2,left:b.left-c}:{top:b.top+b.height/2-d/2,left:b.left+b.width}},b.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},b.prototype.tip=function(){return this.$tip=this.$tip||a(this.options.template)},b.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},b.prototype.validate=function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},b.prototype.enable=function(){this.enabled=!0},b.prototype.disable=function(){this.enabled=!1},b.prototype.toggleEnabled=function(){this.enabled=!this.enabled},b.prototype.toggle=function(b){var c=b?a(b.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type):this;c.tip().hasClass("in")?c.leave(c):c.enter(c)},b.prototype.destroy=function(){this.hide().$element.off("."+this.type).removeData("bs."+this.type)};var c=a.fn.tooltip;a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("bs.tooltip"),f="object"==typeof c&&c;e||d.data("bs.tooltip",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=c,this}}(jQuery),+function(a){"use strict";var b=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");b.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),b.prototype.constructor=b,b.prototype.getDefaults=function(){return b.DEFAULTS},b.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content")[this.options.html?"html":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},b.prototype.hasContent=function(){return this.getTitle()||this.getContent()},b.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},b.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},b.prototype.tip=function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip};var c=a.fn.popover;a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof c&&c;e||d.data("bs.popover",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.noConflict=function(){return a.fn.popover=c,this}}(jQuery),+function(a){"use strict";function b(c,d){var e,f=a.proxy(this.process,this);this.$element=a(c).is("body")?a(window):a(c),this.$body=a("body"),this.$scrollElement=this.$element.on("scroll.bs.scroll-spy.data-api",f),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||(e=a(c).attr("href"))&&e.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.offsets=a([]),this.targets=a([]),this.activeTarget=null,this.refresh(),this.process()}b.DEFAULTS={offset:10},b.prototype.refresh=function(){var b=this.$element[0]==window?"offset":"position";this.offsets=a([]),this.targets=a([]);var c=this;this.$body.find(this.selector).map(function(){var d=a(this),e=d.data("target")||d.attr("href"),f=/^#\w/.test(e)&&a(e);return f&&f.length&&[[f[b]().top+(!a.isWindow(c.$scrollElement.get(0))&&c.$scrollElement.scrollTop()),e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){c.offsets.push(this[0]),c.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,d=c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(b>=d)return g!=(a=f.last()[0])&&this.activate(a);for(a=e.length;a--;)g!=f[a]&&b>=e[a]&&(!e[a+1]||b<=e[a+1])&&this.activate(f[a])},b.prototype.activate=function(b){this.activeTarget=b,a(this.selector).parents(".active").removeClass("active");var c=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',d=a(c).parents("li").addClass("active");d.parent(".dropdown-menu").length&&(d=d.closest("li.dropdown").addClass("active")),d.trigger("activate.bs.scrollspy")};var c=a.fn.scrollspy;a.fn.scrollspy=function(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=c,this},a(window).on("load",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);b.scrollspy(b.data())})})}(jQuery),+function(a){"use strict";var b=function(b){this.element=a(b)};b.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a")[0],f=a.Event("show.bs.tab",{relatedTarget:e});if(b.trigger(f),!f.isDefaultPrevented()){var g=a(d);this.activate(b.parent("li"),c),this.activate(g,g.parent(),function(){b.trigger({type:"shown.bs.tab",relatedTarget:e})})}}},b.prototype.activate=function(b,c,d){function e(){f.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),g?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var f=c.find("> .active"),g=d&&a.support.transition&&f.hasClass("fade");g?f.one(a.support.transition.end,e).emulateTransitionEnd(150):e(),f.removeClass("in")};var c=a.fn.tab;a.fn.tab=function(c){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new b(this)),"string"==typeof c&&e[c]()})},a.fn.tab.Constructor=b,a.fn.tab.noConflict=function(){return a.fn.tab=c,this},a(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(b){b.preventDefault(),a(this).tab("show")})}(jQuery),+function(a){"use strict";var b=function(c,d){this.options=a.extend({},b.DEFAULTS,d),this.$window=a(window).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(c),this.affixed=this.unpin=null,this.checkPosition()};b.RESET="affix affix-top affix-bottom",b.DEFAULTS={offset:0},b.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},b.prototype.checkPosition=function(){if(this.$element.is(":visible")){var c=a(document).height(),d=this.$window.scrollTop(),e=this.$element.offset(),f=this.options.offset,g=f.top,h=f.bottom;"object"!=typeof f&&(h=g=f),"function"==typeof g&&(g=f.top()),"function"==typeof h&&(h=f.bottom());var i=null!=this.unpin&&d+this.unpin<=e.top?!1:null!=h&&e.top+this.$element.height()>=c-h?"bottom":null!=g&&g>=d?"top":!1;this.affixed!==i&&(this.unpin&&this.$element.css("top",""),this.affixed=i,this.unpin="bottom"==i?e.top-d:null,this.$element.removeClass(b.RESET).addClass("affix"+(i?"-"+i:"")),"bottom"==i&&this.$element.offset({top:document.body.offsetHeight-h-this.$element.height()}))}};var c=a.fn.affix;a.fn.affix=function(c){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof c&&c;e||d.data("bs.affix",e=new b(this,f)),"string"==typeof c&&e[c]()})},a.fn.affix.Constructor=b,a.fn.affix.noConflict=function(){return a.fn.affix=c,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var b=a(this),c=b.data();c.offset=c.offset||{},c.offsetBottom&&(c.offset.bottom=c.offsetBottom),c.offsetTop&&(c.offset.top=c.offsetTop),b.affix(c)})})}(jQuery);
@@ -0,0 +1,110 @@
1
+ /* ===================================================
2
+ * confirmModal by Maxime AILLOUD
3
+ * https://github.com/mailloud/confirm-bootstrap
4
+ * ===================================================
5
+ * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENCE
6
+ * Version 2, December 2004
7
+ *
8
+ * Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
9
+ *
10
+ * Everyone is permitted to copy and distribute verbatim or modified
11
+ * copies of this licence document, and changing it is allowed as long
12
+ * as the name is changed.
13
+ *
14
+ * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENCE
15
+ * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
16
+ *
17
+ * 0. You just DO WHAT THE FUCK YOU WANT TO.
18
+ * ========================================================== */
19
+
20
+
21
+ (function($) {
22
+ $.fn.confirmModal = function(opts)
23
+ {
24
+ var body = $('body');
25
+ var defaultOptions = {
26
+ confirmTitle : 'Please confirm',
27
+ confirmMessage : 'Are you sure you want to perform this action ?',
28
+ confirmOk : 'Yes',
29
+ confirmCancel : 'Cancel',
30
+ confirmDirection : 'rtl',
31
+ confirmStyle : 'primary',
32
+ confirmCallback : defaultCallback
33
+ };
34
+ var options = $.extend(defaultOptions, opts);
35
+ var time = Date.now();
36
+
37
+ var headModalTemplate =
38
+ '<div class="modal fade" id="#modalId#" tabindex="-1" role="dialog" aria-labelledby="#AriaLabel#" aria-hidden="true">' +
39
+ '<div class="modal-dialog">' +
40
+ '<div class="modal-content">' +
41
+ '<div class="modal-header">' +
42
+ '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' +
43
+ '<h3>#Heading#</h3>' +
44
+ '</div>' +
45
+ '<div class="modal-body">' +
46
+ '<p>#Body#</p>' +
47
+ '</div>' +
48
+ '<div class="modal-footer">' +
49
+ '#buttonTemplate#' +
50
+ '</div>' +
51
+ '</div>' +
52
+ '</div>' +
53
+ '</div>'
54
+ ;
55
+
56
+ return this.each(function(index)
57
+ {
58
+ var confirmLink = $(this);
59
+ var targetData = confirmLink.data();
60
+
61
+ var currentOptions = $.extend(options, targetData);
62
+
63
+ var modalId = "confirmModal" + parseInt(time + index);
64
+ var modalTemplate = headModalTemplate;
65
+ var buttonTemplate =
66
+ '<button class="btn btn-default" data-dismiss="modal">#Cancel#</button>' +
67
+ '<button class="btn btn-#Style#" data-dismiss="ok">#Ok#</button>'
68
+ ;
69
+
70
+ if(options.confirmDirection == 'ltr')
71
+ {
72
+ buttonTemplate =
73
+ '<button class="btn btn-#Style#" data-dismiss="ok">#Ok#</button>' +
74
+ '<button class="btn btn-default" data-dismiss="modal">#Cancel#</button>'
75
+ ;
76
+ }
77
+
78
+ modalTemplate = modalTemplate.
79
+ replace('#buttonTemplate#', buttonTemplate).
80
+ replace('#modalId#', modalId).
81
+ replace('#AriaLabel#', options.confirmTitle).
82
+ replace('#Heading#', options.confirmTitle).
83
+ replace('#Body#', options.confirmMessage).
84
+ replace('#Ok#', options.confirmOk).
85
+ replace('#Cancel#', options.confirmCancel).
86
+ replace('#Style#', options.confirmStyle)
87
+ ;
88
+
89
+ body.append(modalTemplate);
90
+
91
+ var confirmModal = $('#' + modalId);
92
+
93
+ confirmLink.on('click', function(modalEvent)
94
+ {
95
+ modalEvent.preventDefault();
96
+ confirmModal.modal('show');
97
+
98
+ $('button[data-dismiss="ok"]', confirmModal).on('click', function(event) {
99
+ confirmModal.modal('hide');
100
+ options.confirmCallback(confirmLink, targetData);
101
+ });
102
+ });
103
+ });
104
+
105
+ function defaultCallback(target)
106
+ {
107
+ window.location = $(target).attr('href');
108
+ }
109
+ };
110
+ })(jQuery);
@@ -1,15 +1,24 @@
1
+ Compass.ErpApp.Utility.createNamespace("Knitkit");
2
+
1
3
  Knitkit.InlineEditing = {
2
- contentDiv:null,
3
- websiteId:null,
4
- contentId:null,
4
+ contentDiv: null,
5
+ websiteId: null,
6
+ contentId: null,
5
7
 
6
- closeEditor:function (editor) {
8
+ closeEditor: function (editor) {
7
9
  editor.destroy();
10
+
11
+ var body = jQuery("body");
12
+
8
13
  jQuery('#editableContentContainer').remove();
9
14
  jQuery('#editableContentOverlay').remove();
15
+ body.removeClass('modal-open');
16
+ body.removeClass('inline-editing');
10
17
  },
11
18
 
12
- saved:function (editor, result, status, xhr) {
19
+ saved: function (editor, result, status, xhr) {
20
+ jQuery('#editableContentOverlay').css('z-index', '1001');
21
+
13
22
  if (result.success === true) {
14
23
  this.closeEditor(editor);
15
24
  }
@@ -18,35 +27,49 @@ Knitkit.InlineEditing = {
18
27
  }
19
28
  },
20
29
 
21
- error:function (xhr, status, error) {
30
+ error: function (xhr, status, error) {
22
31
  jQuery('#inlineEditSaveResult').html(" Could not update. Please try again.");
23
32
  },
24
33
 
25
- closeEditorClick:function () {
34
+ closeEditorClick: function () {
26
35
  //make sure modal is not already showing
27
- if ($("#warning-modal").length === 0) {
36
+ if (jQuery("#warning-modal").length === 0) {
28
37
  var editor = CKEDITOR.instances['inlineEditTextarea'];
29
38
  if (editor.checkDirty()) {
30
- jQuery('#editableContentOverlay').css('z-index','1003');
31
-
32
- var warningModal = jQuery("<div id='warning-modal'></div>");
33
- warningModal.append('<span>You have unsaved changes. Are you sure you want to exit?</span><br/><br/>');
39
+ jQuery('#editableContentOverlay').css('z-index', '1003');
40
+
41
+ var warningModal = jQuery('<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>'),
42
+ modalDialog = jQuery('<div class="modal-dialog"></div>'),
43
+ modalContent = jQuery('<div class="modal-content"></div>'),
44
+ modalHeader = jQuery('<div class="modal-header"><h4 class="modal-title" id="myModalLabel">Please Confirm</h4></div>'),
45
+ modalBody = jQuery('<div class="modal-body">You have unsaved changes. Are you sure you want to exit?</div>'),
46
+ footer = jQuery('<div class="modal-footer"></div>'),
47
+ yesBtn = jQuery('<button type="button" class="btn btn-default" data-dismiss="modal">Yes</button>'),
48
+ noBtn = jQuery('<button type="button" class="btn btn-primary" data-dismiss="modal">No</button>');
49
+
50
+ footer.append(yesBtn);
51
+ footer.append(noBtn);
52
+ modalContent.append(modalHeader);
53
+ modalContent.append(modalBody);
54
+ modalContent.append(footer);
55
+ modalDialog.append(modalContent);
56
+ warningModal.append(modalDialog);
34
57
 
35
- var noBtn = jQuery('<input class="warning-btn" type="button" value="No" />');
36
58
  noBtn.bind('click', function () {
59
+ warningModal.modal('hide');
37
60
  warningModal.remove();
38
- jQuery('#editableContentOverlay').css('z-index','1001');
61
+ jQuery('#editableContentOverlay').css('z-index', '1001');
39
62
  });
40
63
 
41
- var yesBtn = jQuery('<input class="warning-btn" type="button" value="Yes" />');
42
64
  yesBtn.bind('click', function () {
43
65
  Knitkit.InlineEditing.closeEditor(editor);
66
+ warningModal.modal('hide');
44
67
  warningModal.remove();
45
68
  });
46
69
 
47
- warningModal.append(noBtn);
48
- warningModal.append(yesBtn);
49
70
  jQuery("body").append(warningModal);
71
+
72
+ warningModal.modal({backdrop: false});
50
73
  }
51
74
  else {
52
75
  Knitkit.InlineEditing.closeEditor(editor);
@@ -55,82 +78,82 @@ Knitkit.InlineEditing = {
55
78
  return false;
56
79
  },
57
80
 
58
- setup:function (websiteId) {
81
+ setup: function (websiteId) {
82
+ var content = jQuery('div.knitkit_content'),
83
+ body = jQuery("body");
84
+
59
85
  this.websiteId = websiteId;
60
86
 
61
- jQuery('div.knitkit_content').bind('mouseenter', function () {
87
+ content.bind('mouseenter', function () {
62
88
  var div = jQuery(this);
63
89
  div.addClass('knitkit-inlineedit-editable');
64
90
  });
65
91
 
66
- jQuery('div.knitkit_content').bind('mouseleave', function () {
92
+ content.bind('mouseleave', function () {
67
93
  var div = jQuery(this);
68
94
  div.removeClass('knitkit-inlineedit-editable');
69
95
  });
70
96
 
71
- jQuery('div.knitkit_content').bind('click', function () {
97
+ content.bind('click', function () {
72
98
  var self = Knitkit.InlineEditing;
73
99
  var div = jQuery(this);
74
100
  self.contentId = div.attr('contentid');
75
101
  self.lastUpdate = div.attr('lastupdate');
76
102
  var data = div.html();
77
103
 
104
+ var dialogHeader = jQuery("<div class='header'></div>");
105
+ var closeLink = jQuery("<a class='inline-edit-close'><img width='24px' height='24px' src='/images/inline_edit/close.png' /></a><br />");
78
106
  var textarea = jQuery('<textarea name="inline-edit-textarea" id="inlineEditTextarea" ></textarea>');
79
- var closeLink = jQuery("<a class='inline-edit-close'><img src='images/knitkit/close.png' /></a>");
80
107
  var messageSpan = jQuery("<span class='inline-edit-message' id='inlineEditMessage'>Last Update: <span id='inlineEditLastUpdate'>" + self.lastUpdate + "</span><span id='inlineEditSaveResult'></span></span>");
81
108
 
82
- var editableContentContainer = jQuery("<div id='editableContentContainer' class='modal-container'></div>");
109
+ var editableContentContainer = jQuery("<div id='editableContentContainer' style='font-size:12px;' class='modal-container'></div>");
83
110
  var ckeditorWrapper = jQuery("<div class='ckeditor_wrapper'></div>");
84
111
  var actionResultDiv = jQuery("<div class='editable-content-actionresult'></div>");
85
112
 
113
+ dialogHeader.append(closeLink);
114
+ editableContentContainer.append(dialogHeader);
86
115
  editableContentContainer.append(ckeditorWrapper);
87
116
  ckeditorWrapper.append(textarea);
117
+ textarea.val(data);
88
118
  editableContentContainer.append(actionResultDiv);
89
- actionResultDiv.append(closeLink);
90
119
  actionResultDiv.append(messageSpan);
91
120
 
92
121
  var overlay = jQuery("<div id='editableContentOverlay' class='modal-overlay'></div>");
93
122
 
94
- jQuery("body").append(editableContentContainer);
95
- jQuery("body").append(overlay);
123
+ body.append(editableContentContainer);
124
+ body.append(overlay);
125
+
126
+ body.addClass('inline-editing');
96
127
 
97
128
  closeLink.bind('click', self.closeEditorClick);
98
129
 
99
130
  CKEDITOR.replace('inline-edit-textarea',
100
131
  {
101
- height:320,
102
- enterMode:CKEDITOR.ENTER_BR,
103
- extraPlugins:'inlineeditsave,jwplayer',
104
- toolbar:[
105
- { name:'document', items:[ 'Source', '-', 'InlineEditSave', 'NewPage', 'DocProps', 'Preview', 'Print', '-', 'Templates' ] },
106
- { name:'clipboard', items:[ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
107
- { name:'editing', items:[ 'Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt' ] },
108
- { name:'forms', items:[ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
109
- 'HiddenField' ] },
132
+ height: 300,
133
+ enterMode: CKEDITOR.ENTER_BR,
134
+ allowedContent: true,
135
+ extraPlugins: 'inlineeditsave,codemirror',
136
+ toolbar: [
137
+ { name: 'document', items: [ 'Source', '-', 'InlineEditSave' ] },
138
+ { name: 'basicstyles', items: [ 'Bold', 'Italic', 'Underline' ] },
139
+ { name: 'paragraph', items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent',
140
+ '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },
141
+ { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
110
142
  '/',
111
- { name:'basicstyles', items:[ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
112
- { name:'paragraph', items:[ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv',
113
- '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl' ] },
114
- { name:'links', items:[ 'Link', 'Unlink', 'Anchor' ] },
115
- { name:'insert', items:[ 'Image', 'Flash', 'jwplayer', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe' ] },
116
- '/',
117
- { name:'styles', items:[ 'Styles', 'Format', 'Font', 'FontSize' ] },
118
- { name:'colors', items:[ 'TextColor', 'BGColor' ] },
119
- { name:'tools', items:[ 'Maximize', 'ShowBlocks', '-', 'About' ] }
143
+ { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
144
+ { name: 'colors', items: [ 'TextColor', 'BGColor' ] }
120
145
  ],
121
- on:{
122
- instanceReady:function (ev) {
146
+ on: {
147
+ instanceReady: function (ev) {
123
148
  Knitkit.InlineEditing.contentDiv = div;
124
- this.setData(data);
125
149
  this.focus();
126
150
  },
127
- dataReady:function (ev) {
151
+ dataReady: function (ev) {
128
152
  this.resetDirty();
129
153
  }
130
154
  }
131
-
132
155
  });
133
156
 
134
157
  });
135
158
  }
136
- }
159
+ };
@@ -0,0 +1,7 @@
1
+ /*
2
+ Masked Input plugin for jQuery
3
+ Copyright (c) 2007-2013 Josh Bush (digitalbush.com)
4
+ Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
5
+ Version: 1.3.1
6
+ */
7
+ (function(e){function t(){var e=document.createElement("input"),t="onpaste";return e.setAttribute(t,""),"function"==typeof e[t]?"paste":"input"}var n,a=t()+".mask",r=navigator.userAgent,i=/iphone/i.test(r),o=/android/i.test(r);e.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},dataName:"rawMaskFn",placeholder:"_"},e.fn.extend({caret:function(e,t){var n;if(0!==this.length&&!this.is(":hidden"))return"number"==typeof e?(t="number"==typeof t?t:e,this.each(function(){this.setSelectionRange?this.setSelectionRange(e,t):this.createTextRange&&(n=this.createTextRange(),n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",e),n.select())})):(this[0].setSelectionRange?(e=this[0].selectionStart,t=this[0].selectionEnd):document.selection&&document.selection.createRange&&(n=document.selection.createRange(),e=0-n.duplicate().moveStart("character",-1e5),t=e+n.text.length),{begin:e,end:t})},unmask:function(){return this.trigger("unmask")},mask:function(t,r){var c,l,s,u,f,h;return!t&&this.length>0?(c=e(this[0]),c.data(e.mask.dataName)()):(r=e.extend({placeholder:e.mask.placeholder,completed:null},r),l=e.mask.definitions,s=[],u=h=t.length,f=null,e.each(t.split(""),function(e,t){"?"==t?(h--,u=e):l[t]?(s.push(RegExp(l[t])),null===f&&(f=s.length-1)):s.push(null)}),this.trigger("unmask").each(function(){function c(e){for(;h>++e&&!s[e];);return e}function d(e){for(;--e>=0&&!s[e];);return e}function m(e,t){var n,a;if(!(0>e)){for(n=e,a=c(t);h>n;n++)if(s[n]){if(!(h>a&&s[n].test(R[a])))break;R[n]=R[a],R[a]=r.placeholder,a=c(a)}b(),x.caret(Math.max(f,e))}}function p(e){var t,n,a,i;for(t=e,n=r.placeholder;h>t;t++)if(s[t]){if(a=c(t),i=R[t],R[t]=n,!(h>a&&s[a].test(i)))break;n=i}}function g(e){var t,n,a,r=e.which;8===r||46===r||i&&127===r?(t=x.caret(),n=t.begin,a=t.end,0===a-n&&(n=46!==r?d(n):a=c(n-1),a=46===r?c(a):a),k(n,a),m(n,a-1),e.preventDefault()):27==r&&(x.val(S),x.caret(0,y()),e.preventDefault())}function v(t){var n,a,i,l=t.which,u=x.caret();t.ctrlKey||t.altKey||t.metaKey||32>l||l&&(0!==u.end-u.begin&&(k(u.begin,u.end),m(u.begin,u.end-1)),n=c(u.begin-1),h>n&&(a=String.fromCharCode(l),s[n].test(a)&&(p(n),R[n]=a,b(),i=c(n),o?setTimeout(e.proxy(e.fn.caret,x,i),0):x.caret(i),r.completed&&i>=h&&r.completed.call(x))),t.preventDefault())}function k(e,t){var n;for(n=e;t>n&&h>n;n++)s[n]&&(R[n]=r.placeholder)}function b(){x.val(R.join(""))}function y(e){var t,n,a=x.val(),i=-1;for(t=0,pos=0;h>t;t++)if(s[t]){for(R[t]=r.placeholder;pos++<a.length;)if(n=a.charAt(pos-1),s[t].test(n)){R[t]=n,i=t;break}if(pos>a.length)break}else R[t]===a.charAt(pos)&&t!==u&&(pos++,i=t);return e?b():u>i+1?(x.val(""),k(0,h)):(b(),x.val(x.val().substring(0,i+1))),u?t:f}var x=e(this),R=e.map(t.split(""),function(e){return"?"!=e?l[e]?r.placeholder:e:void 0}),S=x.val();x.data(e.mask.dataName,function(){return e.map(R,function(e,t){return s[t]&&e!=r.placeholder?e:null}).join("")}),x.attr("readonly")||x.one("unmask",function(){x.unbind(".mask").removeData(e.mask.dataName)}).bind("focus.mask",function(){clearTimeout(n);var e;S=x.val(),e=y(),n=setTimeout(function(){b(),e==t.length?x.caret(0,e):x.caret(e)},10)}).bind("blur.mask",function(){y(),x.val()!=S&&x.change()}).bind("keydown.mask",g).bind("keypress.mask",v).bind(a,function(){setTimeout(function(){var e=y(!0);x.caret(e),r.completed&&e==x.val().length&&r.completed.call(x)},0)}),y()}))}})})(jQuery);
@@ -0,0 +1,108 @@
1
+ Ext.define("KnitkitMobile.view.Main", {
2
+ extend: 'Ext.ux.slidenavigation.View',
3
+ itemId: 'slideContainer',
4
+
5
+ requires: [
6
+ 'Ext.Container',
7
+ 'Ext.MessageBox',
8
+ 'Ext.Panel',
9
+ 'Ext.Toolbar',
10
+ 'Ext.event.publisher.Dom'
11
+ ],
12
+
13
+ config: {
14
+ style: 'font-size:14px;',
15
+
16
+ fullscreen: true,
17
+
18
+ /**
19
+ * Any component within the container with an 'x-toolbar' class
20
+ * will be draggable. To disable draggin all together, set this
21
+ * to false.
22
+ */
23
+ slideSelector: 'x-container',
24
+
25
+ /**
26
+ * Time in milliseconds to animate the closing of the container
27
+ * after an item has been clicked on in the list.
28
+ */
29
+ selectSlideDuration: 200,
30
+
31
+ /**
32
+ * Enable content masking when container is open.
33
+ *
34
+ * @since 0.2.0
35
+ */
36
+ itemMask: true,
37
+
38
+ /**
39
+ * Define the default slide button config. Any item that has
40
+ * a `slideButton` value that is either `true` or a button config
41
+ * will use these values at the default.
42
+ */
43
+ slideButtonDefaults: {
44
+ selector: 'toolbar'
45
+ },
46
+
47
+ /**
48
+ * This allows us to configure how the actual list container
49
+ * looks. Here we've added a custom search field and have
50
+ * modified the width.
51
+ */
52
+ list: {
53
+ maxDrag: 400,
54
+ //width: (Ext.os.is.iOS ? 300 : 250),
55
+ items: [
56
+ {
57
+ xtype: 'toolbar',
58
+ docked: 'top',
59
+ ui: 'light',
60
+ title: {
61
+ title: 'Menu',
62
+ centered: true,
63
+ width: 200,
64
+ left: 0
65
+ }
66
+ }
67
+ ]
68
+
69
+ },
70
+
71
+ /**
72
+ * Example of how to re-order the groups.
73
+ */
74
+ /*groups: {
75
+ 'Pages': 1,
76
+ 'Account': 2
77
+ },*/
78
+
79
+ /**
80
+ * These are the default values to apply to the items within the
81
+ * container.
82
+ */
83
+ defaults: {
84
+ style: 'background: #fff',
85
+ xtype: 'container'
86
+ },
87
+
88
+ items: [
89
+ {
90
+ title: 'Intro to Paradine',
91
+ slideButton: true,
92
+ items: [
93
+ {
94
+ xtype: 'toolbar',
95
+ title: 'Intro to Paradine',
96
+ docked: 'top'
97
+ },
98
+ {
99
+ xtype: 'panel',
100
+ scrollable: true,
101
+ bodyPadding: '5px',
102
+ html: 'test'
103
+ }
104
+ ]
105
+ }
106
+ ]
107
+ }
108
+ });
@@ -0,0 +1,734 @@
1
+ /**
2
+ * {@link Ext.ux.slidenavigation.View} is a subclass of {@link Ext.Container}
3
+ * that provides a sliding main view with an underlying navigation list. The
4
+ * concept was inspired by Facebook's mobile app.
5
+ *
6
+ * @version 0.2.0
7
+ * @author Weston Nielson <wnielson@github>
8
+ */
9
+ Ext.define('Ext.ux.slidenavigation.View', {
10
+ extend: 'Ext.Container',
11
+
12
+ requires: [
13
+ 'Ext.Button',
14
+ 'Ext.Container',
15
+ 'Ext.Function',
16
+ 'Ext.Toolbar',
17
+ 'Ext.data.Model',
18
+ 'Ext.data.ModelManager',
19
+ 'Ext.data.Store',
20
+ 'Ext.dataview.List'
21
+ ],
22
+
23
+ xtype: 'slidenavigationview',
24
+
25
+ /**
26
+ * @event close
27
+ * @preventable moveContainer
28
+ * Fires whenever the container is closed
29
+ * @param {Ext.ux.slidenavigation.View} this The navigation View instance
30
+ * @param {Number} position The x-coordinate to which the container will be moved to
31
+ * @param {Number} duration The duration of the slide event
32
+ */
33
+
34
+ /**
35
+ * @event open
36
+ * @preventable moveContainer
37
+ * Fires whenever the container is opened
38
+ * @param {Ext.ux.slidenavigation.View} this The navigation View instance
39
+ * @param {Number} position The x-coordinate to which the container will be moved to
40
+ * @param {Number} duration The duration of the slide event
41
+ */
42
+
43
+ /**
44
+ * @event select
45
+ * @preventable setContainerItem
46
+ * Fires whenever an item in the menu is selected
47
+ * @param {Ext.ux.slidenavigation.View} this The navigation View instance
48
+ * @param {Ext.Component} item The selected item
49
+ * @param {Integer} index The index of the selected item
50
+ */
51
+
52
+ /**
53
+ * @event slideend
54
+ * Fires whenever the user has finished sliding the container. This is fired once the
55
+ * animation is complete.
56
+ * @param {Ext.ux.slidenavigation.View} this The navigation View instance
57
+ */
58
+
59
+ /**
60
+ * @event slidestart
61
+ * Fires whenever the user has started sliding the container. This is fired once the
62
+ * animation is complete.
63
+ * @param {Ext.ux.slidenavigation.View} this The navigation View instance
64
+ */
65
+
66
+ /**
67
+ * @event opened
68
+ * Fires after the container is fully opened.
69
+ * @param {Ext.ux.slidenavigation.View} this The navigation View instance
70
+ */
71
+
72
+ /**
73
+ * @event closed
74
+ * Fires after the container is fully closed.
75
+ * @param {Ext.ux.slidenavigation.View} this The navigation View instance
76
+ */
77
+
78
+ config: {
79
+ /**
80
+ * @cfg {Object} list Configuration for the navigation list
81
+ */
82
+ list: {
83
+ width: 250,
84
+ maxDrag: null,
85
+ itemTpl: '{title}',
86
+ grouped: true,
87
+ items: [
88
+ {
89
+ xtype: 'toolbar',
90
+ docked: 'top',
91
+ ui: 'light'
92
+ }
93
+ ]
94
+ },
95
+
96
+ /**
97
+ * @cfg {Object} container Configuration for the container
98
+ */
99
+ container: {},
100
+
101
+ /**
102
+ * @cfg {Object/Boolean} itemMask Configuration for the mask used to mask
103
+ * items when the container is opened. Set to false to disable masking of
104
+ * items.
105
+ */
106
+ itemMask: false,
107
+
108
+ /**
109
+ * @cfg {Array} items An array of items to put into the navigation list.
110
+ * The items can either be Ext components or special objects with a "handler"
111
+ * key, which should be a function to execute when selected. Additionally, you
112
+ * can define the order of the items by defining an 'order' parameter.
113
+ */
114
+ items: [],
115
+
116
+ /**
117
+ * @cfg {Object} groups Mapping of group name to order. For example,
118
+ * say you have defined two groups; "Group 1" and "Group 2". By default
119
+ * these will be presented in the list in that order, since
120
+ * 'Group 1' > 'Group 2'. This option allows you to change the ordering,
121
+ * like so:
122
+ *
123
+ * groups: {
124
+ * 'Group 1': 2
125
+ * 'Group 2': 1
126
+ * }
127
+ *
128
+ * You should use integers, starting with 1, as the ordering value.
129
+ * By default groups are ordered by their name.
130
+ */
131
+ groups: {},
132
+
133
+ /**
134
+ * @cfg {Object} defaults An object of default values to apply to any Ext
135
+ * components created from those listed in ``items``.
136
+ */
137
+ defaults: {
138
+ layout: 'card'
139
+ },
140
+
141
+ /**
142
+ * @cfg {String} slideSelector Class selector of object (or parent)
143
+ * of which dragging should be allowed. Defaults to the entire container.
144
+ * For example, this could be set to something like 'x-toolbar' to restrict
145
+ * dragging only to a toolbar.
146
+ */
147
+ slideSelector: '',
148
+
149
+ /**
150
+ * @cfg {Integer} slideDuration Number of miliseconds to animate the sliding
151
+ * of the container when "flicked". By default the animation is disable on
152
+ * Android.
153
+ */
154
+ slideDuration: Ext.os.is('Android') ? 0 : 200,
155
+
156
+ /**
157
+ * @cfg {Integer} selectSlideDuration Number of miliseconds to animate the sliding
158
+ * of the container when list item is selected (if closeOnSelect = true). The default
159
+ * value here of 300 gives a much nicer feel. By default the animation is disable on
160
+ * Android.
161
+ */
162
+ selectSlideDuration: Ext.os.is('Android') ? 0 : 300,
163
+
164
+ /**
165
+ * @cfg {Boolean} closeOnSelect Whether or not to automatically close the container
166
+ * when an item in the list is selected. Default is true.
167
+ */
168
+ closeOnSelect: true,
169
+
170
+ /**
171
+ * @cfg {String} shadowStyle CSS to use for styling the shadow when the container is
172
+ * open. This should be a valid CSS 'box-shadow' argument. Set to false to disable
173
+ * it.
174
+ */
175
+ shadowStyle: '0 0 4px 1px #999'
176
+ },
177
+
178
+ initConfig: function () {
179
+ var me = this;
180
+
181
+ me._indexCount = 0;
182
+
183
+ // Create the store.
184
+ me.store = Ext.create('Ext.data.Store', {
185
+ model: me.getModel(),
186
+ sorters: 'order',
187
+ grouper: {
188
+ property: 'group',
189
+ sortProperty: 'groupOrder'
190
+ }
191
+ });
192
+
193
+ // Add the items into the list.
194
+ me.addItems(me.config.items || []);
195
+ delete me.config.items;
196
+
197
+ me.callParent(arguments);
198
+
199
+ /**
200
+ * @private
201
+ *
202
+ * This stores the instances of the components created.
203
+ * TODO: Support 'autoDestroy'.
204
+ */
205
+ me._cache = {};
206
+
207
+
208
+ // Default config values used for creating a slideButton.
209
+ me._slideButtonConfig = {
210
+ xtype: 'button',
211
+ iconMask: true,
212
+ iconCls: 'list',
213
+ name: 'slidebutton',
214
+ listeners: {
215
+ release: me.toggleContainer,
216
+ tap: function (button, e) {
217
+ // Need this to stop auto-selecting any component
218
+ // hidden beneath the container.
219
+ e.preventDefault();
220
+ },
221
+ scope: me
222
+ }
223
+
224
+ /**
225
+ * To add the button into a toolbar, you can add the following
226
+ * to any item in your navigation list.
227
+ */
228
+ //selector: ['toolbar']
229
+ };
230
+
231
+ /**
232
+ * Default config for masked items.
233
+ */
234
+ me.itemMaskDefaults = {
235
+ zIndex:1
236
+ };
237
+ },
238
+
239
+ initialize: function () {
240
+ this.__init = false;
241
+
242
+ this.callParent();
243
+
244
+ this.addCls('x-slidenavigation');
245
+
246
+ this.list = this.createNavigationList();
247
+ this.container = this.createContainer();
248
+
249
+ this.add([
250
+ this.list,
251
+ this.container
252
+ ]);
253
+
254
+ this.createContainerCSS();
255
+
256
+ // TODO: Make this optional, perhaps by defining
257
+ // "selected: true" in the items list
258
+ this.list.select(0);
259
+
260
+ this.__init = true;
261
+ },
262
+
263
+ /**
264
+ * @private
265
+ *
266
+ * Adds an array of items (or a single item) into the list.
267
+ */
268
+ addItems: function (items) {
269
+ var me = this,
270
+ items = Ext.isArray(items) ? items : [items],
271
+ groups = me.config.groups;
272
+
273
+ Ext.each(items, function (item, index) {
274
+ if (!Ext.isDefined(item.index)) {
275
+ item.index = me._indexCount;
276
+ me._indexCount++;
277
+ }
278
+ me.store.add(item);
279
+ });
280
+ },
281
+
282
+ /**
283
+ * @private
284
+ *
285
+ * Construct style element for container shadow and insert into the DOM.
286
+ */
287
+ createContainerCSS: function () {
288
+ var shadowStyle = this.getShadowStyle(),
289
+ id = this.getId();
290
+
291
+ if (shadowStyle) {
292
+ if (!document.getElementById(id)) {
293
+ style = document.createElement('style');
294
+ style.type = 'text/css';
295
+ style.id = id;
296
+ style.innerHTML = '.x-slidenavigation-container.x-dragging, ' +
297
+ '.x-slidenavigation-container.open { ' +
298
+ 'box-shadow: ' + shadowStyle + ';' +
299
+ '-webkit-box-shadow:' + shadowStyle + ';';
300
+ document.getElementsByTagName('head')[0].appendChild(style);
301
+ }
302
+ }
303
+ },
304
+
305
+ /**
306
+ * @private
307
+ *
308
+ * Creates a button that can toggle the navigation menu. For an example
309
+ * config, see ``slideButtonDefaults``.
310
+ */
311
+ createSlideButton: function (el, config) {
312
+ var me = this,
313
+ config = Ext.merge(me.getSlideButtonDefaults(),
314
+ Ext.isObject(config) ? config : {}),
315
+ parent = el.down(config.selector);
316
+
317
+ if (parent) {
318
+ return parent.insert(0, Ext.merge(me._slideButtonConfig, config));
319
+ }
320
+
321
+ return false;
322
+ },
323
+
324
+ /**
325
+ * @private
326
+ *
327
+ * Gets the configuration for masking items. If masking items is disabled
328
+ * this returns false.
329
+ */
330
+ getMask: function () {
331
+ var mask = this.getItemMask();
332
+ if (mask != false) {
333
+ if (Ext.isBoolean(mask)) {
334
+ mask = this.itemMaskDefaults;
335
+ }
336
+ }
337
+
338
+ return mask;
339
+ },
340
+
341
+ /**
342
+ * @private
343
+ *
344
+ * If item masking is enabled, this method will mask any containers that have
345
+ * a ``maskOnOpen`` configuration variable set to ``true``. If masking is
346
+ * disabled, this method does nothing.
347
+ */
348
+ doMaskItem: function (item, mask) {
349
+ var maskConfig = this.getMask(),
350
+ mask = Ext.isDefined(mask) ? mask : true;
351
+
352
+ Ext.each(item.query('component[maskOnOpen=true]'), function (el) {
353
+ if (mask) {
354
+ el.setMasked(maskConfig);
355
+ } else {
356
+ el.setMasked(false);
357
+ }
358
+ });
359
+ },
360
+
361
+ /**
362
+ * @private
363
+ *
364
+ * Called when an item in the list is tapped.
365
+ */
366
+
367
+ onItemTap: function (list, index, target, record, e, eOpts) {
368
+ e.stopPropagation();
369
+ e.preventDefault();
370
+
371
+ var me = this;
372
+
373
+ if (Ext.isFunction(record.raw.handler) && me.__init) {
374
+ me.fireAction('select', [me , me._cache[index], index], record.raw.handler, me);
375
+ }
376
+ Ext.defer(me.closeContainer, 200, me, [me.config.selectSlideDuration]);
377
+ },
378
+
379
+ /**
380
+ * @private
381
+ *
382
+ * Called when an item in the list is tapped.
383
+ */
384
+ onSelect: function (list, item, eOpts) {
385
+ var me = this,
386
+ store = list.getStore(),
387
+ index = item.raw.index,
388
+ container = me.container,
389
+ func = Ext.emptyFn;
390
+
391
+ if (me._cache[index] == undefined) {
392
+ // If the object has a handler defined, then we don't need to
393
+ // create an Ext object
394
+ if (Ext.isFunction(item.raw.handler) && me.__init) {
395
+ me._cache[index] = item.raw.handler;
396
+ } else {
397
+ me._cache[index] = container.add(Ext.merge({}, me.config.defaults, item.raw));
398
+
399
+ me.doMaskItem(me._cache[index], true);
400
+
401
+ // Wait until the component is painted before closing the container. This makes
402
+ // the initial animation much smoother.
403
+ if (me.config.closeOnSelect) {
404
+ me._cache[index].addListener('painted', function () {
405
+ // The slight delay here gives the component enough time to update before
406
+ // the close animation starts.
407
+ Ext.defer(me.closeContainer, 200, me, [me.config.selectSlideDuration]);
408
+ });
409
+ }
410
+
411
+ // Add a button for controlling the slide, if desired
412
+ if ((item.raw.slideButton || false)) {
413
+ me.createSlideButton(me._cache[index], item.raw.slideButton);
414
+ }
415
+ }
416
+ }
417
+ else if (Ext.isFunction(item.raw.handler) && !Ext.isFunction(me._cache[index])) {
418
+ me._cache[index] = item.raw.handler;
419
+ }
420
+
421
+ if (Ext.isFunction(me._cache[index])) {
422
+ func = me._cache[index];
423
+ } else {
424
+ func = me.setContainerItem;
425
+ }
426
+
427
+ if (me.__init) {
428
+ me.fireAction('select', [me , me._cache[index], index], func, me);
429
+ }
430
+ },
431
+
432
+ /**
433
+ * @private
434
+ *
435
+ * Set the active item in the container.
436
+ */
437
+ setContainerItem: function (nav, item) {
438
+ var container = nav.container;
439
+ container.setActiveItem(item);
440
+ },
441
+
442
+ /**
443
+ * @private
444
+ *
445
+ * Callback function for when the container has started being dragged.
446
+ */
447
+ onContainerDragstart: function (draggable, e, offset, eOpts) {
448
+ if (this.config.slideSelector == false) {
449
+ return false;
450
+ }
451
+
452
+ if (this.config.slideSelector) {
453
+ node = e.target;
454
+ while (node = node.parentNode) {
455
+ if (node.className && node.className.indexOf(this.config.slideSelector) > -1) {
456
+ this.fireEvent('dragstart', this);
457
+ return true;
458
+ }
459
+ }
460
+ return false;
461
+ }
462
+ return false;
463
+ },
464
+
465
+ /**
466
+ * @private
467
+ *
468
+ * Callback function for when the container has finished being dragged. This determines
469
+ * which direction to finish moving the container based on its current position and velocity.
470
+ */
471
+ onContainerDragend: function (draggable, e, eOpts) {
472
+ var velocity = Math.abs(e.deltaX / e.deltaTime),
473
+ direction = (e.deltaX > 0) ? "right" : "left",
474
+ offset = Ext.clone(draggable.offset),
475
+ threshold = parseInt(this.config.list.minWidth * .70);
476
+
477
+ switch (direction) {
478
+ case "right":
479
+ offset.x = (velocity > 0.75 || offset.x > threshold) ? this.config.list.minWidth : 0;
480
+ break;
481
+ case "left":
482
+ offset.x = (velocity > 0.75 || offset.x < threshold) ? 0 : this.config.list.minWidth;
483
+ break;
484
+ }
485
+
486
+ this.fireEvent('dragend', this);
487
+
488
+ this.moveContainer(this, offset.x);
489
+ },
490
+
491
+ /**
492
+ * @private
493
+ *
494
+ * Registers the model with Ext.ModelManager, if it hasn't been
495
+ * already, and returns the name of the model for use in the store.
496
+ */
497
+ getModel: function () {
498
+ var model = 'SlideNavigationPanelItem',
499
+ groups = this.config.groups;
500
+
501
+ if (!Ext.ModelManager.get(model)) {
502
+ Ext.define(model, {
503
+ extend: 'Ext.data.Model',
504
+ config: {
505
+ idProperty: 'index',
506
+ fields: [
507
+ 'index', 'title', 'group',
508
+ {
509
+ name: 'order',
510
+ defaultValue: 1
511
+ }, {
512
+ name: 'groupOrder',
513
+ convert: function (value, record) {
514
+ // By default we group and order by group name.
515
+ group = record.get('group');
516
+ return groups[group] || group;
517
+ }
518
+ }
519
+ ]
520
+ }
521
+ });
522
+ }
523
+
524
+ return model;
525
+ },
526
+
527
+ /**
528
+ * Closes the container. See {@link #moveContainer} for more details.
529
+ */
530
+ closeContainer: function (duration) {
531
+ var me = this,
532
+ duration = duration || this.config.slideDuration;
533
+
534
+ if (me.__init) {
535
+ me.fireAction('close', [me, 0, duration], 'moveContainer', me);
536
+ }
537
+ },
538
+
539
+ /**
540
+ * Opens the container. See {@link #moveContainer} for more details.
541
+ */
542
+ openContainer: function (duration) {
543
+ var me = this,
544
+ duration = duration || this.config.slideDuration,
545
+ offsetX = this.config.list.minWidth;
546
+
547
+ if (me.__init) {
548
+ me.fireAction('open', [me, offsetX, duration], 'moveContainer', me);
549
+ }
550
+ },
551
+
552
+ /**
553
+ * Toggles the container open or close.
554
+ */
555
+ toggleContainer: function (duration) {
556
+ var duration = Ext.isNumber(duration) ? duration : this.config.slideDuration;
557
+ if (this.isClosed()) {
558
+ this.openContainer(duration);
559
+ } else {
560
+ this.closeContainer(duration);
561
+ }
562
+ },
563
+
564
+ /**
565
+ * @private
566
+ *
567
+ * Moves the container to a specified ``offsetX`` pixels. Positive
568
+ * integer values move the container that many pixels from the left edge
569
+ * of the window. If ``duration`` is provided, it should be an integer
570
+ * number of milliseconds to animate the slide effect. If no duration is
571
+ * provided, the default in ``config.slideDuration`` is used.
572
+ */
573
+ moveContainer: function (nav, offsetX, duration) {
574
+ var duration = duration || this.config.slideDuration,
575
+ draggable = this.container.draggableBehavior.draggable;
576
+
577
+ this.container.addCls('open');
578
+
579
+ draggable.setOffset(offsetX, 0, {
580
+ duration: duration
581
+ });
582
+ },
583
+
584
+ /**
585
+ * Returns true if the container is closed, false otherwise. This is a
586
+ * computed value based off the current offset position of the container.
587
+ *
588
+ * @return {Boolean} Whether or not the container is fully closed.
589
+ */
590
+ isClosed: function () {
591
+ return (this.container.draggableBehavior.draggable.offset.x == 0);
592
+ },
593
+
594
+
595
+ /**
596
+ * Returns true if the container is closed, false otherwise. This is a
597
+ * computed value based off the current offset position of the container.
598
+ *
599
+ * @return {Boolean} Whether or not the container is fully open.
600
+ */
601
+ isOpened: function () {
602
+ return (this.container.draggableBehavior.draggable.offset.x == this.config.list.minWidth);
603
+ },
604
+
605
+ /**
606
+ * @private
607
+ *
608
+ * Sets the container as being closed. This shouldn't ever be called
609
+ * directly as it is automatically called by the ``translatable``
610
+ * "animationend" event after the container has stopped moving. All this
611
+ * really does is set the CSS class for the container.
612
+ */
613
+ setClosed: function (closed) {
614
+ if (closed) {
615
+ this.container.removeCls('open');
616
+ } else {
617
+ this.container.addCls('open');
618
+ }
619
+ },
620
+
621
+ /**
622
+ * @private
623
+ *
624
+ * Generates a new Ext.dataview.List object to be used for displaying
625
+ * the navigation items.
626
+ */
627
+ createNavigationList: function (store) {
628
+ var listConfig = this.getList();
629
+
630
+ // The width of the list needs to be set to 100%, so we copy
631
+ // the width value (if set) to minWidth and then delete it.
632
+ if (listConfig.width) {
633
+ if (!listConfig.minWidth) {
634
+ listConfig.minWidth = listConfig.width;
635
+ }
636
+ delete listConfig.width;
637
+ }
638
+
639
+ return Ext.create('Ext.dataview.List', Ext.merge({}, listConfig, {
640
+ scrollable: {
641
+ direction: 'vertical',
642
+ directionLock: true
643
+ },
644
+ store: this.store,
645
+ docked: 'left',
646
+ cls: 'x-slidenavigation-list',
647
+ style: 'position: absolute; top: 0; left: 0; height: 100%; z-index: 2',
648
+ width: '100%',
649
+ listeners: {
650
+ select: this.onSelect,
651
+ itemtap: this.onItemTap,
652
+ scope: this
653
+ }
654
+ }));
655
+ },
656
+
657
+ /**
658
+ * @private
659
+ *
660
+ * Generates and returns the Ext.Container to be used for displaying
661
+ * content. This is the "slideable" container that is positioned above
662
+ * the navigation list.
663
+ */
664
+ createContainer: function () {
665
+ var me = this;
666
+
667
+ return Ext.create('Ext.Container', Ext.merge({}, me.config.container, {
668
+ docked: 'left',
669
+ cls: 'x-slidenavigation-container',
670
+ style: 'width: 100%; height: 100%; position: absolute; opacity: 1; z-index: 3',
671
+ layout: 'card',
672
+ draggable: {
673
+ direction: 'horizontal',
674
+ constraint: {
675
+ min: { x: 0, y: 0 },
676
+ max: { x: me.config.list.maxDrag || Math.max(screen.width, screen.height), y: 0 }
677
+ },
678
+ listeners: {
679
+ dragstart: {
680
+ fn: me.onContainerDragstart,
681
+ order: 'before',
682
+ scope: me
683
+ },
684
+ dragend: me.onContainerDragend,
685
+ scope: me
686
+ },
687
+ translatable: {
688
+ listeners: {
689
+ animationstart: function () {
690
+ me.fireEvent('slidestart', me);
691
+ },
692
+ animationend: function (translatable, b, c) {
693
+ // Fire the event now that the animation is done.
694
+ if (me.__init) {
695
+ me.fireEvent('slideend', me);
696
+ }
697
+
698
+ if (me.isOpened()) {
699
+ me.fireEvent('opened', me);
700
+
701
+ me.doMaskItem(me.container.getActiveItem(), true);
702
+ }
703
+
704
+ else if (me.isClosed()) {
705
+ me.fireEvent('closed', me);
706
+
707
+ me.doMaskItem(me.container.getActiveItem(), false);
708
+ }
709
+
710
+ // Remove the class when the animation is finished, but only
711
+ // if we're "closed"
712
+ me.setClosed(me.isClosed());
713
+ },
714
+ scope: me // The "x-slidenavigation" container
715
+ }
716
+ }
717
+ }
718
+ }));
719
+ },
720
+
721
+ /**
722
+ * Override the default method so that we actually return the active item in the list,
723
+ * otherwise this will always return the same thing (the main container, not the
724
+ * selected item).
725
+ *
726
+ * @return {Ext.Component/null} The currently active component.
727
+ */
728
+ getActiveItem: function () {
729
+ var selection = this.list.getSelection();
730
+ if (selection) {
731
+ return selection[0];
732
+ }
733
+ }
734
+ });