-
Notifications
You must be signed in to change notification settings - Fork 248
feat(ng-model-options) Added ng-model-options #974
Changes from 5 commits
fcfc248
c1a2cc4
82dd42d
68e21a6
308d8dc
e706b93
ac37d3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
part of angular.directive; | ||
|
||
@Decorator(selector: 'input[ng-model-options]') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some doc about the purpose of this class would be great! |
||
class NgModelOptions { | ||
int _debounceDefaultValue = 0; | ||
int _debounceBlurValue; | ||
int _debounceChangeValue; | ||
int _debounceInputValue; | ||
|
||
static const String _DEBOUNCE_DEFAULT_KEY = "default"; | ||
static const String _DEBOUNCE_BLUR_KEY = "blur"; | ||
static const String _DEBOUNCE_CHANGE_KEY = "change"; | ||
static const String _DEBOUNCE_INPUT_KEY = "input"; | ||
|
||
NgModelOptions(NodeAttrs attrs) { | ||
Map options = convert.JSON.decode(attrs["ng-model-options"].replaceFirst("debounce", "'debounce'").replaceAll("'", "\"")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we just have valid JSON as input ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only thing i was trying to achieve to match the angularjs spec There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually you should check how this is done in ng_pluralize.dart IMO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the comment has been removed: please check ng-pluralize There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what should i check ng-pluralize for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some attributes have a JSON format On 04/29/2014 01:21 AM, jrote1 wrote:
|
||
|
||
if (options["debounce"].containsKey(_DEBOUNCE_DEFAULT_KEY)){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing ws |
||
_debounceDefaultValue = options["debounce"][_DEBOUNCE_DEFAULT_KEY]; | ||
} | ||
_debounceBlurValue = options["debounce"][_DEBOUNCE_BLUR_KEY]; | ||
_debounceChangeValue = options["debounce"][_DEBOUNCE_CHANGE_KEY]; | ||
_debounceInputValue = options["debounce"][_DEBOUNCE_INPUT_KEY]; | ||
} | ||
|
||
async.Timer _blurTimer; | ||
void executeBlurFunc(func()) { | ||
var delay = _debounceBlurValue == null ? _debounceDefaultValue : _debounceBlurValue; | ||
_blurTimer = _runFuncDebounced(delay, func,_blurTimer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ", " There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
} | ||
|
||
async.Timer _changeTimer; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls move properties at the top of the class, before methods |
||
void executeChangeFunc(func()) { | ||
var delay = _debounceChangeValue == null ? _debounceDefaultValue : _debounceChangeValue; | ||
_changeTimer = _runFuncDebounced(delay, func, _changeTimer); | ||
} | ||
|
||
async.Timer _inputTimer; | ||
void executeInputFunc(func()) { | ||
var delay = _debounceInputValue == null ? _debounceDefaultValue : _debounceInputValue; | ||
_inputTimer = _runFuncDebounced(delay, func, _inputTimer); | ||
} | ||
|
||
async.Timer _runFuncDebounced(int delay, func(), async.Timer timer){ | ||
if (timer != null && timer.isActive) timer.cancel(); | ||
|
||
if(delay == 0){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
notice ws & formatting |
||
func(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add missing {} |
||
return null; | ||
} else { | ||
return new async.Timer(new Duration(milliseconds: delay), func); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert