Skip to content

Instantly share code, notes, and snippets.

@joemaffia
Created February 6, 2015 13:52
Show Gist options
  • Save joemaffia/a7a0095cf2380c48d3b0 to your computer and use it in GitHub Desktop.
Save joemaffia/a7a0095cf2380c48d3b0 to your computer and use it in GitHub Desktop.
Bookmarklet to switch between Touch & Classic edit mode in AEM
javascript:(function(){
var TOUCH = '/editor.html';
var CLASSIC = '/cf';
var createURL = function(path, qs, hash) {
var url = path;
if(qs.length != 0 && !(qs.length == 1 && qs[0] == '')) {
url += '?' + qs.join('&');
}
url += hash;
return url;
};
var hash = '';
var parameters = [];
if (window.location.search.substring(1) != '') {
parameters = window.location.search.substring(1).split('&');
}
var path = '';
if (window.location.pathname.indexOf(TOUCH) != -1) {
path = window.location.pathname.replace(TOUCH,CLASSIC+'#');
if(window.location.search.substring(1) != '') {
parameters = window.location.search.substring(1).split('&');
}
hash = window.location.hash;
}
if (window.location.pathname.indexOf(CLASSIC) != -1) {
path = TOUCH + window.frames[1].location.pathname;
if(window.frames[1].location.search.substring(1) != '') {
parameters = window.frames[1].location.search.substring(1).split('&');
}
hash = window.frames[1].location.hash;
}
var url = createURL(path, parameters, hash);
window.location = url;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment