diff options
| author | hukl <contact@smyck.org> | 2009-05-08 09:18:19 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-05-08 09:18:19 +0200 |
| commit | 6856613c1bebf778a843eaeb4527870c5f1f72e6 (patch) | |
| tree | 4680007da92faab9e541eb7ad0c8e0743691a63a /public/javascripts | |
| parent | 7f88d4b70da9b1f1916e3f1e7c0d3913d1e31bc1 (diff) | |
put the whole autosave stuff into admin_interface.js
Diffstat (limited to 'public/javascripts')
| -rw-r--r-- | public/javascripts/admin_interface.js | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index 2b8a0d2..a1d78c7 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -16,4 +16,51 @@ $(document).ready(function () { | |||
| 16 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} | 16 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} |
| 17 | }) | 17 | }) |
| 18 | 18 | ||
| 19 | }); \ No newline at end of file | 19 | }); |
| 20 | |||
| 21 | |||
| 22 | cccms = { | ||
| 23 | setup_autosave : function() { | ||
| 24 | |||
| 25 | var elements = { | ||
| 26 | "title" : $('#page_title'), | ||
| 27 | "abstract" : $('#page_abstract'), | ||
| 28 | "body" : $('#page_body_ifr').contents().find('#tinymce'), | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | var page = { | ||
| 33 | "cached_title_length" : elements.title.val().length, | ||
| 34 | "cached_abstract_length" : elements.abstract.val().length, | ||
| 35 | "cached_body_length" : elements.body.html().length, | ||
| 36 | |||
| 37 | "title_has_changed" : function() { | ||
| 38 | return (elements.title.val().length != this.cached_title_length) | ||
| 39 | }, | ||
| 40 | |||
| 41 | "abstract_has_changed" : function() { | ||
| 42 | return (elements.abstract.val().length != this.cached_abstract_length) | ||
| 43 | }, | ||
| 44 | |||
| 45 | "body_has_changed" : function() { | ||
| 46 | return elements.body.html().length != this.cached_body_length | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | jQuery.fn.submitWithAjax = function(options) { | ||
| 52 | if (page.title_has_changed() || page.abstract_has_changed() || page.body_has_changed()) { | ||
| 53 | |||
| 54 | page.cached_title_length = elements.title.val().length; | ||
| 55 | page.cached_abstract_length = elements.abstract.val().length; | ||
| 56 | page.cached_body_length = elements.body.html().length; | ||
| 57 | |||
| 58 | $("#flash").append("<img src='/images/ajax-loader.gif' alt='' />"); | ||
| 59 | $.post(this.attr("action"), $(this).serialize(), null, "script"); | ||
| 60 | |||
| 61 | } | ||
| 62 | }; | ||
| 63 | |||
| 64 | setInterval('$("#page_editor > form").submitWithAjax()', 15000); | ||
| 65 | } | ||
| 66 | } \ No newline at end of file | ||
