Skip to content

Commit

Permalink
Merge branch 'master' of github.com:IdeaBlade/Breeze
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraband committed Mar 15, 2014
2 parents 414cb9a + 7fed43d commit c62973f
Show file tree
Hide file tree
Showing 5 changed files with 482 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Breeze.Client/Scripts/IBlade/a25_validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ var Validator = (function () {
**/
ctor.emailAddress = function(context) {
// See https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions/EmailAttribute.cs
var reEmailAddress = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/;
var reEmailAddress = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
return makeRegExpValidator('emailAddress', reEmailAddress, null, context);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/*
* Breeze directives for validation
* Breeze Labs: Breeze Directives for Angular Apps
*
* v.1.3.4
* v.1.3.5
*
* Usage:
* Make this module a dependency of your app module:
* var app = angular.module('app', ['breeze.directives']);
*
* Include breeze.directives.css for default styling
* <link href="content/breeze.directives.css" rel="stylesheet" />
*
* Copyright 2014 IdeaBlade, Inc. All Rights Reserved.
* Licensed under the MIT License
* http://opensource.org/licenses/mit-license.php
Expand All @@ -19,13 +16,62 @@
(function () {
'use strict';

var module = angular.module('breeze.directives', []);
var module = angular.module('breeze.directives', [])
.directive('zFloat', [zFloat])
.directive('zValidate', ['zDirectivesConfig', 'zValidateInfo', zValidate])
.service('zValidateInfo', zValidateInfo)
.provider('zDirectivesConfig', zDirectivesConfig);

/*** IMPLEMENTATION ***/

/* Breeze Float Equivalence directive
*
* Adds a formatter to the ngModel controller.
* This formatter returns the view value rather than the model property value
* if the two values are deemed equivalent.
*
* For explanation and more info, see
* http://www.breezejs.com/breeze-labs/breezedirectivesfloat
*
* Install
* --------------------------------------------------
*
* Make this module a dependency of your app module:
* var app = angular.module('app', ['breeze.directives']);
*
* Add the directive to an input tag bound to a floating point property
* <input data-ng-model='vm.product.unitPrice' data-z-float />
*/
function zFloat() {
return {
restrict: 'A',
require: 'ngModel',

link: function(scope, elm, attr, ngModelCtrl) {
if (attr.type === 'radio' || attr.type === 'checkbox') return;
ngModelCtrl.$formatters.push(equivalenceFormatter);

function equivalenceFormatter(value){
var viewValue = ngModelCtrl.$viewValue // could have used 'elm.val()'
return (value === +viewValue) ? viewValue : value;
}
}
};
}

/* Breeze Validation directive
*
* Displays the model validation errors for an entity property
* and adds required indicator if the bound property is required
*
* Install
* --------------------------------------------------
* Include breeze.directives.css for default styling
* <link href="content/breeze.directives.css" rel="stylesheet" />
*
* Make this module a dependency of your app module:
* var app = angular.module('app', ['breeze.directives']);
*
* Usage for input elements (input|select|textarea):
* ---------------------------------------------------
* When scope is a viewmodel (vm):
Expand All @@ -46,8 +92,6 @@
*
* Learn more at http://www.breezejs.com/breeze-labs/breezedirectivesvalidationjs
*/
module.directive('zValidate', ['zDirectivesConfig', 'zValidateInfo', zValidate]);

function zValidate(config, validateInfo) {
var directive = {
link: link,
Expand Down Expand Up @@ -123,8 +167,6 @@
}
}

module.service('zValidateInfo', zValidateInfo);

// Service to extract validation information from a zValidate data binding
// Although built for Angular, it is designed to be used
// in alternative zValidate directive implementations
Expand Down Expand Up @@ -335,9 +377,9 @@
}
}

/* Configure app to use zValidate
/* Configure app to use breeze.directives
*
* Configure breeze directive templates
* Configure breeze directive templates for zValidate
*
* zValidateTemplate: template for display of validation errors
* zRequiredTemplate: template for display of required property indicator
Expand All @@ -357,7 +399,7 @@
* 'So sad!!! %error%</span>';
* }]);
*/
module.provider('zDirectivesConfig', function () {
function zDirectivesConfig() {
// The default zValidate template for display of validation errors
this.zValidateTemplate =
'<span class="invalid">%error%</span>';
Expand All @@ -373,6 +415,6 @@
zRequiredTemplate: this.zRequiredTemplate
};
};
});
};

})();
4 changes: 3 additions & 1 deletion Breeze.Client/Scripts/Labs/breeze.directives.validation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*
* Breeze directives for validation
*
* v.1.3.4
* [OBSOLETE/DEPRECATED PLEASE USE Breeze.directives.js]
* [RETAINED FOR BACKWARD COMPAT ONLY. WILL BE REMOVED IN 2014]
* LAST VERSION 1.3.3
*
* Usage:
* Make this module a dependency of your app module:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Breeze.Angular.Directives</id>
<version>1.3.4</version>
<version>1.3.5</version>
<title>Breeze Labs Angular Directives</title>
<authors>Ward Bell</authors>
<owners>Ward Bell</owners>
Expand All @@ -18,6 +18,6 @@
</metadata>
<files>
<file src="..\..\Breeze.Client\Scripts\Labs\breeze.directives.css" target="content\content\breeze.directives.css" />
<file src="..\..\Breeze.Client\Scripts\Labs\breeze.directives.validation.js" target="content\scripts\breeze.directives.validation.js" />
<file src="..\..\Breeze.Client\Scripts\Labs\breeze.directives.js" target="content\scripts\breeze.directives.js" />
</files>
</package>
Loading

0 comments on commit c62973f

Please sign in to comment.