card-mod-format 0.15.6 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,8 @@
1
1
  decko.slot =
2
2
  # returns full path with slot parameters
3
- path: (path, slot)->
3
+ path: (path, slot, slotterMode)->
4
4
  params = slotPathParams slot
5
+ params["slotter_mode"] = slotterMode if slotterMode?
5
6
  decko.path(path) + ( (if path.match /\?/ then '&' else '?') + $.param(params) )
6
7
 
7
8
  ready: (func)->
@@ -19,7 +20,6 @@ decko.slot =
19
20
  e.stopPropagation()
20
21
  func.call this, $(this)
21
22
 
22
-
23
23
  jQuery.fn.extend
24
24
  isSlot: -> $(this).hasClass "card-slot"
25
25
 
@@ -53,7 +53,7 @@ jQuery.fn.extend
53
53
  overlaySlot = @closest("[data-#{type}-origin-slot-id]")
54
54
  origin_slot_id = overlaySlot.data("#{type}-origin-slot-id")
55
55
  origin_slot = $("[data-slot-id=#{origin_slot_id}]")
56
- if origin_slot[0]?
56
+ if origin_slot.length > 0
57
57
  origin_slot
58
58
  else
59
59
  decko.warn "couldn't find origin with slot id #{origin_slot_id}"
@@ -61,12 +61,18 @@ jQuery.fn.extend
61
61
  slotReload: (url) ->
62
62
  @each -> $(this)._slotReloadSingle url
63
63
 
64
+ slotReloading: ()->
65
+ # TODO: add default spinner behavior
66
+
67
+ slotLoadingComplete: ()->
68
+ # TODO: add default spinner behavior
69
+
64
70
  slotUpdate: (newContent, mode) ->
65
71
  mode ||= "replace"
66
72
  @slotContent newContent, mode, $(this)
67
73
 
68
74
  slotContent: (newContent, mode, $slotter) ->
69
- v = $(newContent)[0] && $(newContent) || newContent
75
+ v = $(newContent).length > 0 && $(newContent) || newContent
70
76
 
71
77
  if typeof(v) == "string"
72
78
  # Needed to support "TEXT: result" pattern in success (eg deleting nested cards)
@@ -114,6 +120,7 @@ jQuery.fn.extend
114
120
  # that's where handleRemote gets the url from
115
121
  # .attr(href, url) only works for anchors
116
122
  $.rails.handleRemote $slot
123
+ $slot.slotReloading()
117
124
 
118
125
  # ~~~~~~~~~~~~~~~~~~~~~~~~
119
126
  # "private" helper methods
@@ -65,12 +65,18 @@
65
65
  #
66
66
  #
67
67
  $(window).ready ->
68
+ $('body').on 'ajax:send', '.slotter', (event, data) ->
69
+ $(this).slot().slotReloading()
70
+
68
71
  $('body').on 'ajax:success', '.slotter', (event, data) ->
69
72
  $(this).slotterSuccess event, data
70
73
 
71
74
  $('body').on 'ajax:error', '.slotter', (event, xhr) ->
72
75
  $(this).showErrorResponse xhr.status, xhr.responseText
73
76
 
77
+ $('body').on 'ajax:complete', '.slotter', (event, data) ->
78
+ $(this).slot().slotLoadingComplete()
79
+
74
80
  $('body').on 'click', 'button.slotter', ->
75
81
  return false if !$.rails.allowAction $(this)
76
82
  $.rails.handleRemote $(this)
@@ -103,6 +109,15 @@ $(window).ready ->
103
109
  $('body').on 'ajax:beforeSend', '.slotter', (event, xhr, opt)->
104
110
  $(this).slotterBeforeSend opt
105
111
 
112
+ # NOTE: without the following two propagation checks, slotter events can propagate
113
+ # from one slot to another and cause weird problems, as with the type editor
114
+ $('body').on 'ajax:beforeSend', '.card-slot', (event)->
115
+ event.stopPropagation()
116
+
117
+ $('body').on 'ajax:send', '.card-slot', (event)->
118
+ event.stopPropagation()
119
+
120
+
106
121
  jQuery.fn.extend
107
122
  mainSuccess: ()->
108
123
  form = $(this)
@@ -204,7 +219,14 @@ jQuery.fn.extend
204
219
 
205
220
  slotterBeforeSend: (opt) ->
206
221
  # avoiding duplication. could be better test?
222
+ mode = @slotterMode()
223
+
207
224
  return if opt.noSlotParams or opt.url.match(/home_view/) or
208
- @data("slotter-mode") == "modal" or @data("slotter-mode") == "override"
225
+ mode == "modal" or mode == "override"
226
+
227
+ opt.url = decko.slot.path opt.url, @slot(), mode
209
228
 
210
- opt.url = decko.slot.path opt.url, @slot()
229
+ slotterMode: () ->
230
+ mode = @data "slotter-mode"
231
+ return if !mode? || (mode.match(/origin/) && !@slotOrigin())
232
+ mode
@@ -6,6 +6,7 @@
6
6
  position: absolute;
7
7
  right: 8px;
8
8
  top: 5px;
9
+ width: auto;
9
10
  }
10
11
 
11
12
  .d0-card-content, .titled-view > .d0-card-header {
@@ -14,8 +15,10 @@
14
15
  }
15
16
  }
16
17
 
