Show

var nav = document.getElementById("navin");
var thisnum;
for (var i = 0; i <= nav.children.length - 1; i++) {
    //默认打开样式为CN的二级菜单
    if (nav.children[i].className == "cn") {
        nav.children[i].getElementsByTagName("ul")[0].style.display = "block";
        thisnum = i;
    }
    nav.children[i].onmouseover = function () {
        for (var j = 0; j <= nav.getElementsByTagName("ul").length - 1; j++) {
            nav.children[j].className = "";
            nav.children[j].getElementsByTagName("ul")[0].style.display = "none";
        }
        this.className = "cn";
        this.getElementsByTagName("ul")[0].style.display = "block";
    }
    nav.children[i].onmouseout = function () {
        for (var k = 0; k <= nav.getElementsByTagName("ul").length - 1; k++) {
            nav.children[k].className = "";
            nav.children[k].getElementsByTagName("ul")[0].style.display = "none";
        }
        this.getElementsByTagName("ul")[0].style.display = "none";
        nav.children[thisnum].className = "cn"
        nav.children[thisnum].getElementsByTagName("ul")[0].style.display = "block";
    }
}


//发布动态编辑器
if (document.getElementById("noteUp")) {
    var noteUp = document.getElementById("noteUp");
    var Nonote = document.getElementById("Nonote");
    var clearUP = document.getElementById("clearUP");
    var notetest = document.getElementById("notetest");

    Nonote.onclick = function () {
        Nonote.style.display = "none";
        noteUp.style.display = "block";
        notetest.focus();
    }
    clearUP.onclick = function () {
        Nonote.style.display = "block";
        noteUp.style.display = "none";
    }
}

 

 

//表格隔行换色
function changeTable(o, a, b, c, d) {
    var t = document.getElementById(o).getElementsByTagName("tr"); //getElementByid获到某个元素的id
    for (var i = 0; i < t.length; i++) {
        t[i].style.backgroundColor = (t[i].sectionRowIndex % 2 == 0) ? a : b;
//        t[i].onclick = function () {
//            if (this.x != "1") {
//                this.x = "1";
//                this.style.backgroundColor = d;
//            } else {
//                this.x = "0";
//                this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
//            }
//        }
        t[i].onmouseover = function () {
            if (this.x != "1") this.style.backgroundColor = c;
        }
        t[i].onmouseout = function () {
            if (this.x != "1") this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
        }
    }
}
if (document.getElementById("datalist")) {
    //changeTable("表格名称","奇数行背景","偶数行背景","鼠标经过背景","点击后背景");
    changeTable("datalist", "#fff", "#f9f9f9", "#f5f8f9", "#e7f3f7");
}


//回复函数
function showReply(obj) {
    if (obj) {
        var Replybox = document.getElementById(obj);
        if (Replybox.style.display == "block") {
            Replybox.style.display = "none";
        } else {
            Replybox.style.display = "block";
        }
    }
}
function showdoReply(obj, thisobj) {
    var Replybox = document.getElementById(obj);
    var thisobj = document.getElementById(thisobj);

    Replybox.style.display = "block";
    thisobj.style.display = "none";
    Replybox.getElementsByTagName("textarea")[0].focus();
}


//提示框 p(显示的文字,定时)
function p(text, t) {
    var p = document.getElementById("prompt");
    var ptext = document.getElementById("ptext");
    ptext.innerHTML = text;
    $("#prompt").fadeIn(200);
    var ptop = (document.documentElement.scrollTop + (document.documentElement.clientHeight - p.offsetHeight) / 2);
    var pleft = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - p.offsetWidth) / 2);
    p.style.top = ptop + "px";
    p.style.left = pleft + "px";
    //定时器
    setTimeout(promptnone, t);
}
//定时器函数
function promptnone() {
    var p = document.getElementById("prompt");
    $("#prompt").fadeOut(200);
}


//弹出层
function showBox(obj, t, w, h, z, url) {
    $("#system").load(url, function () {
        if (z == "1") {
            var bgDiv = document.getElementById("bgDiv");
            var sHeight = document.body.clientHeight;
            bgDiv.style.height = sHeight + "px";
            //bgDiv.style.display = "block";
            $("#bgDiv").fadeTo("slow", 0.3);
        }
        var box = document.getElementById(obj);
        var showBoxtitle = document.getElementById("showBoxtitle");
        box.style.width = w + "px";
        box.style.height = h + "px";
        showBoxtitle.innerHTML = t;
        box.style.display = "block";
        box.style.top = (document.documentElement.scrollTop + document.body.scrollTop + document.documentElement.clientHeight / 2) - (box.offsetHeight / 2) + "px";
        box.style.left = (document.documentElement.scrollLeft + document.body.scrollLeft + document.documentElement.clientWidth / 2) - (box.offsetWidth / 2) + "px";
    });
}
//隐藏弹出窗体 n(被弹出ID)
function n(obj) {
    var box = document.getElementById(obj);
    var bgDiv = document.getElementById("bgDiv");
    box.style.display = "none";
    //bgDiv.style.display = "none";
    $("#bgDiv").fadeOut(300);

}


//多数据提交 ondat
if (document.getElementById("godata")) {
    $("#godata div.ondata").mouseenter(function () { $(this).addClass("ondatabg"); });
    $("#godata div.ondata").mouseleave(function () { $(this).removeClass("ondatabg"); });
}

 

$(function () {
    $('#godata').hradio();
    $('#godata').hcheckbox();

    //获取值
    //$('#btnOK').click(function(){
    // var checkedValues = new Array();
    // $('#chklist :checkbox').each(function(){
    //  if($(this).is(':checked'))
    //  {
    //   checkedValues.push($(this).val());
    //  }
    // });
    //
    // alert(checkedValues.join(','));
    // alert($('#radiolist :checked').val());
    //})

});

 

 

 

/**
* --------------------------------------------------------------------
* jQuery tree plugin
* Author: Scott Jehl, scott@filamentgroup.com
* Copyright (c) 2009 Filament Group
* licensed under MIT (filamentgroup.com/examples/mit-license.txt)
* --------------------------------------------------------------------
*/
$.fn.tree = function (settings) {
    var o = $.extend({
        expanded: ''
    }, settings);

    return $(this).each(function () {
        if (!$(this).parents('.tree').length) {
            //save reference to tree UL
            var tree = $(this);

            //add the role and default state attributes
            if (!$('body').is('[role]')) { $('body').attr('role', 'application'); }
            //add role and class of tree
            tree.attr({ 'role': 'tree' }).addClass('tree');
            //set first node's tabindex to 0
            tree.find('a:eq(0)').attr('tabindex', '0');
            //set all others to -1
            tree.find('a:gt(0)').attr('tabindex', '-1');
            //add group role and tree-group-collapsed class to all ul children
            tree.find('ul').attr('role', 'group').addClass('tree-group-collapsed');
            //add treeitem role to all li children
            tree.find('li').attr('role', 'treeitem');
            //find tree group parents
            tree.find('li:has(ul)')
    .attr('aria-expanded', 'false')
    .find('>a')
    .addClass('tree-parent tree-parent-collapsed');

            //expanded at load  
            tree
   .find(o.expanded)
   .attr('aria-expanded', 'true')
    .find('>a')
    .removeClass('tree-parent-collapsed')
    .next()
    .removeClass('tree-group-collapsed');


            //bind the custom events
            tree
            //expand a tree node
   .bind('expand', function (event) {
       var target = $(event.target) || tree.find('a[tabindex=0]');
       target.removeClass('tree-parent-collapsed');
       target.next().hide().removeClass('tree-group-collapsed').slideDown(150, function () {
           $(this).removeAttr('style');
           target.parent().attr('aria-expanded', 'true');
       });
   })
            //collapse a tree node
   .bind('collapse', function (event) {
       var target = $(event.target) || tree.find('a[tabindex=0]');
       target.addClass('tree-parent-collapsed');
       target.next().slideUp(150, function () {
           target.parent().attr('aria-expanded', 'false');
           $(this).addClass('tree-group-collapsed').removeAttr('style');
       });
   })
   .bind('toggle', function (event) {
       var target = $(event.target) || tree.find('a[tabindex=0]');
       //check if target parent LI is collapsed
       if (target.parent().is('[aria-expanded=false]')) {
           //call expand function on the target
           target.trigger('expand');
       }
       //otherwise, parent must be expanded
       else {
           //collapse the target
           target.trigger('collapse');
       }
   })
            //shift focus down one item  
   .bind('traverseDown', function (event) {
       var target = $(event.target) || tree.find('a[tabindex=0]');
       var targetLi = target.parent();
       if (targetLi.is('[aria-expanded=true]')) {
           target.next().find('a').eq(0).focus();
       }
       else if (targetLi.next().length) {
           targetLi.next().find('a').eq(0).focus();
       }
       else {
           targetLi.parents('li').next().find('a').eq(0).focus();
       }
   })
            //shift focus up one item
   .bind('traverseUp', function (event) {
       var target = $(event.target) || tree.find('a[tabindex=0]');
       var targetLi = target.parent();
       if (targetLi.prev().length) {
           if (targetLi.prev().is('[aria-expanded=true]')) {
               targetLi.prev().find('li:visible:last a').eq(0).focus();
           }
           else {
               targetLi.prev().find('a').eq(0).focus();
           }
       }
       else {
           targetLi.parents('li:eq(0)').find('a').eq(0).focus();
       }
   });


            //and now for the native events
            tree
   .focus(function (event) {
       //deactivate previously active tree node, if one exists
       tree.find('[tabindex=0]').attr('tabindex', '-1').removeClass('tree-item-active');
       //assign 0 tabindex to focused item
       $(event.target).attr('tabindex', '0').addClass('tree-item-active');
   })
   .click(function (event) {
       //save reference to event target
       var target = $(event.target);
       //check if target is a tree node
       if (target.is('a.tree-parent')) {
           target.trigger('toggle');
           target.eq(0).focus();
           //return click event false because it's a tree node (folder)
           return false;
       }
   })
   .keydown(function (event) {
       var target = tree.find('a[tabindex=0]');
       //check for arrow keys
       if (event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 39 || event.keyCode == 40) {
           //if key is left arrow
           if (event.keyCode == 37) {
               //if list is expanded
               if (target.parent().is('[aria-expanded=true]')) {
                   target.trigger('collapse');
               }
               //try traversing to parent
               else {
                   target.parents('li:eq(1)').find('a').eq(0).focus();
               }
           }
           //if key is right arrow
           if (event.keyCode == 39) {
               //if list is collapsed
               if (target.parent().is('[aria-expanded=false]')) {
                   target.trigger('expand');
               }
               //try traversing to child
               else {
                   target.parents('li:eq(0)').find('li a').eq(0).focus();
               }
           }
           //if key is up arrow
           if (event.keyCode == 38) {
               target.trigger('traverseUp');
           }
           //if key is down arrow
           if (event.keyCode == 40) {
               target.trigger('traverseDown');
           }
           //return any of these keycodes false
           return false;
       }
       //check if enter or space was pressed on a tree node
       else if ((event.keyCode == 13 || event.keyCode == 32) && target.is('a.tree-parent')) {
           target.trigger('toggle');
           //return click event false because it's a tree node (folder)
           return false;
       }
   });
        }
    });
};   

posted @ 2013-08-20 09:24  nieyulin  阅读(323)  评论(0编辑  收藏  举报