summaryrefslogtreecommitdiffstats
path: root/theme/javascript/core/navigation.js
diff options
context:
space:
mode:
Diffstat (limited to 'theme/javascript/core/navigation.js')
-rwxr-xr-xtheme/javascript/core/navigation.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/theme/javascript/core/navigation.js b/theme/javascript/core/navigation.js
index 6e775cf..2a6d1df 100755
--- a/theme/javascript/core/navigation.js
+++ b/theme/javascript/core/navigation.js
@@ -17,15 +17,19 @@ define([
return
}
- console.log("load url", url);
return $.get(url)
- .done(function (data) {
- var $newPage = $(data);
- var title = data.match("<title>(.*?)</title>")[1];
-
- $('title').text(title);
- $('.book-body').html($newPage.find('.book-body').html());
- $('.book-summary').html($newPage.find('.book-summary').html());
+ .done(function (html) {
+ html = html.replace( /<(\/?)(html|head|body)([^>]*)>/ig, function(a,b,c,d){
+ return '<' + b + 'div' + ( b ? '' : ' data-element="' + c + '"' ) + d + '>';
+ });
+
+ var $page = $(html);
+ var $pageHead = $page.find("[data-element=head]");
+
+ $("head").html($pageHead.html());
+ $('.book-header').html($page.find('.book-header').html());
+ $('.book-body').html($page.find('.book-body').html());
+ $('.book-summary').html($page.find('.book-summary').html());
if (push) updateHistory(url, null);
preparePage();