ios_nav_expand.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 click",".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 .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. }else{
  41. $(".nav_add").show();
  42. $(this).addClass("active").html("完成");
  43. $(".nav_column").addClass("active sortable");
  44. $.getScript("trsTop/js/jquery-ui.js");
  45. $.getScript("trsTop/js/jquery-ui-mobile.js",function(){
  46. //var items = $(".sortable ul").sortable("option", "items");
  47. //$(".sortable ul").sortable("option", "items", "> li");
  48. $(".sortable ul").sortable({items: "> li.port"});
  49. $(".sortable ul").disableSelection();
  50. });
  51. $.getScript("trsTop/images/mui.min.js");
  52. $(".nav_column li .close_delete").show();
  53. $(".nav_add").hide();
  54. }
  55. });
  56. $(document).on("touchend",".mui-scroll iframe",function(){
  57. console.log(2)
  58. });
  59. $(document).on("click",".nav_add li",function(event){
  60. //event.preventDefault();
  61. //event.stopPropagation();
  62. var text = $(this).text(),
  63. num = parseInt(Math.random()*(1000-10+1)+10,10),
  64. leng = $("#sliderSegmentedControl .mui-scroll a").length,
  65. url = $(this).find("h1").attr("data-active-url");
  66. text = text.substr(1,100);
  67. $(this).remove();
  68. $add_info(text,num,leng,url);
  69. $nav_expand_no();
  70. });
  71. $(document).on("touchend",".nav_column li .close_delete",function(){
  72. var text = $(this).parent().find("h1").text(),
  73. url = $(this).parent().find("h1").attr("data-active-url");
  74. $(this).parent().hide();
  75. $(".nav_add ul").prepend("<li class='Unfinished'><i class='ico_add'>+</i><h1 data-active-url="+url+"></h1></li>");
  76. $(".nav_add ul li:eq(0) h1").html(text);
  77. $("#sliderSegmentedControl .mui-scroll a").each(function(){
  78. var t = $(this).text();
  79. if(t == text){
  80. var i = $(this).index();
  81. $(this).addClass("Unfinished");
  82. $(".mui-slider-group .mui-slider-item").eq(i).addClass("Unfinished");
  83. }
  84. });
  85. });
  86. });
  87. function $ui_sortable(){
  88. $(".ui-sortable li").each(function(){
  89. var t = $(this).find("h1").text();
  90. //console.log(t);
  91. $("#sliderSegmentedControl .mui-scroll a").each(function(){
  92. var uit = $(this).text(),
  93. href = $(this).attr("href"),
  94. index = $(this).index(),
  95. has = $(this).hasClass("mui-active");
  96. //console.log(uit);
  97. if(t == uit && has == true){
  98. $("#sliderSegmentedControl .mui-scroll").append("<a class='mui-control-item "+ 'mui-active' +"' href='"+ href +"'>" + uit + "</a>");
  99. $(this).remove();
  100. }
  101. if(t == uit && has != true){
  102. $("#sliderSegmentedControl .mui-scroll").append("<a class='mui-control-item' href='"+ href +"'>" + uit + "</a>");
  103. $(this).remove();
  104. }
  105. $(".mui-slider-group .mui-slider-item").each(function(){
  106. var ut = $(this).attr("id"),
  107. uh = $(this).html(),
  108. has = $(this).hasClass("mui-active");
  109. if(ut == uit && has == true){
  110. $(".mui-slider-group").append("<div id='"+ ut +"' class='mui-slider-item mui-control-content" + 'mui-active' + "'>" + uh + "</div>");
  111. $(this).remove();
  112. }
  113. if(ut == uit && has != true){
  114. $(".mui-slider-group").append("<div id='"+ ut +"' class='mui-slider-item mui-control-content'>" + uh + "</div>");
  115. $(this).remove();
  116. }
  117. });
  118. });
  119. });
  120. var l = $("#sliderSegmentedControl .mui-scroll a").length;
  121. $("#sliderSegmentedControl .mui-scroll a").each(function(){
  122. var uit = $(this).attr("data-active-id");
  123. if(uit == "占位"){
  124. console.log(uit)
  125. $(this).remove();
  126. $("#sliderSegmentedControl .mui-scroll a").eq(l-2).after("<a class='mui-control-item' data-active-id='占位'>&nbsp;&nbsp;&nbsp;&nbsp;</a>");
  127. }
  128. });
  129. }
  130. function $add_Unfinished(b){
  131. $(".nav_add ul li").each(function(){
  132. var has = $(this).hasClass("Unfinished");
  133. if(has == true && b == "return"){
  134. $(this).remove();
  135. }
  136. if(has == true && b == "complete"){
  137. $(this).removeClass("Unfinished");
  138. }
  139. });
  140. $("#sliderSegmentedControl .mui-scroll a").each(function(){
  141. var has = $(this).hasClass("Unfinished");
  142. if(has == true && b == "return"){
  143. $(this).removeClass("Unfinished");
  144. console.log(1)
  145. }
  146. if(has == true && b == "complete"){
  147. $(this).remove();
  148. console.log(2)
  149. }
  150. });
  151. $(".mui-slider-group .mui-slider-item").each(function(){
  152. var has = $(this).hasClass("Unfinished"),
  153. $mg = $("#slider .mui-slider-group");
  154. if(has == true && b == "return"){
  155. $(this).removeClass("Unfinished");
  156. console.log(1)
  157. }
  158. if(has == true && b == "complete"){
  159. $(this).remove();
  160. var i = $(this).hasClass("mui-active")
  161. if(i == true){
  162. $("#sliderSegmentedControl a").removeClass("mui-active").eq(0).addClass("mui-active");
  163. $mg.css({"transform":"translate3d(0px,0,0) translateZ(0px)"});
  164. }
  165. }
  166. });
  167. $(".nav_column ul li").each(function(){
  168. var vis = $(this).is(":visible"),
  169. ut = $(this).text();
  170. console.log(vis)
  171. if(vis == false && b == "complete"){
  172. $(this).remove();
  173. }
  174. if(ut == ""){
  175. $(this).remove();
  176. }
  177. });
  178. }
  179. function $add_info(a,b,c,d){
  180. var height_jquery = $("#mainFarm1").height();
  181. //$(".nav_column ul").append("<li class='port'><i class='close_delete'>x</i><h1 data-active-url="+d+">"+a+"</h1></li>");
  182. $(".nav_column ul").append("<li class='port'><i class='close_delete'>x</i><h1 data-active-url="+d+"></h1></li>");
  183. var sl = $(".nav_column ul li").length;
  184. $(".nav_column ul li").eq(sl-1).find("h1").html(a);
  185. //$("#sliderSegmentedControl .mui-scroll a").eq(c - 2).after("<a class='mui-control-item' href='#item"+b+"mobile'>"+a+"</a>");
  186. $("#sliderSegmentedControl .mui-scroll a").eq(c - 2).after("<a class='mui-control-item' href='#item"+b+"mobile'></a>");
  187. $("#sliderSegmentedControl .mui-scroll a").eq(c - 1).html(a);
  188. $(".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>");
  189. }
  190. function nav_return(){
  191. $(".nav_expand").slideUp();
  192. $(".nav_expand .sort_delete").removeClass("active").html("排序删除");
  193. $(".nav_column").removeClass("active");
  194. $(".nav_column li .close_delete").hide();
  195. $(".nav_add").show();
  196. $(".nav_column ul li").removeAttr("style");
  197. $add_Unfinished("return");
  198. }
  199. function $nav_expand_no(){
  200. var l = $(".nav_add ul li").length;
  201. if(l > 0){
  202. $(".nav_add > h1").html("点击添加更多栏目");
  203. }else{
  204. $(".nav_add > h1").html("无更多栏目");
  205. }
  206. }