Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: chrome/browser/resources/vr_shell/vr_shell_ui.js

Issue 2670833005: Improve VR omnibox styling and function (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var vrShellUi = (function() { 5 var vrShellUi = (function() {
6 'use strict'; 6 'use strict';
7 7
8 let ui = new scene.Scene(); 8 let ui = new scene.Scene();
9 let uiManager; 9 let uiManager;
10 10
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 this.devMode = false; 203 this.devMode = false;
204 204
205 this.uiElement = new DomUiElement('#reload-ui-button'); 205 this.uiElement = new DomUiElement('#reload-ui-button');
206 this.uiElement.domElement.addEventListener('click', function() { 206 this.uiElement.domElement.addEventListener('click', function() {
207 ui.purge(); 207 ui.purge();
208 api.doAction(api.Action.RELOAD_UI, {}); 208 api.doAction(api.Action.RELOAD_UI, {});
209 }); 209 });
210 210
211 let update = new api.UiElementUpdate(); 211 let update = new api.UiElementUpdate();
212 update.setVisible(false); 212 update.setVisible(false);
213 update.setSize(0.5, 0.2, 1);
214 update.setTranslation(0, -2, -1);
215 update.setRotation(1, 0, 0, -0.8);
213 ui.updateElement(this.uiElement.uiElementId, update); 216 ui.updateElement(this.uiElement.uiElementId, update);
214 } 217 }
215 218
216 setEnabled(enabled) { 219 setEnabled(enabled) {
217 this.enabled = enabled; 220 this.enabled = enabled;
218 this.updateState(); 221 this.updateState();
219 } 222 }
220 223
221 setDevMode(enabled) { 224 setDevMode(enabled) {
222 this.devMode = enabled; 225 this.devMode = enabled;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // Field-clearing button. 492 // Field-clearing button.
490 let clearButton = root.querySelector('#omnibox-clear-button'); 493 let clearButton = root.querySelector('#omnibox-clear-button');
491 clearButton.addEventListener('click', function() { 494 clearButton.addEventListener('click', function() {
492 this.inputField.value = ''; 495 this.inputField.value = '';
493 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': ''}); 496 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': ''});
494 }.bind(this)); 497 }.bind(this));
495 498
496 // Watch for the enter key to trigger navigation. 499 // Watch for the enter key to trigger navigation.
497 this.inputField.addEventListener('keypress', function(e) { 500 this.inputField.addEventListener('keypress', function(e) {
498 if (e.keyCode == 13) { 501 if (e.keyCode == 13) {
502 this.setSuggestions([]);
499 api.doAction( 503 api.doAction(
500 // TODO(crbug.com/683344): Properly choose prefix. 504 // TODO(crbug.com/683344): Properly choose prefix.
501 api.Action.LOAD_URL, {'url': 'http://' + e.target.value}); 505 api.Action.LOAD_URL, {'url': 'http://' + e.target.value});
502 } 506 }
503 }); 507 });
504 508
505 // Watch for field input to generate suggestions. 509 // Watch for field input to generate suggestions.
506 this.inputField.addEventListener('input', function(e) { 510 this.inputField.addEventListener('input', function(e) {
507 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': e.target.value}); 511 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': e.target.value});
508 }); 512 });
509 513
510 // Clicking on suggestions triggers navigation. 514 // Clicking on suggestions triggers navigation.
511 let elements = root.querySelectorAll('.omnibox-suggestion'); 515 let elements = root.querySelectorAll('.suggestion');
512 this.maxSuggestions = elements.length; 516 this.maxSuggestions = elements.length;
513 for (var i = 0; i < elements.length; i++) { 517 for (var i = 0; i < elements.length; i++) {
514 elements[i].addEventListener('click', function(index, e) { 518 elements[i].addEventListener('click', function(index, e) {
515 if (e.target.url) { 519 if (e.target.url) {
516 api.doAction(api.Action.LOAD_URL, {'url': e.target.url}); 520 api.doAction(api.Action.LOAD_URL, {'url': e.target.url});
521 this.setSuggestions([]);
517 } 522 }
518 }.bind(this, i)); 523 }.bind(this, i));
519 } 524 }
525
520 } 526 }
521 527
522 setEnabled(enabled) { 528 setEnabled(enabled) {
523 this.enabled = enabled; 529 this.enabled = enabled;
524 530
525 let update = new api.UiElementUpdate(); 531 let update = new api.UiElementUpdate();
526 update.setVisible(enabled); 532 update.setVisible(enabled);
527 ui.updateElement(this.domUiElement.uiElementId, update); 533 ui.updateElement(this.domUiElement.uiElementId, update);
528 } 534 }
529 535
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 ui.flush(); 654 ui.flush();
649 } 655 }
650 656
651 return { 657 return {
652 initialize: initialize, 658 initialize: initialize,
653 command: command, 659 command: command,
654 }; 660 };
655 })(); 661 })();
656 662
657 window.addEventListener('load', vrShellUi.initialize); 663 window.addEventListener('load', vrShellUi.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698