e554ead476376e95c75b85d1f5782c143a9c29b6
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 mailingList: function($route
, crmApi
) {
35 return crmApi('Mailing', 'get', {});
43 //-----------------------------------------
44 // Add a new record by name.
45 // Ex: <crmAddName crm-options="['Alpha','Beta','Gamma']" crm-var="newItem" crm-on-add="callMyCreateFunction(newItem)" />
47 crmMailingAB
.controller('TabsDemoCtrl', function($scope
, crmApi
, mailingList
) {
50 $scope
.campaign_clicked= function(){
55 $scope
.compose_clicked=function(){
60 $scope
.rec_clicked=function(){
65 $scope
.preview_clicked=function(){
71 [ { name
: 'subjectlines', url
: partialUrl('subject_lines.html')},
72 { name
: 'fromname', url
: partialUrl('from_name.html')},
73 {name
:'2emails',url
: partialUrl('two_emails.html')} ];
74 $scope
.template
= $scope
.templates
[0];
76 $scope
.slide_value
= 0;
78 $scope
.$watch("automated", function() {
84 $scope
.setifyes= function(val
){
92 $scope
.closebox
="open";
96 crmMailingAB
.directive('nexttab', function() {
98 // Restrict it to be an attribute in this case
100 // responsible for registering DOM listeners as well as updating the DOM
101 link: function(scope
, element
, attrs
) {
103 $(element
).parent().parent().parent().tabs(scope
.$eval(attrs
.nexttab
));
104 var myarr
= new Array(1,2,3)
105 $(element
).parent().parent().parent().tabs({disabled
:myarr
});
106 //$(element).parent().parent().parent().tabs({"enable":1});
108 $(element
).on("click",function() {
109 scope
.adi
=scope
.adi
+1;
110 var myArray1
= new Array( );
111 for ( var i
= scope
.adi
+1; i
< 4; i
++ ) {
113 console
.log( "try " + i
);
115 $(element
).parent().parent().parent().tabs( "option", "disabled", myArray1
);
116 $(element
).parent().parent().parent().tabs({active
:scope
.adi
});
117 console
.log("adiroxxx");
123 crmMailingAB
.directive('groupselect',function(){
128 link: function(scope
,element
, attrs
){
130 $(document
).ready(function() { $(element
).select2({width
:"400px",placeholder
: "Select the groups you wish to include"});
139 crmMailingAB
.directive('sliderbar',function(){
144 link: function(scope
,element
, attrs
){
148 slide: function( event
, ui
) {
149 scope
.slide_value
= ui
.value
;
163 crmMailingAB
.directive('tpmax',function(){
170 link: function(scope
,element
,attr
){
174 scope
.$watch('automated', function(val
) {
179 title
: 'Automated A/B Testing',
196 $(element
).find("#closebutton").on("click",function(){
197 console
.log("you can do it");
198 $(element
).dialog("close");
214 crmMailingAB
.directive('numbar',function(){
219 link: function(scope
,element
, attrs
){
221 $(element
).spinner({max
:attrs
.numbar
,min
:0});
242 })(angular
, CRM
.$, CRM
._
);