Skip to content

Commit

Permalink
Allow 0.0 as value
Browse files Browse the repository at this point in the history
  • Loading branch information
magbeat committed Nov 5, 2015
1 parent b165d5d commit e0eab41
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/ng-inline-edit.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ng-inline-edit v0.6.0 (http://tamerayd.in/ng-inline-edit)
* ng-inline-edit v0.7.1 (http://tamerayd.in/ng-inline-edit)
* Copyright 2015 Tamer Aydin (http://tamerayd.in)
* Licensed under MIT
*/
Expand Down
10 changes: 8 additions & 2 deletions dist/ng-inline-edit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ng-inline-edit v0.6.0 (http://tamerayd.in/ng-inline-edit)
* ng-inline-edit v0.7.1 (http://tamerayd.in/ng-inline-edit)
* Copyright 2015 Tamer Aydin (http://tamerayd.in)
* Licensed under MIT
*/
Expand Down Expand Up @@ -166,6 +166,7 @@
link: function(scope, element, attrs) {
scope.model = scope.$parent.$eval(attrs.inlineEdit);
scope.isInputTextarea = attrs.hasOwnProperty('inlineEditTextarea');
scope.isNumber = isNumber;

var onBlurBehavior = attrs.hasOwnProperty('inlineEditOnBlur') ?
attrs.inlineEditOnBlur : InlineEditConfig.onBlur;
Expand Down Expand Up @@ -199,7 +200,8 @@
'ng-class="{\'ng-inline-edit__text--placeholder\': !model}" ' +
(attrs.hasOwnProperty('inlineEditOnClick') || InlineEditConfig.editOnClick ?
'ng-click="editText()" ' : '') +
'ng-if="!editMode">{{(model || placeholder)' +
'ng-if="!editMode">{{' +
(scope.isNumber(scope.model) || scope.model ? 'model' : 'placeholder') +
(attrs.hasOwnProperty('inlineEditFilter') ? ' | ' + attrs.inlineEditFilter : '') +
'}}</span>'));

Expand Down Expand Up @@ -256,6 +258,10 @@
attrs.$observe('inlineEditPlaceholder', function(placeholder) {
scope.placeholder = placeholder;
});

function isNumber(value) {
return !isNaN(parseFloat(value)) && isFinite(value);
}
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion dist/ng-inline-edit.min.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ng-inline-edit v0.6.0 (http://tamerayd.in/ng-inline-edit)
* ng-inline-edit v0.7.1 (http://tamerayd.in/ng-inline-edit)
* Copyright 2015 Tamer Aydin (http://tamerayd.in)
* Licensed under MIT
*/
Expand Down
4 changes: 2 additions & 2 deletions dist/ng-inline-edit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ng-inline-edit",
"description": "Simple inline editing for HTML elements",
"version": "0.7.0",
"version": "0.7.1",
"main": "dist/ng-inline-edit.js",
"keywords": [
"angular",
Expand Down
8 changes: 7 additions & 1 deletion src/scripts/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
link: function(scope, element, attrs) {
scope.model = scope.$parent.$eval(attrs.inlineEdit);
scope.isInputTextarea = attrs.hasOwnProperty('inlineEditTextarea');
scope.isNumber = isNumber;

var onBlurBehavior = attrs.hasOwnProperty('inlineEditOnBlur') ?
attrs.inlineEditOnBlur : InlineEditConfig.onBlur;
Expand Down Expand Up @@ -52,7 +53,8 @@
'ng-class="{\'ng-inline-edit__text--placeholder\': !model}" ' +
(attrs.hasOwnProperty('inlineEditOnClick') || InlineEditConfig.editOnClick ?
'ng-click="editText()" ' : '') +
'ng-if="!editMode">{{(model || placeholder)' +
'ng-if="!editMode">{{' +
(scope.isNumber(scope.model) || scope.model ? 'model' : 'placeholder') +
(attrs.hasOwnProperty('inlineEditFilter') ? ' | ' + attrs.inlineEditFilter : '') +
'}}</span>'));

Expand Down Expand Up @@ -109,6 +111,10 @@
attrs.$observe('inlineEditPlaceholder', function(placeholder) {
scope.placeholder = placeholder;
});

function isNumber(value) {
return !isNaN(parseFloat(value)) && isFinite(value);
}
}
};
}
Expand Down

0 comments on commit e0eab41

Please sign in to comment.