CRM-11137, replaced old style windowpop with jqueryui dialog and also fixed the issue
authorCiviCRM <info@civicrm.org>
Tue, 23 Jul 2013 09:06:19 +0000 (14:36 +0530)
committerCiviCRM <info@civicrm.org>
Tue, 23 Jul 2013 09:06:19 +0000 (14:36 +0530)
----------------------------------------
* CRM-11137:
  http://issues.civicrm.org/jira/browse/CRM-11137

CRM/Core/BAO/CustomField.php
js/Common.js
templates/CRM/Case/Page/CustomDataView.tpl
templates/CRM/Contact/Page/View/CustomDataFieldView.tpl
templates/CRM/Custom/Form/CustomField.tpl
templates/CRM/Custom/Page/CustomDataView.tpl

index c2197f9d5be9419dcff75e47b6e0dc94bbf2c9af..d6def06dc3b0223a82267bb0f76cc15b506c9467 100644 (file)
@@ -1485,7 +1485,10 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
             "reset=1&id=$fileID&eid=$contactID",
             $absolute, NULL, TRUE, TRUE
           );
-          $result['file_url'] = "<a href='javascript:imagePopUp(\"$url\");'><img src=\"$url\" width=$imageThumbWidth height=$imageThumbHeight/></a>";
+          $result['file_url'] = "
+          <a href=\"$url\" class='crm-image-popup'>
+          <img src=\"$url\" width=$imageThumbWidth height=$imageThumbHeight/>
+          </a>";
           // for non image files
         }
         else {
index 8f5294ef60db3c13e12c62db59dc18e291cfe68b..d54a4fe4f090bb6551a1234ec584b35516758669 100644 (file)
@@ -426,10 +426,6 @@ function popUp(URL) {
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=420,left = 202,top = 184');");
 }
 
-function imagePopUp(path) {
-  window.open(path, 'popupWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,screenX=150,screenY=150,top=150,left=150');
-}
-
 /**
  * Function to show / hide the row in optionFields
  *
@@ -824,6 +820,20 @@ CRM.validate = CRM.validate || {
       messagesFromMarkup.call($('#crm-container'));
       $('#crm-container').on('crmFormLoad', '*', messagesFromMarkup);
     }
+
+    // bind the event for image popup
+    $('body').on('click', 'a.crm-image-popup', function() {
+      var o = $('<div class="crm-container crm-custom-image-popup"><img src=' + $(this).attr('href') + '></div>');
+
+      CRM.confirm('',
+        {
+          title: ts('Preview'),
+          message: o
+        },
+        ts('Done')
+      );
+      return false;
+    });
   });
 
   $.fn.crmAccordions = function (speed) {
index f3f8b3457822e95bb1172bb0aba39d8cefbf4c05..dd85887cbf3928d9635e96777dd017e6b48736b3 100644 (file)
@@ -48,8 +48,8 @@
               {if $element.field_type == 'File'}
                 {if $element.field_value.displayURL}
                   <td class="html-adjust">
-                    <a href="#" onclick="imagePopUp('{$element.field_value.imageURL}'); return false;">
-                    <img src="{$element.field_value.displayURL}" height = "100" width="100">
+                    <a href="{$element.field_value.displayURL}" class='crm-image-popup'>
+                      <img src="{$element.field_value.displayURL}" height = "100" width="100">
                     </a>
                   </td>
                   {else}
index dd3364d665b5ef81fc8436db758ba7cadafe46a0..e28a61015a6c89a62bef5a6b37c9476e29cd9c76 100644 (file)
           {if $element.field_type == 'File'}
             {if $element.field_value.displayURL}
                 <div class="crm-content crm-custom_data crm-displayURL">
-                  <a href="#" onclick="imagePopUp('{$element.field_value.imageURL}'); return false;" ><img src="{$element.field_value.displayURL}" height = "{$element.field_value.imageThumbHeight}" width="{$element.field_value.imageThumbWidth}"></a>
+                  <a href="{$element.field_value.displayURL}" class='crm-image-popup'>
+                    <img src="{$element.field_value.displayURL}" height = "{$element.field_value.imageThumbHeight}"
+                         width="{$element.field_value.imageThumbWidth}">
+                  </a>
                 </div>
             {else}
                 <div class="crm-content crm-custom_data crm-fileURL">
index 4ba37d25141d33dc2e7f66dba230460c24eda33a..b86f978ae3efe8ff4efd706656f110c0a0db9cfe 100644 (file)
                         <span class="html-adjust"><br />
                             &nbsp;{ts}Attached File{/ts}: &nbsp;
                             {if $element.element_value.displayURL}
-                                <a href="#" onclick="popUp('{$element.element_value.imageURL}'); return false;" ><img src="{$element.element_value.displayURL}" height = "{$element.element_value.imageThumbHeight}" width="{$element.element_value.imageThumbWidth}"></a>
+                                <a href="{$element.element_value.displayURL}" class='crm-image-popup'>
+                                  <img src="{$element.element_value.displayURL}"
+                                       height = "{$element.element_value.imageThumbHeight}"
+                                       width="{$element.element_value.imageThumbWidth}">
+                                </a>
                             {else}
                                 <a href="{$element.element_value.fileURL}">{$element.element_value.fileName}</a>
                             {/if}
index e67b91ffe62159d61c477ef6ac2d164d8b575362..46747a130df03f3fe9c78429751680a29f1ea945 100644 (file)
                       <td class="label">{$element.field_title}</td>
                       {if $element.field_type == 'File'}
                         {if $element.field_value.displayURL}
-                          <td class="html-adjust"><a href="#"
-                                                     onclick="imagePopUp('{$element.field_value.imageURL}'); return false;"><img
-                                src="{$element.field_value.displayURL}" height="100" width="100"></a></td>
+                          <td class="html-adjust">
+                            <a href="{$element.field_value.displayURL}" class='crm-image-popup'>
+                              <img src="{$element.field_value.displayURL}" height="100" width="100">
+                            </a>
+                          </td>
                         {else}
-                          <td class="html-adjust"><a
-                              href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a></td>
+                          <td class="html-adjust">
+                            <a href="{$element.field_value.fileURL}">{$element.field_value.fileName}</a>
+                          </td>
                         {/if}
                       {else}
                         {if $element.field_data_type == 'Money'}