card-mod-format 0.14.2 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/assets/script/decko/clicks_and_hovers.js.coffee +49 -0
  3. data/assets/script/decko/decko.js.coffee +37 -0
  4. data/assets/script/decko/decko_jquery.js.coffee +25 -0
  5. data/assets/script/decko/slot.js.coffee +150 -0
  6. data/assets/script/decko/slot_ready.js.coffee +11 -0
  7. data/assets/script/decko/slotter.js.coffee +210 -0
  8. data/assets/script/jquery/jquery-ui.min.js +13 -0
  9. data/assets/script/jquery/jquery.autosize.js +274 -0
  10. data/assets/script/jquery/jquery.ui.autocomplete.html.js +41 -0
  11. data/assets/script/manifest.yml +38 -0
  12. data/assets/style/common.scss +75 -0
  13. data/assets/style/logo_and_credit.scss +24 -0
  14. data/assets/style/menu.scss +51 -0
  15. data/assets/style/messaging.scss +59 -0
  16. data/assets/style/misc.scss +86 -0
  17. data/assets/style/open_and_closed.scss +68 -0
  18. data/{locales → config/locales}/de.yml +1 -0
  19. data/{locales → config/locales}/en.yml +1 -0
  20. data/data/files/credit_image.svg +59 -0
  21. data/data/files/mod_format_script_asset_output/file.js +66 -0
  22. data/data/real.yml +67 -0
  23. data/lib/card/format/html_format.rb +0 -2
  24. data/lib/card/mod/format.rb +4 -0
  25. data/lib/card/path.rb +20 -20
  26. data/set/all/base.rb +1 -11
  27. data/set/all/content.rb +3 -11
  28. data/set/all/csv.rb +22 -74
  29. data/set/all/data.rb +12 -12
  30. data/set/all/demo.rb +6 -2
  31. data/set/all/error.rb +1 -1
  32. data/set/all/html/error.rb +2 -2
  33. data/set/all/html/head.rb +22 -12
  34. data/set/all/html/header.rb +10 -40
  35. data/set/all/html/header_wrap.haml +3 -4
  36. data/set/all/html/labeled.haml +1 -1
  37. data/set/all/html/menu.rb +45 -22
  38. data/set/all/html/views.rb +11 -28
  39. data/set/all/html/wrap.rb +5 -4
  40. data/set/all/html.rb +2 -3
  41. data/set/all/json.rb +1 -5
  42. data/set/right/head.rb +1 -0
  43. data/set/type/basic.rb +1 -1
  44. data/set/type/cardtype.rb +4 -6
  45. data/set/type/json.rb +1 -1
  46. data/set/type/number.rb +1 -16
  47. data/vendor/jquery_file_upload/LICENSE.txt +20 -0
  48. data/vendor/jquery_file_upload/README.md +224 -0
  49. data/vendor/jquery_file_upload/SECURITY.md +227 -0
  50. data/vendor/jquery_file_upload/VULNERABILITIES.md +118 -0
  51. data/vendor/jquery_file_upload/cors/postmessage.html +85 -0
  52. data/vendor/jquery_file_upload/cors/result.html +26 -0
  53. data/vendor/jquery_file_upload/css/jquery.fileupload-noscript.css +22 -0
  54. data/vendor/jquery_file_upload/css/jquery.fileupload-ui-noscript.css +17 -0
  55. data/vendor/jquery_file_upload/css/jquery.fileupload-ui.css +68 -0
  56. data/vendor/jquery_file_upload/css/jquery.fileupload.css +36 -0
  57. data/vendor/jquery_file_upload/docker-compose.yml +55 -0
  58. data/vendor/jquery_file_upload/img/loading.gif +0 -0
  59. data/vendor/jquery_file_upload/img/progressbar.gif +0 -0
  60. data/vendor/jquery_file_upload/index.html +357 -0
  61. data/vendor/jquery_file_upload/js/cors/jquery.postmessage-transport.js +126 -0
  62. data/vendor/jquery_file_upload/js/cors/jquery.xdr-transport.js +97 -0
  63. data/vendor/jquery_file_upload/js/demo.js +75 -0
  64. data/vendor/jquery_file_upload/js/jquery.fileupload-audio.js +101 -0
  65. data/vendor/jquery_file_upload/js/jquery.fileupload-image.js +347 -0
  66. data/vendor/jquery_file_upload/js/jquery.fileupload-process.js +170 -0
  67. data/vendor/jquery_file_upload/js/jquery.fileupload-ui.js +759 -0
  68. data/vendor/jquery_file_upload/js/jquery.fileupload-validate.js +119 -0
  69. data/vendor/jquery_file_upload/js/jquery.fileupload-video.js +101 -0
  70. data/vendor/jquery_file_upload/js/jquery.fileupload.js +1604 -0
  71. data/vendor/jquery_file_upload/js/jquery.iframe-transport.js +227 -0
  72. data/vendor/jquery_file_upload/js/vendor/jquery.ui.widget.js +805 -0
  73. data/vendor/jquery_file_upload/package-lock.json +6853 -0
  74. data/vendor/jquery_file_upload/package.json +116 -0
  75. data/vendor/jquery_file_upload/server/gae-python/app.yaml +18 -0
  76. data/vendor/jquery_file_upload/server/gae-python/main.py +204 -0
  77. data/vendor/jquery_file_upload/server/gae-python/static/favicon.ico +0 -0
  78. data/vendor/jquery_file_upload/server/gae-python/static/robots.txt +2 -0
  79. data/vendor/jquery_file_upload/server/php/Dockerfile +44 -0
  80. data/vendor/jquery_file_upload/server/php/UploadHandler.php +1480 -0
  81. data/vendor/jquery_file_upload/server/php/index.php +15 -0
  82. data/vendor/jquery_file_upload/server/php/php.ini +5 -0
  83. data/vendor/jquery_file_upload/test/index.html +49 -0
  84. data/vendor/jquery_file_upload/test/unit.js +989 -0
  85. data/vendor/jquery_file_upload/test/vendor/chai.js +10854 -0
  86. data/vendor/jquery_file_upload/test/vendor/mocha.css +325 -0
  87. data/vendor/jquery_file_upload/test/vendor/mocha.js +18178 -0
  88. data/vendor/jquery_file_upload/wdio/LICENSE.txt +20 -0
  89. data/vendor/jquery_file_upload/wdio/assets/black+white-3x2.jpg +0 -0
  90. data/vendor/jquery_file_upload/wdio/assets/black+white-60x40.gif +0 -0
  91. data/vendor/jquery_file_upload/wdio/conf/chrome.js +40 -0
  92. data/vendor/jquery_file_upload/wdio/conf/firefox.js +25 -0
  93. data/vendor/jquery_file_upload/wdio/hooks/index.js +36 -0
  94. data/vendor/jquery_file_upload/wdio/test/pages/file-upload.js +79 -0
  95. data/vendor/jquery_file_upload/wdio/test/specs/01-file-upload.js +25 -0
  96. data/vendor/jquery_file_upload/wdio/wdio.conf.js +4 -0
  97. data/vendor/jquery_rails/CHANGELOG.md +359 -0
  98. data/vendor/jquery_rails/CONTRIBUTING.md +132 -0
  99. data/vendor/jquery_rails/Gemfile +22 -0
  100. data/vendor/jquery_rails/MIT-LICENSE +21 -0
  101. data/vendor/jquery_rails/README.md +75 -0
  102. data/vendor/jquery_rails/Rakefile +59 -0
  103. data/vendor/jquery_rails/VERSIONS.md +62 -0
  104. data/vendor/jquery_rails/jquery-rails.gemspec +26 -0
  105. data/vendor/jquery_rails/lib/jquery/assert_select.rb +149 -0
  106. data/vendor/jquery_rails/lib/jquery/rails/engine.rb +6 -0
  107. data/vendor/jquery_rails/lib/jquery/rails/version.rb +9 -0
  108. data/vendor/jquery_rails/lib/jquery/rails.rb +8 -0
  109. data/vendor/jquery_rails/lib/jquery-rails.rb +1 -0
  110. data/vendor/jquery_rails/test/assert_select_jquery_test.rb +85 -0
  111. data/vendor/jquery_rails/test/test_helper.rb +6 -0
  112. data/vendor/jquery_rails/vendor/assets/javascripts/jquery.js +11008 -0
  113. data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.js +5 -0
  114. data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.map +1 -0
  115. data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.js +9814 -0
  116. data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.js +4 -0
  117. data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.map +1 -0
  118. data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.js +10364 -0
  119. data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.js +2 -0
  120. data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.map +1 -0
  121. data/vendor/jquery_rails/vendor/assets/javascripts/jquery_ujs.js +555 -0
  122. metadata +106 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 033c1838261484c659a9c3508ec505e77adf55e7c86e44aa7634d6b5a516f4f4
