CrmCxnLinkDialogCtrl - Add ctrl to show an external link in a dialog
authorTim Otten <totten@civicrm.org>
Mon, 29 Jun 2015 07:22:59 +0000 (00:22 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 14 Jul 2015 04:00:08 +0000 (21:00 -0700)
ang/crmCxn/LinkDialogCtrl.html [new file with mode: 0644]
ang/crmCxn/LinkDialogCtrl.js [new file with mode: 0644]
ang/crmUi.js

diff --git a/ang/crmCxn/LinkDialogCtrl.html b/ang/crmCxn/LinkDialogCtrl.html
new file mode 100644 (file)
index 0000000..ad65640
--- /dev/null
@@ -0,0 +1,3 @@
+<div ng-controller="CrmCxnLinkDialogCtrl">
+  <iframe crm-ui-iframe crm-ui-iframe-src="model.url"></iframe>
+</div>
diff --git a/ang/crmCxn/LinkDialogCtrl.js b/ang/crmCxn/LinkDialogCtrl.js
new file mode 100644 (file)
index 0000000..d1672d8
--- /dev/null
@@ -0,0 +1,11 @@
+(function(angular, $, _) {
+
+  // Controller for the "Open Link" dialog
+  // Scope members:
+  //   - [input] "model": Object
+  //     - "url": string
+  angular.module('crmCxn').controller('CrmCxnLinkDialogCtrl', function CrmCxnLinkDialogCtrl($scope, dialogService) {
+    var ts = $scope.ts = CRM.ts(null);
+  });
+
+})(angular, CRM.$, CRM._);
index 24c7dceb42429380c3fde5b57d0b18e70d7a3a91..e0d26b1a2ff4b32683f59bffada8e24053e2de00 100644 (file)
 
     // Display an HTML blurb inside an IFRAME.
     // example: <iframe crm-ui-iframe="getHtmlContent()"></iframe>
+    // example:  <iframe crm-ui-iframe crm-ui-iframe-src="getUrl()"></iframe>
     .directive('crmUiIframe', function ($parse) {
       return {
         scope: {
-          crmUiIframe: '@' // expression which evalutes to HTML content
+          crmUiIframeSrc: '@', // expression which evaluates to a URL
+          crmUiIframe: '@' // expression which evaluates to HTML content
         },
         link: function (scope, elm, attrs) {
           var iframe = $(elm)[0];
           iframe.setAttribute('frameborder', '0');
 
           var refresh = function () {
-            // var iframeHtml = '<html><head><base target="_blank"></head><body onload="parent.document.getElementById(\'' + iframe.id + '\').style.height=document.body.scrollHeight + \'px\'"><scr' + 'ipt type="text/javascript" src="https://gist.github.com/' + iframeId + '.js"></sc' + 'ript></body></html>';
-            var iframeHtml = scope.$parent.$eval(attrs.crmUiIframe);
-
-            var doc = iframe.document;
-            if (iframe.contentDocument) {
-              doc = iframe.contentDocument;
-            }
-            else if (iframe.contentWindow) {
-              doc = iframe.contentWindow.document;
+            if (attrs.crmUiIframeSrc) {
+              iframe.setAttribute('src', scope.$parent.$eval(attrs.crmUiIframeSrc));
             }
+            else {
+              var iframeHtml = scope.$parent.$eval(attrs.crmUiIframe);
 
-            doc.open();
-            doc.writeln(iframeHtml);
-            doc.close();
+              var doc = iframe.document;
+              if (iframe.contentDocument) {
+                doc = iframe.contentDocument;
+              }
+              else if (iframe.contentWindow) {
+                doc = iframe.contentWindow.document;
+              }
+
+              doc.open();
+              doc.writeln(iframeHtml);
+              doc.close();
+            }
           };
 
           // If the iframe is in a dialog, respond to resize events