Skip to content

Commit

Permalink
Merge pull request #65 from beregovoy68/devel
Browse files Browse the repository at this point in the history
Development is in progress
  • Loading branch information
beregovoy68 committed Oct 26, 2016
2 parents e3fbb12 + d96136c commit 830694a
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 116 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Expand Up @@ -62,7 +62,7 @@ module.exports = function (grunt) {
'bower_components/ngclipboard/dist/ngclipboard.js',
'bower_components/growl/javascripts/jquery.growl.js',
'bower_components/jquery-validation/dist/jquery.validate.js',
'bower_components/jpkleemans-angular-validate/src/angular-validate.js',
'bower_components/waves-angular-validate/src/angular-validate.js',

'src/js/vendor/jquery.modal.js',

Expand Down Expand Up @@ -118,6 +118,7 @@ module.exports = function (grunt) {
'src/js/shared/password.strength.directive.js',
'src/js/shared/address.directive.js',
'src/js/shared/decimal.directive.js',
'src/js/shared/focus.directive.js',
'src/js/shared/transaction.loading.service.js',
'src/js/shared/transaction.filter.js',

Expand Down
3 changes: 2 additions & 1 deletion bower.json
Expand Up @@ -23,7 +23,8 @@
"growl": "^1.3.2",
"angular-messages": "^1.5.8",
"angular-validation-match": "^1.9.0",
"jpkleemans-angular-validate": "^1.1.1"
"angular-material": "^1.1.1",
"waves-angular-validate": "git@github.com:beregovoy68/angular-validate.git#^1.1.2"
},
"analytics": false
}
8 changes: 8 additions & 0 deletions src/css/style.css
Expand Up @@ -1188,6 +1188,14 @@ span.tabs-radio img.selected {
color: #999999;
}

.popup-autocomplete {
z-index: 160;
}

.md-virtual-repeat-container.md-autocomplete-suggestions-container {
z-index: 160;
}

/* ======================================================================= */


Expand Down
108 changes: 89 additions & 19 deletions src/js/app.js
Expand Up @@ -4,22 +4,92 @@
* @see controllers
* @see services
*/
var app = angular.module('app',
[
'restangular',
'waves.core',
'waves.core.services',

'ngclipboard',
'ngMessages',
'ngValidate',
'ngAnimate',
'app.ui',
'app.shared',
'app.login',
'app.navigation',
'app.wallet',
'app.history',
'app.community'
]
);

// mock methods to implement late binding
var __mockShowError = function(message) {};
var __mockValidateAddress = function(address) {};

var app = angular.module('app', [
'restangular',
'waves.core',
'waves.core.services',

'ngclipboard',
'ngMessages',
'ngAnimate',
'ngMaterial',
'ngValidate',
'app.ui',
'app.shared',
'app.login',
'app.navigation',
'app.wallet',
'app.history',
'app.community'
]).config(AngularApplicationConfig).run(AngularApplicationRun);

function AngularApplicationConfig($validatorProvider) {
$validatorProvider.setDefaults({
errorClass: 'wInput-error',
onkeyup: false,
showErrors : function(errorMap, errorList) {
errorList.forEach(function(error) {
// can't use notificationService here cos services are not available in config phase
__mockShowError(error.message);
});

var i, elements;
for (i = 0, elements = this.validElements(); elements[i]; i++) {
angular.element(elements[i]).removeClass(this.settings.errorClass);
}

for (i = 0, elements = this.invalidElements(); elements[i]; i++) {
angular.element(elements[i]).addClass(this.settings.errorClass);
}
}
});
$validatorProvider.addMethod('address', function(value, element) {
return this.optional(element) || __mockValidateAddress(value);
}, 'Account number must be a sequence of 35 alphanumeric characters with no spaces, ' +
'optionally starting with \'1W\'');
$validatorProvider.addMethod('decimal', function(value, element, params) {
var maxdigits = angular.isNumber(params) ? params : Currency.WAV.precision;

var regex = new RegExp('^(?:-?\\d+)?(?:\\.\\d{1,' + maxdigits + '})?$');
return this.optional(element) || regex.test(value);
}, 'Amount is expected with a dot (.) as a decimal separator with no more than {0} fraction digits');
$validatorProvider.addMethod('password', function(value, element) {
if (this.optional(element))
return true;

var containsDigits = /[0-9]/.test(value);
var containsUppercase = /[A-Z]/.test(value);
var containsLowercase = /[a-z]/.test(value);

return containsDigits && containsUppercase && containsLowercase;
}, 'The password is too weak. A good password must contain at least one digit, ' +
'one uppercase and one lowercase letter');
}

AngularApplicationConfig.$inject = ['$validatorProvider'];

function AngularApplicationRun(rest, coreConstants, notificationService, addressService) {
// restangular configuration
rest.setDefaultHttpFields({
timeout: 10000 // milliseconds
});
//var url = coreConstants.NODE_ADDRESS;
var url = 'http://52.28.66.217:6869';
rest.setBaseUrl(url);

// override mock methods cos in config phase services are not available yet
__mockShowError = function (message) {
notificationService.error(message);
};
__mockValidateAddress = function (address) {
return addressService.validateDisplayAddress(address);
};
}

