Remove GWT UI Change-Id: I0f3a5b9da224f5fb2f5dd7a997e935f25aa3e6a9
diff --git a/src/main/java/com/googlesource/gerrit/plugins/imagare/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/imagare/HttpModule.java index 627cfd8..f7960e8 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/imagare/HttpModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/imagare/HttpModule.java
@@ -39,10 +39,6 @@ serveRegex("^" + ImageServlet.PATH_PREFIX + "(.+)?$").with(ImageServlet.class); } - // GWT only - DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new JavaScriptPlugin("imagare.js")); - - // Polymer only DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new JavaScriptPlugin("imagare.html")); } }
diff --git a/src/main/resources/static/imagare.html b/src/main/resources/static/imagare.html index 2d2077d..7e3ee3b 100644 --- a/src/main/resources/static/imagare.html +++ b/src/main/resources/static/imagare.html
@@ -23,8 +23,6 @@ <dom-module id="imagare"> <script> Gerrit.install(plugin => { - if (!window.Polymer) { return; } - plugin.restApi('/config/server/').get('imagare~config').then(config => { if (config && config.enable_image_server) { plugin.screen('upload', 'gr-imagare-upload');
diff --git a/src/main/resources/static/imagare.js b/src/main/resources/static/imagare.js deleted file mode 100644 index 779f1b5..0000000 --- a/src/main/resources/static/imagare.js +++ /dev/null
@@ -1,111 +0,0 @@ -// Copyright (C) 2014 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -Gerrit.install(function(self) { - - if (window.Polymer) { return; } - - // The code below is only used by the GWT-UI - - function onComment(e) { - var prefs = getPrefsFromCookie(); - if (prefs !== null) { - convertImageLinks(getLinks(e), prefs); - } else { - Gerrit.get('/accounts/self/' + self.getPluginName() + '~preference', function(prefs) { - storePrefsInCookie(prefs); - convertImageLinks(getLinks(e), prefs); - }); - } - } - - function getLinks(e) { - return e.getElementsByTagName("a"); - } - - function storePrefsInCookie(prefs) { - var date = new Date(); - date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000)); // 1 day - document.cookie = getCookieName() - + "=" - + JSON.stringify(prefs) - + "; expires=" + date.toGMTString() - + "; path=/"; - } - - function getPrefsFromCookie() { - var cookie = document.cookie; - if (cookie.length > 0) { - var cookieName = getCookieName(); - var start = cookie.indexOf(cookieName + "="); - if (start != -1) { - start = start + cookieName.length + 1; - var end = document.cookie.indexOf(";", start); - if (end == -1) { - end = document.cookie.length; - } - return JSON.parse(unescape(document.cookie.substring(start, end))); - } - } - return null; - } - - function getCookieName() { - return self.getPluginName() + "~prefs"; - } - - function convertImageLinks(l, prefs) { - if (!prefs.pattern) { - return; - } - - if ('TOOLTIP' === prefs.link_decoration) { - addTooltips(l, prefs.pattern); - } else if ('INLINE' === prefs.link_decoration) { - inlineImages(l, prefs.pattern); - } - } - - function inlineImages(l, pattern) { - for(var i = 0; i < l.length; i++) { - if (l[i].href.match(pattern)) { - var a = document.createElement('a'); - a.setAttribute('href', l[i].href); - var img = document.createElement('img'); - img.setAttribute('src', l[i].href); - img.setAttribute('style', 'border: 1px solid #B3B2B2;'); - a.appendChild(img); - l[i].parentNode.replaceChild(a, l[i]); - } - } - } - - function addTooltips(pattern) { - for(var i = 0; i < l.length; i++) { - if (l[i].href.match(pattern)) { - l[i].onmouseover = function (evt) { - var img = document.createElement('img'); - img.setAttribute('src', this.href); - img.setAttribute('style', 'border: 1px solid #B3B2B2; position: absolute; top: ' + (this.offsetTop + this.offsetHeight) + 'px'); - this.parentNode.insertBefore(img, this); - this.onmouseout = function (evt) { - this.parentNode.removeChild(this.previousSibling); - } - } - } - } - } - - Gerrit.on('comment', onComment); - });