diff options
author | Byron Jones <bjones@mozilla.com> | 2012-11-07 08:40:53 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2012-11-07 08:40:53 +0100 |
commit | 40f5156e2e047efb2d863181ae7afb02c460d313 (patch) | |
tree | 2c754cf75f59bbbadb81f43e5f031a17509b5a47 /extensions/ShadowBugs/web | |
parent | 7cd9fd570d61e316e2398a8b9db274d200d73bc4 (diff) | |
download | bugzilla-40f5156e2e047efb2d863181ae7afb02c460d313.tar.gz bugzilla-40f5156e2e047efb2d863181ae7afb02c460d313.tar.xz |
Bug 801713: implement "bug shadowing" feature
Diffstat (limited to 'extensions/ShadowBugs/web')
-rw-r--r-- | extensions/ShadowBugs/web/shadow-bugs.js | 51 | ||||
-rw-r--r-- | extensions/ShadowBugs/web/style.css | 10 |
2 files changed, 61 insertions, 0 deletions
diff --git a/extensions/ShadowBugs/web/shadow-bugs.js b/extensions/ShadowBugs/web/shadow-bugs.js new file mode 100644 index 000000000..ff320e117 --- /dev/null +++ b/extensions/ShadowBugs/web/shadow-bugs.js @@ -0,0 +1,51 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ + +var shadow_bug = { + init: function() { + var Dom = YAHOO.util.Dom; + var comment_divs = Dom.getElementsByClassName('bz_comment', 'div', 'comments'); + var comments = new Array(); + for (var i = 0, l = comment_divs.length; i < l; i++) { + var time_spans = Dom.getElementsByClassName('bz_comment_time', 'span', comment_divs[i]); + if (!time_spans.length) continue; + var date = this.parse_date(time_spans[0].innerHTML); + if (!date) continue; + + var comment = {}; + comment.div = comment_divs[i]; + comment.date = date; + comment.shadow = Dom.hasClass(comment.div, 'shadow_bug_comment'); + comments.push(comment); + } + + for (var i = 0, l = comments.length; i < l; i++) { + if (!comments[i].shadow) continue; + for (var j = 0, jl = comments.length; j < jl; j++) { + if (comments[j].shadow) continue; + if (comments[j].date > comments[i].date) { + comments[j].div.parentNode.insertBefore(comments[i].div, comments[j].div); + break; + } + } + Dom.removeClass(comments[i].div, 'bz_default_hidden'); + } + + Dom.get('comment').placeholder = 'Add non-public comment'; + }, + + parse_date: function(date) { + var matches = date.match(/^\s*(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/); + if (!matches) return; + return (matches[1] + matches[2] + matches[3] + matches[4] + matches[5] + matches[6]) + 0; + } +}; + + +YAHOO.util.Event.onDOMReady(function() { + shadow_bug.init(); +}); diff --git a/extensions/ShadowBugs/web/style.css b/extensions/ShadowBugs/web/style.css new file mode 100644 index 000000000..0c104130f --- /dev/null +++ b/extensions/ShadowBugs/web/style.css @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ + +.shadow_bug_comment { + background: transparent !important; +} |