diff options
Diffstat (limited to 'public/javascripts/admin_interface.js')
| -rw-r--r-- | public/javascripts/admin_interface.js | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index cb32d5a..67bfc02 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -12,7 +12,7 @@ function hide_all() { | |||
| 12 | 12 | ||
| 13 | $(document).ready(function () { | 13 | $(document).ready(function () { |
| 14 | admin_search.initialize(); | 14 | admin_search.initialize(); |
| 15 | 15 | ||
| 16 | tinymce.init({ | 16 | tinymce.init({ |
| 17 | selector: 'textarea.with_editor', | 17 | selector: 'textarea.with_editor', |
| 18 | license_key: 'gpl', | 18 | license_key: 'gpl', |
| @@ -29,24 +29,24 @@ $(document).ready(function () { | |||
| 29 | cccms.setup_autosave(); | 29 | cccms.setup_autosave(); |
| 30 | }); | 30 | }); |
| 31 | } | 31 | } |
| 32 | }); | 32 | }); |
| 33 | 33 | ||
| 34 | if ($("#menu_search_term").length != 0) { | 34 | if ($("#menu_search_term").length != 0) { |
| 35 | menu_items.initialize_search(); | 35 | menu_items.initialize_search(); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | if ($("#menu_item_list").length != 0) { | 38 | if ($("#menu_item_list").length != 0) { |
| 39 | menu_item_sorter.initialize(); | 39 | menu_item_sorter.initialize(); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | if ($("#metadata").length != 0) { | 42 | if ($("#metadata").length != 0) { |
| 43 | meta_data.initialize(); | 43 | meta_data.initialize(); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | if ($("#parent_search_term").length != 0) { | 46 | if ($("#parent_search_term").length != 0) { |
| 47 | parent_search.initialize_search(); | 47 | parent_search.initialize_search(); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | if ($("#move_to_search_term").length != 0) { | 50 | if ($("#move_to_search_term").length != 0) { |
| 51 | move_to_search.initialize_search(); | 51 | move_to_search.initialize_search(); |
| 52 | } | 52 | } |
| @@ -59,14 +59,14 @@ $(document).ready(function () { | |||
| 59 | hide_all(); | 59 | hide_all(); |
| 60 | $('#recent_changes_toggle').attr("class", "selected"); | 60 | $('#recent_changes_toggle').attr("class", "selected"); |
| 61 | $('#recent_changes_table').show(); | 61 | $('#recent_changes_table').show(); |
| 62 | 62 | ||
| 63 | $('#recent_changes_toggle').bind("click", function(){ | 63 | $('#recent_changes_toggle').bind("click", function(){ |
| 64 | hide_all(); | 64 | hide_all(); |
| 65 | $('#recent_changes_toggle').attr("class", "selected"); | 65 | $('#recent_changes_toggle').attr("class", "selected"); |
| 66 | $('#recent_changes_table').show(); | 66 | $('#recent_changes_table').show(); |
| 67 | return false; | 67 | return false; |
| 68 | }); | 68 | }); |
| 69 | 69 | ||
| 70 | $('#my_work_toggle').bind("click", function(){ | 70 | $('#my_work_toggle').bind("click", function(){ |
| 71 | hide_all(); | 71 | hide_all(); |
| 72 | $('#my_work_toggle').attr("class", "selected"); | 72 | $('#my_work_toggle').attr("class", "selected"); |
| @@ -80,7 +80,7 @@ $(document).ready(function () { | |||
| 80 | $('#my_work_table').show(); | 80 | $('#my_work_table').show(); |
| 81 | return false; | 81 | return false; |
| 82 | }); | 82 | }); |
| 83 | 83 | ||
| 84 | $('#current_drafts_toggle').bind("click", function(){ | 84 | $('#current_drafts_toggle').bind("click", function(){ |
| 85 | hide_all(); | 85 | hide_all(); |
| 86 | $('#current_drafts_toggle').attr("class", "selected"); | 86 | $('#current_drafts_toggle').attr("class", "selected"); |
| @@ -102,18 +102,18 @@ $(document).ready(function () { | |||
| 102 | return false; | 102 | return false; |
| 103 | }); | 103 | }); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | jQuery.ajaxSetup({ | 106 | jQuery.ajaxSetup({ |
| 107 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");} | 107 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");} |
| 108 | }); | 108 | }); |
| 109 | 109 | ||
| 110 | $(document).ajaxSend(function(event, request, settings) { | 110 | $(document).ajaxSend(function(event, request, settings) { |
| 111 | if (typeof(AUTH_TOKEN) == "undefined") return; | 111 | if (typeof(AUTH_TOKEN) == "undefined") return; |
| 112 | // settings.data is a serialized string like "foo=bar&baz=boink" (or null) | 112 | // settings.data is a serialized string like "foo=bar&baz=boink" (or null) |
| 113 | settings.data = settings.data || ""; | 113 | settings.data = settings.data || ""; |
| 114 | settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN); | 114 | settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN); |
| 115 | }); | 115 | }); |
| 116 | 116 | ||
| 117 | }); | 117 | }); |
| 118 | 118 | ||
| 119 | 119 | ||
| @@ -143,50 +143,50 @@ meta_data = { | |||
| 143 | 143 | ||
| 144 | cccms = { | 144 | cccms = { |
| 145 | setup_autosave : function() { | 145 | setup_autosave : function() { |
| 146 | 146 | ||
| 147 | var elements = { | 147 | var elements = { |
| 148 | title : $('#page_title'), | 148 | title : $('#page_title'), |
| 149 | abstract : $('#page_abstract'), | 149 | abstract : $('#page_abstract'), |
| 150 | body : $('#page_body_ifr').contents().find('#tinymce'), | 150 | body : $('#page_body_ifr').contents().find('#tinymce'), |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | var page = { | 153 | var page = { |
| 154 | cached_title : elements.title.val(), | 154 | cached_title : elements.title.val(), |
| 155 | cached_abstract : elements.abstract.val(), | 155 | cached_abstract : elements.abstract.val(), |
| 156 | cached_body : elements.body.html(), | 156 | cached_body : elements.body.html(), |
| 157 | 157 | ||
| 158 | title_has_changed : function() { | 158 | title_has_changed : function() { |
| 159 | return (elements.title.val() != this.cached_title) | 159 | return (elements.title.val() != this.cached_title) |
| 160 | }, | 160 | }, |
| 161 | 161 | ||
| 162 | abstract_has_changed : function() { | 162 | abstract_has_changed : function() { |
| 163 | return (elements.abstract.val() != this.cached_abstract) | 163 | return (elements.abstract.val() != this.cached_abstract) |
| 164 | }, | 164 | }, |
| 165 | 165 | ||
| 166 | body_has_changed : function() { | 166 | body_has_changed : function() { |
| 167 | return elements.body.html() != this.cached_body | 167 | return elements.body.html() != this.cached_body |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | jQuery.fn.submitWithAjax = function(options) { | 171 | jQuery.fn.submitWithAjax = function(options) { |
| 172 | if (page.title_has_changed() || page.abstract_has_changed() || page.body_has_changed()) { | 172 | if (page.title_has_changed() || page.abstract_has_changed() || page.body_has_changed()) { |
| 173 | 173 | ||
| 174 | page.cached_title = elements.title.val(); | 174 | page.cached_title = elements.title.val(); |
| 175 | page.cached_abstract = elements.abstract.val(); | 175 | page.cached_abstract = elements.abstract.val(); |
| 176 | page.cached_body = elements.body.html(); | 176 | page.cached_body = elements.body.html(); |
| 177 | 177 | ||
| 178 | $("#flash").append("<img src='/images/ajax-loader.gif' alt='' />"); | 178 | $("#flash").append("<img src='/images/ajax-loader.gif' alt='' />"); |
| 179 | $.post(this.attr("action"), $(this).serialize(), null, "script"); | 179 | $.post(this.attr("action"), $(this).serialize(), null, "script"); |
| 180 | 180 | ||
| 181 | } | 181 | } |
| 182 | }; | 182 | }; |
| 183 | 183 | ||
| 184 | setInterval('$("#page_editor > form").submitWithAjax()', 7000); | 184 | setInterval('$("#page_editor > form").submitWithAjax()', 7000); |
| 185 | } | 185 | } |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | menu_item_sorter = { | 188 | menu_item_sorter = { |
| 189 | 189 | ||
| 190 | initialize : function() { | 190 | initialize : function() { |
| 191 | $("#menu_item_list").sortable({ | 191 | $("#menu_item_list").sortable({ |
| 192 | axis: 'y', | 192 | axis: 'y', |
| @@ -209,24 +209,24 @@ menu_item_sorter = { | |||
| 209 | } | 209 | } |
| 210 | }); | 210 | }); |
| 211 | }, | 211 | }, |
| 212 | 212 | ||
| 213 | placeholder_helper : function(e,ui) { | 213 | placeholder_helper : function(e,ui) { |
| 214 | $(".ui-state-highlight").html("<td colspan='100%'></td>"); | 214 | $(".ui-state-highlight").html("<td colspan='100%'></td>"); |
| 215 | } | 215 | } |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | image_interface = { | 218 | image_interface = { |
| 219 | 219 | ||
| 220 | initialize : function() { | 220 | initialize : function() { |
| 221 | 221 | ||
| 222 | $("#image_browser").hide(); | 222 | $("#image_browser").hide(); |
| 223 | image_interface.initialize_sortable_image_box(); | 223 | image_interface.initialize_sortable_image_box(); |
| 224 | image_interface.connect_browser_and_box(); | 224 | image_interface.connect_browser_and_box(); |
| 225 | image_interface.set_droppable_behavior(); | 225 | image_interface.set_droppable_behavior(); |
| 226 | image_interface.bind_image_browser_toggle(); | 226 | image_interface.bind_image_browser_toggle(); |
| 227 | }, | 227 | }, |
| 228 | 228 | ||
| 229 | 229 | ||
| 230 | set_droppable_behavior : function() { | 230 | set_droppable_behavior : function() { |
| 231 | $("ul#image_box").droppable({ | 231 | $("ul#image_box").droppable({ |
| 232 | out : function(event, ui) { | 232 | out : function(event, ui) { |
| @@ -242,7 +242,7 @@ image_interface = { | |||
| 242 | } | 242 | } |
| 243 | }); | 243 | }); |
| 244 | }, | 244 | }, |
| 245 | 245 | ||
| 246 | connect_browser_and_box : function() { | 246 | connect_browser_and_box : function() { |
| 247 | $("#image_browser ul li").draggable({ | 247 | $("#image_browser ul li").draggable({ |
| 248 | connectToSortable : 'ul#image_box', | 248 | connectToSortable : 'ul#image_box', |
| @@ -250,9 +250,9 @@ image_interface = { | |||
| 250 | revert : 'invalid' | 250 | revert : 'invalid' |
| 251 | }); | 251 | }); |
| 252 | }, | 252 | }, |
| 253 | 253 | ||
| 254 | initialize_sortable_image_box : function() { | 254 | initialize_sortable_image_box : function() { |
| 255 | 255 | ||
| 256 | $("ul#image_box").sortable({ | 256 | $("ul#image_box").sortable({ |
| 257 | revert : true, | 257 | revert : true, |
| 258 | update : function(event, ui) { | 258 | update : function(event, ui) { |
| @@ -267,9 +267,9 @@ image_interface = { | |||
| 267 | } | 267 | } |
| 268 | }); | 268 | }); |
| 269 | } | 269 | } |
| 270 | }); | 270 | }); |
| 271 | }, | 271 | }, |
| 272 | 272 | ||
| 273 | bind_image_browser_toggle : function() { | 273 | bind_image_browser_toggle : function() { |
| 274 | $("#image_browser_toggle").bind("click", function(){ | 274 | $("#image_browser_toggle").bind("click", function(){ |
| 275 | if ($("#image_browser_toggle").attr("class") == "unselected") { | 275 | if ($("#image_browser_toggle").attr("class") == "unselected") { |
