UNPKG

landers.base

Version:

landers.base

1,171 lines (1,135 loc) 80.7 kB
// md5 ;!function(n){"use strict";function t(n,t){var r=(65535&n)+(65535&t),e=(n>>16)+(t>>16)+(r>>16);return e<<16|65535&r}function r(n,t){return n<<t|n>>>32-t}function e(n,e,o,u,c,f){return t(r(t(t(e,n),t(u,f)),c),o)}function o(n,t,r,o,u,c,f){return e(t&r|~t&o,n,t,u,c,f)}function u(n,t,r,o,u,c,f){return e(t&o|r&~o,n,t,u,c,f)}function c(n,t,r,o,u,c,f){return e(t^r^o,n,t,u,c,f)}function f(n,t,r,o,u,c,f){return e(r^(t|~o),n,t,u,c,f)}function i(n,r){n[r>>5]|=128<<r%32,n[(r+64>>>9<<4)+14]=r;var e,i,a,h,d,l=1732584193,g=-271733879,v=-1732584194,m=271733878;for(e=0;e<n.length;e+=16)i=l,a=g,h=v,d=m,l=o(l,g,v,m,n[e],7,-680876936),m=o(m,l,g,v,n[e+1],12,-389564586),v=o(v,m,l,g,n[e+2],17,606105819),g=o(g,v,m,l,n[e+3],22,-1044525330),l=o(l,g,v,m,n[e+4],7,-176418897),m=o(m,l,g,v,n[e+5],12,1200080426),v=o(v,m,l,g,n[e+6],17,-1473231341),g=o(g,v,m,l,n[e+7],22,-45705983),l=o(l,g,v,m,n[e+8],7,1770035416),m=o(m,l,g,v,n[e+9],12,-1958414417),v=o(v,m,l,g,n[e+10],17,-42063),g=o(g,v,m,l,n[e+11],22,-1990404162),l=o(l,g,v,m,n[e+12],7,1804603682),m=o(m,l,g,v,n[e+13],12,-40341101),v=o(v,m,l,g,n[e+14],17,-1502002290),g=o(g,v,m,l,n[e+15],22,1236535329),l=u(l,g,v,m,n[e+1],5,-165796510),m=u(m,l,g,v,n[e+6],9,-1069501632),v=u(v,m,l,g,n[e+11],14,643717713),g=u(g,v,m,l,n[e],20,-373897302),l=u(l,g,v,m,n[e+5],5,-701558691),m=u(m,l,g,v,n[e+10],9,38016083),v=u(v,m,l,g,n[e+15],14,-660478335),g=u(g,v,m,l,n[e+4],20,-405537848),l=u(l,g,v,m,n[e+9],5,568446438),m=u(m,l,g,v,n[e+14],9,-1019803690),v=u(v,m,l,g,n[e+3],14,-187363961),g=u(g,v,m,l,n[e+8],20,1163531501),l=u(l,g,v,m,n[e+13],5,-1444681467),m=u(m,l,g,v,n[e+2],9,-51403784),v=u(v,m,l,g,n[e+7],14,1735328473),g=u(g,v,m,l,n[e+12],20,-1926607734),l=c(l,g,v,m,n[e+5],4,-378558),m=c(m,l,g,v,n[e+8],11,-2022574463),v=c(v,m,l,g,n[e+11],16,1839030562),g=c(g,v,m,l,n[e+14],23,-35309556),l=c(l,g,v,m,n[e+1],4,-1530992060),m=c(m,l,g,v,n[e+4],11,1272893353),v=c(v,m,l,g,n[e+7],16,-155497632),g=c(g,v,m,l,n[e+10],23,-1094730640),l=c(l,g,v,m,n[e+13],4,681279174),m=c(m,l,g,v,n[e],11,-358537222),v=c(v,m,l,g,n[e+3],16,-722521979),g=c(g,v,m,l,n[e+6],23,76029189),l=c(l,g,v,m,n[e+9],4,-640364487),m=c(m,l,g,v,n[e+12],11,-421815835),v=c(v,m,l,g,n[e+15],16,530742520),g=c(g,v,m,l,n[e+2],23,-995338651),l=f(l,g,v,m,n[e],6,-198630844),m=f(m,l,g,v,n[e+7],10,1126891415),v=f(v,m,l,g,n[e+14],15,-1416354905),g=f(g,v,m,l,n[e+5],21,-57434055),l=f(l,g,v,m,n[e+12],6,1700485571),m=f(m,l,g,v,n[e+3],10,-1894986606),v=f(v,m,l,g,n[e+10],15,-1051523),g=f(g,v,m,l,n[e+1],21,-2054922799),l=f(l,g,v,m,n[e+8],6,1873313359),m=f(m,l,g,v,n[e+15],10,-30611744),v=f(v,m,l,g,n[e+6],15,-1560198380),g=f(g,v,m,l,n[e+13],21,1309151649),l=f(l,g,v,m,n[e+4],6,-145523070),m=f(m,l,g,v,n[e+11],10,-1120210379),v=f(v,m,l,g,n[e+2],15,718787259),g=f(g,v,m,l,n[e+9],21,-343485551),l=t(l,i),g=t(g,a),v=t(v,h),m=t(m,d);return[l,g,v,m]}function a(n){var t,r="";for(t=0;t<32*n.length;t+=8)r+=String.fromCharCode(n[t>>5]>>>t%32&255);return r}function h(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t<r.length;t+=1)r[t]=0;for(t=0;t<8*n.length;t+=8)r[t>>5]|=(255&n.charCodeAt(t/8))<<t%32;return r}function d(n){return a(i(h(n),8*n.length))}function l(n,t){var r,e,o=h(n),u=[],c=[];for(u[15]=c[15]=void 0,o.length>16&&(o=i(o,8*n.length)),r=0;16>r;r+=1)u[r]=909522486^o[r],c[r]=1549556828^o[r];return e=i(u.concat(h(t)),512+8*t.length),a(i(c.concat(e),640))}function g(n){var t,r,e="0123456789abcdef",o="";for(r=0;r<n.length;r+=1)t=n.charCodeAt(r),o+=e.charAt(t>>>4&15)+e.charAt(15&t);return o}function v(n){return unescape(encodeURIComponent(n))}function m(n){return d(v(n))}function p(n){return g(m(n))}function s(n,t){return l(v(n),v(t))}function C(n,t){return g(s(n,t))}function A(n,t,r){return t?r?s(t,n):C(t,n):r?m(n):p(n)}"function"==typeof define&&define.amd?define(function(){return A}):"object"==typeof module&&module.exports?module.exports=A:n.md5=A}(this); ; (function (window, $) { window.Landers = window.Landers || {}; var env = Landers.env = { path:{}, config:{cache:false, debug:false}, current_script:function(){ var scripts = document.getElementsByTagName('script'); return scripts[scripts.length-1]; }, current_url_param:function(name, url){ url = url || document.location.href; var a = url.split('?'); url = a[0]; var params = a[1]; if (!params) return; a = params.split('&'); var j = {}; for(var i=0; i<a.length; i++) { var aa = a[i].split('='); j[aa[0]] = aa[1]; } return name ? j[name] : j; }, current_url:function(){ var url1 = this.currentScript().getAttribute('src'); //必须用getAttribute,否则IE=EmulateIE7写与不写两种结果 var url2 = this.currentUrlParam('url', url1); return url2 || url1; } }; $.extend(env.path, { home:'', script:'/static/script/', ui:{ css:'/static/css/' } }); })(this, jQuery); ; (function (window, $, Landers) { Landers = Landers || {}; Landers.utils = { is_string: function(x) { return typeof(x) == 'string'; }, isString: function(x) { return this.is_string(x); }, is_defined: function(x) { return typeof(x) != 'undefined'; }, isDefined: function(x) { return this.is_defined(x); }, is_null: function(x) { return (x === null || !this.is_defined(x)); }, isNull: function(x){ return this.is_null(x); }, is_fun: function(x) { return typeof(x) == 'function'; }, isFunction: function(x){ return this.is_fun(x); }, is_bool: function(x) { return typeof(x) == 'boolean'; }, isBool: function(x){ return this.is_bool(x); }, is_json: function(x) { return typeof(x) == "object" && Object.prototype.toString.call(x).toLowerCase() == "[object object]" && !x.length; }, isJson: function(x){ return this.is_json(x); }, is_jquery: function(x) { return Landers.utils.type(x) == 'jQuery'; }, isJQuery: function(x){ return this.is_jquery(x); }, is_numeric: function(x) { return $.isNumeric(x); }, isNumeric: function(x){ return this.is_numeric(x); }, is_array: function(x) { try { return x.constructor == Array; } catch (e) { return false; } }, isArray: function(x){ return this.is_array(x); }, is_object: function(o) { return (o !== null && typeof(o) == 'object'); }, isObject: function(o){ return this.is_object(o); }, is_rgb: function(s) { return (s.length === 4 || s.length === 7) && s.indexOf('#') === 0; }, isRGB: function(s){ return this.is_rgb(s); }, is_url: function(s) { return s.indexOf('/') != -1 || s.indexOf('\\') != -1; }, isUrl: function(s){ return this.is_url(s); }, is_ie: function() { return !!window.ActiveXObject; }, isIE: function(){ return this.is_ie(); }, is_ie6: function() { return !-[1, ] && !window.XMLHttpRequest; }, isIE6: function(){ return this.is_ie6(); }, is_ie7: function() { return this.ie() && navigator.appVersion.split(";")[1].replace(/[ ]/g, "") == "MSIE7.0"; }, isIE7: function(){ return this.is_ie7(); }, is_mobile: function() { return navigator.userAgent.match(/(iPhone|iPod|Android|ios|iOS|iPad|Backerry|WebOS|Symbian|Windows Phone|Phone)/i); }, isMobile: function(){ return this.is_mobile(); }, is_android: function() { return navigator.userAgent.match(/Android/i); }, isAndroid: function(){ return this.is_android(); }, is_ios: function() { return navigator.userAgent.match(/(iPhone|iPod|iPad|iOS)/i); }, isIOS: function(){ return this.is_ios(); }, to: { bool:function (x){ return x === 'true' || x === 'TRUE' || x === 1 || x === true; }, array:function(){ var args = arguments, dat = args[0], a; switch(Landers.utils.type(dat)) { case 'string' : var split = args[1] || ','; a = dat.split(split); for(var i=0; i<a.length; i++) a[i] = $.trim(a[i]); return a; case 'json' : a = []; for (var s in dat) a.push([s,dat[s]]); return a; case 'array' : return dat; } }, json:{ encode:function(j){return JSON.stringify(j);}, decode:function(s){return $.parseJSON(s);} }, utf8:{ encode:function(str){ var out = '', i, len = str.length, c; for(i = 0; i < len; i++) { c = str.charCodeAt(i); if ((c >= 0x0001) && (c <= 0x007F)) { out += str.charAt(i); } else if (c > 0x07FF) { out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); } else { out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); } } return out; } }, hex:{ encode:function(){ var monyer = new Array(), i, s; is = is === false ? false : true; for (i = 0; i < str.length; i++) { s = str.charCodeAt(i).toString(16); monyer += is ? "\\x" + s : (new Array(5 - String(s).length).join("0") + s); } return monyer; }, decode:function(){ var monyer = new Array(); var s = str.split("\\"); for (i = 1; i < s.length; i++) { s[i] = s[i].replace('x', ''); monyer += String.fromCharCode(parseInt(s[i], 16)); } return monyer; } }, constructor:function(obj) { var con = obj.constructor; if (!con) return undefined; if (con.name) return con.name; var str = con.toString(); var arr = str.charAt(0) == '[' ? str.match(/\[\w+\s*(\w+)\]/) : str.match(/function\s*(\w+)/); if (arr && arr.length == 2) return arr[1]; return undefined; } }, time:{ toHuman : function(oDate){ var year = oDate.getFullYear(); var month = oDate.getMonth() + 1; month = month < 10 ? "0" + month : month; var day = oDate.getDate(); day = day < 10 ? "0" + day : day; var hour = oDate.getHours(); hour = hour < 10 ? "0" + hour : hour; var minute = oDate.getMinutes(); minute = minute < 10 ? "0" + minute : minute; var second = oDate.getSeconds(); second = second < 10 ? "0" + second : second; return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second; }, //功能:把日期转为unix时间戳 data2unix : function(year, month, day, hour, minute, second) { var UTC = Date.UTC(year, (month - 1), day, hour, minute, second); var oDate = new Date(UTC); return oDate.getTime() / 1000 - 8 * 60 * 60; }, //功能:把unix时间戳转成Y-m-d H:i:s格式的日期 unix2human:function(unix) { var now = new Date(unix * 1000); return this.toHuman(now); }, parse : function(oDate) { return { y : oDate.getFullYear(), m : oDate.getMonth() + 1, d : oDate.getDate(), h : oDate.getHours(), i : oDate.getMinutes(), s : oDate.getSeconds() }; }, nowUnix:function(){ //当前时间戳 var d = this.parse(new Date()); return this.data2unix(d.y, d.m, d.d, d.h, d.i, d.s); } }, str:{ sprintf : function(){ var ret = arguments[0]; for (var i=1; i<arguments.length; i++) { ret = ret.replace('%s', arguments[i]); } return ret; }, snakeCase : function(str) { return str.replace(/[A-Z]/g, function($1) { return "_" + ($1.toLowerCase()); }); }, camelCase : function(str) { str = str.toLowerCase(); var reg = /\b(\w)|\s(\w)/g; //  \b判断边界\s判断空格 return str.replace(reg, function(m){ return m.toUpperCase(); }); }, len:function(str){return str.replace(/[\u0391-\uFFE5]/g,' ').length;}, right:function(str, n){return str.slice(str.slice(-n).replace(/[\x00-\xff]/g,"").length-n);}, left:function(str, n){return str.slice(0,n-str.slice(0,n).replace(/[\x00-\xff]/g,"").length);}, replace:function(str, s1, s2) { if (str === null || str === undefined) return ''; try { str = str.toString(); } catch(e) { console.log(str); } s1 = s1.replace(/\{/,'\\{').replace(/\}/,'\\}'); var re = new RegExp(s1,"gi"); return str.replace(re,s2); }, random:function(n){ var s = ''; for ( var i=0;i<6;i++ ) { s += Math.floor( Math.random()*10 ).toString(); } return s; }, stripHTML : function(str) { var reTag = /<(?:.|\s)*?>/g; return str.replace(reTag,""); } }, json: { create:function(j, str, hasself) { j = j || {}; var a = str.split('.'), jtmp = j; if (hasself) a = a.splice(1); for (var i=0; i<a.length; i++) { if (!jtmp[a[i]]) jtmp[a[i]] = {}; jtmp = jtmp[a[i]]; } }, count:function(j){var c = 0; for (var p in j) c++; return c;}, slice:function(j, keys) { j = j || {}; var ret = {}; if ( !Landers.utils.is_array(keys)) keys = keys.split(','); for (var i = 0; i < keys.length; i++ ) { var key = $.trim(keys[i]); ret[key] = j[key]; } return ret; }, count:function(j){var c=0; for (var k in j) c++; return c;}, keys:function(j){var a=[]; for (var k in j) a.push(k); return a;}, values:function(j){var a=[]; for (var k in j) a.push(j[k]); return a;}, filter: function(j, value){ var ret = {}; for (var k in j) { if (value === j[k]) ret[k] = j[k]; }; return ret; } }, arr: { remove_val:function(arr, v) { for(var i=0;i<arr.length;i++){ if(v == arr[i]) arr.splice(i,1); } return arr; }, search:function(x, arr, from){ return $.inArray(x, arr, from || 0); }, is_in:function(x, arr, from){ return this.search(x, arr, from || 0) >= 0; }, isIn: function(x, arr, from){ return this.is_in(x, arr, from); }, random:function(arr){ return arr[Landers.utils.math.random(0, arr.length-1)]; }, sum:function(arr){ var r = 0; for (var i=0; i<arr.length; i++){ var t = parseFloat(arr[i]); if (t) r += t; }; return r; }, shuffle:function(arr) { var a = arr.slice(); var s = new Array(); while (a.length) s.push(a.splice(Math.random() * a.length, 1)[0]); while (s.length) a.push(s.pop()); return a; }, rand:function(arr, n){ var a = arr.slice(); var aret = new Array(); for (var i=1; i<=n; i++){ var idx = Landers.utils.math.random(0,a.length-1); var val = a[idx]; aret.push(val); a.remove(idx,true); } return aret.length > 1 ? aret : aret[0]; }, cross:function(a1,a2){ var a = []; for (var i=0;i<a1.length;i++){ var idx = a2.search(a1[i]); if (idx!==null) a.push(a2[idx]); }; return a; }, unique:function(arr){ var aflag = new Array(); for (var i=0;i<=arr.length-1;i++) aflag[i] = false; for (var i=0;i<=arr.length-1;i++){ for (var j=i+1;j<=arr.length-1;j++){ if (this[i]==arr[j]) aflag[j] = true; } } for (var i=aflag.length-1;i>=0;i--){ if (aflag[i]) arr.splice(i,1); }; return arr; } }, type: function(x){ try{if (x instanceof jQuery) return 'jQuery';}catch(e){} var ret = $.type(x); if (ret != 'object') return ret; if ( $.isPlainObject(x) ) return 'json'; var type = this.to.constructor(x); var arr = type.match(/^HTML(.*)Element$/); if (arr) return arr[1].toLowerCase(); if (type != 'Object') return type; return ret; }, math: { add:function(n1, n2){ var r1, r2, m; try{r1 = n1.toString().split(".")[1].length;} catch(e) {r1 = 0;} try{r2 = n2.toString().split(".")[1].length;} catch(e) {r2 = 0;} m = Math.pow(10 , Math.max(r1, r2)); return (n1 * m + n2 * m ) / m ; }, round:function(num, n){ return Math.round(num*Math.pow(10,n || 0))/Math.pow(10,n || 0); }, random:function(n1,n2){ var max = Math.max(n1,n2), min = Math.min(n1,n2); return parseInt(Math.random()*(max-min+1)) + min; } }, dom:{ add_param:function(o,name,val){ var param = document.createElement('param'); param.setAttribute('name', name); param.setAttribute('value', val); o.appendChild(param); } } }; })(this, jQuery, Landers); ; (function (window, $) { Landers = Landers || {}; Landers.animate = { _callbacks:'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oAnimationEnd animationend', mod_complete:false, mod_init:function(callback){ var me = this; if (me.mod_complete) { return callback && callback(); }; Landers.loader.cssm('animate', function(){ me.mod_complete = true; callback && callback(); }); }, effects:{ 'default' : {'in':'scaleUp', out:'scaleDown', random:true}, //fade 'fade1': {'in':'fadeIn', out:'fadeOut', 'duration-out':300, random:true}, 'fade2' : {'in':'pop_fadein', out:'pop_fadeout', random:true}, 'fade3' : {'in':'scaleUp', out:'pop_fadeout', random:true}, 'fade4' : {'in':'pop_fadein', out:'scaleDown', random:true}, //zoom 'zoom1': {'in':'scaleUp', out:'scaleDown', random:true}, 'zoom2': {'in':'zoomIn', out:'zoomOut', duration:500, random:true}, 'zoom3' : {'in':'pop_fadein3x', out:'pop_fadeout3x', random:true}, 'zoom4': {'in':'zoomInDown', out:'zoomOutDown'}, 'zoom5': {'in':'zoomInUp', out:'zoomOutUp'}, 'zoom6': {'in':'zoomInLeft', out:'zoomOutRight'}, 'zoom7': {'in':'zoomInRight', out:'zoomOutLeft'}, 'zoom8': {'in':'bounceIn', out:'bounceOut', duration:500, random:true}, //hmove 'hmove1': {'in':'bounceInLeft', out:'bounceOutRight', 'duration-in':500, 'duration-out':1000, random:true}, 'hmove2': {'in':'fadeInLeft', out:'fadeOutRight', 'duration-in':500, 'duration-out':300, random:true}, 'hmove3': {'in':'lightSpeedIn', out:'lightSpeedOut', 'duration-in':500, 'duration-out':300}, //vmove 'vmove1': {'in':'bounceInDown', out:'bounceOutDown', 'duration-in':500, 'duration-out':1000, random:true}, 'vmove2': {'in':'fadeInDown', out:'fadeOutUp', 'duration-in':200, 'duration-out':300, random:true}, //hflip 'hflip1': {'in':'flipInY', out:'flipOutY', duration:600}, 'hflip2': {'in':'flip', out:'scaleDown', 'duration-out':500}, //vflip 'vflip1': {'in':'flipInX', out:'flipOutX', duration:600, random:true}, //rotate 'rotate1': {'in':'rotateIn', out:'rotateOut', duration:500}, 'rotate2': {'in':'rotateInUpLeft', out:'rotateOutUpRight', duration:500, random:true}, 'rotate3': {'in':'rotateInDownLeft', out:'rotateOutUpRight', duration:500}, 'rotate4': {'in':'rotateInNewspaper', out:'rotateOutNewspaper'}, //roll 'roll1': {'in':'rollIn', out:'rollOut', duration:500}, //flash 'flash1': {'in':'flash', out:'flash', duration:500} }, random:function(){ return 'default'; var keys = []; for (var i in this.effects) { if (this.effects[i].random) keys.push(i); } var n = Landers.utils.math.random(0, keys.length-1); return keys[n]; }, attach:function(xo, xclass, duration, callback){ var me = this; me.mod_init(function(){ var $o = $(xo).show().visible().removeClass(xclass); xclass += ' animated'; if (duration) { $o.css({'animation-duration': duration + 'ms' }); $o.css({'transition-duration': duration + 'ms' }); }; $o.addClass(xclass).one(me._callbacks, function(){ $o.removeClass(xclass); callback && callback(); }); }); }, show:function(xin, effect, callback) { effect = effect || 'default'; var effect = this.effects[effect]; var class_in = effect['in']; var duration = effect['duration-in'] || effect['duration']; this.attach(xin, class_in, duration, function(){ $(xin).show(); callback && callback(); }); }, hide:function(xout, effect, callback){ effect = effect || 'default'; var effect = this.effects[effect]; var class_out = effect['out']; var duration = effect['duration-out'] || effect['duration']; this.attach(xout, class_out, duration, function(){ $(xout).hide(); callback && callback(); }); }, transitive:function(xout, effect_out, xin, effect_in, callback, is_sync){ var me = this; var effect_out = effect_out || 'default'; var effect_in = effect_in || 'default'; if (is_sync) { me.hide(xout, effect_out); me.show(xin, effect_in, function(){ callback && callback(); }); } else { me.hide(xout, effect_out, function(){ me.show(xin, effect_in, function(){ callback && callback(); }); }); } } }; })(this, jQuery, Landers); ; (function (window, $, Landers) { Landers = Landers || {}; Landers.cookie = function(name, val, opts){ if (Landers.utils.is_defined(val)){ if (val===null) val = ''; opts = opts || {}; var expires = '',date; if (opts.expires){ if (typeof(opts.expires)=='number'){ date = new Date(); date.setTime(date.getTime()+(opts.expires*60*60*1000)); } else if (opts.expires.toUTCString){date = opts.expires} expires = '; expires=' + date.toUTCString(); } var path = opts.path ? '; path=' + (opts.path) : '; path=/'; var domain = opts.domain ? '; domain=' + (opts.domain) : ''; var secure = opts.secure ? '; secure' : ''; var dat = [name , '=' , encodeURIComponent(val) , expires , path , domain , secure]; document.cookie = dat.join(''); } else { var ret = null ; if (document.cookie){ var a = document.cookie.split(';'); for (var i=0; i<a.length; i++){ var s = $.trim(a[i]); if (s.substring(0,name.length+1)==(name+'=')){ ret = decodeURIComponent(s.substring(name.length + 1));break; } } }; return ret; } }; })(this, jQuery, Landers); ; (function (window, $, Landers) { Landers = Landers || {}; Landers.css = { add:function(){ if (arguments.length == 2) { var k = arguments[0], v = arguments[1], content = []; if (!Landers.utils.is_string(v)){ for (var i in v) content.push(i + ':' + v[i]); } content = content.join(';'); content = k + ' {' + content + '}'; } else { var arg = arguments[0], content = ''; if (Landers.utils.is_array(arg)) { for (var i=0; i<arg.length; i++) content += arg[i]; } else { content = arg; } } try { //高版本浏览器 var $head = $('head'), $o = $('style'); if (!$o.length) $o = $('<style></style>').appendTo($head).attr({type:'text/css'}); var oStyle = $o.get(0); oStyle.innerHTML += '\n' + content; } catch(e) { //低版本浏览器,如ie8 var match = content.match(/(.*?)\{(.*?)\}/); var k = $.trim(match[1]), v = $.trim(match[2]); var t = document.styleSheets; var oStyle = t.length ? t[0]:document.createStyleSheet(); oStyle.addRule(k, v); } }, remove:function(k){this.add(k,'')} }; })(this, jQuery, Landers); ; (function (window, $, Landers) { Landers = Landers || {}; Landers.dialog = { loadmod:function(skin, callback){ if (window.art) return callback && callback(); var mods = ['landers.dialog,skins/' + (skin || 'ulan') + '.css']; Landers.loader.jsm(mods, function(){ setTimeout(callback, 200); }, {loading:true}); }, show:function(opts, skin){ this.loadmod(skin, function(){ Landers.dialog.show(opts); }) }, tip:function(msg, time){ this.loadmod('default', function(){ art.dialog.tips(msg, time); }) } }; })(this, jQuery, Landers); ; (function (window, $, Landers) { Landers = Landers || {}; Landers.helpers = { loadmod_call:function(mod, call){ if (!call) return; if (Landers.utils.is_string(call)) mod[call].call(mod); else if (Landers.utils.is_fun(call)) call.call(mod); }, parse_args:function(args, maps){ var ret = {}, enums; maps = maps || {}; //找出enum项 for(var k in maps) { var arr = k.match(/^__ENUM:(.*)$/); if (arr) { enums = enums || {}; enums[k] = eval('(' + arr[1] + ')'); } } for (var i=0; i<args.length; i++) { var type = Landers.utils.type(args[i]); if (type == 'jQuery') type = 'jobject'; if (enums && (type == 'string' || type == 'number')) { var tmp = false; for (var j in enums) { if (Landers.utils.arr.is_in(args[i], enums[j])) { ret[maps[j]] = args[i]; delete enums[j]; tmp = true; } } if (tmp) continue; } if (maps[type]) { ret[maps[type]] = args[i]; } else { ret[type] = args[i]; } }; return ret; }, parseArgs: function(args, maps){ return this.parse_args(args, maps); }, debug : function(xvar){ if (Landers.env.config.debug) { console.log(xvar); alert(xvar); } }, throttle : function(seconds){ var last; this.getTime = function(){ return (new Date()).getTime(); }; this.check = function(){ if ( this.getTime() - last >= seconds * 1000 || !last) { last = this.getTime(); return true; } else { return false; } }; }, eventstop:function(e){ if (e && e.stopPropagation) { e.stopPropagation(); } else if (window.event) { window.event.cancelBubble = true; } }, reload:function(){ setTimeout(function(){ document.location.reload(); }, 200); }, noimg:function(oimg, is_bg, src){ var path = Landers.env.path.ui.img; var def_bg = path + 'noimg.jpg', $o = $(oimg); oimg.src = src || $o.attr('nosrc') || path + 'spacer.gif'; if (is_bg) $o.css('background', 'url('+def_bg+') center'); oimg.onload = null; }, noavatar:function(oimg){ oimg.src = Landers.env.path.ui.img + 'noavatar_middle.gif'; }, gotop:function(callback){ var $o = $('html body'); $o.animate({ scrollTop: 0 }, { easing: 'easeOutExpo', duration: $o.scrollTop() * 0.5 , complete: callback }); }, disable : function($o) { return $o.prop('disabled', true).addClass('disabled'); }, enable : function($o) { return $o.prop('disabled', false).removeClass('disabled'); }, countdown : { _countdown: function(seconds, callback_run, callback_stop){ var that = this; var is_stop = false; this.start = this.run = function(){ if(seconds >= 0 && !is_stop){ setTimeout(function(){ callback_run(seconds--); that.run(seconds, callback_run, callback_stop); }, 1000); } else { callback_stop(); } return this; }; this.stop = function(){ is_stop = true; callback_stop(); return this; }; }, make : function(seconds, callback_run, callback_stop){ return new this._countdown(seconds, callback_run, callback_stop); }, show: function($elem, seconds, callback_run, callback_stop){ $elem.prop('disabled', true).addClass('disabled'); var content = $elem.attr('data-countdown-content'); var backup = $elem.html(); return this.make(seconds, function(seconds){ $elem.html(content.replace('%s', seconds)); }, function(){ $elem.html(backup) .prop('disabled', false) .removeClass('disabled'); callback_stop && callback_stop(); }).run(); }, sms : function($elem, seconds, callback_stop){ $elem.attr('data-countdown-content', '%s 秒后可再次发送'); this.show($elem, seconds, null, callback_stop); } }, parseErrors: function(errors){ var results = []; for (var key in errors) { results.push(errors[key][0]); } return results; } }; $.extend(Landers, Landers.helpers); })(this, jQuery, Landers); //Spiner !function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return l[e]||(m.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",m.cssRules.length),l[e]=1),e}function d(a,b){var c,d,e=a.style;for(b=b.charAt(0).toUpperCase()+b.slice(1),d=0;d<k.length;d++)if(c=k[d]+b,void 0!==e[c])return c;return void 0!==e[b]?b:void 0}function e(a,b){for(var c in b)a.style[d(a,c)||c]=b[c];return a}function f(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)void 0===a[d]&&(a[d]=c[d])}return a}function g(a,b){return"string"==typeof a?a:a[b%a.length]}function h(a){this.opts=f(a||{},h.defaults,n)}function i(){function c(b,c){return a("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',c)}m.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.width,left:d.radius,top:-d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.length+d.width,k=2*j,l=2*-(d.width+d.length)+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}var j,k=["webkit","Moz","ms","O"],l={},m=function(){var c=a("style",{type:"text/css"});return b(document.getElementsByTagName("head")[0],c),c.sheet||c.styleSheet}(),n={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"iSpinner",top:"50%",left:"50%",position:"absolute"};h.defaults={},f(h.prototype,{spin:function(b){this.stop();{var c=this,d=c.opts,f=c.el=e(a(0,{className:d.className}),{position:d.position,width:0,zIndex:d.zIndex});d.radius+d.length+d.width}if(e(f,{left:d.left,top:d.top}),b&&b.insertBefore(f,b.firstChild||null),f.setAttribute("role","progressbar"),c.lines(f,c.opts),!j){var g,h=0,i=(d.lines-1)*(1-d.direction)/2,k=d.fps,l=k/d.speed,m=(1-d.opacity)/(l*d.trail/100),n=l/d.lines;!function o(){h++;for(var a=0;a<d.lines;a++)g=Math.max(1-(h+(d.lines-a)*n)%l*m,d.opacity),c.opacity(f,a*d.direction+i,g,d);c.timeout=c.el&&setTimeout(o,~~(1e3/k))}()}return c},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=void 0),this},lines:function(d,f){function h(b,c){return e(a(),{position:"absolute",width:f.length+f.width+"px",height:f.width+"px",background:b,boxShadow:c,transformOrigin:"left",transform:"rotate("+~~(360/f.lines*k+f.rotate)+"deg) translate("+f.radius+"px,0)",borderRadius:(f.corners*f.width>>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k<f.lines;k++)i=e(a(),{position:"absolute",top:1+~(f.width/2)+"px",transform:f.hwaccel?"translate3d(0,0,0)":"",opacity:f.opacity,animation:j&&c(f.opacity,f.trail,l+k*f.direction,f.lines)+" "+1/f.speed+"s linear infinite"}),f.shadow&&b(i,e(h("#000","0 0 4px #000"),{top:"2px"})),b(d,b(i,h(g(f.color,k),"0 0 1px rgba(0,0,0,.1)")));return d},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}});var o=e(a("group"),{behavior:"url(#default#VML)"});return!d(o,"transform")&&o.adj?i():j=d(o,"animation"),h}); (function($){ if (!$.browser) $.browser = { msie: Landers.utils.is_ie(), version: '' }; if ($.fn.off && !$.fn.die) $.fn.die = $.fn.off; /** * [ifShow description] * @param {[type]} condition [description] * @param {Function} callback [description] * @return {[type]} [description] */ $.fn.ifShow = function( condition, callback ){ var me = this, $me = $(me); if ( condition ) $me.show(function(){ callback && callback.call(me, condition); }); else $me.hide(function(){ callback && callback.call(me, condition); }); }; /** * jQuery.toTop.js v1.0 $('.to-top').toTop({ //options with default values autohide: true, //boolean 'true' or 'false' offset: 420, //numeric value (as pixels) for scrolling length from top to hide automatically speed: 500, //numeric value (as mili-seconds) for duration right: 15, //numeric value (as pixels) for position from right bottom: 30 //numeric value (as pixels) for position from bottom }); **/ $.fn.toTop = function(t) { var e = this, i = $(window), s = $("html, body"), n = $.extend({ autohide: false, offset: 420, speed: 500, right: 15, bottom: 30 }, t); e.css({ right: n.right, bottom: n.bottom, cursor: "pointer" }), n.autohide && e.css("display", "none"), e.click(function() { s.animate({ scrollTop: 0 }, n.speed) }), i.scroll(function() { var o = i.scrollTop(); n.autohide && (o > n.offset ? e.fadeIn(n.speed) : e.fadeOut(n.speed)) }) }; /** * [visible description] * @return {[type]} [description] */ $.fn.visible = function(){ return $(this).css('visibility', 'visible'); }; /** * [hidden description] * @return {[type]} [description] */ $.fn.hidden = function(){ return $(this).css('visibility', 'hidden'); }; /** * [boxsize description] * @param {[type]} size [description] * @return {[type]} [description] */ $.fn.boxsize = function(size) { if (size) { $(this).width(size.width).height(size.height); return this; } else { return { width: $(this).width(), height: $(this).height() } } }; /** * [setCenter description] */ $.fn.setCenter = function() { var $jq = $(this); $jq.css({ 'text-align': 'center', 'vertical-align': 'middle', 'left': '50%', 'top': '50%' }); var pos = $jq.css('position'); if (pos == 'absolute' || pos == 'fixed') { $jq.css({ 'margin-left': -$jq.width() / 2 + 'px', 'margin-top': -$jq.height() / 2 + 'px' }); } else { $jq.css({ magin: '0 auto' }); }; return $jq; }; /** * [tag description] * @return {[type]} [description] */ $.fn.tag = function() { if (!this.length) return ''; return this.get(0).tagName.toLowerCase(); }; /** * [outerhtml description] * @return {[type]} [description] */ $.fn.outerhtml = $.fn.outerHtml = function() { var $tmp = $('<p></p>'), $clone = this.clone().appendTo($tmp), html = $tmp.html(); $tmp.remove(); return html; }; /** * [response description] * @param {[type]} dat [description] * @param {[type]} time [description] * @return {[type]} [description] */ $.fn.response = function(dat, time) { var $jq = $(this); var delay = 300, msg; if (dat === null) msg = ''; else if (typeof dat === 'string') msg = dat; else if ($.isArray(dat)) msg = dat[1]; if (time === true) time = 8 * delay; var hide = function($_o, _time) { setTimeout(function() { $_o.fadeOut(delay); }, _time); }; $jq.addClass('response'); var $o = $jq.children(), _class; if (dat !== null) { if (typeof dat === 'string') _class = 'info'; else if (typeof dat[0] === 'boolean') _class = dat[0] ? 'error' : 'success'; else if ($.isNumeric(dat[0])) _class = dat[0] < 10 ? (dat[0] == 0 ? 'success' : 'info') : 'error'; else _class = !!dat[0] ? 'error' : 'success'; }; if (msg) { $o.remove(); $o = $('<span class="text"></span>') .addClass(_class) .hide() .appendTo($jq) .html(msg) .fadeIn(delay, function() { if (time) hide($(this), time); }); } else { hide($o, time); } return $jq; }; /** * [showSpin description] * @param {[type]} opts [description] * @return {[type]} [description] */ $.fn.showSpin = function(opts) { this.each(function() { var $this = $(this), data = $this.data(); if (data.spinner) { data.spinner.stop(); delete data.spinner }; if (opts !== false) { opts = $.extend({ color: $this.css('color') }, opts); data.spinner = new Spinner(opts).spin(this) }; }); return this; }; /** * [mySize description] * @return {[type]} [description] */ $.fn.mySize = function() { var $jq = $(this), o = $jq.get(0); if (!o) { o = window; $jq = $(o); } var w, sw, h, sh, ret = {}, debug = false; if ($.isWindow(o)) { var win = o, doc = document, body = doc.body; if (win.innerHeight) { if (debug) alert(11); w = doc.documentElement.clientWidth; w = w ? w : win.innerWidth, h = win.innerHeight } else if (doc.documentElement && doc.documentElement.clientHeight) { if (debug) alert(12); w = doc.documentElement.clientWidth; h = doc.documentElement.clientHeight } else if (body) { if (debug) alert(13); w = body.clientWidth; h = body.clientHeight }; ret.width = w; ret.height = h; if (win.innerHeight && win.scrollMaxY) { if (debug) alert(21); sw = win.innerWidth + win.scrollMaxX; sh = win.innerHeight + win.scrollMaxY; } else if (body.scrollHeight > body.offsetHeight) { if (debug) alert(22); sw = body.scrollWidth; sh = body.scrollHeight; } else { if (debug) alert(23); sw = body.offsetWidth; sh = body.offsetHeight; }; ret.scroll_width = sw; ret.scroll_height = sh; } else { ret = { width: $jq.width(), height: $jq.height(), scroll_width: o.scrollWidth, scroll_height: o.scrollHeight } }; return ret; }; /** * [overlay description] * @param {[type]} act [description] * @param {[type]} opts [description] * @return {[type]} [description] */ $.fn.overlay = function(act, opts) { act = act.toLowerCase(); opts = opts || {}; var $jq = $(this), delay = 300, data_key = 'overlay'; if (!$.isWindow($jq.get(0)) && !$jq.tag() == 'body') { $jq.css({ position: 'relative' }); }; switch (act) { case 'show': var mysize = $jq.mySize(); var opacity = opts.alpha || opts.opacity; if (opacity === undefined) opacity = 0.2; if (opacity > 1) opacity = opacity / 100; $jq.data(data_key, $('<div></div>').css({ width: '100%', height: Math.max(mysize.height, mysize.scroll_height), position: 'absolute', left: '0px', top: '0px', filter: 'alpha(opacity=' + (opacity * 100) + ')', opacity: opacity, 'background-color': opts.bgcolor || '#000000', 'z-index': opts.zindex || 4001 }).appendTo($jq).fadeIn(delay)); break; case 'hide': $($jq.data(data_key)).fadeOut(delay, function() { $(this).remove(); }); $jq.data(data_key, null); } return this; }; /* var gotoTag = function(id, val) { if (val == undefined) { val = 0; } var id = (id) ? $(id).offset().top : 0, str = id - val; $('html, body').stop().animate({scrollTop: str}, 800, 'easeInOutQuart'); }; */ /** * [scrollMe description] * @param {[type]} offset [description] * @return {[type]} [description] */ $.fn.scrollMe = function(offset) { var $jq = $(this), offset = offset = 0; $('html, body').stop().animate({ scrollTop: $jq.offset().top-offset }, 800, 'easeInOutQuart'); }; /** * 设置状态 * [status description] * @return {[type]} [description] */ $.fn.status = function(status, options){ var texts = {}; var $me = $(this); if ( !$me.data('original-html') ) { $me.data('original-html', $me.html()); } var styles = { loading: { html: '<i class="glyphicon glyphicon-cog glyphicon-spin fa fa-cog fa-spin"></i>', disabled: true, }, success: { html: '<i class="glyphicon glyphicon-ok"></i>', disabled: true, }, error: { html: '<i class="glyphicon glyphicon-minus-sign"></i>', disabled: false, }, countdown: { html: '', disabled: true, callback: function(){ var seconds = options.seconds; var callback = options.callback; var scene = options.scen