smart_listing 0.9.7 → 0.9.8

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: 3e5029b5f33d511b0683ca39c58f1d4956b6fd29
4
- data.tar.gz: d924b0eb292135656a20c0b37e2ef1cf7e48a95f
3
+ metadata.gz: e4fcf22c0d95a61711b265aa25f2a270a3f2b7e1
4
+ data.tar.gz: 723a731a8be9bd2b62db1dbf94fe3d2c9b06aeb2
5
5
  SHA512:
6
- metadata.gz: 55401a3882f4b42e2797ea24c895d00e285c0f76b575b2809825b0f5ff4dd32ccf1953075290d4cdf25ad359e4c5446db5889b4e76797e529d9a58b93f603ac5
7
- data.tar.gz: 6ab9ad98c2f7ec341d2d2d14c1a002f617cbb0317a1cb21b2ad82ac1003a77eec335beca1c68086342fc306aac15e8a4772d63b25b8025e9525423141b3c6516
6
+ metadata.gz: 665a03580d6ee2de1251f25623cac4bcb93ca469ca17a9fd60e81314b73cd7558503813d21a85ae687636ff8af701e009200b095e697e7a2988febad8d555b8d
7
+ data.tar.gz: 28091b9aa284ee8ae36e3e2b1837547231aeeddc3518dce04f320bc5ac416f86725c30971da4168fff89f44ee6391d5443941f87a270230398753ba3d9e3f9e2
@@ -10,6 +10,7 @@ class SmartListing
10
10
  @content = @container.find(".<%= SmartListing.config.classes(:content) %>")
11
11
  @status = $(".<%= SmartListing.config.classes(:status) %>[data-<%= SmartListing.config.data_attributes(:main) %>='#{@name}']")
12
12
  @confirmed = null
13
+ @popovers = {}
13
14
 
14
15
  @container.on 'ajax:before', (e) =>
15
16
  @fadeLoading()
@@ -47,7 +48,7 @@ class SmartListing
47
48
  # Check if we are confirming the right element
48
49
  if(@confirmed != event.currentTarget)
49
50
  # We need confirmation
50
- $.fn.smart_listing.showPopover $(event.currentTarget), $(event.currentTarget).data('<%= SmartListing.config.data_attributes(:confirmation) %>'), (confirm_elem) =>
51
+ $.fn.smart_listing.showConfirmation $(event.currentTarget), $(event.currentTarget).data('<%= SmartListing.config.data_attributes(:confirmation) %>'), (confirm_elem) =>
51
52
  @confirmed = confirm_elem[0]
52
53
  false
53
54
  else
@@ -55,6 +56,13 @@ class SmartListing
55
56
  @confirmed = null
56
57
  true
57
58
 
59
+ @container.on 'click', '.<%= SmartListing.config.classes(:item_actions) %> a[data-<%= SmartListing.config.data_attributes(:popover) %>]', (event) =>
60
+ name = $(event.currentTarget).data('<%= SmartListing.config.data_attributes(:popover) %>')
61
+ if jQuery.isFunction(@popovers[name])
62
+ @popovers[name]($(event.currentTarget))
63
+ false
64
+
65
+
58
66
  @container.on 'click', 'input[type=text].<%= SmartListing.config.classes(:autoselect) %>', (event) ->
59
67
  $(this).select()
60
68
 
@@ -135,6 +143,9 @@ class SmartListing
135
143
 
136
144
  params: () =>
137
145
  @container.data('<%= SmartListing.config.data_attributes(:params) %>')
146
+
147
+ registerPopover: (name, callback) =>
148
+ @popovers[name] = callback
138
149
 
139
150
  #################################################################################################
140
151
  # Methods executed by rails UJS:
@@ -257,7 +268,12 @@ $.fn.smart_listing.observeField = (field, opts = {}) ->
257
268
  keyChange()
258
269
  , 400)
259
270
 
260
- $.fn.smart_listing.showPopover = (confirmation_elem, msg, confirm) ->
271
+ $.fn.smart_listing.showPopover = (elem, body) ->
272
+ elem.popover('destroy')
273
+ elem.popover(content: body, html: true, trigger: 'manual', title: null)
274
+ elem.popover('show')
275
+
276
+ $.fn.smart_listing.showConfirmation = (confirmation_elem, msg, confirm_callback) ->
261
277
  buildPopover = (confirmation_elem, msg) ->
262
278
  deletion_popover = $('<div/>').addClass('confirmation_box')
263
279
  deletion_popover.append($('<p/>').html(msg))
@@ -265,7 +281,7 @@ $.fn.smart_listing.showPopover = (confirmation_elem, msg, confirm) ->
265
281
  .append($('<button/>').html('Yes').addClass('btn btn-danger ').click (event) =>
266
282
  # set @confirmed element and emulate click on icon
267
283
  editable = $(event.currentTarget).closest('.<%= SmartListing.config.classes(:editable) %>')
268
- confirm(confirmation_elem)
284
+ confirm_callback(confirmation_elem)
269
285
  $(confirmation_elem).click()
270
286
  $(confirmation_elem).popover('destroy')
271
287
  )
@@ -276,9 +292,7 @@ $.fn.smart_listing.showPopover = (confirmation_elem, msg, confirm) ->
276
292
  )
277
293
  )
278
294
 
279
- confirmation_elem.popover('destroy')
280
- confirmation_elem.popover(content: buildPopover(confirmation_elem, msg), html: true, trigger: 'manual', title: null)
281
- confirmation_elem.popover('show')
295
+ $.fn.smart_listing.showPopover confirmation_elem, buildPopover(confirmation_elem, msg)
282
296
 
283
297
  $.fn.smart_listing.onLoading = (content, loader) ->
284
298
  content.stop(true).fadeTo(500, 0.2)
@@ -47,6 +47,7 @@ SmartListing.configure do |config|
47
47
  #:observed => "observed",
48
48
  #:href => "href",
49
49
  #:autoshow => "autoshow",
50
+ #:popover => "slpopover",
50
51
  }
51
52
 
52
53
  config.constants :selectors, {
@@ -57,6 +57,7 @@ module SmartListing
57
57
  :observed => "observed",
58
58
  :href => "href",
59
59
  :autoshow => "autoshow",
60
+ :popover => "slpopover",
60
61
  },
61
62
  :selectors => {
62
63
  :item_action_destroy => "a.destroy",
@@ -1,3 +1,3 @@
1
1
  module SmartListing
2
- VERSION = "0.9.7"
2
+ VERSION = "0.9.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_listing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2014-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails