nav_expand.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. $(function(){
  2. var a,
  3. one,
  4. two,
  5. three,
  6. four,
  7. oneh,
  8. onet;
  9. /*$(document).on("touchmove","nav_expand",function(event){
  10. event.preventDefault();
  11. event.stopPropagation();
  12. });*/
  13. $(document).on("touchend",".navmore",function(){
  14. var h = $(window).height(),
  15. navt = $(".nav_expand").css("top"),
  16. navn = navt.substring(0,2),
  17. navh = $(".nav_expand .nav_expand_head").height(),
  18. bnavh = $(".tabs-bottom .tab-nav").outerHeight(true);
  19. $(".nav_expand").slideDown()
  20. $(".nav_expand .nav_expand_body").css({"height":h - navn- navh - bnavh});
  21. openSelectPage=true;
  22. $nav_expand_no();
  23. });
  24. $(document).on("touchend",".nav_expand .ico_nav_return,.nav_expand .nav_expand_head > h1",function(){
  25. nav_return()
  26. });
  27. $(document).on("touchend",".nav_expand .sort_delete",function(){
  28. var has = $(this).hasClass("active");
  29. if(has == true){
  30. $(this).removeClass("active").html("排序删除");
  31. $(".nav_column").removeClass("active");
  32. $(".nav_column ul").removeClass("sortable");
  33. $(".nav_column li .close_delete").hide();
  34. $(".nav_add").show();
  35. $add_Unfinished("complete");
  36. $(".nav_column ul li").removeAttr("style");
  37. $ui_sortable();
  38. $(".sortable ul").sortable("destroy");
  39. $nav_expand_no();
  40. /*var sl = $("#sliderSegmentedControl .mui-scroll a").length;
  41. $("#sliderSegmentedControl .mui-scroll a").each(function(){
  42. var h = $(this).text(),
  43. i = $(this).index();
  44. if(h == "" && i != sl-1){
  45. $(this).remove();
  46. }
  47. })*/
  48. }else{
  49. $(".nav_add").show();
  50. $(this).addClass("active").html("完成");
  51. $(".nav_column").addClass("active sortable");
  52. $.getScript("trsTop/js/jquery-ui.js");
  53. $.getScript("trsTop/js/jquery-ui-mobile.js",function(){
  54. //var items = $(".sortable ul").sortable("option", "items");
  55. //$(".sortable ul").sortable("option", "items", "> li");
  56. $(".sortable ul").sortable({items: "> li.port"});
  57. $(".sortable ul").disableSelection();
  58. });
  59. $.getScript("trsTop/images/mui.min.js");
  60. $(".nav_column li .close_delete").show();
  61. $(".nav_add").hide();
  62. }
  63. });
  64. $(document).on("touchend",".mui-scroll iframe",function(){
  65. console.log(2)
  66. });
  67. $(document).on("mouseup",".nav_add li",function(event){
  68. //event.preventDefault();
  69. //event.stopPropagation();
  70. var text = $(this).text(),
  71. num = parseInt(Math.random()*(1000-10+1)+10,10),
  72. leng = $("#sliderSegmentedControl .mui-scroll a").length,
  73. url = $(this).find("h1").attr("data-active-url");
  74. text = text.substr(1,100);
  75. $(this).remove();
  76. $add_info(text,num,leng,url);
  77. $nav_expand_no();
  78. });
  79. $(document).on("touchend",".nav_column li .close_delete",function(){
  80. var text = $(this).parent().find("h1").text(),
  81. url = $(this).parent().find("h1").attr("data-active-url");
  82. mui.fire(plus.webview.currentWebview(),'alte',{id:url});
  83. $(this).parent().hide();
  84. $(".nav_add ul").prepend("<li class='Unfinished'><i class='ico_add'>+</i><h1 data-active-url="+url+">"+text+"</h1></li>");
  85. $("#sliderSegmentedControl .mui-scroll a").each(function(){
  86. var t = $(this).text();
  87. if(t == text){
  88. var i = $(this).index();
  89. $(this).addClass("Unfinished");
  90. $(".mui-slider-group .mui-slider-item").eq(i).addClass("Unfinished");
  91. }
  92. });
  93. });
  94. /* setInterval(function(){
  95. $("#mainFarm1").contents().find("head").append('<meta name="viewport" content="width=device-width,initial-scale=0.5,minimum-scale=0.5,maximum-scale=0.5,user-scalable=yes">');
  96. },300)*/
  97. });
  98. function $ui_sortable(){
  99. $(".ui-sortable li").each(function(){
  100. var t = $(this).find("h1").text();
  101. //console.log(t);
  102. $("#sliderSegmentedControl .mui-scroll a").each(function(){
  103. var uit = $(this).text(),
  104. href = $(this).attr("href"),
  105. index = $(this).index(),
  106. has = $(this).hasClass("mui-active");
  107. //读取配置表
  108. var curl = dicContainer['sy_tab'].toValue(uit);
  109. //console.log(uit);
  110. if(t == uit && has == true){
  111. $("#sliderSegmentedControl .mui-scroll").append("<a class='mui-control-item "+ 'mui-active' +"' href='"+ href +"' data-wid='"+curl+"'>" + uit + "</a>");
  112. $(this).remove();
  113. }
  114. if(t == uit && has != true){
  115. $("#sliderSegmentedControl .mui-scroll").append("<a class='mui-control-item' href='"+ href +"' data-wid='"+curl+"'>" + uit + "</a>");
  116. $(this).remove();
  117. }
  118. $(".mui-slider-group .mui-slider-item").each(function(){
  119. var ut = $(this).attr("id"),
  120. uh = $(this).html(),
  121. has = $(this).hasClass("mui-active");
  122. if(ut == uit && has == true){
  123. $(".mui-slider-group").append("<div id='"+ ut +"' class='mui-slider-item mui-control-content" + 'mui-active' + "'>" + uh + "</div>");
  124. $(this).remove();
  125. }
  126. if(ut == uit && has != true){
  127. $(".mui-slider-group").append("<div id='"+ ut +"' class='mui-slider-item mui-control-content'>" + uh + "</div>");
  128. $(this).remove();
  129. }
  130. });
  131. });
  132. });
  133. var l = $("#sliderSegmentedControl .mui-scroll a").length;
  134. $("#sliderSegmentedControl .mui-scroll a").each(function(){
  135. var uit = $(this).attr("data-active-id");
  136. if(uit == "占位"){
  137. console.log(uit)
  138. $(this).remove();
  139. $("#sliderSegmentedControl .mui-scroll a").eq(l-2).after("<a class='mui-control-item' data-active-id='占位'>&nbsp;&nbsp;&nbsp;&nbsp;</a>");
  140. }
  141. });
  142. }
  143. function $add_Unfinished(b){
  144. $(".nav_add ul li").each(function(){
  145. var has = $(this).hasClass("Unfinished");
  146. if(has == true && b == "return"){
  147. $(this).remove();
  148. }
  149. if(has == true && b == "complete"){
  150. $(this).removeClass("Unfinished");
  151. }
  152. });
  153. $("#sliderSegmentedControl .mui-scroll a").each(function(){
  154. var has = $(this).hasClass("Unfinished");
  155. if(has == true && b == "return"){
  156. $(this).removeClass("Unfinished");
  157. console.log(1)
  158. }
  159. if(has == true && b == "complete"){
  160. $(this).remove();
  161. console.log(2)
  162. }
  163. });
  164. $(".mui-slider-group .mui-slider-item").each(function(){
  165. var has = $(this).hasClass("Unfinished"),
  166. $mg = $("#slider .mui-slider-group");
  167. if(has == true && b == "return"){
  168. $(this).removeClass("Unfinished");
  169. console.log(1)
  170. }
  171. if(has == true && b == "complete"){
  172. $(this).remove();
  173. var i = $(this).hasClass("mui-active")
  174. if(i == true){
  175. $("#sliderSegmentedControl a").removeClass("mui-active").eq(0).addClass("mui-active");
  176. $mg.css({"transform":"translate3d(0px,0,0) translateZ(0px)"});
  177. }
  178. }
  179. });
  180. $(".nav_column ul li").each(function(){
  181. var vis = $(this).is(":visible");
  182. // console.log(vis)
  183. if(vis == false && b == "complete"){
  184. $(this).remove();
  185. }
  186. });
  187. }
  188. function $add_info(a,b,c,d){
  189. var itemStr = getItemStr();
  190. re = new RegExp('"', "g");
  191. var tempArr = itemStr.replace(re,'').split(",");
  192. var inArrIndex = $.inArray(d, tempArr);
  193. if(inArrIndex<0){
  194. tempArr.push(d);
  195. //alert(tempArr);
  196. localStorage.setItem("initItem",tempArr);
  197. }
  198. var height_jquery = $("#mainFarm1").height();
  199. //$(".nav_column ul").append("<li class='port'><i class='close_delete'>x</i><h1 data-active-url="+d+">"+a+"</h1></li>");
  200. $(".nav_column ul").append("<li class='port'><i class='close_delete'>x</i><h1 data-active-url="+d+"></h1></li>");
  201. var sl = $(".nav_column ul li").length;
  202. $(".nav_column ul li").eq(sl-1).find("h1").html(a);
  203. //$("#sliderSegmentedControl .mui-scroll a").eq(c - 2).after("<a class='mui-control-item' href='#item"+b+"mobile'>"+a+"</a>");
  204. $("#sliderSegmentedControl .mui-scroll a").eq(c - 2).after("<a class='mui-control-item' href='#item"+b+"mobile' data-wid='"+d+"'></a>");
  205. $("#sliderSegmentedControl .mui-scroll a").eq(c - 1).html(a);
  206. /*$("#sliderSegmentedControl .mui-scroll a").each(function(){
  207. var h = $(this).text(),
  208. i = $(this).index();
  209. if(h == "" && i != sl-1){
  210. $(this).remove();
  211. }
  212. })*/
  213. $(".mui-slider-group").append("<div id='item"+b+"mobile' data-active-id="+b+" class='mui-slider-item mui-control-content'><div class='mui-scroll-wrapper'><div class='mui-scroll'><iframe id='mainFarm1' name='iframeAll' width='100%' height='"+height_jquery+"' src='"+d+"' seamless frameborder='0'></iframe></div></div></div>");
  214. }
  215. function nav_return(){
  216. //隐藏webview
  217. mui.fire(plus.webview.currentWebview(),'openWvg');
  218. $(".nav_expand").slideUp();
  219. $(".nav_expand .sort_delete").removeClass("active").html("排序删除");
  220. $(".nav_column").removeClass("active");
  221. $(".nav_column li .close_delete").hide();
  222. $(".nav_add").show();
  223. $(".nav_column ul li").removeAttr("style");
  224. $add_Unfinished("return");
  225. }
  226. function $nav_expand_no(){
  227. //显示webview
  228. mui.fire(plus.webview.currentWebview(),'closeWvg');
  229. // mui.fire(plus.webview.currentWebview(),'alte',{id:'l'});
  230. var l = $(".nav_add ul li").length;
  231. if(l > 0){
  232. $(".nav_add > h1").html("点击添加更多栏目");
  233. }else{
  234. $(".nav_add > h1").html("无更多栏目");
  235. }
  236. }