版本库收起后之保存在cookie中,刷新页面后仍保持收起状态

This commit is contained in:
sw 2015-05-05 17:08:46 +08:00
parent 2ade53053b
commit 2e26e27298
4 changed files with 56 additions and 17 deletions

View File

@ -13,7 +13,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= stylesheet_link_tag 'public', 'pleft', 'project','jquery/jquery-ui-1.9.2' %>
<%= javascript_include_tag 'project', 'header','select_list_move' %>
<%= javascript_include_tag 'cookie','project', 'header','select_list_move' %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>

View File

@ -30,7 +30,7 @@
</p>
</div>
</div>
<div class="repos_more"><a id="showgithelp" value="hide_help" onclick ="showhelpAndScrollTo('repos_git_more','repos_git_more'); return false;" class="c_dblue lh23">收起Git操作指南</a></div>
<div class="repos_more"><a id="showgithelp" value="hide_help" onclick ="showhelpAndScrollTo('repos_git_more'); " class="c_dblue lh23">收起Git操作指南</a></div>
<div id="repos_git_more">
<br>
<div class=" c_dark f14">

View File

@ -0,0 +1,39 @@
//保存cookie
//n:cookie的名字
//v:cookie的值
//mins:时间(分钟)
//dn:
//path:保存路径
function cookiesave(n, v, mins, dn, path)
{
if(n)
{
if(!mins) mins = 365 * 24 * 60;
if(!path) path = "/";
var date = new Date();
date.setTime(date.getTime() + (mins * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
if(dn) dn = "domain=" + dn + "; ";
document.cookie = n + "=" + v + expires + "; " + dn + "path=" + path;
}
}
//获取cookie
function cookieget(n)
{
var name = n + "=";
var ca = document.cookie.split(';');
for(var i=0;i<ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(name) == 0){
return c.substring(name.length,c.length);}
}
return false;
}

View File

@ -61,25 +61,25 @@ function show_more_msg() {
//项目版本库git帮助文档显示
function showhelpAndScrollTo(id, focus) {
var information = $("#showgithelp");
var val = information.attr("value");
if (val == "show_help") {
$("#showgithelp").text("收起Git操作指南");
information.attr("value", "hide_help");
$('#' + id).show();
if (focus !== null) {
$('#' + focus).focus();
}
$('html, body').animate({scrollTop: $('#' + id).offset().top}, 400);
function showhelpAndScrollTo(id) {
$('#' + id).toggle();
if(cookieget("repositories_visiable") == "true")
{
cookiesave("repositories_visiable", false,'','','');
}
else {
$("#showgithelp").text("显示Git操作指南");
information.attr("value", "show_help");
$('#' + id).hide();
else
{
cookiesave("repositories_visiable", true,'','','');
}
}
$(function(){
if(cookieget("repositories_visiable") == "true")
{
$('#repos_git_more').hide();
}
});
///////////////////////////////////////////////////////////////