AngularApplicationRun.$inject = ['Restangular', 'constants.core', 'notificationService', 'addressService'];

2 changes: 1 addition & 1 deletion src/js/shared/address.directive.js
Expand Up @@ -14,7 +14,7 @@
return true;

return addressService.validateDisplayAddress(viewValue);
}
};
}
};
}]);
Expand Down
4 changes: 2 additions & 2 deletions src/js/shared/decimal.directive.js
Expand Up @@ -23,10 +23,10 @@
return true;

var maxdigits = isFinite(parseInt(digits)) ? digits : 8;
var regex = new RegExp("^(?:-?\\d+)?(?:\\.\\d{1," + maxdigits + "})?$");
var regex = new RegExp('^(?:-?\\d+)?(?:\\.\\d{1,' + maxdigits + '})?$');

return regex.test(viewValue);
}
};
}
};
});
Expand Down
18 changes: 18 additions & 0 deletions src/js/shared/focus.directive.js
@@ -0,0 +1,18 @@
(function () {
'use strict';

angular
.module('app.shared')
.directive('focusMe', ['$timeout', function WavesFocusDirective($timeout) {
return {
restrict: 'A',
link: function (scope, element, attributes) {
scope.$watch(attributes.focusMe, function (newValue) {
$timeout(function () {
return newValue && element[0].focus();
});
}, true);
}
};
}]);
})();
2 changes: 1 addition & 1 deletion src/js/shared/password.strength.directive.js
Expand Up @@ -18,7 +18,7 @@
var containsLowercase = /[a-z]/.test(viewValue);

return containsDigits && containsUppercase && containsLowercase;
}
};
}
};
});
Expand Down
5 changes: 4 additions & 1 deletion src/js/shared/shared.dialog.directive.js
Expand Up @@ -8,6 +8,7 @@
closeable: true,
showButtons: true,
okButtonCaption: 'OK',
okButtonEnabled: true,
cancelButtonCaption: 'CANCEL'
};

Expand Down Expand Up @@ -58,6 +59,7 @@
dialogOk: '&onDialogOk',
dialogCancel: '&onDialogCancel',
okButtonCaption: '@',
okButtonEnabled: '=?',
cancelButtonCaption: '@',
isError: '=?'
},
Expand All @@ -66,7 +68,8 @@
'<div class="wavesPop-content" ng-transclude></div>' +
'<div class="wPop-content-buttons" ng-show="showButtons">' +
'<button class="wButton fade tooltip-1" ng-class="[{wButtonDanger: isError}]" ' +
'title="{{::tooltip}}" ng-click="onOk()">{{::okButtonCaption}}</button>' +
'title="{{::tooltip}}" ng-click="onOk()" ng-disabled="!okButtonEnabled">' +
'{{::okButtonCaption}}</button>' +
'<span class="divider-2" ng-if="cancelButtonVisible"></span>' +
'<button ng-if="cancelButtonVisible" class="wButton fade" ' +
'ng-class="[{wButtonDanger: isError}]" ng-click="onCancel()">{{::cancelButtonCaption}}' +
Expand Down
42 changes: 1 addition & 41 deletions src/js/shared/shared.module.js
Expand Up @@ -2,45 +2,5 @@
'use strict';

angular
.module('app.shared', [])
.config(['$validatorProvider', 'notificationService', function ($validatorProvider, notificationService) {
$validatorProvider.setDefaults({
errorClass: 'wInput-error',
onkeyup: false,
showErrors : function(errorMap, errorList) {
errorList.forEach(function(error) {
notificationService.error(error.message);
});

var i, elements;
for (i = 0, elements = this.validElements(); elements[i]; i++) {
angular.element(elements[i]).removeClass(this.settings.errorClass);
}

for (i = 0, elements = this.invalidElements(); elements[i]; i++) {
angular.element(elements[i]).addClass(this.settings.errorClass);
}
}
});

$validatorProvider.addMethod('address', function(value, element){
return this.optional(element) || Waves.Addressing.validateDisplayAddress(value);
}, "Account number must be a sequence of 35 alphanumeric characters with no spaces, optionally starting with '1W'");
$validatorProvider.addMethod('decimal', function(value, element, params) {
var maxdigits = angular.isNumeric(params) ? params : Currency.WAV.precision;

var regex = new RegExp("^(?:-?\\d+)?(?:\\.\\d{1," + maxdigits + "})?$");
return this.optional(element) || regex.test(value);
}, "Amount is expected with a dot (.) as a decimal separator with no more than {0} fraction digits");
$validatorProvider.addMethod('password', function(value, element){
if (this.optional(element))
return true;

var containsDigits = /[0-9]/.test(value);
var containsUppercase = /[A-Z]/.test(value);
var containsLowercase = /[a-z]/.test(value);

return containsDigits && containsUppercase && containsLowercase;
}, "The password is too weak. A good password must contain at least one digit, one uppercase and one lowercase letter");
}]);
.module('app.shared', []);
})();

0 comments on commit 830694a

Please sign in to comment.