Commits

jay...@jaysee.id.au  committed 4f18389

use AJS.toInit instead of jQuery's document ready function. Tidied up javascript and made environment-specific configuration more noticeable.

  • Participants
  • Parent commits 046d3f6

Comments (0)

Files changed (2)

File src/main/resources/atlassian-plugin.xml

     <context>atl.admin</context>
     <context>page</context>
     <context>blogpost</context>
+      <dependency>confluence.web.resources:ajs</dependency>
   </web-resource>
 </atlassian-plugin>

File src/main/resources/js/confluence-feedback.js

-(function() {
-    AJS.log("Inside confluence-feedback.js");
-    jQuery(document).ready(function() {
-        //These two values are configured from the Jira Issue Connector
-        var urlString = "https://jira.atlassian.com/s/en_UK-v15u5g/711/2/1.0.14-beta/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector.js";
-        var connectorID = "0d0b4b7e";
+AJS.toInit(function($) {
+    /**
+     *******************************************************************************************************************
+     * JIRA ISSUE COLLECTOR CONFIGURATION
+     * These values are hard-coded to a specific project on jira.atlassian.com. Please make sure this is appropriate
+     * before installing this plugin.
+     * - Joe Clark (jclark@atlassian.com), 2nd Feb 2012
+     */
+    var urlString = "https://jira.atlassian.com/s/en_UK-v15u5g/711/2/1.0.14-beta/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector.js";
+    var connectorID = "0d0b4b7e";
+    /**
+     *******************************************************************************************************************
+     */
 
-        AJS.log("Loading Feedback button");
-        jQuery('.ajs-menu-item:first').before("<li class='normal ajs-menu-item'><a id='feedback-menu-link' class='ajs-menu-title' href='#'><span id='feedback_icon' class='feedback_icon'>Provide feedback to Atlassian</span></a>&nbsp;&nbsp;</li>");
-        jQuery.getScript(urlString, function(data, textStatus) {
-            if (window.ATL_JQ !== undefined) {
-                AJS.log("window.ATL_JQ is not undefined.");
-                window.ATL_JQ(function() {
-                    new ATL_JQ.IssueDialog({
-                        collectorId:connectorID,
-                        collectFeedback:function() {
-                            AJS.log("in collectFeedback");
-                            return {
-                                "Location":window.location,
-                                "User-Agent":navigator.userAgent,
-                                "Referrer":document.referrer,
-                                "Screen Resolution":screen.width + " x " + screen.height
-                            };
-                        },
-                        triggerText: "Raise a Bug",
-                        triggerPosition: function(onclickHandler) {
-                            AJS.log("In triggerPosition");
+    $('.ajs-menu-item:first').before("<li class='normal ajs-menu-item'><a id='feedback-menu-link' class='ajs-menu-title' href='#'><span id='feedback_icon' class='feedback_icon'>Provide feedback to Atlassian</span></a>&nbsp;&nbsp;</li>");
+    $.getScript(urlString, function(data, textStatus) {
+        if (window.ATL_JQ == undefined) {
+            AJS.log("jQuery was not successfully loaded from JIRA.");
+            return;
+        }
 
-                            //ATL_JQ == jQuery. All jQuery (http://jquery.com/)
-                            //method calls will work using ATL_JQ
-                            AJS.$("#feedback-menu-link").click(function(e) {
-                                AJS.log("in click handler");
-                                e.preventDefault();
-                                onclickHandler();
-                            });
-                        }
+        window.ATL_JQ(function() {
+            new ATL_JQ.IssueDialog({
+                collectorId: connectorID,
+                collectFeedback: function() {
+                    return {
+                        "Location": window.location,
+                        "User-Agent": navigator.userAgent,
+                        "Referrer": document.referrer,
+                        "Screen Resolution": screen.width + " x " + screen.height
+                    };
+                },
+                triggerText: "Raise a Bug",
+                triggerPosition: function(onClickHandler)
+                {
+                    $("#feedback-menu-link").click(function(e) {
+                        e.preventDefault();
+                        onClickHandler();
                     });
-                });
-            }
-            else
-            {
-                AJS.log("Page is undefined")
-            }
+                }
+            });
         });
     });
-})();
+})(AJS.$);