mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
changed remaining ng- to ng:
This commit is contained in:
parent
228b54aa2e
commit
87cfc27be3
9 changed files with 44 additions and 44 deletions
|
|
@ -19,7 +19,7 @@ WidgetFactory.prototype = {
|
|||
if (exp) exp = exp.split(':').pop();
|
||||
var event = "change";
|
||||
var bubbleEvent = true;
|
||||
var formatter = angularFormatter[input.attr('ng-format')] || angularFormatter['noop'];
|
||||
var formatter = angularFormatter[input.attr('ng:format')] || angularFormatter['noop'];
|
||||
if (type == 'button' || type == 'submit' || type == 'reset' || type == 'image') {
|
||||
controller = new ButtonController(input[0], exp, formatter);
|
||||
event = "click";
|
||||
|
|
@ -191,8 +191,8 @@ function TextController(view, exp, formatter) {
|
|||
this.view = view;
|
||||
this.formatter = formatter;
|
||||
this.exp = exp;
|
||||
this.validator = view.getAttribute('ng-validate');
|
||||
this.required = typeof view.attributes['ng-required'] != "undefined";
|
||||
this.validator = view.getAttribute('ng:validate');
|
||||
this.required = typeof view.attributes['ng:required'] != "undefined";
|
||||
this.lastErrorText = null;
|
||||
this.lastValue = undefined;
|
||||
this.initialValue = this.formatter['parse'](view.value);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var angularFilterGoogleChartApi;
|
|||
|
||||
foreach({
|
||||
'currency': function(amount){
|
||||
this.$element.toggleClass('ng-format-negative', amount < 0);
|
||||
this.$element.toggleClass('ng:format-negative', amount < 0);
|
||||
return '$' + angularFilter['number'].apply(this, [amount, 2]);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ function modelAccessor(scope, element) {
|
|||
|
||||
function modelFormattedAccessor(scope, element) {
|
||||
var accessor = modelAccessor(scope, element),
|
||||
formatterName = element.attr('ng-format') || NOOP,
|
||||
formatterName = element.attr('ng:format') || NOOP,
|
||||
formatter = angularFormatter(formatterName);
|
||||
if (!formatter) throw "Formatter named '" + formatterName + "' not found.";
|
||||
return {
|
||||
|
|
@ -33,10 +33,10 @@ function compileValidator(expr) {
|
|||
}
|
||||
|
||||
function valueAccessor(scope, element) {
|
||||
var validatorName = element.attr('ng-validate') || NOOP,
|
||||
var validatorName = element.attr('ng:validate') || NOOP,
|
||||
validator = compileValidator(validatorName),
|
||||
requiredExpr = element.attr('ng-required'),
|
||||
formatterName = element.attr('ng-format') || NOOP,
|
||||
requiredExpr = element.attr('ng:required'),
|
||||
formatterName = element.attr('ng:format') || NOOP,
|
||||
formatter = angularFormatter(formatterName),
|
||||
format, parse, lastError, required;
|
||||
invalidWidgets = scope.$invalidWidgets || {markValid:noop, markInvalid:noop};
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ BinderTest.prototype.testChangingRadioUpdatesModel = function(){
|
|||
};
|
||||
|
||||
BinderTest.prototype.testChangingCheckboxUpdatesModel = function(){
|
||||
var form = this.compile('<input type="checkbox" name="model.price" value="true" checked ng-format="boolean"/>');
|
||||
var form = this.compile('<input type="checkbox" name="model.price" value="true" checked ng:format="boolean"/>');
|
||||
assertEquals(true, form.scope.model.price);
|
||||
};
|
||||
|
||||
|
|
@ -508,8 +508,8 @@ BinderTest.prototype.testFillInOptionValueWhenMissing = function() {
|
|||
};
|
||||
|
||||
BinderTest.prototype.testValidateForm = function() {
|
||||
var c = this.compile('<div><input name="name" ng-required>' +
|
||||
'<div ng:repeat="item in items"><input name="item.name" ng-required/></div></div>');
|
||||
var c = this.compile('<div><input name="name" ng:required>' +
|
||||
'<div ng:repeat="item in items"><input name="item.name" ng:required/></div></div>');
|
||||
var items = [{}, {}];
|
||||
c.scope.$set("items", items);
|
||||
c.scope.$eval();
|
||||
|
|
@ -537,7 +537,7 @@ BinderTest.prototype.testValidateForm = function() {
|
|||
};
|
||||
|
||||
BinderTest.prototype.testValidateOnlyVisibleItems = function(){
|
||||
var c = this.compile('<div><input name="name" ng-required><input ng:show="show" name="name" ng-required></div>');
|
||||
var c = this.compile('<div><input name="name" ng:required><input ng:show="show" name="name" ng:required></div>');
|
||||
jqLite(document.body).append(c.node);
|
||||
c.scope.$set("show", true);
|
||||
c.scope.$eval();
|
||||
|
|
@ -660,7 +660,7 @@ BinderTest.prototype.XtestItShouldRenderMultiRootHtmlInBinding = function() {
|
|||
};
|
||||
|
||||
BinderTest.prototype.testItShouldUseFormaterForText = function() {
|
||||
var x = this.compile('<input name="a" ng-format="list" value="a,b">');
|
||||
var x = this.compile('<input name="a" ng:format="list" value="a,b">');
|
||||
x.scope.$eval();
|
||||
assertEquals(['a','b'], x.scope.$get('a'));
|
||||
var input = x.node;
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ FiltersTest.prototype.testCurrency = function(){
|
|||
var currency = bind(context, angular.filter.currency);
|
||||
|
||||
assertEquals(currency(0), '$0.00');
|
||||
assertEquals(html.hasClass('ng-format-negative'), false);
|
||||
assertEquals(html.hasClass('ng:format-negative'), false);
|
||||
assertEquals(currency(-999), '$-999.00');
|
||||
assertEquals(html.hasClass('ng-format-negative'), true);
|
||||
assertEquals(html.hasClass('ng:format-negative'), true);
|
||||
assertEquals(currency(1234.5678), '$1,234.57');
|
||||
assertEquals(html.hasClass('ng-format-negative'), false);
|
||||
assertEquals(html.hasClass('ng:format-negative'), false);
|
||||
};
|
||||
|
||||
FiltersTest.prototype.testFilterThisIsContext = function(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ ValidatorTest.prototype.testItShouldHaveThisSet = function() {
|
|||
validator.last = last;
|
||||
validator._this = this;
|
||||
};
|
||||
var scope = compile('<input name="name" ng-validate="myValidator:\'hevery\'"/>');
|
||||
var scope = compile('<input name="name" ng:validate="myValidator:\'hevery\'"/>');
|
||||
scope.name = 'misko';
|
||||
scope.$init();
|
||||
assertEquals('misko', validator.first);
|
||||
|
|
@ -109,7 +109,7 @@ describe('Validator:asynchronous', function(){
|
|||
|
||||
it('should make a request and show spinner', function(){
|
||||
var value, fn;
|
||||
var scope = compile('<input type="text" name="name" ng-validate="asynchronous:asyncFn"/>');
|
||||
var scope = compile('<input type="text" name="name" ng:validate="asynchronous:asyncFn"/>');
|
||||
scope.$init();
|
||||
var input = scope.$element;
|
||||
scope.asyncFn = function(v,f){
|
||||
|
|
@ -151,7 +151,7 @@ describe('Validator:asynchronous', function(){
|
|||
});
|
||||
|
||||
it("should handle update function", function(){
|
||||
var scope = angular.compile('<input name="name" ng-validate="asynchronous:asyncFn:updateFn"/>');
|
||||
var scope = angular.compile('<input name="name" ng:validate="asynchronous:asyncFn:updateFn"/>');
|
||||
scope.asyncFn = jasmine.createSpy();
|
||||
scope.updateFn = jasmine.createSpy();
|
||||
scope.name = 'misko';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
WidgetTest = TestCase('WidgetTest');
|
||||
|
||||
WidgetTest.prototype.testRequired = function () {
|
||||
var view = $('<input name="a" ng-required>');
|
||||
var view = $('<input name="a" ng:required>');
|
||||
var scope = new Scope({$invalidWidgets:[]});
|
||||
var cntl = new TextController(view[0], 'a', angularFormatter.noop);
|
||||
cntl.updateView(scope);
|
||||
|
|
@ -14,7 +14,7 @@ WidgetTest.prototype.testRequired = function () {
|
|||
};
|
||||
|
||||
WidgetTest.prototype.testValidator = function () {
|
||||
var view = $('<input name="a" ng-validate="testValidator:\'ABC\'">');
|
||||
var view = $('<input name="a" ng:validate="testValidator:\'ABC\'">');
|
||||
var scope = new Scope({$invalidWidgets:[]});
|
||||
var cntl = new TextController(view[0], 'a', angularFormatter.noop);
|
||||
angular.validator.testValidator = function(value, expect){
|
||||
|
|
@ -42,7 +42,7 @@ WidgetTest.prototype.testValidator = function () {
|
|||
};
|
||||
|
||||
WidgetTest.prototype.testRequiredValidator = function () {
|
||||
var view = $('<input name="a" ng-required ng-validate="testValidator:\'ABC\'">');
|
||||
var view = $('<input name="a" ng:required ng:validate="testValidator:\'ABC\'">');
|
||||
var scope = new Scope({$invalidWidgets:[]});
|
||||
var cntl = new TextController(view[0], 'a', angularFormatter.noop);
|
||||
angular.validator.testValidator = function(value, expect){
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ describe("service", function(){
|
|||
|
||||
describe("$invalidWidgets", function(){
|
||||
it("should count number of invalid widgets", function(){
|
||||
var scope = compile('<input name="price" ng-required ng-validate="number"></input>').$init();
|
||||
var scope = compile('<input name="price" ng:required ng:validate="number"></input>').$init();
|
||||
expect(scope.$invalidWidgets.length).toEqual(1);
|
||||
scope.price = 123;
|
||||
scope.$eval();
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ describe("widget", function(){
|
|||
expect(scope.$get('count')).toEqual(2);
|
||||
});
|
||||
|
||||
describe("ng-format", function(){
|
||||
describe("ng:format", function(){
|
||||
|
||||
it("should format text", function(){
|
||||
compile('<input type="Text" name="list" value="a,b,c" ng-format="list"/>');
|
||||
compile('<input type="Text" name="list" value="a,b,c" ng:format="list"/>');
|
||||
expect(scope.$get('list')).toEqual(['a', 'b', 'c']);
|
||||
|
||||
scope.$set('list', ['x', 'y', 'z']);
|
||||
|
|
@ -57,7 +57,7 @@ describe("widget", function(){
|
|||
});
|
||||
|
||||
it("should come up blank if null", function(){
|
||||
compile('<input type="text" name="age" ng-format="number"/>', function(){
|
||||
compile('<input type="text" name="age" ng:format="number"/>', function(){
|
||||
scope.age = null;
|
||||
});
|
||||
expect(scope.age).toBeNull();
|
||||
|
|
@ -65,7 +65,7 @@ describe("widget", function(){
|
|||
});
|
||||
|
||||
it("should show incorect text while number does not parse", function(){
|
||||
compile('<input type="text" name="age" ng-format="number"/>');
|
||||
compile('<input type="text" name="age" ng:format="number"/>');
|
||||
scope.age = 123;
|
||||
scope.$eval();
|
||||
scope.$element.val('123X');
|
||||
|
|
@ -76,14 +76,14 @@ describe("widget", function(){
|
|||
});
|
||||
|
||||
it("should clober incorect text if model changes", function(){
|
||||
compile('<input type="text" name="age" ng-format="number" value="123X"/>');
|
||||
compile('<input type="text" name="age" ng:format="number" value="123X"/>');
|
||||
scope.age = 456;
|
||||
scope.$eval();
|
||||
expect(scope.$element.val()).toEqual('456');
|
||||
});
|
||||
|
||||
it("should not clober text if model changes doe to itself", function(){
|
||||
compile('<input type="text" name="list" ng-format="list" value="a"/>');
|
||||
compile('<input type="text" name="list" ng:format="list" value="a"/>');
|
||||
|
||||
scope.$element.val('a ');
|
||||
scope.$element.trigger('change');
|
||||
|
|
@ -107,7 +107,7 @@ describe("widget", function(){
|
|||
});
|
||||
|
||||
it("should come up blank when no value specifiend", function(){
|
||||
compile('<input type="text" name="age" ng-format="number"/>');
|
||||
compile('<input type="text" name="age" ng:format="number"/>');
|
||||
scope.$eval();
|
||||
expect(scope.$element.val()).toEqual('');
|
||||
expect(scope.age).toEqual(null);
|
||||
|
|
@ -134,7 +134,7 @@ describe("widget", function(){
|
|||
expect(scope.checkbox).toEqual(true);
|
||||
});
|
||||
|
||||
it("should use ng-format", function(){
|
||||
it("should use ng:format", function(){
|
||||
angularFormatter('testFormat', {
|
||||
parse: function(value){
|
||||
return value ? "Worked" : "Failed";
|
||||
|
|
@ -146,7 +146,7 @@ describe("widget", function(){
|
|||
}
|
||||
|
||||
});
|
||||
compile('<input type="checkbox" name="state" ng-format="testFormat" checked/>');
|
||||
compile('<input type="checkbox" name="state" ng:format="testFormat" checked/>');
|
||||
expect(scope.state).toEqual("Worked");
|
||||
expect(scope.$element[0].checked).toEqual(true);
|
||||
|
||||
|
|
@ -161,9 +161,9 @@ describe("widget", function(){
|
|||
});
|
||||
});
|
||||
|
||||
describe("ng-validate", function(){
|
||||
it("should process ng-validate", function(){
|
||||
compile('<input type="text" name="price" value="abc" ng-validate="number"/>');
|
||||
describe("ng:validate", function(){
|
||||
it("should process ng:validate", function(){
|
||||
compile('<input type="text" name="price" value="abc" ng:validate="number"/>');
|
||||
expect(element.hasClass('ng-validation-error')).toBeTruthy();
|
||||
expect(element.attr('ng-validation-error')).toEqual('Not a number');
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ describe("widget", function(){
|
|||
});
|
||||
|
||||
it('should not blow up for validation with bound attributes', function() {
|
||||
compile('<input type="text" name="price" boo="{{abc}}" ng-required/>');
|
||||
compile('<input type="text" name="price" boo="{{abc}}" ng:required/>');
|
||||
expect(element.hasClass('ng-validation-error')).toBeTruthy();
|
||||
expect(element.attr('ng-validation-error')).toEqual('Required');
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ describe("widget", function(){
|
|||
it("should not call validator if undefined/empty", function(){
|
||||
var lastValue = "NOT_CALLED";
|
||||
angularValidator.myValidator = function(value){lastValue = value;};
|
||||
compile('<input type="text" name="url" ng-validate="myValidator"/>');
|
||||
compile('<input type="text" name="url" ng:validate="myValidator"/>');
|
||||
expect(lastValue).toEqual("NOT_CALLED");
|
||||
|
||||
scope.url = 'http://server';
|
||||
|
|
@ -205,19 +205,19 @@ describe("widget", function(){
|
|||
});
|
||||
|
||||
it("should ignore disabled widgets", function(){
|
||||
compile('<input type="text" name="price" ng-required disabled/>');
|
||||
compile('<input type="text" name="price" ng:required disabled/>');
|
||||
expect(element.hasClass('ng-validation-error')).toBeFalsy();
|
||||
expect(element.attr('ng-validation-error')).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should ignore readonly widgets", function(){
|
||||
compile('<input type="text" name="price" ng-required readonly/>');
|
||||
compile('<input type="text" name="price" ng:required readonly/>');
|
||||
expect(element.hasClass('ng-validation-error')).toBeFalsy();
|
||||
expect(element.attr('ng-validation-error')).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should process ng-required", function(){
|
||||
compile('<input type="text" name="price" ng-required/>');
|
||||
it("should process ng:required", function(){
|
||||
compile('<input type="text" name="price" ng:required/>');
|
||||
expect(element.hasClass('ng-validation-error')).toBeTruthy();
|
||||
expect(element.attr('ng-validation-error')).toEqual('Required');
|
||||
|
||||
|
|
@ -232,8 +232,8 @@ describe("widget", function(){
|
|||
expect(element.attr('ng-validation-error')).toEqual('Required');
|
||||
});
|
||||
|
||||
it('should allow conditions on ng-required', function() {
|
||||
compile('<input type="text" name="price" ng-required="ineedz"/>');
|
||||
it('should allow conditions on ng:required', function() {
|
||||
compile('<input type="text" name="price" ng:required="ineedz"/>');
|
||||
scope.$set('ineedz', false);
|
||||
scope.$eval();
|
||||
expect(element.hasClass('ng-validation-error')).toBeFalsy();
|
||||
|
|
@ -256,7 +256,7 @@ describe("widget", function(){
|
|||
expect(element.attr('ng-validation-error')).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should process ng-required2", function() {
|
||||
it("should process ng:required2", function() {
|
||||
compile('<textarea name="name">Misko</textarea>');
|
||||
expect(scope.$get('name')).toEqual("Misko");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue