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,76 +0,0 @@
1
- wrapDeckoLayout = ->
2
- $footer = $('body > footer').first()
3
- $('body > article, body > aside').wrapAll("<div class='#{containerClass()}'/>")
4
- $('body > div > article, body > div > aside')
5
- .wrapAll('<div class="row row-offcanvas">')
6
- if $footer
7
- $('body').append $footer
8
-
9
- wrapSidebarToggle = (toggle, flex) ->
10
- "<div class='container'><div class='row #{flex}'>#{toggle}</div></div>"
11
-
12
- containerClass = ->
13
- if $('body').hasClass('fluid') then "container-fluid" else "container"
14
-
15
- toggleButton = (side) ->
16
- icon_dir = if side == 'left' then 'right' else 'left'
17
- "<button class='offcanvas-toggle btn btn-secondary "+
18
- "d-sm-none' data-toggle='offcanvas-#{side}'>" +
19
- "<i class='material-icons'>chevron_#{icon_dir}</i></button>"
20
-
21
- sidebarToggle = (side) ->
22
- if side == "both"
23
- wrapSidebarToggle(toggleButton("left") + toggleButton("right"), "flex-row justify-content-between")
24
- else if side == "left"
25
- wrapSidebarToggle(toggleButton("left"), "flex-row")
26
- else
27
- wrapSidebarToggle(toggleButton("right"), "flex-row-reverse")
28
-
29
- singleSidebar = (side) ->
30
- $article = $('body > article').first()
31
- $aside = $('body > aside').first()
32
- $article.addClass("col-xs-12 col-sm-9")
33
- $aside.addClass(
34
- "col-xs-6 col-sm-3 sidebar-offcanvas sidebar-offcanvas-#{side}"
35
- )
36
- if side == 'left'
37
- $('body').append($aside).append($article)
38
- else
39
- $('body').append($article).append($aside)
40
- wrapDeckoLayout()
41
- $article.prepend(sidebarToggle(side))
42
-
43
- doubleSidebar = ->
44
- $article = $('body > article').first()
45
- $asideLeft = $('body > aside').first()
46
- $asideRight = $($('body > aside')[1])
47
- $article.addClass("col-xs-12 col-sm-6")
48
- sideClass = "col-xs-6 col-sm-3 sidebar-offcanvas"
49
- $asideLeft.addClass("#{sideClass} sidebar-offcanvas-left")
50
- $asideRight.addClass("#{sideClass} sidebar-offcanvas-right")
51
- $('body').append($asideLeft).append($article).append($asideRight)
52
- wrapDeckoLayout()
53
- toggles = sidebarToggle('both')
54
- $article.prepend(toggles)
55
-
56
- $.fn.extend toggleText: (a, b) ->
57
- @text(if @text() == b then a else b)
58
-
59
- this
60
- $(window).ready ->
61
- switch
62
- when $('body').hasClass('right-sidebar')
63
- singleSidebar('right')
64
- when $('body').hasClass('left-sidebar')
65
- singleSidebar('left')
66
- when $('body').hasClass('two-sidebar')
67
- doubleSidebar()
68
-
69
- $('[data-toggle="offcanvas-left"]').click ->
70
- $('.row-offcanvas').removeClass('right-active').toggleClass('left-active')
71
- $(this).find('i.material-icons')
72
- .toggleText('chevron_left', 'chevron_right')
73
- $('[data-toggle="offcanvas-right"]').click ->
74
- $('.row-offcanvas').removeClass('left-active').toggleClass('right-active')
75
- $(this).find('i.material-icons')
76
- .toggleText('chevron_left', 'chevron_right')
@@ -1,61 +0,0 @@
1
- $(document).ready ->
2
- $('body').on 'click', 'button._link-apply', () ->
3
- link.applyLink($(this).data("tinymce-id"), $(this).data("tm-snippet-start"), $(this).data("tm-snippet-size"))
4
-
5
- window.link ||= {}
6
-
7
- $(document).ready ->
8
- $('body').on 'click', '._link-field-toggle', () ->
9
- if $(this).is(':checked')
10
- link.addPlus()
11
- else
12
- link.removePlus()
13
-
14
- $('body').on 'input', 'input._link-target', (event) ->
15
- link.targetChanged()
16
-
17
- $('body').on 'input', 'input._link-title', (event) ->
18
- link.titleChanged()
19
-
20
- $.extend link,
21
- # called by TinyMCE
22
- openLinkEditor: (tm) ->
23
- params = nest.editParams(tm, "[[", "]]") unless params?
24
- nest.openEditorForTm(tm, params, "link_editor", "modal_link_editor")
25
-
26
- applyLink: (tinymce_id, link_start, link_size) ->
27
- nest.applySnippet("link", tinymce_id, link_start, link_size)
28
-
29
- target: () ->
30
- link.evalFieldOption $('input._link-target').val()
31
-
32
- title: () ->
33
- $('input._link-title').val()
34
-
35
- titleChanged: () ->
36
- new_val = $("._link-preview").val().replace(/^\[\[[^\]]*/, "[[" + link.target() + "|" + link.title())
37
- link.updatePreview new_val
38
-
39
- targetChanged: () ->
40
- new_val = $("._link-preview").val().replace(/^\[\[[^\]|]*/, "[[" + link.target())
41
- link.updatePreview new_val
42
-
43
- evalFieldOption: (name) ->
44
- if link.isField() then "+#{name}" else name
45
-
46
- isField: ->
47
- $('._link-field-toggle').is(":checked")
48
-
49
- addPlus: () ->
50
- new_val = $("._link-preview").val().replace(/^\[\[\+?/, "[[+")
51
- link.updatePreview new_val
52
- $(".input-group.hide-prefix").removeClass("hide-prefix").addClass("show-prefix")
53
-
54
- removePlus: () ->
55
- new_val = $("._link-preview").val().replace(/^\[\[\+?/, "[[")
56
- link.updatePreview new_val
57
- $(".input-group.show-prefix").removeClass("show-prefix").addClass("hide-prefix")
58
-
59
- updatePreview: (new_val) ->
60
- new_val = "[[#{link.target()}|#{link.title()}]]" unless new_val?
61
- $("._link-preview").val new_val
@@ -1,79 +0,0 @@
1
-
2
- window.decko ||= {} #needed to run w/o *head. eg. jasmine
3
-
4
- # $.extend decko,
5
- # Can't get this to work yet. Intent was to tighten up head tag.
6
- # initGoogleAnalytics: (key) ->
7
- # window._gaq.push ['_setAccount', key]
8
- # window._gaq.push ['_trackPageview']
9
- #
10
- # initfunc = ()->
11
- # ga = document.createElement 'script'
12
- # ga.type = 'text/javascript'
13
- # ga.async = true
14
- # ga.src = `('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'`
15
- # s = document.getElementsByTagName('script')[0]
16
- # s.parentNode.insertBefore ga, s
17
- # initfunc()
18
-
19
- $(window).ready ->
20
- $(document).on 'click', '._stop_propagation', (event)->
21
- event.stopPropagation()
22
-
23
- $(document).on 'click', '._prevent_default', (event)->
24
- event.preventDefault()
25
-
26
- $('body').on 'mouseenter', 'a[data-hover-text]', ->
27
- text = $(this).text()
28
- $(this).data("original-text", text)
29
- $(this).text($(this).data("hover-text"))
30
-
31
- $('body').on 'mouseleave', 'a[data-hover-text]', ->
32
- $(this).text($(this).data("original-text"))
33
-
34
- #decko_org mod (for now)
35
- $('body').on 'click', '.shade-view h1', ->
36
- toggleThis = $(this).slot().find('.shade-content').is ':hidden'
37
- decko.toggleShade $(this).closest('.pointer-list').find('.shade-content:visible').parent()
38
- if toggleThis
39
- decko.toggleShade $(this).slot()
40
-
41
- if firstShade = $('.shade-view h1')[0]
42
- $(firstShade).trigger 'click'
43
-
44
- # performance log mod
45
- $('body').on 'click', '.open-slow-items', ->
46
- panel = $(this).closest('.panel-group')
47
- panel.find('.open-slow-items').removeClass('open-slow-items').addClass('close-slow-items')
48
- panel.find('.toggle-fast-items').text("show < 100ms")
49
- panel.find('.duration-ok').hide()
50
- panel.find('.panel-danger > .panel-collapse').collapse('show').find('a > span').addClass('show-fast-items')
51
-
52
- $('body').on 'click', '.close-slow-items', ->
53
- panel = $(this).closest('.panel-group')
54
- panel.find('.close-slow-items').removeClass('close-slow-items').addClass('open-slow-items')
55
- panel.find('.toggle-fast-items').text("hide < 100ms")
56
- panel.find('.panel-danger > .panel-collapse').collapse('hide').removeClass('show-fast-items')
57
- panel.find('.duration-ok').show()
58
-
59
- $('body').on 'click', '.toggle-fast-items', ->
60
- panel = $(this).closest('.panel-group')
61
- if $(this).text() == 'hide < 100ms'
62
- panel.find('.duration-ok').hide()
63
- $(this).text("show < 100ms")
64
- else
65
- panel.find('.duration-ok').show()
66
- $(this).text("hide < 100ms")
67
-
68
- $('body').on 'click', '.show-fast-items', (event) ->
69
- $(this).removeClass('show-fast-items')
70
- panel = $(this).closest('.panel-group')
71
- panel.find('.duration-ok').show()
72
- panel.find('.show-fast-items').removeClass('show-fast-items')
73
- panel.find('.panel-collapse').collapse('show')
74
- event.stopPropagation()
75
-
76
- $.extend decko,
77
- toggleShade: (shadeSlot) ->
78
- shadeSlot.find('.shade-content').slideToggle 1000
79
- shadeSlot.find('.glyphicon').toggleClass 'glyphicon-triangle-right glpyphicon-triangle-bottom'
@@ -1,113 +0,0 @@
1
- $(window).ready ->
2
- $('body').on 'hidden.bs.modal', (_event) ->
3
- decko.removeModal()
4
-
5
- $('body').on "show.bs.modal", "._modal-slot", (event, slot) ->
6
- link = $(event.relatedTarget)
7
- addModalDialogClasses $(this), link
8
- $(this).modal("handleUpdate")
9
- decko.contentLoaded $(event.target), link
10
-
11
- $('._modal-slot').each ->
12
- openModalIfPresent $(this)
13
- addModalDialogClasses $(this)
14
-
15
- $('body').on 'click', '.submit-modal', ->
16
- $(this).closest('.modal-content').find('form').submit()
17
-
18
- openModalIfPresent = (mslot) ->
19
- modal_content = mslot.find(".modal-content")
20
- if modal_content.length > 0 && modal_content.html().length > 0
21
- $("#main > .card-slot").registerAsOrigin("modal", mslot)
22
- mslot.modal("show")
23
-
24
- addModalDialogClasses = ($modal_slot, $link) ->
25
- dialog = $modal_slot.find(".modal-dialog")
26
- classes_from_link =
27
- if $link? then $link.data("modal-class") else $modal_slot.data("modal-class")
28
- if classes_from_link? and dialog?
29
- dialog.addClass classes_from_link
30
-
31
- jQuery.fn.extend {
32
- showAsModal: ($slotter) ->
33
- el = @modalify($slotter) if $slotter?
34
- if $("body > ._modal-slot").is(":visible")
35
- @addModal el, $slotter
36
- else
37
- if $("body > ._modal-slot")[0]
38
- $("._modal-slot").trigger "slotDestroy"
39
- $("body > ._modal-slot").replaceWith el
40
- else
41
- $("body").append el
42
-
43
- $slotter.registerAsOrigin("modal", el)
44
- el.modal("show", $slotter)
45
-
46
- addModal: (el, $slotter) ->
47
- if $slotter.data("slotter-mode") == "modal-replace"
48
- dialog = el.find(".modal-dialog")
49
- el.adoptModalOrigin()
50
- $("._modal-slot").trigger "slotDestroy"
51
- $("body > ._modal-slot > .modal-dialog").replaceWith(dialog)
52
- decko.contentLoaded(dialog, $slotter)
53
- else
54
- decko.pushModal el
55
- $slotter.registerAsOrigin("modal", el)
56
- el.modal("show", $slotter)
57
-
58
- adoptModalOrigin: () ->
59
- origin_slot_id = $("body > ._modal-slot .card-slot[data-modal-origin-slot-id]")
60
- .data("modal-origin-slot-id")
61
- @find(".modal-body .card-slot").attr("data-modal-origin-slot-id", origin_slot_id)
62
-
63
- modalOriginSlot: ()->
64
-
65
-
66
- modalSlot: ->
67
- slot = $("#modal-container")
68
- if slot.length > 0 then slot else decko.createModalSlot()
69
-
70
- modalify: ($slotter) ->
71
- if $slotter.data("modal-body")?
72
- @find(".modal-body").append($slotter.data("modal-body"))
73
-
74
- if @hasClass("_modal-slot")
75
- this
76
- else
77
- modalSlot = $('<div/>', id: "modal-container", class: "modal fade _modal-slot")
78
- modalSlot.append(
79
- $('<div/>' , class: "modal-dialog").append(
80
- $('<div/>', class: "modal-content").append(this)
81
- )
82
- )
83
- modalSlot
84
- }
85
-
86
- $.extend decko,
87
- createModalSlot: ->
88
- slot = $('<div/>', id: "modal-container", class: "modal fade _modal-slot")
89
- $("body").append(slot)
90
- slot
91
-
92
- removeModal: ->
93
- if $("._modal-stack")[0]
94
- decko.popModal()
95
- else
96
- $("._modal-slot").trigger "slotDestroy"
97
- $(".modal-dialog").empty()
98
-
99
- pushModal: (el) ->
100
- mslot = $("body > ._modal-slot")
101
- mslot.removeAttr("id")
102
- mslot.removeClass("_modal-slot").addClass("_modal-stack").removeClass("modal").addClass("background-modal")
103
- el.insertBefore mslot
104
- $(".modal-backdrop").removeClass("show")
105
-
106
- popModal: ->
107
- $(".modal-backdrop").addClass("show")
108
- $("body > ._modal-slot").trigger "slotDestroy"
109
- $("body > ._modal-slot").remove()
110
- modal = $($("._modal-stack")[0])
111
- modal.addClass("_modal-slot").removeClass("_modal-stack").attr("id", "modal-container").addClass("modal").removeClass("background-modal")
112
- $(document.body).addClass("modal-open")
113
-
@@ -1,40 +0,0 @@
1
- checkNameAfterTyping = null
2
-
3
- $(window).ready ->
4
- $('body').on 'keyup', '.name-editor input', (event) ->
5
- clearTimeout(checkNameAfterTyping) if checkNameAfterTyping
6
- input = $(this)
7
- if event.which == 13
8
- checkName(input)
9
- checkNameAfterTyping = null
10
- else
11
- checkNameAfterTyping = setTimeout ->
12
- checkName(input)
13
- checkNameAfterTyping = null
14
- , 400
15
-
16
-
17
- checkName = (box) ->
18
- name = box.val()
19
- decko.pingName name, (data)->
20
- return null if box.val() != name # avert race conditions
21
- status = data['status']
22
- if status
23
- ed = box.parent()
24
- leg = box.closest('fieldset').find('legend')
25
- msg = leg.find '.name-messages'
26
- unless msg[0]
27
- msg = $('<span class="name-messages"></span>')
28
- leg.append msg?
29
- ed.removeClass 'real-name virtual-name known-name'
30
-
31
- # use id to avoid warning when renaming to name variant
32
- slot_id = box.slot().data 'cardId'
33
- if status != 'unknown' and !(slot_id && parseInt(slot_id) == data['id'])
34
- ed.addClass status + '-name known-name'
35
- qualifier = if status == 'virtual' then 'in virtual' else 'already in'
36
- href = decko.path(data['url_key'])
37
- msg.html "\"<a href='#{href}'>#{name}</a>\" #{qualifier} use"
38
- else
39
- msg.html ''
40
-
@@ -1,74 +0,0 @@
1
- $(window).ready ->
2
- navbox = $('._navbox')
3
- navbox.select2
4
- placeholder: navbox.attr("placeholder")
5
- escapeMarkup: (markup) ->
6
- markup
7
- minimumInputLength: 1
8
- maximumSelectionSize: 1
9
- ajax:
10
- delay: 200
11
- url: decko.path ':search.json'
12
- data: (params) ->
13
- query: { keyword: params.term }
14
- view: "complete"
15
- processResults: (data) ->
16
- results: navboxize(data)
17
- cache: true
18
- templateResult: formatNavboxItem
19
- templateSelection: formatNavboxSelectedItem
20
- multiple: true
21
- containerCssClass: 'select2-navbox-autocomplete'
22
- dropdownCssClass: 'select2-navbox-dropdown'
23
- width: "100%!important"
24
-
25
- navbox.on "select2:select", (e) ->
26
- navboxSelect(e)
27
-
28
- formatNavboxItem = (i) ->
29
- if i.loading
30
- return i.text
31
- '<i class="material-icons">' + i.icon + '</i>' +
32
- '<span class="navbox-item-label">' + i.prefix + ':</span> ' +
33
- '<span class="navbox-item-value">' + i.label + '</span>'
34
-
35
- formatNavboxSelectedItem = (i) ->
36
- unless i.icon
37
- return i.text
38
- '<i class="material-icons">' + i.icon + '</i>' +
39
- '<span class="navbox-item-value">' + i.label + '</span>'
40
-
41
- navboxize = (results) ->
42
- items = []
43
- term = results.term
44
- if results["search"]
45
- # id is what the form sends
46
- items.push navboxItem(prefix: "search", id: term, text: term)
47
-
48
- $.each ['add', 'new'], (index, key) ->
49
- if val = results[key]
50
- items.push navboxItem(prefix: key, icon: "add", text: val[0], href: val[1])
51
-
52
- $.each results['goto'], (index, val) ->
53
- i = navboxItem(
54
- prefix: "go to", id: index, icon: "arrow_forward",
55
- text: val[0], href: val[1], label: val[2]
56
- )
57
- items.push i
58
-
59
- items
60
-
61
- navboxItem = (data) ->
62
- data.id ||= data.prefix
63
- data.icon ||= data.prefix
64
- data.label ||= '<strong class="highlight">' + data.text + '</strong>'
65
- data
66
-
67
- navboxSelect = (event) ->
68
- item = event.params.data
69
- if item.href
70
- window.location = decko.path(item.href)
71
- else
72
- $(event.target).closest('form').submit()
73
-
74
- $(event.target).attr('disabled', 'disabled')
@@ -1,166 +0,0 @@
1
- $(document).ready ->
2
- $('body').on 'click', 'button._nest-apply', () ->
3
- if $(this).data("index")?
4
- nest.applyNestToNestListEditor($(this).data("index"))
5
- else
6
- nest.applyNestToTinymceEditor($(this).data("tinymce-id"), $(this).data("tm-snippet-start"), $(this).data("tm-snippet-size"))
7
-
8
- $('body').on 'click', 'button._change-create-to-update', () ->
9
- tm_id = $(this).closest("form").find("#success_tinymce_id").val()
10
- nest.changeCreateToUpdate(tm_id)
11
-
12
- $('body').on 'click', 'button._open-nest-editor', () ->
13
- form = $(this).closest("._nest-form")
14
- reference = form.find("._reference").val()
15
- nest_options = form.find("._nest-options").val()
16
- encoded_nest = encodeURIComponent "{{#{reference}|#{nest_options}}}"
17
- nest.openNestEditorForSlot(
18
- $(this).closest(".card-slot"),
19
- $(this).closest(".slotter"),
20
- "index=#{form.data('index')}&tm_snippet_raw=#{encoded_nest}"
21
- )
22
-
23
-
24
- window.nest ||= {}
25
-
26
- $.extend nest,
27
- # called by TinyMCE
28
- openNestEditor: (tm, params) ->
29
- params = nest.editParams(tm) unless params?
30
- this.openEditorForTm(tm, params, "nest_editor", "modal_nest_editor")
31
-
32
- openNestEditorForSlot: (slot, slotter, params) ->
33
- card = if slot[0] then $(slot[0]).attr('data-card-name') else ":update"
34
- nest.request(card, "nest_editor", "modal_nest_editor", slotter, params)
35
-
36
- openEditorForTm: (tm, params, overlay_view, modal_view) ->
37
- params += "&tinymce_id=#{tm.id}"
38
- slot = $("##{tm.id}").closest(".card-slot")
39
- slotter = $("##{tm.id}")
40
- card = if slot[0] then $(slot[0]).attr('data-card-name') else ":update"
41
- nest.request(card, overlay_view, modal_view, slotter, params)
42
-
43
- # called by TinyMCE
44
- openImageEditor: (tm) ->
45
- params = nest.editParams(tm, "{{", "}}", false) unless params?
46
- this.openEditorForTm(tm, params,"nest_image", "modal_nest_image")
47
-
48
- changeCreateToUpdate: (tm_id) ->
49
- form = $("##{tm_id}").closest("form")
50
- new_action = form.attr("action").replace("card/create", "card/update")
51
- form.attr("action", new_action)
52
-
53
- insertNest: (tm, nest_string) ->
54
- tm.insertContent(nest_string)
55
- # insertIndex = nest.offsetAfterInsert(tm, nest_string)
56
- # params = nest.paramsStr(insertIndex, nest_string)
57
- # nest.openNestEditor(etm, params)
58
-
59
-
60
- request: (card, overlay_view, modal_view, slotter, params) ->
61
- slot = $(".bridge-sidebar > ._overlay-container-placeholder > .card-slot")
62
-
63
- if slot[0]
64
- view = overlay_view
65
- mode = "overlay"
66
- else
67
- slot = $($(".card-slot")[0])
68
- view = modal_view
69
- mode = "modal"
70
-
71
- nest.sendRequest(slotter, slot, mode, card, view, params)
72
-
73
- sendRequest: (slotter, slot, mode, card, view, params) ->
74
- params = "" unless params?
75
- url = "/#{card}?view=#{view}&#{params}"
76
- $.ajax
77
- url: url
78
- type: 'GET'
79
- success: (html) ->
80
- slot.setSlotContent html, mode, slotter
81
-
82
- editParams: (tm, prefix="{{", postfix="}}", edit=true) ->
83
- sel = tm.selection.getSel()
84
- return nest.paramsStr(0) unless sel? and sel.anchorNode?
85
-
86
- text = sel.anchorNode.data
87
- return nest.paramsStr(sel.anchorOffset) unless text
88
-
89
- offset = sel.anchorOffset
90
- before = text.substr(0, offset)
91
- after = text.substr(offset)
92
- index = {
93
- before: {
94
- close: before.lastIndexOf(postfix)
95
- open: before.lastIndexOf(prefix)
96
- },
97
- after: {
98
- close: after.indexOf(postfix)
99
- open: after.indexOf(prefix)
100
- }
101
- }
102
- if index.before.open > index.before.close &&
103
- index.after.close != -1 &&
104
- (index.after.open == -1 || index.after.close < index.after.open)
105
- nest_start = index.before.open
106
- unless name?
107
- nest_size = index.after.close + offset + 2 - nest_start
108
- name = text.substr(nest_start, nest_size)
109
- if edit
110
- nest.paramsStr(nest_start, name)
111
- else
112
- nest.paramsStr(nest_start + nest_size)
113
- else
114
- nest.paramsStr(offset)
115
-
116
- paramsStr: (start, name) ->
117
- params = ""
118
- if start?
119
- params += "&tm_snippet_start=#{start}"
120
- if name? and name.length > 0
121
- params += "&tm_snippet_raw=#{encodeURIComponent(name)}"
122
-
123
- params
124
-
125
- offsetAfterInsert: (editor, content) ->
126
- offset = editor.selection.getSel().anchorOffset
127
- offset - content.lengthr
128
-
129
- applyNestToTinymceEditor: (tinymce_id, nest_start, nest_size) ->
130
- nest.applySnippet("nest", tinymce_id, nest_start, nest_size)
131
-
132
- applyNestToNestListEditor: (index) ->
133
- row = $("._nest-form[data-index='#{index}']")
134
- row.find("._reference").val(nest.name())
135
- row.find("._nest-options").val(nest.options())
136
- decko.updateAddItemButton(row)
137
-
138
-
139
- applySnippet: (snippet_type, tinymce_id, start, size) ->
140
- content = $("._#{snippet_type}-preview").val()
141
- editor = tinymce.get(tinymce_id)
142
- if start?
143
- nest.replaceSnippet(editor, start, size, content)
144
- else
145
- editor.insertContent content
146
- offset = nest.offsetAfterInsert(editor, content)
147
- $("button._#{snippet_type}-apply").attr("data-tm-snippet-start", offset)
148
-
149
- $("button._#{snippet_type}-apply").attr("data-tm-snippet-size", content.length)
150
-
151
- replaceSnippet: (editor, start, size, content) ->
152
- sel = editor.selection.getSel()
153
- if sel? and sel.anchorNode? and sel.anchorNode.data?
154
- text = sel.anchorNode.data
155
- size = 0 unless size?
156
- text = "#{text.substr(0, start)}#{content}#{text.substr(start + size)}"
157
- sel.anchorNode.data = text
158
- else
159
- editor.insertContent content
160
-
161
- updatePreview: (new_val) ->
162
- new_val = "{{#{nest.name()}|#{nest.options()}}}" unless new_val?
163
- preview = $("._nest-preview")
164
- preview.val new_val
165
- preview.data("nest-options", nest.options())
166
- preview.data("reference", nest.name())