|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- /*
- * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
- * Copyright (c) 2013-2018 北京泉江科技有限公司
- * 创建人:陈彬彬
- * 日 期:2017.03.16
- * 描 述:弹层(基于layer.js-3.0.3)
- */
- (function ($, learun) {
- "use strict";
- $.extend(learun, {
- // 询问框
- layerConfirm: function (_msg, callback) {
- top.learun.language.get(_msg,
- function (msg) {
- top.layer.confirm(msg,
- {
- btn: ['确认', '取消'],
- title: "提示",
- icon: 0,
- skin: 'lr-layer',
- success: function (layero, index) {
- layero.find('.layui-layer-btn a').each(function () {
- var $this = $(this);
- var _text = $this.text();
- top.learun.language.get(_text,
- function (text) {
- $this.text(text);
- });
-
- });
- layero.find('.layui-layer-title').each(function () {
- var $this = $(this);
- var _text = $this.text();
- top.learun.language.get(_text,
- function (text) {
- $this.text(text);
- });
-
- });
- },
- },
- function (index) {
- callback(true, index);
- top.layer.close(index); //再执行关闭
- },
- function (index) {
- callback(false, index);
- top.layer.close(index); //再执行关闭
- });
- });
-
-
- },
- // 自定义表单弹层
- layerForm: function (op) {
- var dfop = {
- id: null,
- title: '系统窗口',
- width: 550,
- height: 400,
- url: 'error',
- btn: ['确认', '关闭'],
- callBack: false,
- maxmin: false,
- end: false,
- };
- $.extend(dfop, op || {});
-
- /*适应窗口大小*/
- dfop.width = dfop.width > $(window).width() ? $(window).width() - 10 : dfop.width;
- dfop.height = dfop.height > $(window).height() ? $(window).height() - 10 : dfop.height;
- var r = 0;
- r=top.layer.open({
- id: dfop.id,
- maxmin: dfop.maxmin,
- type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
- title: dfop.title,
- area: [dfop.width + 'px', dfop.height + 'px'],
- btn: dfop.btn,
- content: op.url,
- skin: dfop.btn == null ? 'lr-layer-nobtn' : 'lr-layer',
- success: function (layero, index) {
- top['layer_' + dfop.id] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
- layero[0].learun_layerid = 'layer_' + dfop.id;
- //如果底部有按钮添加-确认并关闭窗口勾选按钮
- if (!!dfop.btn && layero.find('.lr-layer-btn-cb').length == 0) {
- top.learun.language.get('确认并关闭窗口',
- function (text) {
- layero.find('.layui-layer-btn')
- .append('<div class="checkbox lr-layer-btn-cb" myIframeId="layer_' +
- dfop.id +
- '" ><label><input checked="checked" type="checkbox" >' +
- text +
- '</label></div>');
- });
- layero.find('.layui-layer-btn a').each(function () {
- var $this = $(this);
- var _text = $this.text();
- top.learun.language.get(_text,
- function (text) {
- $this.text(text);
- });
-
- });
- }
- layero.find('.layui-layer-title').each(function () {
- var $this = $(this);
- var _text = $this.text();
- top.learun.language.get(_text,
- function (text) {
- $this.text(text);
- });
-
- });
- },
- yes: function (index) {
- var flag = true;
- if (!!dfop.callBack) {
- flag = dfop.callBack('layer_' + dfop.id);
- }
- if (!!flag) {
- learun.layerClose('', index);
- }
- },
- end: function () {
- top['layer_' + dfop.id] = null;
- if (!!dfop.end) {
- dfop.end();
- }
- }
- });
- },
-
- layerFormForPercent: function (op) {
- var dfop = {
- id: null,
- title: '系统窗口',
- width: 550,
- height: 400,
- url: 'error',
- btn: ['确认', '关闭'],
- callBack: false,
- maxmin: false,
- end: false,
- };
- $.extend(dfop, op || {});
-
- /*适应窗口大小*/
- dfop.width = dfop.width > $(window).width() ? $(window).width() - 10 : dfop.width;
- dfop.height = dfop.height > $(window).height() ? $(window).height() - 10 : dfop.height;
-
- var r = top.layer.open({
- id: dfop.id,
- maxmin: dfop.maxmin,
- type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
- title: dfop.title,
- area: [dfop.width, dfop.height],
- btn: dfop.btn,
- content: op.url,
- skin: dfop.btn == null ? 'lr-layer-nobtn' : 'lr-layer',
- success: function (layero, index) {
- top['layer_' + dfop.id] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
- layero[0].learun_layerid = 'layer_' + dfop.id;
- //如果底部有按钮添加-确认并关闭窗口勾选按钮
- if (!!dfop.btn && layero.find('.lr-layer-btn-cb').length == 0) {
- top.learun.language.get('确认并关闭窗口',
- function (text) {
- layero.find('.layui-layer-btn')
- .append('<div class="checkbox lr-layer-btn-cb" myIframeId="layer_' +
- dfop.id +
- '" ><label><input checked="checked" type="checkbox" >' +
- text +
- '</label></div>');
- });
- layero.find('.layui-layer-btn a').each(function () {
- var $this = $(this);
- var _text = $this.text();
- top.learun.language.get(_text,
- function (text) {
- $this.text(text);
- });
-
- });
- }
- layero.find('.layui-layer-title').each(function () {
- var $this = $(this);
- var _text = $this.text();
- top.learun.language.get(_text,
- function (text) {
- $this.text(text);
- });
-
- });
- },
- yes: function (index) {
- var flag = true;
- if (!!dfop.callBack) {
- flag = dfop.callBack('layer_' + dfop.id);
- }
- if (dfop.id == 'formitem') {
- learun.layerClose('', index);
- }
- if (!!flag) {
- learun.layerClose('', index);
- }
- },
- end: function () {
- top['layer_' + dfop.id] = null;
- if (!!dfop.end) {
- dfop.end();
- }
- }
- });
- },
- // 关闭弹层
- layerClose: function (name, index) {
- var _index;
- if (!!index) {
- _index = index;
- } else {
- _index = top.layer.getFrameIndex(name);
- }
- var layero = top.$("#layui-layer" + _index);
- var $IsClose = layero.find('.layui-layer-btn').find(".lr-layer-btn-cb input");
- var IsClose = $IsClose.is(":checked");
- if ($IsClose.length == 0) {
- IsClose = true;
- }
- if (IsClose) {
- top.layer.close(_index); //再执行关闭
- } else {
- top[layero[0].learun_layerid].location.reload();
- }
-
- },
- prompt: function (text, callback) {
- top.layer.prompt({ title: text, formType: 2 }, callback);
- },
- close: function (index) {
- top.layer.close(index);
- }
- });
-
-
- })(window.jQuery, top.learun);
|