75 lines
2.2 KiB
JavaScript
75 lines
2.2 KiB
JavaScript
|
|
(function($) {
|
||
|
|
'use strict';//严格模式
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$(function() {
|
||
|
|
/*begin*/
|
||
|
|
var $fullText = $('.admin-fullText');
|
||
|
|
$('#admin-fullscreen').on('click', function() {
|
||
|
|
$.AMUI.fullscreen.toggle();
|
||
|
|
});
|
||
|
|
|
||
|
|
$(document).on($.AMUI.fullscreen.raw.fullscreenchange, function() {
|
||
|
|
$fullText.text($.AMUI.fullscreen.isFullscreen ? '退出全屏' : '开启全屏');
|
||
|
|
});
|
||
|
|
/*end*/
|
||
|
|
|
||
|
|
/*begin*/
|
||
|
|
var path = window.location.pathname;
|
||
|
|
var end = path.split('/');
|
||
|
|
console.log(end);
|
||
|
|
$('#'+end[end.length-1]).addClass('am-active');
|
||
|
|
/*end*/
|
||
|
|
});
|
||
|
|
/*$(function() {
|
||
|
|
var path = window.location.pathname;
|
||
|
|
var end = path.split('/');
|
||
|
|
console.log(end);
|
||
|
|
$('#'+end[2]).addClass('am-active');
|
||
|
|
});*/
|
||
|
|
})(jQuery);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 多选下拉框全选功能
|
||
|
|
* @param selector
|
||
|
|
*/
|
||
|
|
function selectAll(selector) {
|
||
|
|
var $select = $(selector);
|
||
|
|
var $allBtn = $($($select[0].nextElementSibling).find('ul li')[0]);
|
||
|
|
var $amSelect = $($select[0].nextElementSibling).find('ul');
|
||
|
|
var $options = $allBtn.siblings();
|
||
|
|
$allBtn.on('click', function() {
|
||
|
|
if($(this).hasClass('am-checked')) {
|
||
|
|
console.log('取消全选');
|
||
|
|
$(this).siblings().removeClass('am-checked');
|
||
|
|
$select.find('option').prop('selected', false);
|
||
|
|
} else {
|
||
|
|
console.log('全选');
|
||
|
|
$(this).siblings().addClass('am-checked');
|
||
|
|
$select.find('option').prop('selected', true);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
$options.on('click', function() {
|
||
|
|
var length = $options.length;
|
||
|
|
var selectedLen = 0;
|
||
|
|
if($(this).hasClass('am-checked')) {
|
||
|
|
selectedLen = $amSelect.find('.am-checked').length - 1;
|
||
|
|
if ($allBtn.hasClass('am-checked')) {
|
||
|
|
selectedLen -= 1;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
selectedLen = $amSelect.find('.am-checked').length + 1;
|
||
|
|
}
|
||
|
|
if (selectedLen === length) {
|
||
|
|
$allBtn.addClass('am-checked');
|
||
|
|
$select.find('option[value="-1"]').prop('selected', true);
|
||
|
|
} else {
|
||
|
|
$allBtn.removeClass('am-checked');
|
||
|
|
$select.find('option[value="-1"]').prop('selected', false);
|
||
|
|
}
|
||
|
|
console.log(selectedLen);
|
||
|
|
});
|
||
|
|
}
|