CRM-12910 - logButton.tpl - Move $.fn.crmRevisionLink to its own file
authorTim Otten <totten@civicrm.org>
Wed, 7 Aug 2013 00:30:57 +0000 (17:30 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 7 Aug 2013 00:30:57 +0000 (17:30 -0700)
----------------------------------------
* CRM-12910:
  http://issues.civicrm.org/jira/browse/CRM-12910

js/jquery/jquery.crmRevisionLink.js [new file with mode: 0644]
templates/CRM/common/logButton.tpl

diff --git a/js/jquery/jquery.crmRevisionLink.js b/js/jquery/jquery.crmRevisionLink.js
new file mode 100644 (file)
index 0000000..8aa9470
--- /dev/null
@@ -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 = $('<div><div class="revision-content"></div></div>');
+      $('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&section=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);
index bdbd147db4f50facb4be98904ecda0477e8580da..c9cef83fc8dc0ee85d3fbf0252e6f72fc2dee2db 100644 (file)
 
 {literal}
 <script type="text/javascript">
-
 (function($, CRM) {
-  $.fn.crmRevisionLink = function(options) {
-    return this.each(function(){
-      var $dialog = $('<div><div class="revision-content"></div></div>');
-      $('body').append($dialog);
-      $(this).on("click", function() {
-        $dialog.show( );
-        $dialog.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&section=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");
-            }
-          }
-        });
-      });
-    }); // this.each
-  }; // fn.crmRevisionLink
-
   $(".{/literal}{$snippet.css_class}{literal}").crmRevisionLink({
     contactId: {/literal}{$snippet.contact_id}{literal},
     tableName: "{/literal}{$snippet.table_name}{literal}",