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

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

Issue 2670833005: Improve VR omnibox styling and function (Closed)
Patch Set: Fix closure compiler failure. Yay closure compiler. 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
« no previous file with comments | « chrome/browser/resources/vr_shell/vr_shell_ui.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 this.devMode = false; 213 this.devMode = false;
214 214
215 this.uiElement = new DomUiElement('#reload-ui-button'); 215 this.uiElement = new DomUiElement('#reload-ui-button');
216 this.uiElement.domElement.addEventListener('click', function() { 216 this.uiElement.domElement.addEventListener('click', function() {
217 ui.purge(); 217 ui.purge();
218 api.doAction(api.Action.RELOAD_UI, {}); 218 api.doAction(api.Action.RELOAD_UI, {});
219 }); 219 });
220 220
221 let update = new api.UiElementUpdate(); 221 let update = new api.UiElementUpdate();
222 update.setVisible(false); 222 update.setVisible(false);
223 update.setSize(0.5, 0.2);
224 update.setTranslation(0, -2, -1);
225 update.setRotation(1, 0, 0, -0.8);
223 ui.updateElement(this.uiElement.uiElementId, update); 226 ui.updateElement(this.uiElement.uiElementId, update);
224 } 227 }
225 228
226 setEnabled(enabled) { 229 setEnabled(enabled) {
227 this.enabled = enabled; 230 this.enabled = enabled;
228 this.updateState(); 231 this.updateState();
229 } 232 }
230 233
231 setDevMode(enabled) { 234 setDevMode(enabled) {
232 this.devMode = enabled; 235 this.devMode = enabled;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // Field-clearing button. 502 // Field-clearing button.
500 let clearButton = root.querySelector('#omnibox-clear-button'); 503 let clearButton = root.querySelector('#omnibox-clear-button');
501 clearButton.addEventListener('click', function() { 504 clearButton.addEventListener('click', function() {
502 this.inputField.value = ''; 505 this.inputField.value = '';
503 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': ''}); 506 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': ''});
504 }.bind(this)); 507 }.bind(this));
505 508
506 // Watch for the enter key to trigger navigation. 509 // Watch for the enter key to trigger navigation.
507 this.inputField.addEventListener('keypress', function(e) { 510 this.inputField.addEventListener('keypress', function(e) {
508 if (e.keyCode == 13) { 511 if (e.keyCode == 13) {
512 this.setSuggestions([]);
509 api.doAction( 513 api.doAction(
510 // TODO(crbug.com/683344): Properly choose prefix. 514 // TODO(crbug.com/683344): Properly choose prefix.
511 api.Action.LOAD_URL, {'url': 'http://' + e.target.value}); 515 api.Action.LOAD_URL, {'url': 'http://' + e.target.value});
512 } 516 }
513 }); 517 });
514 518
515 // Watch for field input to generate suggestions. 519 // Watch for field input to generate suggestions.
516 this.inputField.addEventListener('input', function(e) { 520 this.inputField.addEventListener('input', function(e) {
517 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': e.target.value}); 521 api.doAction(api.Action.OMNIBOX_CONTENT, {'text': e.target.value});
518 }); 522 });
519 523
520 // Clicking on suggestions triggers navigation. 524 // Clicking on suggestions triggers navigation.
521 let elements = root.querySelectorAll('.omnibox-suggestion'); 525 let elements = root.querySelectorAll('.suggestion');
522 this.maxSuggestions = elements.length; 526 this.maxSuggestions = elements.length;
523 for (var i = 0; i < elements.length; i++) { 527 for (var i = 0; i < elements.length; i++) {
524 elements[i].addEventListener('click', function(index, e) { 528 elements[i].addEventListener('click', function(index, e) {
525 if (e.target.url) { 529 if (e.target.url) {
526 api.doAction(api.Action.LOAD_URL, {'url': e.target.url}); 530 api.doAction(api.Action.LOAD_URL, {'url': e.target.url});
531 this.setSuggestions([]);
527 } 532 }
528 }.bind(this, i)); 533 }.bind(this, i));
529 } 534 }
535
530 } 536 }
531 537
532 setEnabled(enabled) { 538 setEnabled(enabled) {
533 this.enabled = enabled; 539 this.enabled = enabled;
534 540
535 let update = new api.UiElementUpdate(); 541 let update = new api.UiElementUpdate();
536 update.setVisible(enabled); 542 update.setVisible(enabled);
537 ui.updateElement(this.domUiElement.uiElementId, update); 543 ui.updateElement(this.domUiElement.uiElementId, update);
538 } 544 }
539 545
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 ui.flush(); 673 ui.flush();
668 } 674 }
669 675
670 return { 676 return {
671 initialize: initialize, 677 initialize: initialize,
672 command: command, 678 command: command,
673 }; 679 };
674 })(); 680 })();
675 681
676 window.addEventListener('load', vrShellUi.initialize); 682 window.addEventListener('load', vrShellUi.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/resources/vr_shell/vr_shell_ui.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698