Bläddra i källkod

Support drafts on existing pages

tags/v1.0
Matt Baer 8 år sedan
förälder
incheckning
bef1219018
1 ändrade filer med 6 tillägg och 6 borttagningar
  1. +6
    -6
      templates/editor.html

+ 6
- 6
templates/editor.html Visa fil

@@ -75,18 +75,18 @@ var $view = $('#preview');
editor.setTheme("ace/theme/chrome");
editor.session.setMode("ace/mode/html");
editor.getSession().on('change', updatePreview);
{{if .ID}}{{else}}var saved = H.get('constructionSite', '');
var saved = H.get('{{if .ID}}house{{.ID}}{{else}}constructionSite{{end}}', '');
if (saved !== '') {
editor.setValue(saved);
}{{end}}
}
updatePreview();

{{if .ID}}{{else}}window.addEventListener('beforeunload', function(e) {
window.addEventListener('beforeunload', function(e) {
if (!justPublished) {
H.set('constructionSite', editor.getSession().getValue());
H.set('{{if .ID}}house{{.ID}}{{else}}constructionSite{{end}}', editor.getSession().getValue());
}
return null;
});{{end}}
});

if (hasBuilt) {
$('header').append('<a href="/houses.html">my pages</a>');
@@ -122,7 +122,7 @@ $publishBtn.on('click', function(e) {
houses.push({id: data.data.id, token: xhr.getResponseHeader('Authorization')});
H.set('neighborhood', JSON.stringify(houses));{{end}}
justPublished = true;
{{if .ID}}{{else}}H.remove('constructionSite');{{end}}
H.remove('{{if .ID}}house{{.ID}}{{else}}constructionSite{{end}}');
window.location = '/' + data.data.id + '.html';
} else {
alert(data.meta.error_msg);


Laddar…
Avbryt
Spara