card-mod-script 0.13.3 → 0.14.2

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