From 917a0a5690aacc0a627bbe023b8fcc531598f292 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 6 Aug 2013 16:40:21 -0700 Subject: [PATCH] CRM-12910 - logButton.tpl - Move most JS inside $.fn.crmRevisionLink ---------------------------------------- * CRM-12910: Display revision history for each item under "Job" http://issues.civicrm.org/jira/browse/CRM-12910 --- templates/CRM/common/logButton.tpl | 58 ++++++++++++++++-------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/templates/CRM/common/logButton.tpl b/templates/CRM/common/logButton.tpl index 8d5dc8b2e9..d9aebb7cff 100644 --- a/templates/CRM/common/logButton.tpl +++ b/templates/CRM/common/logButton.tpl @@ -49,36 +49,42 @@ cssDialogSelector: ".dialog-{/literal}{$snippet.css_class}{literal}", contactId: {/literal}{$snippet.contact_id}{literal}, tableName: "{/literal}{$snippet.table_name}{literal}", - reportId: {/literal}{$snippet.instance_id}{literal}, + reportId: {/literal}{$snippet.instance_id}{literal} }; - $(document).on("click", ".{/literal}{$snippet.css_class}{literal}", function() { - $(options.cssDialogSelector).show( ); - $(options.cssDialogSelector).dialog({ - title: "{/literal}{ts}Revisions{/ts}{literal}", - modal: true, - width: "680px", - bgiframe: true, - overlay: { opacity: 0.5, background: "black" }, - open:function() { - var ajaxurl = CRM.url("civicrm/report/instance/" + options.reportId); - cj.ajax({ - data: "reset=1&snippet=4§ion=2&altered_contact_id_op=eq&altered_contact_id_value="+options.contactId+"&log_type_table_op=has&log_type_table_value=" + options.tableName, - url: ajaxurl, - success: function (data) { - $(options.cssDialogSelector + " .revision-content").html(data); - if (!$(options.cssDialogSelector + " .revision-content .report-layout").length) { - $(options.cssDialogSelector + " .revision-content").html("Sorry, couldn't find any revisions."); + + $.fn.crmRevisionLink = function(options) { + return this.each(function(){ + $(this).on("click", function() { + $(options.cssDialogSelector).show( ); + $(options.cssDialogSelector).dialog({ + title: "{/literal}{ts}Revisions{/ts}{literal}", + modal: true, + width: "680px", + bgiframe: true, + overlay: { opacity: 0.5, background: "black" }, + open:function() { + var ajaxurl = CRM.url("civicrm/report/instance/" + options.reportId); + cj.ajax({ + data: "reset=1&snippet=4§ion=2&altered_contact_id_op=eq&altered_contact_id_value="+options.contactId+"&log_type_table_op=has&log_type_table_value=" + options.tableName, + url: ajaxurl, + success: function (data) { + $(options.cssDialogSelector + " .revision-content").html(data); + if (!$(options.cssDialogSelector + " .revision-content .report-layout").length) { + $(options.cssDialogSelector + " .revision-content").html("Sorry, couldn't find any revisions."); + } + } + }); + }, + buttons: { + "Done": function() { + $(this).dialog("destroy"); } } }); - }, - buttons: { - "Done": function() { - $(this).dialog("destroy"); - } - } - }); - }); + }); + }); // this.each + }; // fn.crmRevisionLink + $(".{/literal}{$snippet.css_class}{literal}").crmRevisionLink(options); })(cj, CRM); {/literal} -- 2.25.1