jQuery仿Ext工具栏

 

<script type="text/javascript">
	  var fullname ;   //document's fullname
	  var spacename ;  //the spacename of the document where it is.
	  var docname ;    //the name of the document.
	  var username ;   //login's username
	  var isLogin = 0;  //user have login or not.
	  //the menus show after user login.
	  var loginShowItems = ['iknow_new','iknow_edit','iknow_delete','iknow_account','iknow_logout','iknow_sort','iknow_search_txt','iknow_search_input','iknow_search_button','iknow_space'];
	  //the menu hidden after user login.
	  var loginHiddenItem = 'iknow_login';
	  updateProperties(); //set values to variables.
      $(document).ready(function(){
      var mainWin = top.document.getElementById('mainarea');
	  var configArgument = {
        renderTo : 'toolbar',
		//border: 'top',
        items : [],
        azable : true,
        azparam : 'azparam',
        active : 'ALL'    //激活哪个
      }
      var toolbar = new Toolbar(configArgument);

	  var menuItems = [{
		  id : 'iknow_home',
          type : 'button',
          text : 'iKnow 首页',
          bodyStyle : 'house',
          useable : 'T',
          handler : function(){
			  mainWin.src = "/iKnow/bin/view/Main/";
          }
        },
		{
		  id : 'iknow_new',
          type : 'button',
          text : '新建',
          bodyStyle : 'new',
          useable : 'T',
          handler : function(){
			  updateProperties();
			  mainWin.src = "/iKnow/bin/create/"+spacename+"/"+docname+"?parent="+fullname;
          }
        },
		{
		  id : 'iknow_edit',
          type : 'button',
          text : '编辑',
          bodyStyle : 'edit',
          useable : 'T',
          handler : function(){
			  updateProperties();
			  mainWin.src = "/iKnow/bin/edit/"+spacename+"/"+docname;
          }
        },
		{
		  id : 'iknow_delete',
          type : 'button',
          text : '删除',
          bodyStyle : 'delete',
          useable : 'T',
          handler : function(){
			  updateProperties();
			  mainWin.src = "/iKnow/bin/delete/"+spacename+"/"+docname;
          }
        },
		{
		  id : 'iknow_sort',
          type : 'button',
          text : '排序',
          bodyStyle : 'sort',
          useable : 'T',
          handler : function(){
             alert("谢谢您的关注,该功能正在建设中!");
          }
        },
		{
		  id : 'iknow_account',
          type:'button',
          text:'账户',
          bodyStyle:'account',
		  useable : 'T',
		  handler : function(){
			   updateProperties();
			   if(username == ''){
				   top.location.href = "/iKnow/bin/login/XWiki/XWikiLogin?xredirect=%2FiKnow%2Ftreepanel%2Fframe.jsp?space="+spacename;
				   return ;
			   }
			   mainWin.src = "/iKnow/bin/view/XWiki/" + username;
		  }
        },
		{
			id : 'iknow_help',
			type : 'button',
			text : '帮助',
			bodyStyle : 'help',
			useable : 'T',
			handler : function(){
				mainWin.src = "http://10.71.226.8/iKnow/bin/view/iKnow/iKnow%20%E5%BA%94%E7%94%A8Step%20by%20Step";
			}
		},
		{
			id : 'iknow_problem',
			type : 'button',
			text : '问题反馈',
			bodyStyle : 'problem',
			useable : 'T',
			handler : function(){
				mainWin.src = "http://10.88.32.108:8010/login.jsp?os_destination=/secure/CreateIssue!default.jspa";
			}
		},

{
		  id : 'iknow_email',
          type : 'button',
          text : '联系我们',
          bodyStyle : 'email',
          useable : 'T',
	      handler : function(){
				top.location.href = "mailto:z00144534@notesmail.huawei.com";
		  }
        },
		{
		  id : 'iknow_search_txt',
          type:'button',
          text:'全文搜索:',
          bodyStyle:'',
		  useable : 'T'
        },
		{
		  id : 'iknow_search_input',
		  type : 'textfield',
		  text : '',
		  useable : 'T'
		},
		{
		  id : 'iknow_search_button',
          type:'button',
          text:'',
          bodyStyle:'search',
		  useable : 'T',
		  handler : function(){
			  var searchTxt = document.getElementById("iknow_search_input").value;
			  //mainWin.src = "/iKnow/bin/view/Main/WebSearch?test="+searchTxt; 
			  mainWin.src = "/iKnow/bin/view/Main/Search?text="+searchTxt; 
		  }
        },
		{
		  id : 'iknow_space',
          type:'button',
          text:'切换空间',
          bodyStyle:'space',
		  useable : 'T',
		  handler : function(){
			 alert("谢谢您的关注,该功能正在建设中!");
		  }
        },
		{
		  id : 'iknow_logout',
          type : 'button',
          text : '注销 '+username,
          bodyStyle : 'user',
          useable : 'T',
          handler : function(){
			 top.location.href = "/iKnow/bin/logout/XWiki/XWikiLogout?xredirect=%2FiKnow%2Ftreepanel%2Fframe.jsp";
          }
        },
		{
		  id : 'iknow_login',
		  type : 'button',
          text : '登录',
          bodyStyle : 'login',
          useable : 'T',
          handler : function(){
			 updateProperties();
			 top.location.href = "/iKnow/bin/login/XWiki/XWikiLogin?xredirect=%2FiKnow%2Ftreepanel%2Fframe.jsp?space="+spacename;
          }
		}];

	  toolbar.render();

	  toolbar.genAZ();

	  //根据isLogin显示或者隐藏工具条上的按钮
	  var widgets = menuItems;
	  for(var i = 0; i < widgets.length; i++){
		 var item = widgets[i];
		 if(isLogin){
			   if(item.id != loginHiddenItem){
				  toolbar.add(item);
				  toolbar.add('-');
			   }
		  }else{
			 var tmp = 1;
			 for(var j = 0 ; j < loginShowItems.length ; j++){
				if(item.id == loginShowItems[j]){
					tmp = 2;
				    break;
				}
			 }
			 if(tmp == 1){
				toolbar.add(item);
				toolbar.add('-');
			 }
		  }
	   }
		 
  });

  //更新属性值
  function updateProperties(){
	  fullname = window.parent.docname;
	  spacename = window.parent.space;
	  if(spacename=="null"){
		 spacename = "Main";
	  }	
	  docname = fullname.substring(fullname.indexOf(".")+1);
	  username = window.parent.username;
	  if(typeof username != 'undefined'){
		if(username != "XWiki.XWikiGuest"){
		    isLogin = 1;
		}
		if(username.indexOf(".") != -1){
			username = username.substring(username.indexOf(".")+1);
		}
	  }
  }
	
    </script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值