1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
(function(angular, $, _) {
// example:
// scope.myAbtest = new CrmMailingAB();
// <crm-mailing-ab-block-setup="{abName: 1, group_percentage: 1}" crm-abtest="myAbtest" />
var simpleDirectives = {
crmMailingAbBlockSetup: '~/crmMailingAB/BlockSetup.html'
};
_.each(simpleDirectives, function(templateUrl, directiveName) {
angular.module('crmMailingAB').directive(directiveName, function($parse, crmMailingABCriteria, crmUiHelp) {
var scopeDesc = {crmAbtest: '@'};
scopeDesc[directiveName] = '@';
return {
scope: scopeDesc,
templateUrl: templateUrl,
link: function(scope, elm, attr) {
var model = $parse(attr.crmAbtest);
scope.abtest = model(scope.$parent);
scope.crmMailingConst = CRM.crmMailing;
scope.crmMailingABCriteria = crmMailingABCriteria;
scope.ts = CRM.ts(null);
scope.hs = crmUiHelp({file: 'CRM/Mailing/MailingUI'});
var fieldsModel = $parse(attr[directiveName]);
scope.fields = fieldsModel(scope.$parent);
}
};
});
});
})(angular, CRM.$, CRM._);
|