CRM-12910 - logButton.tpl - More client-side logic:
authorTim Otten <totten@civicrm.org>
Tue, 6 Aug 2013 23:16:18 +0000 (16:16 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 6 Aug 2013 23:22:56 +0000 (16:22 -0700)
 * Use JS variable instead of Smarty variable
 * Construct URL on client side

----------------------------------------
* CRM-12910: Display revision history for each item under "Job"
  http://issues.civicrm.org/jira/browse/CRM-12910

templates/CRM/common/logButton.tpl

index 58362654b33f771bac415b7051764b03959684fc..7db01d17dc459ca388b658ac0c09ef0890d0bd77 100644 (file)
 
 {literal}
 <script type="text/javascript">
+var cssDialogSelector = ".dialog-{/literal}{$snippet.css_class}{literal}";
 cj(document).on("click", ".{/literal}{$snippet.css_class}{literal}", function() {
-  cj(".dialog-{/literal}{$snippet.css_class}{literal}").show( );
-  cj(".dialog-{/literal}{$snippet.css_class}{literal}").dialog({
+  cj(cssDialogSelector).show( );
+  cj(cssDialogSelector).dialog({
     title: "{/literal}{ts}Revisions{/ts}{literal}",
     modal: true,
     width: "680px",
     bgiframe: true,
     overlay: { opacity: 0.5, background: "black" },
     open:function() {
-      var ajaxurl = {/literal}'{crmURL p="civicrm/report/instance/`$snippet.instance_id`" h=0 }'{literal};
+      var ajaxurl = CRM.url("civicrm/report/instance/{/literal}{$snippet.instance_id}{literal}");
       cj.ajax({
         data: "reset=1&snippet=4&section=2&altered_contact_id_op=eq&altered_contact_id_value={/literal}{$snippet.contact_id}{literal}&log_type_table_op=has&log_type_table_value={/literal}{$snippet.table_name}{literal}",
         url:  ajaxurl,
         success: function (data) {
-          cj(".dialog-{/literal}{$snippet.css_class}{literal} .revision-content").html(data);
-          if (!cj(".dialog-{/literal}{$snippet.css_class}{literal} .revision-content .report-layout").length) {
-            cj(".dialog-{/literal}{$snippet.css_class}{literal} .revision-content").html("Sorry, couldn't find any revisions.");
+          cj(cssDialogSelector + " .revision-content").html(data);
+          if (!cj(cssDialogSelector + " .revision-content .report-layout").length) {
+            cj(cssDialogSelector + " .revision-content").html("Sorry, couldn't find any revisions.");
           }
         }
       });