contabs.min.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. var p = '<a href="javascript:;" class="active J_menuTab" data-id="' + o + '">' + l + ' <i class="fa fa-times-circle"></i></a>';
  125. $(".J_menuTab").removeClass("active");
  126. var n = '<iframe class="J_iframe" 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_iframe").each(function() {
  132. if ($(this).attr('src') == o) {
  133. $(this).attr('src',o).ready();
  134. return false;
  135. }
  136. });
  137. }
  138. return false
  139. }
  140. $(".J_menuItem").on("click", c);
  141. function h() {
  142. var m = $(this).parents(".J_menuTab").data("id");
  143. var l = $(this).parents(".J_menuTab").width();
  144. if ($(this).parents(".J_menuTab").hasClass("active")) {
  145. if ($(this).parents(".J_menuTab").next(".J_menuTab").size()) {
  146. var k = $(this).parents(".J_menuTab").next(".J_menuTab:eq(0)").data("id");
  147. $(this).parents(".J_menuTab").next(".J_menuTab:eq(0)").addClass("active");
  148. $(".J_mainContent .J_iframe").each(function() {
  149. if ($(this).data("id") == k) {
  150. $(this).show().siblings(".J_iframe").hide();
  151. return false
  152. }
  153. });
  154. var n = parseInt($(".page-tabs-content").css("margin-left"));
  155. if (n < 0) {
  156. $(".page-tabs-content").animate({
  157. marginLeft: (n + l) + "px"
  158. },
  159. "fast")
  160. }
  161. $(this).parents(".J_menuTab").remove();
  162. $(".J_mainContent .J_iframe").each(function() {
  163. if ($(this).data("id") == m) {
  164. $(this).remove();
  165. return false
  166. }
  167. })
  168. }
  169. if ($(this).parents(".J_menuTab").prev(".J_menuTab").size()) {
  170. var k = $(this).parents(".J_menuTab").prev(".J_menuTab:last").data("id");
  171. $(this).parents(".J_menuTab").prev(".J_menuTab:last").addClass("active");
  172. $(".J_mainContent .J_iframe").each(function() {
  173. if ($(this).data("id") == k) {
  174. $(this).show().siblings(".J_iframe").hide();
  175. return false
  176. }
  177. });
  178. $(this).parents(".J_menuTab").remove();
  179. $(".J_mainContent .J_iframe").each(function() {
  180. if ($(this).data("id") == m) {
  181. $(this).remove();
  182. return false
  183. }
  184. })
  185. }
  186. } else {
  187. $(this).parents(".J_menuTab").remove();
  188. $(".J_mainContent .J_iframe").each(function() {
  189. if ($(this).data("id") == m) {
  190. $(this).remove();
  191. return false
  192. }
  193. });
  194. g($(".J_menuTab.active"))
  195. }
  196. return false
  197. }
  198. $(".J_menuTabs").on("click", ".J_menuTab i", h);
  199. function i() {
  200. $(".page-tabs-content").children("[data-id]").not(":first").not(".active").each(function() {
  201. $('.J_iframe[data-id="' + $(this).data("id") + '"]').remove();
  202. $(this).remove()
  203. });
  204. $(".page-tabs-content").css("margin-left", "0")
  205. }
  206. $(".J_tabCloseOther").on("click", i);
  207. function j() {
  208. g($(".J_menuTab.active"))
  209. }
  210. $(".J_tabShowActive").on("click", j);
  211. function e() {
  212. if (!$(this).hasClass("active")) {
  213. var k = $(this).data("id");
  214. $(".J_mainContent .J_iframe").each(function() {
  215. if ($(this).data("id") == k) {
  216. $(this).show().siblings(".J_iframe").hide();
  217. return false
  218. }
  219. });
  220. $(this).addClass("active").siblings(".J_menuTab").removeClass("active");
  221. g(this)
  222. }
  223. }
  224. $(".J_menuTabs").on("click", ".J_menuTab", e);
  225. function d() {
  226. var l = $('.J_iframe[data-id="' + $(this).data("id") + '"]');
  227. var k = l.attr("src")
  228. }
  229. $(".J_menuTabs").on("dblclick", ".J_menuTab", d);
  230. $(".J_tabLeft").on("click", a);
  231. $(".J_tabRight").on("click", b);
  232. $(".J_tabCloseAll").on("click",
  233. function() {
  234. $(".page-tabs-content").children("[data-id]").not(":first").each(function() {
  235. $('.J_iframe[data-id="' + $(this).data("id") + '"]').remove();
  236. $(this).remove()
  237. });
  238. $(".page-tabs-content").children("[data-id]:first").each(function() {
  239. $('.J_iframe[data-id="' + $(this).data("id") + '"]').show();
  240. $(this).addClass("active")
  241. });
  242. $(".page-tabs-content").css("margin-left", "0")
  243. })
  244. });