dorsale 2.7.0 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0c8d98fd7be7ef03b8a68351173b79c3de55f1f
4
- data.tar.gz: 78a4adf2df5a2d4fe03617f0e89dee62494018bb
3
+ metadata.gz: ba2dc02af38aca29571385066c9f7cb473ea8d20
4
+ data.tar.gz: 6815f363fbbe634def1f30cbdd6e9d451895d8dd
5
5
  SHA512:
6
- metadata.gz: a21271b62e7c924f3a0b7da3b9bf075c3713907d37efd6564878dc0ecd8dbbf2b4b93409a754b5ba18c21c83b3020b6b3aac55fc423e1b96d7236466ef3f062e
7
- data.tar.gz: 02856acd0a899beacacc78d16ac1c310e15775bcbf6fc5a3206992bd05a3aecd92ca8727d13939e3a4a1e02e4c0571768bfb62a8fedc23bde1f9a59c693ef751
6
+ metadata.gz: 37634eb562b34c2ca462c5bdcc98ac6d3a29e1de6a2f900609ba649afc1c231f66ed99d2536207cbb7791888457ae3705ee0c425de09d980b12e6e949373c26e
7
+ data.tar.gz: f0517e47e65df22bd1b6778d10ad4fadb51e204e0601cabd2a56ad2777b4a1ead80c087ce8c448401a6b06adb5409e114dada79b349041309a69eff40f924af1
@@ -4,10 +4,12 @@ window.modal =
4
4
  error: "Error."
5
5
 
