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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e39b0d3c7d2728686cf541e1177988024c9c79630c985959111f45ba3d808cbd
4
- data.tar.gz: 7ef0c675fe6036d2323a1d19159976a2852780fa59be1265ba0b981d54045c7d
3
+ metadata.gz: fee3c7745a6b6f4aa6f59ac47297e0afa15da01033c01ea19fda748760f9f491
4
+ data.tar.gz: 95eecb8662de65c2c667cd775057d8510294312e007f4520362e4e3bbbe4bb87
5
5
  SHA512:
6
- metadata.gz: 545e457a824be0d31dc0eb20b38c176da77a275edaa19d36ede9da1c750e91b56be212211597fdadb99fc040da84a7b3616663d2bf442d18e7a78ff4d91cf0a0
7
- data.tar.gz: 3b0fd23156411a1371dda1b8edd5a1c552eb07efb591fa3a88c49fc9e9da2ebc6810c4e464a7748afeb516427d927f1f01ad22522abb40efe2f8566c1ba4f71b
6
+ metadata.gz: c58d244694ad19afc5658d38e90c591596069d7bebe341e45acb272958b41d48cc0f6530234c50a76ad92e6b60503f65bdaea5ba5df27429e2bf0eebd37bc23f
7
+ data.tar.gz: e7aa692d4fb79293964850098b63cc38b530a110478004b66ecc945fabb1c3360b5f80a655c891f58464929aeebd5a9bdb5aad8e32c3a7f2229e0999e572f2c0
@@ -0,0 +1,30 @@
1
+ jQuery.fn.extend
2
+ autosave: ->
3
+ slot = @slot()
4
+ return if @attr 'no-autosave'
5
+ multi = @closest '.form-group'
6
+ if multi[0]
7
+ return unless id = multi.data 'cardId'
8
+ reportee = ': ' + multi.data 'cardName'
9
+ else
10
+ id = slot.data 'cardId'
11
+ reportee = ''
12
+
13
+ return unless id
14
+
15
+ # might be better to put this href base in the html
16
+ submit_url = decko.path 'update/~' + id
17
+ form_data = $('#edit_card_'+id).serializeArray().reduce( ((obj, item) ->
18
+ obj[item.name] = item.value
19
+ return obj
20
+ ), { 'draft' : 'true', 'success[view]' : 'blank'});
21
+ $.ajax submit_url, {
22
+ data : form_data,
23
+ type : 'POST'
24
+ }
25
+ ##{ 'card[content]' : @val() },
26
+
27
+ $(window).ready ->
28
+ $('body').on 'change', '.autosave .d0-card-content', ->
29
+ content_field = $(this)
30
+ setTimeout ( -> content_field.autosave() ), 500
@@ -0,0 +1,31 @@
1
+ decko.slotReady (slot, slotter) ->
2
+ slot.updateBridge(false, slotter)
3
+
4
+ links = slot.find('ul._auto-single-select > li.nav-item > a.nav-link')
5
+ if links.length == 1
6
+ $(links[0]).click()
7
+
8
+ jQuery.fn.extend
9
+ # overlayClosed=true means the bridge update was
10
+ # triggered by closing an overlay
11
+ updateBridge: (overlayClosed=false, slotter) ->
12
+ return unless @closest(".bridge").length > 0
13
+ if @data("breadcrumb")
14
+ @updateBreadcrumb()
15
+ else if slotter and $(slotter).data("breadcrumb")
16
+ $(slotter).updateBreadcrumb()
17
+
18
+ if overlayClosed
19
+ $(".bridge-pills > .nav-item > .nav-link.active").removeClass("active")
20
+
21
+ updateBreadcrumb: () ->
22
+ bc_item = $(".modal-header ._bridge-breadcrumb li:last-child")
23
+ bc_item.text(this.data("breadcrumb"))
24
+ bc_item.attr("class", "breadcrumb-item active #{this.data('breadcrumb-class')}")
25
+
26
+ $(window).ready ->
27
+ $('body').on "select2:select", "._close-rule-overlay-on-select", (event) ->
28
+ $(".overlay-container > ._overlay.card-slot.overlay_rule-view.RULE").removeOverlay()
29
+
30
+ $('body').on "click", "._update-history-pills", (event) ->
31
+ $(this).closest(".slotter").data("update-foreign-slot", ".card-slot.history_tab-view")
@@ -0,0 +1,26 @@
1
+ decko.isTouchDevice = ->
2
+ if 'ontouchstart' of window or window.DocumentTouch and
3
+ document instanceof DocumentTouch
4
+ return true
5
+ else
6
+ return detectMobileBrowser()
7
+
8
+ # source for this method: detectmobilebrowsers.com
9
+ detectMobileBrowser = (userAgent) ->
10
+ userAgent = navigator.userAgent or navigator.vendor or window.opera
11
+ /(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) or /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))
12
+
13
+ decko.slotReady (slot) ->
14
+ if decko.isTouchDevice()
15
+ slot.find('._show-on-hover').removeClass('_show-on-hover')
16
+
17
+ $(window).ready ->
18
+ $('body').on 'show.bs.popover', '._card-menu-popover', () ->
19
+ $(this).closest(".card-menu._show-on-hover")
20
+ .removeClass("_show-on-hover")
21
+ .addClass("_show-on-hover-disabled")
22
+
23
+ $('body').on 'hide.bs.popover', '._card-menu-popover', () ->
24
+ $(this).closest(".card-menu._show-on-hover-disabled")
25
+ .removeClass("_show-on-hover-disabled")
26
+ .addClass("_show-on-hover")
@@ -0,0 +1,49 @@
1
+ submitAfterTyping = null
2
+
3
+ $(window).ready ->
4
+ $('body').on 'show.bs.tab', 'a.load[data-toggle="tab"][data-url]', (e) ->
5
+ tab_id = $(e.target).attr('href')
6
+ url = $(e.target).data('url')
7
+ $(e.target).removeClass('load')
8
+ $.ajax
9
+ url: url
10
+ type: 'GET'
11
+ success: (html) ->
12
+ $(tab_id).append(html)
13
+ decko.contentLoaded($(tab_id), $(this))
14
+
15
+ $('body').on "input", "._submit-after-typing", (event) ->
16
+ form = $(event.target).closest('form')
17
+ form.slot().find(".autosubmit-success-notification").remove()
18
+ clearTimeout(submitAfterTyping) if submitAfterTyping
19
+ submitAfterTyping = setTimeout ->
20
+ $(event.target).closest('form').submit()
21
+ submitAfterTyping = null
22
+ , 1000
23
+
24
+ $('body').on "keydown", "._submit-after-typing", (event) ->
25
+ if event.which == 13
26
+ clearTimeout(submitAfterTyping) if submitAfterTyping
27
+ submitAfterTyping = null
28
+ $(event.target).closest('form').submit()
29
+ false
30
+
31
+ $('body').on "change", "._submit-on-change", (event) ->
32
+ $(event.target).closest('form').submit()
33
+ false
34
+
35
+ $('body').on "change", "._edit-item", (event) ->
36
+ cb = $(event.target)
37
+ if cb.is(":checked")
38
+ cb.attr("name", "add_item")
39
+ else
40
+ cb.attr("name", "drop_item")
41
+
42
+ $(event.target).closest('form').submit()
43
+ false
44
+
45
+ $("body").on "click", "._popover_link", (event) ->
46
+ event.preventDefault();
47
+
48
+
49
+
@@ -0,0 +1,82 @@
1
+ $.extend decko,
2
+ # returns absolute path (starting with a slash)
3
+ # if rawPath is complete url, this returns the complete url
4
+ # if rawPath is relative (no slash), this adds relative root
5
+ path: (rawPath) ->
6
+ if rawPath.match /^\/|:\/\//
7
+ rawPath
8
+ else
9
+ decko.rootUrl + rawPath
10
+
11
+ pingName: (name, success)->
12
+ $.getJSON decko.path(''), format: 'json', view: 'status', 'card[name]': name, success
13
+
14
+ jQuery.fn.extend {
15
+ notify: (message, status) ->
16
+ slot = @slot(status)
17
+ notice = slot.find '.card-notice'
18
+ unless notice[0]
19
+ notice = $('<div class="card-notice"></div>')
20
+ form = slot.find('.card-form')
21
+ if form[0]
22
+ $(form[0]).append notice
23
+ else
24
+ slot.append notice
25
+ notice.html message
26
+ notice.show 'blind'
27
+
28
+ report: (message) ->
29
+ report = @slot().find '.card-report'
30
+ return false unless report[0]
31
+ report.hide()
32
+ report.html message
33
+ report.show 'drop', 750
34
+ setTimeout (->report.hide 'drop', 750), 3000
35
+ }
36
+
37
+ #~~~~~ ( EVENTS )
38
+
39
+ $(window).ready ->
40
+ $.ajaxSetup cache: false
41
+
42
+ $('body').on 'click', '.submitter', ->
43
+ $(this).closest('form').submit()
44
+
45
+ $('body').on 'click', 'button.redirecter', ->
46
+ window.location = $(this).attr('href')
47
+
48
+ $('body').on 'mouseenter', '[hover_content]', ->
49
+ $(this).attr 'hover_restore', $(this).html()
50
+ $(this).html $(this).attr( 'hover_content' )
51
+ $('body').on 'mouseleave', '[hover_content]', ->
52
+ $(this).html $(this).attr( 'hover_restore' )
53
+
54
+ $('body').on 'click', '.render-error-link', (event) ->
55
+ msg = $(this).closest('.render-error').find '.render-error-message'
56
+ msg.show()
57
+ # msg.dialog()
58
+ event.preventDefault()
59
+
60
+ decko.slotReady (slot) ->
61
+ slot.find('card-view-placeholder').each ->
62
+ $place = $(this)
63
+ return if $place.data("loading")
64
+
65
+ $place.data "loading", true
66
+ $.get $place.data("url"), (data, _status) ->
67
+ $place.replaceWith data
68
+
69
+ # important: this prevents jquery-mobile from taking over everything
70
+ # $( document ).on "mobileinit", ->
71
+ # $.extend $.mobile , {
72
+ # #autoInitializePage: false
73
+ # #ajaxEnabled: false
74
+ # }
75
+
76
+
77
+
78
+ warn = (stuff) -> console.log stuff if console?
79
+
80
+
81
+
82
+
@@ -0,0 +1,30 @@
1
+ doubleClickActiveMap = { off: false, on: true, signed_in: decko.currentUserId }
2
+
3
+ doubleClickActive = () ->
4
+ doubleClickActiveMap[decko.doubleClick]
5
+ # else alert "illegal configuration: " + decko.doubleClick
6
+
7
+ doubleClickApplies = (el) ->
8
+ return false if ['.nodblclick', '.d0-card-header', '.card-editor'].some (klass) ->
9
+ el.closest(klass)[0]
10
+ # double click inactive inside header, editor, or tag with "nodblclick" class
11
+ !el.slot().find('.card-editor')[0]?
12
+
13
+
14
+ triggerDoubleClickEditingOn = (el)->
15
+ slot = el.slot()
16
+ edit_link = decko.slotEditLink(slot)
17
+
18
+ if edit_link
19
+ edit_link.click()
20
+ else
21
+ edit_view = decko.slotEditView(slot)
22
+ url = decko.path("~#{slot.data('cardId')}?view=#{edit_view}")
23
+ slot.reloadSlot url
24
+
25
+ $(window).ready ->
26
+ if doubleClickActive()
27
+ $('body').on 'dblclick', 'div', (_event) ->
28
+ if doubleClickApplies $(this)
29
+ triggerDoubleClickEditingOn $(this)
30
+ false # don't propagate up to next slot
@@ -0,0 +1,57 @@
1
+ $.extend decko,
2
+ initializeEditors: (range, map) ->
3
+ map = decko.editorInitFunctionMap unless map?
4
+ $.each map, (selector, fn) ->
5
+ $.each range.find(selector), ->
6
+ fn.call $(this)
7
+
8
+ editorContentFunctionMap: {}
9
+
10
+ editorInitFunctionMap:
11
+ 'textarea': -> $(this).autosize()
12
+ '.file-upload': -> decko.upload_file(this)
13
+ '.etherpad-textarea': ->
14
+ $(this).closest('form')
15
+ .find('.edit-submit-button')
16
+ .attr('class', 'etherpad-submit-button')
17
+
18
+ addEditor: (selector, init, get_content) ->
19
+ decko.editorContentFunctionMap[selector] = get_content
20
+ decko.editorInitFunctionMap[selector] = init
21
+
22
+ jQuery.fn.extend
23
+ setContentFieldsFromMap: (map) ->
24
+ map = decko.editorContentFunctionMap unless map?
25
+ this_form = $(this)
26
+ $.each map, (selector, fn) ->
27
+ this_form.setContentFields(selector, fn)
28
+ setContentFields: (selector, fn) ->
29
+ $.each @find(selector), ->
30
+ $(this).setContentField(fn)
31
+ contentField: ->
32
+ @closest('.card-editor').find '.d0-card-content'
33
+ setContentField: (fn) ->
34
+ field = @contentField()
35
+ init_val = field.val() # tinymce-jquery overrides val();
36
+ # that's why we're not using it.
37
+ new_val = fn.call this
38
+ field.val new_val
39
+ field.change() if init_val != new_val
40
+
41
+ $(window).ready ->
42
+ # decko.initializeEditors $('body > :not(.modal)')
43
+ setTimeout (-> decko.initializeEditors $('body > :not(.modal)')), 10
44
+ # dislike the timeout, but without this forms with multiple TinyMCE editors
45
+ # were failing to load properly
46
+ # I couldn't reproduce that problem described above -pk
47
+
48
+ $('body').on 'submit', '.card-form', ->
49
+ $(this).setContentFieldsFromMap()
50
+ $(this).find('.d0-card-content').attr('no-autosave','true')
51
+ true
52
+
53
+ setInterval (-> $('.card-form').setContentFieldsFromMap()), 20000
54
+
55
+
56
+
57
+
@@ -0,0 +1,183 @@
1
+ # filter object that manages dynamic sorting and filtering
2
+
3
+ # el can be any element inside widget
4
+ decko.filter = (el) ->
5
+ closest_widget = $(el).closest "._filter-widget"
6
+ @widget =
7
+ if closest_widget.length
8
+ closest_widget
9
+ else
10
+ $(el).closest("._filtered-content").find "._filter-widget"
11
+
12
+
13
+ # the filter form includes the below
14
+ @form = @widget.find "._filter-form"
15
+
16
+ # one-click filter links
17
+ @quickFilter = @widget.find "._quick-filter"
18
+
19
+ # include filters field, more-fields dropdown, and reset button
20
+ @activeContainer = @widget.find "._filter-container"
21
+
22
+ # the "More Filters" Dropdown
23
+ @dropdown = @widget.find "._add-filter-dropdown"
24
+ @dropdownItems = @widget.find "._filter-category-select"
25
+
26
+ @showWithStatus = (status) ->
27
+ f = this
28
+ $.each (@dropdownItems), ->
29
+ item = $(this)
30
+ if item.data status
31
+ f.activate item.data("category")
32
+
33
+ @reset = () ->
34
+ @restrict @form.find("._reset-filter").data("reset")
35
+
36
+ @clear = () ->
37
+ @dropdownItems.show()
38
+ @activeContainer.find(".input-group").remove()
39
+
40
+ @activate = (category, value) ->
41
+ @activateField category, value
42
+ @hideOption category
43
+
44
+ @showOption = (category) ->
45
+ @dropdown.show()
46
+ @option(category).show()
47
+
48
+ @hideOption = (category) ->
49
+ @option(category).hide()
50
+ @dropdown.hide() if @dropdownItems.length <= @activeFields().length
51
+
52
+ @activeFields = () ->
53
+ @activeContainer.find "._filter-input"
54
+
55
+ @option = (category) ->
56
+ @dropdownItems.filter("[data-category='#{category}']")
57
+
58
+ @findPrototype = (category) ->
59
+ @widget.find "._filter-input-field-prototypes ._filter-input-#{category}"
60
+
61
+ @activateField = (category, value) ->
62
+ field = @findPrototype(category).clone()
63
+ @fieldValue field, value
64
+ @dropdown.before field
65
+ @initField field
66
+ field.find("input, select").first().focus()
67
+
68
+ @fieldValue = (field, value) ->
69
+ if typeof(value) == "object" && !Array.isArray(value)
70
+ @compoundFieldValue field, value
71
+ else
72
+ @simpleFieldValue field, value
73
+
74
+ @simpleFieldValue = (field, value) ->
75
+ input = field.find("input, select")
76
+ input.val value if (typeof value != 'undefined')
77
+
78
+ @compoundFieldValue = (field, vals) ->
79
+ for key of vals
80
+ input = field.find "#filter_value_" + key
81
+ input.val vals[key]
82
+
83
+ @removeField = (category)->
84
+ @activeField(category).remove()
85
+ @showOption category
86
+
87
+ @initField = (field) ->
88
+ @initSelectField field
89
+ decko.initAutoCardPlete field.find("input")
90
+ # only has effect if there is a data-options-card value
91
+
92
+ @initSelectField = (field) ->
93
+ field.find("select").select2
94
+ containerCssClass: ":all:"
95
+ width: "auto"
96
+ dropdownAutoWidth: "true"
97
+
98
+ @activeField = (category) ->
99
+ @activeContainer.find("._filter-input-#{category}")
100
+
101
+ @isActive = (category) ->
102
+ @activeField(category).length
103
+
104
+ # clear filter and use restrictions in data
105
+ @restrict = (data) ->
106
+ @clear()
107
+ for key of data
108
+ @activateField key, data[key]
109
+ @update()
110
+
111
+ @addRestrictions = (hash) ->
112
+ for category of hash
113
+ @removeField category
114
+ @activate category, hash[category]
115
+ @update()
116
+
117
+ @removeRestrictions = (hash) ->
118
+ for category of hash
119
+ @removeField category
120
+ @update()
121
+
122
+ # triggers update
123
+ @setInputVal = (field, value) ->
124
+ select = field.find "select"
125
+ if select.length
126
+ @setSelect2Val select, value
127
+ else
128
+ @setTextInputVal field.find("input"), value
129
+
130
+ # this triggers change, which updates form
131
+ # if we just use simple "val", the display doesn't update correctly
132
+ @setSelect2Val = (select, value) ->
133
+ value = [value] if select.attr("multiple") && !Array.isArray(value)
134
+ select.select2 "val", value
135
+
136
+ @setTextInputVal = (input, value) ->
137
+ input.val value
138
+ @update()
139
+
140
+ @updateLastVals = ()->
141
+ @activeFields().find("input, select").each ()->
142
+ $(this).data "lastVal", $(this).val()
143
+
144
+ @updateUrlBar = () ->
145
+ return if @widget.closest('._noFilterUrlUpdates')[0]
146
+ window.history.pushState "filter", "filter", '?' + @form.serialize()
147
+
148
+ @update = ()->
149
+ @updateLastVals()
150
+ @updateQuickLinks()
151
+ @form.submit()
152
+ @updateUrlBar()
153
+
154
+ @updateQuickLinks = ()->
155
+ widget = this
156
+ links = @quickFilter.find "._filter-link"
157
+ links.addClass "active"
158
+ links.each ->
159
+ link = $(this)
160
+ opts = link.data "filter"
161
+ for key of opts
162
+ widget.deactivateQuickLink link, key, opts[key]
163
+
164
+ @deactivateQuickLink = (link, key, value) ->
165
+ sel = "._filter-input-#{key}"
166
+ $.map [@form.find("#{sel} input, #{sel} select").val()], (arr) ->
167
+ arr = [arr].flat()
168
+ link.removeClass "active" if $.inArray(value, arr) > -1
169
+
170
+ @updateIfChanged = ()->
171
+ @update() if @changedSinceLastVal()
172
+
173
+ @updateIfPresent = (category)->
174
+ val = @activeField(category).find("input, select").val()
175
+ @update() if val && val.length > 0
176
+
177
+ @changedSinceLastVal = () ->
178
+ changed = false
179
+ @activeFields().find("input, select").each ()->
180
+ changed = true if $(this).val() != $(this).data("lastVal")
181
+ changed
182
+
183
+ this
@@ -0,0 +1,128 @@
1
+ # FILTERED LIST / ITEMS INTERFACE
2
+ # (fancy pointer ui)
3
+
4
+ $(window).ready ->
5
+ # add all selected items
6
+ $("body").on "click", "._filter-items ._add-selected", ->
7
+ btn = $(this)
8
+ content = newFilteredListContent btn
9
+ btn.attr "href", addSelectedButtonUrl(btn, content)
10
+
11
+ # select all visible filtered items
12
+ $("body").on "click", "._select-all", ->
13
+ filterBox($(this)).find("._unselected input._checkbox-list-checkbox").each ->
14
+ selectFilteredItem $(this)
15
+ $(this).prop "checked", false
16
+ updateAfterSelection $(this)
17
+
18
+ # deselect all selected items
19
+ $("body").on "click", "._deselect-all", ->
20
+ filterBox($(this)).find("._selected input._checkbox-list-checkbox").each ->
21
+ $(this).slot().remove()
22
+ $(this).prop "checked", true
23
+ updateAfterSelection $(this)
24
+
25
+ $("body").on "click", "._filter-items ._unselected input._checkbox-list-checkbox", ->
26
+ selectFilteredItem $(this)
27
+ updateAfterSelection $(this)
28
+
29
+ $("body").on "click", "._filter-items ._selected input._checkbox-list-checkbox", ->
30
+ bin = selectedBin $(this)
31
+ $(this).slot().remove()
32
+ updateAfterSelection bin
33
+
34
+ $('body').on 'click', '._filtered-list-item-delete', ->
35
+ $(this).closest('li').remove()
36
+
37
+ # TODO: make this object oriented!
38
+
39
+ newFilteredListContent = (el) ->
40
+ $.map(prefilteredIds(el).concat(selectedIds el), (id) -> "~" + id).join "\n"
41
+
42
+ addSelectedButtonUrl = (btn, content) ->
43
+ view = btn.slot().data("slot")["view"]
44
+ card_args = { content: content, type: "Pointer" }
45
+ query = { assign: true, view: view, card: card_args }
46
+ path_base = btn.attr("href") + "&" + $.param(query)
47
+ decko.slotPath path_base, btn.slot()
48
+
49
+ updateAfterSelection = (el) ->
50
+ trackSelectedIds el
51
+ f = new decko.filter(filterBox(el).find('._filter-widget'))
52
+ f.update()
53
+ updateSelectedCount el
54
+ updateUnselectedCount el
55
+
56
+ updateSelectedCount = (el) ->
57
+ count = selectedBin(el).children().length
58
+ filterBox(el).find("._selected-items").html count
59
+ deselectAllLink(el).attr "disabled", count == 0
60
+ if count > 0
61
+ addSelectedButton(el).removeClass("disabled")
62
+ else
63
+ addSelectedButton(el).addClass("disabled")
64
+
65
+ updateSelectedSectionVisibility el, count > 0
66
+
67
+ updateSelectedSectionVisibility = (el, items_present) ->
68
+ box = filterBox el
69
+ selected_items = box.find "._selected-item-list"
70
+ help_text = box.find "._filter-help"
71
+ if items_present
72
+ selected_items.show()
73
+ help_text.hide()
74
+ else
75
+ selected_items.hide()
76
+ help_text.show()
77
+
78
+ updateUnselectedCount = (el) ->
79
+ box = filterBox(el)
80
+ count = box.find("._search-checkbox-list").children().length
81
+ box.find("._unselected-items").html count
82
+ box.find("._select-all").attr "disabled", count > 0
83
+
84
+ selectFilteredItem = (checkbox) ->
85
+ checkbox.prop "checked", true
86
+ selectedBin(checkbox).append checkbox.slot()
87
+
88
+ selectedBin = (el) ->
89
+ filterBox(el).find "._selected-bin"
90
+
91
+ filterBox = (el) ->
92
+ el.closest "._filter-items"
93
+
94
+ # this button contains the data about the form that opened the filter-items interface.
95
+ # the itemSelector
96
+ addSelectedButton = (el) ->
97
+ filterBox(el).find("._add-selected")
98
+
99
+ deselectAllLink = (el) ->
100
+ filterBox(el).find("._deselect-all")
101
+
102
+ selectedIds = (el) ->
103
+ selectedData el, "cardId"
104
+
105
+ prefilteredIds = (el) ->
106
+ prefilteredData el, "cardId"
107
+
108
+ prefilteredNames = (el) ->
109
+ prefilteredData el, "cardName"
110
+
111
+ prefilteredData = (el, field) ->
112
+ btn = addSelectedButton el
113
+ selector = btn.data "itemSelector"
114
+ arrayFromField btn.slot().find(selector), field
115
+
116
+ selectedNames = (el) ->
117
+ selectedData el, "cardName"
118
+
119
+ selectedData = (el, field) ->
120
+ arrayFromField selectedBin(el).children(), field
121
+
122
+ arrayFromField = (rows, field) ->
123
+ rows.map( -> $(this).data field ).toArray()
124
+
125
+ trackSelectedIds = (el) ->
126
+ ids = prefilteredIds(el).concat selectedIds(el)
127
+ box = filterBox el
128
+ box.find("._not-ids").val ids.toString()