How to use layui - 10 common examples

To help you get started, we’ve selected a few layui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RAOE / show-videos / scetc-show-videos-admin / src / main / resources / static / js / layui.js View on Github external
}());
      }
    }
    
    //回调
    function onCallback(){
      exports.push(layui[item]);
      apps.length > 1 ?
        that.use(apps.slice(1), callback, exports)
      : ( typeof callback === 'function' && callback.apply(layui, exports) );
    }
    
    //如果使用了 layui.all.js
    if(apps.length === 0 
    || (layui['layui.all'] && modules[item]) 
    || (!layui['layui.all'] && layui['layui.mobile'] && modules[item])
    ){
      return onCallback(), that;
    }

    //首次加载模块
    if(!config.modules[item]){
      var node = doc.createElement('script')
      
      //如果是内置模块,则按照 dir 参数拼接模块路径
      //如果是扩展模块,则判断模块路径值是否为 {!} 开头,
      //  如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。
      //  否则,则按照 base 参数拼接模块路径
      ,url = ( modules[item] ? (dir + 'lay/') 
        : (/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || ''))
      ) + (that.modules[item] || item) + '.js';
github RAOE / show-videos / scetc-show-videos-admin / src / main / resources / static / js / layui.js View on Github external
config.status[item] ? onCallback() : setTimeout(poll, 4);
        }());
      }
    }
    
    //回调
    function onCallback(){
      exports.push(layui[item]);
      apps.length > 1 ?
        that.use(apps.slice(1), callback, exports)
      : ( typeof callback === 'function' && callback.apply(layui, exports) );
    }
    
    //如果使用了 layui.all.js
    if(apps.length === 0 
    || (layui['layui.all'] && modules[item]) 
    || (!layui['layui.all'] && layui['layui.mobile'] && modules[item])
    ){
      return onCallback(), that;
    }

    //首次加载模块
    if(!config.modules[item]){
      var node = doc.createElement('script')
      
      //如果是内置模块,则按照 dir 参数拼接模块路径
      //如果是扩展模块,则判断模块路径值是否为 {!} 开头,
      //  如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。
      //  否则,则按照 base 参数拼接模块路径
      ,url = ( modules[item] ? (dir + 'lay/') 
        : (/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || ''))
      ) + (that.modules[item] || item) + '.js';
github weizhiqiang1995 / skyeye / skyeye-promote / src / main / resources / template / assets / lib / layui / layui.js View on Github external
}());
			}
		}

		// 回调
		function onCallback() {
			exports.push(layui[item]);
			apps.length > 1 ?
				that.use(apps.slice(1), callback, exports) :
				(typeof callback === 'function' && callback.apply(layui, exports));
		}

		// 如果使用了 layui.all.js
		if(apps.length === 0 ||
			(layui['layui.all'] && modules[item]) ||
			(!layui['layui.all'] && layui['layui.mobile'] && modules[item])
		) {
			return onCallback(), that;
		}

		// 首次加载模块
		if(!config.modules[item]) {
			var node = doc.createElement('script'),
				// 如果是内置模块,则按照 dir 参数拼接模块路径
				// 如果是扩展模块,则判断模块路径值是否为 {/} 开头,
				// 如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。
				// 否则,则按照 base 参数拼接模块路径
				url = (modules[item] ? (dir + 'lay/') :
					(/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || ''))
				) + (that.modules[item] || item) + '.js';
			url = url.replace(/^\{\/\}/, '');
			//判断URL拼接可访问路径
github Meowv / Blog / src / MeowvBlog.SOA / wwwroot / admin / lib / layui / layui.js View on Github external
config.status[item] ? onCallback() : setTimeout(poll, 4);
        }());
      }
    }
    
    //回调
    function onCallback(){
      exports.push(layui[item]);
      apps.length > 1 ?
        that.use(apps.slice(1), callback, exports)
      : ( typeof callback === 'function' && callback.apply(layui, exports) );
    }
    
    //如果使用了 layui.all.js
    if(apps.length === 0 
    || (layui['layui.all'] && modules[item]) 
    || (!layui['layui.all'] && layui['layui.mobile'] && modules[item])
    ){
      return onCallback(), that;
    }

    //首次加载模块
    if(!config.modules[item]){
      var node = doc.createElement('script')
      
      //如果是内置模块,则按照 dir 参数拼接模块路径
      //如果是扩展模块,则判断模块路径值是否为 {/} 开头,
      //如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。
      //否则,则按照 base 参数拼接模块路径
      ,url = ( modules[item] ? (dir + 'lay/') 
        : (/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || ''))
      ) + (that.modules[item] || item) + '.js';
