Permalink
Browse files

feat(tooltips): migrate tooltips to a new directive - tooltipster

  • Loading branch information...
1 parent 4c5335f commit 3b6e8c5f16619a553e79d76bdf08669d98680580 @beregovoy68 beregovoy68 committed Oct 31, 2016
View
@@ -113,13 +113,15 @@ module.exports = function (grunt) {
'src/js/splash.controller.js',
'src/js/shared/shared.module.js',
+ 'src/js/shared/shared.constants.js',
'src/js/shared/dialog.service.js',
'src/js/shared/notification.service.js',
'src/js/shared/shared.dialog.directive.js',
'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/tooltipster.directive.js',
'src/js/shared/transaction.loading.service.js',
'src/js/shared/transaction.filter.js',
View
@@ -90,24 +90,6 @@ function AngularApplicationRun(rest, coreConstants, notificationService, address
__mockValidateAddress = function (address) {
return addressService.validateDisplayAddress(address);
};
-
- // setting tooltips
- /*angular.element('.tooltip').tooltipster();
- angular.element('.tooltip-1').tooltipster({
- theme: 'tooltipster-theme1',
- delay: 1000,
- contentAsHTML: true,
- debug: true
- });
- angular.element('.tooltip-2').tooltipster({
- theme: 'tooltipster-theme2',
- delay: 1000
- });
- angular.element('.tooltip-3').tooltipster({
- theme: 'tooltipster-theme3',
- delay: 1000,
- contentAsHTML: true
- });*/
}
AngularApplicationRun.$inject = ['Restangular', 'constants.core', 'notificationService', 'addressService'];
@@ -24,13 +24,12 @@
scope: {
pageId: '@',
caption: '<',
- tooltip: '<',
onSelect: '&',
currentPageId: '<'
},
link: WavesTabLink,
- template: '<img ng-src="img/tabs-iconset-{{pageId}}.svg" class="fFade tooltip-3" alt="{{caption}}" ' +
- 'title="{{tooltip}}" ng-click="onClick()" ng-class="[{selected: isSelected()}]"/>'
+ template: '<img ng-src="img/tabs-iconset-{{pageId}}.svg" class="fFade" alt="{{caption}}" ' +
+ 'ng-click="onClick()" ng-class="[{selected: isSelected()}]"/>'
};
});
})();
@@ -0,0 +1,10 @@
+(function () {
+ 'use strict';
+
+ angular
+ .module('app.shared')
+ .constant('constants.tooltip', {
+ contentAsHTML: false,
+ delay: 1000
+ });
+})();
@@ -0,0 +1,37 @@
+(function () {
+ 'use strict';
+
+ angular
+ .module('app.shared')
+ .directive('tooltipster', ['constants.tooltip', function WavesTooltipsterDirective(constants) {
+
+ return {
+ restrict: 'A',
+ link: function (scope, element, attributes) {
+ var text;
+ if (angular.isDefined(attributes.title))
+ text = attributes.title;
+ else if (angular.isDefined(attributes.tooltipTitle))
+ text = attributes.tooltipTitle;
+
+ if (angular.isUndefined(text))
+ throw new Error('Tooltip text is undefined. ' +
+ 'Tooltipster directive is unnecessary for element: ' + element);
+
+ var tooltipOptions = _.clone(constants);
+ if (angular.isDefined(attributes.tooltipTheme))
+ tooltipOptions.theme = attributes.tooltipTheme;
+ tooltipOptions.content = text;
+
+ if (angular.isDefined(attributes.tooltipHtml) || attributes.tooltipHtml === true)
+ tooltipOptions.contentAsHTML = true;
+
+ element.tooltipster(tooltipOptions);
+
+ scope.$on('$destroy', function DestroyTooltip() {
+ element.tooltipster('destroy');
+ });
+ }
+ };
+ }]);
+})();
@@ -158,12 +158,13 @@
}
function getPaymentForm() {
+ // here we have a direct markup dependency
+ // but other ways of getting the form from a child scope are even more ugly
return angular.element('#send-waves-form').scope().sendWavesForm;
}
- function submitPayment(paymentForm) {
- // here we have a direct markup dependency
- //var paymentForm = getPaymentForm();
+ function submitPayment() {
+ var paymentForm = getPaymentForm();
wallet.transfer.fee.isValid = angular.isDefined(paymentForm.invalid.wavessendfee) ?
paymentForm.invalid.wavessendfee : true;
if (!paymentForm.validate())
Oops, something went wrong.

0 comments on commit 3b6e8c5

Please sign in to comment.