| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Common JS that talks XHR back to the server and runs the code and receives | 2 * Common JS that talks XHR back to the server and runs the code and receives |
| 3 * the results. | 3 * the results. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * A polyfill for HTML Templates. | 7 * A polyfill for HTML Templates. |
| 8 * | 8 * |
| 9 * This just adds in the content attribute, it doesn't stop scripts | 9 * This just adds in the content attribute, it doesn't stop scripts |
| 10 * from running nor does it stop other side-effects. | 10 * from running nor does it stop other side-effects. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Copy the image over to a canvas so we can read RGBA values for each point
. | 66 // Copy the image over to a canvas so we can read RGBA values for each point
. |
| 67 if (hex) { | 67 if (hex) { |
| 68 canvasCopy = document.createElement('canvas'); | 68 canvasCopy = document.createElement('canvas'); |
| 69 canvasCopy.width = currentImage.width; | 69 canvasCopy.width = currentImage.width; |
| 70 canvasCopy.height = currentImage.height; | 70 canvasCopy.height = currentImage.height; |
| 71 canvasCopy.id = 'zoomCopy'; | 71 canvasCopy.id = 'zoomCopy'; |
| 72 canvasCopy.getContext('2d').drawImage(currentImage, 0, 0, currentImage.wid
th, currentImage.height); | 72 canvasCopy.getContext('2d').drawImage(currentImage, 0, 0, currentImage.wid
th, currentImage.height); |
| 73 this.parentNode.insertBefore(canvasCopy, this); | 73 this.parentNode.insertBefore(canvasCopy, this); |
| 74 } | 74 } |
| 75 | 75 |
| 76 document.body.addEventListener('mousemove', zoomMove, true); | 76 document.body.addEventListener('pointermove', zoomMove, true); |
| 77 document.body.addEventListener('mouseup', zoomFinished); | 77 document.body.addEventListener('pointerup', zoomFinished); |
| 78 document.body.addEventListener('mouseleave', zoomFinished); | 78 document.body.addEventListener('pointerleave', zoomFinished); |
| 79 | 79 |
| 80 // Kick off the drawing. | 80 // Kick off the drawing. |
| 81 setTimeout(drawZoom, 1); | 81 setTimeout(drawZoom, 1); |
| 82 } | 82 } |
| 83 | 83 |
| 84 function hexify(i) { | 84 function hexify(i) { |
| 85 var s = i.toString(16).toUpperCase(); | 85 var s = i.toString(16).toUpperCase(); |
| 86 // Pad out to two hex digits if necessary. | 86 // Pad out to two hex digits if necessary. |
| 87 if (s.length < 2) { | 87 if (s.length < 2) { |
| 88 s = '0' + s; | 88 s = '0' + s; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 function zoomFinished() { | 136 function zoomFinished() { |
| 137 currentImage = null; | 137 currentImage = null; |
| 138 if (hex) { | 138 if (hex) { |
| 139 hex.textContent = ''; | 139 hex.textContent = ''; |
| 140 } | 140 } |
| 141 document.body.style.cursor = 'default'; | 141 document.body.style.cursor = 'default'; |
| 142 ctx.canvas.parentNode.removeChild(ctx.canvas); | 142 ctx.canvas.parentNode.removeChild(ctx.canvas); |
| 143 canvasCopy.parentNode.removeChild(canvasCopy); | 143 canvasCopy.parentNode.removeChild(canvasCopy); |
| 144 document.body.removeEventListener('mousemove', zoomMove, true); | 144 document.body.removeEventListener('pointermove', zoomMove, true); |
| 145 document.body.removeEventListener('mouseup', zoomFinished); | 145 document.body.removeEventListener('pointerup', zoomFinished); |
| 146 document.body.removeEventListener('mouseleave', zoomFinished); | 146 document.body.removeEventListener('pointerleave', zoomFinished); |
| 147 } | 147 } |
| 148 | 148 |
| 149 this.addEventListener('DOMContentLoaded', function() { | 149 this.addEventListener('DOMContentLoaded', function() { |
| 150 var zoomables = document.body.querySelectorAll('.zoom'); | 150 var zoomables = document.body.querySelectorAll('.zoom'); |
| 151 for (var i=0; i<zoomables.length; i++) { | 151 for (var i=0; i<zoomables.length; i++) { |
| 152 zoomables[i].addEventListener('mousedown', zoomMouseDown); | 152 zoomables[i].addEventListener('pointerdown', zoomMouseDown); |
| 153 } | 153 } |
| 154 }); | 154 }); |
| 155 })(); | 155 })(); |
| 156 | 156 |
| 157 | 157 |
| 158 /** | 158 /** |
| 159 * All the functionality is wrapped up in this anonymous closure, but we need | 159 * All the functionality is wrapped up in this anonymous closure, but we need |
| 160 * to be told if we are on the workspace page or a normal try page, so the | 160 * to be told if we are on the workspace page or a normal try page, so the |
| 161 * workspaceName is passed into the closure, it must be set in the global | 161 * workspaceName is passed into the closure, it must be set in the global |
| 162 * namespace. If workspaceName is the empty string then we know we aren't | 162 * namespace. If workspaceName is the empty string then we know we aren't |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 337 |
| 338 | 338 |
| 339 // Add the images to the history if we are on a workspace page. | 339 // Add the images to the history if we are on a workspace page. |
| 340 if (tryHistory && history) { | 340 if (tryHistory && history) { |
| 341 for (var i=0; i<history.length; i++) { | 341 for (var i=0; i<history.length; i++) { |
| 342 addToHistory(history[i].hash, '/i/'+history[i].hash+'.png'); | 342 addToHistory(history[i].hash, '/i/'+history[i].hash+'.png'); |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 | 345 |
| 346 })(workspaceName); | 346 })(workspaceName); |
| OLD | NEW |