card-mod-script 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/assets/script/decko/autosave.js.coffee +30 -0
  3. data/assets/script/decko/bridge.js.coffee +31 -0
  4. data/assets/script/decko/card_menu.js.coffee +26 -0
  5. data/assets/script/decko/components.js.coffee +49 -0
  6. data/assets/script/decko/decko.js.coffee +82 -0
  7. data/assets/script/decko/doubleclick.js.coffee +30 -0
  8. data/assets/script/decko/editor.js.coffee +57 -0
  9. data/assets/script/decko/filter.js.coffee +183 -0
  10. data/assets/script/decko/filter_items.js.coffee +128 -0
  11. data/assets/script/decko/filter_links.js.coffee +81 -0
  12. data/assets/script/decko/follow.js.coffee +22 -0
  13. data/assets/script/decko/layout.js.coffee +76 -0
  14. data/assets/script/decko/link_editor.js.coffee +61 -0
  15. data/assets/script/decko/mod.js.coffee +79 -0
  16. data/assets/script/decko/modal.js.coffee +113 -0
  17. data/assets/script/decko/name_editor.js.coffee +40 -0
  18. data/assets/script/decko/navbox.js.coffee +74 -0
  19. data/assets/script/decko/nest_editor.js.coffee +166 -0
  20. data/assets/script/decko/nest_editor_name.js.coffee +102 -0
  21. data/assets/script/decko/nest_editor_options.js.coffee +93 -0
  22. data/assets/script/decko/nest_editor_rules.js.coffee +3 -0
  23. data/assets/script/decko/overlay.js.coffee +54 -0
  24. data/assets/script/decko/pointer_config.js.coffee +79 -0
  25. data/assets/script/decko/pointer_list_editor.js.coffee +67 -0
  26. data/assets/script/decko/recaptcha.js.coffee +19 -0
  27. data/assets/script/decko/selectable_filtered_content.js.coffee +12 -0
  28. data/assets/script/decko/slot.js.coffee +182 -0
  29. data/assets/script/decko/slot_ready.js.coffee +12 -0
  30. data/assets/script/decko/slotter.js.coffee +268 -0
  31. data/assets/script/decko/type_editor.js.coffee +21 -0
  32. data/assets/script/decko/upload.js.coffee +64 -0
  33. data/assets/script/jquery-ui.min.js +13 -0
  34. data/assets/script/jquery.autosize.js +274 -0
  35. data/assets/script/manifest.yml +57 -0
  36. data/init/early/init_execjs.rb +3 -0
  37. data/set/abstract/00_script.rb +30 -31
  38. data/set/abstract/01_asset_script.rb +0 -16
  39. data/set/abstract/{script_asset_list.rb → script_group.rb} +12 -13
  40. data/set/all/head_javascript.rb +12 -8
  41. data/set/right/script.rb +1 -14
  42. data/set/type/local_script_folder_group.rb +2 -2
  43. data/set/type/local_script_manifest_group.rb +1 -1
  44. data/set/type_plus_right/mod/script.rb +56 -0
  45. data/set/type_plus_right/set/script.rb +7 -0
  46. data/vendor/jquery_file_upload/LICENSE.txt +11 -12
  47. data/vendor/jquery_file_upload/README.md +189 -72
  48. data/vendor/jquery_file_upload/SECURITY.md +227 -0
  49. data/vendor/jquery_file_upload/VULNERABILITIES.md +118 -0
  50. data/vendor/jquery_file_upload/cors/postmessage.html +68 -58
  51. data/vendor/jquery_file_upload/cors/result.html +12 -10
  52. data/vendor/jquery_file_upload/css/jquery.fileupload-ui.css +24 -13
  53. data/vendor/jquery_file_upload/css/jquery.fileupload.css +3 -4
  54. data/vendor/jquery_file_upload/docker-compose.yml +55 -0
  55. data/vendor/jquery_file_upload/index.html +332 -230
  56. data/vendor/jquery_file_upload/js/cors/jquery.postmessage-transport.js +109 -109
  57. data/vendor/jquery_file_upload/js/cors/jquery.xdr-transport.js +81 -73
  58. data/vendor/jquery_file_upload/js/demo.js +75 -0
  59. data/vendor/jquery_file_upload/js/jquery.fileupload-audio.js +82 -94
  60. data/vendor/jquery_file_upload/js/jquery.fileupload-image.js +321 -300
  61. data/vendor/jquery_file_upload/js/jquery.fileupload-process.js +138 -146
  62. data/vendor/jquery_file_upload/js/jquery.fileupload-ui.js +737 -692
  63. data/vendor/jquery_file_upload/js/jquery.fileupload-validate.js +91 -97
  64. data/vendor/jquery_file_upload/js/jquery.fileupload-video.js +82 -94
  65. data/vendor/jquery_file_upload/js/jquery.fileupload.js +1569 -1451
  66. data/vendor/jquery_file_upload/js/jquery.iframe-transport.js +208 -205
  67. data/vendor/jquery_file_upload/js/vendor/jquery.ui.widget.js +397 -340
  68. data/vendor/jquery_file_upload/package-lock.json +6853 -0
  69. data/vendor/jquery_file_upload/package.json +71 -10
  70. data/vendor/jquery_file_upload/server/gae-python/app.yaml +11 -10
  71. data/vendor/jquery_file_upload/server/php/Dockerfile +23 -17
  72. data/vendor/jquery_file_upload/server/php/UploadHandler.php +206 -137
  73. data/vendor/jquery_file_upload/server/php/php.ini +5 -0
  74. data/vendor/jquery_file_upload/test/index.html +36 -159
  75. data/vendor/jquery_file_upload/test/unit.js +989 -0
  76. data/vendor/jquery_file_upload/test/vendor/chai.js +10854 -0
  77. data/vendor/jquery_file_upload/test/vendor/mocha.css +325 -0
  78. data/vendor/jquery_file_upload/test/vendor/mocha.js +18178 -0
  79. data/vendor/jquery_file_upload/wdio/LICENSE.txt +20 -0
  80. data/vendor/jquery_file_upload/wdio/assets/black+white-3x2.jpg +0 -0
  81. data/vendor/jquery_file_upload/wdio/assets/black+white-60x40.gif +0 -0
  82. data/vendor/jquery_file_upload/wdio/conf/chrome.js +40 -0
  83. data/vendor/jquery_file_upload/wdio/conf/firefox.js +25 -0
  84. data/vendor/jquery_file_upload/wdio/hooks/index.js +36 -0
  85. data/vendor/jquery_file_upload/wdio/test/pages/file-upload.js +79 -0
  86. data/vendor/jquery_file_upload/wdio/test/specs/01-file-upload.js +25 -0
  87. data/vendor/jquery_file_upload/wdio/wdio.conf.js +4 -0
  88. metadata +66 -50
  89. data/file/mod_script_script_decko_machine_output/file.js +0 -2710
  90. data/file/mod_script_script_jquery_machine_output/file.js +0 -12924
  91. data/lib/javascript/script_html5shiv_printshiv.js +0 -1
  92. data/set/self/script_html5shiv_printshiv.rb +0 -11
  93. data/set/self/script_mods.rb +0 -1
  94. data/set/type/mod_script_assets.rb +0 -21
  95. data/vendor/jquery_file_upload/CONTRIBUTING.md +0 -15
  96. data/vendor/jquery_file_upload/angularjs.html +0 -211
  97. data/vendor/jquery_file_upload/basic-plus.html +0 -226
  98. data/vendor/jquery_file_upload/basic.html +0 -136
  99. data/vendor/jquery_file_upload/bower-version-update.js +0 -16
  100. data/vendor/jquery_file_upload/bower.json +0 -64
  101. data/vendor/jquery_file_upload/css/jquery-ui-demo-ie8.css +0 -21
  102. data/vendor/jquery_file_upload/css/jquery-ui-demo.css +0 -67
  103. data/vendor/jquery_file_upload/css/style.css +0 -15
  104. data/vendor/jquery_file_upload/jquery-ui.html +0 -252
  105. data/vendor/jquery_file_upload/js/app.js +0 -101
  106. data/vendor/jquery_file_upload/js/jquery.fileupload-angular.js +0 -437
  107. data/vendor/jquery_file_upload/js/jquery.fileupload-jquery-ui.js +0 -161
  108. data/vendor/jquery_file_upload/js/main.js +0 -75
  109. data/vendor/jquery_file_upload/server/gae-go/app/main.go +0 -361
  110. data/vendor/jquery_file_upload/server/gae-go/app.yaml +0 -12
  111. data/vendor/jquery_file_upload/server/gae-go/static/favicon.ico +0 -0
  112. data/vendor/jquery_file_upload/server/gae-go/static/robots.txt +0 -2
  113. data/vendor/jquery_file_upload/server/php/docker-compose.yml +0 -9
  114. data/vendor/jquery_file_upload/test/test.js +0 -1292