17
- .d0-card-content .card-menu i {
18
- font-size: 1.2em
18
+ .d0-card-content, .labeled-view {
19
+ .card-menu i {
20
+ font-size: 1.2em
21
+ }
19
22
  }
20
23
 
21
24
  .modal-menu, .overlay-menu {
@@ -33,7 +36,7 @@
33
36
  // Hover over these, and only the card menus that are immediate children will appear
34
37
  .card-slot > .d0-card-frame > .d0-card-header,
35
38
  .card-slot > .d0-card-header,
36
- .card-slot.labeled-view > .labeled-content > .d0-card-body,
39
+ .card-slot.labeled-view,
37
40
  .card-slot,
38
41
  .card > .card-body,
39
42
  .card > .card-header {
data/config/admin.yml ADDED
@@ -0,0 +1,30 @@
1
+ configurations:
2
+ basic:
3
+ - title
4
+ - head
5
+ - credit
6
+ cardtypes:
7
+ text:
8
+ - basic
9
+ - plain_text
10
+ - html
11
+ - phrase
12
+ scripting:
13
+ - json
14
+ data:
15
+ - number
16
+ - toggle
17
+ - uri
18
+ views:
19
+ - name
20
+ - link
21
+ - url_link
22
+ - content
23
+ - short_content
24
+ - core
25
+ - raw
26
+ - titled
27
+ - labeled
28
+ - smart_label
29
+ - title
30
+ - title_link
@@ -22,3 +22,4 @@ en:
22
22
  format_toggle_yes: "yes"
23
23
  format_too_deep: Man, you're too deep. (Too many levels of nests at a time)
24
24
  format_unsupported_view: view (%{view}) not supported for %{cardname}
25
+ format_mod_description: Format mod
@@ -1,59 +1 @@
1
- <svg style="width:18px; height:14px;" viewBox="0 0 242 220" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
- <!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
3
- <title>b&amp;w_logo</title>
4
- <desc>Created with Sketch.</desc>
5
- <defs>
6
- <rect id="path-1" x="35.3297422" y="10.484836" width="157.279595" height="190.607432" rx="12.491335"></rect>
7
- <filter x="-12.1%" y="-10.5%" width="125.4%" height="121.0%" filterUnits="objectBoundingBox" id="filter-2">
8
- <feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
9
- <feOffset dx="1" dy="0" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
10
- <feGaussianBlur stdDeviation="5.5" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
11
- <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix>
12
- </filter>
13
- <rect id="path-3" x="51.9878879" y="19.404077" width="123.9533" height="171.161486" rx="9.6888466"></rect>
14
- <filter x="-15.3%" y="-11.7%" width="132.3%" height="123.4%" filterUnits="objectBoundingBox" id="filter-4">
15
- <feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
16
- <feOffset dx="1" dy="0" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
17
- <feGaussianBlur stdDeviation="5.5" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
18
- <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix>
19
- </filter>
20
- <path d="M70.1050368,35.6666109 L159.089911,35.6666109 L159.089911,35.6666109 C163.678051,35.6666109 167.397473,39.386033 167.397473,43.9741728 L167.397473,87.717145 L167.397473,166.808436 L167.397473,166.808436 C167.397473,171.396576 163.678051,175.115998 159.089911,175.115998 L70.1050368,175.115998 L70.1050368,175.115998 C65.516897,175.115998 61.7974749,171.396576 61.7974749,166.808436 L61.7974749,43.9741728 L61.7974749,43.9741728 C61.7974749,39.386033 65.516897,35.6666109 70.1050368,35.6666109 Z" id="path-5"></path>
21
- <filter x="-18.0%" y="-14.3%" width="137.9%" height="128.7%" filterUnits="objectBoundingBox" id="filter-6">
22
- <feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
23
- <feOffset dx="1" dy="0" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
24
- <feGaussianBlur stdDeviation="5.5" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
25
- <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix>
26
- </filter>
27
- <rect id="path-7" x="70.7637805" y="49.8525134" width="92.149175" height="107.18743" rx="7.8659801"></rect>
28
- <filter x="-20.6%" y="-18.7%" width="143.4%" height="137.3%" filterUnits="objectBoundingBox" id="filter-8">
29
- <feMorphology radius="1" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"></feMorphology>
30
- <feOffset dx="1" dy="0" in="shadowSpreadOuter1" result="shadowOffsetOuter1"></feOffset>
31
- <feGaussianBlur stdDeviation="5.5" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
32
- <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.102553216 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix>
33
- </filter>
34
- </defs>
35
- <g id="Page-3" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
36
- <g id="b&amp;w_logo" fill-rule="nonzero">
37
- <g id="Decko-Logo-" transform="translate(7.000000, 4.000000)">
38
- <g id="g5642">
39
- <g id="svg-card-1" transform="translate(113.969540, 105.788552) scale(-1, 1) rotate(105.855860) translate(-113.969540, -105.788552) ">
40
- <use fill="black" fill-opacity="1" filter="url(#filter-2)" xlink:href="#path-1"></use>
41
- <use fill="#4D4D4D" fill-rule="evenodd" xlink:href="#path-1"></use>
42
- </g>
43
- <g id="svg-card-2" opacity="0.879999995" transform="translate(113.964538, 104.984820) scale(-1, 1) rotate(117.480003) translate(-113.964538, -104.984820) ">
44
- <use fill="black" fill-opacity="1" filter="url(#filter-4)" xlink:href="#path-3"></use>
45
- <use fill="#FFFFFF" fill-rule="evenodd" xlink:href="#path-3"></use>
46
- </g>
47
- <g id="svg-card-3" transform="translate(114.597474, 105.391304) scale(-1, 1) rotate(133.539993) translate(-114.597474, -105.391304) ">
48
- <use fill="black" fill-opacity="1" filter="url(#filter-6)" xlink:href="#path-5"></use>
49
- <use fill="#4C4C4C" fill-rule="evenodd" xlink:href="#path-5"></use>
50
- </g>
51
- <g id="svg-card-4" opacity="0.879999995" transform="translate(116.838368, 103.446228) scale(-1, 1) rotate(142.690002) translate(-116.838368, -103.446228) ">
52
- <use fill="black" fill-opacity="1" filter="url(#filter-8)" xlink:href="#path-7"></use>
53
- <use fill="#FFFFFF" fill-rule="evenodd" xlink:href="#path-7"></use>
54
- </g>
55
- </g>
56
- </g>
57
- </g>
58
- </g>
59
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="width:18px;height:14px" version="1.1" viewBox="0 0 242 220"><title>b&amp;w_logo</title><desc>Created with Sketch.</desc><defs><rect id="path-1" width="157.28" height="190.607" x="35.33" y="10.485" rx="12.491"/><filter id="filter-2" width="125.4%" height="121%" x="-12.1%" y="-10.5%" filterUnits="objectBoundingBox"><feMorphology in="SourceAlpha" operator="dilate" radius="1" result="shadowSpreadOuter1"/><feOffset dx="1" dy="0" in="shadowSpreadOuter1" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="5.5"/><feColorMatrix in="shadowBlurOuter1" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"/></filter><rect id="path-3" width="123.953" height="171.161" x="51.988" y="19.404" rx="9.689"/><filter id="filter-4" width="132.3%" height="123.4%" x="-15.3%" y="-11.7%" filterUnits="objectBoundingBox"><feMorphology in="SourceAlpha" operator="dilate" radius="1" result="shadowSpreadOuter1"/><feOffset dx="1" dy="0" in="shadowSpreadOuter1" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="5.5"/><feColorMatrix in="shadowBlurOuter1" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"/></filter><path id="path-5" d="M70.1050368,35.6666109 L159.089911,35.6666109 L159.089911,35.6666109 C163.678051,35.6666109 167.397473,39.386033 167.397473,43.9741728 L167.397473,87.717145 L167.397473,166.808436 L167.397473,166.808436 C167.397473,171.396576 163.678051,175.115998 159.089911,175.115998 L70.1050368,175.115998 L70.1050368,175.115998 C65.516897,175.115998 61.7974749,171.396576 61.7974749,166.808436 L61.7974749,43.9741728 L61.7974749,43.9741728 C61.7974749,39.386033 65.516897,35.6666109 70.1050368,35.6666109 Z"/><filter id="filter-6" width="137.9%" height="128.7%" x="-18%" y="-14.3%" filterUnits="objectBoundingBox"><feMorphology in="SourceAlpha" operator="dilate" radius="1" result="shadowSpreadOuter1"/><feOffset dx="1" dy="0" in="shadowSpreadOuter1" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="5.5"/><feColorMatrix in="shadowBlurOuter1" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"/></filter><rect id="path-7" width="92.149" height="107.187" x="70.764" y="49.853" rx="7.866"/><filter id="filter-8" width="143.4%" height="137.3%" x="-20.6%" y="-18.7%" filterUnits="objectBoundingBox"><feMorphology in="SourceAlpha" operator="dilate" radius="1" result="shadowSpreadOuter1"/><feOffset dx="1" dy="0" in="shadowSpreadOuter1" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="5.5"/><feColorMatrix in="shadowBlurOuter1" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.102553216 0"/></filter></defs><g id="Page-3" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="b&amp;w_logo" fill-rule="nonzero"><g id="Decko-Logo-" transform="translate(7.000000, 4.000000)"><g id="g5642"><g id="svg-card-1" transform="translate(113.969540, 105.788552) scale(-1, 1) rotate(105.855860) translate(-113.969540, -105.788552)"><use fill="#000" fill-opacity="1" filter="url(#filter-2)" xlink:href="#path-1"/><use fill="#4D4D4D" fill-rule="evenodd" xlink:href="#path-1"/></g><g id="svg-card-2" opacity=".88" transform="translate(113.964538, 104.984820) scale(-1, 1) rotate(117.480003) translate(-113.964538, -104.984820)"><use fill="#000" fill-opacity="1" filter="url(#filter-4)" xlink:href="#path-3"/><use fill="#FFF" fill-rule="evenodd" xlink:href="#path-3"/></g><g id="svg-card-3" transform="translate(114.597474, 105.391304) scale(-1, 1) rotate(133.539993) translate(-114.597474, -105.391304)"><use fill="#000" fill-opacity="1" filter="url(#filter-6)" xlink:href="#path-5"/><use fill="#4C4C4C" fill-rule="evenodd" xlink:href="#path-5"/></g><g id="svg-card-4" opacity=".88" transform="translate(116.838368, 103.446228) scale(-1, 1) rotate(142.690002) translate(-116.838368, -103.446228)"><use fill="#000" fill-opacity="1" filter="url(#filter-8)" xlink:href="#path-7"/><use fill="#FFF" fill-rule="evenodd" xlink:href="#path-7"/></g></g></g></g></g></svg>
@@ -57,9 +57,9 @@ i.call(this)}),!1!==this._start(e)&&this._repeat(null,t(e.currentTarget).hasClas
57
57
  // decko_jquery.js.coffee
58
58
  (function(){jQuery.fn.extend({findCard:function(n){return this.find("[data-card-id='"+n+"']")},isMain:function(){return this.slot().parent("#main")[0]},cardMark:function(){return this.data("cardId")?"~"+this.data("cardId"):this.data("cardName")},isMainOrMainModal:function(){var n;return(n=$(this)).closest(".modal")[0]&&(n=n.slotOrigin("modal")),n&&n.isMain()},notify:function(n,i){var a,t,d;return(t=(d=this.slot(i)).find(".card-notice"))[0]||(t=$('<div class="card-notice"></div>'),(a=d.find(".card-form"))[0]?$(a[0]).append(t):d.append(t)),t.html(n),t.show("blind")}})}).call(this);
59
59
  // slot.js.coffee
60
- (function(){var t,o,s;decko.slot={path:function(t,s){var e;return e=o(s),decko.path(t)+(t.match(/\?/)?"&":"?")+$.param(e)},ready:function(t){return $("document").ready(function(){return $("body").on("decko.slot.ready",".card-slot",function(o,s){return o.stopPropagation(),null!=s?t.call(this,$(this),$(s)):t.call(this,$(this))})})},destroy:function(t){return $("document").ready(function(){return $("body").on("decko.slot.destroy",".card-slot, ._modal-slot",function(o){return o.stopPropagation(),t.call(this,$(this))})})}},jQuery.fn.extend({isSlot:function(){return $(this).hasClass("card-slot")},triggerSlotReady:function(t){return this.isSlot()&&this.trigger("decko.slot.ready",t),this.find(".card-slot").trigger("decko.slot.ready",t)},slot:function(t,o){return null==t&&(t="success"),null==o&&(o="replace"),"modal"===o?this.modalSlot():this._slotSelect("slot-"+t+"-selector")||this._slotSelect("slot-selector")||this.closest(".card-slot")},slotUrl:function(){var t;return t=$(this),decko.slot.path(t.cardMark()+"/"+t.data("slot").view)},slotFind:function(t){switch(t){case"modal-origin":return this.slotOrigin("modal");case"overlay-origin":return this.slotOrigin("overlay");default:return s(this.closest(t),this.closest(".card-slot"),t)}},slotClear:function(){return this.trigger("decko.slot.destroy"),this.empty()},slotOrigin:function(t){var o,s;return s=this.closest("[data-"+t+"-origin-slot-id]").data(t+"-origin-slot-id"),null!=(o=$("[data-slot-id="+s+"]"))[0]?o:decko.warn("couldn't find origin with slot id "+s)},slotReload:function(t){return this.each(function(){return $(this)._slotReloadSingle(t)})},slotUpdate:function(t,o){return o||(o="replace"),this.slotContent(t,o,$(this))},slotContent:function(t,o,s){var e;return"string"==typeof(e=$(t)[0]&&$(t)||t)?this.slot("success",o)._slotFillOrReplace(e,s):(e.hasClass("_overlay")?o="overlay":e.hasClass("_modal")&&(o="modal"),this.slot("success",o)._slotContentFromElement(e,o,s)),e},_slotContentFromElement:function(t,o,s){var e;return"overlay"===o?this.addOverlay(t,s):t.hasClass("_modal-slot")||"modal"===o?t.showAsModal(s):((e=this.data("slot-id"))&&t.attr("data-slot-id",e),this.trigger("decko.slot.destroy"),this._slotFillOrReplace(t,s),decko.contentLoaded(t,s))},_slotFillOrReplace:function(t,o){return this.hasClass("_fixed-slot")?this.html(t):this.replaceWith(t),decko.contentLoaded(this,o)},_slotSelect:function(t){var o,s;if(o=this.data(t))return(s=this.slotFind(o))&&s[0]&&s},_slotReloadSingle:function(t){var o;return o=$(this),null==t&&(t=o.slotUrl()),o.addClass("slotter"),o.data("url",t),o.data("remote",!0),o.attr("href",t),this[0].href=t,$.rails.handleRemote(o)}}),o=function(o){var s,e,l;return e={},null!=(s=$("#main").children(".card-slot").data("cardName"))&&(e.main=s),o&&(o.isMain()&&(e.is_main=!0),null!=(l=o.data("slot"))&&(t(l,e,"slot"),l.type&&(e.type=l.type))),e},t=function(o,s,e){return $.each(o,function(o,l){var r;return r=e+"["+decko.snakeCase(o)+"]","items"===o?t(l,s,r):s[r]=l})},s=function(t,o,s){for(;0===t.length&&o.length>0;)t=$(o).find(s),o=$(o).parent().closest(".card-slot");return 0===t.length?$(s):t}}).call(this);
60
+ (function(){var t,o,s;decko.slot={path:function(t,s,l){var e;return e=o(s),null!=l&&(e.slotter_mode=l),decko.path(t)+(t.match(/\?/)?"&":"?")+$.param(e)},ready:function(t){return $("document").ready(function(){return $("body").on("decko.slot.ready",".card-slot",function(o,s){return o.stopPropagation(),null!=s?t.call(this,$(this),$(s)):t.call(this,$(this))})})},destroy:function(t){return $("document").ready(function(){return $("body").on("decko.slot.destroy",".card-slot, ._modal-slot",function(o){return o.stopPropagation(),t.call(this,$(this))})})}},jQuery.fn.extend({isSlot:function(){return $(this).hasClass("card-slot")},triggerSlotReady:function(t){return this.isSlot()&&this.trigger("decko.slot.ready",t),this.find(".card-slot").trigger("decko.slot.ready",t)},slot:function(t,o){return null==t&&(t="success"),null==o&&(o="replace"),"modal"===o?this.modalSlot():this._slotSelect("slot-"+t+"-selector")||this._slotSelect("slot-selector")||this.closest(".card-slot")},slotUrl:function(){var t;return t=$(this),decko.slot.path(t.cardMark()+"/"+t.data("slot").view)},slotFind:function(t){switch(t){case"modal-origin":return this.slotOrigin("modal");case"overlay-origin":return this.slotOrigin("overlay");default:return s(this.closest(t),this.closest(".card-slot"),t)}},slotClear:function(){return this.trigger("decko.slot.destroy"),this.empty()},slotOrigin:function(t){var o,s;return s=this.closest("[data-"+t+"-origin-slot-id]").data(t+"-origin-slot-id"),(o=$("[data-slot-id="+s+"]")).length>0?o:decko.warn("couldn't find origin with slot id "+s)},slotReload:function(t){return this.each(function(){return $(this)._slotReloadSingle(t)})},slotReloading:function(){},slotLoadingComplete:function(){},slotUpdate:function(t,o){return o||(o="replace"),this.slotContent(t,o,$(this))},slotContent:function(t,o,s){var l;return"string"==typeof(l=$(t).length>0&&$(t)||t)?this.slot("success",o)._slotFillOrReplace(l,s):(l.hasClass("_overlay")?o="overlay":l.hasClass("_modal")&&(o="modal"),this.slot("success",o)._slotContentFromElement(l,o,s)),l},_slotContentFromElement:function(t,o,s){var l;return"overlay"===o?this.addOverlay(t,s):t.hasClass("_modal-slot")||"modal"===o?t.showAsModal(s):((l=this.data("slot-id"))&&t.attr("data-slot-id",l),this.trigger("decko.slot.destroy"),this._slotFillOrReplace(t,s),decko.contentLoaded(t,s))},_slotFillOrReplace:function(t,o){return this.hasClass("_fixed-slot")?this.html(t):this.replaceWith(t),decko.contentLoaded(this,o)},_slotSelect:function(t){var o,s;if(o=this.data(t))return(s=this.slotFind(o))&&s[0]&&s},_slotReloadSingle:function(t){var o;return o=$(this),null==t&&(t=o.slotUrl()),o.addClass("slotter"),o.data("url",t),o.data("remote",!0),o.attr("href",t),this[0].href=t,$.rails.handleRemote(o),o.slotReloading()}}),o=function(o){var s,l,e;return l={},null!=(s=$("#main").children(".card-slot").data("cardName"))&&(l.main=s),o&&(o.isMain()&&(l.is_main=!0),null!=(e=o.data("slot"))&&(t(e,l,"slot"),e.type&&(l.type=e.type))),l},t=function(o,s,l){return $.each(o,function(o,e){var n;return n=l+"["+decko.snakeCase(o)+"]","items"===o?t(e,s,n):s[n]=e})},s=function(t,o,s){for(;0===t.length&&o.length>0;)t=$(o).find(s),o=$(o).parent().closest(".card-slot");return 0===t.length?$(s):t}}).call(this);
61
61
  // slotter.js.coffee
62
- (function(){$(window).ready(function(){return $("body").on("ajax:success",".slotter",function(t,s){return $(this).slotterSuccess(t,s)}),$("body").on("ajax:error",".slotter",function(t,s){return $(this).showErrorResponse(s.status,s.responseText)}),$("body").on("click","button.slotter",function(){return!!$.rails.allowAction($(this))&&$.rails.handleRemote($(this))}),$("body").on("click",'[data-bs-dismiss="overlay"]',function(){return $(this).slotFind(".card-slot._overlay").removeOverlay()}),$("body").on("click","._close-overlay-on-success",function(){return $(this).closeOnSuccess("overlay")}),$("body").on("click","._close-modal-on-success",function(){return $(this).closeOnSuccess("modal")}),$("body").on("click","._close-on-success",function(){return $(this).closeOnSuccess()}),$("body").on("click","._update-origin",function(){return $(this).closest(".slotter").data("slotter-mode","update-origin")}),$("body").on("submit","form.slotter",function(){var t;if((t=$(this)).data("main-success")&&t.isMainOrMainModal())return t.mainSuccess()}),$("body").on("ajax:beforeSend",".slotter",function(t,s,o){return $(this).slotterBeforeSend(o)})}),jQuery.fn.extend({mainSuccess:function(){var t;return t=$(this),$.each(t.data("main-success"),function(s,o){var e,i;return i="[name=success\\["+s+"\\]]",(e=t.find(i))[0]||(e=$('<input type="hidden" name="success['+s+']"/>'),t.append(e)),e.val(o)})},slotterSuccess:function(t,s){var o,e,i;if(this.hasClass("slotter")){if(!t.slotSuccessful)return this.showSuccessResponse(s,this.data("slotter-mode")),this.hasClass("_close-overlay")&&this.removeOverlay(),this.hasClass("_close-modal")&&this.closest(".modal").modal("hide"),this.hasClass("card-paging-link")&&(i=this.slot().offset().top,$("body").scrollTop(i)),this.data("update-foreign-slot")&&(o=this.slotFind(this.data("update-foreign-slot")),e=this.data("update-foreign-slot-url"),o.slotReload(e)),this.data("original-slotter-mode")&&this.attr("data-slotter-mode",this.data("original-slotter-mode")),this.data("original-slot-selector")&&this.attr("data-slot-selector",this.data("original-slot-selector")),t.slotSuccessful=!0}else console.log("warning: slotterSuccess called on non-slotter element "+this)},showSuccessResponse:function(t,s){if(t.redirect)return window.location=t.redirect;if(t.reload)return window.location.reload(!0);switch(s){case"silent-success":break;case"update-modal-origin":return this.updateModalOrigin();case"update-origin":return this.updateOrigin();default:return this.slotUpdate(t,s)}},showErrorResponse:function(t,s){return 403===t?$(s).showAsModal($(this)):900===t?$(s).showAsModal($(this)):(this.notify(s,"error"),409===t?this.slot().find(".current_revision_id").val(this.slot().find(".new-current-revision-id").text()):void 0)},updateModalOrigin:function(){return this.overlaySlot()?this.slotOrigin("overlay").updateOrigin():this.closest("#modal-container")[0]?this.updateOrigin():void 0},updateOrigin:function(){var t,s;if(null!=(s=this.overlaySlot()?"overlay":this.closest("#modal-container")[0]?"modal":void 0))return(t=this.slotOrigin(s))&&null!=t[0]?t.slotReload():void 0},registerAsOrigin:function(t,s){return s.hasClass("_modal-slot")&&(s=s.find(".modal-body")),s.attr("data-"+t+"-origin-slot-id",this.slot().data("slot-id"))},closeOnSuccess:function(t){var s;return s=this.closest(".slotter"),null==t&&(t=this.isInOverlay()?"overlay":"modal"),s.addClass("_close-"+t)},slotterBeforeSend:function(t){if(!t.noSlotParams&&!t.url.match(/home_view/)&&"modal"!==this.data("slotter-mode")&&"override"!==this.data("slotter-mode"))return t.url=decko.slot.path(t.url,this.slot())}})}).call(this);
62
+ (function(){$(window).ready(function(){return $("body").on("ajax:send",".slotter",function(){return $(this).slot().slotReloading()}),$("body").on("ajax:success",".slotter",function(t,o){return $(this).slotterSuccess(t,o)}),$("body").on("ajax:error",".slotter",function(t,o){return $(this).showErrorResponse(o.status,o.responseText)}),$("body").on("ajax:complete",".slotter",function(){return $(this).slot().slotLoadingComplete()}),$("body").on("click","button.slotter",function(){return!!$.rails.allowAction($(this))&&$.rails.handleRemote($(this))}),$("body").on("click",'[data-bs-dismiss="overlay"]',function(){return $(this).slotFind(".card-slot._overlay").removeOverlay()}),$("body").on("click","._close-overlay-on-success",function(){return $(this).closeOnSuccess("overlay")}),$("body").on("click","._close-modal-on-success",function(){return $(this).closeOnSuccess("modal")}),$("body").on("click","._close-on-success",function(){return $(this).closeOnSuccess()}),$("body").on("click","._update-origin",function(){return $(this).closest(".slotter").data("slotter-mode","update-origin")}),$("body").on("submit","form.slotter",function(){var t;if((t=$(this)).data("main-success")&&t.isMainOrMainModal())return t.mainSuccess()}),$("body").on("ajax:beforeSend",".slotter",function(t,o,s){return $(this).slotterBeforeSend(s)}),$("body").on("ajax:beforeSend",".card-slot",function(t){return t.stopPropagation()}),$("body").on("ajax:send",".card-slot",function(t){return t.stopPropagation()})}),jQuery.fn.extend({mainSuccess:function(){var t;return t=$(this),$.each(t.data("main-success"),function(o,s){var e,i;return i="[name=success\\["+o+"\\]]",(e=t.find(i))[0]||(e=$('<input type="hidden" name="success['+o+']"/>'),t.append(e)),e.val(s)})},slotterSuccess:function(t,o){var s,e,i;if(this.hasClass("slotter")){if(!t.slotSuccessful)return this.showSuccessResponse(o,this.data("slotter-mode")),this.hasClass("_close-overlay")&&this.removeOverlay(),this.hasClass("_close-modal")&&this.closest(".modal").modal("hide"),this.hasClass("card-paging-link")&&(i=this.slot().offset().top,$("body").scrollTop(i)),this.data("update-foreign-slot")&&(s=this.slotFind(this.data("update-foreign-slot")),e=this.data("update-foreign-slot-url"),s.slotReload(e)),this.data("original-slotter-mode")&&this.attr("data-slotter-mode",this.data("original-slotter-mode")),this.data("original-slot-selector")&&this.attr("data-slot-selector",this.data("original-slot-selector")),t.slotSuccessful=!0}else console.log("warning: slotterSuccess called on non-slotter element "+this)},showSuccessResponse:function(t,o){if(t.redirect)return window.location=t.redirect;if(t.reload)return window.location.reload(!0);switch(o){case"silent-success":break;case"update-modal-origin":return this.updateModalOrigin();case"update-origin":return this.updateOrigin();default:return this.slotUpdate(t,o)}},showErrorResponse:function(t,o){return 403===t?$(o).showAsModal($(this)):900===t?$(o).showAsModal($(this)):(this.notify(o,"error"),409===t?this.slot().find(".current_revision_id").val(this.slot().find(".new-current-revision-id").text()):void 0)},updateModalOrigin:function(){return this.overlaySlot()?this.slotOrigin("overlay").updateOrigin():this.closest("#modal-container")[0]?this.updateOrigin():void 0},updateOrigin:function(){var t,o;if(null!=(o=this.overlaySlot()?"overlay":this.closest("#modal-container")[0]?"modal":void 0))return(t=this.slotOrigin(o))&&null!=t[0]?t.slotReload():void 0},registerAsOrigin:function(t,o){return o.hasClass("_modal-slot")&&(o=o.find(".modal-body")),o.attr("data-"+t+"-origin-slot-id",this.slot().data("slot-id"))},closeOnSuccess:function(t){var o;return o=this.closest(".slotter"),null==t&&(t=this.isInOverlay()?"overlay":"modal"),o.addClass("_close-"+t)},slotterBeforeSend:function(t){var o;if(o=this.slotterMode(),!t.noSlotParams&&!t.url.match(/home_view/)&&"modal"!==o&&"override"!==o)return t.url=decko.slot.path(t.url,this.slot(),o)},slotterMode:function(){var t;if(null!=(t=this.data("slotter-mode"))&&(!t.match(/origin/)||this.slotOrigin()))return t}})}).call(this);
63
63
  // slot_ready.js.coffee
64
64
  (function(){decko.slot.ready(function(a){return a.find("card-view-placeholder").each(function(){var a;if(!(a=$(this)).data("loading"))return a.data("loading",!0),$.get(a.data("url"),function(e){return a.replaceWith(e)})}),a.find("._disappear").delay(5e3).animate({height:0},1e3,function(){return $(this).hide()})})}).call(this);
65
65
  // clicks_and_hovers.js.coffee
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Card
4
4
  class Format
5
- class CsvFormat < TextFormat
5
+ class CsvFormat < Format
6
6
  register :csv
7
7
 
8
8
  def mime_type
data/set/all/base.rb CHANGED
@@ -26,6 +26,7 @@ format do
26
26
  view(:key, compact: true, perms: :none) { card.key }
27
27
  view(:linkname, compact: true, perms: :none) { card.name.url_key }
28
28
  view(:url, compact: true, perms: :none) { card_url _render_linkname }
29
+ view(:id_url, compact: true) { card_url "~#{card.id}" }
29
30
 
30
31
  view :url_link, compact: true, perms: :none do
31
32
  link_to_resource card_url(_render_linkname)
data/set/all/csv.rb CHANGED
@@ -20,10 +20,10 @@ format :csv do
20
20
 
21
21
  view :titled do
22
22
  voo.items[:view] ||= :row
23
- (render_header + render_core).map { |row| CSV.generate_line row }.join
23
+ (render_header + render_body).map { |row| CSV.generate_line row }.join
24
24
  end
25
25
 
26
- view :core do
26
+ view :body do
27
27
  item_cards.map { |item_card| nest item_card }
28
28
  end
29
29
 
data/set/all/demo.rb CHANGED
@@ -28,11 +28,15 @@ format :html do
28
28
  def view_select
29
29
  card_form :get, success: { view: :demo } do
30
30
  select_tag :demo_view,
31
- options_for_select(all_views, demo_view),
31
+ options_for_select(all_views_from_admin_config, demo_view),
32
32
  class: "_submit-on-select"
33
33
  end
34
34
  end
35
35
 
36
+ def all_views_from_admin_config
37
+ card.all_admin_configs_of_category("views").map(&:codename)
38
+ end
39
+
36
40
  def all_views
37
41
  Card::Set::Format::AbstractFormat::ViewDefinition
38
42
  .views.slice(*self.class.ancestors).values.map(&:keys).flatten.uniq.sort
@@ -147,14 +147,14 @@ format :html do
147
147
 
148
148
  def signin_link
149
149
  link_to_card :signin, t(:account_sign_in)&.downcase,
150
- class: "signin-link", slotter: true, path: { view: :open }
150
+ class: "signin-link", path: { view: :titled }
151
151
  end
152
152
 
153
153
  def signup_link
154
154
  return unless signup_ok?
155
155
 
156
156
  link_to_card :signup, t(:account_sign_up)&.downcase,
157
- class: "signup-link", slotter: true, path: { action: :new }
157
+ class: "signup-link", path: { action: :new }
158
158
  end
159
159
 
160
160
  def signup_ok?
@@ -36,14 +36,16 @@ format :html do
36
36
  end
37
37
  end
38
38
 
39
+ def panel &block
40
+ wrap_with :div, class: classy("d0-card-frame"), &block
41
+ end
42
+
43
+ private
44
+
39
45
  def frame_and_form action, form_opts={}, &block
40
46
  form_opts ||= {}
41
47
  frame do
42
48
  card_form action, form_opts, &block
43
49
  end
44
50
  end
45
-
46
- def panel &block
47
- wrap_with :div, class: classy("d0-card-frame"), &block
48
- end
49
51
  end
data/set/all/html/menu.rb CHANGED
@@ -1,16 +1,41 @@
1
1
  format :html do
2
+ view :menu_block do
3
+ wrap_with :div, class: "menu-block position-relative py-2" do
4
+ [render_menu, "&nbsp;"]
5
+ end
6
+ end
7
+
2
8
  view :menu, denial: :blank, unknown: true do
3
9
  return "" unless card.known?
4
10
  # would be preferable to do this with unknown: :blank, but that fails with view
5
11
  # caching on, because voo always thinks it's the root.
6
- wrap_with :div, class: "card-menu #{menu_link_classes}" do
7
- [render_help_link,
8
- menu_link,
9
- (voo.show?(:board_link) ? board_link(in_modal: false) : nil)]
10
- end
12
+ wrap_with(:div, class: "card-menu #{menu_link_classes}") { menu_items }
13
+ end
14
+
15
+ view :edit_link, unknown: true, denial: :blank do
16
+ edit_link edit_link_view
17
+ end
18
+
19
+ view :edit_button do
20
+ view = voo.edit == :inline ? :edit_inline : :edit
21
+ link_to_view view, "Edit", class: "btn btn-sm btn-outline-primary me-2"
22
+ end
23
+
24
+ view :full_page_link do
25
+ full_page_link
26
+ end
27
+
28
+ view :board_link, unknown: true do
29
+ board_link
11
30
  end
12
31
 
13
- def menu_link
32
+ # no caching because help_text view doesn't cache, and we can't have a
33
+ # stub in the data-content attribute or it will get html escaped.
34
+ view :help_link, cache: :never, unknown: true do
35
+ help_link render_help_text, help_title
36
+ end
37
+
38
+ def menu_edit_link
14
39
  case voo.edit
15
40
  when :inline
16
41
  edit_inline_link
@@ -21,6 +46,14 @@ format :html do
21
46
  end
22
47
  end
23
48
 
49
+ def menu_board_link
50
+ voo.show?(:board_link) ? board_link(in_modal: false) : nil
51
+ end
52
+
53
+ def menu_items
54
+ [render_help_link, menu_edit_link, menu_board_link]
55
+ end
56
+
24
57
  def edit_view
25
58
  case voo.edit
26
59
  when :inline
@@ -32,40 +65,34 @@ format :html do
32
65
  end
33
66
  end
34
67
 
35
- view :edit_link, unknown: true, denial: :blank do
36
- edit_link edit_link_view
37
- end
38
-
39
- view :edit_button do
40
- view = voo.edit == :inline ? :edit_inline : :edit
41
- link_to_view view, "Edit", class: "btn btn-sm btn-outline-primary me-2"
42
- end
43
-
44
68
  def edit_link_view
45
69
  :edit
46
70
  end
47
71
 
48
- view :full_page_link do
49
- full_page_link
50
- end
51
-
52
- view :board_link, unknown: true do
53
- board_link
54
- end
55
-
72
+ # Generates a link to a board with optional parameters.
73
+ #
74
+ # @param [String] text The text displayed on the link.
75
+ # @param [Boolean] in_modal (true) Indicates whether the board
76
+ # link should open in a modal.
77
+ # @param [Boolean] confirm (false) Indicates whether to show a
78
+ # confirmation for potential data loss.
79
+ #
80
+ # @return [String] The HTML code for the board link.
81
+ #
82
+ # @example
83
+ # board_link(text: "Advanced", in_modal: true, confirm: true)
56
84
  def board_link text: "", in_modal: true, confirm: false
57
- opts = { class: "board-link" }
85
+ opts = {
86
+ class: "board-link",
87
+ title: "Advanced",
88
+ "data-bs-toggle": "tooltip",
89
+ "data-bs-placement": "bottom"
90
+ }
58
91
  opts["data-slotter-mode"] = "modal-replace" if in_modal
59
92
  confirm_edit_loss opts if confirm
60
93
  link_to_view :board, "#{board_icon} #{text}", opts
61
94
  end
62
95
 
63
- # no caching because help_text view doesn't cache, and we can't have a
64
- # stub in the data-content attribute or it will get html escaped.
65
- view :help_link, cache: :never, unknown: true do
66
- help_link render_help_text, help_title
67
- end
68
-
69
96
  def help_link text=nil, title=nil
70
97
  opts = help_popover_opts text, title
71
98
  add_class opts, "_card-menu-popover"
@@ -93,6 +120,12 @@ format :html do
93
120
  class: classy("full-page-link")
94
121
  end
95
122
 
123
+ def new_window_link text: ""
124
+ link_to_card new_window_card, "#{new_window_icon} #{text}",
125
+ class: classy("new-window-link"),
126
+ target: "window_#{rand 999}"
127
+ end
128
+
96
129
  def modal_page_link text: ""
97
130
  modal_link "#{modal_icon} #{text}",
98
131
  path: { mark: card }, size: modal_page_size, class: "_modal-page-link"
@@ -106,6 +139,10 @@ format :html do
106
139
  card
107
140
  end
108
141
 
142
+ def new_window_card
143
+ full_page_card
144
+ end
145
+
109
146
  def edit_in_board_link opts={}
110
147
  edit_link :board, *opts
111
148
  end
@@ -115,9 +152,24 @@ format :html do
115
152
  edit_link_opts(modal: (modal || :lg))
116
153
  end
117
154
 
118
- # @param modal [Symbol] modal size
155
+ # Generates options hash for an edit link with optional parameters.
156
+ #
157
+ # @param [Symbol] modal (nil) The modal class to use for the edit link.
158
+ #
159
+ # @return [Hash] The options hash for the edit link.
160
+ #
161
+ # @example
162
+ # edit_link_opts(modal: "custom-modal")
163
+ # #=> { class: 'edit-link', title: 'Edit', 'data-bs-toggle': 'tooltip',
164
+ # 'data-bs-placement': 'bottom', 'data-slotter-mode': 'modal',
165
+ # 'data-modal-class': 'modal-custom-modal' }
119
166
  def edit_link_opts modal: nil
120
- opts = { class: classy("edit-link") }
167
+ opts = {
168
+ class: classy("edit-link"),
169
+ title: "Edit",
170
+ "data-bs-toggle": "tooltip",
171
+ "data-bs-placement": "bottom"
172
+ }
121
173
  if modal
122
174
  opts[:"data-slotter-mode"] = "modal"
123
175
  opts[:"data-modal-class"] = "modal-#{modal}"
@@ -134,7 +186,11 @@ format :html do
134
186
  end
135
187
 
136
188
  def full_page_icon
137
- icon_tag :open_in_new
189
+ icon_tag :full_page
190
+ end
191
+
192
+ def new_window_icon
193
+ icon_tag :new_window
138
194
  end
139
195
 
140
196
  def modal_icon
@@ -67,7 +67,7 @@ format :html do
67
67
  view :labeled, unknown: :labeled do
68
68
  @content_body = true
69
69
  wrap(true, class: "row") do
70
- labeled(render_title, wrap_body { "#{render_menu}#{render_labeled_content}" })
70
+ [labeled(render_title, wrap_body { render_labeled_content }), render_menu]
71
71
  end
72
72
  end
73
73
 
data/set/all/html/wrap.rb CHANGED
@@ -40,6 +40,7 @@ format :html do
40
40
  "card-id": card.id,
41
41
  "card-name": slot_cardname,
42
42
  "card-type-id": card.type_id,
43
+ "card-type-name": card.type_name,
43
44
  "card-link-name": card.name.url_key,
44
45
  "slot-id": SecureRandom.hex(10)
45
46
  }
data/set/all/links.rb CHANGED
@@ -26,9 +26,10 @@ format do
26
26
  end
27
27
 
28
28
  # link to a card other than the current card.
29
- # @param cardish [Integer, Symbol, String, Card] a card identifier
30
- # @param text [String]
31
- # @param opts [Hash]
29
+ # @param cardish [Integer, Symbol, String, Card]: A card identifier
30
+ # @param text [String], optional: The text content of the link.
31
+ # @param opts [Hash], optional: Additional options for the link.
32
+ # @return [String] HTML markup for the generated link.
32
33
  def link_to_card cardish, text=nil, opts={}
33
34
  add_to_path opts, mark: Card::Name[cardish]
34
35
  link_to text, opts
@@ -79,6 +80,12 @@ format do
79
80
  end
80
81
  end
81
82
 
83
+ # Adds key-value pairs from a new hash to the 'path' key
84
+ # in the given options dictionary.
85
+ # @params opts [dict]: The options dictionary to be modified.
86
+ # @params new_hash [dict]: The new hash containing
87
+ # key-value pairs to be added to the 'path'.
88
+ # @return [Hash] The value of opts[:path]
82
89
  def add_to_path opts, new_hash
83
90
  opts[:path] = (opts[:path] || {}).merge new_hash
84
91
  end
data/set/all/yaml.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  format :yaml do
2
2
  def show view, args={}
3
- view ||= :export
4
3
  render!(view, args).to_yaml
5
4
  end
5
+
6
+ view :core do
7
+ render_pod
8
+ end
6
9
  end
data/set/type/cardtype.rb CHANGED
@@ -85,3 +85,7 @@ format :html do
85
85
  end
86
86
  end
87
87
  end
88
+
89
+ def scoping_rule_card
90
+ Card.fetch([self, :type, :update], new: {})
91
+ end