From: Coleman Watts Date: Sat, 14 Mar 2015 00:23:47 +0000 (-0400) Subject: CRM-15706 - Add Angular help directive X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a517b78a171597cfa1dc7c8064b59704df8935e6;p=civicrm-core.git CRM-15706 - Add Angular help directive --- diff --git a/js/angular-crm-ui.js b/js/angular-crm-ui.js index 0876e149a3..70f7519fe1 100644 --- a/js/angular-crm-ui.js +++ b/js/angular-crm-ui.js @@ -126,7 +126,8 @@ restrict: 'EA', scope: { crmUiField: '@', - crmTitle: '@' + crmTitle: '@', + crmHelp: '@' }, templateUrl: function(tElement, tAttrs){ var layout = tAttrs.crmLayout ? tAttrs.crmLayout : 'default'; @@ -137,6 +138,7 @@ $(element).addClass('crm-section'); scope.crmUiField = attrs.crmUiField; scope.crmTitle = attrs.crmTitle; + scope.crmHelp = attrs.crmHelp; } }; }) @@ -155,6 +157,27 @@ }; }) + // standalone: + // within crmUiField:
+ .directive('crmUiHelp', function() { + return { + restrict: 'EA', + scope: { + crmUiHelp: '=' + }, + link: function (scope, element, attrs) { + element + .addClass('helpicon') + .attr('title', ts('%1 Help', {1: scope.crmUiHelp.title})) + .attr('href', '#') + .on('click', function(e) { + e.preventDefault(); + CRM.help(scope.crmUiHelp.title, {id: scope.crmUiHelp.id, file: scope.$parent.$parent.$parent.helpFile}); + }); + } + }; + }) + // example:
.directive('crmUiFor', function ($parse, $timeout) { return { diff --git a/js/angular-crmMailing/directives.js b/js/angular-crmMailing/directives.js index 307df6369e..7db48d4c0e 100644 --- a/js/angular-crmMailing/directives.js +++ b/js/angular-crmMailing/directives.js @@ -28,6 +28,7 @@ }); scope.crmMailingConst = CRM.crmMailing; scope.ts = CRM.ts(null); + scope.helpFile = 'CRM/Mailing/Form/Upload'; scope[directiveName] = attr[directiveName] ? scope.$parent.$eval(attr[directiveName]) : {}; $q.when(crmMetadata.getFields('Mailing'), function(fields) { scope.mailingFields = fields; diff --git a/partials/crmMailing/mailing.html b/partials/crmMailing/mailing.html index 3ade3ee9f4..815bdf7b9c 100644 --- a/partials/crmMailing/mailing.html +++ b/partials/crmMailing/mailing.html @@ -21,7 +21,7 @@ It could perhaps be thinned by 30-60% by making more directives.
-
+