diff options
| -rw-r--r-- | app/views/layouts/admin.html.erb | 68 | ||||
| -rw-r--r-- | app/views/nodes/_autosave.html.erb | 3 | ||||
| -rw-r--r-- | public/javascripts/admin_interface.js | 7 |
3 files changed, 56 insertions, 22 deletions
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 1fb9c2b..4e0347d 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb | |||
| @@ -12,19 +12,61 @@ | |||
| 12 | <%= javascript_include_tag 'admin_interface.js' %> | 12 | <%= javascript_include_tag 'admin_interface.js' %> |
| 13 | 13 | ||
| 14 | <script type="text/javascript"> | 14 | <script type="text/javascript"> |
| 15 | tinyMCE.init({ | 15 | tinyMCE.init({ |
| 16 | theme: "advanced", | 16 | theme: "advanced", |
| 17 | mode : "specific_textareas", | 17 | mode : "specific_textareas", |
| 18 | editor_selector : "with_editor", | 18 | editor_selector : "with_editor", |
| 19 | theme_advanced_toolbar_location : "top", | 19 | theme_advanced_toolbar_location : "top", |
| 20 | theme_advanced_toolbar_align : "left", | 20 | theme_advanced_toolbar_align : "left", |
| 21 | theme_advanced_buttons1 : "bold, italic, underline, bullist, numlist, link, unlink, formatselect, code", | 21 | theme_advanced_buttons1 : "bold, italic, underline, bullist, numlist, link, unlink, formatselect, code", |
| 22 | theme_advanced_buttons2 : "", | 22 | theme_advanced_buttons2 : "", |
| 23 | theme_advanced_buttons3 : "", | 23 | theme_advanced_buttons3 : "", |
| 24 | extended_valid_elements : "aggregate[tags|limit|order_by|order_direction|partial]", | 24 | extended_valid_elements : "aggregate[tags|limit|order_by|order_direction|partial]", |
| 25 | relative_urls : false, | 25 | relative_urls : false, |
| 26 | entity_encoding : "raw" | 26 | entity_encoding : "raw", |
| 27 | }); | 27 | oninit : "setup_autosave" |
| 28 | }); | ||
| 29 | |||
| 30 | var setup_autosave = function() { | ||
| 31 | |||
| 32 | var elements = { | ||
| 33 | "title" : $('#page_title'), | ||
| 34 | "abstract" : $('#page_abstract'), | ||
| 35 | "body" : $('#page_body_ifr').contents().find('#tinymce'), | ||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | var page = { | ||
| 40 | "cached_title_length" : elements.title.val().length, | ||
| 41 | "cached_abstract_length" : elements.abstract.val().length, | ||
| 42 | "cached_body_length" : elements.body.html().length, | ||
| 43 | |||
| 44 | "title_has_changed" : function() { | ||
| 45 | return (elements.title.val().length != this.cached_title_length) | ||
| 46 | }, | ||
| 47 | |||
| 48 | "abstract_has_changed" : function() { | ||
| 49 | return (elements.abstract.val().length != this.cached_abstract_length) | ||
| 50 | }, | ||
| 51 | |||
| 52 | "body_has_changed" : function() { | ||
| 53 | return elements.body.html().length != this.cached_body_length | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | |||
| 58 | jQuery.fn.submitWithAjax = function(options) { | ||
| 59 | if (page.title_has_changed() || page.abstract_has_changed() || page.body_has_changed()) { | ||
| 60 | |||
| 61 | page.cached_title_length = elements.title.val().length; | ||
| 62 | page.cached_abstract_length = elements.abstract.val().length; | ||
| 63 | page.cached_body_length = elements.body.html().length; | ||
| 64 | |||
| 65 | $("#flash").append("<img src='/images/ajax-loader.gif' alt='' />"); | ||
| 66 | $.post(this.attr("action"), $(this).serialize(), null, "script"); | ||
| 67 | } | ||
| 68 | }; | ||
| 69 | } | ||
| 28 | </script> | 70 | </script> |
| 29 | </head> | 71 | </head> |
| 30 | 72 | ||
diff --git a/app/views/nodes/_autosave.html.erb b/app/views/nodes/_autosave.html.erb index 583b374..7d3736b 100644 --- a/app/views/nodes/_autosave.html.erb +++ b/app/views/nodes/_autosave.html.erb | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | |||
| 2 | <script type="text/javascript" charset="utf-8"> | 1 | <script type="text/javascript" charset="utf-8"> |
| 3 | $(document).ready(function() { | 2 | $(document).ready(function() { |
| 4 | setInterval('$("#edit_node_<%= @node.id %>").submitWithAjax()', 15000); | 3 | setInterval('$("#edit_node_<%= @node.id %>").submitWithAjax()', 15000); |
| 5 | }); | 4 | }); |
| 6 | </script> \ No newline at end of file | 5 | </script> |
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index 12a3ba6..2b8a0d2 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -16,11 +16,4 @@ $(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 | jQuery.fn.submitWithAjax = function() { | ||
| 20 | $("#flash").append("<img src='/images/ajax-loader.gif' alt='' />"); | ||
| 21 | $.post(this.attr("action"), $(this).serialize(), null, "script"); | ||
| 22 | }; | ||
| 23 | |||
| 24 | |||
| 25 | |||
| 26 | }); \ No newline at end of file | 19 | }); \ No newline at end of file |
