tramway 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +12 -893
  4. data/Rakefile +8 -8
  5. data/app/components/tailwind_component.html.haml +0 -0
  6. data/app/components/tailwind_component.rb +6 -0
  7. data/app/components/tailwinds/navbar/button_component.html.haml +1 -0
  8. data/app/components/tailwinds/navbar/button_component.rb +14 -0
  9. data/config/routes.rb +0 -9
  10. data/lib/tasks/tramway_tasks.rake +5 -0
  11. data/lib/tramway/engine.rb +5 -10
  12. data/lib/tramway/version.rb +1 -1
  13. data/lib/tramway.rb +5 -140
  14. metadata +16 -545
  15. data/app/assets/config/tramway_core_manifest.js +0 -2
  16. data/app/assets/images/tramway/mona_lisa_from_prado.jpg +0 -0
  17. data/app/assets/images/tramway/mona_lisa_from_prado_square.jpg +0 -0
  18. data/app/assets/javascripts/bootstrap-datepicker-1.8.0.js +0 -2035
  19. data/app/assets/javascripts/bootstrap-datepicker-1.8.0.ru.min.js +0 -64
  20. data/app/assets/javascripts/ckeditor/config.js +0 -30
  21. data/app/assets/javascripts/ckeditor/plugins/image/dialogs/image.js +0 -1259
  22. data/app/assets/javascripts/ckeditor/plugins/image/icons/hidpi/image.png +0 -0
  23. data/app/assets/javascripts/ckeditor/plugins/image/icons/image.png +0 -0
  24. data/app/assets/javascripts/ckeditor/plugins/image/images/noimage.png +0 -0
  25. data/app/assets/javascripts/ckeditor/plugins/image/lang/en.js +0 -25
  26. data/app/assets/javascripts/ckeditor/plugins/image/lang/ru.js +0 -25
  27. data/app/assets/javascripts/ckeditor/plugins/image/plugin.js +0 -184
  28. data/app/assets/javascripts/ckeditor/plugins/youtube/images/icon-hdpi.png +0 -0
  29. data/app/assets/javascripts/ckeditor/plugins/youtube/images/icon.png +0 -0
  30. data/app/assets/javascripts/ckeditor/plugins/youtube/lang/en.js +0 -25
  31. data/app/assets/javascripts/ckeditor/plugins/youtube/lang/ru.js +0 -25
  32. data/app/assets/javascripts/ckeditor/plugins/youtube/plugin.js +0 -449
  33. data/app/assets/javascripts/tramway/application.js +0 -61
  34. data/app/assets/stylesheets/tramway/application.sass +0 -59
  35. data/app/controllers/tramway/application_controller.rb +0 -142
  36. data/app/controllers/tramway/concerns/auth_management.rb +0 -26
  37. data/app/controllers/tramway/concerns/filtering.rb +0 -43
  38. data/app/controllers/tramway/export/application_controller.rb +0 -5
  39. data/app/controllers/tramway/has_and_belongs_to_many_records_controller.rb +0 -26
  40. data/app/controllers/tramway/records_controller.rb +0 -86
  41. data/app/controllers/tramway/sessions_controller.rb +0 -49
  42. data/app/controllers/tramway/singletons_controller.rb +0 -48
  43. data/app/controllers/tramway/welcome_controller.rb +0 -17
  44. data/app/decorators/tramway/application_decorated_collection.rb +0 -15
  45. data/app/decorators/tramway/application_decorator.rb +0 -124
  46. data/app/decorators/tramway/associations/class_helper.rb +0 -45
  47. data/app/decorators/tramway/associations/object_helper.rb +0 -58
  48. data/app/decorators/tramway/attributes/view_helper.rb +0 -30
  49. data/app/decorators/tramway/concerns/attributes_decorator_helper.rb +0 -97
  50. data/app/decorators/tramway/concerns/table_builder.rb +0 -33
  51. data/app/decorators/tramway/default/values_helper.rb +0 -23
  52. data/app/decorators/tramway/delegating/class_helper.rb +0 -9
  53. data/app/decorators/tramway/user_decorator.rb +0 -49
  54. data/app/forms/admin/tramway/user_form.rb +0 -24
  55. data/app/forms/tramway/application_form.rb +0 -124
  56. data/app/forms/tramway/application_forms/association_class_helpers.rb +0 -7
  57. data/app/forms/tramway/application_forms/association_object_helpers.rb +0 -36
  58. data/app/forms/tramway/application_forms/constant_class_actions.rb +0 -7
  59. data/app/forms/tramway/application_forms/constant_object_actions.rb +0 -20
  60. data/app/forms/tramway/application_forms/frontend.rb +0 -12
  61. data/app/forms/tramway/application_forms/object_helpers.rb +0 -15
  62. data/app/forms/tramway/application_forms/properties_object_helper.rb +0 -16
  63. data/app/forms/tramway/application_forms/submit_helper.rb +0 -26
  64. data/app/forms/tramway/extendable_form.rb +0 -15
  65. data/app/forms/tramway/extendable_forms_helpers/class_builder.rb +0 -34
  66. data/app/forms/tramway/extendable_forms_helpers/ignored_properties_helper.rb +0 -11
  67. data/app/forms/tramway/extendable_forms_helpers/more_properties_helper.rb +0 -31
  68. data/app/forms/tramway/extendable_forms_helpers/properties_helper.rb +0 -16
  69. data/app/forms/tramway/extendable_forms_helpers/submit/class_helpers.rb +0 -18
  70. data/app/forms/tramway/extendable_forms_helpers/submit/object_helpers.rb +0 -21
  71. data/app/forms/tramway/extendable_forms_helpers/validators.rb +0 -40
  72. data/app/forms/tramway/extended_application_form.rb +0 -23
  73. data/app/forms/tramway/form_creator.rb +0 -7
  74. data/app/forms/tramway/session_form.rb +0 -26
  75. data/app/helpers/tramway/actions_helper.rb +0 -45
  76. data/app/helpers/tramway/additional_buttons_builder.rb +0 -12
  77. data/app/helpers/tramway/application_helper.rb +0 -27
  78. data/app/helpers/tramway/cases_helper.rb +0 -13
  79. data/app/helpers/tramway/copy_to_clipboard_helper.rb +0 -11
  80. data/app/helpers/tramway/focus_generator_helper.rb +0 -10
  81. data/app/helpers/tramway/frontend_helper.rb +0 -26
  82. data/app/helpers/tramway/inputs/associations_helper.rb +0 -30
  83. data/app/helpers/tramway/inputs/polymorphic_associations_helper.rb +0 -24
  84. data/app/helpers/tramway/inputs_helper.rb +0 -96
  85. data/app/helpers/tramway/model_helper.rb +0 -7
  86. data/app/helpers/tramway/navbar_helper.rb +0 -11
  87. data/app/helpers/tramway/records_helper.rb +0 -120
  88. data/app/helpers/tramway/russian_cases_helper.rb +0 -26
  89. data/app/helpers/tramway/singleton_helper.rb +0 -12
  90. data/app/helpers/tramway/state_machine_buttons_helper.rb +0 -61
  91. data/app/helpers/tramway/title_helper.rb +0 -25
  92. data/app/inputs/date_picker_input.rb +0 -4
  93. data/app/inputs/multiple_file_input.rb +0 -7
  94. data/app/models/tramway/application_record.rb +0 -62
  95. data/app/models/tramway/user.rb +0 -18
  96. data/app/uploaders/application_uploader.rb +0 -22
  97. data/app/uploaders/file_uploader.rb +0 -4
  98. data/app/uploaders/ico_uploader.rb +0 -7
  99. data/app/uploaders/image_defaults.rb +0 -14
  100. data/app/uploaders/photo_uploader.rb +0 -54
  101. data/app/views/layouts/tramway/application.html.haml +0 -32
  102. data/app/views/layouts/tramway/shared/_navbar.html.haml +0 -46
  103. data/app/views/tramway/404.haml +0 -1
  104. data/app/views/tramway/records/_form.html.haml +0 -22
  105. data/app/views/tramway/records/_list.html.haml +0 -38
  106. data/app/views/tramway/records/_search.html.haml +0 -34
  107. data/app/views/tramway/records/edit.html.haml +0 -1
  108. data/app/views/tramway/records/index.html.haml +0 -31
  109. data/app/views/tramway/records/new.html.haml +0 -1
  110. data/app/views/tramway/records/show.html.haml +0 -1
  111. data/app/views/tramway/sessions/new.html.haml +0 -9
  112. data/app/views/tramway/shared/_input.html.haml +0 -34
  113. data/app/views/tramway/shared/_input_extended.html.haml +0 -14
  114. data/app/views/tramway/shared/_messages.html.haml +0 -10
  115. data/app/views/tramway/shared/_show.html.haml +0 -35
  116. data/app/views/tramway/shared/errors/server_error.html.haml +0 -12
  117. data/app/views/tramway/shared/input_extended_types/_checkbox.html.haml +0 -1
  118. data/app/views/tramway/shared/input_extended_types/_select.html.haml +0 -16
  119. data/app/views/tramway/shared/input_extended_types/_simple.html.haml +0 -4
  120. data/app/views/tramway/shared/input_extended_types/_yes_no.html.haml +0 -4
  121. data/app/views/tramway/shared/show/_attribute_tr.html.haml +0 -9
  122. data/app/views/tramway/shared/show/associations/_habtm_row.html.haml +0 -14
  123. data/app/views/tramway/shared/show/associations/_list.html.haml +0 -21
  124. data/app/views/tramway/shared/show/associations/_row.html.haml +0 -19
  125. data/app/views/tramway/shared/show/associations/_table_row.html.haml +0 -21
  126. data/app/views/tramway/singletons/_form.html.haml +0 -15
  127. data/app/views/tramway/singletons/edit.html.haml +0 -1
  128. data/app/views/tramway/singletons/new.html.haml +0 -1
  129. data/app/views/tramway/singletons/show.html.haml +0 -1
  130. data/app/views/tramway/welcome/index.html.haml +0 -4
  131. data/config/initializers/assets.rb +0 -7
  132. data/config/initializers/ckeditor.rb +0 -9
  133. data/config/initializers/plurals.rb +0 -25
  134. data/config/locales/en/collections.yml +0 -4
  135. data/config/locales/en/date.yml +0 -16
  136. data/config/locales/en/dates.yml +0 -10
  137. data/config/locales/en/helpers.yml +0 -26
  138. data/config/locales/en/locale.yml +0 -11
  139. data/config/locales/en/messages.yml +0 -7
  140. data/config/locales/en/models.yml +0 -9
  141. data/config/locales/en/simple_form_extension.yml +0 -8
  142. data/config/locales/en/state_machines.yml +0 -8
  143. data/config/locales/ru/collections.yml +0 -4
  144. data/config/locales/ru/date.yml +0 -16
  145. data/config/locales/ru/dates.yml +0 -10
  146. data/config/locales/ru/helpers.yml +0 -30
  147. data/config/locales/ru/locale.yml +0 -6
  148. data/config/locales/ru/messages.yml +0 -7
  149. data/config/locales/ru/models.yml +0 -21
  150. data/config/locales/ru/simple_form_extension.yml +0 -8
  151. data/config/locales/ru/state_machines.yml +0 -8
  152. data/lib/string.rb +0 -18
  153. data/lib/tramway/application.rb +0 -10
  154. data/lib/tramway/class_name_helpers.rb +0 -15
  155. data/lib/tramway/collection.rb +0 -9
  156. data/lib/tramway/collections/helper.rb +0 -21
  157. data/lib/tramway/collections.rb +0 -4
  158. data/lib/tramway/error.rb +0 -32
  159. data/lib/tramway/forms.rb +0 -5
  160. data/lib/tramway/generators/install_generator.rb +0 -49
  161. data/lib/tramway/generators/model_generator.rb +0 -105
  162. data/lib/tramway/generators/templates/create_tramway_users.rb +0 -18
  163. data/lib/tramway/generators/templates/decorator.rb.erb +0 -56
  164. data/lib/tramway/generators/templates/form.rb.erb +0 -22
  165. data/lib/tramway/generators/templates/initializers/simple_form.rb +0 -23
  166. data/lib/tramway/generators/templates/initializers/simple_form_bootstrap.rb +0 -133
  167. data/lib/tramway/generators.rb +0 -6
  168. data/lib/tramway/navbar.rb +0 -44
  169. data/lib/tramway/notifications.rb +0 -12
  170. data/lib/tramway/record_routes_helper.rb +0 -23
  171. data/lib/tramway/records_models.rb +0 -60
  172. data/lib/tramway/singleton_models.rb +0 -32
  173. data/lib/tramway/spec/helpers/navbar_helper.rb +0 -7
  174. data/lib/tramway/spec/helpers/tramway_helpers.rb +0 -47
  175. data/lib/tramway/welcome_page_actions.rb +0 -5
  176. data/lib/tramway/yaml/errors.yml +0 -50
  177. data/lib/validators/presence_validator.rb +0 -9
