web_admin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +32 -0
  6. data/Gemfile.lock +335 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.rdoc +3 -0
  9. data/Rakefile +22 -0
  10. data/app/assets/images/web_admin/.keep +0 -0
  11. data/app/assets/images/web_admin/avatar.jpg +0 -0
  12. data/app/assets/images/web_admin/first_icon.png +0 -0
  13. data/app/assets/images/web_admin/render-1-thumb.jpg +0 -0
  14. data/app/assets/images/web_admin/render-1.jpg +0 -0
  15. data/app/assets/images/web_admin/render-2-thumb.jpg +0 -0
  16. data/app/assets/images/web_admin/render-2.jpg +0 -0
  17. data/app/assets/images/web_admin/render-3-thumb.jpg +0 -0
  18. data/app/assets/images/web_admin/render-3.jpg +0 -0
  19. data/app/assets/images/web_admin/render-4-thumb.jpg +0 -0
  20. data/app/assets/images/web_admin/render-4.jpg +0 -0
  21. data/app/assets/images/web_admin/responsive.png +0 -0
  22. data/app/assets/javascripts/web_admin/app.data.js +336 -0
  23. data/app/assets/javascripts/web_admin/app.js +172 -0
  24. data/app/assets/javascripts/web_admin/app.plugin.js +220 -0
  25. data/app/assets/javascripts/web_admin/application.js +20 -0
  26. data/app/assets/javascripts/web_admin/bootstrap-filestyle.min.js +1 -0
  27. data/app/assets/javascripts/web_admin/bootstrap.js +1951 -0
  28. data/app/assets/javascripts/web_admin/charts/easypiechart/jquery.easy-pie-chart.js +184 -0
  29. data/app/assets/javascripts/web_admin/charts/sparkline/jquery.sparkline.min.js +5 -0
  30. data/app/assets/javascripts/web_admin/combodate/combodate.js +453 -0
  31. data/app/assets/javascripts/web_admin/combodate/moment.min.js +6 -0
  32. data/app/assets/javascripts/web_admin/data/datagrid.json +1900 -0
  33. data/app/assets/javascripts/web_admin/data/datatable.json +401 -0
  34. data/app/assets/javascripts/web_admin/datatables/jquery.dataTables.min.js +155 -0
  35. data/app/assets/javascripts/web_admin/datepicker/bootstrap-datepicker.js +474 -0
  36. data/app/assets/javascripts/web_admin/datepicker.js +3 -0
  37. data/app/assets/javascripts/web_admin/fuelux/fuelux.js +1645 -0
  38. data/app/assets/javascripts/web_admin/fullcalendar/fullcalendar.min.js +7 -0
  39. data/app/assets/javascripts/web_admin/grid/gallery.js +14 -0
  40. data/app/assets/javascripts/web_admin/grid/jquery.grid-a-licious.min.js +15 -0
  41. data/app/assets/javascripts/web_admin/grid/masonry.pkgd.min.js +9 -0
  42. data/app/assets/javascripts/web_admin/ie/excanvas.js +924 -0
  43. data/app/assets/javascripts/web_admin/ie/html5.js +9 -0
  44. data/app/assets/javascripts/web_admin/ie/respond.min.js +6 -0
  45. data/app/assets/javascripts/web_admin/jquery-ui-1.10.3.custom.min.js +6 -0
  46. data/app/assets/javascripts/web_admin/jquery.datetimepicker.js +1851 -0
  47. data/app/assets/javascripts/web_admin/jquery.ui.touch-punch.min.js +11 -0
  48. data/app/assets/javascripts/web_admin/parsley/parsley.min.js +35 -0
  49. data/app/assets/javascripts/web_admin/prettyphoto/default/default_thumb.png +0 -0
  50. data/app/assets/javascripts/web_admin/prettyphoto/default/loader.gif +0 -0
  51. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite.png +0 -0
  52. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_next.png +0 -0
  53. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_prev.png +0 -0
  54. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_x.png +0 -0
  55. data/app/assets/javascripts/web_admin/prettyphoto/default/sprite_y.png +0 -0
  56. data/app/assets/javascripts/web_admin/prettyphoto/jquery.prettyPhoto.js +7 -0
  57. data/app/assets/javascripts/web_admin/prettyphoto/prettyPhoto.css +170 -0
  58. data/app/assets/javascripts/web_admin/select2/select2.css +652 -0
  59. data/app/assets/javascripts/web_admin/select2/select2.min.js +22 -0
  60. data/app/assets/javascripts/web_admin/slider/bootstrap-slider.js +388 -0
  61. data/app/assets/javascripts/web_admin/underscore-min.js +7 -0
  62. data/app/assets/javascripts/web_admin/underscore-min.map +1 -0
  63. data/app/assets/javascripts/web_admin/upload_image.js +39 -0
  64. data/app/assets/stylesheets/web_admin/application.css +15 -0
  65. data/app/assets/stylesheets/web_admin/bootstrap.css +5784 -0
  66. data/app/assets/stylesheets/web_admin/font-awesome.min.css +4 -0
  67. data/app/assets/stylesheets/web_admin/font.css +18 -0
  68. data/app/assets/stylesheets/web_admin/fonts/FontAwesome.otf +0 -0
  69. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.eot +0 -0
  70. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.svg +414 -0
  71. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.ttf +0 -0
  72. data/app/assets/stylesheets/web_admin/fonts/fontawesome-webfont.woff +0 -0
  73. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.eot +0 -0
  74. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.svg +229 -0
  75. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.ttf +0 -0
  76. data/app/assets/stylesheets/web_admin/fonts/glyphicons-halflings-regular.woff +0 -0
  77. data/app/assets/stylesheets/web_admin/fonts/opensans/opensans-bold-webfont.woff +0 -0
  78. data/app/assets/stylesheets/web_admin/fonts/opensans/opensans-light-webfont.woff +0 -0
  79. data/app/assets/stylesheets/web_admin/fonts/opensans/opensans-webfont.woff +0 -0
  80. data/app/assets/stylesheets/web_admin/landing.css +272 -0
  81. data/app/assets/stylesheets/web_admin/plugin.css +1132 -0
  82. data/app/assets/stylesheets/web_admin/style.css +613 -0
  83. data/app/assets/stylesheets/web_admin/style2.css +21 -0
  84. data/app/controllers/web_admin/albums_controller.rb +8 -0
  85. data/app/controllers/web_admin/application_controller.rb +10 -0
  86. data/app/controllers/web_admin/crud_controller.rb +61 -0
  87. data/app/controllers/web_admin/events_controller.rb +9 -0
  88. data/app/controllers/web_admin/images_controller.rb +8 -0
  89. data/app/controllers/web_admin/institutionals_controller.rb +8 -0
  90. data/app/controllers/web_admin/main_controller.rb +7 -0
  91. data/app/controllers/web_admin/posts_controller.rb +19 -0
  92. data/app/controllers/web_admin/users_controller.rb +15 -0
  93. data/app/controllers/web_admin/videos_controller.rb +8 -0
  94. data/app/enumerations/web_admin/permission_type.rb +5 -0
  95. data/app/enumerations/web_admin/user_type.rb +6 -0
  96. data/app/helpers/web_admin/application_helper.rb +20 -0
  97. data/app/models/ability.rb +14 -0
  98. data/app/models/ckeditor/asset.rb +7 -0
  99. data/app/models/ckeditor/attachment_file.rb +7 -0
  100. data/app/models/ckeditor/picture.rb +7 -0
  101. data/app/models/web_admin/album.rb +13 -0
  102. data/app/models/web_admin/event.rb +20 -0
  103. data/app/models/web_admin/image.rb +10 -0
  104. data/app/models/web_admin/institutional.rb +11 -0
  105. data/app/models/web_admin/permission.rb +9 -0
  106. data/app/models/web_admin/post.rb +14 -0
  107. data/app/models/web_admin/user.rb +25 -0
  108. data/app/models/web_admin/video.rb +17 -0
  109. data/app/uploaders/ckeditor_attachment_file_uploader.rb +36 -0
  110. data/app/uploaders/ckeditor_picture_uploader.rb +47 -0
  111. data/app/uploaders/web_admin/image_post_uploader.rb +55 -0
  112. data/app/uploaders/web_admin/image_uploader.rb +52 -0
  113. data/app/views/devise/confirmations/new.html.erb +12 -0
  114. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  115. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  116. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  117. data/app/views/devise/passwords/edit.html.erb +16 -0
  118. data/app/views/devise/passwords/new.html.erb +12 -0
  119. data/app/views/devise/registrations/edit.html.erb +29 -0
  120. data/app/views/devise/registrations/new.html.erb +18 -0
  121. data/app/views/devise/sessions/new.html.erb +16 -0
  122. data/app/views/devise/shared/_links.html.erb +25 -0
  123. data/app/views/devise/unlocks/new.html.erb +12 -0
  124. data/app/views/layouts/web_admin/devise.html.erb +42 -0
  125. data/app/views/shared/403.html +57 -0
  126. data/app/views/shared/_header.html.erb +16 -0
  127. data/app/views/shared/_navbar.html.erb +23 -0
  128. data/app/views/shared/_notice.html.erb +12 -0
  129. data/app/views/web_admin/albums/_form.html.erb +23 -0
  130. data/app/views/web_admin/albums/edit.html.erb +4 -0
  131. data/app/views/web_admin/albums/index.html.erb +39 -0
  132. data/app/views/web_admin/albums/new.html.erb +4 -0
  133. data/app/views/web_admin/albums/show.html.erb +4 -0
  134. data/app/views/web_admin/events/_form.html.erb +37 -0
  135. data/app/views/web_admin/events/edit.html.erb +4 -0
  136. data/app/views/web_admin/events/index.html.erb +39 -0
  137. data/app/views/web_admin/events/new.html.erb +4 -0
  138. data/app/views/web_admin/images/_form.html.erb +23 -0
  139. data/app/views/web_admin/images/_images.html.erb +10 -0
  140. data/app/views/web_admin/images/create.js.erb +2 -0
  141. data/app/views/web_admin/images/update.js.erb +2 -0
  142. data/app/views/web_admin/institutionals/_form.html.erb +22 -0
  143. data/app/views/web_admin/institutionals/edit.html.erb +4 -0
  144. data/app/views/web_admin/institutionals/index.html.erb +35 -0
  145. data/app/views/web_admin/institutionals/new.html.erb +4 -0
  146. data/app/views/web_admin/layouts/application.html.erb +77 -0
  147. data/app/views/web_admin/main/index.html.erb +1 -0
  148. data/app/views/web_admin/posts/_form.html.erb +27 -0
  149. data/app/views/web_admin/posts/edit.html.erb +4 -0
  150. data/app/views/web_admin/posts/index.html.erb +37 -0
  151. data/app/views/web_admin/posts/new.html.erb +4 -0
  152. data/app/views/web_admin/users/_form.html.erb +49 -0
  153. data/app/views/web_admin/users/edit.html.erb +4 -0
  154. data/app/views/web_admin/users/index.html.erb +35 -0
  155. data/app/views/web_admin/users/new.html.erb +4 -0
  156. data/app/views/web_admin/videos/_form.html.erb +22 -0
  157. data/app/views/web_admin/videos/edit.html.erb +4 -0
  158. data/app/views/web_admin/videos/index.html.erb +37 -0
  159. data/app/views/web_admin/videos/new.html.erb +4 -0
  160. data/bin/rails +12 -0
  161. data/config/initializers/ckeditor.rb +39 -0
  162. data/config/initializers/devise.rb +261 -0
  163. data/config/initializers/enumerate_it.rb +1 -0
  164. data/config/initializers/simple_form.rb +145 -0
  165. data/config/initializers/simple_form_bootstrap.rb +46 -0
  166. data/config/locales/buttons.yml +3 -0
  167. data/config/locales/controllers.yml +9 -0
  168. data/config/locales/devise.en.yml +62 -0
  169. data/config/locales/devise.pt.yml +62 -0
  170. data/config/locales/models.yml +54 -0
  171. data/config/locales/rails.yml +219 -0
  172. data/config/locales/responders.yml +10 -0
  173. data/config/locales/simple_form.en.yml +26 -0
  174. data/config/routes.rb +13 -0
  175. data/db/migrate/20141023223026_devise_create_admin_web_users.rb +42 -0
  176. data/db/migrate/20141023223656_create_admin_web_posts.rb +15 -0
  177. data/db/migrate/20141026181117_create_ckeditor_assets.rb +26 -0
  178. data/db/migrate/20141028020102_create_admin_web_institutionals.rb +10 -0
  179. data/db/migrate/20141028135201_create_admin_web_videos.rb +10 -0
  180. data/db/migrate/20141114020551_create_admin_web_albums.rb +12 -0
  181. data/db/migrate/20141117183405_create_admin_web_images.rb +11 -0
  182. data/db/migrate/20141130203155_add_user_type_to_users.rb +5 -0
  183. data/db/migrate/20141224221959_create_admin_web_events.rb +18 -0
  184. data/db/migrate/20150130140502_create_admin_web_permissions.rb +13 -0
  185. data/db/migrate/20150510191213_rename_tables.rb +12 -0
  186. data/lib/application_responder.rb +12 -0
  187. data/lib/tasks/web_admin_tasks.rake +4 -0
  188. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  189. data/lib/web_admin/engine.rb +15 -0
  190. data/lib/web_admin/version.rb +3 -0
  191. data/lib/web_admin.rb +18 -0
  192. data/spec/factories/admin_web_users.rb +24 -0
  193. data/spec/features/admin_web/albums_spec.rb +74 -0
  194. data/spec/features/admin_web/event_spec.rb +85 -0
  195. data/spec/features/admin_web/institutionals_spec.rb +47 -0
  196. data/spec/features/admin_web/login_spec.rb +18 -0
  197. data/spec/features/admin_web/permissions_spec.rb +40 -0
  198. data/spec/features/admin_web/posts_spec.rb +55 -0
  199. data/spec/features/admin_web/users_spec.rb +73 -0
  200. data/spec/features/admin_web/videos_spec.rb +51 -0
  201. data/spec/fixtures/p3-single.jpg +0 -0
  202. data/spec/models/admin_web/album_spec.rb +20 -0
  203. data/spec/models/admin_web/event_spec.rb +42 -0
  204. data/spec/models/admin_web/image_spec.rb +14 -0
  205. data/spec/models/admin_web/institutional_spec.rb +19 -0
  206. data/spec/models/admin_web/permission_spec.rb +14 -0
  207. data/spec/models/admin_web/post_spec.rb +25 -0
  208. data/spec/models/admin_web/user_spec.rb +18 -0
  209. data/spec/models/admin_web/video_spec.rb +26 -0
  210. data/spec/rails_helper.rb +52 -0
  211. data/spec/spec_helper.rb +85 -0
  212. data/spec/support/capybara.rb +53 -0
  213. data/spec/support/database_cleaner.rb +25 -0
  214. data/spec/support/devise.rb +5 -0
  215. data/spec/support/factory_girl.rb +4 -0
  216. data/spec/support/helpers.rb +82 -0
  217. data/spec/support/shared_connection.rb +10 -0
  218. data/spec/test_app/README.rdoc +28 -0
  219. data/spec/test_app/Rakefile +6 -0
  220. data/spec/test_app/app/assets/images/.keep +0 -0
  221. data/spec/test_app/app/assets/javascripts/application.js +13 -0
  222. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  223. data/spec/test_app/app/controllers/application_controller.rb +5 -0
  224. data/spec/test_app/app/controllers/concerns/.keep +0 -0
  225. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  226. data/spec/test_app/app/mailers/.keep +0 -0
  227. data/spec/test_app/app/models/.keep +0 -0
  228. data/spec/test_app/app/models/concerns/.keep +0 -0
  229. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  230. data/spec/test_app/bin/bundle +3 -0
  231. data/spec/test_app/bin/rails +4 -0
  232. data/spec/test_app/bin/rake +4 -0
  233. data/spec/test_app/config/application.rb +29 -0
  234. data/spec/test_app/config/boot.rb +5 -0
  235. data/spec/test_app/config/database.yml +85 -0
  236. data/spec/test_app/config/environment.rb +5 -0
  237. data/spec/test_app/config/environments/development.rb +37 -0
  238. data/spec/test_app/config/environments/production.rb +78 -0
  239. data/spec/test_app/config/environments/test.rb +39 -0
  240. data/spec/test_app/config/initializers/assets.rb +8 -0
  241. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  242. data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
  243. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  244. data/spec/test_app/config/initializers/inflections.rb +16 -0
  245. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  246. data/spec/test_app/config/initializers/session_store.rb +3 -0
  247. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  248. data/spec/test_app/config/locales/en.yml +23 -0
  249. data/spec/test_app/config/routes.rb +4 -0
  250. data/spec/test_app/config/secrets.yml +22 -0
  251. data/spec/test_app/config.ru +4 -0
  252. data/spec/test_app/db/schema.rb +121 -0
  253. data/spec/test_app/lib/assets/.keep +0 -0
  254. data/spec/test_app/log/.keep +0 -0
  255. data/spec/test_app/public/404.html +67 -0
  256. data/spec/test_app/public/422.html +67 -0
  257. data/spec/test_app/public/500.html +66 -0
  258. data/spec/test_app/public/favicon.ico +0 -0
  259. data/spec/test_app/spec/factories/admin_web_albums.rb +7 -0
  260. data/spec/test_app/spec/factories/admin_web_users.rb +24 -0
  261. data/spec/test_app/spec/factories/permissions.rb +36 -0
  262. data/web_admin.gemspec +38 -0
  263. data/wercker.yml +16 -0
  264. metadata +530 -0
@@ -0,0 +1,474 @@
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 );
@@ -0,0 +1,3 @@
1
+ $(function() {
2
+ $('.datetime').datetimepicker({format: 'd/m/Y H:i'});
3
+ });