| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** |
| 31 * @implements {WebInspector.Progress} |
| 32 * @unrestricted |
| 33 */ |
| 34 WebInspector.ProgressIndicator = class { |
| 35 constructor() { |
| 36 this.element = createElementWithClass('div', 'progress-indicator'); |
| 37 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element,
'ui/progressIndicator.css'); |
| 38 this._contentElement = this._shadowRoot.createChild('div', 'progress-indicat
or-shadow-container'); |
| 30 | 39 |
| 31 /** | 40 this._labelElement = this._contentElement.createChild('div', 'title'); |
| 32 * @constructor | 41 this._progressElement = this._contentElement.createChild('progress'); |
| 33 * @implements {WebInspector.Progress} | |
| 34 */ | |
| 35 WebInspector.ProgressIndicator = function() | |
| 36 { | |
| 37 this.element = createElementWithClass("div", "progress-indicator"); | |
| 38 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element,
"ui/progressIndicator.css"); | |
| 39 this._contentElement = this._shadowRoot.createChild("div", "progress-indicat
or-shadow-container"); | |
| 40 | |
| 41 this._labelElement = this._contentElement.createChild("div", "title"); | |
| 42 this._progressElement = this._contentElement.createChild("progress"); | |
| 43 this._progressElement.value = 0; | 42 this._progressElement.value = 0; |
| 44 this._stopButton = this._contentElement.createChild("button", "progress-indi
cator-shadow-stop-button"); | 43 this._stopButton = this._contentElement.createChild('button', 'progress-indi
cator-shadow-stop-button'); |
| 45 this._stopButton.addEventListener("click", this.cancel.bind(this)); | 44 this._stopButton.addEventListener('click', this.cancel.bind(this)); |
| 46 | 45 |
| 47 this._isCanceled = false; | 46 this._isCanceled = false; |
| 48 this._worked = 0; | 47 this._worked = 0; |
| 48 } |
| 49 |
| 50 /** |
| 51 * @param {!Element} parent |
| 52 */ |
| 53 show(parent) { |
| 54 parent.appendChild(this.element); |
| 55 } |
| 56 |
| 57 /** |
| 58 * @override |
| 59 */ |
| 60 done() { |
| 61 if (this._isDone) |
| 62 return; |
| 63 this._isDone = true; |
| 64 this.element.remove(); |
| 65 } |
| 66 |
| 67 cancel() { |
| 68 this._isCanceled = true; |
| 69 } |
| 70 |
| 71 /** |
| 72 * @override |
| 73 * @return {boolean} |
| 74 */ |
| 75 isCanceled() { |
| 76 return this._isCanceled; |
| 77 } |
| 78 |
| 79 /** |
| 80 * @override |
| 81 * @param {string} title |
| 82 */ |
| 83 setTitle(title) { |
| 84 this._labelElement.textContent = title; |
| 85 } |
| 86 |
| 87 /** |
| 88 * @override |
| 89 * @param {number} totalWork |
| 90 */ |
| 91 setTotalWork(totalWork) { |
| 92 this._progressElement.max = totalWork; |
| 93 } |
| 94 |
| 95 /** |
| 96 * @override |
| 97 * @param {number} worked |
| 98 * @param {string=} title |
| 99 */ |
| 100 setWorked(worked, title) { |
| 101 this._worked = worked; |
| 102 this._progressElement.value = worked; |
| 103 if (title) |
| 104 this.setTitle(title); |
| 105 } |
| 106 |
| 107 /** |
| 108 * @override |
| 109 * @param {number=} worked |
| 110 */ |
| 111 worked(worked) { |
| 112 this.setWorked(this._worked + (worked || 1)); |
| 113 } |
| 49 }; | 114 }; |
| 50 | |
| 51 WebInspector.ProgressIndicator.prototype = { | |
| 52 /** | |
| 53 * @param {!Element} parent | |
| 54 */ | |
| 55 show: function(parent) | |
| 56 { | |
| 57 parent.appendChild(this.element); | |
| 58 }, | |
| 59 | |
| 60 /** | |
| 61 * @override | |
| 62 */ | |
| 63 done: function() | |
| 64 { | |
| 65 if (this._isDone) | |
| 66 return; | |
| 67 this._isDone = true; | |
| 68 this.element.remove(); | |
| 69 }, | |
| 70 | |
| 71 cancel: function() | |
| 72 { | |
| 73 this._isCanceled = true; | |
| 74 }, | |
| 75 | |
| 76 /** | |
| 77 * @override | |
| 78 * @return {boolean} | |
| 79 */ | |
| 80 isCanceled: function() | |
| 81 { | |
| 82 return this._isCanceled; | |
| 83 }, | |
| 84 | |
| 85 /** | |
| 86 * @override | |
| 87 * @param {string} title | |
| 88 */ | |
| 89 setTitle: function(title) | |
| 90 { | |
| 91 this._labelElement.textContent = title; | |
| 92 }, | |
| 93 | |
| 94 /** | |
| 95 * @override | |
| 96 * @param {number} totalWork | |
| 97 */ | |
| 98 setTotalWork: function(totalWork) | |
| 99 { | |
| 100 this._progressElement.max = totalWork; | |
| 101 }, | |
| 102 | |
| 103 /** | |
| 104 * @override | |
| 105 * @param {number} worked | |
| 106 * @param {string=} title | |
| 107 */ | |
| 108 setWorked: function(worked, title) | |
| 109 { | |
| 110 this._worked = worked; | |
| 111 this._progressElement.value = worked; | |
| 112 if (title) | |
| 113 this.setTitle(title); | |
| 114 }, | |
| 115 | |
| 116 /** | |
| 117 * @override | |
| 118 * @param {number=} worked | |
| 119 */ | |
| 120 worked: function(worked) | |
| 121 { | |
| 122 this.setWorked(this._worked + (worked || 1)); | |
| 123 } | |
| 124 }; | |
| OLD | NEW |