FoldingMenu.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //命名空间
  2. Namespace.register("U.Control.FoldMenu");
  3. /*
  4. //控件元素生成函数
  5. */
  6. U.Control.FoldMenu.Createframe = function (data, container) {
  7. if (data.length) {
  8. var nav = $$("div", { "class": "U_Control_FoldMenu_nav" }, container);
  9. var MainMenuWarp = $$("div", { "class": "U_Control_FoldMenu_main_menu" }, nav);
  10. U.Control.FoldMenu.CreateElement(data,MainMenuWarp);
  11. }
  12. }
  13. /*
  14. //控件元素生成函数
  15. */
  16. U.Control.FoldMenu.CreateElement = function (data, container) {
  17. var i;
  18. for (var i = 0; i < data.length; i++) {
  19. var a_menu_title = $$("a", { "class": "U_Control_FoldMenu_menu_title" }, container); //创建ayuans
  20. a_menu_title.onclick = function () { U.Control.FoldMenu.Lishow(this); } //赋值a元素点击事件
  21. //var img = $$("img",{"class":"U_Control_FoldMenu_Icon",'src':'img/JT.png'},a_menu_title);//创建控件菜单箭头元素
  22. data[i].submenu ? $$("img", { "class": "U_Control_FoldMenu_Icon", 'src': 'img/JT.png' }, a_menu_title) : "";
  23. var spna = $$("span", { "innerHTML": data[i].text }, a_menu_title); //创建控件菜单名字
  24. if (data[i].submenu) {
  25. var subMenu = $$("div", { "class": "U_Control_FoldMenu_subMenu", "style": { "display": "none", "padding-left": "10px"} }, container);
  26. U.Control.FoldMenu.CreateElement(data[i].submenu, subMenu);
  27. }
  28. }
  29. }
  30. /*
  31. //子菜单显示函数
  32. //e 事件源元素(event对象)
  33. */
  34. U.Control.FoldMenu.Lishow = function (e) {
  35. var div = e.nextSibling;
  36. if(div){
  37. if(div.style.display=="none"){
  38. div.style.display="block";
  39. U.Control.FoldMenu.TS(e,90);
  40. e.className +=" U_Control_FoldMenu_menu_title_active";
  41. }else{
  42. div.style.display="none";
  43. U.Control.FoldMenu.TS(e,0);
  44. e.className = "U_Control_FoldMenu_menu_title";
  45. }
  46. }
  47. }
  48. /*
  49. //图片旋转样式改变函数
  50. //目标对象
  51. //n 旋转度数
  52. */
  53. U.Control.FoldMenu.TS=function(e,n){
  54. e.getElementsByTagName("img")[0].style.webkitTransform="rotate("+n+"deg)";
  55. e.getElementsByTagName("img")[0].style.MozTransform="rotate("+n+"deg)";
  56. e.getElementsByTagName("img")[0].style.msTransform="rotate("+n+"deg)";
  57. e.getElementsByTagName("img")[0].style.OTransform="rotate("+n+"deg)";
  58. e.getElementsByTagName("img")[0].style.transform="rotate("+n+"deg)";
  59. }