12345市长热线标准版-前端

contabs.min.js 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. $(function() {
  2. function f(l) {
  3. var k = 0;
  4. $(l).each(function() {
  5. k += $(this).outerWidth(true)
  6. });
  7. return k
  8. }
  9. function g(n) {
  10. var o = f($(n).prevAll()),
  11. q = f($(n).nextAll());
  12. var l = f($(".content-tabs").children().not(".J_menuTabs"));
  13. var k = $(".content-tabs").outerWidth(true) - l;
  14. var p = 0;
  15. if($(".page-tabs-content").outerWidth() < k) {
  16. p = 0
  17. } else {
  18. if(q <= (k - $(n).outerWidth(true) - $(n).next().outerWidth(true))) {
  19. if((k - $(n).next().outerWidth(true)) > q) {
  20. p = o;
  21. var m = n;
  22. while((p - $(m).outerWidth()) > ($(".page-tabs-content").outerWidth() - k)) {
  23. p -= $(m).prev().outerWidth();
  24. m = $(m).prev()
  25. }
  26. }
  27. } else {
  28. if(o > (k - $(n).outerWidth(true) - $(n).prev().outerWidth(true))) {
  29. p = o - $(n).prev().outerWidth(true)
  30. }
  31. }
  32. }
  33. $(".page-tabs-content").animate({
  34. marginLeft: 0 - p + "px"
  35. },
  36. "fast")
  37. }
  38. function a() {
  39. var o = Math.abs(parseInt($(".page-tabs-content").css("margin-left")));
  40. var l = f($(".content-tabs").children().not(".J_menuTabs"));
  41. var k = $(".content-tabs").outerWidth(true) - l;
  42. var p = 0;
  43. if($(".page-tabs-content").width() < k) {
  44. return false
  45. } else {
  46. var m = $(".J_menuTab:first");
  47. var n = 0;
  48. while((n + $(m).outerWidth(true)) <= o) {
  49. n += $(m).outerWidth(true);
  50. m = $(m).next()
  51. }
  52. n = 0;
  53. if(f($(m).prevAll()) > k) {
  54. while((n + $(m).outerWidth(true)) < (k) && m.length > 0) {
  55. n += $(m).outerWidth(true);
  56. m = $(m).prev()
  57. }
  58. p = f($(m).prevAll())
  59. }
  60. }
  61. $(".page-tabs-content").animate({
  62. marginLeft: 0 - p + "px"
  63. },
  64. "fast")
  65. }
  66. function b() {
  67. var o = Math.abs(parseInt($(".page-tabs-content").css("margin-left")));
  68. var l = f($(".content-tabs").children().not(".J_menuTabs"));
  69. var k = $(".content-tabs").outerWidth(true) - l;
  70. var p = 0;
  71. if($(".page-tabs-content").width() < k) {
  72. return false
  73. } else {
  74. var m = $(".J_menuTab:first");
  75. var n = 0;
  76. while((n + $(m).outerWidth(true)) <= o) {
  77. n += $(m).outerWidth(true);
  78. m = $(m).next()
  79. }
  80. n = 0;
  81. while((n + $(m).outerWidth(true)) < (k) && m.length > 0) {
  82. n += $(m).outerWidth(true);
  83. m = $(m).next()
  84. }
  85. p = f($(m).prevAll());
  86. if(p > 0) {
  87. $(".page-tabs-content").animate({
  88. marginLeft: 0 - p + "px"
  89. },
  90. "fast")
  91. }
  92. }
  93. }
  94. $(".J_menuItem").each(function(k) {
  95. if(!$(this).attr("data-index")) {
  96. $(this).attr("data-index", k)
  97. }
  98. });
  99. function c() {
  100. var o = $(this).attr("href"),
  101. m = $(this).data("index"),
  102. l = $.trim($(this).text()),
  103. k = true;
  104. if(o == undefined || $.trim(o).length == 0) {
  105. return false
  106. }
  107. $(".J_menuTab").each(function() {
  108. if($(this).data("id") == o) {
  109. if(!$(this).hasClass("active")) {
  110. $(this).addClass("active").siblings(".J_menuTab").removeClass("active");
  111. g(this);
  112. $(".J_mainContent .J_iframe").each(function() {
  113. if($(this).data("id") == o) {
  114. $(this).show().siblings(".J_iframe").hide();
  115. return false
  116. }
  117. })
  118. }
  119. k = false;
  120. return false;
  121. }
  122. });
  123. if(k) {
  124. if(o == './TelCall/zxKong.html' || o.substring(0,28) == './callScreen/callScreen.html') {
  125. console.log(o)
  126. var p = '<a href="javascript:;" class="active J_menuTab" data-id="' + o + '">' + l + ' <i class="fa fa-times-circle"></i></a>';
  127. $(".J_menuTab").removeClass("active");
  128. var n = '<iframe class="J_iframe J_iframeNew" name="iframe' + m + '" width="100%" height="100%" src="' + o + '" frameborder="0" data-id="' + o + '" seamless></iframe>';
  129. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(n);
  130. $(".J_menuTabs .page-tabs-content").append(p);
  131. g($(".J_menuTab.active"))
  132. } else {
  133. $(".J_mainContent .J_iframe0").show();
  134. $(".J_mainContent .J_iframe0").attr("src", o);
  135. if(o !== './TelCall/zxKong.html') {
  136. $(".J_menuTab").removeClass("active");
  137. $(".J_menuTab").eq(0).addClass("active").text(l);
  138. $(".J_menuTab.active").attr("data-id",o);
  139. }
  140. }
  141. }
  142. return false
  143. }
  144. $(".J_menuItem").on("click", c);
  145. function h() {
  146. var m = $(this).parents(".J_menuTab").data("id");
  147. var l = $(this).parents(".J_menuTab").width();
  148. if($(this).parents(".J_menuTab").hasClass("active")) {
  149. if($(this).parents(".J_menuTab").next(".J_menuTab").size()) {
  150. var k = $(this).parents(".J_menuTab").next(".J_menuTab:eq(0)").data("id");
  151. $(this).parents(".J_menuTab").next(".J_menuTab:eq(0)").addClass("active");
  152. $(".J_mainContent .J_iframe").each(function() {
  153. if($(this).data("id") == k) {
  154. $(this).show().siblings(".J_iframe").hide();
  155. return false
  156. }
  157. });
  158. var n = parseInt($(".page-tabs-content").css("margin-left"));
  159. if(n < 0) {
  160. $(".page-tabs-content").animate({
  161. marginLeft: (n + l) + "px"
  162. },
  163. "fast")
  164. }
  165. $(this).parents(".J_menuTab").remove();
  166. $(".J_mainContent .J_iframe").each(function() {
  167. if($(this).data("id") == m) {
  168. $(this).remove();
  169. return false
  170. }
  171. })
  172. }
  173. if($(this).parents(".J_menuTab").prev(".J_menuTab").size()) {
  174. var k = $(this).parents(".J_menuTab").prev(".J_menuTab:last").data("id");
  175. $(this).parents(".J_menuTab").prev(".J_menuTab:last").addClass("active");
  176. $(".J_mainContent .J_iframe").each(function() {
  177. if($(this).data("id") == k) {
  178. $(this).show().siblings(".J_iframe").hide();
  179. return false
  180. }
  181. });
  182. $(this).parents(".J_menuTab").remove();
  183. $(".J_mainContent .J_iframe").each(function() {
  184. if($(this).data("id") == m) {
  185. $(this).remove();
  186. return false
  187. }
  188. })
  189. }
  190. } else {
  191. $(this).parents(".J_menuTab").remove();
  192. $(".J_mainContent .J_iframe").each(function() {
  193. if($(this).data("id") == m) {
  194. $(this).remove();
  195. return false
  196. }
  197. });
  198. g($(".J_menuTab.active"))
  199. }
  200. return false
  201. }
  202. $(".J_menuTabs").on("click", ".J_menuTab i", h);
  203. function i() {
  204. $(".page-tabs-content").children("[data-id]").not(":first").not(".active").each(function() {
  205. $('.J_iframe[data-id="' + $(this).data("id") + '"]').remove();
  206. $(this).remove()
  207. });
  208. $(".page-tabs-content").css("margin-left", "0")
  209. }
  210. $(".J_tabCloseOther").on("click", i);
  211. function j() {
  212. g($(".J_menuTab.active"))
  213. }
  214. $(".J_tabShowActive").on("click", j);
  215. function e() {
  216. if(!$(this).hasClass("active")) {
  217. var k = $(this).data("id");
  218. // console.log( k)
  219. $(".J_mainContent .J_iframe").each(function() {
  220. if($(this).data("id") == k) {
  221. $(this).show().siblings(".J_iframe").hide();
  222. return false
  223. }
  224. });
  225. $(this).addClass("active").siblings(".J_menuTab").removeClass("active");
  226. g(this)
  227. }
  228. }
  229. $(".J_menuTabs").on("click", ".J_menuTab", e);
  230. function d() {
  231. var l = $('.J_iframe[data-id="' + $(this).data("id") + '"]');
  232. var k = l.attr("src")
  233. }
  234. $(".J_menuTabs").on("dblclick", ".J_menuTab", d);
  235. $(".J_tabLeft").on("click", a);
  236. $(".J_tabRight").on("click", b);
  237. $(".J_tabCloseAll").on("click",
  238. function() {
  239. $(".page-tabs-content").children("[data-id]").not(":first").each(function() {
  240. $('.J_iframe[data-id="' + $(this).data("id") + '"]').remove();
  241. $(this).remove()
  242. });
  243. $(".page-tabs-content").children("[data-id]:first").each(function() {
  244. $('.J_iframe[data-id="' + $(this).data("id") + '"]').show();
  245. $(this).addClass("active")
  246. });
  247. $(".page-tabs-content").css("margin-left", "0")
  248. })
  249. });