Merge pull request #11186 from totten/master-civicase-pdf
[civicrm-core.git] / ang / crmUi.js
index d3ea3a469c6f3f2efdb7c9e1bc31928089e01234..a66334015a256336d4a7bd7af57d51e46706544d 100644 (file)
     // example: <div crm-ui-field="{title: ts('My Field')}"> {{mydata}} </div>
     // example: <div crm-ui-field="{name: 'subform.myfield', title: ts('My Field')}"> <input crm-ui-id="subform.myfield" name="myfield" /> </div>
     // example: <div crm-ui-field="{name: 'subform.myfield', title: ts('My Field')}"> <input crm-ui-id="subform.myfield" name="myfield" required /> </div>
-    // example: <div crm-ui-field="{name: 'subform.myfield', title: ts('My Field'), help: hs('help_field_name')}"> {{mydata}} </div>
+    // example: <div crm-ui-field="{name: 'subform.myfield', title: ts('My Field'), help: hs('help_field_name'), required: true}"> {{mydata}} </div>
     .directive('crmUiField', function() {
       // Note: When writing new templates, the "label" position is particular. See/patch "var label" below.
       var templateUrls = {
           // immediately for initialization. Use retries/retryDelay to initialize such elements.
           var init = function (retries, retryDelay) {
             var input = $('#' + id);
-            if (input.length === 0) {
+            if (input.length === 0 && !attrs.crmUiForceRequired) {
               if (retries) {
                 $timeout(function(){
                   init(retries-1, retryDelay);
               return;
             }
 
+            if (attrs.crmUiForceRequired) {
+              scope.crmIsRequired = true;
+              return;
+            }
+
             var tgtScope = scope;//.$parent;
             if (attrs.crmDepth) {
               for (var i = attrs.crmDepth; i > 0; i--) {
         link: function (scope, elm, attrs) {
           var iframe = $(elm)[0];
           iframe.setAttribute('width', '100%');
+          iframe.setAttribute('height', '250px');
           iframe.setAttribute('frameborder', '0');
 
           var refresh = function () {
             iframe.setAttribute('height', '' + $(this).innerHeight() + 'px');
           });
 
+          $(elm).parent().on('dialogresize', function(e, ui) {
+            iframe.setAttribute('class', 'resized');
+          });
+
           scope.$parent.$watch(attrs.crmUiIframe, refresh);
         }
       };
           };
           this.isSelectable = function(step) {
             if (step.selected) return false;
-            var result = false;
-            angular.forEach(steps, function(otherStep, otherKey) {
-              if (step === otherStep && otherKey <= maxVisited) result = true;
-            });
-            return result;
+            return this.$validStep();
           };
 
           /*** @param Object step the $scope of the step */
               // If the CMS has already added title markup to the page, use it
               $('h1').not('.crm-container h1').each(function() {
                 if (_.trim($(this).html()) === pageTitle) {
-                  $(this).html(newPageTitle);
+                  $(this).addClass('crm-page-title').html(newPageTitle);
                   $el.hide();
                 }
               });