card-mod-script 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/assets/script/decko/autosave.js.coffee +30 -0
  3. data/assets/script/decko/bridge.js.coffee +31 -0
  4. data/assets/script/decko/card_menu.js.coffee +26 -0
  5. data/assets/script/decko/components.js.coffee +49 -0
  6. data/assets/script/decko/decko.js.coffee +82 -0
  7. data/assets/script/decko/doubleclick.js.coffee +30 -0
  8. data/assets/script/decko/editor.js.coffee +57 -0
  9. data/assets/script/decko/filter.js.coffee +183 -0
  10. data/assets/script/decko/filter_items.js.coffee +128 -0
  11. data/assets/script/decko/filter_links.js.coffee +81 -0
  12. data/assets/script/decko/follow.js.coffee +22 -0
  13. data/assets/script/decko/layout.js.coffee +76 -0
  14. data/assets/script/decko/link_editor.js.coffee +61 -0
  15. data/assets/script/decko/mod.js.coffee +79 -0
  16. data/assets/script/decko/modal.js.coffee +113 -0
  17. data/assets/script/decko/name_editor.js.coffee +40 -0
  18. data/assets/script/decko/navbox.js.coffee +74 -0
  19. data/assets/script/decko/nest_editor.js.coffee +166 -0
  20. data/assets/script/decko/nest_editor_name.js.coffee +102 -0
  21. data/assets/script/decko/nest_editor_options.js.coffee +93 -0
  22. data/assets/script/decko/nest_editor_rules.js.coffee +3 -0
  23. data/assets/script/decko/overlay.js.coffee +54 -0
  24. data/assets/script/decko/pointer_config.js.coffee +79 -0
  25. data/assets/script/decko/pointer_list_editor.js.coffee +67 -0
  26. data/assets/script/decko/recaptcha.js.coffee +19 -0
  27. data/assets/script/decko/selectable_filtered_content.js.coffee +12 -0
  28. data/assets/script/decko/slot.js.coffee +182 -0
  29. data/assets/script/decko/slot_ready.js.coffee +12 -0
  30. data/assets/script/decko/slotter.js.coffee +268 -0
  31. data/assets/script/decko/type_editor.js.coffee +21 -0
  32. data/assets/script/decko/upload.js.coffee +64 -0
  33. data/assets/script/jquery-ui.min.js +13 -0
  34. data/assets/script/jquery.autosize.js +274 -0
  35. data/assets/script/manifest.yml +57 -0
  36. data/init/early/init_execjs.rb +3 -0
  37. data/set/abstract/00_script.rb +30 -31
  38. data/set/abstract/01_asset_script.rb +0 -16
  39. data/set/abstract/{script_asset_list.rb → script_group.rb} +12 -13
  40. data/set/all/head_javascript.rb +12 -8
  41. data/set/right/script.rb +1 -14
  42. data/set/type/local_script_folder_group.rb +2 -2
  43. data/set/type/local_script_manifest_group.rb +1 -1
  44. data/set/type_plus_right/mod/script.rb +56 -0
  45. data/set/type_plus_right/set/script.rb +7 -0
  46. data/vendor/jquery_file_upload/LICENSE.txt +11 -12
  47. data/vendor/jquery_file_upload/README.md +189 -72
  48. data/vendor/jquery_file_upload/SECURITY.md +227 -0
  49. data/vendor/jquery_file_upload/VULNERABILITIES.md +118 -0
  50. data/vendor/jquery_file_upload/cors/postmessage.html +68 -58
  51. data/vendor/jquery_file_upload/cors/result.html +12 -10
  52. data/vendor/jquery_file_upload/css/jquery.fileupload-ui.css +24 -13
  53. data/vendor/jquery_file_upload/css/jquery.fileupload.css +3 -4
  54. data/vendor/jquery_file_upload/docker-compose.yml +55 -0
  55. data/vendor/jquery_file_upload/index.html +332 -230
  56. data/vendor/jquery_file_upload/js/cors/jquery.postmessage-transport.js +109 -109
  57. data/vendor/jquery_file_upload/js/cors/jquery.xdr-transport.js +81 -73
  58. data/vendor/jquery_file_upload/js/demo.js +75 -0
  59. data/vendor/jquery_file_upload/js/jquery.fileupload-audio.js +82 -94
  60. data/vendor/jquery_file_upload/js/jquery.fileupload-image.js +321 -300
  61. data/vendor/jquery_file_upload/js/jquery.fileupload-process.js +138 -146
  62. data/vendor/jquery_file_upload/js/jquery.fileupload-ui.js +737 -692
  63. data/vendor/jquery_file_upload/js/jquery.fileupload-validate.js +91 -97
  64. data/vendor/jquery_file_upload/js/jquery.fileupload-video.js +82 -94
  65. data/vendor/jquery_file_upload/js/jquery.fileupload.js +1569 -1451
  66. data/vendor/jquery_file_upload/js/jquery.iframe-transport.js +208 -205
  67. data/vendor/jquery_file_upload/js/vendor/jquery.ui.widget.js +397 -340
  68. data/vendor/jquery_file_upload/package-lock.json +6853 -0
  69. data/vendor/jquery_file_upload/package.json +71 -10
  70. data/vendor/jquery_file_upload/server/gae-python/app.yaml +11 -10
  71. data/vendor/jquery_file_upload/server/php/Dockerfile +23 -17
  72. data/vendor/jquery_file_upload/server/php/UploadHandler.php +206 -137
  73. data/vendor/jquery_file_upload/server/php/php.ini +5 -0
  74. data/vendor/jquery_file_upload/test/index.html +36 -159
  75. data/vendor/jquery_file_upload/test/unit.js +989 -0
  76. data/vendor/jquery_file_upload/test/vendor/chai.js +10854 -0
  77. data/vendor/jquery_file_upload/test/vendor/mocha.css +325 -0
  78. data/vendor/jquery_file_upload/test/vendor/mocha.js +18178 -0
  79. data/vendor/jquery_file_upload/wdio/LICENSE.txt +20 -0
  80. data/vendor/jquery_file_upload/wdio/assets/black+white-3x2.jpg +0 -0
  81. data/vendor/jquery_file_upload/wdio/assets/black+white-60x40.gif +0 -0
  82. data/vendor/jquery_file_upload/wdio/conf/chrome.js +40 -0
  83. data/vendor/jquery_file_upload/wdio/conf/firefox.js +25 -0
  84. data/vendor/jquery_file_upload/wdio/hooks/index.js +36 -0
  85. data/vendor/jquery_file_upload/wdio/test/pages/file-upload.js +79 -0
  86. data/vendor/jquery_file_upload/wdio/test/specs/01-file-upload.js +25 -0
  87. data/vendor/jquery_file_upload/wdio/wdio.conf.js +4 -0
  88. metadata +66 -50
  89. data/file/mod_script_script_decko_machine_output/file.js +0 -2710
  90. data/file/mod_script_script_jquery_machine_output/file.js +0 -12924
  91. data/lib/javascript/script_html5shiv_printshiv.js +0 -1
  92. data/set/self/script_html5shiv_printshiv.rb +0 -11
  93. data/set/self/script_mods.rb +0 -1
  94. data/set/type/mod_script_assets.rb +0 -21
  95. data/vendor/jquery_file_upload/CONTRIBUTING.md +0 -15
  96. data/vendor/jquery_file_upload/angularjs.html +0 -211
  97. data/vendor/jquery_file_upload/basic-plus.html +0 -226
  98. data/vendor/jquery_file_upload/basic.html +0 -136
  99. data/vendor/jquery_file_upload/bower-version-update.js +0 -16
  100. data/vendor/jquery_file_upload/bower.json +0 -64
  101. data/vendor/jquery_file_upload/css/jquery-ui-demo-ie8.css +0 -21
  102. data/vendor/jquery_file_upload/css/jquery-ui-demo.css +0 -67
  103. data/vendor/jquery_file_upload/css/style.css +0 -15
  104. data/vendor/jquery_file_upload/jquery-ui.html +0 -252
  105. data/vendor/jquery_file_upload/js/app.js +0 -101
  106. data/vendor/jquery_file_upload/js/jquery.fileupload-angular.js +0 -437
  107. data/vendor/jquery_file_upload/js/jquery.fileupload-jquery-ui.js +0 -161
  108. data/vendor/jquery_file_upload/js/main.js +0 -75
  109. data/vendor/jquery_file_upload/server/gae-go/app/main.go +0 -361
  110. data/vendor/jquery_file_upload/server/gae-go/app.yaml +0 -12
  111. data/vendor/jquery_file_upload/server/gae-go/static/favicon.ico +0 -0
  112. data/vendor/jquery_file_upload/server/gae-go/static/robots.txt +0 -2
  113. data/vendor/jquery_file_upload/server/php/docker-compose.yml +0 -9
  114. data/vendor/jquery_file_upload/test/test.js +0 -1292
