mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Making HTML5 History support optional, so we can disable HTML4 hash change fallback
This commit is contained in:
parent
1b7c33574a
commit
9c6cbf7012
@ -31,7 +31,12 @@
|
|||||||
|
|
||||||
var url = $(node).find('a:first').attr('href');
|
var url = $(node).find('a:first').attr('href');
|
||||||
if(url && url != '#') {
|
if(url && url != '#') {
|
||||||
|
if($(node).find('a:first').is(':internal')) url = $('base').attr('href') + url;
|
||||||
|
if(window.History.enabled) {
|
||||||
window.History.pushState({}, '', url);
|
window.History.pushState({}, '', url);
|
||||||
|
} else {
|
||||||
|
window.location = url;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.removeForm();
|
self.removeForm();
|
||||||
}
|
}
|
||||||
|
@ -98,13 +98,18 @@
|
|||||||
var item = this.getMenuItem();
|
var item = this.getMenuItem();
|
||||||
item.select();
|
item.select();
|
||||||
|
|
||||||
|
var url = this.attr('href');
|
||||||
|
if(this.is(':internal')) url = $('base').attr('href') + url;
|
||||||
|
|
||||||
var children = item.find('li');
|
var children = item.find('li');
|
||||||
if(children.length) {
|
if(children.length) {
|
||||||
children.first().find('a').click();
|
children.first().find('a').click();
|
||||||
} else {
|
} else if(window.History.enabled) {
|
||||||
// Active menu item is set based on X-Controller ajax header,
|
// Active menu item is set based on X-Controller ajax header,
|
||||||
// which matches one class on the menu
|
// which matches one class on the menu
|
||||||
window.History.pushState({}, '', this.attr('href'));
|
window.History.pushState({}, '', url);
|
||||||
|
} else {
|
||||||
|
window.location = url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -99,9 +99,9 @@
|
|||||||
var id = $(doc).find('meta[name=x-page-id]').attr('content'),
|
var id = $(doc).find('meta[name=x-page-id]').attr('content'),
|
||||||
editLink = $(doc).find('meta[name=x-cms-edit-link]').attr('content'),
|
editLink = $(doc).find('meta[name=x-cms-edit-link]').attr('content'),
|
||||||
contentPanel = $('.cms-content');
|
contentPanel = $('.cms-content');
|
||||||
// TODO Remove hardcoding
|
|
||||||
if(id && contentPanel.find(':input[name=ID]').val() != id) {
|
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);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -137,9 +137,11 @@
|
|||||||
var firstLink = this.find('a[href]');
|
var firstLink = this.find('a[href]');
|
||||||
if(!firstLink) return;
|
if(!firstLink) return;
|
||||||
|
|
||||||
|
if(window.History.enabled) {
|
||||||
window.History.pushState({selector: '.cms-content-fields form:first'}, '', firstLink.attr('href'));
|
window.History.pushState({selector: '.cms-content-fields form:first'}, '', firstLink.attr('href'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user