123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698 |
- //多选
- $(document).ready(function() {
- if ($(".single-optgroup-select").length > 0) {
- $('.single-optgroup-select').multiselect({
- enableFiltering: true,
- enableHTML: true,
- disableIfEmpty: true,
- buttonClass: 'btn btn-white',
- templates: {
- button: '<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"><span class="multiselect-selected-text"></span> <b class="fa fa-caret-down"></b></button>',
- ul: '<ul class="multiselect-container dropdown-menu" style="width: 300px;"></ul>',
- filter: '<li class="multiselect-item multiselect-filter"><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span><input class="form-control multiselect-search" type="text"></div></li>',
- filterClearBtn: '',
- li: '<li><a tabindex="0"><label></label></a></li>',
- divider: '<li class="multiselect-item divider"></li>',
- liGroup: '<li class="multiselect-item multiselect-group"><label></label></li>'
- },
- onChange: function (e) {
- if(check_function_exist('singleSelectChange')){ // 方法存在即调用,该方法需要自己实现,抽出一个值改变的方法
- singleSelectChange(e.context.value);
- }
- }
- });
- }
- if ($(".single-select").length > 0) {
- $('.single-select').multiselect({
- enableFiltering: true,
- enableHTML: true,
- disableIfEmpty: true,
- buttonClass: 'btn btn-white',
- templates: {
- button: '<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"><span class="multiselect-selected-text"></span> <b class="fa fa-caret-down"></b></button>',
- ul: '<ul class="multiselect-container dropdown-menu" style="width: 219px;"></ul>',
- filter: '<li class="multiselect-item multiselect-filter"><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span><input class="form-control multiselect-search" type="text"></div></li>',
- filterClearBtn: '',
- li: '<li><a tabindex="0"><label></label></a></li>',
- divider: '<li class="multiselect-item divider"></li>',
- liGroup: '<li class="multiselect-item multiselect-group"><label></label></li>'
- },
- onChange: function (e) {
- if(check_function_exist('singleSelectChange')){ // 方法存在即调用,该方法需要自己实现,抽出一个值改变的方法
- singleSelectChange(e.context.value);
- }
- }
- });
- }
- if ($(".multi-select").length > 0) {
- $('.multi-select').multiselect({
- enableFiltering: true,
- enableHTML: true,
- enableClickableOptGroups: true,
- disableIfEmpty: true,
- enableCollapsibleOptGroups: true,
- buttonClass: 'btn btn-white',
- templates: {
- button: '<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"><span class="multiselect-selected-text"></span> <b class="fa fa-caret-down"></b></button>',
- ul: '<ul class="multiselect-container dropdown-menu" style="width: 300px;"></ul>',
- filter: '<li class="multiselect-item multiselect-filter"><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span><input class="form-control multiselect-search" type="text"></div></li>',
- filterClearBtn: '',
- li: '<li><a tabindex="0"><label></label></a></li>',
- divider: '<li class="multiselect-item divider"></li>',
- liGroup: '<li class="multiselect-item multiselect-group"><label></label></li>'
- }
- });
- }
- if ($(".multi-select-filter").length > 0) {
- $('.multi-select-filter').multiselect({
- enableFiltering: true,
- includeSelectAllOption: true,
- numberDisplayed: 3,
- enableHTML: true,
- enableClickableOptGroups: false,
- disableIfEmpty: true,
- enableCollapsibleOptGroups: true,
- buttonClass: 'btn btn-white',
- templates: {
- button: '<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"><span class="multiselect-selected-text"></span> <b class="fa fa-caret-down"></b></button>',
- ul: '<ul class="multiselect-container dropdown-menu" style="width: 300px;"></ul>',
- filter: '<li class="multiselect-item multiselect-filter"><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span><input class="form-control multiselect-search" type="text"></div></li>',
- filterClearBtn: '',
- li: '<li><a tabindex="0"><label></label></a></li>',
- divider: '<li class="multiselect-item divider"></li>',
- liGroup: '<li class="multiselect-item multiselect-group"><label></label></li>'
- }
- });
- }
- if ($(".multi-select-filter-selectall").length > 0) {
- $('.multi-select-filter-selectall').multiselect({
- enableFiltering: true,
- includeSelectAllOption: true,
- numberDisplayed: 3,
- enableHTML: true,
- enableClickableOptGroups: true,
- disableIfEmpty: true,
- enableCollapsibleOptGroups: true,
- buttonClass: 'btn btn-white',
- templates: {
- button: '<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"><span class="multiselect-selected-text"></span> <b class="fa fa-caret-down"></b></button>',
- ul: '<ul class="multiselect-container dropdown-menu" style="width: 300px;"></ul>',
- filter: '<li class="multiselect-item multiselect-filter"><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span><input class="form-control multiselect-search" type="text"></div></li>',
- filterClearBtn: '',
- li: '<li><a tabindex="0"><label></label></a></li>',
- divider: '<li class="multiselect-item divider"></li>',
- liGroup: '<li class="multiselect-item multiselect-group"><label></label></li>'
- }
- });
- }
- });
- $(document).ready(function() {
- //播放音频
- /*if ($("audio").length > 0) {
- audiojs.events.ready(function() {
- if ($('audio').attr('type') !== 'hide') {
- var as = audiojs.createAll();
- } else {
- $('audio').hide();
- }
- });
- }*/
- });
- // 快速编辑
- $(document).on('click', '.quick-edit-text', function(e) {
- var $this = $(this),
- defaultValue = $this.attr('data-vaule');
- if ($this.hasClass('editing'))
- return;
- var input = '<input type="number" maxlength="4" style="width:2.5em;" value=' + defaultValue + '>';
- $this.addClass('editing').html(input);
- });
- // <span class="quick-edit-text" data-url="sort?id=<?=$item->ExBuildFormID?>" data-vaule="<?=$item->Sort?>"><?=$item->Sort?></span>
- $(document).on('focusout', '.quick-edit-text input', function(e) {
- var $this = $(this).parent(),
- $input = $(this),
- value = $input.val(),
- url = $this.attr('data-url'),
- defaultValue = $this.attr('data-vaule');
- if (value == '') {
- $this.html(defaultValue);
- $this.removeClass('editing');
- layer.tips('未填写排序值', '.quick-edit-text');
- return;
- }
- var bOk = false;
- if (value != defaultValue) {
- $.post(url, 'value=' + value, function(result) {
- layer.tips(result.info, '.quick-edit-text');
- if (result.status == 1) {
- bOk = true;
- if (result.url === undefined || result.url == '') {
- //赋值
- $this.html(value);
- } else {
- window.location.href = result.url;
- }
- }
- });
- }
- $this.removeClass('editing');
- if (!bOk) {
- $this.html(defaultValue);
- }
- });
- $(document).ready(function() {
- if ($('.dialog-datetime').length > 0) {
- //时间控件
- var $this = $('.dialog-datetime');
- $this.each(function(index, element) {
- var defaultValue = $(element).attr('data-rules');
- if (defaultValue != undefined && defaultValue !== '') {
- $(element).datetimepicker(eval('(' + defaultValue + ')'));
- } else {
- var step = $(element).attr('data-minute-step');
- var format = $(element).attr('data-date-format');
- if ('yyyy' == format) {
- minView = "decade";
- maxView = 'decade';
- startView = 'decade';
- } else if ('yyyy-mm' == format) {
- minView = "year";
- maxView = 'year';
- startView = 'year';
- } else if ('yyyy-mm-dd' == format) {
- minView = "month";
- maxView = 'month';
- startView = 'month';
- } else if ('yyyy-mm-dd hh' == format) {
- minView = "day";
- maxView = 'month';
- startView = 'month';
- } else if ('yyyy-mm-dd hh:ii' == format) {
- minView = "hour";
- maxView = 'month';
- startView = 'month';
- } else if ('hh:ii' == format) {
- minView = "hour";
- maxView = 'hour';
- startView = 'hour';
- } else if ('hh' == format) {
- minView = "hour";
- maxView = 'hour';
- startView = 'hour';
- format = "hh:ii";
- step = 60;
- } else {
- minView = "hour";
- maxView = 'month';
- startView = 'month';
- }
- // alert(minView);
- $(element).datetimepicker({
- minView: minView,
- maxView: maxView,
- weekStart: 1,
- startView: startView,
- minuteStep: parseInt(step),
- showMeridian: true,
- format: format,
- autoclose: true,
- todayBtn: false,
- forceParse: true
- });
- }
- });
- }
- });
- //删除
- $(document).on('click', '.btn-confirm', function(e) {
- var $this = $(this),
- msg = $this.attr('data-confirm') || '你确定执行该操作吗?';
- url = $this.attr('href') || $this.attr('data-url');
- layer.confirm(msg, {
- icon: 3,
- btn: ['确定', '取消'],
- skin: 'layer-ext-moon'
- }, function(index) {
- window.location.href = url;
- });
- return false;
- });
- //删除
- $(document).on('click', '.btn-confirm-get', function(e) {
- var $this = $(this),
- msg = $this.attr('data-confirm') || '你确定执行该操作吗?';
- url = $this.attr('href') || $this.attr('data-url');
- layer.confirm(msg, {
- icon: 3,
- btn: ['确定', '取消'],
- skin: 'layer-ext-moon'
- }, function(index) {
- $.get(url, function(result) {
- layer.close(index);
- if (result.info != undefined && result.info != '') {
- if (result.status == 1) {
- layer.alert(result.info, { icon: 1, skin: 'layer-ext-moon' }, function() {
- if (result.url === undefined || result.url == '') {
- parent.location.reload();
- } else {
- window.location.href = result.url;
- }
- });
- } else {
- layer.alert(result.info, { icon: 2, skin: 'layer-ext-moon' });
- }
- } else {
- //parent.location.reload();
- }
- });
- });
- return false;
- // var cf = confirm(msg);
- // if(!cf) e.stopImmediatePropagation(); // 阻止事件追加
- // return cf ? true : false;
- });
- //弹出窗
- $(document).on('click', '.btn-dialog-pop', function(e) {
- e.preventDefault();
- var $this = $(this),
- id = $this.attr('data-id') || 'dialog',
- url = $this.attr('href') || $this.attr('data-url');
- var title = $this.text();
- layer.open({
- type: 2,
- shade: 0.8,
- title: title,
- area: 'auto',
- area: ['800px', '90%'],
- fix: false, //不固定
- maxmin: true,
- content: url,
- skin: 'layer-ext-moon',
- success: function(layero, index) {
- layer.iframeAuto(index);
- //设置标题
- //layer.title($this.text(), index);
- },
- btn: ['取消']
- });
- });
- $(document).on('click', '.btn-dialog-pop2', function(e) {
- e.preventDefault();
- var $this = $(this),
- id = $this.attr('data-id') || 'dialog',
- url = $this.attr('href') || $this.attr('data-url');
- var title = $this.text();
- layer.open({
- type: 2,
- shade: 0.8,
- title: title,
- area: 'auto',
- area: ['80%', '90%'],
- fix: false, //不固定
- maxmin: true,
- content: url,
- skin: 'layer-ext-moon',
- success: function(layero, index) {
- layer.iframeAuto(index);
- //设置标题
- //layer.title($this.text(), index);
- },
- btn: ['取消']
- });
- });
- $(document).on('click', '.btn-dialog-pop3', function(e) {
- e.preventDefault();
- var $this = $(this),
- id = $this.attr('data-id') || 'dialog',
- url = $this.attr('href') || $this.attr('data-url');
- var title = $this.text();
- parent.layer.open({
- type: 2,
- shade: 0.8,
- title: title,
- area: 'auto',
- area: ['60%', '90%'],
- fix: false, //不固定
- maxmin: true,
- content: url,
- skin: 'layer-ext-moon',
- success: function(layero, index) {
- layer.iframeAuto(index);
- //设置标题
- //layer.title($this.text(), index);
- },
- btn: ['取消']
- });
- });
- $(document).ready(function() {
- //表单静态提交,并且刷新本页
- $('.ajax-form').ajaxSubmit(function(result) {
- jFlyer.show_result_info(result);
- });
- });
- var jFlyer = {};
- jFlyer.is_null = function(str) {
- if (str == null) {
- return true;
- }
- if (str == "") {
- return true;
- }
- var regu = "^[ ]+$";
- var re = new RegExp(regu);
- return re.test(str);
- }
- //private
- jFlyer.show_result_info = function(result) {
- function refresh(url){
- if (!jFlyer.is_null(url)) {
- window.location.href = url;
- return;
- }
- if (result.status == 1) {
- parent.location.reload();
- }
- };
- if (!jFlyer.is_null(result.info)) {
- layer.alert(result.info, {
- icon: (result.status == 1) ? 1 : 2,
- skin: 'layer-ext-moon',
- yes: function(index) {
- layer.close(index);
- refresh(result.url);
- }
- });
- }else{
- refresh(result.url)
- }
- }
- //class 为 btn-dialog-form 的点击弹出
- $(document).off('click', '.btn-dialog-form').on('click', '.btn-dialog-form', function(e) {
- e.preventDefault();
- var $this = $(this),
- id = $this.attr('data-id') || 'dialog',
- url = $this.attr('href') || $this.attr('data-url');
- var title = $this.text();
- jFlyer.show_dialog_form(title, url);
- return false;
- });
- jFlyer.show_dialog_form_callback = function(title, url, callback) {
- layer.open({
- type: 2,
- shade: 0.8,
- title: title,
- area: ['800px', '90%'],
- fix: false, //不固定
- maxmin: true,
- content: url,
- skin: 'layer-ext-moon',
- success: function(layero, index) {
- layer.iframeAuto(index);
- var form = layer.getChildFrame('form', index);
- //如果form的action为空,将当前的action 弄过去
- if (form.attr('action') === undefined || form.attr('action') === '') {
- form.attr('action', url);
- }
- },
- // btn: ['确定', '取消'],
- yes: function(index) {
- var form = layer.getChildFrame('form', index);
- if(form[0].dataset.next == 'true'){
- layer.msg('请点击下一步');
- return false;
- }
- $.Form.ajaxSubmit(form, function(result) {
- if (result.status == 1) {
- layer.close(index);
- }
- callback(result, form);
- });
- }
- });
- }
- jFlyer.show_dialog_form = function(title, url) {
- jFlyer.show_dialog_form_callback(title, url, function(result, form) {
- jFlyer.show_result_info(result);
- });
- }
- $(document).off('click', '.btn-dialog-form2').on('click', '.btn-dialog-form2', function(e) {
- e.preventDefault();
- var $this = $(this),
- id = $this.attr('data-id') || 'dialog',
- url = $this.attr('href') || $this.attr('data-url');
- var title = $this.text();
- jFlyer.show_dialog_form2(title, url);
- return false;
- });
- jFlyer.show_dialog_form_callback2 = function(title, url, callback) {
- layer.open({
- type: 2,
- shade: 0.8,
- title: title,
- area: ['600px', '90%'],
- fix: false, //不固定
- maxmin: true,
- content: url,
- skin: 'layer-ext-moon',
- success: function(layero, index) {
- layer.iframeAuto(index);
- var form = layer.getChildFrame('form', index);
- //如果form的action为空,将当前的action 弄过去
- if (form.attr('action') === undefined || form.attr('action') === '') {
- form.attr('action', url);
- }
- },
- btn: ['确定', '取消'],
- yes: function(index) {
- var form = layer.getChildFrame('form', index);
- $.Form.ajaxSubmit(form, function(result) {
- if (result.status == 1) {
- layer.close(index);
- }
- callback(result, form);
- });
- }
- });
- }
- jFlyer.show_dialog_form2 = function(title, url) {
- jFlyer.show_dialog_form_callback2(title, url, function(result, form) {
- jFlyer.show_result_info(result);
- });
- }
- $(document).off('click', '.btn-dialog-form3').on('click', '.btn-dialog-form3', function(e) {
- e.preventDefault();
- var $this = $(this),
- id = $this.attr('data-id') || 'dialog',
- url = $this.attr('href') || $this.attr('data-url');
- var title = $this.text();
- jFlyer.show_dialog_form3(title, url);
- return false;
- });
- jFlyer.show_dialog_form_callback3 = function(title, url, callback) {
- parent.layer.open({
- type: 2,
- shade: 0.8,
- title: title,
- area: ['60%', '90%'],
- fix: false, //不固定
- maxmin: true,
- content: url,
- skin: 'layer-ext-moon',
- success: function(layero, index) {
- layer.iframeAuto(index);
- var form = layer.getChildFrame('form', index);
- //如果form的action为空,将当前的action 弄过去
- if (form.attr('action') === undefined || form.attr('action') === '') {
- form.attr('action', url);
- }
- },
- btn: ['确定', '取消'],
- yes: function(index) {
- var form = layer.getChildFrame('form', index);
- $.Form.ajaxSubmit(form, function(result) {
- if (result.status == 1) {
- layer.close(index);
- }
- callback(result, form);
- });
- }
- });
- }
- jFlyer.show_dialog_form3 = function(title, url) {
- jFlyer.show_dialog_form_callback3(title, url, function(result, form) {
- jFlyer.show_result_info(result);
- });
- }
- jFlyer.is_function = function(fn) {
- return Object.prototype.toString.call(fn) === '[object Function]';
- }
- jFlyer.get_data = function(url, callback) {
- var layerIndexget = layer.load(1);
- $.get(url, function(result) {
- layer.close(layerIndexget);
- if (callback != undefined && jFlyer.is_function(callback)) {
- callback(result);
- }
- });
- }
- jFlyer.post_data = function(url, data, callback) {
- var layerIndex = layer.load(1);
- $.post(url, data, function(result) {
- layer.close(layerIndex);
- if (callback != undefined && jFlyer.is_function(callback)) {
- callback(result);
- }
- });
- }
- jFlyer.show_pop_info = function(info, reload, callback) {
- layer.open({
- content: info,
- btn: '确定',
- yes: function(index) {
- layer.close(index);
- if (callback != undefined && jFlyer.is_function(callback)) {
- callback();
- }
- if (reload) {
- location.reload();
- }
- }
- });
- }
- //ajax get请求
- $(document).on('click','.ajax-get',function(){
- var that = this;
- var confirm_msg = $(this).attr('data-confirm')?$(this).attr('data-confirm'):'确认要执行该操作吗?';
- if ( $(this).hasClass('confirm') ) {
- layer.confirm(confirm_msg, {
- btn: ['确认', '取消'], //按钮
- shade: false //不显示遮罩
- }, function() {
- layer.closeAll();
- ajax_get_fun(that);
- }, function() {
- layer.closeAll();
- });
- }else{
- ajax_get_fun(that);
- }
- return false;
- });
- function ajax_get_fun(that) {
- var target;
- if ( (target = $(that).attr('href')) || (target = $(that).attr('url')) ) {
- var flag = $(that).attr('data-flag');
- if(flag == 1){
- return '';
- }
- $(that).attr('data-flag',1);
- $.get(target).success(function(data){
- if (data.status == 1) {
- layer.msg(data.info, {time: 1500, icon:6,offset:0});
- setTimeout(function(){
- if( $(that).hasClass('no-refresh')){
- $(that).attr('data-flag',0);
- }else{
- if (data.url === undefined || data.url == '') {
- location.reload();
- } else {
- window.location.href = result.url;
- }
- }
- },1500);
- }else{
- layer.msg(data.info, {time: 1500, icon:5,offset:0,shift: 6});
- $(that).attr('data-flag',0);
- }
- });
- }
- }
- //打开查看图片
- function open_img(_self) {
- var src = $(_self).attr('src');
- var img = new Image();
- img.src = src;
- var width = $(window).width()*0.8;
- var height = $(window).height()*0.8;
- img.onload = function(){
- var imgw = img.width;
- var imgh = img.height;
- if(imgw > width&&imgh < height){
- imgh = imgh*width/imgw;
- imgw = width;
- }else if(imgw < width&&imgh > height){
- imgw = imgw*height/imgh;
- imgh = height;
- }else if(imgw > width&&imgh > height){
- var bl1 = width/height;
- var bl2 = imgw/imgh;
- if(bl1 < bl2){
- imgh = imgh*width/imgw;
- imgw = width;
- }else if(bl1 > bl2){
- imgw = imgw*height/imgh;
- imgh = height;
- }else{
- imgh = height;
- imgw = width;
- }
- }
- var imgs = '<img width="'+imgw+'" height="'+imgh+'" src="'+src+'" />';
- layer.open({
- type: 1,
- title: false,
- closeBtn: 1,
- area: [imgw+'px', imgh+'px'],
- skin: 'layui-layer-nobg', //没有背景色
- shadeClose: true,
- content: imgs
- });
- };
- }
- //左侧导航高量
- function add_highlight(url) {
- $('#sidebar li').removeClass('active').removeClass('open');
- $('#sidebar a[href="'+url+'"]').parent().addClass('active');
- $('#sidebar a[href="'+url+'"]').parent().parent().parent().addClass('active').addClass('open');
- }
- //检查函数是否存在
- function check_function_exist(funcName) {
- try{
- if(typeof(eval(funcName))=="function"){
- return true;
- }
- }catch(e){}
- return false;
- }
|