@@ -1,449 +0,0 @@
1
- /*
2
- * Youtube Embed Plugin
3
- *
4
- * @author Jonnas Fonini <jonnasfonini@gmail.com>
5
- * @version 2.1.14
6
- */
7
- (function () {
8
- CKEDITOR.plugins.add('youtube', {
9
- lang: [ 'en', 'bg', 'pt', 'pt-br', 'ja', 'hu', 'it', 'fr', 'tr', 'ru', 'de', 'ar', 'nl', 'pl', 'vi', 'zh', 'el', 'he', 'es', 'nb', 'nn', 'fi', 'et', 'sk', 'cs', 'ko', 'eu', 'uk'],
10
- init: function (editor) {
11
- editor.addCommand('youtube', new CKEDITOR.dialogCommand('youtube', {
12
- allowedContent: 'div{*}(*); iframe{*}[!width,!height,!src,!frameborder,!allowfullscreen,!allow]; object param[*]; a[*]; img[*]'
13
- }));
14
-
15
- editor.ui.addButton('Youtube', {
16
- label : editor.lang.youtube.button,
17
- toolbar : 'insert',
18
- command : 'youtube',
19
- icon : this.path + 'images/icon.png'
20
- });
21
-
22
- CKEDITOR.dialog.add('youtube', function (instance) {
23
- var video,
24
- disabled = editor.config.youtube_disabled_fields || [];
25
-
26
- return {
27
- title : editor.lang.youtube.title,
28
- minWidth : 510,
29
- minHeight : 200,
30
- onShow: function () {
31
- for (var i = 0; i < disabled.length; i++) {
32
- this.getContentElement('youtubePlugin', disabled[i]).disable();
33
- }
34
- },
35
- contents :
36
- [{
37
- id : 'youtubePlugin',
38
- expand : true,
39
- elements :
40
- [{
41
- id : 'txtEmbed',
42
- type : 'textarea',
43
- label : editor.lang.youtube.txtEmbed,
44
- onChange : function (api) {
45
- handleEmbedChange(this, api);
46
- },
47
- onKeyUp : function (api) {
48
- handleEmbedChange(this, api);
49
- },
50
- validate : function () {
51
- if (this.isEnabled()) {
52
- if (!this.getValue()) {
53
- alert(editor.lang.youtube.noCode);
54
- return false;
55
- }
56
- else
57
- if (this.getValue().length === 0 || this.getValue().indexOf('//') === -1) {
58
- alert(editor.lang.youtube.invalidEmbed);
59
- return false;
60
- }
61
- }
62
- }
63
- },
64
- {
65
- type : 'html',
66
- html : editor.lang.youtube.or + '<hr>'
67
- },
68
- {
69
- type : 'hbox',
70
- widths : [ '70%', '15%', '15%' ],
71
- children :
72
- [
73
- {
74
- id : 'txtUrl',
75
- type : 'text',
76
- label : editor.lang.youtube.txtUrl,
77
- onChange : function (api) {
78
- handleLinkChange(this, api);
79
- },
80
- onKeyUp : function (api) {
81
- handleLinkChange(this, api);
82
- },
83
- validate : function () {
84
- if (this.isEnabled()) {
85
- if (!this.getValue()) {
86
- alert(editor.lang.youtube.noCode);
87
- return false;
88
- }
89
- else{
90
- video = ytVidId(this.getValue());
91
-
92
- if (this.getValue().length === 0 || video === false)
93
- {
94
- alert(editor.lang.youtube.invalidUrl);
95
- return false;
96
- }
97
- }
98
- }
99
- }
100
- },
101
- {
102
- type : 'text',
103
- id : 'txtWidth',
104
- width : '60px',
105
- label : editor.lang.youtube.txtWidth,
106
- 'default' : editor.config.youtube_width != null ? editor.config.youtube_width : '640',
107
- validate : function () {
108
- if (this.getValue()) {
109
- var width = parseInt (this.getValue()) || 0;
110
-
111
- if (width === 0) {
112
- alert(editor.lang.youtube.invalidWidth);
113
- return false;
114
- }
115
- }
116
- else {
117
- alert(editor.lang.youtube.noWidth);
118
- return false;
119
- }
120
- }
121
- },
122
- {
123
- type : 'text',
124
- id : 'txtHeight',
125
- width : '60px',
126
- label : editor.lang.youtube.txtHeight,
127
- 'default' : editor.config.youtube_height != null ? editor.config.youtube_height : '360',
128
- validate : function () {
129
- if (this.getValue()) {
130
- var height = parseInt(this.getValue()) || 0;
131
-
132
- if (height === 0) {
133
- alert(editor.lang.youtube.invalidHeight);
134
- return false;
135
- }
136
- }
137
- else {
138
- alert(editor.lang.youtube.noHeight);
139
- return false;
140
- }
141
- }
142
- }
143
- ]
144
- },
145
- {
146
- type : 'hbox',
147
- widths : [ '55%', '45%' ],
148
- children :
149
- [
150
- {
151
- id : 'chkResponsive',
152
- type : 'checkbox',
153
- label : editor.lang.youtube.txtResponsive,
154
- 'default' : editor.config.youtube_responsive != null ? editor.config.youtube_responsive : false
155
- },
156
- {
157
- id : 'chkNoEmbed',
158
- type : 'checkbox',
159
- label : editor.lang.youtube.txtNoEmbed,
160
- 'default' : editor.config.youtube_noembed != null ? editor.config.youtube_noembed : false
161
- }
162
- ]
163
- },
164
- {
165
- type : 'hbox',
166
- widths : [ '55%', '45%' ],
167
- children :
168
- [
169
- {
170
- id : 'chkRelated',
171
- type : 'checkbox',
172
- 'default' : editor.config.youtube_related != null ? editor.config.youtube_related : true,
173
- label : editor.lang.youtube.chkRelated
174
- },
175
- {
176
- id : 'chkOlderCode',
177
- type : 'checkbox',
178
- 'default' : editor.config.youtube_older != null ? editor.config.youtube_older : false,
179
- label : editor.lang.youtube.chkOlderCode
180
- }
181
- ]
182
- },
183
- {
184
- type : 'hbox',
185
- widths : [ '55%', '45%' ],
186
- children :
187
- [
188
- {
189
- id : 'chkPrivacy',
190
- type : 'checkbox',
191
- label : editor.lang.youtube.chkPrivacy,
192
- 'default' : editor.config.youtube_privacy != null ? editor.config.youtube_privacy : false
193
- },
194
- {
195
- id : 'chkAutoplay',
196
- type : 'checkbox',
197
- 'default' : editor.config.youtube_autoplay != null ? editor.config.youtube_autoplay : false,
198
- label : editor.lang.youtube.chkAutoplay
199
- }
200
- ]
201
- },
202
- {
203
- type : 'hbox',
204
- widths : [ '55%', '45%'],
205
- children :
206
- [
207
- {
208
- id : 'txtStartAt',
209
- type : 'text',
210
- label : editor.lang.youtube.txtStartAt,
211
- validate : function () {
212
- if (this.getValue()) {
213
- var str = this.getValue();
214
-
215
- if (!/^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$/i.test(str)) {
216
- alert(editor.lang.youtube.invalidTime);
217
- return false;
218
- }
219
- }
220
- }
221
- },
222
- {
223
- id : 'chkControls',
224
- type : 'checkbox',
225
- 'default' : editor.config.youtube_controls != null ? editor.config.youtube_controls : true,
226
- label : editor.lang.youtube.chkControls
227
- }
228
- ]
229
- }
230
- ]
231
- }
232
- ],
233
- onOk: function()
234
- {
235
- var content = '';
236
- var responsiveStyle = '';
237
-
238
- if (this.getContentElement('youtubePlugin', 'txtEmbed').isEnabled()) {
239
- content = this.getValueOf('youtubePlugin', 'txtEmbed');
240
- }
241
- else {
242
- var url = 'https://', params = [], startSecs, paramAutoplay='';
243
- var width = this.getValueOf('youtubePlugin', 'txtWidth');
244
- var height = this.getValueOf('youtubePlugin', 'txtHeight');
245
-
246
- if (this.getContentElement('youtubePlugin', 'chkPrivacy').getValue() === true) {
247
- url += 'www.youtube-nocookie.com/';
248
- }
249
- else {
250
- url += 'www.youtube.com/';
251
- }
252
-
253
- url += 'embed/' + video;
254
-
255
- if (this.getContentElement('youtubePlugin', 'chkRelated').getValue() === false) {
256
- params.push('rel=0');
257
- }
258
-
259
- if (this.getContentElement('youtubePlugin', 'chkAutoplay').getValue() === true) {
260
- params.push('autoplay=1');
261
- paramAutoplay='autoplay';
262
- }
263
-
264
- if (this.getContentElement('youtubePlugin', 'chkControls').getValue() === false) {
265
- params.push('controls=0');
266
- }
267
-
268
- startSecs = this.getValueOf('youtubePlugin', 'txtStartAt');
269
-
270
- if (startSecs) {
271
- var seconds = hmsToSeconds(startSecs);
272
-
273
- params.push('start=' + seconds);
274
- }
275
-
276
- if (params.length > 0) {
277
- url = url + '?' + params.join('&');
278
- }
279
-
280
- if (this.getContentElement('youtubePlugin', 'chkResponsive').getValue() === true) {
281
- content += '<div class="youtube-embed-wrapper" style="position:relative;padding-bottom:56.25%;padding-top:30px;height:0;overflow:hidden">';
282
- responsiveStyle = 'style="position:absolute;top:0;left:0;width:100%;height:100%"';
283
- }
284
-
285
- if (this.getContentElement('youtubePlugin', 'chkOlderCode').getValue() === true) {
286
- url = url.replace('embed/', 'v/');
287
- url = url.replace(/&/g, '&amp;');
288
-
289
- if (url.indexOf('?') === -1) {
290
- url += '?';
291
- }
292
- else {
293
- url += '&amp;';
294
- }
295
- url += 'hl=' + (this.getParentEditor().config.language ? this.getParentEditor().config.language : 'en') + '&amp;version=3';
296
-
297
- content += '<object width="' + width + '" height="' + height + '" ' + responsiveStyle + '>';
298
- content += '<param name="movie" value="' + url + '"></param>';
299
- content += '<param name="allowFullScreen" value="true"></param>';
300
- content += '<param name="allowscriptaccess" value="always"></param>';
301
- content += '<embed src="' + url + '" type="application/x-shockwave-flash" ';
302
- content += 'width="' + width + '" height="' + height + '" '+ responsiveStyle + ' allowscriptaccess="always" ';
303
- content += 'allowfullscreen="true"></embed>';
304
- content += '</object>';
305
- }
306
- else
307
- if (this.getContentElement('youtubePlugin', 'chkNoEmbed').getValue() === true) {
308
- var imgSrc = 'https://img.youtube.com/vi/' + video + '/sddefault.jpg';
309
- content += '<a href="' + url + '" ><img width="' + width + '" height="' + height + '" src="' + imgSrc + '" ' + responsiveStyle + '/></a>';
310
- }
311
- else {
312
- content += '<iframe ' + (paramAutoplay ? 'allow="' + paramAutoplay + ';" ' : '') + 'width="' + width + '" height="' + height + '" src="' + url + '" ' + responsiveStyle;
313
- content += 'frameborder="0" allowfullscreen></iframe>';
314
- }
315
-
316
- if (this.getContentElement('youtubePlugin', 'chkResponsive').getValue() === true) {
317
- content += '</div>';
318
- }
319
- }
320
-
321
- var element = CKEDITOR.dom.element.createFromHtml(content);
322
- var instance = this.getParentEditor();
323
- instance.insertElement(element);
324
- }
325
- };
326
- });
327
- }
328
- });
329
- })();
330
-
331
- function handleLinkChange(el, api) {
332
- var video = ytVidId(el.getValue());
333
- var time = ytVidTime(el.getValue());
334
-
335
- if (el.getValue().length > 0) {
336
- el.getDialog().getContentElement('youtubePlugin', 'txtEmbed').disable();
337
- }
338
- else if (!disabled.length || !disabled.includes('txtEmbed')) {
339
- el.getDialog().getContentElement('youtubePlugin', 'txtEmbed').enable();
340
- }
341
-
342
- if (video && time) {
343
- var seconds = timeParamToSeconds(time);
344
- var hms = secondsToHms(seconds);
345
- el.getDialog().getContentElement('youtubePlugin', 'txtStartAt').setValue(hms);
346
- }
347
- }
348
-
349
- function handleEmbedChange(el, api) {
350
- if (el.getValue().length > 0) {
351
- el.getDialog().getContentElement('youtubePlugin', 'txtUrl').disable();
352
- }
353
- else {
354
- el.getDialog().getContentElement('youtubePlugin', 'txtUrl').enable();
355
- }
356
- }
357
-
358
-
359
- /**
360
- * JavaScript function to match (and return) the video Id
361
- * of any valid Youtube Url, given as input string.
362
- * @author: Stephan Schmitz <eyecatchup@gmail.com>
363
- * @url: http://stackoverflow.com/a/10315969/624466
364
- */
365
- function ytVidId(url) {
366
- var p = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
367
- return (url.match(p)) ? RegExp.$1 : false;
368
- }
369
-
370
- /**
371
- * Matches and returns time param in YouTube Urls.
372
- */
373
- function ytVidTime(url) {
374
- var p = /t=([0-9hms]+)/;
375
- return (url.match(p)) ? RegExp.$1 : false;
376
- }
377
-
378
- /**
379
- * Converts time in hms format to seconds only
380
- */
381
- function hmsToSeconds(time) {
382
- var arr = time.split(':'), s = 0, m = 1;
383
-
384
- while (arr.length > 0) {
385
- s += m * parseInt(arr.pop(), 10);
386
- m *= 60;
387
- }
388
-
389
- return s;
390
- }
391
-
392
- /**
393
- * Converts seconds to hms format
394
- */
395
- function secondsToHms(seconds) {
396
- var h = Math.floor(seconds / 3600);
397
- var m = Math.floor((seconds / 60) % 60);
398
- var s = seconds % 60;
399
-
400
- var pad = function (n) {
401
- n = String(n);
402
- return n.length >= 2 ? n : "0" + n;
403
- };
404
-
405
- if (h > 0) {
406
- return pad(h) + ':' + pad(m) + ':' + pad(s);
407
- }
408
- else {
409
- return pad(m) + ':' + pad(s);
410
- }
411
- }
412
-
413
- /**
414
- * Converts time in youtube t-param format to seconds
415
- */
416
- function timeParamToSeconds(param) {
417
- var componentValue = function (si) {
418
- var regex = new RegExp('(\\d+)' + si);
419
- return param.match(regex) ? parseInt(RegExp.$1, 10) : 0;
420
- };
421
-
422
- return componentValue('h') * 3600
423
- + componentValue('m') * 60
424
- + componentValue('s');
425
- }
426
-
427
- /**
428
- * Converts seconds into youtube t-param value, e.g. 1h4m30s
429
- */
430
- function secondsToTimeParam(seconds) {
431
- var h = Math.floor(seconds / 3600);
432
- var m = Math.floor((seconds / 60) % 60);
433
- var s = seconds % 60;
434
- var param = '';
435
-
436
- if (h > 0) {
437
- param += h + 'h';
438
- }
439
-
440
- if (m > 0) {
441
- param += m + 'm';
442
- }
443
-
444
- if (s > 0) {
445
- param += s + 's';
446
- }
447
-
448
- return param;
449
- }
@@ -1,61 +0,0 @@
1
- //= require jquery
2
- //= require jquery_ujs
3
- //= require jquery3
4
- //= require popper
5
- //= require bootstrap-datepicker-1.8.0
6
- //= require bootstrap-datepicker-1.8.0.ru.min
7
- //= require bootstrap-sprockets
8
- //= require font_awesome5
9
- //= require ckeditor/init
10
- //= require clipboard
11
- //= require_tree .
12
-
13
- window.i18n_locale = function(locale) {
14
- switch (locale) {
15
- case 'en':
16
- return({ date_format: 'yyyy-mm-dd', locale: locale });
17
- break;
18
- case 'ru':
19
- return({ date_format: 'dd.mm.yyyy', locale: locale });
20
- break;
21
- default:
22
- return({ date_format: 'yyyy-mm-dd', locale: locale });
23
- break;
24
- }
25
- }
26
-
27
- $(document).ready(function() {
28
- if (!(window.current_locale)) {
29
- console.log('You should set `window.current_locale` before all Javascript code');
30
- }
31
-
32
- if ($('.date_picker').length != 0) {
33
- $('.date_picker').datepicker({
34
- format: window.current_locale.date_format,
35
- language: window.current_locale.locale
36
- });
37
- }
38
-
39
- $('.link').click(function() {
40
- const href = $(this).data('href');
41
- if (href) {
42
- location.href = href;
43
- } else {
44
- const anchor = $(this).data('anchor');
45
- if (!$(anchor).offset() == undefined) {
46
- $(window).scrollTop($(anchor).offset().top);
47
- }
48
- };
49
- });
50
-
51
- let clipboard = new Clipboard('.clipboard-btn');
52
- $(function () {
53
- $('[data-toggle="popover"]').popover()
54
- })
55
-
56
- const url = new URL(window.location.href);
57
- const focusElementSelector = url.searchParams.get('focus');
58
- if (!$(focusElementSelector).offset() == undefined) {
59
- $(window).scrollTop($(focusElementSelector).offset().top);
60
- }
61
- });
@@ -1,59 +0,0 @@
1
- /*
2
- *= require_tree .
3
- *= require_self
4
- */
5
-
6
- @import 'font_awesome5_webfont'
7
- @import 'font_awesome5'
8
- @import 'bootstrap'
9
-
10
- .datepicker-inline
11
- display: none !important
12
-
13
- .link
14
- cursor: pointer
15
- &:hover
16
- opacity: 0.8
17
-
18
- .circle
19
- border-radius: 50%
20
-
21
- .container
22
- padding-top: 2rem
23
-
24
- td
25
- &.actions
26
- width: 8rem
27
-
28
- .icon-in-navbar
29
- font-size: 15pt
30
-
31
- .notifications
32
- a
33
- margin-right: 25px
34
- span.badge:hover
35
- filter: brightness(90%)
36
-
37
- .smart_button
38
- float: right
39
- margin-bottom: 0
40
-
41
- .scrollable
42
- height: auto
43
- max-height: 30em
44
- overflow-x: hidden
45
-
46
- .row-fluid.filters
47
- width: 100%
48
- display: flex
49
-
50
- select
51
- width: 100%
52
-
53
- .submit
54
- display: flex
55
- flex-direction: row-reverse
56
-
57
- .dates_filter
58
- display: flex
59
- flex-direction: row
@@ -1,142 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # FIXME: use default `require` method
4
- load "#{Tramway.root}/lib/tramway/class_name_helpers.rb"
5
- load "#{Tramway.root}/lib/tramway/record_routes_helper.rb"
6
-
7
- # FIXME: configurate load_path
8
- load "#{Tramway.root}/app/controllers/tramway/concerns/auth_management.rb"
9
- load "#{Tramway.root}/app/controllers/tramway/concerns/filtering.rb"
10
-
11
- class Tramway::ApplicationController < ActionController::Base
12
- include Tramway::ClassNameHelpers
13
- include Tramway::Concerns::AuthManagement
14
- include Tramway::Concerns::Filtering
15
- include Tramway::RecordRoutesHelper
16
-
17
- before_action :application
18
- before_action :load_extensions
19
- before_action :notifications
20
- before_action :notifications_count
21
- before_action :collections_counts, if: :model_given?
22
- before_action :authenticate_user!
23
- before_action :check_available!
24
- before_action :check_available_scope!, if: :model_given?, only: :index
25
-
26
- protect_from_forgery with: :exception
27
-
28
- protected
29
-
30
- def check_available!
31
- return if session_path?
32
-
33
- return unless !model_given? && !form_given?
34
-
35
- Tramway::Error.raise_error :tramway, :application_controller, :model_or_form_not_available
36
- end
37
-
38
- def check_available_scope!
39
- raise 'Scope is not available' if params[:scope].present? && !available_scope_given?
40
- end
41
-
42
- def collections_counts
43
- @counts = decorator_class.collections.reduce({}) do |hash, collection|
44
- records = model_class.public_send(collection)
45
- records = filtering records
46
- records = list_filtering records
47
-
48
- hash.merge! collection => records.public_send(current_user_role_scope, current_user.id).count
49
- end
50
- end
51
-
52
- def notifications
53
- if current_user
54
- @notifications ||= Tramway.notificable_queries&.reduce({}) do |hash, notification|
55
- hash.merge! notification[0] => notification[1].call(current_user)
56
- end
57
- end
58
- @notifications
59
- end
60
-
61
- def notifications_count
62
- @notifications_count = notifications&.reduce(0) do |count, notification|
63
- count += notification[1].count # rubocop:disable Lint/UselessAssignment
64
- end
65
- end
66
-
67
- include Tramway::ClassNameHelpers
68
-
69
- def model_class
70
- model_class_name(params[:model] || params[:form])
71
- end
72
-
73
- def decorator_class
74
- decorator_class_name
75
- end
76
-
77
- def admin_form_class
78
- class_name = "::#{current_user.role.camelize}::#{model_class}Form"
79
-
80
- unless defined? class_name
81
- Tramway::Error.raise_error(
82
- :tramway,
83
- :application,
84
- :create_form_for_role,
85
- role: current_user.role,
86
- model_class:,
87
- class_name:
88
- )
89
- end
90
-
91
- class_name.constantize
92
- end
93
-
94
- def model_given?
95
- current_user.present? && (available_models_given? || singleton_models_given?)
96
- end
97
-
98
- def form_given?
99
- Tramway.forms.include? params[:form].underscore.sub(%r{^admin/}, '').sub(/_form$/, '') if params[:form].present?
100
- end
101
-
102
- def available_scope_given?
103
- params[:scope].present? && params[:scope].in?(decorator_class.collections.map(&:to_s))
104
- end
105
-
106
- def available_models_given?
107
- check_models_given? :available
108
- end
109
-
110
- def singleton_models_given?
111
- check_models_given? :singleton
112
- end
113
-
114
- private
115
-
116
- def check_models_given?(model_type)
117
- models = Tramway.send("#{model_type}_models", role: current_user.role)
118
- models.any? && params[:model].in?(models.map(&:to_s))
119
- end
120
-
121
- def session_path?
122
- request.path.in?(['/admin/session/new', '/admin/session', '/admin/sign_out'])
123
- end
124
-
125
- def application
126
- return unless Tramway.application
127
-
128
- @application ||= Tramway.application&.model_class&.first || Tramway.application
129
- end
130
-
131
- def load_extensions
132
- Tramway::Extensions.load if defined? Tramway::Extensions
133
- end
134
-
135
- def authenticated_user
136
- (defined?(current_user) && current_user.try(:model)) || (defined?(current_user) && current_user.model)
137
- end
138
-
139
- def current_user_role_scope
140
- "#{current_user.role}_scope"
141
- end
142
- end