4
- data.tar.gz: 95976aff533ba8d7a7f05f719e5a5322e5ddc1948f9af2bfc829451bad50112c
3
+ metadata.gz: 6385d27eaf6708d0704daa72425a148df5130f657e4670c93fe204de622a019e
4
+ data.tar.gz: bfc1ff58ad8c05d9698f9ae31b16cc461594d1db81098433e5bc8cd002863857
5
5
  SHA512:
6
- metadata.gz: 4a2b0fc9f5bc4283b178165c44a0f0a4764ecd70f77eca605e2a50912e2d219bf9d1f02b84e1557b86c629979c80ead223ee1950af30f048facd583c08711194
7
- data.tar.gz: 4cf2c9bc444e64980a035c14bcd414ee3718fa39b4c075687d488dccea7c28e17e81ee862c7528b0a31df32d2151bd0b54b290de6c7827efe3f9738002e6381c
6
+ metadata.gz: a4d83073a5ba048b617879b4337b38ca6395c47e22f1939884fce4b3d19e237773f840ab9bccb9503b6fbd0aaea03db428474fd695c660b300cf62fbeb50e040
7
+ data.tar.gz: 8a45d1a24c7d128c0fe1ba1b2c8b2e499ec0914ecf6e758f8ffa6e9c25ca5132b642f24a963fb6198ca00dea167a5e7b16db39d583cd4d459c735792a45526e4
@@ -0,0 +1,49 @@
1
+ $(window).ready ->
2
+ $('body').on 'click', '.submitter', ->
3
+ $(this).closest('form').submit()
4
+
5
+ $('body').on 'click', 'button.redirecter', ->
6
+ window.location = $(this).attr('href')
7
+
8
+ $('body').on 'click', '.render-error-link', (event) ->
9
+ msg = $(this).closest('.render-error').find '.render-error-message'
10
+ msg.show()
11
+ # msg.dialog()
12
+ event.preventDefault()
13
+
14
+ $(document).on 'click', '._stop_propagation', (event)->
15
+ event.stopPropagation()
16
+
17
+ $("body").on 'click', '._prevent_default', (event)->
18
+ event.preventDefault()
19
+
20
+ $('body').on 'mouseenter', 'a[data-hover-text]', ->
21
+ text = $(this).text()
22
+ $(this).data("original-text", text)
23
+ $(this).text($(this).data("hover-text"))
24
+
25
+ $('body').on 'mouseleave', 'a[data-hover-text]', ->
26
+ $(this).text($(this).data("original-text"))
27
+
28
+ $('body').on 'mouseenter', '[hover_content]', ->
29
+ $(this).attr 'hover_restore', $(this).html()
30
+ $(this).html $(this).attr( 'hover_content' )
31
+
32
+ $('body').on 'mouseleave', '[hover_content]', ->
33
+ $(this).html $(this).attr( 'hover_restore' )
34
+
35
+ decko.slot.ready (slot) ->
36
+ if isTouchDevice()
37
+ slot.find('._show-on-hover').removeClass('_show-on-hover')
38
+
39
+ isTouchDevice = ->
40
+ if 'ontouchstart' of window or window.DocumentTouch and
41
+ document instanceof DocumentTouch
42
+ true
43
+ else
44
+ detectMobileBrowser()
45
+
46
+ # source for this method: detectmobilebrowsers.com
47
+ detectMobileBrowser = (userAgent) ->
48
+ userAgent = navigator.userAgent or navigator.vendor or window.opera
49
+ /(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))
@@ -0,0 +1,37 @@
1
+ window.decko =
2
+ rootUrl: "" # overwritten in inline script in head
3
+
4
+ # returns absolute path (starting with a slash)
5
+ # if rawPath is complete url, this returns the complete url
6
+ # if rawPath is relative (no slash), this adds relative root
7
+ path: (rawPath) ->
8
+ if rawPath.match /^\/|:\/\//
9
+ rawPath
10
+ else
11
+ decko.rootUrl + rawPath
12
+
13
+ editors:
14
+ init: {}
15
+ content: {}
16
+ add: (selector, initf, contentf)->
17
+ decko.editors.init[selector] = initf
18
+ decko.editors.content[selector] = contentf
19
+
20
+ warn: (stuff) -> console.log stuff if console?
21
+
22
+ snakeCase: (str)->
23
+ str.replace /([a-z])([A-Z])/g, (match) -> match[0] + '_' +
24
+ match[1].toLowerCase()
25
+
26
+
27
+ #~~~~~ ( EVENTS )
28
+
29
+ $(window).ready ->
30
+ $.ajaxSetup cache: false
31
+
32
+ $('body').on 'click', '._confirm', ->
33
+ confirm $(this).data('confirm-msg') || 'Are you sure?'
34
+
35
+
36
+
37
+
@@ -0,0 +1,25 @@
1
+ jQuery.fn.extend
2
+ findCard: (id) -> @find("[data-card-id='" + id + "']")
3
+
4
+ isMain: -> @slot().parent('#main')[0]
5
+
6
+ cardMark: ->
7
+ if @data('cardId') then "~#{@data('cardId')}" else @data("cardName")
8
+
9
+ isMainOrMainModal: ->
10
+ el = $(this)
11
+ el = el.slotOrigin("modal") if el.closest(".modal")[0]
12
+ el && el.isMain()
13
+
14
+ notify: (message, status) ->
15
+ slot = @slot(status)
16
+ notice = slot.find '.card-notice'
17
+ unless notice[0]
18
+ notice = $('<div class="card-notice"></div>')
19
+ form = slot.find('.card-form')
20
+ if form[0]
21
+ $(form[0]).append notice
22
+ else
23
+ slot.append notice
24
+ notice.html message
25
+ notice.show 'blind'
@@ -0,0 +1,150 @@
1
+ decko.slot =
2
+ # returns full path with slot parameters
3
+ path: (path, slot)->
4
+ params = slotPathParams slot
5
+ decko.path(path) + ( (if path.match /\?/ then '&' else '?') + $.param(params) )
6
+
7
+ ready: (func)->
8
+ $('document').ready ->
9
+ $('body').on 'decko.slot.ready', '.card-slot', (e, slotter) ->
10
+ e.stopPropagation()
11
+ if slotter?
12
+ func.call this, $(this), $(slotter)
13
+ else
14
+ func.call this, $(this)
15
+
16
+ destroy: (func)->
17
+ $('document').ready ->
18
+ $('body').on 'decko.slot.destroy', '.card-slot, ._modal-slot', (e) ->
19
+ e.stopPropagation()
20
+ func.call this, $(this)
21
+
22
+
23
+ jQuery.fn.extend
24
+ isSlot: -> $(this).hasClass "card-slot"
25
+
26
+ triggerSlotReady: (slotter) ->
27
+ @trigger "decko.slot.ready", slotter if @isSlot()
28
+ @find(".card-slot").trigger "decko.slot.ready", slotter
29
+
30
+ slot: (status="success", mode="replace") ->
31
+ return @modalSlot() if mode == "modal"
32
+
33
+ @_slotSelect("slot-#{status}-selector") ||
34
+ @_slotSelect("slot-selector") ||
35
+ @closest(".card-slot")
36
+
37
+ slotUrl: ->
38
+ slot = $(this)
39
+ decko.slot.path "#{slot.cardMark()}/#{slot.data("slot")["view"]}"
40
+
41
+ slotFind: (selector) ->
42
+ switch selector
43
+ when "modal-origin" then @slotOrigin "modal"
44
+ when "overlay-origin" then @slotOrigin "overlay"
45
+ else slotScour @closest(selector), @closest(".card-slot"), selector
46
+
47
+ slotClear: () ->
48
+ @trigger "decko.slot.destroy"
49
+ @empty()
50
+
51
+ # type can be "modal" or "overlay"
52
+ slotOrigin: (type) ->
53
+ overlaySlot = @closest("[data-#{type}-origin-slot-id]")
54
+ origin_slot_id = overlaySlot.data("#{type}-origin-slot-id")
55
+ origin_slot = $("[data-slot-id=#{origin_slot_id}]")
56
+ if origin_slot[0]?
57
+ origin_slot
58
+ else
59
+ decko.warn "couldn't find origin with slot id #{origin_slot_id}"
60
+
61
+ slotReload: (url) ->
62
+ @each -> $(this)._slotReloadSingle url
63
+
64
+ slotUpdate: (newContent, mode) ->
65
+ mode ||= "replace"
66
+ @slotContent newContent, mode, $(this)
67
+
68
+ slotContent: (newContent, mode, $slotter) ->
69
+ v = $(newContent)[0] && $(newContent) || newContent
70
+
71
+ if typeof(v) == "string"
72
+ # Needed to support "TEXT: result" pattern in success (eg deleting nested cards)
73
+ @slot("success", mode)._slotFillOrReplace v, $slotter
74
+ else
75
+ if v.hasClass("_overlay")
76
+ mode = "overlay"
77
+ else if v.hasClass("_modal")
78
+ mode = "modal"
79
+ @slot("success", mode)._slotContentFromElement v, mode, $slotter
80
+ v
81
+
82
+ _slotContentFromElement: (el, mode, $slotter) ->
83
+ if mode == "overlay"
84
+ @addOverlay(el, $slotter)
85
+ else if el.hasClass("_modal-slot") or mode == "modal"
86
+ el.showAsModal($slotter)
87
+ else
88
+ slot_id = @data("slot-id")
89
+ el.attr("data-slot-id", slot_id) if slot_id
90
+ @trigger "decko.slot.destroy"
91
+ @_slotFillOrReplace el, $slotter
92
+ decko.contentLoaded(el, $slotter)
93
+
94
+ _slotFillOrReplace: (content, $slotter) ->
95
+ if @hasClass("_fixed-slot")
96
+ @html content
97
+ else
98
+ @replaceWith content
99
+ decko.contentLoaded(this, $slotter)
100
+
101
+ _slotSelect: (selectorName) ->
102
+ if selector = @data(selectorName)
103
+ slot = @slotFind selector
104
+ slot && slot[0] && slot
105
+
106
+ _slotReloadSingle: (url) ->
107
+ $slot = $(this)
108
+ url = $slot.slotUrl() unless url?
109
+ $slot.addClass 'slotter'
110
+ $slot.data "url", url
111
+ $slot.data "remote", true
112
+ $slot.attr 'href', url
113
+ this[0].href = url
114
+ # that's where handleRemote gets the url from
115
+ # .attr(href, url) only works for anchors
116
+ $.rails.handleRemote $slot
117
+
118
+ # ~~~~~~~~~~~~~~~~~~~~~~~~
119
+ # "private" helper methods
120
+
121
+ slotPathParams = (slot) ->
122
+ params = {}
123
+ main = $('#main').children('.card-slot').data 'cardName'
124
+ params['main'] = main if main?
125
+
126
+ if slot
127
+ params['is_main'] = true if slot.isMain()
128
+ slotdata = slot.data 'slot'
129
+ if slotdata?
130
+ slotParams slotdata, params, 'slot'
131
+ params['type'] = slotdata['type'] if slotdata['type']
132
+ params
133
+
134
+ slotParams = (raw, processed, prefix)->
135
+ $.each raw, (key, value)->
136
+ cgiKey = prefix + '[' + decko.snakeCase(key) + ']'
137
+ if key == 'items'
138
+ slotParams value, processed, cgiKey
139
+ else
140
+ processed[cgiKey] = value
141
+
142
+ slotScour = (target_slot, parent_slot, selector) ->
143
+ # if slot-selector doesn't apply to a child, search in all parent slots and finally in the body
144
+ while target_slot.length == 0 and parent_slot.length > 0
145
+ target_slot = $(parent_slot).find(selector)
146
+ parent_slot = $(parent_slot).parent().closest '.card-slot'
147
+ if target_slot.length == 0
148
+ $(selector)
149
+ else
150
+ target_slot
@@ -0,0 +1,11 @@
1
+ decko.slot.ready (slot) ->
2
+ slot.find('card-view-placeholder').each ->
3
+ $place = $(this)
4
+ return if $place.data("loading")
5
+
6
+ $place.data "loading", true
7
+ $.get $place.data("url"), (data, _status) ->
8
+ $place.replaceWith data
9
+
10
+ slot.find('._disappear').delay(5000).animate(
11
+ height: 0, 1000, -> $(this).hide())
@@ -0,0 +1,210 @@
1
+ # There are three places that can control what happens after an ajax request
2
+ # 1. the element that triggered the request (eg. a link or a button)
3
+ # 2. the closest ".slotter" element
4
+ # (if the trigger itself isn't a slotter,
5
+ # a common example is that a form is a slotter but the form buttons aren't)
6
+ # 3. the slot returned by the request
7
+ #
8
+ # A slot is an element marked with "card-slot" class, a slotter has a "slotter" class.
9
+ # By the default, the closest slot of the slotter is replaced with the new slot that the
10
+ # request returned. The behavior can be changed with css classes and data attributes.
11
+ #
12
+ # To 1. The trigger element has only a few options to override the slotter.
13
+ # classes:
14
+ # "_close-modal-on-success"
15
+ # "_close-overlay-on-success"
16
+ # "_update-origin"
17
+ #
18
+ # To 2. The slotter is the standard way to define what happens with request result
19
+ # data:
20
+ # slot-selector
21
+ # a css selector that defines which slot will be replaced.
22
+ # You can also use "modal-origin" and "overlay-origin" to refer to the origin slots.
23
+ # slot-success-selector/slot-error-selector
24
+ # the same as slot-selector but only used
25
+ # for success case or error case, respectively
26
+ # update-foreign-slot
27
+ # a css selector to specify an additional slot that will be
28
+ # updated after the request.
29
+ # update-foreign-slot-url
30
+ # a url to fetch the new content for the additional slot
31
+ # if not given the slot is updated with the same card and view that was used before
32
+ # update-origin
33
+ # if present then the slot from where the current modal or overlay slot was opened
34
+ # will be updated
35
+ # slotter-mode
36
+ # possible values are
37
+ # replace (default)
38
+ # replace the closest slot with new slot
39
+ # override
40
+ # the same as replace, but overrides the slot options of the slot that is replaced
41
+ # modal
42
+ # show new slot in modal; if there is already a modal then put it on top
43
+ # modal-replace
44
+ # replace existing modal
45
+ # overlay
46
+ # show new slot in overlay
47
+ # update-origin
48
+ # update closest slot of the slotter that opened the modal or overlay
49
+ # (assumes that the request was triggered from a modal or overlay)
50
+ # If you need the update-origin mode together with another mode then use
51
+ # data-update-origin="true".
52
+ # silent-success
53
+ # do nothing
54
+ #
55
+ # classes:
56
+ # _close-overlay
57
+ # _close-modal
58
+ #
59
+ # To 3. Similar as 1, the slot has only overlay and modal options.
60
+ # classes:
61
+ # _modal
62
+ # show slot in modal
63
+ # _overlay
64
+ # show slot in overlay
65
+ #
66
+ #
67
+ $(window).ready ->
68
+ $('body').on 'ajax:success', '.slotter', (event, data) ->
69
+ $(this).slotterSuccess event, data
70
+
71
+ $('body').on 'ajax:error', '.slotter', (event, xhr) ->
72
+ $(this).showErrorResponse xhr.status, xhr.responseText
73
+
74
+ $('body').on 'click', 'button.slotter', ->
75
+ return false if !$.rails.allowAction $(this)
76
+ $.rails.handleRemote $(this)
77
+
78
+ # $('body').on 'click', '._clickable.slotter', (event)->
79
+ # $(this)[0].href = $(this).attr("href") # that's where rails.handleRemote
80
+ # # expects the url
81
+ # $.rails.handleRemote $(this)
82
+
83
+ $('body').on 'click', '[data-bs-dismiss="overlay"]', ->
84
+ $(this).slotFind(".card-slot._overlay").removeOverlay()
85
+
86
+ $('body').on 'click', '._close-overlay-on-success', ->
87
+ $(this).closeOnSuccess("overlay")
88
+
89
+ $('body').on 'click', '._close-modal-on-success', ->
90
+ $(this).closeOnSuccess("modal")
91
+
92
+ $('body').on 'click', '._close-on-success', ->
93
+ $(this).closeOnSuccess()
94
+
95
+ $('body').on 'click', '._update-origin', ->
96
+ $(this).closest('.slotter').data("slotter-mode", "update-origin")
97
+
98
+ $('body').on 'submit', 'form.slotter', ->
99
+ form = $(this)
100
+ if form.data("main-success") and form.isMainOrMainModal()
101
+ form.mainSuccess()
102
+
103
+ $('body').on 'ajax:beforeSend', '.slotter', (event, xhr, opt)->
104
+ $(this).slotterBeforeSend opt
105
+
106
+ jQuery.fn.extend
107
+ mainSuccess: ()->
108
+ form = $(this)
109
+ $.each form.data("main-success"), (key, value)->
110
+ inputSelector = "[name=success\\[" + key + "\\]]"
111
+ input = form.find inputSelector
112
+ unless input[0]
113
+ input = $('<input type="hidden" name="success[' + key + ']"/>')
114
+ form.append input
115
+ input.val value
116
+
117
+ slotterSuccess: (event, responseData) ->
118
+ unless @hasClass("slotter")
119
+ console.log "warning: slotterSuccess called on non-slotter element #{this}"
120
+ return
121
+
122
+ return if event.slotSuccessful
123
+
124
+ @showSuccessResponse responseData, @data("slotter-mode")
125
+
126
+ if @hasClass "_close-overlay"
127
+ @removeOverlay()
128
+ if @hasClass "_close-modal"
129
+ @closest('.modal').modal "hide"
130
+
131
+ # should scroll to top after clicking on new page
132
+ if @hasClass "card-paging-link"
133
+ slot_top_pos = @slot().offset().top
134
+ $("body").scrollTop slot_top_pos
135
+ if @data("update-foreign-slot")
136
+ $slot = @slotFind @data("update-foreign-slot")
137
+ reload_url = @data("update-foreign-slot-url")
138
+ $slot.slotReload reload_url
139
+
140
+ if @data('original-slotter-mode')
141
+ @attr 'data-slotter-mode', @data('original-slotter-mode')
142
+ if @data('original-slot-selector')
143
+ @attr 'data-slot-selector', @data('original-slot-selector')
144
+
145
+ event.slotSuccessful = true
146
+
147
+ showSuccessResponse: (responseData, mode) ->
148
+ if responseData.redirect
149
+ window.location = responseData.redirect
150
+ else if responseData.reload
151
+ window.location.reload(true)
152
+ else
153
+ switch mode
154
+ when "silent-success" then return
155
+ when "update-modal-origin" then @updateModalOrigin()
156
+ when "update-origin" then @updateOrigin()
157
+ else @slotUpdate responseData, mode
158
+
159
+ showErrorResponse: (status, result) ->
160
+ if status == 403 #permission denied
161
+ $(result).showAsModal $(this)
162
+ else if status == 900
163
+ $(result).showAsModal $(this)
164
+ else
165
+ @notify result, "error"
166
+
167
+ if status == 409 #edit conflict
168
+ @slot().find('.current_revision_id').val(
169
+ @slot().find('.new-current-revision-id').text()
170
+ )
171
+
172
+ updateModalOrigin: () ->
173
+ if @overlaySlot()
174
+ overlayOrigin = @slotOrigin("overlay")
175
+ overlayOrigin.updateOrigin()
176
+ else if @closest("#modal-container")[0]
177
+ @updateOrigin()
178
+
179
+ updateOrigin: () ->
180
+ type = if @overlaySlot()
181
+ "overlay"
182
+ else if @closest("#modal-container")[0]
183
+ "modal"
184
+
185
+ return unless type?
186
+
187
+ origin = @slotOrigin(type)
188
+ if origin && origin[0]?
189
+ origin.slotReload()
190
+
191
+ registerAsOrigin: (type, slot) ->
192
+ if slot.hasClass("_modal-slot")
193
+ slot = slot.find(".modal-body") # put the origin slot id on the modal-body instead
194
+ # of on the slot, so that it survives slot reloads
195
+ slot.attr("data-#{type}-origin-slot-id", @slot().data("slot-id"))
196
+
197
+
198
+ # close modal or overlay
199
+ closeOnSuccess: (type) ->
200
+ slotter = @closest('.slotter')
201
+ if !type?
202
+ type = if @isInOverlay() then "overlay" else "modal"
203
+ slotter.addClass "_close-#{type}"
204
+
205
+ slotterBeforeSend: (opt) ->
206
+ # avoiding duplication. could be better test?
207
+ return if opt.noSlotParams or opt.url.match(/home_view/) or
208
+ @data("slotter-mode") == "modal" or @data("slotter-mode") == "override"
209
+
210
+ opt.url = decko.slot.path opt.url, @slot()