restrict: 'EA',
scope: {
crmUiField: '@',
- crmTitle: '@'
+ crmTitle: '@',
+ crmHelp: '@'
},
templateUrl: function(tElement, tAttrs){
var layout = tAttrs.crmLayout ? tAttrs.crmLayout : 'default';
$(element).addClass('crm-section');
scope.crmUiField = attrs.crmUiField;
scope.crmTitle = attrs.crmTitle;
+ scope.crmHelp = attrs.crmHelp;
}
};
})
};
})
+ // standalone: <a crm-ui-help="field_name">
+ // within crmUiField: <div crm-ui-field crm-title="My Field" crm-help="field_name">
+ .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: <div ng-form="subform" crm-ui-id-scope><label crm-ui-for="subform.foo">Foo:</label><input crm-ui-id="subform.foo" name="foo"/></div>
.directive('crmUiFor', function ($parse, $timeout) {
return {
});
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;
<a crm-icon="disk" ng-click="saveTemplate(mailing)" class="crm-hover-button" title="{{ts('Save As')}}"></a>
</div>
</div>
- <div crm-ui-field="subform.fromAddress" crm-title="ts('From')">
+ <div crm-ui-field="subform.fromAddress" crm-title="ts('From')" crm-help="id-from_email">
<div ng-controller="EmailAddrCtrl" crm-mailing-from-address="fromPlaceholder" crm-mailing="mailing">
<select
crm-ui-id="subform.fromAddress"
-<div class="label"><label crm-ui-for="{{crmUiField}}" crm-depth="1">{{$parent.$parent.$eval(crmTitle)}}</label></div>
+<div class="label">
+ <label crm-ui-for="{{crmUiField}}" crm-depth="1">{{$parent.$parent.$eval(crmTitle)}}</label>
+ <a crm-ui-help="{title: $parent.$parent.$eval(crmTitle), id: crmHelp}" ng-if="crmHelp"></a>
+</div>
<div class="content" ng-transclude></div>
<div class="clear"></div>