summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-06-15 06:58:51 +0200
committerByron Jones <glob@mozilla.com>2015-06-15 06:58:51 +0200
commitaff954b93e8f47628c3910c0765f1749511affa7 (patch)
treea29ef1e746e4d694ce6719220f56828b122c7d6a /extensions
parentc290f3ecabec75b741d375e6130af9060255c274 (diff)
downloadbugzilla-aff954b93e8f47628c3910c0765f1749511affa7.tar.gz
bugzilla-aff954b93e8f47628c3910c0765f1749511affa7.tar.xz
Bug 1173771: "Share a link to this list of bugs" doesn't work for saved searches
Diffstat (limited to 'extensions')
-rw-r--r--extensions/Bitly/template/en/default/hook/global/header-start.html.tmpl12
-rw-r--r--extensions/Bitly/template/en/default/hook/list/list-links.html.tmpl17
-rw-r--r--extensions/Bitly/web/js/bitly.js118
-rw-r--r--extensions/Bitly/web/styles/bitly.css13
4 files changed, 56 insertions, 104 deletions
diff --git a/extensions/Bitly/template/en/default/hook/global/header-start.html.tmpl b/extensions/Bitly/template/en/default/hook/global/header-start.html.tmpl
index ba698aa2c..d41320b29 100644
--- a/extensions/Bitly/template/en/default/hook/global/header-start.html.tmpl
+++ b/extensions/Bitly/template/en/default/hook/global/header-start.html.tmpl
@@ -6,8 +6,10 @@
# defined by the Mozilla Public License, v. 2.0.
#%]
-[% RETURN UNLESS template.name == 'list/list.html.tmpl' %]
-
-[% style_urls.push('extensions/Bitly/web/styles/bitly.css') %]
-[% javascript_urls.push('extensions/Bitly/web/js/bitly.js') %]
-[% yui.push('container', 'connection', 'json') %]
+[%
+ RETURN UNLESS template.name == 'list/list.html.tmpl';
+ jquery.push('bPopup');
+ style_urls.push('extensions/Bitly/web/styles/bitly.css');
+ javascript_urls.push('extensions/Bitly/web/js/bitly.js');
+ generate_api_token = 1;
+%]
diff --git a/extensions/Bitly/template/en/default/hook/list/list-links.html.tmpl b/extensions/Bitly/template/en/default/hook/list/list-links.html.tmpl
index 836c017ed..e0dcdc708 100644
--- a/extensions/Bitly/template/en/default/hook/list/list-links.html.tmpl
+++ b/extensions/Bitly/template/en/default/hook/list/list-links.html.tmpl
@@ -8,17 +8,18 @@
[% RETURN UNLESS user.id && Bugzilla.params.bitly_token %]
-<div id="bitly_overlay">
- <div class="bd">
- <select id="bitly_type" onchange="YAHOO.bitly.execute()">
+<div id="bitly-overlay">
+ <div>
+ <select id="bitly-type">
<option value="shorten">Share a link to this search</option>
<option value="list">Share a link to this list of [% terms.bugs %]</option>
</select>
- <input id="bitly_url" readonly placeholder="Generating short link...">
- </div>
- <div class="ft">
- <button id="bitly_close" class="notransition">Close</button>
+ <input id="bitly-url" readonly placeholder="Generating short link...">
</div>
+ <button id="bitly-close" class="notransition">Close</button>
</div>
-<a id="bitly_shorten" href="#" onclick="YAHOO.bitly.toggle();return false">Short URL</a>
+<a id="bitly-shorten" href="#"
+ data-url="[% urlbase _ "buglist.cgi?" _
+ cgi.new(urlquerypart).canonicalise_query('list_id','query_format') FILTER html %]"
+>Short URL</a>
|&nbsp; [%# using nbsp because tt always trims trailing whitespace from templates %]
diff --git a/extensions/Bitly/web/js/bitly.js b/extensions/Bitly/web/js/bitly.js
index 62c49b650..6784c83e9 100644
--- a/extensions/Bitly/web/js/bitly.js
+++ b/extensions/Bitly/web/js/bitly.js
@@ -5,96 +5,48 @@
* This Source Code Form is "Incompatible With Secondary Licenses", as
* defined by the Mozilla Public License, v. 2.0. */
-(function() {
+$(function() {
'use strict';
- var Dom = YAHOO.util.Dom;
- YAHOO.namespace('bitly');
- var bitly = YAHOO.bitly;
+ var popup, urls = [];
- bitly.dialog = false;
- bitly.url = { shorten: '', list: '' };
+ function execute() {
+ var type = $('#bitly-type').val();
- bitly.shorten = function() {
- if (this.dialog) {
- this.dialog.show();
- var el = Dom.get('bitly_url');
- el.select();
- el.focus();
+ if (urls[type]) {
+ $('#bitly-url').val(urls[type]).select().focus();
return;
}
- this.dialog = new YAHOO.widget.Overlay('bitly_overlay', {
- visible: true,
- close: false,
- underlay: 'shadow',
- width: '400px',
- context: [ 'bitly_shorten', 'bl', 'tl', ['windowResize'], [0, -10] ]
- });
- this.dialog.render(document.body);
- YAHOO.util.Event.addListener('bitly_close', 'click', function() {
- YAHOO.bitly.dialog.hide();
- });
- YAHOO.util.Event.addListener('bitly_url', 'keypress', function(o) {
- if (o.keyCode == 27 || o.keyCode == 13)
- YAHOO.bitly.dialog.hide();
+ $('#bitly-url').val('');
+ var request = 'rest/bitly/' + type +
+ '?url=' + encodeURIComponent($('#bitly-shorten').data('url')) +
+ '&Bugzilla_api_token=' + encodeURIComponent(BUGZILLA.api_token);
+ $.ajax(request)
+ .done(function(data) {
+ urls[type] = data.url;
+ $('#bitly-url').val(urls[type]).select().focus();
+ })
+ .error(function(data) {
+ $('#bitly-url').val(data.responseJSON.message);
+ });
+ }
+
+ $('#bitly-shorten')
+ .click(function(event) {
+ event.preventDefault();
+ popup = $('#bitly-overlay').bPopup({
+ speed: 100,
+ followSpeed: 100,
+ modalColor: '#fff'
+ }, execute);
});
- this.execute();
- Dom.get('bitly_url').focus();
- };
-
- bitly.execute = function() {
- Dom.get('bitly_url').value = '';
- var type = Dom.get('bitly_type').value;
- if (this.url[type]) {
- this.set(this.url[type]);
- return;
- }
+ $('#bitly-type')
+ .change(execute);
- var url = 'rest/bitly/' + type + '?url=' + encodeURIComponent(document.location);
- YAHOO.util.Connect.initHeader("Accept", "application/json");
- YAHOO.util.Connect.asyncRequest('GET', url, {
- success: function(o) {
- var response = YAHOO.lang.JSON.parse(o.responseText);
- if (response.error) {
- bitly.set(response.message);
- }
- else {
- bitly.url[type] = response.url;
- bitly.set(response.url);
- }
- },
- failure: function(o) {
- try {
- var response = YAHOO.lang.JSON.parse(o.responseText);
- if (response.error) {
- bitly.set(response.message);
- }
- else {
- bitly.set(o.statusText);
- }
- } catch (ex) {
- bitly.set(o.statusText);
- }
- }
+ $('#bitly-close')
+ .click(function(event) {
+ event.preventDefault();
+ popup.close();
});
- };
-
- bitly.set = function(value) {
- var el = Dom.get('bitly_url');
- el.value = value;
- el.select();
- el.focus();
- };
-
- bitly.toggle = function() {
- if (this.dialog
- && YAHOO.util.Dom.get('bitly_overlay').style.visibility == 'visible')
- {
- this.dialog.hide();
- }
- else {
- this.shorten();
- }
- };
-})();
+});
diff --git a/extensions/Bitly/web/styles/bitly.css b/extensions/Bitly/web/styles/bitly.css
index 110a6bef4..e856cbb5d 100644
--- a/extensions/Bitly/web/styles/bitly.css
+++ b/extensions/Bitly/web/styles/bitly.css
@@ -5,18 +5,15 @@
* This Source Code Form is "Incompatible With Secondary Licenses", as
* defined by the Mozilla Public License, v. 2.0. */
-#bitly_overlay {
- position: absolute;
+#bitly-overlay {
+ display: none;
background: #eee;
- border: 1px solid black;
+ border: 1px solid #000;
padding: 5px;
- margin: 10px;
- visibility: collapse;
- box-shadow: 3px 3px 6px #888;
- -moz-box-shadow: 3px 3px 6px #888;
+ width: 400px;
}
-#bitly_url {
+#bitly-url {
margin: 2px 0;
display: block;
width: 100%;