2 * Created by aditya on 6/12/14.
6 (function(angular
, $, _
) {
8 var partialUrl = function(relPath
) {
9 return CRM
.resourceUrls
['civicrm'] + '/partials/abtesting/' + relPath
;
12 var crmMailingAB
= angular
.module('crmMailingAB', ['ngRoute', 'ui.utils']);
15 //-------------------------------------------------------------------------------------------------------
16 crmMailingAB
.config(['$routeProvider',
17 function($routeProvider
) {
18 $routeProvider
.when('/mailing', {
19 template
: '<h1>sdfs</h1>',
20 controller
: 'mailingListCtrl',
22 mailingList: function($route
, crmApi
) {
23 return crmApi('Mailing', 'get', {});
29 $routeProvider
.when('/mailing/abtesting', {
31 templateUrl
: partialUrl('helloworld.html'),
32 controller
: 'TabsDemoCtrl',
34 metaData: function($route
, crmApi
) {
35 return crmApi('Group', 'get', {});
37 mailingList: function($route
, crmApi
) {
38 return crmApi('Mailing', 'get', {});
49 //-----------------------------------------
50 // Add a new record by name.
51 // Ex: <crmAddName crm-options="['Alpha','Beta','Gamma']" crm-var="newItem" crm-on-add="callMyCreateFunction(newItem)" />
53 crmMailingAB
.controller('TabsDemoCtrl', function($scope
, crmApi
, metaData
, mailingList
) {
55 $scope
.groups
= metaData
.values
;
56 $scope
.mailings
= mailingList
.values
;
58 $scope
.campaign_clicked= function(){
63 $scope
.compose_clicked=function(){
68 $scope
.rec_clicked=function(){
73 $scope
.preview_clicked=function(){
79 [ { name
: 'Subject Lines', url
: partialUrl('subject_lines.html')},
80 { name
: 'From Name', url
: partialUrl('from_name.html')},
81 {name
:'Two different Emails',url
: partialUrl('two_emails.html')} ];
82 $scope
.template
= $scope
.templates
[0];
84 $scope
.slide_value
= 0;
86 $scope
.$watch("automated", function() {
92 $scope
.setifyes= function(val
){
100 $scope
.send_date
="10/4/2004";
106 crmMailingAB
.directive('nexttab', function() {
108 // Restrict it to be an attribute in this case
110 // responsible for registering DOM listeners as well as updating the DOM
111 link: function(scope
, element
, attrs
) {
113 $(element
).parent().parent().parent().tabs(scope
.$eval(attrs
.nexttab
));
114 var myarr
= new Array(1,2,3)
115 $(element
).parent().parent().parent().tabs({disabled
:myarr
});
116 //$(element).parent().parent().parent().tabs({"enable":1});
118 $(element
).on("click",function() {
119 scope
.adi
=scope
.adi
+1;
120 var myArray1
= new Array( );
121 for ( var i
= scope
.adi
+1; i
< 4; i
++ ) {
123 console
.log( "try " + i
);
125 $(element
).parent().parent().parent().tabs( "option", "disabled", myArray1
);
126 $(element
).parent().parent().parent().tabs({active
:scope
.adi
});
127 console
.log("adiroxxx");
133 crmMailingAB
.directive('groupselect',function(){
138 link: function(scope
,element
, attrs
){
140 $(element
).select2({width
:"400px",placeholder
: "Select the groups you wish to include"});
141 $(element
).select2("data",groups
)
151 crmMailingAB
.directive('sliderbar',function(){
156 link: function(scope
,element
, attrs
){
158 $(element
).slider({min
:1});
160 slide: function( event
, ui
) {
161 scope
.slide_value
= ui
.value
;
175 crmMailingAB
.directive('tpmax',function(){
182 link: function(scope
,element
,attr
){
186 scope
.$watch('automated', function(val
) {
191 title
: 'Automated A/B Testing',
208 $(element
).find("#closebutton").on("click",function(){
209 console
.log("you can do it");
210 $(element
).dialog("close");
226 crmMailingAB
.directive('numbar',function(){
231 link: function(scope
,element
, attrs
){
233 $(element
).spinner({max
:attrs
.numbar
,min
:0});
243 crmMailingAB
.directive('datepick',function(){
254 link: function(scope
,element
,attrs
){
256 $(element
).datepicker({
257 onSelect: function(date
) {
258 $(".ui-datepicker a").removeAttr("href");
281 })(angular
, CRM
.$, CRM
._
);