@@ -0,0 +1,81 @@
1
+ decko.slotReady (slot) ->
2
+ slot.find("._filter-widget").each ->
3
+ if slot[0] == $(this).slot()[0]
4
+ filter = new decko.filter this
5
+ filter.showWithStatus "active"
6
+ filter.updateLastVals()
7
+ filter.updateQuickLinks()
8
+
9
+ $(window).ready ->
10
+ filterFor = (el) ->
11
+ new decko.filter el
12
+
13
+ # sometimes this element shows up as changed and breaks the filter.
14
+ weirdoSelect2FilterBreaker = (el) ->
15
+ $(el).hasClass "select2-search__field"
16
+
17
+ filterableData = (filterable) ->
18
+ f = $(filterable)
19
+ f.data("filter") || f.find("._filterable").data("filter")
20
+
21
+ targetFilter = (filterable) ->
22
+ selector = $(filterable).closest("._filtering").data("filter-selector")
23
+ filterFor (selector || this)
24
+
25
+ # Add Filter
26
+ $("body").on "click", "._filter-category-select", (e) ->
27
+ e.preventDefault()
28
+ # e.stopPropagation()
29
+ f = filterFor(this)
30
+ category = $(this).data("category")
31
+ f.activate category
32
+ f.updateIfPresent category
33
+
34
+ # Update filter results based on filter value changes
35
+ onchangers =
36
+ "._filter-input input:not(.simple-text), ._filter-input select, ._filter-sort"
37
+ $("body").on "change", onchangers, ->
38
+ return if weirdoSelect2FilterBreaker this
39
+ filterFor(this).update()
40
+
41
+ # update filter result after typing in text box
42
+ keyupTimeout = null
43
+ $("body").on "keyup", "._filter-input input.simple-text", ->
44
+ clearTimeout keyupTimeout
45
+ filter = filterFor this
46
+ keyupTimeout = setTimeout ( -> filter.updateIfChanged() ), 333
47
+
48
+ # remove filter
49
+ $("body").on "click", "._delete-filter-input", ->
50
+ filter = filterFor this
51
+ filter.removeField $(this).closest("._filter-input").data("category")
52
+ filter.update()
53
+
54
+ # reset all filters
55
+ $('body').on 'click', '._reset-filter', () ->
56
+ f = filterFor(this)
57
+ f.reset()
58
+ f.update()
59
+
60
+ $('body').on 'click', '._filtering ._filterable', (e) ->
61
+ f = targetFilter this
62
+ if f.widget.length
63
+ f.restrict filterableData(this)
64
+ e.preventDefault()
65
+ e.stopPropagation()
66
+
67
+ $('body').on 'click', '._filter-link', (e) ->
68
+ f = filterFor this
69
+ link = $(this)
70
+ filter_data = link.data "filter"
71
+ if inactiveQuickfilter link
72
+ f.removeRestrictions filter_data
73
+ else
74
+ f.addRestrictions filter_data
75
+
76
+ e.preventDefault()
77
+ e.stopPropagation()
78
+
79
+ inactiveQuickfilter = (link) ->
80
+ !link.hasClass("active") && link.closest(".quick-filter").length > 0
81
+
@@ -0,0 +1,22 @@
1
+ $(window).ready ->
2
+ $('body').on 'click', '.btn-item', ->
3
+ $(this).find('i').html('hourglass_full')
4
+
5
+ $('body').on 'mouseenter', '.btn-item-delete', ->
6
+ $(this).find('i').html('remove')
7
+ $(this).addClass("btn-danger").removeClass("btn-primary")
8
+
9
+ $('body').on 'mouseleave', '.btn-item-delete', ->
10
+ $(this).find('i').html('check')
11
+ $(this).addClass("btn-primary").removeClass("btn-danger")
12
+
13
+ $('body').on 'click', '.follow-updater', ->
14
+ $(this).closest('form').find('#card_update_all_users').val 'true'
15
+
16
+ $('body').on 'submit', '.edit-view.SELF-Xfollow_default .card-form', ->
17
+ confirmer = $(this).find '.confirm_update_all-view'
18
+ if confirmer.is ':hidden'
19
+ $(this).find('.follow-updater').show()
20
+
21
+ confirmer.show 'blind'
22
+ false
@@ -0,0 +1,76 @@
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')
@@ -0,0 +1,61 @@
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
@@ -0,0 +1,79 @@
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'
@@ -0,0 +1,113 @@
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
+
@@ -0,0 +1,40 @@
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
+
@@ -0,0 +1,74 @@
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')