This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function () { | |
/** | |
* 创建一个绝对定位的相对定位DOM | |
* @param html | |
* @param parent | |
* @constructor | |
*/ | |
function CreateDom (html, parent) { | |
this.dom = document.createElement('div'); | |
this.parent = document.querySelector(parent); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.log = function () { | |
var args = [].slice.call(arguments); | |
args.forEach(function (v, k) { | |
if(typeof v === 'object') args[k] = JSON.stringify(v); | |
}); | |
alert([].join.call(args, '\n')); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 切换元素显示状态 | |
* | |
* @param btns {object} 定义要切换的元素组 | |
* @constructor | |
* @example | |
var actions = new ChangeState({ a: ['#box', '#box2'], b: ['.box3']); | |
actions.a(); | |
*/ | |
function ChangeState(btns) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function previewImg(el, inputFile) { | |
el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = scale)"; | |
el.filters("DXImageTransform.Microsoft.AlphaImageLoader").src = inputFile.value; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.QUERYSTRING = (function () { | |
var params = {}, | |
pair = (window.location.search.substr(1)).split('&'); | |
if (pair[0]) { | |
for (var i = 0; i < pair.length; i++) { | |
var pos = pair[i].split('='); | |
params[pos[0]] = decodeURIComponent(pos[1]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 替换字符串 ${} | |
* @param obj | |
* @returns {String} | |
* @example | |
* '我是${str}'.render({str: '测试'}); | |
*/ | |
String.prototype.render = function (obj) { | |
var str = this, reg; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.getRouteParams = function () { | |
var params = [], | |
routes = (window.location.pathname).split('/'); | |
for(var i = 0; i < routes.length; i++) { | |
if(routes[i]) params.push(routes[i]); | |
} | |
return params; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.closeWindow = function () { | |
window.open('', '_self', ''); | |
window.close(); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 给图片打文字水印 | |
* @param img Object||String | |
* @param opt | |
* @constructor | |
*/ | |
function Watermark(img, opt) { | |
this.opt = opt; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 轮询ajax请求 | |
* @param fn | |
* @param [delay = 500] | |
* @constructor | |
* @example | |
* var pa = new PollAjax(function (continueNext, done) { | |
$.get('../') | |
.done(function (data) { | |
if (data.success) { |