Sha256: a672eb3bac41d67827e31da9ebcbf4bc425d457b9a3c05834db91604d67e1d19
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
Joint.bind 'Editor.Save', class loaded: => @button = @element().querySelector('button') @time = @element().querySelector('div.update > p') @on 'Editor:loaded', document, @cache @on 'Editor:updated', document, @update @on 'posts:update', document, @saved @on 'click', @button, @save @on 'beforeunload', window, @confirm @button.textContent = @button.getAttribute('persisted') @refresh() @cache() @interval = setInterval(@refresh, 1000) refresh: () => @time.textContent = moment(@time.getAttribute('time')).fromNow() confirm: (e) => if @cache() != PostBody.instance.toString() e.returnValue = "You have unsaved changed." return e.returnValue cache: => cache = PostBody.instance.toString() @cache = (refresh) -> if refresh cache = PostBody.instance.toString() @button.setAttribute('disabled', 'disabled') @button.textContent = @button.getAttribute('persisted') cache @cache() save: (e) => e.preventDefault() e.stopPropagation() xhr = new Joint.XHR(e.target.form) xhr.data.set('post[content]', PostBody.instance.toString()) xhr.data.set('context', 'content') xhr.send() saved: (e) => if e.UpdatedAtTime @time.setAttribute('time', e.UpdatedAtTime) @refresh() @cache(true) update: (e) => return unless @cache()? if @cache() != PostBody.instance.toString() @button.removeAttribute('disabled') @button.textContent = @button.getAttribute('dirty') else @button.setAttribute('disabled', 'disabled') @button.textContent = @button.getAttribute('persisted')
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecrire-0.21.0 | lib/ecrire/app/assets/javascripts/admin/editor/navigation/save.js.coffee |