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
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 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() { | |
var app = angular.module('tools', []); | |
/** | |
* syncCheckboxModalToArray | |
* @$scope | |
* @modal string | |
* @array string | |
*/ | |
app.factory('syncCheckboxModalToArray', function() { |
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
fnInterval(5, 1000, function (index) { | |
console.log(index); | |
}); | |
/** | |
* 间隔执行fn | |
* @param {number} time 次数 | |
* @param {number} delay 间隔毫秒 | |
* @param {Function} fn fn(index) index从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
setViewPort(640); | |
/** | |
* 设置窗口宽度 | |
* @param width | |
*/ | |
function setViewPort(width) { | |
var scale = window.screen.width / width, | |
isAndroid = /Android (\d+\.\d+)/.test(navigator.userAgent); |
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.prototype.after = function (fn) { | |
var that = this; | |
return function () { | |
var ret = that.apply(this, arguments); | |
fn.apply(this, arguments); | |
return ret; | |
}; |
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 getJsDir (src) { | |
var script = null; | |
if (src) { | |
script = [].filter.call(document.scripts, function (v) { | |
return v.src.indexOf(src) !== -1; | |
})[0]; | |
} else { | |
script = document.scripts[document.scripts.length - 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 errMsg | |
* @param scriptURI | |
* @param lineNumber | |
* @param columnNumber | |
* @param errorObj | |
* @return | |
*/ | |
window.onerror = function (errMsg, scriptURI, lineNumber, columnNumber, errorObj) { |
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 element | |
* @param event | |
* @returns {boolean} | |
*/ | |
function fireEvent (element, event) { | |
var evt; | |
if (document.createEventObject) { |
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
/** | |
* 转换为整数 | |
* @returns {this} | |
*/ | |
Number.prototype.toInt = function () { | |
return isNaN(this) ? 0 : parseInt(this); | |
}; |