card-mod-script 0.14.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/data/real.yml +50 -0
  3. data/lib/ansi2html.rb +69 -0
  4. data/lib/card/mod/script.rb +1 -0
  5. data/set/abstract/00_script.rb +4 -4
  6. data/set/abstract/02_coffee_script.rb +9 -1
  7. data/set/all/head_javascript.rb +13 -22
  8. data/set/right/script.rb +1 -1
  9. data/set/type/coffee_script.rb +6 -0
  10. data/set/type/java_script.rb +6 -0
  11. data/set/type/local_script_folder_group.rb +2 -0
  12. data/set/type/local_script_manifest_group.rb +2 -0
  13. data/set/type_plus_right/mod/script.rb +1 -5
  14. data/set/type_plus_right/set/script.rb +3 -1
  15. metadata +13 -119
  16. data/assets/script/decko/autosave.js.coffee +0 -30
  17. data/assets/script/decko/bridge.js.coffee +0 -31
  18. data/assets/script/decko/card_menu.js.coffee +0 -26
  19. data/assets/script/decko/components.js.coffee +0 -49
  20. data/assets/script/decko/decko.js.coffee +0 -82
  21. data/assets/script/decko/doubleclick.js.coffee +0 -30
  22. data/assets/script/decko/editor.js.coffee +0 -57
  23. data/assets/script/decko/filter.js.coffee +0 -183
  24. data/assets/script/decko/filter_items.js.coffee +0 -128
  25. data/assets/script/decko/filter_links.js.coffee +0 -81
  26. data/assets/script/decko/follow.js.coffee +0 -22
  27. data/assets/script/decko/layout.js.coffee +0 -76
  28. data/assets/script/decko/link_editor.js.coffee +0 -61
  29. data/assets/script/decko/mod.js.coffee +0 -79
  30. data/assets/script/decko/modal.js.coffee +0 -113
  31. data/assets/script/decko/name_editor.js.coffee +0 -40
  32. data/assets/script/decko/navbox.js.coffee +0 -74
  33. data/assets/script/decko/nest_editor.js.coffee +0 -166
  34. data/assets/script/decko/nest_editor_name.js.coffee +0 -102
  35. data/assets/script/decko/nest_editor_options.js.coffee +0 -93
  36. data/assets/script/decko/nest_editor_rules.js.coffee +0 -3
  37. data/assets/script/decko/overlay.js.coffee +0 -54
  38. data/assets/script/decko/pointer_config.js.coffee +0 -79
  39. data/assets/script/decko/pointer_list_editor.js.coffee +0 -67
  40. data/assets/script/decko/recaptcha.js.coffee +0 -19
  41. data/assets/script/decko/selectable_filtered_content.js.coffee +0 -12
  42. data/assets/script/decko/slot.js.coffee +0 -182
  43. data/assets/script/decko/slot_ready.js.coffee +0 -12
  44. data/assets/script/decko/slotter.js.coffee +0 -268
  45. data/assets/script/decko/type_editor.js.coffee +0 -21
  46. data/assets/script/decko/upload.js.coffee +0 -64
  47. data/assets/script/jquery-ui.min.js +0 -13
  48. data/assets/script/jquery.autosize.js +0 -274
  49. data/assets/script/manifest.yml +0 -57
  50. data/db/migrate_core_cards/20200804112348_add_mod_script_assets_type.rb +0 -30
  51. data/vendor/jquery_file_upload/LICENSE.txt +0 -20
  52. data/vendor/jquery_file_upload/README.md +0 -224
  53. data/vendor/jquery_file_upload/SECURITY.md +0 -227
  54. data/vendor/jquery_file_upload/VULNERABILITIES.md +0 -118
  55. data/vendor/jquery_file_upload/cors/postmessage.html +0 -85
  56. data/vendor/jquery_file_upload/cors/result.html +0 -26
  57. data/vendor/jquery_file_upload/css/jquery.fileupload-noscript.css +0 -22
  58. data/vendor/jquery_file_upload/css/jquery.fileupload-ui-noscript.css +0 -17
  59. data/vendor/jquery_file_upload/css/jquery.fileupload-ui.css +0 -68
  60. data/vendor/jquery_file_upload/css/jquery.fileupload.css +0 -36
  61. data/vendor/jquery_file_upload/docker-compose.yml +0 -55
  62. data/vendor/jquery_file_upload/img/loading.gif +0 -0
  63. data/vendor/jquery_file_upload/img/progressbar.gif +0 -0
  64. data/vendor/jquery_file_upload/index.html +0 -357
  65. data/vendor/jquery_file_upload/js/cors/jquery.postmessage-transport.js +0 -126
  66. data/vendor/jquery_file_upload/js/cors/jquery.xdr-transport.js +0 -97
  67. data/vendor/jquery_file_upload/js/demo.js +0 -75
  68. data/vendor/jquery_file_upload/js/jquery.fileupload-audio.js +0 -101
  69. data/vendor/jquery_file_upload/js/jquery.fileupload-image.js +0 -347
  70. data/vendor/jquery_file_upload/js/jquery.fileupload-process.js +0 -170
  71. data/vendor/jquery_file_upload/js/jquery.fileupload-ui.js +0 -759
  72. data/vendor/jquery_file_upload/js/jquery.fileupload-validate.js +0 -119
  73. data/vendor/jquery_file_upload/js/jquery.fileupload-video.js +0 -101
  74. data/vendor/jquery_file_upload/js/jquery.fileupload.js +0 -1604
  75. data/vendor/jquery_file_upload/js/jquery.iframe-transport.js +0 -227
  76. data/vendor/jquery_file_upload/js/vendor/jquery.ui.widget.js +0 -805
  77. data/vendor/jquery_file_upload/package-lock.json +0 -6853
  78. data/vendor/jquery_file_upload/package.json +0 -116
  79. data/vendor/jquery_file_upload/server/gae-python/app.yaml +0 -18
  80. data/vendor/jquery_file_upload/server/gae-python/main.py +0 -204
  81. data/vendor/jquery_file_upload/server/gae-python/static/favicon.ico +0 -0
  82. data/vendor/jquery_file_upload/server/gae-python/static/robots.txt +0 -2
  83. data/vendor/jquery_file_upload/server/php/Dockerfile +0 -44
  84. data/vendor/jquery_file_upload/server/php/UploadHandler.php +0 -1480
  85. data/vendor/jquery_file_upload/server/php/index.php +0 -15
  86. data/vendor/jquery_file_upload/server/php/php.ini +0 -5
  87. data/vendor/jquery_file_upload/test/index.html +0 -49
  88. data/vendor/jquery_file_upload/test/unit.js +0 -989
  89. data/vendor/jquery_file_upload/test/vendor/chai.js +0 -10854
  90. data/vendor/jquery_file_upload/test/vendor/mocha.css +0 -325
  91. data/vendor/jquery_file_upload/test/vendor/mocha.js +0 -18178
  92. data/vendor/jquery_file_upload/wdio/LICENSE.txt +0 -20
  93. data/vendor/jquery_file_upload/wdio/assets/black+white-3x2.jpg +0 -0
  94. data/vendor/jquery_file_upload/wdio/assets/black+white-60x40.gif +0 -0
  95. data/vendor/jquery_file_upload/wdio/conf/chrome.js +0 -40
  96. data/vendor/jquery_file_upload/wdio/conf/firefox.js +0 -25
  97. data/vendor/jquery_file_upload/wdio/hooks/index.js +0 -36
  98. data/vendor/jquery_file_upload/wdio/test/pages/file-upload.js +0 -79
  99. data/vendor/jquery_file_upload/wdio/test/specs/01-file-upload.js +0 -25
  100. data/vendor/jquery_file_upload/wdio/wdio.conf.js +0 -4
  101. data/vendor/jquery_rails/CHANGELOG.md +0 -359
  102. data/vendor/jquery_rails/CONTRIBUTING.md +0 -132
  103. data/vendor/jquery_rails/Gemfile +0 -22
  104. data/vendor/jquery_rails/MIT-LICENSE +0 -21
  105. data/vendor/jquery_rails/README.md +0 -75
  106. data/vendor/jquery_rails/Rakefile +0 -59
  107. data/vendor/jquery_rails/VERSIONS.md +0 -62
  108. data/vendor/jquery_rails/jquery-rails.gemspec +0 -26
  109. data/vendor/jquery_rails/lib/jquery/assert_select.rb +0 -149
  110. data/vendor/jquery_rails/lib/jquery/rails/engine.rb +0 -6
  111. data/vendor/jquery_rails/lib/jquery/rails/version.rb +0 -9
  112. data/vendor/jquery_rails/lib/jquery/rails.rb +0 -8
  113. data/vendor/jquery_rails/lib/jquery-rails.rb +0 -1
  114. data/vendor/jquery_rails/test/assert_select_jquery_test.rb +0 -85
  115. data/vendor/jquery_rails/test/test_helper.rb +0 -6
  116. data/vendor/jquery_rails/vendor/assets/javascripts/jquery.js +0 -11008
  117. data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.js +0 -5
  118. data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.map +0 -1
  119. data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.js +0 -9814
  120. data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.js +0 -4
  121. data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.map +0 -1
  122. data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.js +0 -10364
  123. data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.js +0 -2
  124. data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.map +0 -1
  125. data/vendor/jquery_rails/vendor/assets/javascripts/jquery_ujs.js +0 -555