6
6
  template: """
7
- <div id='modal' class='modal'>
8
- <div class='modal-overlay modal-close'></div>
9
- <button class='modal-close'></button>
10
- <div class='modal-body'>
7
+ <div id='modal' class='closable'>
8
+ <div id='modal-overlay'></div>
9
+
10
+ <button id='modal-close'>×</button>
11
+
12
+ <div id='modal-body'>
11
13
  {{content}}
12
14
  </div>
13
15
  </div>
@@ -17,17 +19,48 @@ window.modal =
17
19
  $(modal.template.replace("{{content}}", content))
18
20
 
19
21
  open: (content) ->
20
- modal.close()
22
+ if modal.is_opened()
23
+ modal._update(content)
24
+ else
25
+ modal._create(content)
26
+ $(document).trigger("modal:open")
27
+
28
+ _create: (content) ->
21
29
  $("body").addClass("modal-open")
22
30
  $("body").append(modal._generateModalHTML(content))
23
- $(document).trigger("modal:open")
31
+
32
+ _update: (content) ->
33
+ $("#modal-body").html(content)
24
34
 
25
35
  close: ->
26
- $("#modal").remove()
27
36
  $("body").removeClass("modal-open")
37
+ $("#modal").remove()
28
38
  $(document).trigger("modal:close")
29
39
  return false
30
40
 
41
+ is_opened: ->
42
+ return $("#modal").length > 0
43
+
44
+ is_closed: ->
45
+ return $("#modal").length == 0
46
+
47
+ is_closable: ->
48
+ return $("#modal").hasClass("closable")
49
+
50
+ autoclose: ->
51
+ modal.close() if modal.is_closable()
52
+ return false
53
+
54
+ set_closable: ->
55
+ $("#modal").addClass("closable")
56
+
57
+ set_unclosable: ->
58
+ $("#modal").removeClass("closable")
59
+
60
+ _set_closable_for_element: (element) ->
61
+ return modal.set_closable() if $(element).is("[data-modal-closable=1]")
62
+ return modal.set_unclosable() if $(element).is("[data-modal-closable=0]")
63
+
31
64
  openUrl: (url, type = "GET", data = {}) ->
32
65
  modal.open(modal.i18n.loading)
33
66
 
@@ -40,33 +73,42 @@ window.modal =
40
73
  modal.open(data)
41
74
  error: ->
42
75
  modal.open(modal.i18n.error)
76
+ modal.set_closable()
43
77
 
44
78
  _callbacks:
45
79
  links: ->
46
80
  modal.openUrl(this.href)
81
+ modal._set_closable_for_element(this)
47
82
  return false
48
83
 
49
84
  forms: ->
50
- modal.openUrl(this.href, this.action, $(this).serialize())
85
+ modal.openUrl(this.action, this.method, $(this).serialize())
86
+ modal._set_closable_for_element(this)
51
87
  return false
52
88
 
53
89
  escape: (event) ->
54
- modal.close() if event.keyCode == 27
90
+ modal.autoclose() if event.keyCode == 27
91
+ return true
55
92
 
56
93
  setup: ->
57
94
  $(document)
58
95
  .off("keyup", modal._callbacks.escape)
59
96
  .on("keyup", modal._callbacks.escape)
60
97
 
61
- $(".modal-close")
62
- .off("click", modal.close)
63
- .on("click", modal.close)
98
+ $("#modal-overlay, #modal-close")
99
+ .off("click", modal.autoclose)
100
+ .on("click", modal.autoclose)
64
101
 
65
- $("a[data-modal=1], .modal-body a:not([data-modal=0])")
102
+ $("a[data-modal=1], #modal-body a")
103
+ .not("[data-modal=0]")
104
+ .not("[data-method]")
105
+ .not("[data-remote]")
66
106
  .off("click", modal._callbacks.links)
67
107
  .on("click", modal._callbacks.links)
68
108
 
69
- $("form[data-modal=1], .modal-body form:not([data-modal=0])")
109
+ $("form[data-modal=1], #modal-body form")
110
+ .not("[data-modal=0]")
111
+ .not("[data-remote]")
70
112
  .off("submit", modal._callbacks.forms)
71
113
  .on("submit", modal._callbacks.forms)
72
114
 
@@ -2,37 +2,39 @@ body.modal-open
2
2
  height: 100%
3
3
  overflow: hidden
4
4
 
5
- .modal
5
+ #modal
6
6
  display: block !important // override bootstrap
7
7
 
8
- &, .modal-overlay
9
- position: fixed
10
- top: 0
11
- right: 0
12
- bottom: 0
13
- left: 0
14
- overflow: auto
8
+ #modal, #modal-overlay
9
+ position: fixed
10
+ top: 0
11
+ right: 0
12
+ bottom: 0
13
+ left: 0
14
+ overflow: auto
15
15
 
16
- .modal-overlay
17
- background: rgba(0, 0, 0, 0.85)
16
+ #modal-overlay
17
+ background: rgba(0, 0, 0, 0.85)
18
18
 
19
- .modal-body
20
- position: relative
21
- margin: 10vh auto
22
- padding: 2em
23
- width: auto
24
- min-width: 50%
25
- max-width: 980px
26
- background: white
27
- z-index: 9999
19
+ #modal-body
20
+ position: relative
21
+ margin: 10vh auto
22
+ padding: 2em
23
+ width: auto
24
+ min-width: 50%
25
+ max-width: 980px
26
+ background: white
27
+ z-index: 9999
28
28
 
29
- button.modal-close:after
30
- content: "×"
31
- color: white
32
- position: absolute
33
- font-size: 4em
34
- line-height: 0.5em
35
- top: 0.25em
36
- right: 0.25em
37
- border: none
38
- background: none
29
+ #modal-close
30
+ color: white
31
+ position: absolute
32
+ font-size: 4em
33
+ line-height: 0.5em
34
+ top: 0.25em
35
+ right: 0.25em
36
+ border: none
37
+ background: none
38
+
39
+ #modal:not(.closable) #modal-close
40
+ display: none
@@ -1,3 +1,3 @@
1
1
  module Dorsale
2
- VERSION = "2.7.0"
2
+ VERSION = "2.7.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorsale
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-09 00:00:00.000000000 Z
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails