Skip to content

Commit

Permalink
feature: It's now possible to navigate between pages\!
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Oct 8, 2017
1 parent fa20942 commit a6f41f2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/server/public/abecms/libs/clickEditor.js
@@ -0,0 +1,26 @@
window.addEventListener('click', function (ev) {
if (ev.altKey || ev.ctrlKey || ev.metaKey || ev.shiftKey || ev.defaultPrevented || self.location == top.location) {
console.log('avoided');
return true;
}

var anchor = null;
for (var n = ev.target; n.parentNode; n = n.parentNode) {
if (n.nodeName === 'A') {
anchor = n;
break;
}
}
if (!anchor) return true;

var link = document.createElement('a');
link.setAttribute('href', anchor.getAttribute('href'));

if (link.host && link.host !== location.host) return true;

ev.preventDefault();

var gotoUrl = location.protocol + '//' + location.host + '/abe/editor' + link.pathname + (link.search || '') + (link.hash || '') ;
link = null;
top.location.href = gotoUrl
});
1 change: 1 addition & 0 deletions src/server/public/abecms/scripts/template-engine.js
Expand Up @@ -229,6 +229,7 @@ class Engine {
if (typeof base !== 'undefined' && base !== null) {
base = base.replace(/\[pageHTML\]/g, '')
base = base.replace(/<ABE!--/g, '<!--').replace(/--ABE>/g, '-->')
base = base.replace(/<\/body>/g, '<script src="/abecms/libs/clickEditor.js"></script></body>')
EditorReload.instance.inject(base)
}
}
Expand Down

0 comments on commit a6f41f2

Please sign in to comment.