前端js组件更新
This commit is contained in:
@@ -0,0 +1,252 @@
|
||||
$(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 = $('<ul />', {'class': 'list-unstyled clearfix'})
|
||||
|
||||
// Dark sidebar skins
|
||||
var $skinBlue =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-blue" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px; background: #367fa9"></span><span class="bg-light-blue" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin">蓝黑</p>')
|
||||
$skinsList.append($skinBlue)
|
||||
var $skinBlack =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-black" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div style="box-shadow: 0 0 2px rgba(0,0,0,0.1)" class="clearfix"><span style="display:block; width: 20%; float: left; height: 7px; background: #fefefe"></span><span style="display:block; width: 80%; float: left; height: 7px; background: #fefefe"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin">白黑</p>')
|
||||
$skinsList.append($skinBlack)
|
||||
var $skinPurple =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-purple" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-purple-active"></span><span class="bg-purple" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin">紫黑</p>')
|
||||
$skinsList.append($skinPurple)
|
||||
var $skinGreen =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-green" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-green-active"></span><span class="bg-green" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin">绿黑</p>')
|
||||
$skinsList.append($skinGreen)
|
||||
var $skinRed =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-red" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-red-active"></span><span class="bg-red" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin">红黑</p>')
|
||||
$skinsList.append($skinRed)
|
||||
var $skinYellow =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-yellow" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-yellow-active"></span><span class="bg-yellow" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #222d32"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin">黄黑</p>')
|
||||
$skinsList.append($skinYellow)
|
||||
|
||||
// Light sidebar skins
|
||||
var $skinBlueLight =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-blue-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px; background: #367fa9"></span><span class="bg-light-blue" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin" style="font-size: 12px">亮蓝</p>')
|
||||
$skinsList.append($skinBlueLight)
|
||||
var $skinBlackLight =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-black-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div style="box-shadow: 0 0 2px rgba(0,0,0,0.1)" class="clearfix"><span style="display:block; width: 20%; float: left; height: 7px; background: #fefefe"></span><span style="display:block; width: 80%; float: left; height: 7px; background: #fefefe"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin" style="font-size: 12px">亮</p>')
|
||||
$skinsList.append($skinBlackLight)
|
||||
var $skinPurpleLight =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-purple-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-purple-active"></span><span class="bg-purple" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin" style="font-size: 12px">亮紫</p>')
|
||||
$skinsList.append($skinPurpleLight)
|
||||
var $skinGreenLight =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-green-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-green-active"></span><span class="bg-green" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin" style="font-size: 12px">亮绿</p>')
|
||||
$skinsList.append($skinGreenLight)
|
||||
var $skinRedLight =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-red-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-red-active"></span><span class="bg-red" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin" style="font-size: 12px">亮红</p>')
|
||||
$skinsList.append($skinRedLight)
|
||||
var $skinYellowLight =
|
||||
$('<li />', {style: 'float:left; width: 33.33333%; padding: 5px;'})
|
||||
.append('<a href="javascript:void(0)" data-skin="skin-yellow-light" style="display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)" class="clearfix full-opacity-hover">'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 7px;" class="bg-yellow-active"></span><span class="bg-yellow" style="display:block; width: 80%; float: left; height: 7px;"></span></div>'
|
||||
+ '<div><span style="display:block; width: 20%; float: left; height: 20px; background: #f9fafc"></span><span style="display:block; width: 80%; float: left; height: 20px; background: #f4f5f7"></span></div>'
|
||||
+ '</a>'
|
||||
+ '<p class="text-center no-margin" style="font-size: 12px">亮黄</p>')
|
||||
$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'){}
|
||||
})
|
||||
|
||||
$('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'));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user