navgation.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // 13通信G5-2张岚凯 15互联网G5-3揭以诚
  2. Namespace.register("U.Control.Navgation"); //注册命名空间;
  3. //生成导航条; logo图片自己设置,图片路径要是绝对路径 可以将不同板块放到 var con中
  4. U.Control.Navgation = function () {
  5. var g = $$("div", { "className": "navgation" }, document.body);
  6. var a = $$("div", { "className": "navgation_head" }, g);
  7. var nva_log = $$("span", { "className": 'navgation_headSpan' }, a);
  8. var lo = $$("div", { "className": "navgation_head_logo", "innerHTML": "LOGO" }, a);
  9. var logo = $$("img", { "className": "navgation_head_logo_img" }, lo);
  10. var le = $$("div", { "className": "navgation_head_left" }, a);
  11. var b = $$("ul", {}, le);
  12. var c = $$("li", { "innerHTML": "<a>首页</a>", "onclick": "U.Control.Navgation.update_content_first()" }, b);
  13. var d = $$("li", { "innerHTML": "<a>关于我们</a>", "onclick": "U.Control.Navgation.update_content_second()" }, b);
  14. var e = $$("li", { "innerHTML": "<a>服务中心</a>", "onclick": "U.Control.Navgation.update_content_third()" }, b);
  15. var f = $$("li", { "innerHTML": "<a>联系我们</a>", "onclick": "U.Control.Navgation.update_content_four()" }, b);
  16. var s = $$("div", { "className": "navgation_head_search" }, a);
  17. var simg = $$("img", { "src": "http://d.1473.cn/controls/pc/navgation/search_s.png" }, s);
  18. $$("img", { "src": "nva_log.png", "onclick": "U.Control.Navgation.menuopen()" }, nva_log);
  19. var sinput = $$("input", { "className": "search", "placeholder": "搜索" }, s);
  20. var right = $$("div", { "className": "navgation_head_right" }, a);
  21. var login = $$("div", { "className": "navgation_head_login", "innerHTML": "登录" }, right);
  22. var sign = $$("div", { "className": "navgation_head_register", "innerHTML": "注册" }, right);
  23. //var con = $$("div", { "className": "navgation_content", "innerHTML": "A", "id": "navgation_content" }, g);
  24. $$("meta", { "name": "viewport", content: "width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" }, document.head);
  25. $$("meta", { "name": "apple-mobile-web-app-capable", content: "yes;" }, document.head);
  26. $$("meta", { "name": "apple-mobile-web-app-status-bar-style", content: "black;" }, document.head);
  27. $$("meta", { "name": "apple-mobile-web-app-status-bar-style", content: "telephone=no;" }, document.head);
  28. var search = $$("span", { "className": "navgation_headSearch" }, a);
  29. $$("img", { "src": "sousuo.png" }, search);
  30. return g;
  31. }
  32. //更换内容;函数内容可以自行更换
  33. U.Control.Navgation.update_content_first = function () {
  34. $("#navgation_content")[0].innerHTML = 'A';
  35. }
  36. U.Control.Navgation.update_content_second = function () {
  37. $("#navgation_content")[0].innerHTML = 'B';
  38. }
  39. U.Control.Navgation.update_content_third = function () {
  40. $("#navgation_content")[0].innerHTML = 'C';
  41. }
  42. U.Control.Navgation.update_content_four = function () {
  43. $("#navgation_content")[0].innerHTML = 'D';
  44. }
  45. U.Control.Navgation.menuopen = function () {
  46. event.stopPropagation();
  47. $(".navgation_head_left")[0].style.display = "block";
  48. }
  49. U.Control.Navgation_close = function () {
  50. if (this.Tagname != "navgation_head_left") {
  51. $(".navgation_head_left")[0].style.display = "none";
  52. }
  53. };