From 685a6418717c0c821b95e60ae3978a71e3f6f2b1 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 6 Aug 2013 17:30:57 -0700 Subject: [PATCH] CRM-12910 - logButton.tpl - Move $.fn.crmRevisionLink to its own file ---------------------------------------- * CRM-12910: http://issues.civicrm.org/jira/browse/CRM-12910 --- js/jquery/jquery.crmRevisionLink.js | 50 +++++++++++++++++++++++++++++ templates/CRM/common/logButton.tpl | 36 --------------------- 2 files changed, 50 insertions(+), 36 deletions(-) create mode 100644 js/jquery/jquery.crmRevisionLink.js diff --git a/js/jquery/jquery.crmRevisionLink.js b/js/jquery/jquery.crmRevisionLink.js new file mode 100644 index 0000000000..8aa9470c6a --- /dev/null +++ b/js/jquery/jquery.crmRevisionLink.js @@ -0,0 +1,50 @@ +(function($, CRM) { + + /** + * Usage: + * + * cj('.my-link').crmRevisionLink({ + * 'reportId': 123, // CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), + * 'tableName': 'my_table', + * 'contactId': 123 + * )); + * + * Note: This file is used by CivHR + */ + $.fn.crmRevisionLink = function(options) { + return this.each(function(){ + var $dialog = $('
'); + $('body').append($dialog); + $(this).on("click", function() { + $dialog.show(); + $dialog.dialog({ + title: ts("Revisions"), + 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) { + $dialog.find(".revision-content").html(data); + if (!$dialog.find(".revision-content .report-layout").length) { + $dialog.find(".revision-content").html("Sorry, couldn't find any revisions."); + } + } + }); + }, + buttons: { + "Done": function() { + $(this).dialog("destroy"); + } + } + }); + return false; + }); + }); // this.each + }; // fn.crmRevisionLink + +})(jQuery, CRM); diff --git a/templates/CRM/common/logButton.tpl b/templates/CRM/common/logButton.tpl index bdbd147db4..c9cef83fc8 100644 --- a/templates/CRM/common/logButton.tpl +++ b/templates/CRM/common/logButton.tpl @@ -40,43 +40,7 @@ {literal}