diff --git a/admin/javascript/LeftAndMain.Content.js b/admin/javascript/LeftAndMain.Content.js index 4149901f9..3a8950d83 100644 --- a/admin/javascript/LeftAndMain.Content.js +++ b/admin/javascript/LeftAndMain.Content.js @@ -31,7 +31,12 @@ var url = $(node).find('a:first').attr('href'); if(url && url != '#') { - window.History.pushState({}, '', url); + if($(node).find('a:first').is(':internal')) url = $('base').attr('href') + url; + if(window.History.enabled) { + window.History.pushState({}, '', url); + } else { + window.location = url; + } } else { self.removeForm(); } diff --git a/admin/javascript/LeftAndMain.Menu.js b/admin/javascript/LeftAndMain.Menu.js index c947376ac..1e7b03585 100644 --- a/admin/javascript/LeftAndMain.Menu.js +++ b/admin/javascript/LeftAndMain.Menu.js @@ -97,20 +97,25 @@ // Expand this, and collapse all other items var item = this.getMenuItem(); item.select(); + + var url = this.attr('href'); + if(this.is(':internal')) url = $('base').attr('href') + url; var children = item.find('li'); if(children.length) { children.first().find('a').click(); - } else { + } else if(window.History.enabled) { // Active menu item is set based on X-Controller ajax header, // which matches one class on the menu - window.History.pushState({}, '', this.attr('href')); + window.History.pushState({}, '', url); + } else { + window.location = url; } } }); }); - + // Internal Helper $.expr[':'].internal = function(obj){return obj.href.match(/^mailto\:/) || (obj.hostname == location.hostname);}; $.expr[':'].external = function(obj){return !$(obj).is(':internal')}; diff --git a/admin/javascript/LeftAndMain.Preview.js b/admin/javascript/LeftAndMain.Preview.js index f5fe9c314..f89d16922 100644 --- a/admin/javascript/LeftAndMain.Preview.js +++ b/admin/javascript/LeftAndMain.Preview.js @@ -99,9 +99,9 @@ var id = $(doc).find('meta[name=x-page-id]').attr('content'), editLink = $(doc).find('meta[name=x-cms-edit-link]').attr('content'), contentPanel = $('.cms-content'); - // TODO Remove hardcoding if(id && contentPanel.find(':input[name=ID]').val() != id) { - window.History.pushState({}, '', editLink); + // Ignore behaviour without history support (as we need ajax loading for the new form to load in the background) + if(window.History.enabled) window.History.pushState({}, '', editLink); } }, diff --git a/admin/javascript/ModelAdmin.js b/admin/javascript/ModelAdmin.js index 98c1c8f4c..aac1c6d3a 100644 --- a/admin/javascript/ModelAdmin.js +++ b/admin/javascript/ModelAdmin.js @@ -137,8 +137,10 @@ var firstLink = this.find('a[href]'); if(!firstLink) return; - window.History.pushState({selector: '.cms-content-fields form:first'}, '', firstLink.attr('href')); - return false; + if(window.History.enabled) { + window.History.pushState({selector: '.cms-content-fields form:first'}, '', firstLink.attr('href')); + return false; + } } });