forked from yewton/userscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetail-popup-for-jira-scrum.user.js
59 lines (50 loc) · 1.9 KB
/
detail-popup-for-jira-scrum.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==UserScript==
// @name Detail Pop-up for JIRA Scrum
// @namespace https://github.com/yewton
// @description Add buttons to pop-up the detail view
// @include https://www.example.org/secure/RapidBoard.jspa*
// @version 0.0.1
// @grant GM_xmlhttpRequest
// @require https://code.jquery.com/jquery-1.12.0.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/simplemodal/1.4.4/jquery.simplemodal.min.js
// ==/UserScript==
var $iframe = $('<iframe width="100%" height="100%" allowfullscreen></iframe>');
// cf. http://slides.com/kbigwheel/how-to-greasemonkey-in-ajax#/5
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
$('.js-issue').filter(function () {
return !!!$(this).data('dp-added');
}).each(function () {
var $issue = $(this);
$issue.data('dp-added', true);
var key = $issue.data('issue-key');
if (!!!key) return;
var $content = $issue.find('.ghx-issue-content');
var viewDetailButtonClass = 'dp-view-detail-button';
if (0 < $content.find('.' + viewDetailButtonClass).length) return;
var $viewDetailButton = $('<button class="' + viewDetailButtonClass + '" data-issue-key="' + key + '"href="#"><span class="aui-icon aui-icon-small aui-iconfont-details">View</span></button>');
$viewDetailButton.click(function (event) {
event.preventDefault();
$iframe.modal({
closeHTML: '',
containerCss:{
backgroundColor: '#999',
height: '90%',
padding: 0,
width: '90%'
},
opacity: 80,
overlayCss: { backgroundColor: '#FFF' },
overlayClose: true,
onShow: function() {
$iframe.attr('src', '/browse/' + key);
}
});
});
$content.prepend($viewDetailButton);
});
});
observer.observe(document, {
subtree: true,
attributes: true
});