@@ -1,102 +0,0 @@
1
- nestNameTimeout = null
2
-
3
- $(document).ready ->
4
- $('body').on 'click', '._nest-field-toggle', () ->
5
- if $(this).is(':checked')
6
- nest.addPlus()
7
- else
8
- nest.removePlus()
9
-
10
- $('body').on 'input', 'input._nest-name', (event) ->
11
- nest.nameChanged()
12
-
13
- unless event.which == 13
14
- clearTimeout(nestNameTimeout) if nestNameTimeout
15
- nestNameTimeout = setTimeout (-> nest.updateNameRelatedTabs()), 700
16
-
17
- $('body').on 'keydown', 'input._nest-name', (event) ->
18
- if event.which == 13
19
- clearTimeout(nestNameTimeout) if nestNameTimeout
20
- nest.updateNameRelatedTabs()
21
-
22
- $.extend nest,
23
- name: () ->
24
- nest.evalFieldOption $('input._nest-name').val()
25
-
26
- nameChanged: () ->
27
- new_val = $("._nest-preview").val().replace(/^\{\{[^}|]*/, "{{" + nest.name())
28
- nest.updatePreview new_val
29
-
30
- evalFieldOption: (name) ->
31
- if nest.isField() then "+#{name}" else name
32
-
33
- isField: ->
34
- $('._nest-field-toggle').is(":checked")
35
-
36
- addPlus: () ->
37
- new_val = $("._nest-preview").val().replace(/^\{\{\+?/, "{{+")
38
- nest.updatePreview new_val
39
- $(".input-group.hide-prefix").removeClass("hide-prefix").addClass("show-prefix")
40
-
41
- removePlus: () ->
42
- new_val = $("._nest-preview").val().replace(/^\{\{\+?/, "{{")
43
- nest.updatePreview new_val
44
- $(".input-group.show-prefix").removeClass("show-prefix").addClass("hide-prefix")
45
-
46
- rulesTabSlot: () ->
47
- $("._nest-editor .tab-pane-rules > .card-slot")
48
-
49
- contentTabSlot: () ->
50
- $("._nest-editor .tab-pane-content > .card-slot")
51
-
52
- emptyNameAlert: (show) ->
53
- if show
54
- $("._empty-nest-name-alert").removeClass("d-none")
55
- else
56
- $("._empty-nest-name-alert:not(.d-none)").addClass("d-none")
57
-
58
- updateNameRelatedTabs: () ->
59
- nest.updateRulesTab()
60
- nest.updateContentTab()
61
-
62
- updateContentTab: () ->
63
- $contentTab = nest.contentTabSlot()
64
- if $contentTab.length > 0
65
- url = decko.path "#{nest.fullName()}?view=nest_content"
66
- nest.updateNameDependentSlot($contentTab, url)
67
-
68
- updateRulesTab: () ->
69
- $rulesTab = nest.rulesTabSlot()
70
- url = decko.path "#{nest.setNameForRules()}?view=nest_rules"
71
- nest.updateNameDependentSlot($rulesTab, url)
72
-
73
- updateNameDependentSlot: ($slot, url) ->
74
- name = $("input._nest-name").val()
75
- if name? && name.length > 0
76
- nest.emptyNameAlert(false)
77
- $slot.reloadSlot url
78
- else
79
- $slot.clearSlot()
80
- nest.emptyNameAlert(true)
81
-
82
- fullName: () ->
83
- input = $('input._nest-name')
84
- nest_name = input.val()
85
- if nest.isField() and input.attr("data-left-name")
86
- "#{input.attr("data-left-name")}+#{nest_name}"
87
- else
88
- nest_name
89
-
90
- # set in the sense of card set
91
- setNameForRules: () ->
92
- input = $('input._nest-name')
93
- nest_name = input.val()
94
- if nest.isField()
95
- if input.attr("data-left-type")
96
- "#{input.attr("data-left-type")}+#{nest_name}+*type plus right"
97
- else
98
- "#{nest_name}+*right"
99
- else
100
- return "#{nest_name}+*self"
101
-
102
-
@@ -1,93 +0,0 @@
1
- $(document).ready ->
2
- $('body').on 'keyup', 'input._nest-option-value', () ->
3
- nest.updatePreview()
4
-
5
- $('body').on "select2:select", "._nest-option-name", () ->
6
- nest.toggleOptionName($(this).closest("._options-select"), $(this).val(), true)
7
- nest.updatePreview()
8
-
9
- $('body').on "select2:selecting", "._nest-option-name", () ->
10
- nest.toggleOptionName($(this).closest("._options-select"), $(this).val(), false)
11
-
12
- $('body').on "select2:select", "._nest-option-name._new-row", () ->
13
- $(this).closest(".input-group").find(".input-group-prepend").removeClass("d-none")
14
- row = $(this).closest("._nest-option-row")
15
- row.find("._nest-option-value").removeAttr("disabled")
16
- template = row.parent().find("._nest-option-row._template")
17
- $(this).removeClass("_new-row")
18
- nest.addRow(template)
19
-
20
- $('body').on "click", "._configure-items-button", () ->
21
- nest.addItemsOptions($(this))
22
-
23
- $('body').on 'click', 'button._nest-delete-option', () ->
24
- nest.removeRow $(this).closest("._nest-option-row")
25
-
26
- $.extend nest,
27
- showTemplate: (elem) ->
28
- elem.removeClass("_template") #.removeClass("_#{name}-template").addClass("_#{name}")
29
-
30
- addRow: (template) ->
31
- select_tag = template.find("select")
32
- select_tag.select2("destroy")
33
- select_tag.removeAttr("data-select2-id")
34
- double = template.clone()
35
- #double = template.cloneSelect2(true, true)
36
- decko.initSelect2(select_tag)
37
- nest.showTemplate template
38
- template.after(double)
39
- decko.initSelect2(double.find("select"))
40
-
41
- removeRow: (row) ->
42
- name = row.find("._nest-option-name").val()
43
- nest.toggleOptionName(row.closest("._options-select"), name,false)
44
- row.remove()
45
- nest.updatePreview()
46
-
47
- addItemsOptions: (button) ->
48
- container = button.closest("._configure-items")
49
- next = container.cloneSelect2(true)
50
- title = button.text()
51
- button.replaceWith($("<h6>#{title.substr(9)}<h6>"))
52
- nest.showTemplate container.find("._options-select._template")
53
- next.find("._configure-items-button").text(title.replace("items", "subitems"))
54
- container.after(next)
55
- nest.updatePreview()
56
-
57
- options: () ->
58
- options = []
59
- for ele in $("._options-select:not(._template")
60
- options.push nest.extractOptions($(ele))
61
-
62
- level_options = options.map (opts) ->
63
- nest.toNestSyntax(opts)
64
- level_options.join "|"
65
-
66
- # extract options for one item level
67
- extractOptions: (ele) ->
68
- options = {}
69
- nest.addOption(options, $(row)) for row in ele.find("._nest-option-row:not(.template)")
70
- options
71
-
72
- addOption: (options, row) ->
73
- val = row.find("._nest-option-value").val()
74
- return unless val? && val.length > 0
75
-
76
- name = row.find("._nest-option-name").val()
77
- if options[name]?
78
- options[name].push val
79
- else
80
- options[name] = [val]
81
-
82
- toggleOptionName: (container, name, active) ->
83
- return true if name == "show" || name == "hide"
84
- for sel in container.find("._nest-option-name")
85
- if $(sel).val() != name
86
- $(sel).find("option[value=#{name}]").attr "disabled", active
87
- # $(sel).find("option[value=#{val}]").removeAttr "disabled"
88
- decko.initSelect2($(sel))
89
-
90
- toNestSyntax: (opts) ->
91
- str = []
92
- str.push "#{name}: #{values.join ', '}" for name, values of opts
93
- str.join "; "
@@ -1,54 +0,0 @@
1
- jQuery.fn.extend
2
- overlaySlot: ->
3
- oslot = @closest(".card-slot._overlay")
4
- return oslot if oslot[0]?
5
- oslot = @closest(".overlay-container").find("._overlay")
6
- oslot[0]? && $(oslot[0])
7
-
8
- addOverlay: (overlay, $slotter) ->
9
- if @parent().hasClass("overlay-container")
10
- if $(overlay).hasClass("_stack-overlay")
11
- @before overlay
12
- else
13
- $("._overlay-origin").removeClass("_overlay-origin")
14
- @replaceOverlay(overlay)
15
- else
16
- if @parent().hasClass("_overlay-container-placeholder")
17
- @parent().addClass("overlay-container")
18
- else
19
- @wrapAll('<div class="overlay-container">')
20
- @addClass("_bottomlay-slot")
21
- @before overlay
22
-
23
- $slotter.registerAsOrigin("overlay", overlay)
24
- decko.contentLoaded(overlay, $slotter)
25
-
26
- replaceOverlay: (overlay) ->
27
- @overlaySlot().trigger "slotDestroy"
28
- @overlaySlot().replaceWith overlay
29
- $(".bridge-sidebar .tab-pane:not(.active) .bridge-pills > .nav-item > .nav-link.active").removeClass("active")
30
-
31
- isInOverlay: ->
32
- return @closest(".card-slot._overlay").length
33
-
34
- removeOverlay: () ->
35
- slot = @overlaySlot()
36
- if slot
37
- slot.removeOverlaySlot()
38
-
39
- removeOverlaySlot: () ->
40
- @trigger "slotDestroy"
41
- if @siblings().length == 1
42
- bottomlay = $(@siblings()[0])
43
- if bottomlay.hasClass("_bottomlay-slot")
44
- if bottomlay.parent().hasClass("_overlay-container-placeholder")
45
- bottomlay.parent().removeClass("overlay-container")
46
- else
47
- bottomlay.unwrap()
48
- bottomlay.removeClass("_bottomlay-slot").updateBridge(true, bottomlay)
49
-
50
- #bottomlay.find(".tinymce-textarea").each ->
51
- # tinymce.EditorManager.execCommand('mceAddControl',true, editor_id);
52
- # decko.initTinyMCE($(this).attr("id"))
53
-
54
- @remove()
@@ -1,79 +0,0 @@
1
- $.extend decko.editorContentFunctionMap,
2
- 'select.pointer-select': ->
3
- pointerContent @val()
4
- 'select.pointer-multiselect': ->
5
- pointerContent @val()
6
- '.pointer-radio-list': ->
7
- pointerContent @find('input:checked').val()
8
- '.pointer-list-ul': ->
9
- pointerContent @find('input').map( -> $(this).val() )
10
- '.pointer-link-list-ul': ->
11
- decko.linkListContent @find('.input-group')
12
- '._nest-list-ul': ->
13
- decko.nestListContent @find('.input-group')
14
- '.pointer-checkbox-list': ->
15
- pointerContent @find('input:checked').map( -> $(this).val() )
16
- '.pointer-select-list': ->
17
- pointerContent @find('.pointer-select select').map( -> $(this).val() )
18
- '._pointer-filtered-list': ->
19
- pointerContent @find('._filtered-list-item').map( -> $(this).data('cardName') )
20
- '._pointer-list': ->
21
- pointerContent @find('._pointer-item').map( -> $(this).val() )
22
- # can't find evidence that the following is in use: #efm
23
- # '.pointer-mixed': ->
24
- # element = '.pointer-checkbox-sublist input:checked,\
25
- # .pointer-sublist-ul input'
26
- # pointerContent @find(element).map( -> $(this).val() )
27
- # must happen after pointer-list-ul, I think
28
- '.perm-editor': -> permissionsContent this
29
-
30
- decko.editorInitFunctionMap['.pointer-list-editor'] = ->
31
- @sortable({handle: '.handle', cancel: ''})
32
- decko.initPointerList @find('input')
33
-
34
- decko.editorInitFunctionMap['._pointer-filtered-list'] = ->
35
- @sortable({handle: '._handle', cancel: ''})
36
-
37
- $.extend decko,
38
- initPointerList: (input) ->
39
- decko.initAutoCardPlete input
40
-
41
- initAutoCardPlete: (input) ->
42
- optionsCard = input.data 'options-card'
43
- return unless !!optionsCard
44
- path = optionsCard + '.json?view=name_match'
45
- input.autocomplete { source: decko.slotPath(path) }
46
-
47
- pointerContent: (vals) ->
48
- $.makeArray(vals).join "\n"
49
-
50
- linkListContent: (input_groups) ->
51
- vals = input_groups.map( ->
52
- v = $(this).find('input._reference').val()
53
- title = $(this).find('input._title').val()
54
- v += "|#{title}" if title.length > 0
55
- v
56
- )
57
- list = $.map $.makeArray(vals), (v) -> if v then '[[' + v + ']]'
58
- $.makeArray(list).join "\n"
59
-
60
- nestListContent: (input_groups) ->
61
- vals = input_groups.map( ->
62
- v = $(this).find('input._reference').val()
63
- options = $(this).find('input._nest-options').val()
64
- v += "|#{options}" if options.length > 0
65
- v
66
- )
67
- list = $.map $.makeArray(vals), (v) -> if v then '{{' + v + '}}'
68
- $.makeArray(list).join "\n"
69
-
70
-
71
- pointerContent = (vals) ->
72
- decko.pointerContent vals
73
- # deprecated. backwards compatibility
74
-
75
- permissionsContent = (ed) ->
76
- return '_left' if ed.find('#inherit').is(':checked')
77
- groups = ed.find('.perm-group input:checked').map( -> $(this).val() )
78
- indivs = ed.find('.perm-indiv input' ).map( -> $(this).val() )
79
- pointerContent $.makeArray(groups).concat($.makeArray(indivs))
@@ -1,67 +0,0 @@
1
- $(window).ready ->
2
- # add pointer item when clicking on "add another" button
3
- $('body').on 'click', '._pointer-item-add', (event)->
4
- decko.addPointerItem this
5
- event.preventDefault() # Prevent link from following its href
6
-
7
- # add pointer item when you hit enter in an item
8
- $('body').on 'keydown', '.pointer-item-text', (event)->
9
- if event.key == 'Enter'
10
- decko.addPointerItem this
11
- event.preventDefault() # was triggering extra item in unrelated pointer
12
-
13
- # enable/disable add
14
- $('body').on 'keyup', '.pointer-item-text', (_event)->
15
- decko.updateAddItemButton this
16
-
17
- $('body').on 'click', '.pointer-item-delete', ->
18
- item = $(this).closest 'li'
19
- list = item.closest('ul')
20
- if list.find('.pointer-li').length > 1
21
- item.remove()
22
- else
23
- item.find('input').val ''
24
- decko.updateAddItemButton(list)
25
-
26
- decko.slotReady (slot) ->
27
- slot.find('.pointer-list-editor').each ->
28
- decko.updateAddItemButton this
29
-
30
- $.extend decko,
31
- addPointerItem: (el) ->
32
- slot = $(el).slot()
33
- slot.trigger "slotDestroy"
34
- # why is this necessary?
35
- # this can have a lot of side effects in a multi-card form.
36
-
37
- newInput = decko.nextPointerInput decko.lastPointerItem(el)
38
- newInput.val ''
39
-
40
- slot.trigger "slotReady"
41
- decko.initializeEditors slot
42
- # should be (but is not) handled by slotReady
43
- # without this, "add another" was breaking tinymce editors in same slot
44
-
45
- newInput.first().focus()
46
- decko.updateAddItemButton el
47
- decko.initPointerList newInput
48
-
49
- nextPointerInput: (lastItem)->
50
- lastInputs = lastItem.find 'input'
51
- all_empty = true
52
- for input in lastInputs
53
- all_empty = all_empty and $(input).val() == ''
54
- return lastInputs if all_empty
55
-
56
- newItem = lastItem.clone()
57
- lastItem.after newItem
58
- newItem.attr("data-index", parseInt(lastItem.attr("data-index") + 1))
59
- newItem.find 'input'
60
-
61
- lastPointerItem: (el)->
62
- $(el).closest('.content-editor').find '.pointer-li:last'
63
-
64
- updateAddItemButton: (el)->
65
- button = $(el).closest('.content-editor').find '._pointer-item-add'
66
- disabled = decko.lastPointerItem(el).find('input').val() == ''
67
- button.prop 'disabled', disabled
@@ -1,19 +0,0 @@
1
- jQuery.fn.extend {
2
- updateRecaptchaToken: (event) ->
3
- recaptcha = @find("input._recaptcha-token")
4
-
5
- if !recaptcha[0]?
6
- recaptcha.val "recaptcha-token-field-missing"
7
- else if !grecaptcha?
8
- recaptcha.val("grecaptcha-undefined")
9
- else
10
- $slotter = $(this)
11
- event.stopPropagation() if event
12
- grecaptcha.execute(recaptcha.data("site-key"), action: recaptcha.data("action"))
13
- .then (token) ->
14
- recaptcha.val(token)
15
- recaptcha.addClass("_token-updated")
16
- if event
17
- $slotter.submit()
18
- false
19
- }
@@ -1,12 +0,0 @@
1
- $(window).ready ->
2
-
3
- # TODO: generalize so this works with item views other than bar
4
- $("body").on "click", "._selectable-filtered-content .bar-body", (e) ->
5
- item = $(this)
6
- name = item.slot().data("card-name")
7
- container = item.closest("._selectable-filtered-content")
8
- input = $(container.data("input-selector"))
9
- input.val name
10
- item.closest('.modal').modal('hide')
11
- e.preventDefault()
12
- e.stopPropagation()
@@ -1,182 +0,0 @@
1
- $.extend decko,
2
- snakeCase: (str)->
3
- str.replace /([a-z])([A-Z])/g, (match) -> match[0] + '_' +
4
- match[1].toLowerCase()
5
-
6
- # returns full path with slot parameters
7
- slotPath: (path, slot)->
8
- params = decko.slotData(slot)
9
- decko.path(path) + ( (if path.match /\?/ then '&' else '?') + $.param(params) )
10
-
11
- slotData: (slot) ->
12
- xtra = {}
13
- main = $('#main').children('.card-slot').data 'cardName'
14
- xtra['main'] = main if main?
15
-
16
- if slot
17
- xtra['is_main'] = true if slot.isMain()
18
- slotdata = slot.data 'slot'
19
- if slotdata?
20
- decko.slotParams slotdata, xtra, 'slot'
21
- xtra['type'] = slotdata['type'] if slotdata['type']
22
- xtra
23
-
24
- slotEditView: (slot) ->
25
- data = decko.slotData(slot)
26
- switch data["slot[edit]"]
27
- when "inline" then "edit_inline"
28
- when "full" then "bridge"
29
- else "edit"
30
-
31
- slotEditLink: (slot) ->
32
- edit_links =
33
- slot.find(".edit-link").filter (i, el) ->
34
- $(el).slot().data('slotId') == slot.data('slotId')
35
-
36
- if edit_links[0] then $(edit_links[0]) else false
37
-
38
- slotParams: (raw, processed, prefix)->
39
- $.each raw, (key, value)->
40
- cgiKey = prefix + '[' + decko.snakeCase(key) + ']'
41
- if key == 'items'
42
- decko.slotParams value, processed, cgiKey
43
- else
44
- processed[cgiKey] = value
45
-
46
- contentLoaded: (el, slotter)->
47
- decko.initializeEditors(el)
48
- notice = slotter.attr('notify-success')
49
- if notice?
50
- el.notify notice, "success"
51
- el.triggerSlotReady(slotter)
52
-
53
- slotReady: (func)->
54
- $('document').ready ->
55
- $('body').on 'slotReady', '.card-slot', (e, slotter) ->
56
- e.stopPropagation()
57
- if slotter?
58
- func.call this, $(this), $(slotter)
59
- else
60
- func.call this, $(this)
61
-
62
- slotDestroy: (func)->
63
- $('document').ready ->
64
- $('body').on 'slotDestroy', '.card-slot, ._modal-slot', (e) ->
65
- e.stopPropagation()
66
- func.call this, $(this)
67
-
68
- jQuery.fn.extend
69
- slot: (status="success", mode="replace") ->
70
- if mode == "modal"
71
- @modalSlot()
72
- else
73
- @selectSlot("slot-#{status}-selector") ||
74
- @selectSlot("slot-selector") ||
75
- @closest(".card-slot")
76
-
77
- selectSlot: (selectorName) ->
78
- if selector = @data(selectorName)
79
- slot = @findSlot selector
80
- slot && slot[0] && slot
81
-
82
- isSlot: ->
83
- $(this).hasClass "card-slot"
84
-
85
- isMain: ->
86
- @slot().parent('#main')[0]
87
-
88
- isMainOrMainModal: ->
89
- el = $(this)
90
- el = el.findOriginSlot("modal") if el.closest(".modal")[0]
91
- el && el.isMain()
92
-
93
- findSlot: (selector) ->
94
- if selector == "modal-origin"
95
- @findOriginSlot("modal")
96
- else if selector == "overlay-origin"
97
- @findOriginSlot("overlay")
98
- else
99
- target_slot = @closest(selector)
100
- parent_slot = @closest '.card-slot'
101
-
102
- # if slot-selector doesn't apply to a child, search in all parent slots and finally in the body
103
- while target_slot.length == 0 and parent_slot.length > 0
104
- target_slot = $(parent_slot).find(selector)
105
- parent_slot = $(parent_slot).parent().closest '.card-slot'
106
- if target_slot.length == 0
107
- $(selector)
108
- else
109
- target_slot
110
-
111
- # type can be "modal" or "overlay"
112
- findOriginSlot: (type) ->
113
- overlaySlot = @closest("[data-#{type}-origin-slot-id]")
114
- origin_slot_id = overlaySlot.data("#{type}-origin-slot-id")
115
- origin_slot = $("[data-slot-id=#{origin_slot_id}]")
116
- if origin_slot[0]?
117
- origin_slot
118
- else
119
- console.log "couldn't find origin with slot id #{origin_slot_id}"
120
-
121
- reloadSlot: (url) ->
122
- $slot = $(this)
123
- if $slot.length > 1
124
- $slot.each ->
125
- $(this).reloadSlot url
126
- return
127
-
128
- $slot = $slot.slot() unless $slot.isSlot
129
- return unless $slot[0]
130
-
131
- unless url?
132
- url = $slot.slotUrl()
133
- $slot.addClass 'slotter'
134
- $slot.attr 'href', url
135
- $slot.data "url", url
136
- this[0].href = url # that's where handleRemote gets the url from
137
- # .attr(href, url) only works for anchors
138
- $slot.data "remote", true
139
- $.rails.handleRemote($slot)
140
-
141
- clearSlot: () ->
142
- @triggerSlotDestroy()
143
- @empty()
144
-
145
- slotUrl: ->
146
- decko.slotPath "#{this.slotMark()}?view=#{@data("slot")["view"]}"
147
-
148
- slotMark: ->
149
- if @data('cardId') then "~#{@data('cardId')}" else @data("cardName")
150
-
151
- setSlotContent: (newContent, mode, $slotter) ->
152
- v = $(newContent)[0] && $(newContent) || newContent
153
-
154
- if typeof(v) == "string"
155
- # Needed to support "TEXT: result" pattern in success (eg deleting nested cards)
156
- @slot("success", mode).replaceWith v
157
- else
158
- if v.hasClass("_overlay")
159
- mode = "overlay"
160
- else if v.hasClass("_modal")
161
- mode = "modal"
162
- @slot("success", mode).setSlotContentFromElement v, mode, $slotter
163
- v
164
-
165
- setSlotContentFromElement: (el, mode, $slotter) ->
166
- if mode == "overlay"
167
- @addOverlay(el, $slotter)
168
- else if el.hasClass("_modal-slot") or mode == "modal"
169
- el.showAsModal($slotter)
170
- else
171
- slot_id = @data("slot-id")
172
- el.attr("data-slot-id", slot_id) if slot_id
173
- @triggerSlotDestroy()
174
- @replaceWith el
175
- decko.contentLoaded(el, $slotter)
176
-
177
- triggerSlotReady: (slotter) ->
178
- @trigger "slotReady", slotter if @isSlot()
179
- @find(".card-slot").trigger "slotReady", slotter
180
-
181
- triggerSlotDestroy: () ->
182
- @trigger "slotDestroy"
@@ -1,12 +0,0 @@
1
- decko.slotReady (slot) ->
2
- slot.find('._disappear').delay(5000).animate(
3
- height: 0, 1000, -> $(this).hide())
4
-
5
- if slot.hasClass("_refresh-timer")
6
- setTimeout(
7
- -> slot.reloadSlot(slot.data("refresh-url")),
8
- 2000
9
- )
10
-
11
-
12
-