github nabaonan / layui-operating / frame / layui / layui.js View on Github external
if(item === 'jquery'){
        apps.splice(index, 1);
      }
    });
    layui.jquery = jQuery;
  }

  var item = apps[0], timeout = 0;
  exports = exports || [];

  //静态资源host
  config.host = config.host || (dir.match(/\/\/([\s\S]+?)\//)||['//'+ location.host +'/'])[0];

  if(apps.length === 0
  || (layui['layui.all'] && modules[item])
  || (!layui['layui.all'] && layui['layui.mobile'] && modules[item])
  ){
    return onCallback(), that;
  }

  //加载完毕
  function onScriptLoad(e, url){
    var readyRegExp = navigator.platform === 'PLaySTATION 3' ? /^complete$/ : /^(complete|loaded)$/
    if (e.type === 'load' || (readyRegExp.test((e.currentTarget || e.srcElement).readyState))) {
      config.modules[item] = url;
      head.removeChild(node);
      (function poll() {
        if(++timeout > config.timeout * 1000 / 4){
          return error(item + ' is not a valid module');
        };
        config.status[item] ? onCallback() : setTimeout(poll, 4);
      }());
github flyhero / flyapi / flyapi-web / src / main / webapp / static / layui / layui.js View on Github external
}());
      }
    }
    
    //回调
    function onCallback(){
      exports.push(layui[item]);
      apps.length > 1 ?
        that.use(apps.slice(1), callback, exports)
      : ( typeof callback === 'function' && callback.apply(layui, exports) );
    }
    
    //如果使用了 layui.all.js
    if(apps.length === 0 
    || (layui['layui.all'] && modules[item]) 
    || (!layui['layui.all'] && layui['layui.mobile'] && modules[item])
    ){
      return onCallback(), that;
    }

    //首次加载模块
    if(!config.modules[item]){
      var node = doc.createElement('script')
      
      //如果是内置模块,则按照 dir 参数拼接模块路径
      //如果是扩展模块,则判断模块路径值是否为 {/} 开头,
      //如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。
      //否则,则按照 base 参数拼接模块路径
      ,url = ( modules[item] ? (dir + 'lay/') 
        : (/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || ''))
      ) + (that.modules[item] || item) + '.js';
github weizhiqiang1995 / skyeye / skyeye-web / src / main / webapp / assets / lib / layui / layui.js View on Github external
Layui.prototype.define = function(deps, factory){
		var that = this, type = typeof deps === 'function', callback = function(){
			var setApp = function(app, exports){
				layui[app] = exports;
				config.status[app] = true;
			};
			typeof factory === 'function' && factory(function(app, exports){
				setApp(app, exports);
				config.callback[app] = function(){
					factory(setApp);
				}
			});
			return this;
		};
		type && (factory = deps,deps = []);
		if(layui['layui.all'] || (!layui['layui.all'] && layui['layui.mobile'])){
			return callback.call(that);
		}
		that.use(deps, callback);
		return that;
	};
github yubaolee / OpenAuth.Net / OpenAuth.Mvc / layui / layui.js View on Github external
};
      typeof factory === 'function' && factory(function(app, exports){
        setApp(app, exports);
        config.callback[app] = function(){
          factory(setApp);
        }
      });
      return this;
    };
    
    type && (
      factory = deps,
      deps = []
    );
    
    if(layui['layui.all'] || (!layui['layui.all'] && layui['layui.mobile'])){
      return callback.call(that);
    }

    that.use(deps, callback);
    return that;
  };
github Joyrocky / DormitoryManager / out / artifacts / dormitorySystem_war_exploded / lib / layui / layui.js View on Github external
n.prototype.cache = o, n.prototype.define = function (e, t) {
        var n = this, r = "function" == typeof e, i = function () {
            var e = function (e, t) {
                layui[e] = t, o.status[e] = !0
            };
            return "function" == typeof t && t(function (n, r) {
                e(n, r), o.callback[n] = function () {
                    t(e)
                }
            }), this
        };
        return r && (t = e, e = []), layui["layui.all"] || !layui["layui.all"] && layui["layui.mobile"] ? i.call(n) : (n.use(e, i), n)
    }, n.prototype.use = function (e, n, l) {
        function s(e, t) {

layui

Classic modular Front-End UI library

MIT
Latest version published 15 days ago

Package Health Score

92 / 100
Full package analysis

Popular layui functions