-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from ecomfe/dev
0.2.9
- Loading branch information
Showing
10 changed files
with
149 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* @file 锦囊进行权限验证的基础容器 | ||
* @file 进行权限验证的基础容器 | ||
* @author Justineo([email protected]) | ||
*/ | ||
|
||
|
@@ -10,7 +10,7 @@ define(function (require) { | |
var auth = require('../system/auth'); | ||
|
||
/** | ||
* 锦囊权限编辑器权限节点 | ||
* 权限编辑器权限节点 | ||
* | ||
* @param {Object} [options] 初始化参数 | ||
* @extends esui.Panel | ||
|
@@ -60,7 +60,7 @@ define(function (require) { | |
root = root || me.main; | ||
|
||
// 可以通过设置disabled属性禁用的控件 | ||
// 见 http://www.w3.org/html/wg/drafts/html/master/disabled-elements.html | ||
// 见 http://www.w3.org/TR/html/disabled-elements.html | ||
var disableableTagNames = [ | ||
'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA', | ||
'OPTGROUP', 'OPTION', 'COMMAND', 'FIELDSET' | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* @file 让输入控件在特定事件下自动校验rule | ||
* @author feibinyang | ||
*/ | ||
define( | ||
function (require) { | ||
var u = require('underscore'); | ||
var lib = require('esui/lib'); | ||
var Extension = require('esui/Extension'); | ||
var InputControl = require('esui/InputControl'); | ||
|
||
/** | ||
* 让输入控件在特定事件下自动校验rule | ||
* | ||
* @param {Object} [options] 配置项 | ||
* @extends esui.Extension | ||
* @constructor | ||
*/ | ||
function AutoValidate(options) { | ||
options = options || {}; | ||
if (typeof options.events === 'string') { | ||
options.events = u.map( | ||
lib.splitTokenList(options.events), | ||
lib.trim | ||
); | ||
} | ||
|
||
Extension.apply(this, arguments); | ||
} | ||
|
||
/** | ||
* 扩展的类型,始终为`"AutoValidate"` | ||
* | ||
* @type {string} | ||
* @override | ||
*/ | ||
AutoValidate.prototype.type = 'AutoValidate'; | ||
|
||
/** | ||
* 指定用于提交表单的事件名称,默认为`change`和`input`事件 | ||
* | ||
* @type {string[]} | ||
*/ | ||
AutoValidate.prototype.events = ['change', 'input']; | ||
|
||
/** | ||
* 验证rule | ||
* | ||
* @param {esui.Control} this 触发事件的控件 | ||
* @ignore | ||
*/ | ||
function validate() { | ||
if (!(this.target instanceof InputControl)) { | ||
throw new Error('Current target is not an instance of InputControl.'); | ||
} | ||
this.target.validate(); | ||
} | ||
|
||
/** | ||
* 激活扩展 | ||
* | ||
* @override | ||
*/ | ||
AutoValidate.prototype.activate = function () { | ||
u.each( | ||
this.events, | ||
function (eventName) { | ||
this.target.on(eventName, validate, this); | ||
}, | ||
this | ||
); | ||
Extension.prototype.activate.apply(this, arguments); | ||
}; | ||
|
||
/** | ||
* 取消激活 | ||
* | ||
* @override | ||
*/ | ||
AutoValidate.prototype.inactivate = function () { | ||
u.each( | ||
this.events, | ||
function (eventName) { | ||
this.target.un(eventName, validate, this); | ||
}, | ||
this | ||
); | ||
|
||
Extension.prototype.inactivate.apply(this, arguments); | ||
}; | ||
|
||
lib.inherits(AutoValidate, Extension); | ||
require('esui').registerExtension(AutoValidate); | ||
return AutoValidate; | ||
} | ||
); |
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