| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.DialogDelegate} | 33 * @extends {WebInspector.DialogDelegate} |
| 34 * @param {!WebInspector.SourceFrame} sourceFrame |
| 34 */ | 35 */ |
| 35 WebInspector.GoToLineDialog = function(view) | 36 WebInspector.GoToLineDialog = function(sourceFrame) |
| 36 { | 37 { |
| 37 WebInspector.DialogDelegate.call(this); | 38 WebInspector.DialogDelegate.call(this); |
| 38 | 39 |
| 39 this.element = document.createElement("div"); | 40 this.element = document.createElement("div"); |
| 40 this.element.className = "go-to-line-dialog"; | 41 this.element.className = "go-to-line-dialog"; |
| 41 | 42 |
| 42 this.element.createChild("label").textContent = WebInspector.UIString("Go to
line: "); | 43 this.element.createChild("label").textContent = WebInspector.UIString("Go to
line: "); |
| 43 | 44 |
| 44 this._input = this.element.createChild("input"); | 45 this._input = this.element.createChild("input"); |
| 45 this._input.setAttribute("type", "text"); | 46 this._input.setAttribute("type", "text"); |
| 46 this._input.setAttribute("size", 6); | 47 this._input.setAttribute("size", 6); |
| 47 | 48 |
| 48 this._goButton = this.element.createChild("button"); | 49 this._goButton = this.element.createChild("button"); |
| 49 this._goButton.textContent = WebInspector.UIString("Go"); | 50 this._goButton.textContent = WebInspector.UIString("Go"); |
| 50 this._goButton.addEventListener("click", this._onGoClick.bind(this), false); | 51 this._goButton.addEventListener("click", this._onGoClick.bind(this), false); |
| 51 | 52 |
| 52 this._view = view; | 53 this._sourceFrame = sourceFrame; |
| 53 } | 54 } |
| 54 | 55 |
| 55 /** | 56 /** |
| 56 * @param {!WebInspector.Panel} panel | 57 * @param {!WebInspector.Panel} panel |
| 57 * @param {function():?WebInspector.View} viewGetter | 58 * @param {function():?WebInspector.SourceFrame} sourceFrameGetter |
| 58 */ | 59 */ |
| 59 WebInspector.GoToLineDialog.install = function(panel, viewGetter) | 60 WebInspector.GoToLineDialog.install = function(panel, sourceFrameGetter) |
| 60 { | 61 { |
| 61 var goToLineShortcut = WebInspector.GoToLineDialog.createShortcut(); | 62 var goToLineShortcut = WebInspector.GoToLineDialog.createShortcut(); |
| 62 panel.registerShortcuts([goToLineShortcut], WebInspector.GoToLineDialog._sho
w.bind(null, viewGetter)); | 63 panel.registerShortcuts([goToLineShortcut], WebInspector.GoToLineDialog._sho
w.bind(null, sourceFrameGetter)); |
| 63 } | 64 } |
| 64 | 65 |
| 65 /** | 66 /** |
| 66 * @param {function():?WebInspector.View} viewGetter | 67 * @param {function():?WebInspector.SourceFrame} sourceFrameGetter |
| 67 * @param {?Event=} event | 68 * @param {?Event=} event |
| 68 * @return {boolean} | 69 * @return {boolean} |
| 69 */ | 70 */ |
| 70 WebInspector.GoToLineDialog._show = function(viewGetter, event) | 71 WebInspector.GoToLineDialog._show = function(sourceFrameGetter, event) |
| 71 { | 72 { |
| 72 var sourceView = viewGetter(); | 73 var sourceFrame = sourceFrameGetter(); |
| 73 if (!sourceView || !sourceView.canHighlightPosition()) | 74 if (!sourceFrame) |
| 74 return false; | 75 return false; |
| 75 WebInspector.Dialog.show(sourceView.element, new WebInspector.GoToLineDialog
(sourceView)); | 76 WebInspector.Dialog.show(sourceFrame.element, new WebInspector.GoToLineDialo
g(sourceFrame)); |
| 76 return true; | 77 return true; |
| 77 } | 78 } |
| 78 | 79 |
| 79 /** | 80 /** |
| 80 * @return {!WebInspector.KeyboardShortcut.Descriptor} | 81 * @return {!WebInspector.KeyboardShortcut.Descriptor} |
| 81 */ | 82 */ |
| 82 WebInspector.GoToLineDialog.createShortcut = function() | 83 WebInspector.GoToLineDialog.createShortcut = function() |
| 83 { | 84 { |
| 84 return WebInspector.KeyboardShortcut.makeDescriptor("g", WebInspector.Keyboa
rdShortcut.Modifiers.Ctrl); | 85 return WebInspector.KeyboardShortcut.makeDescriptor("g", WebInspector.Keyboa
rdShortcut.Modifiers.Ctrl); |
| 85 } | 86 } |
| 86 | 87 |
| 87 WebInspector.GoToLineDialog.prototype = { | 88 WebInspector.GoToLineDialog.prototype = { |
| 88 focus: function() | 89 focus: function() |
| 89 { | 90 { |
| 90 WebInspector.setCurrentFocusElement(this._input); | 91 WebInspector.setCurrentFocusElement(this._input); |
| 91 this._input.select(); | 92 this._input.select(); |
| 92 }, | 93 }, |
| 93 | 94 |
| 94 _onGoClick: function() | 95 _onGoClick: function() |
| 95 { | 96 { |
| 96 this._applyLineNumber(); | 97 this._applyLineNumber(); |
| 97 WebInspector.Dialog.hide(); | 98 WebInspector.Dialog.hide(); |
| 98 }, | 99 }, |
| 99 | 100 |
| 100 _applyLineNumber: function() | 101 _applyLineNumber: function() |
| 101 { | 102 { |
| 102 var value = this._input.value; | 103 var value = this._input.value; |
| 103 var lineNumber = parseInt(value, 10) - 1; | 104 var lineNumber = parseInt(value, 10) - 1; |
| 104 if (!isNaN(lineNumber) && lineNumber >= 0) | 105 if (!isNaN(lineNumber) && lineNumber >= 0) |
| 105 this._view.highlightPosition(lineNumber); | 106 this._sourceFrame.revealPosition(lineNumber, 0, true); |
| 106 }, | 107 }, |
| 107 | 108 |
| 108 onEnter: function() | 109 onEnter: function() |
| 109 { | 110 { |
| 110 this._applyLineNumber(); | 111 this._applyLineNumber(); |
| 111 }, | 112 }, |
| 112 | 113 |
| 113 __proto__: WebInspector.DialogDelegate.prototype | 114 __proto__: WebInspector.DialogDelegate.prototype |
| 114 } | 115 } |
| OLD | NEW |