Skip to content

Commit c581fcf

Browse files
committed
Adding new shared resources for scripts (editor issue management support) and sytlesheets
1 parent acc6db3 commit c581fcf

6 files changed

Lines changed: 1417 additions & 31 deletions

File tree

css3-regions/BugzillaTrackerCSSRegions.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
(function(){
2-
function getIssuesFromDocument(){
1+
(function () {
2+
function getIssuesFromDocument () {
33
var list = {},
44
issues = document.querySelectorAll(".issue-marker");
55

6-
if (issues){
6+
if (issues) {
77
// make issue an array
88
issues = Array.prototype.slice.call(issues);
99

1010
// pluck out the bug data from the DOM object
11-
issues.forEach(function(issue){
11+
issues.forEach(function (issue) {
1212

1313
var bugId = issue.dataset["bug_id"];
1414

@@ -26,7 +26,7 @@
2626
}
2727

2828
// Decorate the issues received from the sever with their state related to the issues in the page (new, changed)
29-
function setIssueStates(serverIssues, documentIssues){
29+
function setIssueStates (serverIssues, documentIssues) {
3030
var serverIssue, documentIssue;
3131

3232
if (!serverIssues){
@@ -72,7 +72,7 @@
7272
}
7373

7474
// "this" is bound to the "BugzillaTracker" instance
75-
function renderIssues(serverIssues){
75+
function renderIssues (serverIssues) {
7676

7777
if (!serverIssues && !serverIssues.length){
7878
return;
@@ -114,7 +114,7 @@
114114
issueListContainer.addEventListener("click", toggleMarkup);
115115
}
116116

117-
function toggleMarkup(e){
117+
function toggleMarkup (e) {
118118
if (e.target.className && e.target.classList.contains("issue-markup-trigger")){
119119
e.preventDefault();
120120

@@ -138,7 +138,7 @@
138138
}
139139
}
140140

141-
function filterIssues(e){
141+
function filterIssues (e) {
142142
if (e.target.name !== "issue-filter"){
143143
return
144144
}
@@ -160,15 +160,17 @@
160160
}
161161
}
162162

163-
document.addEventListener("DOMContentLoaded", function(){
164-
BugzillaTracker.setIssueTemplate(document.querySelector("#issue-template").innerHTML);
165-
BugzillaTracker.sync(
166-
{
167-
product: "CSS",
168-
component: "Regions",
169-
},
170-
renderIssues);
171-
172-
document.querySelector("#issue-manager form").addEventListener("change", filterIssues)
173-
})
174-
})()
163+
164+
window.checkSpecificationIssues = function (product, component) {
165+
document.addEventListener("DOMContentLoaded", function(){
166+
BugzillaTracker.setIssueTemplate(document.querySelector("#issue-template").innerHTML);
167+
BugzillaTracker.sync({
168+
product: product, // e.g., 'CSS'
169+
component: component // e.g., "Regions",
170+
},
171+
renderIssues);
172+
173+
document.querySelector("#issue-manager form").addEventListener("change", filterIssues)
174+
});
175+
};
176+
})();

css3-regions/Overview.src.html

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@
44
<head profile="http://www.w3.org/2006/03/hcard">
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
66
<title>CSS Regions Module Level 3</title>
7-
<link rel="stylesheet" type="text/css" href="../default.css">
7+
<link rel="stylesheet" type="text/css" href="../shared/style/default.css">
88

99
<style type="text/css">
1010

11-
/* Alternate stylesheet fonts are here because in some browsers (Opera 11.5) */
12-
/* The fonts are not applied if only loaded from the alternate stylesheet */
13-
14-
/* License font the following two fonts: fonts/Droid-Serif-fontfacekit/Google Android License.txt */
15-
@import url(fonts/Droid-Serif-fontfacekit/stylesheet.css);
16-
@import url(fonts/Droid-Sans-Mono-fontfacekit/stylesheet.css);
17-
1811
a.toggle {
1912
position: fixed;
2013
top: 0.5em;
@@ -214,7 +207,7 @@
214207
<link rel="stylesheet" type="text/css"
215208
href="http://www.w3.org/StyleSheets/TR/W3C-ED.css">
216209

217-
<link id="st" href="../alternate-spec-style.css" rel="stylesheet"
210+
<link id="st" href="../shared/style/alternate-spec-style.css" rel="stylesheet"
218211
type="text/css" title="alternate spec style">
219212
</head>
220213

@@ -2789,8 +2782,11 @@ <h2 class="no-num" id="property-index">Property index</h2>
27892782
</div>
27902783
</script>
27912784

2792-
<script type="text/javascript" src="BugzillaTracker.js"></script>
2793-
<script type="text/javascript" src="BugzillaTrackerCSSRegions.js"></script>
2785+
<script type="text/javascript" src="../shared/scripts/BugzillaTrackerUtil.js"></script>
2786+
<script type="text/javascript" src="../shared/scripts/BugzillaTracker.js"></script>
2787+
<script type="text/javascript">
2788+
checkSpecificationIssues('CSS', 'Regions');
2789+
</script>
27942790

27952791

27962792
<div id="issue-manager">

shared/scripts/BugzillaTracker.js

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
(function () {
2+
function getIssuesFromDocument () {
3+
var list = {},
4+
issues = document.querySelectorAll(".issue-marker");
5+
6+
if (issues) {
7+
// make issue an array
8+
issues = Array.prototype.slice.call(issues);
9+
10+
// pluck out the bug data from the DOM object
11+
issues.forEach(function (issue) {
12+
13+
var bugId = issue.dataset["bug_id"];
14+
15+
if (bugId){
16+
list[bugId] = {
17+
"bug_status": issue.dataset["bug_status"],
18+
"short_desc": issue.querySelector(".short-desc").innerText
19+
}
20+
}
21+
22+
})
23+
}
24+
25+
return list;
26+
}
27+
28+
// Decorate the issues received from the sever with their state related to the issues in the page (new, changed)
29+
function setIssueStates (serverIssues, documentIssues) {
30+
var serverIssue, documentIssue;
31+
32+
if (!serverIssues){
33+
throw new TypeError("Missing 'serverIssues' from server. Expected Object, got "+ typeof serverIssues)
34+
}
35+
36+
if (!documentIssues){
37+
throw new TypeError("Missing 'documentIssues' from document. Expected Object, got "+ typeof documentIssues)
38+
}
39+
40+
for (var bugId in serverIssues){
41+
serverIssue = serverIssues[bugId];
42+
documentIssue = documentIssues[bugId];
43+
44+
// is the bug in the doument?
45+
if (documentIssues[bugId]){
46+
47+
// bug status has changed. it's an updated issue
48+
if ( (documentIssue.bug_status !== serverIssue.bug_status) ||
49+
(documentIssue.short_desc !== serverIssue.short_desc) ){
50+
51+
// changes from NEW->ASSIGNED aren't noteworthy
52+
if ( ! (documentIssue.bug_status == "NEW" &&
53+
serverIssue.bug_status == "ASSIGNED") )
54+
serverIssue.issue_state = "updated";
55+
}
56+
}
57+
else{
58+
// not found in the document. it's a new issue if the bug_status
59+
// is not RESOLVED
60+
if (serverIssue.bug_status === "RESOLVED") {
61+
//why do we want to show resolved issues that
62+
//have already been removed from the spec?
63+
64+
//serverIssue.issue_state = 'resolved';
65+
} else {
66+
serverIssue.issue_state = "new";
67+
}
68+
}
69+
}
70+
71+
return serverIssues;
72+
}
73+
74+
// "this" is bound to the "BugzillaTracker" instance
75+
function renderIssues (serverIssues) {
76+
77+
if (!serverIssues && !serverIssues.length){
78+
return;
79+
}
80+
81+
// get a list of bugs from the document
82+
var documentIssues = getIssuesFromDocument();
83+
84+
// get the bugs list with the updated state (not bug status) related to the bugs already in the page
85+
var issueList = setIssueStates(serverIssues, documentIssues);
86+
87+
var fragment = document.createDocumentFragment();
88+
89+
for (var issueId in issueList){
90+
91+
if (issueList[issueId]["issue_state"]){
92+
93+
// bind the bug data to the bug template
94+
var issueFragment = this.renderIssue(issueList[issueId]);
95+
96+
var wrapper = document.createElement("div");
97+
var trigger = document.createElement("a");
98+
trigger.className = "issue-markup-trigger";
99+
trigger.href = "#";
100+
trigger.innerHTML = "toggle markup"
101+
102+
wrapper.setAttribute("data-issue_state", issueList[issueId]["issue_state"]);
103+
104+
wrapper.appendChild(trigger);
105+
wrapper.appendChild(issueFragment);
106+
fragment.appendChild(wrapper);
107+
}
108+
}
109+
110+
var issueListContainer = document.querySelector("#issue-list");
111+
issueListContainer.appendChild(fragment);
112+
113+
// show/hide the markup for a bug entry
114+
issueListContainer.addEventListener("click", toggleMarkup);
115+
}
116+
117+
function toggleMarkup (e) {
118+
if (e.target.className && e.target.classList.contains("issue-markup-trigger")){
119+
e.preventDefault();
120+
121+
var parent = e.target.parentNode,
122+
issueEl = parent.querySelector(".issue-marker"),
123+
markup = issueEl.outerHTML;
124+
125+
126+
parent.classList.toggle("showMarkup");
127+
128+
// already generated the markup
129+
if (parent.querySelector("pre")){
130+
return
131+
}
132+
else{
133+
var pre = document.createElement("pre");
134+
pre.textContent = markup;
135+
136+
parent.appendChild(pre);
137+
}
138+
}
139+
}
140+
141+
function filterIssues (e) {
142+
if (e.target.name !== "issue-filter"){
143+
return
144+
}
145+
146+
var issueManager = document.querySelector("#issue-manager");
147+
148+
switch(e.target.value){
149+
case "all":
150+
issueManager.removeAttribute("data-view_state");
151+
break;
152+
153+
case "new":
154+
issueManager.setAttribute("data-view_state", "new");
155+
break;
156+
157+
case "updated":
158+
issueManager.setAttribute("data-view_state", "updated");
159+
break;
160+
}
161+
}
162+
163+
164+
window.checkSpecificationIssues = function (product, component) {
165+
document.addEventListener("DOMContentLoaded", function(){
166+
BugzillaTracker.setIssueTemplate(document.querySelector("#issue-template").innerHTML);
167+
BugzillaTracker.sync({
168+
product: product, // e.g., 'CSS'
169+
component: component // e.g., "Regions",
170+
},
171+
renderIssues);
172+
173+
document.querySelector("#issue-manager form").addEventListener("change", filterIssues)
174+
});
175+
};
176+
})();

0 commit comments

Comments
 (0)