knitkit 3.0.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/{public → app/assets}/images/check.png +0 -0
  3. data/{public → app/assets}/images/credit_card.png +0 -0
  4. data/{public → app/assets}/images/inline_edit/close.png +0 -0
  5. data/{public → app/assets}/images/knitkit/icons/document.png +0 -0
  6. data/{public → app/assets}/images/knitkit/icons/multi_doc.png +0 -0
  7. data/{public → app/assets}/images/knitkit/logo.png +0 -0
  8. data/{public → app/assets}/images/knitkit/splash/images/add-site.png +0 -0
  9. data/app/assets/images/knitkit/splash/images/add_website_105x105-active.png +0 -0
  10. data/app/assets/images/knitkit/splash/images/add_website_105x105.png +0 -0
  11. data/{public → app/assets}/images/knitkit/splash/images/adjust-site.png +0 -0
  12. data/{public → app/assets}/images/knitkit/splash/images/browse-site.png +0 -0
  13. data/app/assets/images/knitkit/splash/images/browse_db_105x105-active.png +0 -0
  14. data/app/assets/images/knitkit/splash/images/browse_db_105x105.png +0 -0
  15. data/app/assets/images/knitkit/splash/images/console_105x105-active.png +0 -0
  16. data/app/assets/images/knitkit/splash/images/console_105x105.png +0 -0
  17. data/{public → app/assets}/images/knitkit/splash/images/find-themes.png +0 -0
  18. data/app/assets/images/knitkit/splash/images/find_themes_105x105-active.png +0 -0
  19. data/app/assets/images/knitkit/splash/images/find_themes_105x105.png +0 -0
  20. data/app/assets/images/knitkit/splash/images/learn_more_105x105-active.png +0 -0
  21. data/app/assets/images/knitkit/splash/images/learn_more_105x105.png +0 -0
  22. data/{public → app/assets}/images/knitkit/splash/images/settings.png +0 -0
  23. data/{public → app/assets}/images/knitkit/splash/images/tutorials.png +0 -0
  24. data/app/assets/images/knitkit/splash/splash.png +0 -0
  25. data/app/assets/images/widgets/manage_profile/contact_information.png +0 -0
  26. data/app/assets/images/widgets/manage_profile/password.png +0 -0
  27. data/app/assets/images/widgets/manage_profile/user_information.png +0 -0
  28. data/app/assets/javascripts/erp_app/desktop/applications/knitkit/app.js +24 -0
  29. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +15 -12
  30. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/center_region.js +69 -48
  31. data/app/assets/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +214 -0
  32. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/east_region.js +0 -0
  33. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/file_assets_panel.js +17 -19
  34. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_data_view.js +13 -3
  35. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_panel.js +59 -48
  36. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/widgets_panel.js +0 -0
  37. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +2 -2
  38. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/module.js +2 -2
  39. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +0 -0
  40. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +1 -1
  41. data/app/assets/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +268 -0
  42. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/top_menu/main_menu.js +85 -33
  43. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/top_menu/websites_combo.js +0 -0
  44. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +5 -28
  45. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/article.js +22 -8
  46. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +143 -25
  47. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +5 -1
  48. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +2 -0
  49. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +181 -65
  50. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +0 -0
  51. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/hosts_tree_panel.js +0 -0
  52. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/menu_tree_panel.js +0 -0
  53. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/site_contents_tree_panel.js +121 -116
  54. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/themes_tree_panel.js +101 -10
  55. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +9 -5
  56. data/app/assets/javascripts/knitkit-web.js +22 -0
  57. data/app/assets/javascripts/knitkit/additional-methods.min.js +4 -0
  58. data/app/assets/javascripts/knitkit/bootstrap.min.js +7 -0
  59. data/app/assets/javascripts/knitkit/captcha.js +154 -0
  60. data/{public → app/assets}/javascripts/knitkit/confirm-bootstrap.js +1 -1
  61. data/{public → app/assets}/javascripts/knitkit/inline_editing.js +1 -1
  62. data/{public → app/assets}/javascripts/knitkit/jquery.maskedinput.min.js +0 -0
  63. data/app/assets/javascripts/knitkit/jquery.validate.min.js +4 -0
  64. data/app/assets/javascripts/knitkit/js.cookie.js +145 -0
  65. data/{public → app/assets}/javascripts/knitkit/theme.js +0 -0
  66. data/app/assets/stylesheets/erp_app/desktop/applications/knitkit/app.css +12 -0
  67. data/{public → app/assets}/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +23 -33
  68. data/app/assets/stylesheets/erp_app/shared/knitkit_shared.css +21 -0
  69. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.eot +0 -0
  70. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.svg +288 -0
  71. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.ttf +0 -0
  72. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.woff +0 -0
  73. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.woff2 +0 -0
  74. data/app/assets/stylesheets/knitkit-web.css +16 -0
  75. data/app/assets/stylesheets/knitkit/bootstrap.min.css +5 -0
  76. data/app/assets/stylesheets/knitkit/captcha.css +59 -0
  77. data/app/assets/stylesheets/knitkit/custom.css +144 -0
  78. data/{public → app/assets}/stylesheets/knitkit/inline_editing.css +0 -0
  79. data/app/assets/stylesheets/knitkit/submenu.css +93 -0
  80. data/app/controllers/api/v1/websites_controller.rb +14 -0
  81. data/app/controllers/captcha_controller.rb +53 -0
  82. data/app/controllers/knitkit/base_controller.rb +1 -5
  83. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +2 -9
  84. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +20 -7
  85. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +38 -28
  86. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +16 -9
  87. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +69 -15
  88. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +45 -58
  89. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +64 -29
  90. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +36 -13
  91. data/app/controllers/knitkit/erp_app/desktop/website_host_controller.rb +12 -0
  92. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +4 -11
  93. data/app/controllers/knitkit/erp_app/desktop/website_nav_item_controller.rb +2 -9
  94. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +56 -20
  95. data/app/controllers/knitkit/online_document_sections_controller.rb +9 -3
  96. data/app/mailers/website_inquiry_mailer.rb +11 -3
  97. data/app/models/content.rb +16 -6
  98. data/app/models/documented_item.rb +12 -1
  99. data/app/models/online_document_section.rb +54 -20
  100. data/app/models/published_website.rb +16 -0
  101. data/app/models/theme.rb +53 -47
  102. data/app/models/website.rb +172 -191
  103. data/app/models/website_section.rb +64 -30
  104. data/app/views/knitkit/blogs/show.html.erb +5 -2
  105. data/app/views/layouts/knitkit/base.html.erb +54 -51
  106. data/app/views/menus/knitkit/_default_menu.html.erb +11 -11
  107. data/app/views/menus/knitkit/_default_section_menu.html.erb +2 -2
  108. data/app/views/menus/knitkit/_default_sub_menu.erb +27 -0
  109. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +30 -0
  110. data/app/views/website_inquiry_mailer/inquiry.html.erb +266 -0
  111. data/app/widgets/contact_us/base.rb +26 -16
  112. data/app/widgets/contact_us/javascript/contact_us.js +1 -1
  113. data/app/widgets/contact_us/views/error.html.erb +7 -3
  114. data/app/widgets/contact_us/views/index.html.erb +36 -28
  115. data/app/widgets/google_map/javascript/google_map.js +1 -1
  116. data/app/widgets/google_map/views/index.html.erb +1 -1
  117. data/app/widgets/login/javascript/login.js +1 -1
  118. data/app/widgets/login/views/index.html.erb +1 -1
  119. data/app/widgets/manage_profile/base.rb +141 -112
  120. data/app/widgets/manage_profile/javascript/manage_profile.js +2 -2
  121. data/app/widgets/manage_profile/views/_password_form.html.erb +1 -1
  122. data/app/widgets/manage_profile/views/_user_information_form.html.erb +1 -30
  123. data/app/widgets/manage_profile/views/index.html.erb +42 -40
  124. data/app/widgets/reset_password/base.rb +39 -8
  125. data/app/widgets/reset_password/javascript/reset_password.js +1 -1
  126. data/app/widgets/reset_password/views/index.html.erb +3 -3
  127. data/app/widgets/reset_password/views/invalid_reset_token.html.erb +7 -0
  128. data/app/widgets/reset_password/views/layouts/base.html.erb +1 -1
  129. data/app/widgets/reset_password/views/reset_password.html.erb +39 -0
  130. data/app/widgets/reset_password/views/reset_success.html.erb +5 -0
  131. data/app/widgets/search/base.rb +5 -5
  132. data/app/widgets/search/javascript/search.js +6 -6
  133. data/app/widgets/search/views/_inline_search_form.html.erb +23 -12
  134. data/app/widgets/search/views/_search_form.html.erb +34 -30
  135. data/app/widgets/search/views/layouts/base.html.erb +6 -1
  136. data/app/widgets/signup/base.rb +73 -30
  137. data/app/widgets/signup/javascript/signup.js +1 -1
  138. data/app/widgets/signup/views/_signup_form.html.erb +2 -1
  139. data/app/widgets/signup/views/layouts/base.html.erb +1 -1
  140. data/app/widgets/signup/views/success.html.erb +2 -3
  141. data/config/routes.rb +25 -4
  142. data/db/data_migrations/20110509223702_add_publisher_role.rb +0 -2
  143. data/db/data_migrations/20110816153456_add_knitkit_application.rb +7 -15
  144. data/db/data_migrations/20120127150505_create_website_default_configuration.rb +63 -3
  145. data/db/data_migrations/20150118180450_add_website_member_roles.rb +12 -0
  146. data/db/data_migrations/20150414150359_nest_knitkit_security_roles.rb +35 -0
  147. data/db/data_migrations/20150414173437_move_website_roles_under_website_builder.rb +19 -0
  148. data/db/migrate/20110211002317_setup_knitkit.rb +86 -39
  149. data/lib/knitkit.rb +8 -2
  150. data/lib/knitkit/config.rb +2 -3
  151. data/lib/knitkit/engine.rb +35 -4
  152. data/lib/knitkit/extensions.rb +2 -1
  153. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +1 -1
  154. data/lib/knitkit/extensions/action_mailer/theme_support/acts_as_themed_mailer.rb +1 -1
  155. data/lib/knitkit/extensions/compass_ae/mailers/user_mailer.rb +31 -0
  156. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +1 -1
  157. data/lib/knitkit/extensions/railties/action_controller/captcha_helper.rb +43 -0
  158. data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +1 -1
  159. data/lib/knitkit/extensions/railties/action_view/helpers/menu_helper.rb +11 -1
  160. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +83 -0
  161. data/lib/knitkit/routing_filter/section_router.rb +24 -14
  162. data/lib/knitkit/version.rb +1 -1
  163. data/lib/tasks/knitkit_tasks.rake +89 -4
  164. data/lib/tasks/theme_parser.rake +85 -0
  165. data/public/fonts/glyphicons-halflings-regular.eot +0 -0
  166. data/public/fonts/glyphicons-halflings-regular.svg +288 -0
  167. data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  168. data/public/fonts/glyphicons-halflings-regular.woff +0 -0
  169. data/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
  170. data/public/paypal-button.min.js +7 -0
  171. metadata +161 -82
  172. data/app/assets/javascripts/knitkit/application.js +0 -9
  173. data/app/assets/stylesheets/knitkit/application.css +0 -7
  174. data/app/mailers/document_mailer.rb +0 -10
  175. data/app/views/document_mailer/email_document.html.erb +0 -12
  176. data/app/views/knitkit/mobile/index.html.erb +0 -162
  177. data/app/views/knitkit/online_document_sections/index.html.erb +0 -279
  178. data/app/views/layouts/knitkit/online_document_sections.html.erb +0 -80
  179. data/app/views/website_inquiry_mailer/inquiry.erb +0 -24
  180. data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +0 -33
  181. data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +0 -16
  182. data/db/data_migrations/20120809020508_update_website_and_configuration.rb +0 -82
  183. data/db/data_migrations/20121129185611_upgrade_website_role_iid.rb +0 -20
  184. data/db/migrate/20130405184234_add_use_markdown_to_section.rb +0 -19
  185. data/db/migrate/20131112013052_add_knitkit_missing_indexes.rb +0 -33
  186. data/db/migrate/20140622212723_update_website_inquiries.rb +0 -22
  187. data/db/migrate/20140911185022_add_publishing_to_website.rb +0 -5
  188. data/db/migrate/20141013073349_add_custom_fields_to_documents.rb +0 -12
  189. data/db/migrate/20141016101936_upgrade_remove_dynamic_attributes.rb +0 -13
  190. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +0 -49
  191. data/public/images/knitkit/close_window.png +0 -0
  192. data/public/images/knitkit/splash/splash.png +0 -0
  193. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +0 -215
  194. data/public/javascripts/erp_app/desktop/applications/knitkit/select_roles_window.js +0 -108
  195. data/public/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +0 -170
  196. data/public/javascripts/knitkit/bootstrap-datepicker.js +0 -474
  197. data/public/javascripts/knitkit/bootstrap.min.js +0 -7
  198. data/public/javascripts/knitkit/mobile/app/view/Main.js +0 -108
  199. data/public/javascripts/knitkit/mobile/ux/slidenavigation/View.js +0 -734
  200. data/public/stylesheets/knitkit/bootstrap-responsive.min.css +0 -10
  201. data/public/stylesheets/knitkit/bootstrap.min.css +0 -7
  202. data/public/stylesheets/knitkit/custom.css +0 -122
  203. data/public/stylesheets/knitkit/datepicker.css +0 -182
