From 9b01564c3c6b3ffad67dd1040af41d8f940b7464 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 31 Jan 2014 21:54:14 +0000 Subject: [PATCH] luci2: update ACL cache and initialize NetworkModel in LuCI2.ui.init(), bind view changes to 'hashchange' event to support browser back and forward buttons --- luci2/htdocs/luci2/luci2.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js index 2d002cb..beed5ca 100644 --- a/luci2/htdocs/luci2/luci2.js +++ b/luci2/htdocs/luci2/luci2.js @@ -3763,6 +3763,23 @@ function LuCI2() }); }, + changeView: function() + { + var name = _luci2.getHash('view'); + var node = _luci2.globals.defaultNode; + + if (name && _luci2.globals.mainMenu) + node = _luci2.globals.mainMenu.getNode(name); + + if (node) + { + _luci2.ui.loading(true); + _luci2.ui.renderView(node).then(function() { + _luci2.ui.loading(false); + }); + } + }, + updateHostname: function() { return _luci2.system.getBoardInfo().then(function(info) { @@ -3854,13 +3871,19 @@ function LuCI2() _luci2.ui.loading(true); $.when( + _luci2.session.updateACLs(), _luci2.ui.updateHostname(), _luci2.ui.updateChanges(), - _luci2.ui.renderMainMenu() + _luci2.ui.renderMainMenu(), + _luci2.NetworkModel.init() ).then(function() { _luci2.ui.renderView(_luci2.globals.defaultNode).then(function() { _luci2.ui.loading(false); - }) + }); + + $(window).on('hashchange', function() { + _luci2.ui.changeView(); + }); }); }, @@ -4074,10 +4097,7 @@ function LuCI2() _onclick: function(ev) { - _luci2.ui.loading(true); - _luci2.ui.renderView(ev.data).then(function() { - _luci2.ui.loading(false); - }); + _luci2.setHash('view', ev.data); ev.preventDefault(); this.blur(); @@ -4130,7 +4150,7 @@ function LuCI2() } else { - item.find('a').click(nodes[i], this._onclick); + item.find('a').click(nodes[i].view, this._onclick); } } -- 2.30.2