Ei kuvausta

contabs.min.js 8.7KB

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