move script from footer.js

have fixed bug of multiple active of email and send to users.
also make URL like "http://localhost:9000/admin/t?p=0&t=email/sendToUsers" work.
This commit is contained in:
yu huang
2015-08-29 19:19:11 -04:00
parent 05a5280162
commit 6d7fe83469

View File

@ -274,21 +274,56 @@ function goNowToDatetime(goNow) {
!function ($) { !function ($) {
$(function(){ $(function(){
// life //navigation
$(".nav li > a").click(function(e) { !function ($) {
$p = $(this).closest("ul"); /**
var $li = $(this).closest("li"); * description
if($li.find("ul").length == 0) { * every href must begin with "?t="
return true; */
} //initial
e.preventDefault(); function getParameterByName(name, queryString) {
var hasClass = $li.hasClass("active"); name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); //address array [] condiion
$p.find("li").removeClass("active"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
if(hasClass) { results = regex.exec(queryString);
} else { return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
$li.addClass("active"); }
}
}); var pathname = window.location.pathname; // admin/t
var search = window.location.search; // ?t=xxx
var fullPath = pathname;
//test case
//http://localhost:9000/admin/t?p=0&t=email/sendToUsers
//t=email/sendToUsers and t=email/send
var paramId = getParameterByName("t",window.location.search)
if(paramId !== "") {
var fullPath = pathname + "?t=" + paramId; // /admin/t?t=xxx
}
$("#nav > li").removeClass("active");
var $thisLi = $('#nav a[href="' + fullPath + '"]').parent();
// 自己
$thisLi.addClass("active");
// 父也active
$thisLi.parent().parent().addClass('active');
// event binding
$(".nav li > a").click(function(e) {
$p = $(this).closest("ul");
var $li = $(this).closest("li");
if($li.find("ul").length == 0) {
return true;
}
e.preventDefault();
var hasClass = $li.hasClass("active");
$p.find("li").removeClass("active");
if(hasClass) {
} else {
$li.addClass("active");
}
});
}($);
// sort // sort
$(".th-sortable").click(function() { $(".th-sortable").click(function() {
@ -566,4 +601,4 @@ function goNowToDatetime(goNow) {
}); });
}(window.jQuery); }(window.jQuery);