effective_ckeditor 1.4.0 → 1.4.2

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: 5b2138740d525679b6a11bfc5a2ffd6ed654d2b0
4
- data.tar.gz: 8289180fc47e26d84e6c9efb9b71af3b618a8bd9
3
+ metadata.gz: 634f6c4a4c54685130e76c8a6cf45de59cd7970f
4
+ data.tar.gz: 09a062e6c4cded2883bbcf0b3f7732c829db8b03
5
5
  SHA512:
6
- metadata.gz: 8f797097dee091ca776a2b473108469fa3c351301ea4055aecfd0a6534f1a9eea41c857eb5d6e265593b9555e6ad60dc06d679bec6fe1735fee754f0a908d922
7
- data.tar.gz: 45c206d006ee6bb1ffe066b48499b24a1c3216e99660f05ebd3c3480a5d5df94ce11e0047d67896598fa439d5f6c23adfbc0d325450e0fd12e16a3250569990c
6
+ metadata.gz: 816ddb4a2b57a75aafcc523446c0e44338af7d2850c662a2611f3323626875114937eb6ab666292e0312396f1f7f26932545156d42129e2fe48f0be5e114f2f5
7
+ data.tar.gz: a3a749cddf4e0b48005fc42efcb490a61c04b99befb60c124af063e78732148d51130dda9a7dd66403f0bb043b0096727df1f36f2e90c32dd8f9791b29fb5ee2
@@ -35,6 +35,7 @@
35
35
  @menu.on 'click', 'li.dropdown.open,.dropdown-menu > li.dropdown,li:not(.dropdown)', (event) =>
36
36
  event.stopPropagation()
37
37
  @menu.find('.open').removeClass('open')
38
+ @menu.data('dirty', true)
38
39
  # Open the CKEDITOR dialog and pass the source effective_menu_item $('li') to the dialog
39
40
  CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].openDialog 'effectiveMenusDialog', (dialog) ->
40
41
  dialog.effective_menu_item = $(event.currentTarget)
@@ -51,6 +52,7 @@
51
52
  item = $(@menu.data('effective-menu-new-html').replace(/:new/g, "#{unique_id}"))
52
53
 
53
54
  @menu.children('.actions').before(item)
55
+ @menu.data('dirty', true)
54
56
 
55
57
  CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].openDialog 'effectiveMenusDialog', (dialog) ->
56
58
  dialog.effective_menu_item = item
@@ -165,6 +167,8 @@
165
167
  # so we delete it here
166
168
  @menu.find('meta,li.effective-menu-expand').remove()
167
169
 
170
+ @menu.data('dirty', true)
171
+
168
172
  # Collapse any empty dropdowns we may have expanded back to leafs
169
173
  @menu.find('.dropdown-menu:empty').each (index, item) ->
170
174
  item = $(item).closest('.dropdown')
@@ -192,14 +196,7 @@
192
196
  # The first dropdowns all have Depth of 1
193
197
  depthOf: (item) -> item.parentsUntil(@menu, 'li').length
194
198
 
195
- # Just pass _destroyed = 1 back to rails to delete this item
196
- # Rails seems to disregard new items set to the new Date.now() values anyhow
197
- # Put all deleted items after the .actions div just to be tidy
198
- markDestroyed: (item) ->
199
- item.hide().addClass('destroyed')
200
- item.find('li').addClass('destroyed')
201
- item.find("input[name$='[_destroy]']").val(1)
202
- @menu.children('.actions').after(item.remove())
199
+ markDestroyed: (item) -> item.remove()
203
200
 
204
201
  # This method is called with a Hash value
205
202
  # that is called by reference from the parent function
@@ -209,6 +206,8 @@
209
206
  # This way the saves happen all at once
210
207
 
211
208
  serialize: (retval) ->
209
+ return if @menu.data('dirty') != true
210
+
212
211
  # console.log "============ BEFORE =============="
213
212
  # @menu.find('li').each (index, item) =>
214
213
  # item = $(item)
@@ -246,16 +245,15 @@
246
245
  # This retVal has to account for multiple effective-menus on one page
247
246
  retval[@menu.data('effective-menu-id')] = items
248
247
 
249
- saveComplete: ->
250
- @menu.find('.destroyed').remove()
248
+ saveComplete: (data) -> @menu.data('dirty', false)
251
249
 
252
250
  assignLftRgt: (parent, lft) ->
253
251
  rgt = lft + 1
254
252
 
255
- parent.children('.dropdown-menu').children('li:not(.destroyed)').each (_, child) =>
253
+ parent.children('.dropdown-menu').children('li').each (_, child) =>
256
254
  rgt = @assignLftRgt($(child), rgt)
257
255
 
258
- parent.children('li:not(.destroyed)').each (_, child) =>
256
+ parent.children('li').each (_, child) =>
259
257
  rgt = @assignLftRgt($(child), rgt)
260
258
 
261
259
  parent.children('.menu-item').children("input[name$='[lft]']").val(lft)
@@ -55,10 +55,10 @@ SaveAll = {
55
55
  dataType: 'json'
56
56
  data: { effective_regions: regionData, effective_menus: menuData }
57
57
  async: false
58
- complete: (data) ->
59
- $('.effective-menu').effectiveMenuEditor('saveComplete')
60
- if data.responseText == 'refresh'
61
- location.reload(true)
58
+ complete: (response) ->
59
+ data = response['responseJSON'] || {}
60
+ $('.effective-menu').effectiveMenuEditor('saveComplete', data['effective_menus'])
61
+ location.reload(true) if data['refresh'] == true
62
62
  }
63
63
 
64
64
  Exit = {
@@ -1,3 +1,3 @@
1
1
  module EffectiveCkeditor
2
- VERSION = '1.4.0'.freeze
2
+ VERSION = '1.4.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_ckeditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect