$(function () { 'use strict' /** * List of all the available skins * * @type Array */ var mySkins = [ 'skin-blue', 'skin-black', 'skin-red', 'skin-yellow', 'skin-purple', 'skin-green', 'skin-blue-light', 'skin-black-light', 'skin-red-light', 'skin-yellow-light', 'skin-purple-light', 'skin-green-light' ] var $skinsList = $('
蓝黑
') $skinsList.append($skinBlue) var $skinBlack = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '白黑
') $skinsList.append($skinBlack) var $skinPurple = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '紫黑
') $skinsList.append($skinPurple) var $skinGreen = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '绿黑
') $skinsList.append($skinGreen) var $skinRed = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '红黑
') $skinsList.append($skinRed) var $skinYellow = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '黄黑
') $skinsList.append($skinYellow) // Light sidebar skins var $skinBlueLight = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '亮蓝
') $skinsList.append($skinBlueLight) var $skinBlackLight = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '亮
') $skinsList.append($skinBlackLight) var $skinPurpleLight = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '亮紫
') $skinsList.append($skinPurpleLight) var $skinGreenLight = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '亮绿
') $skinsList.append($skinGreenLight) var $skinRedLight = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '亮红
') $skinsList.append($skinRedLight) var $skinYellowLight = $('', {style: 'float:left; width: 33.33333%; padding: 5px;'}) .append('' + '亮黄
') $skinsList.append($skinYellowLight) $('[data-skin-box] > .content').append($skinsList); setup(); /** * Replaces the old skin with the new skin * @param String cls the new skin class * @returns Boolean false to prevent link's default action */ function changeSkin(cls) { $.each(mySkins, function (i) { $('body').removeClass(mySkins[i]) }) $('body').addClass(cls) store('skin', cls) return false } /** * Retrieve default settings and apply them to the template * * @returns void */ function setup() { var tmp = get('skin') || 'skin-blue'; if (tmp && $.inArray(tmp, mySkins) >= 0){ changeSkin(tmp) } // Add the change skin listener $('[data-skin]').on('click', function (e) { if ($(this).hasClass('knob')) return e.preventDefault() changeSkin($(this).data('skin')) }) $('[data-toggle="control-sidebar"]').click(function(){ $("[data-skin-box]").animate({right:"0"}, 500); }) $('.tool-bar').click(function(){ $("[data-skin-box]").animate({right:"-280px"}, 500); }) $('[data-tab-action]').hover(function(){ $(this).find('.dropdown-menu').show(); }, function(){ $(this).find('.dropdown-menu').hide(); }) $('a[data-action=close]').click(function(e){ e.preventDefault(); var type = $(this).data('type'); if (type == 'current') { $.page.closeMenuItem($('.page-tabs-content a.active').data('id')); }else if(type == 'other'){ $('.page-tabs-content a').each(function(){ if (!$(this).hasClass('home') && !$(this).hasClass('active')) { $('.mainContent .sent_iframe[data-id="' + $(this).data('id') + '"]').remove(); $(this).remove(); } }) }else if(type == 'right'){ $('.page-tabs-content a.active').nextAll('.menuTab').each(function(){ if (!$(this).hasClass('home')) { $('.mainContent .sent_iframe[data-id="' + $(this).data('id') + '"]').remove(); $(this).remove(); } }) }else if(type == 'left'){ $('.page-tabs-content a.active').prevAll('.menuTab').each(function(){ if (!$(this).hasClass('home')) { $('.mainContent .sent_iframe[data-id="' + $(this).data('id') + '"]').remove(); $(this).remove(); } }) }else if(type == 'all'){ $('.page-tabs-content a').each(function(){ if (!$(this).hasClass('home')) { $('.mainContent .sent_iframe[data-id="' + $(this).data('id') + '"]').remove(); $(this).remove(); //激活首页 $.page.setActiveTab($('.page-tabs-content a.home')); } }) } }) $('a[data-action=url]').click(function(e){ e.preventDefault(); var type = $(this).data('type'); if (type == 'tab') { $.page.createMenuItem($(this).attr('href'), $(this).html()); }else if(type == 'open'){ $.model.open($(this).text(), $(this).attr('href')); }else if(type == 'msg'){ $.operate.get($(this).attr('href')) } }) $('span[data-action=scroll]').click(function(e){ e.preventDefault(); var type = $(this).data('type'); if (type == 'left') { $.page.scrollToLeft(); }else if(type == 'right'){ $.page.scrollToRight(); } }) $('.refresh').click(function(){ $.page.refreshTab(); }) $('.sidebar-menu a').click(function(e){ if($(this).attr('href') != '#'){ e.preventDefault(); var data = {}; if ($(this).attr('target') == 'main-body') { $.page.createMenuItem($(this).attr('href'), $(this).html()); }else{ $.model.open($(this).text(), $(this).attr('href')); } } }) } if (self != top) { parent.location.reload(); } })