暂无描述

contabs.min.js 8.7KB

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