admincp.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. $(function() {
  2. //使用title内容作为tooltip提示文字
  3. $(document).tooltip({
  4. track: true
  5. });
  6. // 侧边导航展示形式切换
  7. $('#foldSidebar > i, #foldSidebar2').click(function(){
  8. var that = $('#foldSidebar').find('i');
  9. if ($('.admincp-container').hasClass('unfold')) {
  10. $(that).addClass('fa-in').removeClass('fa-out');
  11. $('.sub-menu').removeAttr('style');
  12. $('.admincp-container').addClass('fold').removeClass('unfold');
  13. } else {
  14. $(that).addClass('fa-out').removeClass('fa-in');
  15. $('.nav-tabs').each(function(i){
  16. $(that).find('dl').each(function(i){
  17. $(that).find('dd').css('top', (-70)*i + 'px');
  18. if ($(that).hasClass('active')) {
  19. $(that).find('dd').show();
  20. }
  21. });
  22. });
  23. $('.admincp-container').addClass('unfold').removeClass('fold');
  24. }
  25. });
  26. // 侧边导航三级级菜单点击
  27. $('.sub-menu').find('a').click(function(){
  28. if($(this).attr('data-param') != undefined){
  29. openItem($(this).attr('data-param'));
  30. }
  31. });
  32. if ($.cookie('workspaceParam') == null) {
  33. // 默认选择第一个菜单
  34. //$('.nc-module-menu').find('li:first > a').click();
  35. openItem('Index|welcome');
  36. } else {
  37. // openItem($.cookie('workspaceParam'));
  38. openItem('Index|welcome');
  39. }
  40. });
  41. // 点击菜单,iframe页面跳转
  42. function openItem(param) {
  43. $('.sub-menu').find('li').removeClass('active');
  44. data_str = param.split('|');
  45. $this = $('div[id^="admincpNavTabs_"]').find('a[data-param="' + param + '"]');
  46. if ($('.admincp-container').hasClass('unfold')) {
  47. $this.parents('dd:first').show();
  48. }
  49. $('li[data-param="' + data_str[0] + '"]').addClass('active');
  50. $this.parent().addClass('active').parents('dl:first').addClass('active').parents('div:first').show();
  51. var src = eyou_basefile + '?m='+module_name+'&c=' + data_str[0] + '&a=' + data_str[1];
  52. if (data_str.length%2 == 0) {
  53. for (var i = 2; i < data_str.length; i++) {
  54. if (i%2 == 0) {
  55. src = src + '&';
  56. } else {
  57. src = src + '=';
  58. }
  59. src = src + data_str[i];
  60. }
  61. }
  62. var lang = $.cookie('admin_lang');
  63. if (!lang) lang = __lang__;
  64. if (false != $.inArray('lang', data_str) && $.trim(lang) != '') {
  65. src = src + '&lang=' + lang;
  66. }
  67. $('#workspace').attr('src', src);
  68. $.cookie('workspaceParam', data_str[1] + '|' + data_str[0], { expires: 1 ,path:"/"});
  69. // 循环清空选中的标记的Class
  70. var SubMenuA = $('.sub-menu a');
  71. SubMenuA.each(function(){
  72. // 其他参数处理
  73. $('#'+this.id).removeClass('on');
  74. // 特殊参数处理
  75. $('#'+this.id).parent().siblings().removeClass('on');
  76. });
  77. // 拼装ID获取到点击的ID
  78. var ColorId = param.replace('|','_');
  79. if (0 == $('#'+ColorId).attr('data-child')) {
  80. // 其他参数选项
  81. $('#'+ColorId).addClass('on');
  82. }else{
  83. // 特殊参数处理
  84. $('#'+ColorId).parent().siblings().addClass('on');
  85. }
  86. }
  87. /* 显示Ajax表单 */
  88. function ajax_form(id, title, url, width, model)
  89. {
  90. if (!width) width = 480;
  91. if (!model) model = 1;
  92. var d = DialogManager.create(id);
  93. d.setTitle(title);
  94. d.setContents('ajax', url);
  95. d.setWidth(width);
  96. d.show('center',model);
  97. return d;
  98. }