Merge remote-tracking branch 'upstream/4.5' into 4.5-4.6-2015-03-16-17-24-33
[civicrm-core.git] / js / angular-crmMailingAB / directives.js
index 64c9b3582009ea9cf95002cb5c223f627fcc214f..d5f170c58f7ee0100ca54d95d16f02fd2add047e 100644 (file)
@@ -1,14 +1,11 @@
 (function (angular, $, _) {
-  var partialUrl = function (relPath) {
-    return CRM.resourceUrls['civicrm'] + '/partials/crmMailingAB/' + relPath;
-  };
 
   // example:
   //   scope.myAbtest = new CrmMailingAB();
   //   <crm-mailing-ab-block-mailing="{fromAddressA: 1, fromAddressB: 1}" crm-abtest="myAbtest" />
   var simpleDirectives = {
-    crmMailingAbBlockMailing: partialUrl('joint-mailing.html'),
-    crmMailingAbBlockSetup: partialUrl('setup.html')
+    crmMailingAbBlockMailing: '~/crmMailingAB/joint-mailing.html',
+    crmMailingAbBlockSetup: '~/crmMailingAB/setup.html'
   };
   _.each(simpleDirectives, function (templateUrl, directiveName) {
     angular.module('crmMailingAB').directive(directiveName, function ($parse, crmMailingABCriteria) {
@@ -23,7 +20,7 @@
           scope.abtest = model(scope.$parent);
           scope.crmMailingConst = CRM.crmMailing;
           scope.crmMailingABCriteria = crmMailingABCriteria;
-          scope.ts = CRM.ts('CiviMail');
+          scope.ts = CRM.ts(null);
 
           var fieldsModel = $parse(attr[directiveName]);
           scope.fields = fieldsModel(scope.$parent);
     return {
       require: '?ngModel',
       scope: {},
-      templateUrl: partialUrl('slider.html'),
+      templateUrl: '~/crmMailingAB/slider.html',
       link: function (scope, element, attrs, ngModel) {
         var TEST_MIN = 1, TEST_MAX = 50;
         var sliders = $('.slider-test,.slider-win', element);
         var sliderTests = $('.slider-test', element);
         var sliderWin = $('.slider-win', element);
 
-        scope.ts = CRM.ts('CiviMail');
+        scope.ts = CRM.ts(null);
         scope.testValue = 0;
         scope.winValue = 100;
 
               split_count: options.split_count,
               split_count_select: i
             });
+            /*jshint -W083 */
             result.then(function (data) {
               var temp = 0;
               keep_cnt++;
               var m = t[0];
               var year = t[2];
               var day = t[1].substr(0, t[1].length - 3);
-              if (t[3] == "") {
-                var t1 = t[4].split(":");
-                var hur = t1[0];
+              var t1, hur, hour, min;
+              if (_.isEmpty(t[3])) {
+                t1 = t[4].split(":");
+                hur = t1[0];
                 if (t[5] == "AM") {
                   hour = hur;
                   if (hour == 12) {
                 if (t[5] == "PM") {
                   hour = parseInt(hur) + 12;
                 }
-                var min = t1[1];
+                min = t1[1];
               }
               else {
-                var t1 = t[3].split(":");
-                var hur = t1[0];
+                t1 = t[3].split(":");
+                hur = t1[0];
                 if (t[4] == "AM") {
                   hour = hur;
                   if (hour == 12) {
                 if (t[4] == "PM") {
                   hour = parseInt(hur) + 12;
                 }
-                var min = t1[1];
+                min = t1[1];
               }
               var month = 0;
               switch (m) {
 
               if (keep_cnt == options.split_count) {
                 scope.graphload = true;
-                var data = scope.graph_data;
+                data = scope.graph_data;
 
                 // set up a colour variable
                 var color = d3.scale.category10();
                 svg.append("text")      // text label for the x axis
                   .style("text-anchor", "middle")
                   .text(scope.winnercriteria).attr("transform",function (d) {
-                    return "rotate(-90)"
+                    return "rotate(-90)";
                   }).attr("x", -height / 2)
                   .attr("y", -30);
 
                 // create a variable called series and bind the date
                 // for each series append a g element and class it as series for css styling
-                var series = svg.selectAll(".series")
+                series = svg.selectAll(".series")
                   .data(series)
                   .enter().append("g")
                   .attr("class", "series");