@@ -1,2710 +0,0 @@
1
- // mod.js.coffee
2
- (function() {
3
- window.decko || (window.decko = {});
4
-
5
- $(window).ready(function() {
6
- var firstShade;
7
- $('body').on('click', '._stop_propagation', function(event) {
8
- return event.stopPropagation();
9
- });
10
- $('body').on('click', '._prevent_default', function(event) {
11
- return event.preventDefault();
12
- });
13
- $('body').on('mouseenter', 'a[data-hover-text]', function() {
14
- var text;
15
- text = $(this).text();
16
- $(this).data("original-text", text);
17
- return $(this).text($(this).data("hover-text"));
18
- });
19
- $('body').on('mouseleave', 'a[data-hover-text]', function() {
20
- return $(this).text($(this).data("original-text"));
21
- });
22
- $('body').on('click', '.shade-view h1', function() {
23
- var toggleThis;
24
- toggleThis = $(this).slot().find('.shade-content').is(':hidden');
25
- decko.toggleShade($(this).closest('.pointer-list').find('.shade-content:visible').parent());
26
- if (toggleThis) {
27
- return decko.toggleShade($(this).slot());
28
- }
29
- });
30
- if (firstShade = $('.shade-view h1')[0]) {
31
- $(firstShade).trigger('click');
32
- }
33
- $('body').on('click', '.open-slow-items', function() {
34
- var panel;
35
- panel = $(this).closest('.panel-group');
36
- panel.find('.open-slow-items').removeClass('open-slow-items').addClass('close-slow-items');
37
- panel.find('.toggle-fast-items').text("show < 100ms");
38
- panel.find('.duration-ok').hide();
39
- return panel.find('.panel-danger > .panel-collapse').collapse('show').find('a > span').addClass('show-fast-items');
40
- });
41
- $('body').on('click', '.close-slow-items', function() {
42
- var panel;
43
- panel = $(this).closest('.panel-group');
44
- panel.find('.close-slow-items').removeClass('close-slow-items').addClass('open-slow-items');
45
- panel.find('.toggle-fast-items').text("hide < 100ms");
46
- panel.find('.panel-danger > .panel-collapse').collapse('hide').removeClass('show-fast-items');
47
- return panel.find('.duration-ok').show();
48
- });
49
- $('body').on('click', '.toggle-fast-items', function() {
50
- var panel;
51
- panel = $(this).closest('.panel-group');
52
- if ($(this).text() === 'hide < 100ms') {
53
- panel.find('.duration-ok').hide();
54
- return $(this).text("show < 100ms");
55
- } else {
56
- panel.find('.duration-ok').show();
57
- return $(this).text("hide < 100ms");
58
- }
59
- });
60
- return $('body').on('click', '.show-fast-items', function(event) {
61
- var panel;
62
- $(this).removeClass('show-fast-items');
63
- panel = $(this).closest('.panel-group');
64
- panel.find('.duration-ok').show();
65
- panel.find('.show-fast-items').removeClass('show-fast-items');
66
- panel.find('.panel-collapse').collapse('show');
67
- return event.stopPropagation();
68
- });
69
- });
70
-
71
- $.extend(decko, {
72
- toggleShade: function(shadeSlot) {
73
- shadeSlot.find('.shade-content').slideToggle(1000);
74
- return shadeSlot.find('.glyphicon').toggleClass('glyphicon-triangle-right glpyphicon-triangle-bottom');
75
- }
76
- });
77
-
78
- }).call(this);
79
-
80
- // editor.js.coffee
81
- (function() {
82
- $.extend(decko, {
83
- initializeEditors: function(range, map) {
84
- if (map == null) {
85
- map = decko.editorInitFunctionMap;
86
- }
87
- return $.each(map, function(selector, fn) {
88
- return $.each(range.find(selector), function() {
89
- return fn.call($(this));
90
- });
91
- });
92
- },
93
- editorContentFunctionMap: {},
94
- editorInitFunctionMap: {
95
- 'textarea': function() {
96
- return $(this).autosize();
97
- },
98
- '.file-upload': function() {
99
- return decko.upload_file(this);
100
- },
101
- '.etherpad-textarea': function() {
102
- return $(this).closest('form').find('.edit-submit-button').attr('class', 'etherpad-submit-button');
103
- }
104
- },
105
- addEditor: function(selector, init, get_content) {
106
- decko.editorContentFunctionMap[selector] = get_content;
107
- return decko.editorInitFunctionMap[selector] = init;
108
- }
109
- });
110
-
111
- jQuery.fn.extend({
112
- setContentFieldsFromMap: function(map) {
113
- var this_form;
114
- if (map == null) {
115
- map = decko.editorContentFunctionMap;
116
- }
117
- this_form = $(this);
118
- return $.each(map, function(selector, fn) {
119
- return this_form.setContentFields(selector, fn);
120
- });
121
- },
122
- setContentFields: function(selector, fn) {
123
- return $.each(this.find(selector), function() {
124
- return $(this).setContentField(fn);
125
- });
126
- },
127
- setContentField: function(fn) {
128
- var field, init_val, new_val;
129
- field = this.closest('.card-editor').find('.d0-card-content');
130
- init_val = field.val();
131
- new_val = fn.call(this);
132
- field.val(new_val);
133
- if (init_val !== new_val) {
134
- return field.change();
135
- }
136
- }
137
- });
138
-
139
- $(window).ready(function() {
140
- setTimeout((function() {
141
- return decko.initializeEditors($('body > :not(.modal)'));
142
- }), 10);
143
- return $('body').on('submit', '.card-form', function() {
144
- $(this).setContentFieldsFromMap();
145
- $(this).find('.d0-card-content').attr('no-autosave', 'true');
146
- return true;
147
- });
148
- });
149
-
150
- setInterval((function() {
151
- return $('.card-form').setContentFieldsFromMap();
152
- }), 20000);
153
-
154
- }).call(this);
155
-
156
- // name_editor.js.coffee
157
- (function() {
158
- var checkName, checkNameAfterTyping, referenceConfirm;
159
-
160
- checkNameAfterTyping = null;
161
-
162
- $(window).ready(function() {
163
- $('body').on('click', '._renamer-updater', function() {
164
- return $(this).closest('form').find('#card_update_referers').val('true');
165
- });
166
- $('body').on('submit', '._rename-form', function() {
167
- var confirm, f;
168
- f = $(this);
169
- confirm = f.find('.alert');
170
- if (confirm.is(':hidden')) {
171
- referenceConfirm(f);
172
- confirm.show('blind');
173
- return false;
174
- }
175
- });
176
- return $('body').on('keyup', '.name-editor input', function(event) {
177
- var input;
178
- if (checkNameAfterTyping) {
179
- clearTimeout(checkNameAfterTyping);
180
- }
181
- input = $(this);
182
- if (event.which === 13) {
183
- checkName(input);
184
- return checkNameAfterTyping = null;
185
- } else {
186
- return checkNameAfterTyping = setTimeout(function() {
187
- checkName(input);
188
- return checkNameAfterTyping = null;
189
- }, 400);
190
- }
191
- });
192
- });
193
-
194
- referenceConfirm = function(form) {
195
- var btn, confirm;
196
- confirm = form.find('._rename-reference-confirm');
197
- if (!(confirm.data('referer-count') > 0)) {
198
- return;
199
- }
200
- confirm.show();
201
- btn = form.find('._renamer-updater');
202
- btn.show();
203
- return btn.focus();
204
- };
205
-
206
- checkName = function(box) {
207
- var name;
208
- name = box.val();
209
- return decko.pingName(name, function(data) {
210
- var ed, href, leg, msg, qualifier, slot_id, status;
211
- if (box.val() !== name) {
212
- return null;
213
- }
214
- status = data['status'];
215
- if (status) {
216
- ed = box.parent();
217
- leg = box.closest('fieldset').find('legend');
218
- msg = leg.find('.name-messages');
219
- if (!msg[0]) {
220
- msg = $('<span class="name-messages"></span>');
221
- leg.append(msg != null);
222
- }
223
- ed.removeClass('real-name virtual-name known-name');
224
- slot_id = box.slot().data('cardId');
225
- if (status !== 'unknown' && !(slot_id && parseInt(slot_id) === data['id'])) {
226
- ed.addClass(status + '-name known-name');
227
- qualifier = status === 'virtual' ? 'in virtual' : 'already in';
228
- href = decko.path(data['url_key']);
229
- return msg.html("\"<a href='" + href + "'>" + name + "</a>\" " + qualifier + " use");
230
- } else {
231
- return msg.html('');
232
- }
233
- }
234
- });
235
- };
236
-
237
- }).call(this);
238
-
239
- // autosave.js.coffee
240
- (function() {
241
- jQuery.fn.extend({
242
- autosave: function() {
243
- var form_data, id, multi, reportee, slot, submit_url;
244
- slot = this.slot();
245
- if (this.attr('no-autosave')) {
246
- return;
247
- }
248
- multi = this.closest('.form-group');
249
- if (multi[0]) {
250
- if (!(id = multi.data('cardId'))) {
251
- return;
252
- }
253
- reportee = ': ' + multi.data('cardName');
254
- } else {
255
- id = slot.data('cardId');
256
- reportee = '';
257
- }
258
- if (!id) {
259
- return;
260
- }
261
- submit_url = decko.path('update/~' + id);
262
- form_data = $('#edit_card_' + id).serializeArray().reduce((function(obj, item) {
263
- obj[item.name] = item.value;
264
- return obj;
265
- }), {
266
- 'draft': 'true',
267
- 'success[view]': 'blank'
268
- });
269
- return $.ajax(submit_url, {
270
- data: form_data,
271
- type: 'POST'
272
- });
273
- }
274
- });
275
-
276
- $(window).ready(function() {
277
- return $('body').on('change', '.autosave .d0-card-content', function() {
278
- var content_field;
279
- content_field = $(this);
280
- return setTimeout((function() {
281
- return content_field.autosave();
282
- }), 500);
283
- });
284
- });
285
-
286
- }).call(this);
287
-
288
- // doubleclick.js.coffee
289
- (function() {
290
- var doubleClickActive, doubleClickActiveMap, doubleClickApplies, triggerDoubleClickEditingOn;
291
-
292
- doubleClickActiveMap = {
293
- off: false,
294
- on: true,
295
- signed_in: decko.currentUserId
296
- };
297
-
298
- doubleClickActive = function() {
299
- return doubleClickActiveMap[decko.doubleClick];
300
- };
301
-
302
- doubleClickApplies = function(el) {
303
- if (['.nodblclick', '.d0-card-header', '.card-editor'].some(function(klass) {
304
- return el.closest(klass)[0];
305
- })) {
306
- return false;
307
- }
308
- return el.slot().find('.card-editor')[0] == null;
309
- };
310
-
311
- triggerDoubleClickEditingOn = function(el) {
312
- var edit_link, edit_view, slot, url;
313
- slot = el.slot();
314
- edit_link = decko.slotEditLink(slot);
315
- if (edit_link) {
316
- return edit_link.click();
317
- } else {
318
- edit_view = decko.slotEditView(slot);
319
- url = decko.path("~" + (slot.data('cardId')) + "?view=" + edit_view);
320
- return slot.reloadSlot(url);
321
- }
322
- };
323
-
324
- $(window).ready(function() {
325
- if (doubleClickActive()) {
326
- return $('body').on('dblclick', 'div', function(_event) {
327
- if (doubleClickApplies($(this))) {
328
- triggerDoubleClickEditingOn($(this));
329
- }
330
- return false;
331
- });
332
- }
333
- });
334
-
335
- }).call(this);
336
-
337
- // layout.js.coffee
338
- (function() {
339
- var containerClass, doubleSidebar, sidebarToggle, singleSidebar, toggleButton, wrapDeckoLayout, wrapSidebarToggle;
340
-
341
- wrapDeckoLayout = function() {
342
- var $footer;
343
- $footer = $('body > footer').first();
344
- $('body > article, body > aside').wrapAll("<div class='" + (containerClass()) + "'/>");
345
- $('body > div > article, body > div > aside').wrapAll('<div class="row row-offcanvas">');
346
- if ($footer) {
347
- return $('body').append($footer);
348
- }
349
- };
350
-
351
- wrapSidebarToggle = function(toggle, flex) {
352
- return "<div class='container'><div class='row " + flex + "'>" + toggle + "</div></div>";
353
- };
354
-
355
- containerClass = function() {
356
- if ($('body').hasClass('fluid')) {
357
- return "container-fluid";
358
- } else {
359
- return "container";
360
- }
361
- };
362
-
363
- toggleButton = function(side) {
364
- var icon_dir;
365
- icon_dir = side === 'left' ? 'right' : 'left';
366
- return "<button class='offcanvas-toggle btn btn-secondary " + ("d-sm-none' data-toggle='offcanvas-" + side + "'>") + ("<i class='material-icons'>chevron_" + icon_dir + "</i></button>");
367
- };
368
-
369
- sidebarToggle = function(side) {
370
- if (side === "both") {
371
- return wrapSidebarToggle(toggleButton("left") + toggleButton("right"), "flex-row justify-content-between");
372
- } else if (side === "left") {
373
- return wrapSidebarToggle(toggleButton("left"), "flex-row");
374
- } else {
375
- return wrapSidebarToggle(toggleButton("right"), "flex-row-reverse");
376
- }
377
- };
378
-
379
- singleSidebar = function(side) {
380
- var $article, $aside;
381
- $article = $('body > article').first();
382
- $aside = $('body > aside').first();
383
- $article.addClass("col-xs-12 col-sm-9");
384
- $aside.addClass("col-xs-6 col-sm-3 sidebar-offcanvas sidebar-offcanvas-" + side);
385
- if (side === 'left') {
386
- $('body').append($aside).append($article);
387
- } else {
388
- $('body').append($article).append($aside);
389
- }
390
- wrapDeckoLayout();
391
- return $article.prepend(sidebarToggle(side));
392
- };
393
-
394
- doubleSidebar = function() {
395
- var $article, $asideLeft, $asideRight, sideClass, toggles;
396
- $article = $('body > article').first();
397
- $asideLeft = $('body > aside').first();
398
- $asideRight = $($('body > aside')[1]);
399
- $article.addClass("col-xs-12 col-sm-6");
400
- sideClass = "col-xs-6 col-sm-3 sidebar-offcanvas";
401
- $asideLeft.addClass(sideClass + " sidebar-offcanvas-left");
402
- $asideRight.addClass(sideClass + " sidebar-offcanvas-right");
403
- $('body').append($asideLeft).append($article).append($asideRight);
404
- wrapDeckoLayout();
405
- toggles = sidebarToggle('both');
406
- return $article.prepend(toggles);
407
- };
408
-
409
- $.fn.extend({
410
- toggleText: function(a, b) {
411
- this.text(this.text() === b ? a : b);
412
- return this;
413
- }
414
- });
415
-
416
- $(window).ready(function() {
417
- switch (false) {
418
- case !$('body').hasClass('right-sidebar'):
419
- singleSidebar('right');
420
- break;
421
- case !$('body').hasClass('left-sidebar'):
422
- singleSidebar('left');
423
- break;
424
- case !$('body').hasClass('two-sidebar'):
425
- doubleSidebar();
426
- }
427
- $('[data-toggle="offcanvas-left"]').click(function() {
428
- $('.row-offcanvas').removeClass('right-active').toggleClass('left-active');
429
- return $(this).find('i.material-icons').toggleText('chevron_left', 'chevron_right');
430
- });
431
- return $('[data-toggle="offcanvas-right"]').click(function() {
432
- $('.row-offcanvas').removeClass('left-active').toggleClass('right-active');
433
- return $(this).find('i.material-icons').toggleText('chevron_left', 'chevron_right');
434
- });
435
- });
436
-
437
- }).call(this);
438
-
439
- // navbox.js.coffee
440
- (function() {
441
- var formatNavboxItem, formatNavboxSelectedItem, navboxItem, navboxSelect, navboxize;
442
-
443
- $(window).ready(function() {
444
- var navbox;
445
- navbox = $('._navbox');
446
- navbox.select2({
447
- placeholder: navbox.attr("placeholder"),
448
- escapeMarkup: function(markup) {
449
- return markup;
450
- },
451
- minimumInputLength: 1,
452
- maximumSelectionSize: 1,
453
- ajax: {
454
- delay: 200,
455
- url: decko.path(':search.json'),
456
- data: function(params) {
457
- return {
458
- query: {
459
- keyword: params.term
460
- },
461
- view: "complete"
462
- };
463
- },
464
- processResults: function(data) {
465
- return {
466
- results: navboxize(data)
467
- };
468
- },
469
- cache: true
470
- },
471
- templateResult: formatNavboxItem,
472
- templateSelection: formatNavboxSelectedItem,
473
- multiple: true,
474
- containerCssClass: 'select2-navbox-autocomplete',
475
- dropdownCssClass: 'select2-navbox-dropdown',
476
- width: "100%!important"
477
- });
478
- return navbox.on("select2:select", function(e) {
479
- return navboxSelect(e);
480
- });
481
- });
482
-
483
- formatNavboxItem = function(i) {
484
- if (i.loading) {
485
- return i.text;
486
- }
487
- return '<i class="material-icons">' + i.icon + '</i>' + '<span class="navbox-item-label">' + i.prefix + ':</span> ' + '<span class="navbox-item-value">' + i.label + '</span>';
488
- };
489
-
490
- formatNavboxSelectedItem = function(i) {
491
- if (!i.icon) {
492
- return i.text;
493
- }
494
- return '<i class="material-icons">' + i.icon + '</i>' + '<span class="navbox-item-value">' + i.label + '</span>';
495
- };
496
-
497
- navboxize = function(results) {
498
- var items, term;
499
- items = [];
500
- term = results.term;
501
- if (results["search"]) {
502
- items.push(navboxItem({
503
- prefix: "search",
504
- id: term,
505
- text: term
506
- }));
507
- }
508
- $.each(['add', 'new'], function(index, key) {
509
- var val;
510
- if (val = results[key]) {
511
- return items.push(navboxItem({
512
- prefix: key,
513
- icon: "add",
514
- text: val[0],
515
- href: val[1]
516
- }));
517
- }
518
- });
519
- $.each(results['goto'], function(index, val) {
520
- var i;
521
- i = navboxItem({
522
- prefix: "go to",
523
- id: index,
524
- icon: "arrow_forward",
525
- text: val[0],
526
- href: val[1],
527
- label: val[2]
528
- });
529
- return items.push(i);
530
- });
531
- return items;
532
- };
533
-
534
- navboxItem = function(data) {
535
- data.id || (data.id = data.prefix);
536
- data.icon || (data.icon = data.prefix);
537
- data.label || (data.label = '<strong class="highlight">' + data.text + '</strong>');
538
- return data;
539
- };
540
-
541
- navboxSelect = function(event) {
542
- var item;
543
- item = event.params.data;
544
- if (item.href) {
545
- window.location = decko.path(item.href);
546
- } else {
547
- $(event.target).closest('form').submit();
548
- }
549
- return $(event.target).attr('disabled', 'disabled');
550
- };
551
-
552
- }).call(this);
553
-
554
- // upload.js.coffee
555
- (function() {
556
- $.extend(decko, {
557
- upload_file: function(fileupload) {
558
- var $_fileupload, url;
559
- $(fileupload).on('fileuploadsubmit', function(e, data) {
560
- var $_this, card_name, type_id;
561
- $_this = $(this);
562
- card_name = $_this.siblings(".attachment_card_name:first").attr("name");
563
- type_id = $_this.siblings("#attachment_type_id").val();
564
- return data.formData = {
565
- "card[type_id]": type_id,
566
- "attachment_upload": card_name
567
- };
568
- });
569
- $_fileupload = $(fileupload);
570
- if ($_fileupload.closest("form").attr("action").indexOf("update") > -1) {
571
- url = "card/update/" + $(fileupload).siblings("#file_card_name").val();
572
- } else {
573
- url = "card/create";
574
- }
575
- return $(fileupload).fileupload({
576
- url: decko.path(url),
577
- dataType: 'html',
578
- done: decko.doneFile,
579
- add: decko.chooseFile,
580
- progressall: decko.progressallFile
581
- });
582
- },
583
- chooseFile: function(e, data) {
584
- var editor;
585
- data.form.find('button[type=submit]').attr('disabled', true);
586
- editor = $(this).closest('.card-editor');
587
- $('#progress').show();
588
- editor.append('<input type="hidden" class="extra_upload_param" ' + 'value="true" name="attachment_upload">');
589
- editor.append('<input type="hidden" class="extra_upload_param" ' + 'value="preview_editor" name="view">');
590
- data.submit();
591
- editor.find('.choose-file').hide();
592
- return editor.find('.extra_upload_param').remove();
593
- },
594
- progressallFile: function(e, data) {
595
- var progress;
596
- progress = parseInt(data.loaded / data.total * 100, 10);
597
- return $('#progress .progress-bar').css('width', progress + '%');
598
- },
599
- doneFile: function(e, data) {
600
- var editor;
601
- editor = $(this).closest('.card-editor');
602
- editor.find('.chosen-file').replaceWith(data.result);
603
- return data.form.find('button[type=submit]').attr('disabled', false);
604
- }
605
- });
606
-
607
- $(window).ready(function() {
608
- return $('body').on('click', '.cancel-upload', function() {
609
- var editor;
610
- editor = $(this).closest('.card-editor');
611
- editor.find('.choose-file').show();
612
- editor.find('.chosen-file').empty();
613
- editor.find('.progress').show();
614
- editor.find('#progress .progress-bar').css('width', '0%');
615
- return editor.find('#progress').hide();
616
- });
617
- });
618
-
619
- }).call(this);
620
-
621
- // slot.js.coffee
622
- (function() {
623
- $.extend(decko, {
624
- snakeCase: function(str) {
625
- return str.replace(/([a-z])([A-Z])/g, function(match) {
626
- return match[0] + '_' + match[1].toLowerCase();
627
- });
628
- },
629
- slotPath: function(path, slot) {
630
- var params;
631
- params = decko.slotData(slot);
632
- return decko.path(path) + ((path.match(/\?/) ? '&' : '?') + $.param(params));
633
- },
634
- slotData: function(slot) {
635
- var main, slotdata, xtra;
636
- xtra = {};
637
- main = $('#main').children('.card-slot').data('cardName');
638
- if (main != null) {
639
- xtra['main'] = main;
640
- }
641
- if (slot) {
642
- if (slot.isMain()) {
643
- xtra['is_main'] = true;
644
- }
645
- slotdata = slot.data('slot');
646
- if (slotdata != null) {
647
- decko.slotParams(slotdata, xtra, 'slot');
648
- if (slotdata['type']) {
649
- xtra['type'] = slotdata['type'];
650
- }
651
- }
652
- }
653
- return xtra;
654
- },
655
- slotEditView: function(slot) {
656
- var data;
657
- data = decko.slotData(slot);
658
- switch (data["slot[edit]"]) {
659
- case "inline":
660
- return "edit_inline";
661
- case "full":
662
- return "bridge";
663
- default:
664
- return "edit";
665
- }
666
- },
667
- slotEditLink: function(slot) {
668
- var edit_links;
669
- edit_links = slot.find(".edit-link").filter(function(i, el) {
670
- return $(el).slot().data('slotId') === slot.data('slotId');
671
- });
672
- if (edit_links[0]) {
673
- return $(edit_links[0]);
674
- } else {
675
- return false;
676
- }
677
- },
678
- slotParams: function(raw, processed, prefix) {
679
- return $.each(raw, function(key, value) {
680
- var cgiKey;
681
- cgiKey = prefix + '[' + decko.snakeCase(key) + ']';
682
- if (key === 'items') {
683
- return decko.slotParams(value, processed, cgiKey);
684
- } else {
685
- return processed[cgiKey] = value;
686
- }
687
- });
688
- },
689
- contentLoaded: function(el, slotter) {
690
- var notice;
691
- decko.initializeEditors(el);
692
- notice = slotter.attr('notify-success');
693
- if (notice != null) {
694
- el.notify(notice, "success");
695
- }
696
- return el.triggerSlotReady(slotter);
697
- },
698
- slotReady: function(func) {
699
- return $('document').ready(function() {
700
- return $('body').on('slotReady', '.card-slot', function(e, slotter) {
701
- e.stopPropagation();
702
- if (slotter != null) {
703
- return func.call(this, $(this), $(slotter));
704
- } else {
705
- return func.call(this, $(this));
706
- }
707
- });
708
- });
709
- },
710
- slotDestroy: function(func) {
711
- return $('document').ready(function() {
712
- return $('body').on('slotDestroy', '.card-slot, ._modal-slot', function(e) {
713
- e.stopPropagation();
714
- return func.call(this, $(this));
715
- });
716
- });
717
- }
718
- });
719
-
720
- jQuery.fn.extend({
721
- slot: function(status, mode) {
722
- if (status == null) {
723
- status = "success";
724
- }
725
- if (mode == null) {
726
- mode = "replace";
727
- }
728
- if (mode === "modal") {
729
- return this.modalSlot();
730
- } else {
731
- return this.selectSlot("slot-" + status + "-selector") || this.selectSlot("slot-selector") || this.closest(".card-slot");
732
- }
733
- },
734
- selectSlot: function(selectorName) {
735
- var selector, slot;
736
- if (selector = this.data(selectorName)) {
737
- slot = this.findSlot(selector);
738
- return slot && slot[0] && slot;
739
- }
740
- },
741
- isSlot: function() {
742
- return $(this).hasClass("card-slot");
743
- },
744
- isMain: function() {
745
- return this.slot().parent('#main')[0];
746
- },
747
- isMainOrMainModal: function() {
748
- var el;
749
- el = $(this);
750
- if (el.closest(".modal")[0]) {
751
- el = el.findOriginSlot("modal");
752
- }
753
- return el.isMain();
754
- },
755
- findSlot: function(selector) {
756
- var parent_slot, target_slot;
757
- if (selector === "modal-origin") {
758
- return this.findOriginSlot("modal");
759
- } else if (selector === "overlay-origin") {
760
- return this.findOriginSlot("overlay");
761
- } else {
762
- target_slot = this.closest(selector);
763
- parent_slot = this.closest('.card-slot');
764
- while (target_slot.length === 0 && parent_slot.length > 0) {
765
- target_slot = $(parent_slot).find(selector);
766
- parent_slot = $(parent_slot).parent().closest('.card-slot');
767
- }
768
- if (target_slot.length === 0) {
769
- return $(selector);
770
- } else {
771
- return target_slot;
772
- }
773
- }
774
- },
775
- findOriginSlot: function(type) {
776
- var origin_slot, origin_slot_id, overlaySlot;
777
- overlaySlot = this.closest("[data-" + type + "-origin-slot-id]");
778
- origin_slot_id = overlaySlot.data(type + "-origin-slot-id");
779
- origin_slot = $("[data-slot-id=" + origin_slot_id + "]");
780
- if (origin_slot[0] != null) {
781
- return origin_slot;
782
- } else {
783
- return console.log("couldn't find origin with slot id " + origin_slot_id);
784
- }
785
- },
786
- reloadSlot: function(url) {
787
- var $slot;
788
- $slot = $(this);
789
- if ($slot.length > 1) {
790
- $slot.each(function() {
791
- return $(this).reloadSlot(url);
792
- });
793
- return;
794
- }
795
- if (!$slot.isSlot) {
796
- $slot = $slot.slot();
797
- }
798
- if (!$slot[0]) {
799
- return;
800
- }
801
- if (url == null) {
802
- url = $slot.slotUrl();
803
- }
804
- $slot.addClass('slotter');
805
- $slot.attr('href', url);
806
- $slot.data("url", url);
807
- this[0].href = url;
808
- $slot.data("remote", true);
809
- return $.rails.handleRemote($slot);
810
- },
811
- clearSlot: function() {
812
- this.triggerSlotDestroy();
813
- return this.empty();
814
- },
815
- slotUrl: function() {
816
- return decko.slotPath((this.slotMark()) + "?view=" + (this.data("slot")["view"]));
817
- },
818
- slotMark: function() {
819
- if (this.data('cardId')) {
820
- return "~" + (this.data('cardId'));
821
- } else {
822
- return this.data("cardName");
823
- }
824
- },
825
- setSlotContent: function(val, mode, $slotter) {
826
- var v;
827
- v = $(val)[0] && $(val) || val;
828
- if (typeof v === "string") {
829
- this.slot("success", mode).replaceWith(v);
830
- } else {
831
- if (v.hasClass("_overlay")) {
832
- mode = "overlay";
833
- } else if (v.hasClass("_modal")) {
834
- mode = "modal";
835
- }
836
- this.slot("success", mode).setSlotContentFromElement(v, mode, $slotter);
837
- }
838
- return v;
839
- },
840
- setSlotContentFromElement: function(el, mode, $slotter) {
841
- var slot_id;
842
- if (mode === "overlay") {
843
- return this.addOverlay(el, $slotter);
844
- } else if (el.hasClass("_modal-slot") || mode === "modal") {
845
- return el.showAsModal($slotter);
846
- } else {
847
- slot_id = this.data("slot-id");
848
- if (slot_id) {
849
- el.attr("data-slot-id", slot_id);
850
- }
851
- this.triggerSlotDestroy();
852
- this.replaceWith(el);
853
- return decko.contentLoaded(el, $slotter);
854
- }
855
- },
856
- triggerSlotReady: function(slotter) {
857
- if (this.isSlot()) {
858
- this.trigger("slotReady", slotter);
859
- }
860
- return this.find(".card-slot").trigger("slotReady", slotter);
861
- },
862
- triggerSlotDestroy: function() {
863
- return this.trigger("slotDestroy");
864
- }
865
- });
866
-
867
- }).call(this);
868
-
869
- // decko.js.coffee
870
- (function() {
871
- var setSlotMode, warn;
872
-
873
- $.extend(decko, {
874
- path: function(rawPath) {
875
- if (rawPath.match(/^\/|:\/\//)) {
876
- return rawPath;
877
- } else {
878
- return decko.rootUrl + rawPath;
879
- }
880
- },
881
- pingName: function(name, success) {
882
- return $.getJSON(decko.path(''), {
883
- format: 'json',
884
- view: 'status',
885
- 'card[name]': name
886
- }, success);
887
- }
888
- });
889
-
890
- jQuery.fn.extend({
891
- notify: function(message, status) {
892
- var form, notice, slot;
893
- slot = this.slot(status);
894
- notice = slot.find('.card-notice');
895
- if (!notice[0]) {
896
- notice = $('<div class="card-notice"></div>');
897
- form = slot.find('.card-form');
898
- if (form[0]) {
899
- $(form[0]).append(notice);
900
- } else {
901
- slot.append(notice);
902
- }
903
- }
904
- notice.html(message);
905
- return notice.show('blind');
906
- },
907
- report: function(message) {
908
- var report;
909
- report = this.slot().find('.card-report');
910
- if (!report[0]) {
911
- return false;
912
- }
913
- report.hide();
914
- report.html(message);
915
- report.show('drop', 750);
916
- return setTimeout((function() {
917
- return report.hide('drop', 750);
918
- }), 3000);
919
- }
920
- });
921
-
922
- $(window).ready(function() {
923
- $.ajaxSetup({
924
- cache: false
925
- });
926
- $('body').on('click', '.submitter', function() {
927
- return $(this).closest('form').submit();
928
- });
929
- $('body').on('click', 'button.redirecter', function() {
930
- return window.location = $(this).attr('href');
931
- });
932
- $('body').on("change", '.live-type-field', function() {
933
- var $this;
934
- $this = $(this);
935
- setSlotMode($this);
936
- $this.data('params', $(this).closest('form').serialize());
937
- return $this.data('url', $(this).attr('href'));
938
- });
939
- $('body').on('change', '.edit-type-field', function() {
940
- return $(this).closest('form').submit();
941
- });
942
- $('body').on('mouseenter', '[hover_content]', function() {
943
- $(this).attr('hover_restore', $(this).html());
944
- return $(this).html($(this).attr('hover_content'));
945
- });
946
- $('body').on('mouseleave', '[hover_content]', function() {
947
- return $(this).html($(this).attr('hover_restore'));
948
- });
949
- return $('body').on('click', '.render-error-link', function(event) {
950
- var msg;
951
- msg = $(this).closest('.render-error').find('.render-error-message');
952
- msg.show();
953
- return event.preventDefault();
954
- });
955
- });
956
-
957
- decko.slotReady(function(slot) {
958
- return slot.find('card-view-placeholder').each(function() {
959
- var $place;
960
- $place = $(this);
961
- if ($place.data("loading")) {
962
- return;
963
- }
964
- $place.data("loading", true);
965
- return $.get($place.data("url"), function(data, _status) {
966
- return $place.replaceWith(data);
967
- });
968
- });
969
- });
970
-
971
- setSlotMode = function($el, mode) {
972
- var $slotter;
973
- if (mode == null) {
974
- mode = null;
975
- }
976
- $slotter = $el.closest(".slotter");
977
- if ($slotter.length && $slotter.attr('data-slotter-mode')) {
978
- $slotter.attr('data-original-slotter-mode', $slotter.attr('slotter-mode'));
979
- return $slotter.attr('data-slotter-mode', mode);
980
- }
981
- };
982
-
983
- warn = function(stuff) {
984
- if (typeof console !== "undefined" && console !== null) {
985
- return console.log(stuff);
986
- }
987
- };
988
-
989
- }).call(this);
990
-
991
- // modal.js.coffee
992
- (function() {
993
- var addModalDialogClasses, openModalIfPresent;
994
-
995
- $(window).ready(function() {
996
- $('body').on('hidden.bs.modal', function(_event) {
997
- return decko.removeModal();
998
- });
999
- $('body').on("show.bs.modal", "._modal-slot", function(event, slot) {
1000
- var link;
1001
- link = $(event.relatedTarget);
1002
- addModalDialogClasses($(this), link);
1003
- $(this).modal("handleUpdate");
1004
- return decko.contentLoaded($(event.target), link);
1005
- });
1006
- $('._modal-slot').each(function() {
1007
- openModalIfPresent($(this));
1008
- return addModalDialogClasses($(this));
1009
- });
1010
- return $('body').on('click', '.submit-modal', function() {
1011
- return $(this).closest('.modal-content').find('form').submit();
1012
- });
1013
- });
1014
-
1015
- openModalIfPresent = function(mslot) {
1016
- var modal_content;
1017
- modal_content = mslot.find(".modal-content");
1018
- if (modal_content.length > 0 && modal_content.html().length > 0) {
1019
- $("#main > .card-slot").registerAsOrigin("modal", mslot);
1020
- return mslot.modal("show");
1021
- }
1022
- };
1023
-
1024
- addModalDialogClasses = function($modal_slot, $link) {
1025
- var classes_from_link, dialog;
1026
- dialog = $modal_slot.find(".modal-dialog");
1027
- classes_from_link = $link != null ? $link.data("modal-class") : $modal_slot.data("modal-class");
1028
- if ((classes_from_link != null) && (dialog != null)) {
1029
- return dialog.addClass(classes_from_link);
1030
- }
1031
- };
1032
-
1033
- jQuery.fn.extend({
1034
- showAsModal: function($slotter) {
1035
- var el;
1036
- if ($slotter != null) {
1037
- el = this.modalify($slotter);
1038
- }
1039
- if ($("body > ._modal-slot").is(":visible")) {
1040
- return this.addModal(el, $slotter);
1041
- } else {
1042
- if ($("body > ._modal-slot")[0]) {
1043
- $("._modal-slot").trigger("slotDestroy");
1044
- $("body > ._modal-slot").replaceWith(el);
1045
- } else {
1046
- $("body").append(el);
1047
- }
1048
- $slotter.registerAsOrigin("modal", el);
1049
- return el.modal("show", $slotter);
1050
- }
1051
- },
1052
- addModal: function(el, $slotter) {
1053
- var dialog;
1054
- if ($slotter.data("slotter-mode") === "modal-replace") {
1055
- dialog = el.find(".modal-dialog");
1056
- el.adoptModalOrigin();
1057
- $("._modal-slot").trigger("slotDestroy");
1058
- $("body > ._modal-slot > .modal-dialog").replaceWith(dialog);
1059
- return decko.contentLoaded(dialog, $slotter);
1060
- } else {
1061
- decko.pushModal(el);
1062
- $slotter.registerAsOrigin("modal", el);
1063
- return el.modal("show", $slotter);
1064
- }
1065
- },
1066
- adoptModalOrigin: function() {
1067
- var origin_slot_id;
1068
- origin_slot_id = $("body > ._modal-slot .card-slot[data-modal-origin-slot-id]").data("modal-origin-slot-id");
1069
- return this.find(".modal-body .card-slot").attr("data-modal-origin-slot-id", origin_slot_id);
1070
- },
1071
- modalOriginSlot: function() {},
1072
- modalSlot: function() {
1073
- var slot;
1074
- slot = $("#modal-container");
1075
- if (slot.length > 0) {
1076
- return slot;
1077
- } else {
1078
- return decko.createModalSlot();
1079
- }
1080
- },
1081
- modalify: function($slotter) {
1082
- var modalSlot;
1083
- if ($slotter.data("modal-body") != null) {
1084
- this.find(".modal-body").append($slotter.data("modal-body"));
1085
- }
1086
- if (this.hasClass("_modal-slot")) {
1087
- return this;
1088
- } else {
1089
- modalSlot = $('<div/>', {
1090
- id: "modal-container",
1091
- "class": "modal fade _modal-slot"
1092
- });
1093
- modalSlot.append($('<div/>', {
1094
- "class": "modal-dialog"
1095
- }).append($('<div/>', {
1096
- "class": "modal-content"
1097
- }).append(this)));
1098
- return modalSlot;
1099
- }
1100
- }
1101
- });
1102
-
1103
- $.extend(decko, {
1104
- createModalSlot: function() {
1105
- var slot;
1106
- slot = $('<div/>', {
1107
- id: "modal-container",
1108
- "class": "modal fade _modal-slot"
1109
- });
1110
- $("body").append(slot);
1111
- return slot;
1112
- },
1113
- removeModal: function() {
1114
- if ($("._modal-stack")[0]) {
1115
- return decko.popModal();
1116
- } else {
1117
- $("._modal-slot").trigger("slotDestroy");
1118
- return $(".modal-dialog").empty();
1119
- }
1120
- },
1121
- pushModal: function(el) {
1122
- var mslot;
1123
- mslot = $("body > ._modal-slot");
1124
- mslot.removeAttr("id");
1125
- mslot.removeClass("_modal-slot").addClass("_modal-stack").removeClass("modal").addClass("background-modal");
1126
- el.insertBefore(mslot);
1127
- return $(".modal-backdrop").removeClass("show");
1128
- },
1129
- popModal: function() {
1130
- var modal;
1131
- $(".modal-backdrop").addClass("show");
1132
- $("body > ._modal-slot").trigger("slotDestroy");
1133
- $("body > ._modal-slot").remove();
1134
- modal = $($("._modal-stack")[0]);
1135
- modal.addClass("_modal-slot").removeClass("_modal-stack").attr("id", "modal-container").addClass("modal").removeClass("background-modal");
1136
- return $(document.body).addClass("modal-open");
1137
- }
1138
- });
1139
-
1140
- }).call(this);
1141
-
1142
- // overlay.js.coffee
1143
- (function() {
1144
- jQuery.fn.extend({
1145
- overlaySlot: function() {
1146
- var oslot;
1147
- oslot = this.closest(".card-slot._overlay");
1148
- if (oslot[0] != null) {
1149
- return oslot;
1150
- }
1151
- oslot = this.closest(".overlay-container").find("._overlay");
1152
- return (oslot[0] != null) && $(oslot[0]);
1153
- },
1154
- addOverlay: function(overlay, $slotter) {
1155
- if (this.parent().hasClass("overlay-container")) {
1156
- if ($(overlay).hasClass("_stack-overlay")) {
1157
- this.before(overlay);
1158
- } else {
1159
- $("._overlay-origin").removeClass("_overlay-origin");
1160
- this.replaceOverlay(overlay);
1161
- }
1162
- } else {
1163
- if (this.parent().hasClass("_overlay-container-placeholder")) {
1164
- this.parent().addClass("overlay-container");
1165
- } else {
1166
- this.wrapAll('<div class="overlay-container">');
1167
- }
1168
- this.addClass("_bottomlay-slot");
1169
- this.before(overlay);
1170
- }
1171
- $slotter.registerAsOrigin("overlay", overlay);
1172
- return decko.contentLoaded(overlay, $slotter);
1173
- },
1174
- replaceOverlay: function(overlay) {
1175
- this.overlaySlot().trigger("slotDestroy");
1176
- this.overlaySlot().replaceWith(overlay);
1177
- return $(".bridge-sidebar .tab-pane:not(.active) .bridge-pills > .nav-item > .nav-link.active").removeClass("active");
1178
- },
1179
- isInOverlay: function() {
1180
- return this.closest(".card-slot._overlay").length;
1181
- },
1182
- removeOverlay: function() {
1183
- var slot;
1184
- slot = this.overlaySlot();
1185
- if (slot) {
1186
- return slot.removeOverlaySlot();
1187
- }
1188
- },
1189
- removeOverlaySlot: function() {
1190
- var bottomlay;
1191
- this.trigger("slotDestroy");
1192
- if (this.siblings().length === 1) {
1193
- bottomlay = $(this.siblings()[0]);
1194
- if (bottomlay.hasClass("_bottomlay-slot")) {
1195
- if (bottomlay.parent().hasClass("_overlay-container-placeholder")) {
1196
- bottomlay.parent().removeClass("overlay-container");
1197
- } else {
1198
- bottomlay.unwrap();
1199
- }
1200
- bottomlay.removeClass("_bottomlay-slot").updateBridge(true, bottomlay);
1201
- }
1202
- }
1203
- return this.remove();
1204
- }
1205
- });
1206
-
1207
- }).call(this);
1208
-
1209
- // recaptcha.js.coffee
1210
- (function() {
1211
- jQuery.fn.extend({
1212
- updateRecaptchaToken: function(event) {
1213
- var $slotter, recaptcha;
1214
- recaptcha = this.find("input._recaptcha-token");
1215
- if (recaptcha[0] == null) {
1216
- return recaptcha.val("recaptcha-token-field-missing");
1217
- } else if (typeof grecaptcha === "undefined" || grecaptcha === null) {
1218
- return recaptcha.val("grecaptcha-undefined");
1219
- } else {
1220
- $slotter = $(this);
1221
- if (event) {
1222
- event.stopPropagation();
1223
- }
1224
- grecaptcha.execute(recaptcha.data("site-key"), {
1225
- action: recaptcha.data("action")
1226
- }).then(function(token) {
1227
- recaptcha.val(token);
1228
- recaptcha.addClass("_token-updated");
1229
- if (event) {
1230
- return $slotter.submit();
1231
- }
1232
- });
1233
- return false;
1234
- }
1235
- }
1236
- });
1237
-
1238
- }).call(this);
1239
-
1240
- // slotter.js.coffee
1241
- (function() {
1242
- $(window).ready(function() {
1243
- $('body').on('ajax:success', '.slotter', function(event, data, c, d) {
1244
- return $(this).slotterSuccess(event, data);
1245
- });
1246
- $('body').on('ajax:error', '.slotter', function(event, xhr) {
1247
- return $(this).showErrorResponse(xhr.status, xhr.responseText);
1248
- });
1249
- $('body').on('click', 'button.slotter', function(event) {
1250
- if (!$.rails.allowAction($(this))) {
1251
- return false;
1252
- }
1253
- return $.rails.handleRemote($(this));
1254
- });
1255
- $('body').on('click', '._clickable.slotter', function(event) {
1256
- $(this)[0].href = $(this).attr("href");
1257
- return $.rails.handleRemote($(this));
1258
- });
1259
- $('body').on('click', '[data-dismiss="overlay"]', function(event) {
1260
- return $(this).findSlot(".card-slot._overlay").removeOverlay();
1261
- });
1262
- $('body').on('click', '._close-overlay-on-success', function(event) {
1263
- return $(this).closeOnSuccess("overlay");
1264
- });
1265
- $('body').on('click', '._close-modal-on-success', function(event) {
1266
- return $(this).closeOnSuccess("modal");
1267
- });
1268
- $('body').on('click', '._close-on-success', function(event) {
1269
- return $(this).closeOnSuccess();
1270
- });
1271
- $('body').on('click', '._update-origin', function(event) {
1272
- return $(this).closest('.slotter').data("slotter-mode", "update-origin");
1273
- });
1274
- $('body').on('submit', 'form.slotter', function(event) {
1275
- var form;
1276
- form = $(this);
1277
- if (form.data("main-success") && form.isMainOrMainModal()) {
1278
- form.mainSuccess();
1279
- }
1280
- if (form.data('recaptcha') === 'on') {
1281
- return form.handleRecaptchaBeforeSubmit(event);
1282
- }
1283
- });
1284
- return $('body').on('ajax:beforeSend', '.slotter', function(event, xhr, opt) {
1285
- return $(this).slotterBeforeSend(opt);
1286
- });
1287
- });
1288
-
1289
- jQuery.fn.extend({
1290
- mainSuccess: function() {
1291
- var form;
1292
- form = $(this);
1293
- return $.each(form.data("main-success"), function(key, value) {
1294
- var input, inputSelector;
1295
- inputSelector = "[name=success\\[" + key + "\\]]";
1296
- input = form.find(inputSelector);
1297
- if (!input[0]) {
1298
- input = $('<input type="hidden" name="success[' + key + ']"/>');
1299
- form.append(input);
1300
- }
1301
- return input.val(value);
1302
- });
1303
- },
1304
- slotterSuccess: function(event, data) {
1305
- var $slot, mode, reload_url, slot_top_pos;
1306
- if (!this.hasClass("slotter")) {
1307
- console.log("warning: slotterSuccess called on non-slotter element " + this);
1308
- return;
1309
- }
1310
- if (event.slotSuccessful) {
1311
- return;
1312
- }
1313
- if (this.data("reload")) {
1314
- window.location.reload(true);
1315
- }
1316
- if (this.data("update-modal-origin")) {
1317
- this.updateModalOrigin();
1318
- }
1319
- if (this.data("update-origin")) {
1320
- this.updateOrigin();
1321
- }
1322
- if (this.data('original-slotter-mode')) {
1323
- this.attr('data-slotter-mode', this.data('original-slotter-mode'));
1324
- }
1325
- mode = this.data("slotter-mode");
1326
- this.showSuccessResponse(data, mode);
1327
- if (this.hasClass("_close-overlay")) {
1328
- this.removeOverlay();
1329
- }
1330
- if (this.hasClass("_close-modal")) {
1331
- this.closest('.modal').modal('hide');
1332
- }
1333
- if (this.hasClass("card-paging-link")) {
1334
- slot_top_pos = this.slot().offset().top;
1335
- $("body").scrollTop(slot_top_pos);
1336
- }
1337
- if (this.data("update-foreign-slot")) {
1338
- $slot = this.findSlot(this.data("update-foreign-slot"));
1339
- reload_url = this.data("update-foreign-slot-url");
1340
- $slot.reloadSlot(reload_url);
1341
- }
1342
- return event.slotSuccessful = true;
1343
- },
1344
- showSuccessResponse: function(data, mode) {
1345
- if (mode === "silent-success") {
1346
-
1347
- } else if (mode === "update-modal-origin") {
1348
- return this.updateModalOrigin();
1349
- } else if (mode === "update-origin") {
1350
- return this.updateOrigin();
1351
- } else if (data.redirect) {
1352
- return window.location = data.redirect;
1353
- } else if (data.reload) {
1354
- return window.location.reload(true);
1355
- } else {
1356
- return this.updateSlot(data, mode);
1357
- }
1358
- },
1359
- showErrorResponse: function(status, result) {
1360
- if (status === 403) {
1361
- return $(result).showAsModal($(this));
1362
- } else if (status === 900) {
1363
- return $(result).showAsModal($(this));
1364
- } else {
1365
- this.notify(result, "error");
1366
- if (status === 409) {
1367
- return this.slot().find('.current_revision_id').val(this.slot().find('.new-current-revision-id').text());
1368
- }
1369
- }
1370
- },
1371
- updateModalOrigin: function() {
1372
- var overlayOrigin;
1373
- if (this.overlaySlot()) {
1374
- overlayOrigin = this.findOriginSlot("overlay");
1375
- return overlayOrigin.updateOrigin();
1376
- } else if (this.closest("#modal-container")[0]) {
1377
- return this.updateOrigin();
1378
- }
1379
- },
1380
- updateOrigin: function() {
1381
- var origin, type;
1382
- type = this.overlaySlot() ? "overlay" : this.closest("#modal-container")[0] ? "modal" : void 0;
1383
- if (type == null) {
1384
- return;
1385
- }
1386
- origin = this.findOriginSlot(type);
1387
- if (origin && (origin[0] != null)) {
1388
- return origin.reloadSlot();
1389
- }
1390
- },
1391
- registerAsOrigin: function(type, slot) {
1392
- if (slot.hasClass("_modal-slot")) {
1393
- slot = slot.find(".modal-body .card-slot");
1394
- }
1395
- return slot.attr("data-" + type + "-origin-slot-id", this.closest(".card-slot").data("slot-id"));
1396
- },
1397
- updateSlot: function(data, mode) {
1398
- mode || (mode = "replace");
1399
- return this.setSlotContent(data, mode, $(this));
1400
- },
1401
- closeOnSuccess: function(type) {
1402
- var slotter;
1403
- slotter = this.closest('.slotter');
1404
- if (type == null) {
1405
- type = this.isInOverlay() ? "overlay" : "modal";
1406
- }
1407
- return slotter.addClass("_close-" + type);
1408
- },
1409
- slotterBeforeSend: function(opt) {
1410
- var data;
1411
- if (opt.skip_before_send) {
1412
- return;
1413
- }
1414
- if (!(opt.url.match(/home_view/) || this.data("slotter-mode") === "modal")) {
1415
- opt.url = decko.slotPath(opt.url, this.slot());
1416
- }
1417
- if (this.is('form')) {
1418
- if (data = this.data('file-data')) {
1419
- this.uploadWithBlueimp(data, opt);
1420
- return false;
1421
- }
1422
- }
1423
- },
1424
- uploadWithBlueimp: function(data, opt) {
1425
- var args, iframeUploadFilter, input, widget;
1426
- input = this.find('.file-upload');
1427
- if (input[1]) {
1428
- this.notify("Decko does not yet support multiple files in a single form.", "error");
1429
- return false;
1430
- }
1431
- widget = input.data('blueimpFileupload');
1432
- if (!widget._isXHRUpload(widget.options)) {
1433
- this.find('[name=success]').val('_self');
1434
- opt.url += '&simulate_xhr=true';
1435
- iframeUploadFilter = function(data) {
1436
- return data.find('body').html();
1437
- };
1438
- opt.dataFilter = iframeUploadFilter;
1439
- }
1440
- args = $.extend(opt, widget._getAJAXSettings(data), {
1441
- url: opt.url
1442
- });
1443
- args.skip_before_send = true;
1444
- return $.ajax(args);
1445
- },
1446
- handleRecaptchaBeforeSubmit: function(event) {
1447
- var recaptcha;
1448
- recaptcha = this.find("input._recaptcha-token");
1449
- if (recaptcha[0] == null) {
1450
- return recaptcha.val("recaptcha-token-field-missing");
1451
- } else if (recaptcha.hasClass("_token-updated")) {
1452
- return recaptcha.removeClass("_token-updated");
1453
- } else if (typeof grecaptcha === "undefined" || grecaptcha === null) {
1454
- return recaptcha.val("grecaptcha-undefined");
1455
- } else {
1456
- return this.updateRecaptchaToken(event);
1457
- }
1458
- }
1459
- });
1460
-
1461
- }).call(this);
1462
-
1463
- // bridge.js.coffee
1464
- (function() {
1465
- decko.slotReady(function(slot, slotter) {
1466
- var links;
1467
- slot.updateBridge(false, slotter);
1468
- links = slot.find('ul._auto-single-select > li.nav-item > a.nav-link');
1469
- if (links.length === 1) {
1470
- return $(links[0]).click();
1471
- }
1472
- });
1473
-
1474
- jQuery.fn.extend({
1475
- updateBridge: function(overlayClosed, slotter) {
1476
- if (overlayClosed == null) {
1477
- overlayClosed = false;
1478
- }
1479
- if (!(this.closest(".bridge").length > 0)) {
1480
- return;
1481
- }
1482
- if (this.data("breadcrumb")) {
1483
- this.updateBreadcrumb();
1484
- } else if (slotter && $(slotter).data("breadcrumb")) {
1485
- $(slotter).updateBreadcrumb();
1486
- }
1487
- if (overlayClosed) {
1488
- return $(".bridge-pills > .nav-item > .nav-link.active").removeClass("active");
1489
- }
1490
- },
1491
- updateBreadcrumb: function() {
1492
- var bc_item;
1493
- bc_item = $(".modal-header ._bridge-breadcrumb li:last-child");
1494
- bc_item.text(this.data("breadcrumb"));
1495
- return bc_item.attr("class", "breadcrumb-item active " + (this.data('breadcrumb-class')));
1496
- }
1497
- });
1498
-
1499
- $(window).ready(function() {
1500
- $('body').on("select2:select", "._close-rule-overlay-on-select", function(event) {
1501
- return $(".overlay-container > ._overlay.card-slot.overlay_rule-view.RULE").removeOverlay();
1502
- });
1503
- return $('body').on("click", "._update-history-pills", function(event) {
1504
- return $(this).closest(".slotter").data("update-foreign-slot", ".card-slot.history_tab-view");
1505
- });
1506
- });
1507
-
1508
- }).call(this);
1509
-
1510
- // nest_editor.js.coffee
1511
- (function() {
1512
- $(document).ready(function() {
1513
- $('body').on('click', 'button._nest-apply', function() {
1514
- if ($(this).data("index") != null) {
1515
- return nest.applyNestToNestListEditor($(this).data("index"));
1516
- } else {
1517
- return nest.applyNestToTinymceEditor($(this).data("tinymce-id"), $(this).data("tm-snippet-start"), $(this).data("tm-snippet-size"));
1518
- }
1519
- });
1520
- $('body').on('click', 'button._change-create-to-update', function() {
1521
- var tm_id;
1522
- tm_id = $(this).closest("form").find("#success_tinymce_id").val();
1523
- return nest.changeCreateToUpdate(tm_id);
1524
- });
1525
- return $('body').on('click', 'button._open-nest-editor', function() {
1526
- var encoded_nest, form, nest_options, reference;
1527
- form = $(this).closest("._nest-form");
1528
- reference = form.find("._reference").val();
1529
- nest_options = form.find("._nest-options").val();
1530
- encoded_nest = encodeURIComponent("{{" + reference + "|" + nest_options + "}}");
1531
- return nest.openNestEditorForSlot($(this).closest(".card-slot"), $(this).closest(".slotter"), "index=" + (form.data('index')) + "&tm_snippet_raw=" + encoded_nest);
1532
- });
1533
- });
1534
-
1535
- window.nest || (window.nest = {});
1536
-
1537
- $.extend(nest, {
1538
- openNestEditor: function(tm, params) {
1539
- if (params == null) {
1540
- params = nest.editParams(tm);
1541
- }
1542
- return this.openEditorForTm(tm, params, "nest_editor", "modal_nest_editor");
1543
- },
1544
- openNestEditorForSlot: function(slot, slotter, params) {
1545
- var card;
1546
- card = slot[0] ? $(slot[0]).attr('data-card-name') : ":update";
1547
- return nest.request(card, "nest_editor", "modal_nest_editor", slotter, params);
1548
- },
1549
- openEditorForTm: function(tm, params, overlay_view, modal_view) {
1550
- var card, slot, slotter;
1551
- params += "&tinymce_id=" + tm.id;
1552
- slot = $("#" + tm.id).closest(".card-slot");
1553
- slotter = $("#" + tm.id);
1554
- card = slot[0] ? $(slot[0]).attr('data-card-name') : ":update";
1555
- return nest.request(card, overlay_view, modal_view, slotter, params);
1556
- },
1557
- openImageEditor: function(tm) {
1558
- var params;
1559
- if (typeof params === "undefined" || params === null) {
1560
- params = nest.editParams(tm, "{{", "}}", false);
1561
- }
1562
- return this.openEditorForTm(tm, params, "nest_image", "modal_nest_image");
1563
- },
1564
- changeCreateToUpdate: function(tm_id) {
1565
- var form, new_action;
1566
- form = $("#" + tm_id).closest("form");
1567
- new_action = form.attr("action").replace("card/create", "card/update");
1568
- return form.attr("action", new_action);
1569
- },
1570
- insertNest: function(tm, nest_string) {
1571
- return tm.insertContent(nest_string);
1572
- },
1573
- request: function(card, overlay_view, modal_view, slotter, params) {
1574
- var mode, slot, view;
1575
- slot = $(".bridge-sidebar > ._overlay-container-placeholder > .card-slot");
1576
- if (slot[0]) {
1577
- view = overlay_view;
1578
- mode = "overlay";
1579
- } else {
1580
- slot = $($(".card-slot")[0]);
1581
- view = modal_view;
1582
- mode = "modal";
1583
- }
1584
- return nest.sendRequest(slotter, slot, mode, card, view, params);
1585
- },
1586
- sendRequest: function(slotter, slot, mode, card, view, params) {
1587
- var url;
1588
- if (params == null) {
1589
- params = "";
1590
- }
1591
- url = "/" + card + "?view=" + view + "&" + params;
1592
- return $.ajax({
1593
- url: url,
1594
- type: 'GET',
1595
- success: function(html) {
1596
- return slot.setSlotContent(html, mode, slotter);
1597
- }
1598
- });
1599
- },
1600
- editParams: function(tm, prefix, postfix, edit) {
1601
- var after, before, index, name, nest_size, nest_start, offset, sel, text;
1602
- if (prefix == null) {
1603
- prefix = "{{";
1604
- }
1605
- if (postfix == null) {
1606
- postfix = "}}";
1607
- }
1608
- if (edit == null) {
1609
- edit = true;
1610
- }
1611
- sel = tm.selection.getSel();
1612
- if (!((sel != null) && (sel.anchorNode != null))) {
1613
- return nest.paramsStr(0);
1614
- }
1615
- text = sel.anchorNode.data;
1616
- if (!text) {
1617
- return nest.paramsStr(sel.anchorOffset);
1618
- }
1619
- offset = sel.anchorOffset;
1620
- before = text.substr(0, offset);
1621
- after = text.substr(offset);
1622
- index = {
1623
- before: {
1624
- close: before.lastIndexOf(postfix),
1625
- open: before.lastIndexOf(prefix)
1626
- },
1627
- after: {
1628
- close: after.indexOf(postfix),
1629
- open: after.indexOf(prefix)
1630
- }
1631
- };
1632
- if (index.before.open > index.before.close && index.after.close !== -1 && (index.after.open === -1 || index.after.close < index.after.open)) {
1633
- nest_start = index.before.open;
1634
- if (typeof name === "undefined" || name === null) {
1635
- nest_size = index.after.close + offset + 2 - nest_start;
1636
- name = text.substr(nest_start, nest_size);
1637
- }
1638
- if (edit) {
1639
- return nest.paramsStr(nest_start, name);
1640
- } else {
1641
- return nest.paramsStr(nest_start + nest_size);
1642
- }
1643
- } else {
1644
- return nest.paramsStr(offset);
1645
- }
1646
- },
1647
- paramsStr: function(start, name) {
1648
- var params;
1649
- params = "";
1650
- if (start != null) {
1651
- params += "&tm_snippet_start=" + start;
1652
- }
1653
- if ((name != null) && name.length > 0) {
1654
- params += "&tm_snippet_raw=" + (encodeURIComponent(name));
1655
- }
1656
- return params;
1657
- },
1658
- offsetAfterInsert: function(editor, content) {
1659
- var offset;
1660
- offset = editor.selection.getSel().anchorOffset;
1661
- return offset - content.lengthr;
1662
- },
1663
- applyNestToTinymceEditor: function(tinymce_id, nest_start, nest_size) {
1664
- return nest.applySnippet("nest", tinymce_id, nest_start, nest_size);
1665
- },
1666
- applyNestToNestListEditor: function(index) {
1667
- var row;
1668
- row = $("._nest-form[data-index='" + index + "']");
1669
- row.find("._reference").val(nest.name());
1670
- row.find("._nest-options").val(nest.options());
1671
- return decko.updateAddItemButton(row);
1672
- },
1673
- applySnippet: function(snippet_type, tinymce_id, start, size) {
1674
- var content, editor, offset;
1675
- content = $("._" + snippet_type + "-preview").val();
1676
- editor = tinymce.get(tinymce_id);
1677
- if (start != null) {
1678
- nest.replaceSnippet(editor, start, size, content);
1679
- } else {
1680
- editor.insertContent(content);
1681
- offset = nest.offsetAfterInsert(editor, content);
1682
- $("button._" + snippet_type + "-apply").attr("data-tm-snippet-start", offset);
1683
- }
1684
- return $("button._" + snippet_type + "-apply").attr("data-tm-snippet-size", content.length);
1685
- },
1686
- replaceSnippet: function(editor, start, size, content) {
1687
- var sel, text;
1688
- sel = editor.selection.getSel();
1689
- if ((sel != null) && (sel.anchorNode != null) && (sel.anchorNode.data != null)) {
1690
- text = sel.anchorNode.data;
1691
- if (size == null) {
1692
- size = 0;
1693
- }
1694
- text = "" + (text.substr(0, start)) + content + (text.substr(start + size));
1695
- return sel.anchorNode.data = text;
1696
- } else {
1697
- return editor.insertContent(content);
1698
- }
1699
- },
1700
- updatePreview: function(new_val) {
1701
- var preview;
1702
- if (new_val == null) {
1703
- new_val = "{{" + (nest.name()) + "|" + (nest.options()) + "}}";
1704
- }
1705
- preview = $("._nest-preview");
1706
- preview.val(new_val);
1707
- preview.data("nest-options", nest.options());
1708
- return preview.data("reference", nest.name());
1709
- }
1710
- });
1711
-
1712
- }).call(this);
1713
-
1714
- // nest_editor_rules.js.coffee
1715
- (function() {
1716
-
1717
-
1718
- }).call(this);
1719
-
1720
- // nest_editor_options.js.coffee
1721
- (function() {
1722
- $(document).ready(function() {
1723
- $('body').on('keyup', 'input._nest-option-value', function() {
1724
- return nest.updatePreview();
1725
- });
1726
- $('body').on("select2:select", "._nest-option-name", function() {
1727
- nest.toggleOptionName($(this).closest("._options-select"), $(this).val(), true);
1728
- return nest.updatePreview();
1729
- });
1730
- $('body').on("select2:selecting", "._nest-option-name", function() {
1731
- return nest.toggleOptionName($(this).closest("._options-select"), $(this).val(), false);
1732
- });
1733
- $('body').on("select2:select", "._nest-option-name._new-row", function() {
1734
- var row, template;
1735
- $(this).closest(".input-group").find(".input-group-prepend").removeClass("d-none");
1736
- row = $(this).closest("._nest-option-row");
1737
- row.find("._nest-option-value").removeAttr("disabled");
1738
- template = row.parent().find("._nest-option-row._template");
1739
- $(this).removeClass("_new-row");
1740
- return nest.addRow(template);
1741
- });
1742
- $('body').on("click", "._configure-items-button", function() {
1743
- return nest.addItemsOptions($(this));
1744
- });
1745
- return $('body').on('click', 'button._nest-delete-option', function() {
1746
- return nest.removeRow($(this).closest("._nest-option-row"));
1747
- });
1748
- });
1749
-
1750
- $.extend(nest, {
1751
- showTemplate: function(elem) {
1752
- return elem.removeClass("_template");
1753
- },
1754
- addRow: function(template) {
1755
- var double, select_tag;
1756
- select_tag = template.find("select");
1757
- select_tag.select2("destroy");
1758
- select_tag.removeAttr("data-select2-id");
1759
- double = template.clone();
1760
- decko.initSelect2(select_tag);
1761
- nest.showTemplate(template);
1762
- template.after(double);
1763
- return decko.initSelect2(double.find("select"));
1764
- },
1765
- removeRow: function(row) {
1766
- var name;
1767
- name = row.find("._nest-option-name").val();
1768
- nest.toggleOptionName(row.closest("._options-select"), name, false);
1769
- row.remove();
1770
- return nest.updatePreview();
1771
- },
1772
- addItemsOptions: function(button) {
1773
- var container, next, title;
1774
- container = button.closest("._configure-items");
1775
- next = container.cloneSelect2(true);
1776
- title = button.text();
1777
- button.replaceWith($("<h6>" + (title.substr(9)) + "<h6>"));
1778
- nest.showTemplate(container.find("._options-select._template"));
1779
- next.find("._configure-items-button").text(title.replace("items", "subitems"));
1780
- container.after(next);
1781
- return nest.updatePreview();
1782
- },
1783
- options: function() {
1784
- var ele, i, len, level_options, options, ref;
1785
- options = [];
1786
- ref = $("._options-select:not(._template");
1787
- for (i = 0, len = ref.length; i < len; i++) {
1788
- ele = ref[i];
1789
- options.push(nest.extractOptions($(ele)));
1790
- }
1791
- level_options = options.map(function(opts) {
1792
- return nest.toNestSyntax(opts);
1793
- });
1794
- return level_options.join("|");
1795
- },
1796
- extractOptions: function(ele) {
1797
- var i, len, options, ref, row;
1798
- options = {};
1799
- ref = ele.find("._nest-option-row:not(.template)");
1800
- for (i = 0, len = ref.length; i < len; i++) {
1801
- row = ref[i];
1802
- nest.addOption(options, $(row));
1803
- }
1804
- return options;
1805
- },
1806
- addOption: function(options, row) {
1807
- var name, val;
1808
- val = row.find("._nest-option-value").val();
1809
- if (!((val != null) && val.length > 0)) {
1810
- return;
1811
- }
1812
- name = row.find("._nest-option-name").val();
1813
- if (options[name] != null) {
1814
- return options[name].push(val);
1815
- } else {
1816
- return options[name] = [val];
1817
- }
1818
- },
1819
- toggleOptionName: function(container, name, active) {
1820
- var i, len, ref, results, sel;
1821
- if (name === "show" || name === "hide") {
1822
- return true;
1823
- }
1824
- ref = container.find("._nest-option-name");
1825
- results = [];
1826
- for (i = 0, len = ref.length; i < len; i++) {
1827
- sel = ref[i];
1828
- if ($(sel).val() !== name) {
1829
- $(sel).find("option[value=" + name + "]").attr("disabled", active);
1830
- }
1831
- results.push(decko.initSelect2($(sel)));
1832
- }
1833
- return results;
1834
- },
1835
- toNestSyntax: function(opts) {
1836
- var name, str, values;
1837
- str = [];
1838
- for (name in opts) {
1839
- values = opts[name];
1840
- str.push(name + ": " + (values.join(', ')));
1841
- }
1842
- return str.join("; ");
1843
- }
1844
- });
1845
-
1846
- }).call(this);
1847
-
1848
- // nest_editor_name.js.coffee
1849
- (function() {
1850
- var nestNameTimeout;
1851
-
1852
- nestNameTimeout = null;
1853
-
1854
- $(document).ready(function() {
1855
- $('body').on('click', '._nest-field-toggle', function() {
1856
- if ($(this).is(':checked')) {
1857
- return nest.addPlus();
1858
- } else {
1859
- return nest.removePlus();
1860
- }
1861
- });
1862
- $('body').on('input', 'input._nest-name', function(event) {
1863
- nest.nameChanged();
1864
- if (event.which !== 13) {
1865
- if (nestNameTimeout) {
1866
- clearTimeout(nestNameTimeout);
1867
- }
1868
- return nestNameTimeout = setTimeout((function() {
1869
- return nest.updateNameRelatedTabs();
1870
- }), 700);
1871
- }
1872
- });
1873
- return $('body').on('keydown', 'input._nest-name', function(event) {
1874
- if (event.which === 13) {
1875
- if (nestNameTimeout) {
1876
- clearTimeout(nestNameTimeout);
1877
- }
1878
- return nest.updateNameRelatedTabs();
1879
- }
1880
- });
1881
- });
1882
-
1883
- $.extend(nest, {
1884
- name: function() {
1885
- return nest.evalFieldOption($('input._nest-name').val());
1886
- },
1887
- nameChanged: function() {
1888
- var new_val;
1889
- new_val = $("._nest-preview").val().replace(/^\{\{[^}|]*/, "{{" + nest.name());
1890
- return nest.updatePreview(new_val);
1891
- },
1892
- evalFieldOption: function(name) {
1893
- if (nest.isField()) {
1894
- return "+" + name;
1895
- } else {
1896
- return name;
1897
- }
1898
- },
1899
- isField: function() {
1900
- return $('._nest-field-toggle').is(":checked");
1901
- },
1902
- addPlus: function() {
1903
- var new_val;
1904
- new_val = $("._nest-preview").val().replace(/^\{\{\+?/, "{{+");
1905
- nest.updatePreview(new_val);
1906
- return $(".input-group.hide-prefix").removeClass("hide-prefix").addClass("show-prefix");
1907
- },
1908
- removePlus: function() {
1909
- var new_val;
1910
- new_val = $("._nest-preview").val().replace(/^\{\{\+?/, "{{");
1911
- nest.updatePreview(new_val);
1912
- return $(".input-group.show-prefix").removeClass("show-prefix").addClass("hide-prefix");
1913
- },
1914
- rulesTabSlot: function() {
1915
- return $("._nest-editor .tab-pane-rules > .card-slot");
1916
- },
1917
- contentTabSlot: function() {
1918
- return $("._nest-editor .tab-pane-content > .card-slot");
1919
- },
1920
- emptyNameAlert: function(show) {
1921
- if (show) {
1922
- return $("._empty-nest-name-alert").removeClass("d-none");
1923
- } else {
1924
- return $("._empty-nest-name-alert:not(.d-none)").addClass("d-none");
1925
- }
1926
- },
1927
- updateNameRelatedTabs: function() {
1928
- nest.updateRulesTab();
1929
- return nest.updateContentTab();
1930
- },
1931
- updateContentTab: function() {
1932
- var $contentTab, url;
1933
- $contentTab = nest.contentTabSlot();
1934
- if ($contentTab.length > 0) {
1935
- url = decko.path((nest.fullName()) + "?view=nest_content");
1936
- return nest.updateNameDependentSlot($contentTab, url);
1937
- }
1938
- },
1939
- updateRulesTab: function() {
1940
- var $rulesTab, url;
1941
- $rulesTab = nest.rulesTabSlot();
1942
- url = decko.path((nest.setNameForRules()) + "?view=nest_rules");
1943
- return nest.updateNameDependentSlot($rulesTab, url);
1944
- },
1945
- updateNameDependentSlot: function($slot, url) {
1946
- var name;
1947
- name = $("input._nest-name").val();
1948
- if ((name != null) && name.length > 0) {
1949
- nest.emptyNameAlert(false);
1950
- return $slot.reloadSlot(url);
1951
- } else {
1952
- $slot.clearSlot();
1953
- return nest.emptyNameAlert(true);
1954
- }
1955
- },
1956
- fullName: function() {
1957
- var input, nest_name;
1958
- input = $('input._nest-name');
1959
- nest_name = input.val();
1960
- if (nest.isField() && input.attr("data-left-name")) {
1961
- return (input.attr("data-left-name")) + "+" + nest_name;
1962
- } else {
1963
- return nest_name;
1964
- }
1965
- },
1966
- setNameForRules: function() {
1967
- var input, nest_name;
1968
- input = $('input._nest-name');
1969
- nest_name = input.val();
1970
- if (nest.isField()) {
1971
- if (input.attr("data-left-type")) {
1972
- return (input.attr("data-left-type")) + "+" + nest_name + "+*type plus right";
1973
- } else {
1974
- return nest_name + "+*right";
1975
- }
1976
- } else {
1977
- return nest_name + "+*self";
1978
- }
1979
- }
1980
- });
1981
-
1982
- }).call(this);
1983
-
1984
- // link_editor.js.coffee
1985
- (function() {
1986
- $(document).ready(function() {
1987
- return $('body').on('click', 'button._link-apply', function() {
1988
- return link.applyLink($(this).data("tinymce-id"), $(this).data("tm-snippet-start"), $(this).data("tm-snippet-size"));
1989
- });
1990
- });
1991
-
1992
- window.link || (window.link = {});
1993
-
1994
- $(document).ready(function() {
1995
- $('body').on('click', '._link-field-toggle', function() {
1996
- if ($(this).is(':checked')) {
1997
- return link.addPlus();
1998
- } else {
1999
- return link.removePlus();
2000
- }
2001
- });
2002
- $('body').on('input', 'input._link-target', function(event) {
2003
- return link.targetChanged();
2004
- });
2005
- return $('body').on('input', 'input._link-title', function(event) {
2006
- return link.titleChanged();
2007
- });
2008
- });
2009
-
2010
- $.extend(link, {
2011
- openLinkEditor: function(tm) {
2012
- var params;
2013
- if (typeof params === "undefined" || params === null) {
2014
- params = nest.editParams(tm, "[[", "]]");
2015
- }
2016
- return nest.openEditorForTm(tm, params, "link_editor", "modal_link_editor");
2017
- },
2018
- applyLink: function(tinymce_id, link_start, link_size) {
2019
- return nest.applySnippet("link", tinymce_id, link_start, link_size);
2020
- },
2021
- target: function() {
2022
- return link.evalFieldOption($('input._link-target').val());
2023
- },
2024
- title: function() {
2025
- return $('input._link-title').val();
2026
- },
2027
- titleChanged: function() {
2028
- var new_val;
2029
- new_val = $("._link-preview").val().replace(/^\[\[[^\]]*/, "[[" + link.target() + "|" + link.title());
2030
- return link.updatePreview(new_val);
2031
- },
2032
- targetChanged: function() {
2033
- var new_val;
2034
- new_val = $("._link-preview").val().replace(/^\[\[[^\]|]*/, "[[" + link.target());
2035
- return link.updatePreview(new_val);
2036
- },
2037
- evalFieldOption: function(name) {
2038
- if (link.isField()) {
2039
- return "+" + name;
2040
- } else {
2041
- return name;
2042
- }
2043
- },
2044
- isField: function() {
2045
- return $('._link-field-toggle').is(":checked");
2046
- },
2047
- addPlus: function() {
2048
- var new_val;
2049
- new_val = $("._link-preview").val().replace(/^\[\[\+?/, "[[+");
2050
- link.updatePreview(new_val);
2051
- return $(".input-group.hide-prefix").removeClass("hide-prefix").addClass("show-prefix");
2052
- },
2053
- removePlus: function() {
2054
- var new_val;
2055
- new_val = $("._link-preview").val().replace(/^\[\[\+?/, "[[");
2056
- link.updatePreview(new_val);
2057
- return $(".input-group.show-prefix").removeClass("show-prefix").addClass("hide-prefix");
2058
- },
2059
- updatePreview: function(new_val) {
2060
- if (new_val == null) {
2061
- new_val = "[[" + (link.target()) + "|" + (link.title()) + "]]";
2062
- }
2063
- return $("._link-preview").val(new_val);
2064
- }
2065
- });
2066
-
2067
- }).call(this);
2068
-
2069
- // components.js.coffee
2070
- (function() {
2071
- var submitAfterTyping;
2072
-
2073
- submitAfterTyping = null;
2074
-
2075
- $(window).ready(function() {
2076
- $('body').on('show.bs.tab', 'a.load[data-toggle="tab"][data-url]', function(e) {
2077
- var tab_id, url;
2078
- tab_id = $(e.target).attr('href');
2079
- url = $(e.target).data('url');
2080
- $(e.target).removeClass('load');
2081
- return $.ajax({
2082
- url: url,
2083
- type: 'GET',
2084
- success: function(html) {
2085
- $(tab_id).append(html);
2086
- return decko.contentLoaded($(tab_id), $(this));
2087
- }
2088
- });
2089
- });
2090
- $('body').on("input", "._submit-after-typing", function(event) {
2091
- var form;
2092
- form = $(event.target).closest('form');
2093
- form.slot().find(".autosubmit-success-notification").remove();
2094
- if (submitAfterTyping) {
2095
- clearTimeout(submitAfterTyping);
2096
- }
2097
- return submitAfterTyping = setTimeout(function() {
2098
- $(event.target).closest('form').submit();
2099
- return submitAfterTyping = null;
2100
- }, 1000);
2101
- });
2102
- $('body').on("keydown", "._submit-after-typing", function(event) {
2103
- if (event.which === 13) {
2104
- if (submitAfterTyping) {
2105
- clearTimeout(submitAfterTyping);
2106
- }
2107
- submitAfterTyping = null;
2108
- $(event.target).closest('form').submit();
2109
- return false;
2110
- }
2111
- });
2112
- $('body').on("change", "._submit-on-change", function(event) {
2113
- $(event.target).closest('form').submit();
2114
- return false;
2115
- });
2116
- return $('body').on("change", "._edit-item", function(event) {
2117
- var cb;
2118
- cb = $(event.target);
2119
- if (cb.is(":checked")) {
2120
- cb.attr("name", "add_item");
2121
- } else {
2122
- cb.attr("name", "drop_item");
2123
- }
2124
- $(event.target).closest('form').submit();
2125
- return false;
2126
- });
2127
- });
2128
-
2129
- }).call(this);
2130
-
2131
- // follow.js.coffee
2132
- (function() {
2133
- $(window).ready(function() {
2134
- $('body').on('click', '.btn-item', function() {
2135
- return $(this).find('i').html('hourglass_full');
2136
- });
2137
- $('body').on('mouseenter', '.btn-item-delete', function() {
2138
- $(this).find('i').html('remove');
2139
- return $(this).addClass("btn-danger").removeClass("btn-primary");
2140
- });
2141
- $('body').on('mouseleave', '.btn-item-delete', function() {
2142
- $(this).find('i').html('check');
2143
- return $(this).addClass("btn-primary").removeClass("btn-danger");
2144
- });
2145
- $('body').on('click', '.follow-updater', function() {
2146
- return $(this).closest('form').find('#card_update_all_users').val('true');
2147
- });
2148
- return $('body').on('submit', '.edit-view.SELF-Xfollow_default .card-form', function() {
2149
- var confirmer;
2150
- confirmer = $(this).find('.confirm_update_all-view');
2151
- if (confirmer.is(':hidden')) {
2152
- $(this).find('.follow-updater').show();
2153
- confirmer.show('blind');
2154
- return false;
2155
- }
2156
- });
2157
- });
2158
-
2159
- }).call(this);
2160
-
2161
- // card_menu.js.coffee
2162
- (function() {
2163
- var detectMobileBrowser;
2164
-
2165
- decko.isTouchDevice = function() {
2166
- if ('ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch) {
2167
- return true;
2168
- } else {
2169
- return detectMobileBrowser();
2170
- }
2171
- };
2172
-
2173
- detectMobileBrowser = function(userAgent) {
2174
- userAgent = navigator.userAgent || navigator.vendor || window.opera;
2175
- return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4));
2176
- };
2177
-
2178
- decko.slotReady(function(slot) {
2179
- if (decko.isTouchDevice()) {
2180
- return slot.find('._show-on-hover').removeClass('_show-on-hover');
2181
- }
2182
- });
2183
-
2184
- $(window).ready(function() {
2185
- $('body').on('show.bs.popover', '._card-menu-popover', function() {
2186
- return $(this).closest(".card-menu._show-on-hover").removeClass("_show-on-hover").addClass("_show-on-hover-disabled");
2187
- });
2188
- return $('body').on('hide.bs.popover', '._card-menu-popover', function() {
2189
- return $(this).closest(".card-menu._show-on-hover-disabled").removeClass("_show-on-hover-disabled").addClass("_show-on-hover");
2190
- });
2191
- });
2192
-
2193
- }).call(this);
2194
-
2195
- // slot_ready.js.coffee
2196
- (function() {
2197
- decko.slotReady(function(slot) {
2198
- slot.find('._disappear').delay(5000).animate({
2199
- height: 0
2200
- }, 1000, function() {
2201
- return $(this).hide();
2202
- });
2203
- if (slot.hasClass("_refresh-timer")) {
2204
- return setTimeout(function() {
2205
- return slot.reloadSlot(slot.data("refresh-url"));
2206
- }, 2000);
2207
- }
2208
- });
2209
-
2210
- }).call(this);
2211
-
2212
- // filter.js.coffee
2213
- (function() {
2214
- decko.filter = function(el) {
2215
- var closest_widget;
2216
- closest_widget = $(el).closest("._filter-widget");
2217
- this.widget = closest_widget.length ? closest_widget : $(el).closest("._filtered-content").find("._filter-widget");
2218
- this.activeContainer = this.widget.find("._filter-container");
2219
- this.dropdown = this.widget.find("._add-filter-dropdown");
2220
- this.dropdownItems = this.widget.find("._filter-category-select");
2221
- this.form = this.widget.find("._filter-form");
2222
- this.quickFilter = this.widget.find("._quick-filter");
2223
- this.showWithStatus = function(status) {
2224
- var f;
2225
- f = this;
2226
- return $.each(this.dropdownItems, function() {
2227
- var item;
2228
- item = $(this);
2229
- if (item.data(status)) {
2230
- return f.activate(item.data("category"));
2231
- }
2232
- });
2233
- };
2234
- this.reset = function() {
2235
- this.dropdownItems.show();
2236
- return this.restrict(this.form.find("._reset-filter").data("reset"));
2237
- };
2238
- this.clear = function() {
2239
- return this.activeContainer.find(".input-group").remove();
2240
- };
2241
- this.activate = function(category, value) {
2242
- this.activateField(category, value);
2243
- return this.hideOption(category);
2244
- };
2245
- this.showOption = function(category) {
2246
- this.dropdown.show();
2247
- return this.option(category).show();
2248
- };
2249
- this.hideOption = function(category) {
2250
- this.option(category).hide();
2251
- if (this.dropdownItems.length <= this.activeFields().length) {
2252
- return this.dropdown.hide();
2253
- }
2254
- };
2255
- this.activeFields = function() {
2256
- return this.activeContainer.find("._filter-input");
2257
- };
2258
- this.option = function(category) {
2259
- return this.dropdownItems.filter("[data-category='" + category + "']");
2260
- };
2261
- this.findPrototype = function(category) {
2262
- return this.widget.find("._filter-input-field-prototypes ._filter-input-" + category);
2263
- };
2264
- this.activateField = function(category, value) {
2265
- var field;
2266
- field = this.findPrototype(category).clone();
2267
- this.fieldValue(field, value);
2268
- this.dropdown.before(field);
2269
- this.initField(field);
2270
- return field.find("input, select").first().focus();
2271
- };
2272
- this.fieldValue = function(field, value) {
2273
- if (typeof value === "object") {
2274
- return this.compoundFieldValue(field, value);
2275
- } else {
2276
- return this.simpleFieldValue(field, value);
2277
- }
2278
- };
2279
- this.simpleFieldValue = function(field, value) {
2280
- var input;
2281
- input = field.find("input, select");
2282
- if (typeof value !== 'undefined') {
2283
- return input.val(value);
2284
- }
2285
- };
2286
- this.compoundFieldValue = function(field, vals) {
2287
- var input, key, results;
2288
- results = [];
2289
- for (key in vals) {
2290
- input = field.find("#filter_value_" + key);
2291
- results.push(input.val(vals[key]));
2292
- }
2293
- return results;
2294
- };
2295
- this.removeField = function(category) {
2296
- this.activeField(category).remove();
2297
- return this.showOption(category);
2298
- };
2299
- this.initField = function(field) {
2300
- this.initSelectField(field);
2301
- return decko.initAutoCardPlete(field.find("input"));
2302
- };
2303
- this.initSelectField = function(field) {
2304
- return field.find("select").select2({
2305
- containerCssClass: ":all:",
2306
- width: "auto",
2307
- dropdownAutoWidth: "true"
2308
- });
2309
- };
2310
- this.activeField = function(category) {
2311
- return this.activeContainer.find("._filter-input-" + category);
2312
- };
2313
- this.isActive = function(category) {
2314
- return this.activeField(category).length;
2315
- };
2316
- this.restrict = function(data) {
2317
- var key;
2318
- this.clear();
2319
- for (key in data) {
2320
- this.activateField(key, data[key]);
2321
- }
2322
- return this.update();
2323
- };
2324
- this.addRestrictions = function(hash) {
2325
- var category;
2326
- for (category in hash) {
2327
- this.removeField(category);
2328
- this.activate(category, hash[category]);
2329
- }
2330
- return this.update();
2331
- };
2332
- this.removeRestrictions = function(hash) {
2333
- var category;
2334
- for (category in hash) {
2335
- this.removeField(category);
2336
- }
2337
- return this.update();
2338
- };
2339
- this.setInputVal = function(field, value) {
2340
- var select;
2341
- select = field.find("select");
2342
- if (select.length) {
2343
- return this.setSelect2Val(select, value);
2344
- } else {
2345
- return this.setTextInputVal(field.find("input"), value);
2346
- }
2347
- };
2348
- this.setSelect2Val = function(select, value) {
2349
- if (select.attr("multiple") && !Array.isArray(value)) {
2350
- value = [value];
2351
- }
2352
- return select.select2("val", value);
2353
- };
2354
- this.setTextInputVal = function(input, value) {
2355
- input.val(value);
2356
- return this.update();
2357
- };
2358
- this.updateLastVals = function() {
2359
- return this.activeFields().find("input, select").each(function() {
2360
- return $(this).data("lastVal", $(this).val());
2361
- });
2362
- };
2363
- this.updateUrlBar = function() {
2364
- if (this.widget.closest('._noFilterUrlUpdates')[0]) {
2365
- return;
2366
- }
2367
- return window.history.pushState("filter", "filter", '?' + this.form.serialize());
2368
- };
2369
- this.update = function() {
2370
- this.updateLastVals();
2371
- this.updateQuickLinks();
2372
- this.form.submit();
2373
- return this.updateUrlBar();
2374
- };
2375
- this.updateQuickLinks = function() {
2376
- var links, widget;
2377
- widget = this;
2378
- links = this.quickFilter.find("._filter-link");
2379
- links.addClass("active");
2380
- return links.each(function() {
2381
- var key, link, opts, results;
2382
- link = $(this);
2383
- opts = link.data("filter");
2384
- results = [];
2385
- for (key in opts) {
2386
- results.push(widget.deactivateQuickLink(link, key, opts[key]));
2387
- }
2388
- return results;
2389
- });
2390
- };
2391
- this.deactivateQuickLink = function(link, key, value) {
2392
- var sel;
2393
- sel = "._filter-input-" + key;
2394
- return $.map([this.form.find(sel + " input, " + sel + " select").val()], function(arr) {
2395
- arr = [arr].flat();
2396
- if ($.inArray(value, arr) > -1) {
2397
- return link.removeClass("active");
2398
- }
2399
- });
2400
- };
2401
- this.updateIfChanged = function() {
2402
- if (this.changedSinceLastVal()) {
2403
- return this.update();
2404
- }
2405
- };
2406
- this.updateIfPresent = function(category) {
2407
- var val;
2408
- val = this.activeField(category).find("input, select").val();
2409
- if (val && val.length > 0) {
2410
- return this.update();
2411
- }
2412
- };
2413
- this.changedSinceLastVal = function() {
2414
- var changed;
2415
- changed = false;
2416
- this.activeFields().find("input, select").each(function() {
2417
- if ($(this).val() !== $(this).data("lastVal")) {
2418
- return changed = true;
2419
- }
2420
- });
2421
- return changed;
2422
- };
2423
- return this;
2424
- };
2425
-
2426
- }).call(this);
2427
-
2428
- // filter_links.js.coffee
2429
- (function() {
2430
- decko.slotReady(function(slot) {
2431
- return slot.find("._filter-widget").each(function() {
2432
- var filter;
2433
- if (slot[0] === $(this).slot()[0]) {
2434
- filter = new decko.filter(this);
2435
- filter.showWithStatus("active");
2436
- filter.updateLastVals();
2437
- return filter.updateQuickLinks();
2438
- }
2439
- });
2440
- });
2441
-
2442
- $(window).ready(function() {
2443
- var filterFor, filterableData, inactiveQuickfilter, keyupTimeout, onchangers, targetFilter, weirdoSelect2FilterBreaker;
2444
- filterFor = function(el) {
2445
- return new decko.filter(el);
2446
- };
2447
- weirdoSelect2FilterBreaker = function(el) {
2448
- return $(el).hasClass("select2-search__field");
2449
- };
2450
- filterableData = function(filterable) {
2451
- var f;
2452
- f = $(filterable);
2453
- return f.data("filter") || f.find("._filterable").data("filter");
2454
- };
2455
- targetFilter = function(filterable) {
2456
- var selector;
2457
- selector = $(filterable).closest("._filtering").data("filter-selector");
2458
- return filterFor(selector || this);
2459
- };
2460
- $("body").on("click", "._filter-category-select", function(e) {
2461
- var category, f;
2462
- e.preventDefault();
2463
- f = filterFor(this);
2464
- category = $(this).data("category");
2465
- f.activate(category);
2466
- return f.updateIfPresent(category);
2467
- });
2468
- onchangers = "._filter-input input:not(.simple-text), ._filter-input select, ._filter-sort";
2469
- $("body").on("change", onchangers, function() {
2470
- if (weirdoSelect2FilterBreaker(this)) {
2471
- return;
2472
- }
2473
- return filterFor(this).update();
2474
- });
2475
- keyupTimeout = null;
2476
- $("body").on("keyup", "._filter-input input.simple-text", function() {
2477
- var filter;
2478
- clearTimeout(keyupTimeout);
2479
- filter = filterFor(this);
2480
- return keyupTimeout = setTimeout((function() {
2481
- return filter.updateIfChanged();
2482
- }), 333);
2483
- });
2484
- $("body").on("click", "._delete-filter-input", function() {
2485
- var filter;
2486
- filter = filterFor(this);
2487
- filter.removeField($(this).closest("._filter-input").data("category"));
2488
- return filter.update();
2489
- });
2490
- $('body').on('click', '._reset-filter', function() {
2491
- var f;
2492
- f = filterFor(this);
2493
- f.reset();
2494
- return f.update();
2495
- });
2496
- $('body').on('click', '._filtering ._filterable', function(e) {
2497
- var f;
2498
- f = targetFilter(this);
2499
- if (f.widget.length) {
2500
- f.restrict(filterableData(this));
2501
- }
2502
- e.preventDefault();
2503
- return e.stopPropagation();
2504
- });
2505
- $('body').on('click', '._filter-link', function(e) {
2506
- var f, filter_data, link;
2507
- f = filterFor(this);
2508
- link = $(this);
2509
- filter_data = link.data("filter");
2510
- if (inactiveQuickfilter(link)) {
2511
- f.removeRestrictions(filter_data);
2512
- } else {
2513
- f.addRestrictions(filter_data);
2514
- }
2515
- e.preventDefault();
2516
- return e.stopPropagation();
2517
- });
2518
- return inactiveQuickfilter = function(link) {
2519
- return !link.hasClass("active") && link.closest(".quick-filter").length > 0;
2520
- };
2521
- });
2522
-
2523
- }).call(this);
2524
-
2525
- // filter_items.js.coffee
2526
- (function() {
2527
- var addSelectedButton, addSelectedButtonUrl, arrayFromField, deselectAllLink, filterBox, newFilteredListContent, prefilteredData, prefilteredIds, prefilteredNames, selectFilteredItem, selectedBin, selectedData, selectedIds, selectedNames, trackSelectedIds, updateAfterSelection, updateSelectedCount, updateSelectedSectionVisibility, updateUnselectedCount;
2528
-
2529
- $(window).ready(function() {
2530
- $("body").on("click", "._filter-items ._add-selected", function() {
2531
- var btn, content;
2532
- btn = $(this);
2533
- content = newFilteredListContent(btn);
2534
- return btn.attr("href", addSelectedButtonUrl(btn, content));
2535
- });
2536
- $("body").on("click", "._select-all", function() {
2537
- filterBox($(this)).find("._unselected input._checkbox-list-checkbox").each(function() {
2538
- return selectFilteredItem($(this));
2539
- });
2540
- $(this).prop("checked", false);
2541
- return updateAfterSelection($(this));
2542
- });
2543
- $("body").on("click", "._deselect-all", function() {
2544
- filterBox($(this)).find("._selected input._checkbox-list-checkbox").each(function() {
2545
- return $(this).slot().remove();
2546
- });
2547
- $(this).prop("checked", true);
2548
- return updateAfterSelection($(this));
2549
- });
2550
- $("body").on("click", "._filter-items ._unselected input._checkbox-list-checkbox", function() {
2551
- selectFilteredItem($(this));
2552
- return updateAfterSelection($(this));
2553
- });
2554
- $("body").on("click", "._filter-items ._selected input._checkbox-list-checkbox", function() {
2555
- var bin;
2556
- bin = selectedBin($(this));
2557
- $(this).slot().remove();
2558
- return updateAfterSelection(bin);
2559
- });
2560
- return $('body').on('click', '._filtered-list-item-delete', function() {
2561
- return $(this).closest('li').remove();
2562
- });
2563
- });
2564
-
2565
- newFilteredListContent = function(el) {
2566
- return $.map(prefilteredIds(el).concat(selectedIds(el)), function(id) {
2567
- return "~" + id;
2568
- }).join("\n");
2569
- };
2570
-
2571
- addSelectedButtonUrl = function(btn, content) {
2572
- var card_args, path_base, query, view;
2573
- view = btn.slot().data("slot")["view"];
2574
- card_args = {
2575
- content: content,
2576
- type: "Pointer"
2577
- };
2578
- query = {
2579
- assign: true,
2580
- view: view,
2581
- card: card_args
2582
- };
2583
- path_base = btn.attr("href") + "&" + $.param(query);
2584
- return decko.slotPath(path_base, btn.slot());
2585
- };
2586
-
2587
- updateAfterSelection = function(el) {
2588
- var f;
2589
- trackSelectedIds(el);
2590
- f = new decko.filter(filterBox(el).find('._filter-widget'));
2591
- f.update();
2592
- updateSelectedCount(el);
2593
- return updateUnselectedCount(el);
2594
- };
2595
-
2596
- updateSelectedCount = function(el) {
2597
- var count;
2598
- count = selectedBin(el).children().length;
2599
- filterBox(el).find("._selected-items").html(count);
2600
- deselectAllLink(el).attr("disabled", count === 0);
2601
- if (count > 0) {
2602
- addSelectedButton(el).removeClass("disabled");
2603
- } else {
2604
- addSelectedButton(el).addClass("disabled");
2605
- }
2606
- return updateSelectedSectionVisibility(el, count > 0);
2607
- };
2608
-
2609
- updateSelectedSectionVisibility = function(el, items_present) {
2610
- var box, help_text, selected_items;
2611
- box = filterBox(el);
2612
- selected_items = box.find("._selected-item-list");
2613
- help_text = box.find("._filter-help");
2614
- if (items_present) {
2615
- selected_items.show();
2616
- return help_text.hide();
2617
- } else {
2618
- selected_items.hide();
2619
- return help_text.show();
2620
- }
2621
- };
2622
-
2623
- updateUnselectedCount = function(el) {
2624
- var box, count;
2625
- box = filterBox(el);
2626
- count = box.find("._search-checkbox-list").children().length;
2627
- box.find("._unselected-items").html(count);
2628
- return box.find("._select-all").attr("disabled", count > 0);
2629
- };
2630
-
2631
- selectFilteredItem = function(checkbox) {
2632
- checkbox.prop("checked", true);
2633
- return selectedBin(checkbox).append(checkbox.slot());
2634
- };
2635
-
2636
- selectedBin = function(el) {
2637
- return filterBox(el).find("._selected-bin");
2638
- };
2639
-
2640
- filterBox = function(el) {
2641
- return el.closest("._filter-items");
2642
- };
2643
-
2644
- addSelectedButton = function(el) {
2645
- return filterBox(el).find("._add-selected");
2646
- };
2647
-
2648
- deselectAllLink = function(el) {
2649
- return filterBox(el).find("._deselect-all");
2650
- };
2651
-
2652
- selectedIds = function(el) {
2653
- return selectedData(el, "cardId");
2654
- };
2655
-
2656
- prefilteredIds = function(el) {
2657
- return prefilteredData(el, "cardId");
2658
- };
2659
-
2660
- prefilteredNames = function(el) {
2661
- return prefilteredData(el, "cardName");
2662
- };
2663
-
2664
- prefilteredData = function(el, field) {
2665
- var btn, selector;
2666
- btn = addSelectedButton(el);
2667
- selector = btn.data("itemSelector");
2668
- return arrayFromField(btn.slot().find(selector), field);
2669
- };
2670
-
2671
- selectedNames = function(el) {
2672
- return selectedData(el, "cardName");
2673
- };
2674
-
2675
- selectedData = function(el, field) {
2676
- return arrayFromField(selectedBin(el).children(), field);
2677
- };
2678
-
2679
- arrayFromField = function(rows, field) {
2680
- return rows.map(function() {
2681
- return $(this).data(field);
2682
- }).toArray();
2683
- };
2684
-
2685
- trackSelectedIds = function(el) {
2686
- var box, ids;
2687
- ids = prefilteredIds(el).concat(selectedIds(el));
2688
- box = filterBox(el);
2689
- return box.find("._not-ids").val(ids.toString());
2690
- };
2691
-
2692
- }).call(this);
2693
-
2694
- // selectable_filtered_content.js.coffee
2695
- (function() {
2696
- $(window).ready(function() {
2697
- return $("body").on("click", "._selectable-filtered-content .bar-body", function(e) {
2698
- var container, input, item, name;
2699
- item = $(this);
2700
- name = item.slot().data("card-name");
2701
- container = item.closest("._selectable-filtered-content");
2702
- input = $(container.data("input-selector"));
2703
- input.val(name);
2704
- item.closest('.modal').modal('hide');
2705
- e.preventDefault();
2706
- return e.stopPropagation();
2707
- });
2708
- });
2709
-
2710
- }).call(this);