OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 26 matching lines...) Expand all Loading... |
37 this.imageElement = document.createElement("img"); | 37 this.imageElement = document.createElement("img"); |
38 this.contentElement.appendChild(this.imageElement); | 38 this.contentElement.appendChild(this.imageElement); |
39 | 39 |
40 this.choicesForm = document.createElement("form"); | 40 this.choicesForm = document.createElement("form"); |
41 this.contentElement.appendChild(this.choicesForm); | 41 this.contentElement.appendChild(this.choicesForm); |
42 | 42 |
43 this.headerElement = document.createElement("h1"); | 43 this.headerElement = document.createElement("h1"); |
44 this.headerElement.textContent = headingText; | 44 this.headerElement.textContent = headingText; |
45 this.choicesForm.appendChild(this.headerElement); | 45 this.choicesForm.appendChild(this.headerElement); |
46 | 46 |
| 47 var self = this; |
| 48 function enableOption(text, checked) { |
| 49 var label = document.createElement("label"); |
| 50 var option = document.createElement("input"); |
| 51 option.type = "radio"; |
| 52 option.name = "enable-option"; |
| 53 if (checked) |
| 54 option.checked = true; |
| 55 label.appendChild(option); |
| 56 label.appendChild(document.createTextNode(text)); |
| 57 self.choicesForm.appendChild(label); |
| 58 return option; |
| 59 }; |
| 60 |
| 61 this.enabledForSession = enableOption(WebInspector.UIString("Only enable for
this session"), true); |
| 62 this.enabledAlways = enableOption(WebInspector.UIString("Always enable")); |
| 63 |
47 this.disclaimerElement = document.createElement("div"); | 64 this.disclaimerElement = document.createElement("div"); |
48 this.disclaimerElement.className = "panel-enabler-disclaimer"; | 65 this.disclaimerElement.className = "panel-enabler-disclaimer"; |
49 this.disclaimerElement.textContent = disclaimerText; | 66 this.disclaimerElement.textContent = disclaimerText; |
50 this.choicesForm.appendChild(this.disclaimerElement); | 67 this.choicesForm.appendChild(this.disclaimerElement); |
51 | 68 |
52 this.enableButton = document.createElement("button"); | 69 this.enableButton = document.createElement("button"); |
53 this.enableButton.setAttribute("type", "button"); | 70 this.enableButton.setAttribute("type", "button"); |
54 this.enableButton.textContent = buttonTitle; | 71 this.enableButton.textContent = buttonTitle; |
55 this.enableButton.addEventListener("click", this._enableButtonCicked.bind(th
is), false); | 72 this.enableButton.addEventListener("click", this._enableButtonCicked.bind(th
is), false); |
56 this.choicesForm.appendChild(this.enableButton); | 73 this.choicesForm.appendChild(this.enableButton); |
57 | 74 |
58 window.addEventListener("resize", this._windowResized.bind(this), true); | 75 window.addEventListener("resize", this._windowResized.bind(this), true); |
59 } | 76 } |
60 | 77 |
61 WebInspector.PanelEnablerView.prototype = { | 78 WebInspector.PanelEnablerView.prototype = { |
62 _enableButtonCicked: function() | 79 _enableButtonCicked: function() |
63 { | 80 { |
64 this.dispatchEventToListeners("enable clicked"); | 81 this.dispatchEventToListeners("enable clicked"); |
65 }, | 82 }, |
66 | 83 |
67 _windowResized: function() | 84 _windowResized: function() |
68 { | 85 { |
69 this.imageElement.removeStyleClass("hidden"); | 86 this.imageElement.removeStyleClass("hidden"); |
70 | 87 |
71 if (this.element.offsetWidth < (this.choicesForm.offsetWidth + this.imag
eElement.offsetWidth)) | 88 if (this.element.offsetWidth < (this.choicesForm.offsetWidth + this.imag
eElement.offsetWidth)) |
72 this.imageElement.addStyleClass("hidden"); | 89 this.imageElement.addStyleClass("hidden"); |
| 90 }, |
| 91 |
| 92 get alwaysEnabled() { |
| 93 return this.enabledAlways.checked; |
73 } | 94 } |
74 } | 95 } |
75 | 96 |
76 WebInspector.PanelEnablerView.prototype.__proto__ = WebInspector.View.prototype; | 97 WebInspector.PanelEnablerView.prototype.__proto__ = WebInspector.View.prototype; |
OLD | NEW |