This file contains 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 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 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 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 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 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 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 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) { |
This file contains 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
var app = angular.module('limit-max', []); | |
/** | |
* 限制输入的最大数,最小数无法设置,因为删除时无法判断 | |
* @example | |
* <input ng-model="xx" type="number" limit-max="100"> | |
*/ | |
app.directive('limitMax', function() { | |
return { | |
restrict : 'A', |
This file contains 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() { | |
var app = angular.module('tools', []); | |
/** | |
* syncCheckboxModalToArray | |
* @$scope | |
* @modal string | |
* @array string | |
*/ | |
app.factory('syncCheckboxModalToArray', function() { |