@@ -1,170 +0,0 @@
1
- Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SplashScreen", {
2
- extend: "Ext.panel.Panel",
3
- alias: 'widget.knitkit_splash_screen',
4
- title: 'Startup',
5
- closable: true,
6
- items: [
7
- {
8
- html: "<div style='margin: 15px 50px 5px 50px;'><hr /><h2 style='margin: 3px 0px 0px 0px; color: #555; text-align: center'>Website Builder Home</h2><hr /></div>"
9
- },
10
-
11
- {
12
- xtype: 'image',
13
- style: 'padding-left: 50%; margin-left: -300px;',
14
- src: '/images/knitkit/splash/splash.png'
15
- },
16
-
17
- {
18
- html: "<div style='margin: 15px 50px 5px 50px;'><p style='margin: 0px; color: #222; text-align: center; font-size: 16px; font-weight: 300;'>Click on the shortcuts below to get started.</p></div>"
19
- },
20
-
21
- {
22
- xtype: 'panel',
23
- layout: 'column',
24
- style: 'width: 480px; margin-top: 0px; margin-left: auto; margin-right: auto;',
25
- items: [
26
-
27
- {
28
- xtype: 'panel',
29
- height: 140,
30
- width: 140,
31
- style:{
32
- margin: '0px 0px 5px 10px;',
33
- cursor: 'pointer'
34
- },
35
- bodyStyle: 'background: #ddd; padding: 20px; border-radius: 7px; border-color: #aaa !important;',
36
- border: true,
37
- bodyBorder: true,
38
- overCls: 'shortcut-hover',
39
- items: [
40
- {
41
- xtype: 'image',
42
- src: '/images/knitkit/splash/images/browse-site.png',
43
- height: 80,
44
- width: 80,
45
- style:{
46
- margin: '0px 0px 5px 10px;',
47
- cursor: 'pointer'
48
- },
49
- listeners: {
50
- render: function (component) {
51
- component.getEl().on('click', function (e) {
52
-
53
- var currentWebsite = compassDesktop.getModule('knitkit-win').currentWebsite;
54
- if(currentWebsite){
55
- window.open(currentWebsite.url,'_blank');
56
- }
57
- else{
58
- Ext.Msg.alert('Error', 'No website selected');
59
- }
60
-
61
- }, component);
62
- }
63
- }
64
- },
65
- {
66
- html: "<p style='background-color: #ddd; margin: 0px; text-align: center'>View the current site in a browser</p>"
67
- }
68
- ]
69
- },
70
-
71
- {
72
- xtype: 'panel',
73
- height: 140,
74
- width: 140,
75
- style:{
76
- margin: '0px 0px 5px 10px;',
77
- cursor: 'pointer'
78
- },
79
- bodyStyle: 'background: #ddd; padding: 20px; border-radius: 7px; border-color: #aaa !important;',
80
- border: true,
81
- bodyBorder: true,
82
- overCls: 'shortcut-hover',
83
- items: [
84
- {
85
- xtype: 'image',
86
- src: '/images/knitkit/splash/images/find-themes.png',
87
- height: 80,
88
- width: 80,
89
- style:{
90
- margin: '0px 0px 5px 10px;',
91
- cursor: 'pointer'
92
- },
93
- listeners: {
94
- render: function (component) {
95
- component.getEl().on('click', function (e) {
96
-
97
- var cr = this.findParentByType('knitkit_centerregion');
98
-
99
- cr.setWindowStatus('Finding themes...');
100
- cr.openIframeInTab('Find Themes', 'http://themes.compassagile.com');
101
- cr.clearWindowStatus();
102
-
103
-
104
- }, component);
105
- }
106
- }
107
- },
108
- {
109
- html: "<p style='background-color: #ddd; margin: 0px; text-align: center'>Find themes</p>"
110
- }
111
- ]
112
- },
113
-
114
- {
115
- xtype: 'panel',
116
- height: 140,
117
- width: 140,
118
- style:{
119
- margin: '0px 0px 5px 10px;',
120
- cursor: 'pointer'
121
- },
122
- bodyStyle: 'background: #ddd; padding: 20px; border-radius: 7px; border-color: #aaa !important;',
123
- border: true,
124
- bodyBorder: true,
125
- overCls: 'shortcut-hover',
126
- items: [
127
- {
128
- xtype: 'image',
129
- src: '/images/knitkit/splash/images/tutorials.png',
130
- height: 80,
131
- width: 80,
132
- style:{
133
- margin: '0px 0px 5px 10px;',
134
- cursor: 'pointer'
135
- },
136
- listeners: {
137
- render: function (component) {
138
- component.getEl().on('click', function (e) {
139
-
140
- var cr = this.findParentByType('knitkit_centerregion');
141
-
142
- cr.setWindowStatus('Retrieving Docs...');
143
- cr.openIframeInTab('Tutorials', 'http://tutorials.compassagile.com');
144
- cr.clearWindowStatus();
145
-
146
- }, component);
147
- }
148
- }
149
- },
150
- {
151
- html: "<p style='background-color: #ddd; margin: 0px; text-align: center'>Learn more!</p>"
152
- }
153
- ]
154
- }
155
- ]
156
- }
157
- ],
158
- constructor: function (config) {
159
-
160
- var self = this;
161
-
162
- config = Ext.apply({
163
- //placeholder
164
- }, config);
165
-
166
- self.callParent(config);
167
- }
168
- });
169
-
170
-
@@ -1,474 +0,0 @@
1
- /* =========================================================
2
- * bootstrap-datepicker.js
3
- * http://www.eyecon.ro/bootstrap-datepicker
4
- * =========================================================
5
- * Copyright 2012 Stefan Petre
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- * ========================================================= */
19
-
20
- !function( $ ) {
21
-
22
- // Picker object
23
-
24
- var Datepicker = function(element, options){
25
- this.element = $(element);
26
- this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
27
- this.picker = $(DPGlobal.template)
28
- .appendTo('body')
29
- .on({
30
- click: $.proxy(this.click, this)//,
31
- //mousedown: $.proxy(this.mousedown, this)
32
- });
33
- this.isInput = this.element.is('input');
34
- this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
35
-
36
- if (this.isInput) {
37
- this.element.on({
38
- focus: $.proxy(this.show, this),
39
- //blur: $.proxy(this.hide, this),
40
- keyup: $.proxy(this.update, this)
41
- });
42
- } else {
43
- if (this.component){
44
- this.component.on('click', $.proxy(this.show, this));
45
- } else {
46
- this.element.on('click', $.proxy(this.show, this));
47
- }
48
- }
49
-
50
- this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0;
51
- if (typeof this.minViewMode === 'string') {
52
- switch (this.minViewMode) {
53
- case 'months':
54
- this.minViewMode = 1;
55
- break;
56
- case 'years':
57
- this.minViewMode = 2;
58
- break;
59
- default:
60
- this.minViewMode = 0;
61
- break;
62
- }
63
- }
64
- this.viewMode = options.viewMode||this.element.data('date-viewmode')||0;
65
- if (typeof this.viewMode === 'string') {
66
- switch (this.viewMode) {
67
- case 'months':
68
- this.viewMode = 1;
69
- break;
70
- case 'years':
71
- this.viewMode = 2;
72
- break;
73
- default:
74
- this.viewMode = 0;
75
- break;
76
- }
77
- }
78
- this.startViewMode = this.viewMode;
79
- this.weekStart = options.weekStart||this.element.data('date-weekstart')||0;
80
- this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
81
- this.onRender = options.onRender;
82
- this.fillDow();
83
- this.fillMonths();
84
- this.update();
85
- this.showMode();
86
- };
87
-
88
- Datepicker.prototype = {
89
- constructor: Datepicker,
90
-
91
- show: function(e) {
92
- this.picker.show();
93
- this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
94
- this.place();
95
- $(window).on('resize', $.proxy(this.place, this));
96
- if (e ) {
97
- e.stopPropagation();
98
- e.preventDefault();
99
- }
100
- if (!this.isInput) {
101
- }
102
- var that = this;
103
- $(document).on('mousedown', function(ev){
104
- if ($(ev.target).closest('.datepicker').length == 0) {
105
- that.hide();
106
- }
107
- });
108
- this.element.trigger({
109
- type: 'show',
110
- date: this.date
111
- });
112
- },
113
-
114
- hide: function(){
115
- this.picker.hide();
116
- $(window).off('resize', this.place);
117
- this.viewMode = this.startViewMode;
118
- this.showMode();
119
- if (!this.isInput) {
120
- $(document).off('mousedown', this.hide);
121
- }
122
- //this.set();
123
- this.element.trigger({
124
- type: 'hide',
125
- date: this.date
126
- });
127
- },
128
-
129
- set: function() {
130
- var formated = DPGlobal.formatDate(this.date, this.format);
131
- if (!this.isInput) {
132
- if (this.component){
133
- this.element.find('input').prop('value', formated);
134
- }
135
- this.element.data('date', formated);
136
- } else {
137
- this.element.prop('value', formated);
138
- }
139
- },
140
-
141
- setValue: function(newDate) {
142
- if (typeof newDate === 'string') {
143
- this.date = DPGlobal.parseDate(newDate, this.format);
144
- } else {
145
- this.date = new Date(newDate);
146
- }
147
- this.set();
148
- this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
149
- this.fill();
150
- },
151
-
152
- place: function(){
153
- var offset = this.component ? this.component.offset() : this.element.offset();
154
- this.picker.css({
155
- top: offset.top + this.height,
156
- left: offset.left
157
- });
158
- },
159
-
160
- update: function(newDate){
161
- this.date = DPGlobal.parseDate(
162
- typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')),
163
- this.format
164
- );
165
- this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
166
- this.fill();
167
- },
168
-
169
- fillDow: function(){
170
- var dowCnt = this.weekStart;
171
- var html = '<tr>';
172
- while (dowCnt < this.weekStart + 7) {
173
- html += '<th class="dow">'+DPGlobal.dates.daysMin[(dowCnt++)%7]+'</th>';
174
- }
175
- html += '</tr>';
176
- this.picker.find('.datepicker-days thead').append(html);
177
- },
178
-
179
- fillMonths: function(){
180
- var html = '';
181
- var i = 0
182
- while (i < 12) {
183
- html += '<span class="month">'+DPGlobal.dates.monthsShort[i++]+'</span>';
184
- }
185
- this.picker.find('.datepicker-months td').append(html);
186
- },
187
-
188
- fill: function() {
189
- var d = new Date(this.viewDate),
190
- year = d.getFullYear(),
191
- month = d.getMonth(),
192
- currentDate = this.date.valueOf();
193
- this.picker.find('.datepicker-days th:eq(1)')
194
- .text(DPGlobal.dates.months[month]+' '+year);
195
- var prevMonth = new Date(year, month-1, 28,0,0,0,0),
196
- day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
197
- prevMonth.setDate(day);
198
- prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7);
199
- var nextMonth = new Date(prevMonth);
200
- nextMonth.setDate(nextMonth.getDate() + 42);
201
- nextMonth = nextMonth.valueOf();
202
- var html = [];
203
- var clsName,
204
- prevY,
205
- prevM;
206
- while(prevMonth.valueOf() < nextMonth) {
207
- if (prevMonth.getDay() === this.weekStart) {
208
- html.push('<tr>');
209
- }
210
- clsName = this.onRender(prevMonth);
211
- prevY = prevMonth.getFullYear();
212
- prevM = prevMonth.getMonth();
213
- if ((prevM < month && prevY === year) || prevY < year) {
214
- clsName += ' old';
215
- } else if ((prevM > month && prevY === year) || prevY > year) {
216
- clsName += ' new';
217
- }
218
- if (prevMonth.valueOf() === currentDate) {
219
- clsName += ' active';
220
- }
221
- html.push('<td class="day '+clsName+'">'+prevMonth.getDate() + '</td>');
222
- if (prevMonth.getDay() === this.weekEnd) {
223
- html.push('</tr>');
224
- }
225
- prevMonth.setDate(prevMonth.getDate()+1);
226
- }
227
- this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
228
- var currentYear = this.date.getFullYear();
229
-
230
- var months = this.picker.find('.datepicker-months')
231
- .find('th:eq(1)')
232
- .text(year)
233
- .end()
234
- .find('span').removeClass('active');
235
- if (currentYear === year) {
236
- months.eq(this.date.getMonth()).addClass('active');
237
- }
238
-
239
- html = '';
240
- year = parseInt(year/10, 10) * 10;
241
- var yearCont = this.picker.find('.datepicker-years')
242
- .find('th:eq(1)')
243
- .text(year + '-' + (year + 9))
244
- .end()
245
- .find('td');
246
- year -= 1;
247
- for (var i = -1; i < 11; i++) {
248
- html += '<span class="year'+(i === -1 || i === 10 ? ' old' : '')+(currentYear === year ? ' active' : '')+'">'+year+'</span>';
249
- year += 1;
250
- }
251
- yearCont.html(html);
252
- },
253
-
254
- click: function(e) {
255
- e.stopPropagation();
256
- e.preventDefault();
257
- var target = $(e.target).closest('span, td, th');
258
- if (target.length === 1) {
259
- switch(target[0].nodeName.toLowerCase()) {
260
- case 'th':
261
- switch(target[0].className) {
262
- case 'switch':
263
- this.showMode(1);
264
- break;
265
- case 'prev':
266
- case 'next':
267
- this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call(
268
- this.viewDate,
269
- this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) +
270
- DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1)
271
- );
272
- this.fill();
273
- this.set();
274
- break;
275
- }
276
- break;
277
- case 'span':
278
- if (target.is('.month')) {
279
- var month = target.parent().find('span').index(target);
280
- this.viewDate.setMonth(month);
281
- } else {
282
- var year = parseInt(target.text(), 10)||0;
283
- this.viewDate.setFullYear(year);
284
- }
285
- if (this.viewMode !== 0) {
286
- this.date = new Date(this.viewDate);
287
- this.element.trigger({
288
- type: 'changeDate',
289
- date: this.date,
290
- viewMode: DPGlobal.modes[this.viewMode].clsName
291
- });
292
- }
293
- this.showMode(-1);
294
- this.fill();
295
- this.set();
296
- break;
297
- case 'td':
298
- if (target.is('.day') && !target.is('.disabled')){
299
- var day = parseInt(target.text(), 10)||1;
300
- var month = this.viewDate.getMonth();
301
- if (target.is('.old')) {
302
- month -= 1;
303
- } else if (target.is('.new')) {
304
- month += 1;
305
- }
306
- var year = this.viewDate.getFullYear();
307
- this.date = new Date(year, month, day,0,0,0,0);
308
- this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0);
309
- this.fill();
310
- this.set();
311
- this.element.trigger({
312
- type: 'changeDate',
313
- date: this.date,
314
- viewMode: DPGlobal.modes[this.viewMode].clsName
315
- });
316
- }
317
- break;
318
- }
319
- }
320
- },
321
-
322
- mousedown: function(e){
323
- e.stopPropagation();
324
- e.preventDefault();
325
- },
326
-
327
- showMode: function(dir) {
328
- if (dir) {
329
- this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
330
- }
331
- this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
332
- }
333
- };
334
-
335
- $.fn.datepicker = function ( option, val ) {
336
- return this.each(function () {
337
- var $this = $(this),
338
- data = $this.data('datepicker'),
339
- options = typeof option === 'object' && option;
340
- if (!data) {
341
- $this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
342
- }
343
- if (typeof option === 'string') data[option](val);
344
- });
345
- };
346
-
347
- $.fn.datepicker.defaults = {
348
- onRender: function(date) {
349
- return '';
350
- }
351
- };
352
- $.fn.datepicker.Constructor = Datepicker;
353
-
354
- var DPGlobal = {
355
- modes: [
356
- {
357
- clsName: 'days',
358
- navFnc: 'Month',
359
- navStep: 1
360
- },
361
- {
362
- clsName: 'months',
363
- navFnc: 'FullYear',
364
- navStep: 1
365
- },
366
- {
367
- clsName: 'years',
368
- navFnc: 'FullYear',
369
- navStep: 10
370
- }],
371
- dates:{
372
- days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
373
- daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
374
- daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
375
- months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
376
- monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
377
- },
378
- isLeapYear: function (year) {
379
- return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
380
- },
381
- getDaysInMonth: function (year, month) {
382
- return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
383
- },
384
- parseFormat: function(format){
385
- var separator = format.match(/[.\/\-\s].*?/),
386
- parts = format.split(/\W+/);
387
- if (!separator || !parts || parts.length === 0){
388
- throw new Error("Invalid date format.");
389
- }
390
- return {separator: separator, parts: parts};
391
- },
392
- parseDate: function(date, format) {
393
- var parts = date.split(format.separator),
394
- date = new Date(),
395
- val;
396
- date.setHours(0);
397
- date.setMinutes(0);
398
- date.setSeconds(0);
399
- date.setMilliseconds(0);
400
- if (parts.length === format.parts.length) {
401
- var year = date.getFullYear(), day = date.getDate(), month = date.getMonth();
402
- for (var i=0, cnt = format.parts.length; i < cnt; i++) {
403
- val = parseInt(parts[i], 10)||1;
404
- switch(format.parts[i]) {
405
- case 'dd':
406
- case 'd':
407
- day = val;
408
- date.setDate(val);
409
- break;
410
- case 'mm':
411
- case 'm':
412
- month = val - 1;
413
- date.setMonth(val - 1);
414
- break;
415
- case 'yy':
416
- year = 2000 + val;
417
- date.setFullYear(2000 + val);
418
- break;
419
- case 'yyyy':
420
- year = val;
421
- date.setFullYear(val);
422
- break;
423
- }
424
- }
425
- date = new Date(year, month, day, 0 ,0 ,0);
426
- }
427
- return date;
428
- },
429
- formatDate: function(date, format){
430
- var val = {
431
- d: date.getDate(),
432
- m: date.getMonth() + 1,
433
- yy: date.getFullYear().toString().substring(2),
434
- yyyy: date.getFullYear()
435
- };
436
- val.dd = (val.d < 10 ? '0' : '') + val.d;
437
- val.mm = (val.m < 10 ? '0' : '') + val.m;
438
- var date = [];
439
- for (var i=0, cnt = format.parts.length; i < cnt; i++) {
440
- date.push(val[format.parts[i]]);
441
- }
442
- return date.join(format.separator);
443
- },
444
- headTemplate: '<thead>'+
445
- '<tr>'+
446
- '<th class="prev">&lsaquo;</th>'+
447
- '<th colspan="5" class="switch"></th>'+
448
- '<th class="next">&rsaquo;</th>'+
449
- '</tr>'+
450
- '</thead>',
451
- contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
452
- };
453
- DPGlobal.template = '<div class="datepicker dropdown-menu">'+
454
- '<div class="datepicker-days">'+
455
- '<table class=" table-condensed">'+
456
- DPGlobal.headTemplate+
457
- '<tbody></tbody>'+
458
- '</table>'+
459
- '</div>'+
460
- '<div class="datepicker-months">'+
461
- '<table class="table-condensed">'+
462
- DPGlobal.headTemplate+
463
- DPGlobal.contTemplate+
464
- '</table>'+
465
- '</div>'+
466
- '<div class="datepicker-years">'+
467
- '<table class="table-condensed">'+
468
- DPGlobal.headTemplate+
469
- DPGlobal.contTemplate+
470
- '</table>'+
471
- '</div>'+
472
- '</div>';
473
-
474
- }( window.jQuery );