Leonid Khachaturov avatar Leonid Khachaturov committed 9044cec

UI polishing

Comments (0)

Files changed (3)

server/resources/torrentLinks.css

+.tree-torrent-link {
+  margin-left: 10px;
+
+  opacity: 0.5;
+
+  -webkit-transition: opacity 0.1s linear;
+  -moz-transition: opacity 0.1s linear;
+  -ms-transition: opacity 0.1s linear;
+  -o-transition: opacity 0.1s linear;
+  transition: opacity 0.1s linear;
+}
+
+.tree-torrent-link:hover {
+  opacity: 0.99;
+}
+
+.tree-torrent-icon {
+  vertical-align: text-bottom;
+}

server/resources/torrentLinks.js

-BS.Torrents = {
-  trackTreeEvents: function() {
-    var that = this;
+(function($) {
+  BS.Torrents = {
+    trackTreeEvents: function() {
+      var that = this;
+      $(document).on("bs.treeLoaded", function(event, elem, options) {
+        if (options && options.artifact && options.buildId) {
+          that._injectTorrentLinks(elem, options.buildId);
+        }
+      });
 
-    $j(document).on("bs.treeLoaded", function(event, elem, options) {
-      if (options && options.artifact && options.buildId) {
-        that._injectTorrentLinks(elem, options.buildId);
-      }
-    });
+      $(document).on("bs.subtreeLoaded", function(event, elem, options) {
+        if (options && options.artifact && options.buildId) {
+          that._injectTorrentLinks(elem, options.buildId);
+        }
+      });
+    },
 
-    $j(document).on("bs.subtreeLoaded", function(event, elem, options) {
-      if (options && options.artifact && options.buildId) {
-        that._injectTorrentLinks(elem, options.buildId);
-      }
-    });
-  },
+    _injectTorrentLinks: function(treeRoot, buildId) {
+      var that = this;
+      var elements = $(treeRoot).find("span.c").not(".torrent-handled");
 
-  _injectTorrentLinks: function(treeRoot, buildId) {
-    var elements = $j(treeRoot).find("span.c").not(".torrent-handled");
+      BS.ajaxRequest(window['base_uri'] + "/torrentLinks.html", {
+        parameters: { buildId: buildId },
+        method : "post",
+        onComplete: function(transport) {
+          var text = transport.responseText;
+          if (text) {
+            var filesWithTorrents = {};
+            var list = text.split("\n");
+            for (var i = 0; i < list.length; ++i ) {
+              filesWithTorrents[list[i].trim()] = true;
+            }
 
-    var icon = BS.Torrents.icon;
-    BS.ajaxRequest(window['base_uri'] + "/torrentLinks.html", {
-      parameters: { buildId: buildId },
-      method : "post",
-      onComplete: function(transport) {
-        var text = transport.responseText;
-        if (text) {
-          var filesWithTorrents = {};
-          var list = text.split("\n");
-          for (var i = 0; i < list.length; ++i ) {
-            filesWithTorrents[list[i].trim()] = true;
+            elements.each(function() {
+              var el = $(this);
+              var link = el.children("a");
+              var href = link.attr("href");
+              if (href == '#') return;
+
+              var repo = "/repository/download/";
+              var idx0 = href.indexOf(repo) + repo.length;
+              var idx1 = href.indexOf("/", idx0 + 1);
+              var idx2 = href.indexOf("/", idx1 + 1);
+
+              var path = href.substr(idx2+1);
+              if (filesWithTorrents[path] || filesWithTorrents[path.replace(/\+/g, ' ')]) {
+                var url = window['base_uri'] + "/downloadTorrent.html?buildId=" + buildId + "&file=" + path;
+
+                var img = $('<img class="tree-torrent-icon"/>').attr({
+                  src: that.icon
+                });
+
+                var a = $('<a class="tree-torrent-link"/>').attr({
+                  href: url,
+                  title: "Download torrent file for this artifact"
+                }).click(function(event) {
+                          BS.stopPropagation(event)
+                        });
+
+                a.append(img).appendTo(el);
+                el.addClass("has-torrent");
+              }
+              el.addClass("torrent-handled");
+            });
           }
+        }
+      });
+    }
+  };
+})(jQuery);
 
-          elements.each(function() {
-            var self = $j(this);
-            var link = self.children("a");
-            var name = link.text();
-            var href = link.attr("href");
-            if (href == '#') return;
-
-            var repo = "/repository/download/";
-            var idx0 = href.indexOf(repo) + repo.length;
-            var idx1 = href.indexOf("/", idx0 + 1);
-            var idx2 = href.indexOf("/", idx1 + 1);
-
-            var path = href.substr(idx2+1);
-            if (filesWithTorrents[path] || filesWithTorrents[path.replace(/\+/g, ' ')]) {
-              var url = window['base_uri'] + "/downloadTorrent.html?buildId=" + buildId + "&file=" + path;
-
-              var img = $j("<img/>").attr({
-                src: icon
-              }).css({verticalAlign: "text-bottom"});
-
-              var a = $j("<a/>").attr({
-                href: url,
-                title: "Download torrent file for this artifact"
-              }).css({marginLeft: 10}).click(function(event) {
-                BS.stopPropagation(event)
-              });
-
-              a.append(img).appendTo(self);
-              self.addClass("has-torrent");
-            }
-            self.addClass("torrent-handled");
-          });
-        }
-      }
-    });
-  }
-};

server/src/jetbrains/buildServer/artifactsMirror/web/TorrentLinksExtension.java

   public TorrentLinksExtension(@NotNull PagePlaces pagePlaces,
                                @NotNull PluginDescriptor descriptor) {
     super(pagePlaces, PlaceId.ALL_PAGES_FOOTER, "torrent-links", descriptor.getPluginResourcesPath("torrentLinks.jsp"));
+    addCssFile(descriptor.getPluginResourcesPath("torrentLinks.css"));
     addJsFile(descriptor.getPluginResourcesPath("torrentLinks.js"));
     register();
   }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.