From 1d639d120387cfdee5617f26a6bbc21b97feb2ce Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Fri, 7 Aug 2015 17:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E5=B7=A6?= =?UTF-8?q?=E4=BE=A7=E5=AF=BC=E8=88=AA=E6=A0=8F=E7=9A=84=20hash=20?= =?UTF-8?q?=E5=92=8C=20li=20class=20=E8=BF=98=E6=9C=89=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=AF=B9=E5=BA=94=E5=85=B3=E7=B3=BB=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/js/app/admin/admin.js | 39 +++++++++++++++++++------------- template/admin/admin.html | 10 ++++---- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/static/src/js/app/admin/admin.js b/static/src/js/app/admin/admin.js index b44f575..4145a45 100644 --- a/static/src/js/app/admin/admin.js +++ b/static/src/js/app/admin/admin.js @@ -7,24 +7,11 @@ define("admin", ["jquery", "avalon"], function($, avalon){ $(".list-group-item").attr("class", "list-group-item"); } - var hash = window.location.hash.substring(1); - - if(hash){ - li_active("#li-" + hash); - }else { - li_active("#li-index"); + function show_template(url){ + $("#loading-gif").show(); + vm.template_url = url; } - window.onhashchange = function() { - var hash = window.location.hash.substring(1); - if(hash){ - li_inactive(".list-group-item"); - li_active("#li-" + hash); - $("#loading-gif").show(); - vm.template_url = "template/index/" + hash + ".html"; - } - }; - var vm = avalon.define({ $id: "admin", template_url: "template/index/index.html", @@ -32,4 +19,24 @@ define("admin", ["jquery", "avalon"], function($, avalon){ $("#loading-gif").hide(); } }); + + var hash = window.location.hash.substring(1); + + if(hash){ + li_active("#li-" + hash.replace("/", "-")); + show_template("template/" + hash + ".html"); + }else { + li_active("#li-index-index"); + } + + window.onhashchange = function() { + var hash = window.location.hash.substring(1); + if(hash){ + li_inactive(".list-group-item"); + li_active("#li-" + hash.replace("/", "-")); + show_template("template/" + hash + ".html"); + } + }; + + }); \ No newline at end of file diff --git a/template/admin/admin.html b/template/admin/admin.html index 6ec5a4e..2fbf58d 100644 --- a/template/admin/admin.html +++ b/template/admin/admin.html @@ -67,17 +67,17 @@ -
+