| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 /* | 1 /* |
| 2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License |
| 3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
| 4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 (function() | 7 (function() |
| 8 { | 8 { |
| 9 let progressBar, canvas, headers, isRTL; | 9 let progressBar, canvas, headers, isRTL; |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 const gapWidth = 5; | 38 const gapWidth = 5; |
| 39 const arrowheadWidth = 5; | 39 const arrowheadWidth = 5; |
| 40 | 40 |
| 41 let width = canvas.width = canvas.offsetWidth; | 41 let width = canvas.width = canvas.offsetWidth; |
| 42 let height = canvas.height = canvas.offsetHeight; | 42 let height = canvas.height = canvas.offsetHeight; |
| 43 | 43 |
| 44 let context = canvas.getContext("2d"); | 44 let context = canvas.getContext("2d"); |
| 45 context.fillStyle = window.getComputedStyle(progressBar, "").color; | 45 context.fillStyle = window.getComputedStyle(progressBar, "").color; |
| 46 context.strokeStyle = window.getComputedStyle(progressBar, "").color; | 46 context.strokeStyle = window.getComputedStyle(progressBar, "").color; |
| 47 context.lineWidth = 1; | 47 context.lineWidth = 1; |
| 48 if(isRTL) | 48 if (isRTL) |
|
Wladimir Palant
2012/09/14 21:20:40
Style nit: please insert a space between "if" and
| |
| 49 { | 49 { |
| 50 context.translate(width, 0); | 50 context.translate(width, 0); |
| 51 context.scale(-1, 1); | 51 context.scale(-1, 1); |
| 52 } | 52 } |
| 53 | 53 |
| 54 let panelCount = headers.length; | 54 let panelCount = headers.length; |
| 55 let panelWidth = (width - gapWidth * (panelCount - 1) - 1) / panelCount; | 55 let panelWidth = (width - gapWidth * (panelCount - 1) - 1) / panelCount; |
| 56 for (let i = 0; i < panelCount; i++) | 56 for (let i = 0; i < panelCount; i++) |
| 57 { | 57 { |
| 58 context.save(); | 58 context.save(); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 76 context.lineTo(0, height - 1); | 76 context.lineTo(0, height - 1); |
| 77 context.lineTo(0, 0); | 77 context.lineTo(0, 0); |
| 78 } | 78 } |
| 79 | 79 |
| 80 context.stroke(); | 80 context.stroke(); |
| 81 context.restore(); | 81 context.restore(); |
| 82 | 82 |
| 83 let childLeft = Math.round(i * (panelWidth + gapWidth) + 1); | 83 let childLeft = Math.round(i * (panelWidth + gapWidth) + 1); |
| 84 let childWidth = panelWidth - arrowheadWidth - 2; | 84 let childWidth = panelWidth - arrowheadWidth - 2; |
| 85 let child = headers[i]; | 85 let child = headers[i]; |
| 86 child.style.marginLeft = childLeft + "px"; | 86 child.style.MozMarginStart = childLeft + "px"; |
| 87 child.style.marginRight = (width - childLeft - childWidth) + "px"; | 87 child.style.MozMarginEnd = (width - childLeft - childWidth) + "px"; |
| 88 child.style.width = childWidth + "px"; | 88 child.style.width = childWidth + "px"; |
|
Wladimir Palant
2012/09/14 21:20:40
Since we are already positioning headers manually,
| |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Resize after initialization should be ignored | 91 // Resize after initialization should be ignored |
| 92 canvas.parentNode.removeAttribute("flex"); | 92 canvas.parentNode.removeAttribute("flex"); |
| 93 } | 93 } |
| 94 | 94 |
| 95 function getActiveItem() | 95 function getActiveItem() |
| 96 { | 96 { |
| 97 for (let i = 0; i < headers.length; i++) | 97 for (let i = 0; i < headers.length; i++) |
| 98 { | 98 { |
| 99 let header = headers[i]; | 99 let header = headers[i]; |
| 100 if (header.classList.contains("active")) | 100 if (header.classList.contains("active")) |
| 101 return header; | 101 return header; |
| 102 } | 102 } |
| 103 return null; | 103 return null; |
| 104 } | 104 } |
| 105 | 105 |
| 106 function setActiveItem(val) | 106 function setActiveItem(val) |
| 107 { | 107 { |
| 108 let complete = true; | 108 let complete = true; |
| 109 for (let i = 0; i < headers.length; i++) | 109 for (let i = 0; i < headers.length; i++) |
| 110 { | 110 { |
| 111 let header = headers[(isRTL) ? headers.length-i-1 : i]; | 111 let header = headers[i]; |
|
Wladimir Palant
2012/09/14 21:20:40
Style nit: please a space before and after a binar
| |
| 112 if (header == val) | 112 if (header == val) |
| 113 complete = false; | 113 complete = false; |
| 114 | 114 |
| 115 if (!complete && header.value[0] == "✔") | 115 if (!complete && header.value[0] == "✔") |
| 116 header.value = header.value.replace(/^✔\s*/, ""); | 116 header.value = header.value.replace(/^✔\s*/, ""); |
| 117 else if (complete && header.value[0] != "✔") | 117 else if (complete && header.value[0] != "✔") |
| 118 header.value = "✔ " + header.value; | 118 header.value = "✔ " + header.value; |
| 119 | 119 |
| 120 if (header == val) | 120 if (header == val) |
| 121 header.classList.add("active"); | 121 header.classList.add("active"); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 138 let activeItem = this.activeItem; | 138 let activeItem = this.activeItem; |
| 139 if (!activeItem) | 139 if (!activeItem) |
| 140 return; | 140 return; |
| 141 | 141 |
| 142 if (!val && activeItem.value[0] == "✔") | 142 if (!val && activeItem.value[0] == "✔") |
| 143 activeItem.value = activeItem.value.replace(/^✔\s*/, ""); | 143 activeItem.value = activeItem.value.replace(/^✔\s*/, ""); |
| 144 else if (val && activeItem.value[0] != "✔") | 144 else if (val && activeItem.value[0] != "✔") |
| 145 activeItem.value = "✔ " + activeItem.value; | 145 activeItem.value = "✔ " + activeItem.value; |
| 146 } | 146 } |
| 147 })(); | 147 })(); |
| LEFT | RIGHT |