1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
$(document).ready(function () {
admin_search.initialize();
meta_data.initialize();
jQuery.ajaxSetup({
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})
});
meta_data = {
initialize : function() {
$("#metadata").attr("style", "display: none;");
$("#button").click(function () {
$("#metadata").slideToggle("slow");
if ($("#button").attr("class") == "unselected") {
$("#button").attr("class", "selected");
}
else {
$("#button").attr("class", "unselected");
}
});
}
};
cccms = {
setup_autosave : function() {
var elements = {
title : $('#page_title'),
abstract : $('#page_abstract'),
body : $('#page_body_ifr').contents().find('#tinymce'),
}
var page = {
cached_title : elements.title.val(),
cached_abstract : elements.abstract.val(),
cached_body : elements.body.html(),
title_has_changed : function() {
return (elements.title.val() != this.cached_title)
},
abstract_has_changed : function() {
return (elements.abstract.val() != this.cached_abstract)
},
body_has_changed : function() {
return elements.body.html() != this.cached_body
}
}
jQuery.fn.submitWithAjax = function(options) {
if (page.title_has_changed() || page.abstract_has_changed() || page.body_has_changed()) {
page.cached_title = elements.title.val();
page.cached_abstract = elements.abstract.val();
page.cached_body = elements.body.html();
$("#flash").append("<img src='/images/ajax-loader.gif' alt='' />");
$.post(this.attr("action"), $(this).serialize(), null, "script");
}
};
setInterval('$("#page_editor > form").submitWithAjax()', 15000);
}
}
|