wpTriggerSave for autosave. does not move cursor.
git-svn-id: http://svn.automattic.com/wordpress/trunk@4085 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c4a4c6c371
commit
d52b9b2d2a
|
@ -7,6 +7,7 @@ header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT")
|
|||
|
||||
|
||||
?>
|
||||
var autosaveLast = '';
|
||||
function autosave_timer() {
|
||||
autosave();
|
||||
setTimeout("autosave_timer()", <?php echo apply_filters('autosave_interval', '60000') ?>);
|
||||
|
@ -56,20 +57,23 @@ function autosave_saved() {
|
|||
}
|
||||
|
||||
function autosave() {
|
||||
var form = $('post');
|
||||
|
||||
autosaveAjax = new sack();
|
||||
form = $('post');
|
||||
|
||||
/* Gotta do this up here so we can check the length when tinyMCE is in use */
|
||||
if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 ) {
|
||||
autosaveAjax.setVar("content", form.content.value);
|
||||
} else {
|
||||
tinyMCE.triggerSave();
|
||||
tinyMCE.wpTriggerSave();
|
||||
autosaveAjax.setVar("content", form.content.value);
|
||||
}
|
||||
|
||||
if(form.post_title.value.length==0 || form.content.value.length==0)
|
||||
if(form.post_title.value.length==0 || form.content.value.length==0 || form.post_title.value+form.content.value == autosaveLast)
|
||||
return;
|
||||
|
||||
autosaveLast = form.post_title.value+form.content.value;
|
||||
|
||||
cats = document.getElementsByName("post_category[]");
|
||||
goodcats = ([]);
|
||||
for(i=0;i<cats.length;i++) {
|
||||
|
@ -90,7 +94,7 @@ function autosave() {
|
|||
if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 ) {
|
||||
autosaveAjax.setVar("content", form.content.value);
|
||||
} else {
|
||||
tinyMCE.triggerSave();
|
||||
tinyMCE.wpTriggerSave();
|
||||
autosaveAjax.setVar("content", form.content.value);
|
||||
}
|
||||
|
||||
|
|
|
@ -382,3 +382,86 @@ tinyMCE.execCommand = function (command, user_interface, value) {
|
|||
}
|
||||
return re;
|
||||
};
|
||||
wpInstTriggerSave = function (skip_cleanup, skip_callback) {
|
||||
var e, nl = new Array(), i, s;
|
||||
|
||||
this.switchSettings();
|
||||
s = tinyMCE.settings;
|
||||
|
||||
// Force hidden tabs visible while serializing
|
||||
if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
|
||||
e = this.iframeElement;
|
||||
|
||||
do {
|
||||
if (e.style && e.style.display == 'none') {
|
||||
e.style.display = 'block';
|
||||
nl[nl.length] = {elm : e, type : 'style'};
|
||||
}
|
||||
|
||||
if (e.style && s.hidden_tab_class.length > 0 && e.className.indexOf(s.hidden_tab_class) != -1) {
|
||||
e.className = s.display_tab_class;
|
||||
nl[nl.length] = {elm : e, type : 'class'};
|
||||
}
|
||||
} while ((e = e.parentNode) != null)
|
||||
}
|
||||
|
||||
tinyMCE.settings['preformatted'] = false;
|
||||
|
||||
// Default to false
|
||||
if (typeof(skip_cleanup) == "undefined")
|
||||
skip_cleanup = false;
|
||||
|
||||
// Default to false
|
||||
if (typeof(skip_callback) == "undefined")
|
||||
skip_callback = false;
|
||||
|
||||
// tinyMCE._setHTML(this.getDoc(), this.getBody().innerHTML);
|
||||
|
||||
// Remove visual aids when cleanup is disabled
|
||||
if (this.settings['cleanup'] == false) {
|
||||
tinyMCE.handleVisualAid(this.getBody(), true, false, this);
|
||||
tinyMCE._setEventsEnabled(this.getBody(), true);
|
||||
}
|
||||
|
||||
tinyMCE._customCleanup(this, "submit_content_dom", this.contentWindow.document.body);
|
||||
var htm = skip_cleanup ? this.getBody().innerHTML : tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true);
|
||||
htm = tinyMCE._customCleanup(this, "submit_content", htm);
|
||||
|
||||
if (!skip_callback && tinyMCE.settings['save_callback'] != "")
|
||||
var content = eval(tinyMCE.settings['save_callback'] + "(this.formTargetElementId,htm,this.getBody());");
|
||||
|
||||
// Use callback content if available
|
||||
if ((typeof(content) != "undefined") && content != null)
|
||||
htm = content;
|
||||
|
||||
// Replace some weird entities (Bug: #1056343)
|
||||
htm = tinyMCE.regexpReplace(htm, "(", "(", "gi");
|
||||
htm = tinyMCE.regexpReplace(htm, ")", ")", "gi");
|
||||
htm = tinyMCE.regexpReplace(htm, ";", ";", "gi");
|
||||
htm = tinyMCE.regexpReplace(htm, """, """, "gi");
|
||||
htm = tinyMCE.regexpReplace(htm, "^", "^", "gi");
|
||||
|
||||
if (this.formElement)
|
||||
this.formElement.value = htm;
|
||||
|
||||
if (tinyMCE.isSafari && this.formElement)
|
||||
this.formElement.innerText = htm;
|
||||
|
||||
// Hide them again (tabs in MSIE)
|
||||
for (i=0; i<nl.length; i++) {
|
||||
if (nl[i].type == 'style')
|
||||
nl[i].elm.style.display = 'none';
|
||||
else
|
||||
nl[i].elm.className = s.hidden_tab_class;
|
||||
}
|
||||
}
|
||||
tinyMCE.wpTriggerSave = function () {
|
||||
var inst, n;
|
||||
for (n in tinyMCE.instances) {
|
||||
inst = tinyMCE.instances[n];
|
||||
if (!tinyMCE.isInstance(inst))
|
||||
continue;
|
||||
inst.wpTriggerSave = wpInstTriggerSave;
|
||||
inst.wpTriggerSave(false, false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue