bar.js
上传用户:yfdli66
上传日期:2010-02-20
资源大小:47k
文件大小:8k
源码类别:

JavaScript

开发平台:

JavaScript

  1. /*------------------------------------------------------------------------------
  2. +                        工具条                               +
  3. +                                                        +
  4. +                           +
  5. -------------------------------------------------------------------------------*/
  6. function mu(k){
  7. this.sel_head_index=-1
  8. this.css=new Array()
  9. this.css["head_df"]="margin:1;padding:3;padding-left:7;padding-right:7"
  10. this.css["head_fc"]="padding:2;padding-left:6;padding-right:6;border:1px solid white;border-right:1px solid #808080;border-bottom:1px solid #808080"
  11. this.css["head_hit"]="padding:2;padding-left:6;padding-right:6;border:1px solid #808080;border-right:1px solid white;border-bottom:1px solid white"
  12. this.ini=function(k){
  13. var l,i,a=k.split(";"),s_caption
  14. l="<span style='position:absolute;z-index:100;background:buttonface;width:100%;height:23;border:1px solid white;border-right:1px solid #808080;border-bottom:1px solid #808080'>
  15. <table id=o_menu onmouseover='mu1.m_over(event.srcElement)' onmouseout='mu1.m_out(event.srcElement)' onmousedown='mu1.m_down(event.srcElement)' cellpadding=0 cellspacing=0><tr>"
  16. for(i in a){
  17. a[i]=a[i].split(":")
  18. s_caption=a[i][0]
  19. if(s_caption.indexOf("&")>-1)
  20. s_caption=s_caption.replace("&","(<u>")+"</u>)"
  21. l+="<td val='"+a[i][0].slice(0,(a[i][0]+"&").indexOf("&"))+"' list='"+a[i][1]+"' style='"+this.css["head_df"]+"'>"+s_caption+"</td>"
  22. }
  23. l+="</tr></table></span>"
  24. l+="<span id=o_menu_op style='display:none;z-index:200;padding:1;position:absolute;top:21;width:140;height:20;background:buttonface;border:2px outset;filter:progid:DXImageTransform.Microsoft.Shadow(color=#404040,direction=135,Strength=3)'>
  25. </span>"
  26. document.write(l)
  27. }
  28. this.ini(k)
  29. this.m_over=function(ee){
  30. if(ee.tagName=="U")
  31. ee=ee.parentElement
  32. if(ee.tagName=="TD"){
  33. if(this.sel_head_index==-1)
  34. ee.style.cssText=this.css["head_fc"]
  35. else if(this.sel_head_index!=ee.cellIndex){
  36. o_menu.rows(0).cells(this.sel_head_index).style.cssText=this.css["head_df"]
  37. this.sel_head_index=ee.cellIndex
  38. this.m_down(o_menu.rows(0).cells(this.sel_head_index))
  39. }
  40. }
  41. }
  42. this.m_out=function(ee){
  43. if(ee.tagName=="U")
  44. ee=ee.parentElement
  45. if(ee.tagName=="TD"&&this.sel_head_index==-1){
  46. ee.style.cssText=this.css["head_df"]
  47. }
  48. }
  49. this.m_down=function(ee){
  50. if(ee.tagName=="U")
  51. ee=ee.parentElement
  52. if(ee.tagName=="TD"){
  53. this.sel_head_index=ee.cellIndex
  54. ee.style.cssText=this.css["head_hit"]
  55. var l="",a=ee.list.split(","),i,s_caption
  56. for(i in a){
  57. if(a[i]=="-")
  58. l+="<hr style='border-top:1px solid #808080;border-bottom:1px solid white'>"
  59. else{
  60. s_caption=a[i]
  61. if(s_caption.indexOf("&")>-1)
  62. s_caption=s_caption.replace("&","(<u>")+"</u>)"
  63. l+="<div onmouseup="mu1.sel('menu_"+ee.val+"_"+a[i].slice(0,(a[i]+"&").indexOf("&"))+"')" onmouseover="this.style.color='white';this.style.background='#0A246A'" onmouseout="this.style.color='';this.style.background='buttonface'" style=background:buttonface;padding:2;padding-left:16>"+s_caption+"</div>"
  64. }
  65. }
  66. o_menu_op.parentElement.style.left=ee.offsetLeft
  67. o_menu_op.innerHTML=l
  68. o_menu_op.style.display=""
  69. this.status="hit"
  70. }
  71. }
  72. this.sel=function(k){
  73. o_menu_op.style.display="none"
  74. o_menu.rows(0).cells(this.sel_head_index).style.cssText=this.css["head_df"]
  75. this.sel_head_index=-1
  76. sysMenu_click(k)
  77. }
  78. this.blur=function(){
  79. if(this.sel_head_index==-1)
  80. return
  81. o_menu_op.style.display="none"
  82. o_menu.rows(0).cells(this.sel_head_index).style.cssText=this.css["head_df"]
  83. this.sel_head_index=-1
  84. }
  85. }
  86. function bar(k){
  87. this.css=new Array()
  88. this.css["df"]="margin:1"
  89. this.css["up"]="border:1px solid white;border-right:1px solid #808080;border-bottom:1px solid #808080"
  90. this.css["down"]="border:1px solid #808080;border-right:1px solid white;border-bottom:1px solid white"
  91. this.ini=function(k){
  92. var l,a=k.split(","),i
  93. l="<span  style='z-index:100;background:buttonface;position:absolute;left:0;top:0;width:995;height:27;border-bottom:1px solid #404040'>
  94. <span style='width:100%;height:100%;border:1px solid white;border-right:1px solid #808080;border-bottom:1px solid #808080'>
  95. <img align=absmiddle src=image/split2.gif>"
  96. for(i in a){
  97. if(a[i]=="|")
  98. l+="<img align=absmiddle src=images/workflow/split.gif>"
  99. else
  100. l+="<img val='"+a[i]+"' align=absmiddle src=images/workflow/"+a[i]+".gif onmouseover=bar1.m_over(event.srcElement) onmouseout=bar1.m_out(event.srcElement) onmousedown=bar1.m_down(event.srcElement) onmouseup=bar1.m_up(event.srcElement) style='"+this.css["df"]+"'>"
  101. }
  102. l+="</span></span>"
  103. document.write(l)
  104. }
  105. this.ini(k)
  106. this.m_over=function(ee){
  107. ee.style.cssText=this.css["up"]
  108. }
  109. this.m_out=function(ee){
  110. ee.style.cssText=this.css["df"]
  111. }
  112. this.m_down=function(ee){
  113. ee.style.cssText=this.css["down"]
  114. }
  115. this.m_up=function(ee){
  116. ee.style.cssText=this.css["up"]
  117. try{
  118. sysMenu_click("bar_"+ee.val)
  119. }catch(e){}
  120. }
  121. }
  122. var toolBarButtonCss=new Array();
  123. toolBarButtonCss["df"]  =  "margin:1";
  124. toolBarButtonCss["up"]  =  "border:1px solid white;"+
  125.             "border-right:1px solid #808080;"+
  126.                                "border-bottom:1px solid #808080";
  127. toolBarButtonCss["down"] = "background:#e0e0e0;"+
  128.             "border:1px solid #808080;"+
  129.                                "border-right:1px solid white;"+
  130.                                "border-bottom:1px solid white";
  131. //speed工具栏按钮的点击
  132. function speedToolBarButtonClick(aObj) {
  133. if ( !(aObj.isDown == true) ) {
  134. //重置所有的按钮
  135. resetAllToolBarButton(aObj.parentElement);
  136. //设置当前按钮
  137.          aObj.style.cssText = toolBarButtonCss["down"];
  138. aObj.isDown = true;
  139. try{
  140. leftToolBarClick( aObj.id.replace("btn_","") );
  141. }catch(e){}
  142. }
  143. }
  144. //speed工具栏按钮的onmouseover
  145. function speedToolBarButtonOver(aObj) {
  146.         if ( !(aObj.isDown == true) ) {
  147. aObj.style.cssText = toolBarButtonCss["up"]
  148.         }
  149. }
  150. //speed工具栏按钮的onmouseout
  151. function speedToolBarButtonOut(aObj) {
  152.         if ( !(aObj.isDown == true) ) {
  153. aObj.style.cssText = toolBarButtonCss["df"]
  154.         }
  155. }
  156. //重置所有的按钮
  157. function resetAllToolBarButton(aObj) {
  158. for (var i=0;i<aObj.children.length;i++) {
  159. aObj.children[i].style.cssText = toolBarButtonCss["df"];
  160. aObj.children[i].isDown = false;
  161. }
  162. }
  163. //工具条类
  164. function ToolBar(aStrList,left,top,width,height) {
  165. //property
  166. this.toolBarName;
  167. //constructor
  168. this.create = create;
  169. this.create();
  170. //method
  171. this.clickBtn = clickBtn;
  172. function create() {
  173. var str,a=aStrList.split(",");
  174. //工具条样式
  175. var spnStyle =  "position:absolute;"+
  176. "left:"+left+";"+
  177. "top:"+top+";"+
  178. "width:"+width+";"+
  179. "height:"+height+";"+
  180. "padding:6;"+
  181. "z-index:100;"+
  182. "border-left:2px outset;"+
  183. "border-top:2px outset;"+
  184. "border-right:2px outset;"+
  185. "border-bottom:2px outset;"+
  186. "background:buttonface";
  187. this.toolBarName = ( ("tbar_"+Math.random()).replace(".","") ).substr(0,10);
  188. //输出
  189. str="<span id='"+this.toolBarName+"' onselectstart="return false"  style='"+spnStyle+"'>";
  190. for(var i=0;i<a.length;i++){
  191. if (a[i]=="|") {
  192. str+="<img align=absmiddle src=image/split.gif>";
  193. } else {
  194. var btnName = "btn_"+a[i];
  195. str  += " <img "+
  196.     " isDown='false' "+
  197.                         " onmouseover ='speedToolBarButtonOver(this)' "+
  198.     " onmouseout ='speedToolBarButtonOut(this)' "+
  199.     " onclick = 'speedToolBarButtonClick(this)' "+
  200.     " name='"+btnName+"' "+
  201.     " id='"+btnName+"' "+
  202.             " style='"+toolBarButtonCss["df"]+
  203.     "' src='images/workflow/"+a[i]+".gif' > ";
  204. }
  205. }
  206. str+="</span>"
  207. document.write(str);
  208. }
  209. function clickBtn(i) {
  210. eval(this.toolBarName).children[i].click();
  211. }
  212. }