H-ui.admin.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*H-ui.admin.js v2.3.1 date:15:42 2015.08.19 by:guojunhui*/
  2. /*获取顶部选项卡总长度*/
  3. function tabNavallwidth(){
  4. var taballwidth=0,
  5. $tabNav = $(".acrossTab"),
  6. $tabNavWp = $(".Hui-tabNav-wp"),
  7. $tabNavitem = $(".acrossTab li"),
  8. $tabNavmore =$(".Hui-tabNav-more");
  9. if (!$tabNav[0]){return}
  10. $tabNavitem.each(function(index, element) {
  11. taballwidth+=Number(parseFloat($(this).width()+60))});
  12. $tabNav.width(taballwidth+25);
  13. var w = $tabNavWp.width();
  14. if(taballwidth+25>w){
  15. $tabNavmore.show()}
  16. else{
  17. $tabNavmore.hide();
  18. $tabNav.css({left:0})}
  19. }
  20. /*左侧菜单响应式*/
  21. function Huiasidedisplay(){
  22. if($(window).width()>=768){
  23. $(".Hui-aside").show()
  24. }
  25. }
  26. function getskincookie(){
  27. var v = getCookie("Huiskin");
  28. if(v==null||v==""){
  29. v="default";
  30. }
  31. $("#skin").attr("href","skin/"+v+"/skin.css");
  32. }
  33. $(function(){
  34. getskincookie();
  35. //layer.config({extend: 'extend/layer.ext.js'});
  36. Huiasidedisplay();
  37. var resizeID;
  38. $(window).resize(function(){
  39. clearTimeout(resizeID);
  40. resizeID = setTimeout(function(){
  41. Huiasidedisplay();
  42. },500);
  43. });
  44. $(".Hui-nav-toggle").click(function(){
  45. $(".Hui-aside").slideToggle();
  46. });
  47. $(".Hui-aside").on("click",".menu_dropdown dd li a",function(){
  48. if($(window).width()<768){
  49. $(".Hui-aside").slideToggle();
  50. }
  51. });
  52. /*左侧菜单*/
  53. $.Huifold(".menu_dropdown dl dt",".menu_dropdown dl dd","fast",1,"click");
  54. /*选项卡导航*/
  55. $(".Hui-aside").on("click",".menu_dropdown a",function(){
  56. if($(this).attr('_href')){
  57. var bStop=false;
  58. var bStopIndex=0;
  59. var _href=$(this).attr('_href');
  60. var _titleName=$(this).html();
  61. var topWindow=$(window.parent.document);
  62. var show_navLi=topWindow.find("#min_title_list li");
  63. show_navLi.each(function() {
  64. if($(this).find('span').attr("data-href")==_href){
  65. bStop=true;
  66. bStopIndex=show_navLi.index($(this));
  67. return false;
  68. }
  69. });
  70. if(!bStop){
  71. creatIframe(_href,_titleName);
  72. min_titleList();
  73. }
  74. else{
  75. show_navLi.removeClass("active").eq(bStopIndex).addClass("active");
  76. var iframe_box=topWindow.find("#iframe_box");
  77. iframe_box.find(".show_iframe").hide().eq(bStopIndex).show().find("iframe").attr("src",_href);
  78. }
  79. }
  80. });
  81. function min_titleList(){
  82. var topWindow=$(window.parent.document);
  83. var show_nav=topWindow.find("#min_title_list");
  84. var aLi=show_nav.find("li");
  85. };
  86. function creatIframe(href,titleName){
  87. var topWindow=$(window.parent.document);
  88. var show_nav=topWindow.find('#min_title_list');
  89. show_nav.find('li').removeClass("active");
  90. var iframe_box=topWindow.find('#iframe_box');
  91. show_nav.append('<li class="active"><span data-href="'+href+'">'+titleName+'</span><i></i><em></em></li>');
  92. tabNavallwidth();
  93. var iframeBox=iframe_box.find('.show_iframe');
  94. iframeBox.hide();
  95. iframe_box.append('<div class="show_iframe"><div class="loading"></div><iframe frameborder="0" src='+href+'></iframe></div>');
  96. var showBox=iframe_box.find('.show_iframe:visible');
  97. showBox.find('iframe').attr("src",href).load(function(){
  98. showBox.find('.loading').hide();
  99. });
  100. }
  101. var num=0;
  102. var oUl=$("#min_title_list");
  103. var hide_nav=$("#Hui-tabNav");
  104. $(document).on("click","#min_title_list li",function(){
  105. var bStopIndex=$(this).index();
  106. var iframe_box=$("#iframe_box");
  107. $("#min_title_list li").removeClass("active").eq(bStopIndex).addClass("active");
  108. iframe_box.find(".show_iframe").hide().eq(bStopIndex).show();
  109. });
  110. $(document).on("click","#min_title_list li i",function(){
  111. var aCloseIndex=$(this).parents("li").index();
  112. $(this).parent().remove();
  113. $('#iframe_box').find('.show_iframe').eq(aCloseIndex).remove();
  114. num==0?num=0:num--;
  115. tabNavallwidth();
  116. });
  117. $(document).on("dblclick","#min_title_list li",function(){
  118. var aCloseIndex=$(this).index();
  119. var iframe_box=$("#iframe_box");
  120. if(aCloseIndex>0){
  121. $(this).remove();
  122. $('#iframe_box').find('.show_iframe').eq(aCloseIndex).remove();
  123. num==0?num=0:num--;
  124. $("#min_title_list li").removeClass("active").eq(aCloseIndex-1).addClass("active");
  125. iframe_box.find(".show_iframe").hide().eq(aCloseIndex-1).show();
  126. tabNavallwidth();
  127. }else{
  128. return false;
  129. }
  130. });
  131. tabNavallwidth();
  132. $('#js-tabNav-next').click(function(){
  133. num==oUl.find('li').length-1?num=oUl.find('li').length-1:num++;
  134. toNavPos();
  135. });
  136. $('#js-tabNav-prev').click(function(){
  137. num==0?num=0:num--;
  138. toNavPos();
  139. });
  140. function toNavPos(){
  141. oUl.stop().animate({'left':-num*100},100);
  142. }
  143. /*换肤*/
  144. $("#Hui-skin .dropDown-menu a").click(function(){
  145. var v = $(this).attr("data-val");
  146. setCookie("Huiskin", v);
  147. $("#skin").attr("href","skin/"+v+"/skin.css");
  148. });
  149. });
  150. /*弹出层*/
  151. /*
  152. 参数解释:
  153. title 标题
  154. url 请求的url
  155. id 需要操作的数据id
  156. w 弹出层宽度(缺省调默认值)
  157. h 弹出层高度(缺省调默认值)
  158. */
  159. function layer_show(title,url,w,h){
  160. if (title == null || title == '') {
  161. title=false;
  162. };
  163. if (url == null || url == '') {
  164. url="404.html";
  165. };
  166. if (w == null || w == '') {
  167. w=800;
  168. };
  169. if (h == null || h == '') {
  170. h=($(window).height() - 50);
  171. };
  172. layer.open({
  173. type: 2,
  174. area: [w+'px', h +'px'],
  175. fix: false, //不固定
  176. maxmin: true,
  177. shade:0.4,
  178. title: title,
  179. content: url
  180. });
  181. }
  182. /*关闭弹出框口*/
  183. function layer_close(){
  184. var index = parent.layer.getFrameIndex(window.name);
  185. parent.layer.close(index);
  186. }