hAdmin.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. /*
  2. * Copyright 2018 本系统版权归成都睿思商智科技有限公司所有
  3. * 用户不能删除系统源码上的版权信息, 使用许可证地址:
  4. * https://www.ruisitech.com/licenses/index.html
  5. */
  6. //自定义js
  7. //公共配置
  8. $(document).ready(function () {
  9. // MetsiMenu
  10. $('#side-menu').metisMenu();
  11. //固定菜单栏
  12. $(function () {
  13. $('.sidebar-collapse').slimScroll({
  14. height: '100%',
  15. railOpacity: 0.9,
  16. alwaysVisible: false
  17. });
  18. });
  19. // 侧边栏高度
  20. function fix_height() {
  21. var heightWithoutNavbar = $("body > #wrapper").height() - 61;
  22. $(".sidebard-panel").css("min-height", heightWithoutNavbar + "px");
  23. }
  24. fix_height();
  25. $(window).bind("load resize click scroll", function () {
  26. if (!$("body").hasClass('body-small')) {
  27. fix_height();
  28. }
  29. });
  30. //侧边栏滚动
  31. $(window).scroll(function () {
  32. if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) {
  33. $('#right-sidebar').addClass('sidebar-top');
  34. } else {
  35. $('#right-sidebar').removeClass('sidebar-top');
  36. }
  37. });
  38. $('.full-height-scroll').slimScroll({
  39. height: '100%'
  40. });
  41. /**
  42. // 打开右侧边栏
  43. $('.right-sidebar-toggle').click(function () {
  44. $('#right-sidebar').toggleClass('sidebar-open');
  45. });
  46. // 菜单切换
  47. $('.navbar-minimalize').click(function () {
  48. $("body").toggleClass("mini-navbar");
  49. SmoothlyMenu();
  50. });
  51. // 侧边栏高度
  52. function fix_height() {
  53. var heightWithoutNavbar = $("body > #wrapper").height() - 61;
  54. $(".sidebard-panel").css("min-height", heightWithoutNavbar + "px");
  55. }
  56. fix_height();
  57. $(window).bind("load resize click scroll", function () {
  58. if (!$("body").hasClass('body-small')) {
  59. fix_height();
  60. }
  61. });
  62. //侧边栏滚动
  63. $(window).scroll(function () {
  64. if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) {
  65. $('#right-sidebar').addClass('sidebar-top');
  66. } else {
  67. $('#right-sidebar').removeClass('sidebar-top');
  68. }
  69. });
  70. $('.full-height-scroll').slimScroll({
  71. height: '100%'
  72. });
  73. $('#side-menu>li').click(function () {
  74. if ($('body').hasClass('mini-navbar')) {
  75. NavToggle();
  76. }
  77. });
  78. $('#side-menu>li li a').click(function () {
  79. if ($(window).width() < 769) {
  80. NavToggle();
  81. }
  82. });
  83. $('.nav-close').click(NavToggle);
  84. //ios浏览器兼容性处理
  85. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  86. $('#content-main').css('overflow-y', 'auto');
  87. }
  88. **/
  89. $('#side-menu>li').click(function () {
  90. if ($('body').hasClass('mini-navbar')) {
  91. NavToggle();
  92. }
  93. });
  94. $('#side-menu>li li a').click(function () {
  95. if ($(window).width() < 769) {
  96. NavToggle();
  97. }
  98. });
  99. //ios浏览器兼容性处理
  100. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  101. $('#content-main').css('overflow-y', 'auto');
  102. }
  103. //右上角tab控制按钮
  104. var closeevent = null;
  105. $("#taboptbtn").hover(function(){
  106. var p = $(this).offset();
  107. var l = p.left;
  108. var t = p.top;
  109. $("#taboptdiv").css({top:t+40, left:l-70,minWidth:120}).show();
  110. }, function(){
  111. closeevent = window.setTimeout(function(){
  112. $("#taboptdiv").hide('fast');
  113. }, 200);
  114. });
  115. $("#taboptdiv").hover(function(){
  116. if(closeevent){
  117. clearTimeout(closeevent);
  118. closeevent = null;
  119. }
  120. }, function(){
  121. $(this).hide('fast');
  122. });
  123. var closeuinfoevent = null;
  124. $("#uinfobtn").hover(function(){
  125. var p = $(this).offset();
  126. var l = p.left;
  127. var t = p.top;
  128. $("#uinfodiv").css({top:t+26,left:l}).show();
  129. }, function(){
  130. closeuinfoevent = window.setTimeout(function(){
  131. $("#uinfodiv").hide('fast');
  132. }, 200);
  133. });
  134. $("#uinfodiv").hover(function(){
  135. if(closeuinfoevent){
  136. clearTimeout(closeuinfoevent);
  137. closeuinfoevent = null;
  138. }
  139. }, function(){
  140. $(this).hide('fast');
  141. });
  142. //点击后窗口关闭事件
  143. $("#uinfodiv li a").click(function(){
  144. $("#uinfodiv").hide('fast');
  145. });
  146. $("#taboptdiv li a").click(function(){
  147. $("#taboptdiv").hide('fast');
  148. });
  149. });
  150. /**
  151. function showusermenu(ts){
  152. var p = $(ts).offset();
  153. var l = p.left;
  154. var t = p.top;
  155. $("#uinfodiv").css({top:t+25, left:l}).show();
  156. }
  157. **/
  158. function swatch(ts){
  159. if($("body").hasClass("mini-navbar")){
  160. $('body').removeClass('mini-navbar');
  161. $(ts).removeClass("swatchBtn");
  162. }else{
  163. $('body').addClass('mini-navbar');
  164. $(ts).addClass("swatchBtn");
  165. }
  166. SmoothlyMenu();
  167. }
  168. $(window).bind("load resize", function () {
  169. if ($(this).width() < 769) {
  170. $('body').addClass('mini-navbar');
  171. $('.navbar-static-side').fadeIn();
  172. }
  173. });
  174. function NavToggle() {
  175. swatch();
  176. }
  177. function SmoothlyMenu() {
  178. if (!$('body').hasClass('mini-navbar')) {
  179. $('#side-menu').hide();
  180. setTimeout(
  181. function () {
  182. $('#side-menu').fadeIn(300);
  183. }, 100);
  184. } else if ($('body').hasClass('fixed-sidebar')) {
  185. $('#side-menu').hide();
  186. setTimeout(
  187. function () {
  188. $('#side-menu').fadeIn(300);
  189. }, 300);
  190. } else {
  191. $('#side-menu').removeAttr('style');
  192. }
  193. }
  194. function menuflash(tp){
  195. if("closeAll" == tp){
  196. $("ul.tabpanel_mover li").each(function(a, b){
  197. var id = $(this).attr("id");
  198. if(id != "t_home"){
  199. $(this).remove();
  200. }
  201. });
  202. $("#t_home").addClass("active");
  203. $(".tabpanel_content .html_content").each(function(a, b){
  204. var id = $(this).attr("id");
  205. if(id != "b_home"){
  206. $(this).remove();
  207. }
  208. });
  209. $("#b_home").show();
  210. $(".tabpanel_mover").css("marginLeft", "0px");
  211. }else if("close" == tp){
  212. var node = $(".tabpanel_mover li.active");
  213. var cid = node.attr("id");
  214. $("ul.tabpanel_mover li").each(function(a, b){
  215. var id = $(this).attr("id");
  216. if(id == "t_home" || id == cid) {
  217. }else{
  218. $(this).remove();
  219. }
  220. });
  221. $("#" + cid).addClass("active");
  222. cid = "b_" + cid.split("_")[1];
  223. $(".tabpanel_content .html_content").each(function(a, b){
  224. var id = $(this).attr("id");
  225. if(id == "b_home" || id == cid){
  226. }else{
  227. $(this).remove();
  228. }
  229. });
  230. $("#"+cid).show();
  231. $(".tabpanel_mover").css("marginLeft", "0px");
  232. }else if("ref" == tp){
  233. var node = $(".tabpanel_mover li.active");
  234. var url = node.attr("u");
  235. var cid = node.attr("id");
  236. cid = "b_" + cid.split("_")[1];
  237. if(url){
  238. $("#"+cid+" iframe").attr("src", url);
  239. }
  240. }
  241. }
  242. function menuOper(mid, url){
  243. $(".tabpanel_mover li").removeClass("active");
  244. $(".tabpanel_mover #t_"+mid).addClass("active");
  245. $(".tabpanel_content .html_content").hide();
  246. $(".tabpanel_content #b_"+mid).show();
  247. if(url){
  248. $("#b_"+mid+" iframe").attr("src", url);
  249. }
  250. }
  251. function menuOpen(url, txt, mid, refresh){
  252. var url = url;
  253. var n = txt;
  254. var id = mid;
  255. //菜单窗口是否打开
  256. if($("#t_"+id).length > 0){ //已打开,切换tab
  257. menuOper(id, refresh?url:null);
  258. }else { //新建tab
  259. /**
  260. if($(".tabpanel_mover li").length >= 10){
  261. msginfo("只能打开10个选项卡。");
  262. return false;
  263. }
  264. **/
  265. $(".tabpanel_mover li").removeClass("active");
  266. var s = "<li id=\"t_"+id+"\" class=\"active\" u='"+url+"'><div class=\"title\">"+n+"</div><div class=\"closer fa fa-close\"></div></li>";
  267. $(".tabpanel_tab_content .tabpanel_mover").append(s);
  268. //注册关闭事件
  269. $("#t_"+id+" .closer").click(function(){
  270. var nextId = $("#t_"+id).prev().attr("id").split("_")[1];
  271. $("#t_"+id).remove();
  272. $("#b_"+id).remove();
  273. menuOper(nextId);
  274. });
  275. s = "<div class=\"html_content\" id=\"b_"+id+"\"><iframe width=\"100%\" height=\"100%\" src=\""+url+"\" frameborder=\"0\" seamless></iframe></div>";
  276. $(".tabpanel_content").append(s);
  277. $(".tabpanel_content .html_content").hide();
  278. $(".tabpanel_content .html_content:last").show();
  279. }
  280. }
  281. function gotab(pos){
  282. var o = $(".tabpanel_mover");
  283. var left = Number(o.css("marginLeft").replace("px", ""));
  284. if(pos =='left'){
  285. left = left - 110;
  286. }else{
  287. left = left + 110;
  288. }
  289. if(left > 0){
  290. left = 0;
  291. }
  292. var size = $(".tabpanel_mover li").length;
  293. if(Math.abs(left/110) < size){
  294. o.css("marginLeft", left+"px");
  295. }
  296. }
  297. function fullScreem(){
  298. //$(".navbar-static-side").css("display", "none");
  299. //$("#page-wrapper").css("margin", "0px");
  300. $('body').addClass("screem-navbar");
  301. $(".tabpanel_tab_content").css("display", "none");
  302. $(".J_mainContent2").css("height", "100%");
  303. window.setTimeout(function(){
  304. var element = document.documentElement;
  305. if (element.requestFullscreen) {
  306. element.requestFullscreen();
  307. } else if (element.msRequestFullscreen) {
  308. element.msRequestFullscreen();
  309. } else if (element.mozRequestFullScreen) {
  310. element.mozRequestFullScreen();
  311. } else if (element.webkitRequestFullscreen) {
  312. element.webkitRequestFullscreen();
  313. }
  314. }, 1000);
  315. }
  316. $(function(){
  317. $(".tabpanel_mover").on("click", "li", function(){
  318. var id = $(this).attr("id").split("_")[1];
  319. menuOper(id);
  320. });
  321. //菜单点击
  322. $(".J_menuItem").on('click',function(){
  323. var url = $(this).attr('href');
  324. var n = $(this).find(".nav-label").text();
  325. var id = $(this).attr("mid");
  326. menuOpen(url, n, id, false);
  327. return false;
  328. });
  329. var exitFull = function(){
  330. //$(".navbar-static-side").css("display", "block");
  331. //$("#page-wrapper").css("margin", "0 0 0 220px");
  332. $('body').removeClass("screem-navbar");
  333. $(".tabpanel_tab_content").css("display", "block");
  334. $(".J_mainContent2").css("height", "calc(100% - 50px)");
  335. }
  336. //esc退出全屏
  337. $(document).keyup(function(event){
  338. switch(event.keyCode) {
  339. case 27:
  340. exitFull();
  341. break;
  342. case 96:
  343. break;
  344. }
  345. });
  346. });