Integrate autosave_local into core (#118)
This commit is contained in:
parent
5e5cc1e426
commit
eef94a8048
docs
include
templates/2k11
@ -4,6 +4,8 @@
|
||||
Version 2.0-beta3 ()
|
||||
------------------------------------------------------------------------
|
||||
|
||||
* Use Browsercache to save cache and restore entries
|
||||
|
||||
* Improved installer to forbid using database table prefixes with
|
||||
special characters
|
||||
|
||||
|
@ -94,6 +94,10 @@ function errorHandlerCreateDOM(htmlStr) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'backend_save':
|
||||
case 'backend_publish':
|
||||
echo '<script>$(document).ready(function() { serendipity.eraseEntryEditorCache(); });</script>';
|
||||
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
@ -660,6 +660,66 @@
|
||||
}
|
||||
}
|
||||
|
||||
serendipity.startEntryEditorCache = function() {
|
||||
if ($('textarea[name="serendipity[body]"]').val() == "") {
|
||||
serendipity.getCached("serendipity[body]", function(res) {
|
||||
if (res && res != null && res != "null") {
|
||||
$('textarea[name="serendipity[body]"]').text(res);
|
||||
}
|
||||
});
|
||||
serendipity.getCached("serendipity[extended]", function(res) {
|
||||
if (res && res != null && res != "null") {
|
||||
if ($('textarea[name="serendipity[extended]"]').val() == "") {
|
||||
$('textarea[name="serendipity[extended]"]').text(res);
|
||||
if (! $('textarea[name="serendipity[extended]"]').is(':visible')) {
|
||||
serendipity.toggle_extended();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('textarea[name="serendipity[body]"]').one('keyup', function() {
|
||||
setInterval(function() {
|
||||
serendipity.cache("serendipity[body]", $('textarea[name="serendipity[body]"]').val())
|
||||
}, 5000);
|
||||
});
|
||||
$('textarea[name="serendipity[extended]"]').one('keyup', function() {
|
||||
setInterval(function() {
|
||||
serendipity.cache("serendipity[extended]", $('textarea[name="serendipity[extended]"]').val());
|
||||
}, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
serendipity.eraseEntryEditorCache = function() {
|
||||
serendipity.cache("serendipity[body]", null);
|
||||
serendipity.cache("serendipity[extended]", null);;
|
||||
}
|
||||
|
||||
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
|
||||
|
||||
serendipity.cache = function (id, data) {
|
||||
var request = indexedDB.open("cache", 1);
|
||||
request.onupgradeneeded = function (event) {
|
||||
event.target.result.createObjectStore("cache");
|
||||
};
|
||||
request.onsuccess = function(event) {
|
||||
event.target.result.transaction(["cache"], 'readwrite').objectStore("cache").put(data, id);
|
||||
};
|
||||
}
|
||||
|
||||
serendipity.getCached = function(id, success) {
|
||||
var request = indexedDB.open("cache", 1);
|
||||
request.onupgradeneeded = function (event) {
|
||||
event.target.result.createObjectStore("cache");
|
||||
};
|
||||
request.onsuccess = function(event) {
|
||||
event.target.result.transaction(["cache"], 'readwrite').objectStore("cache").get(id).onsuccess = function (event) {
|
||||
success(event.target.result);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
serendipity.toggle_collapsible = function(toggler, target, stateClass, stateIcon, stateOpen, stateClosed) {
|
||||
// argument defaults
|
||||
stateClass = stateClass || 'additional_info';
|
||||
@ -945,6 +1005,7 @@ $(function() {
|
||||
if(!Modernizr.inputtypes.date) {
|
||||
$('#serendipityNewTimestamp').val($('#serendipityNewTimestamp').val().replace("T", " "));
|
||||
}
|
||||
serendipity.startEntryEditorCache();
|
||||
}
|
||||
|
||||
// Set entry timestamp
|
||||
|
@ -40,6 +40,17 @@
|
||||
customConfig : '{$serendipityHTTPPath}htmlarea/ckeditor/ckeditor_custom_config.js',
|
||||
extraPlugins : 's9y_medialibrary{$item}{foreach $buttons as $button},{$button.id}{/foreach}',
|
||||
|
||||
on: {
|
||||
instanceReady: function( evt ) {
|
||||
CKEDITOR.instances["{$item}"].document.once('keyup', function() {
|
||||
setInterval(function() {
|
||||
console.log("save");
|
||||
serendipity.cache("{$item}", CKEDITOR.instances["{$item}"].getData());
|
||||
}, 5000)
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
toolbar: [
|
||||
{ name: 'tools', items: [ 'Maximize' ] },
|
||||
{ name: 'styles', items: [ 'Format' ] },
|
||||
|
@ -27,6 +27,7 @@
|
||||
{/if}
|
||||
<script src="{serendipity_getFile file="js/modernizr-2.7.1.min.js"}"></script>
|
||||
{serendipity_hookPlugin hook="backend_header" hookAll="true"}
|
||||
<script src="{serendipity_getFile file='admin/serendipity_editor.js'}"></script>
|
||||
<script>
|
||||
window.onload = function() {ldelim}
|
||||
parent.document.getElementById('serendipity_iframe').style.height = document.getElementById('content').offsetHeight
|
||||
|
Loading…
x
Reference in New Issue
Block a user