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

Side by Side Diff: ports/devenv/mounter.js

Issue 1415743013: Run jshint over all JavaScript files (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@repo_conf
Patch Set: Created 5 years, 1 month 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 | « ports/devenv/devenvwidget/devenvwidget.js ('k') | ports/devenv/tests/common.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The Native Client Authors. All rights reserved. 2 * Copyright 2015 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* globals g_mount */
8
7 'use strict'; 9 'use strict';
8 10
9 // TODO(gdeepti): Clean up global variables. 11 // TODO(gdeepti): Clean up global variables.
10 var mounterBackground = null; 12 var mounterBackground = null;
11 var mounterThumb = null; 13 var mounterThumb = null;
12 var mounterHeader = null; 14 var mounterHeader = null;
13 var mounter = null; 15 var mounter = null;
14 var isVisible = false; 16 var isVisible = false;
15 var mounterClient = null; 17 var mounterClient = null;
16 18
(...skipping 20 matching lines...) Expand all
37 function grabFocus() { 39 function grabFocus() {
38 walkDom(function(element) { 40 walkDom(function(element) {
39 if (element == mounterBackground) 41 if (element == mounterBackground)
40 return false; 42 return false;
41 43
42 if (element.hasAttribute('tabIndex')) { 44 if (element.hasAttribute('tabIndex')) {
43 element.oldTabIndex = element.getAttribute('tabIndex'); 45 element.oldTabIndex = element.getAttribute('tabIndex');
44 } 46 }
45 element.setAttribute('tabIndex', '-1'); 47 element.setAttribute('tabIndex', '-1');
46 return true; 48 return true;
47 }) 49 });
48 } 50 }
49 51
50 function releaseFocus() { 52 function releaseFocus() {
51 walkDom(function(element) { 53 walkDom(function(element) {
52 if (element == mounterBackground) 54 if (element == mounterBackground)
53 return false; 55 return false;
54 56
55 if (element.oldTabIndex) { 57 if (element.oldTabIndex) {
56 element.setAttribute('tabIndex', element.oldTabIndex); 58 element.setAttribute('tabIndex', element.oldTabIndex);
57 delete element.oldTabIndex; 59 delete element.oldTabIndex;
58 } else { 60 } else {
59 element.removeAttribute('tabIndex'); 61 element.removeAttribute('tabIndex');
60 } 62 }
61 return true; 63 return true;
62 }) 64 });
63 mounterClient.terminal.focus(); 65 mounterClient.terminal.focus();
64 } 66 }
65 67
66 function sizeBackground() { 68 function sizeBackground() {
67 mounterBackground.style.height = intToPixels(window.innerHeight); 69 mounterBackground.style.height = intToPixels(window.innerHeight);
68 var bgTop = 0; 70 var bgTop = 0;
69 if (!isVisible) 71 if (!isVisible)
70 bgTop = 10 - window.innerHeight 72 bgTop = 10 - window.innerHeight;
71 mounterBackground.style.top = intToPixels(bgTop); 73 mounterBackground.style.top = intToPixels(bgTop);
72 } 74 }
73 75
74 function changeVisibility(visible) { 76 function changeVisibility(visible) {
75 isVisible = visible; 77 isVisible = visible;
76 78
77 sizeBackground() 79 sizeBackground();
78 if (!mounterClient) 80 if (!mounterClient)
79 return; 81 return;
80 82
81 if (isVisible) 83 if (isVisible)
82 grabFocus(); 84 grabFocus();
83 else 85 else
84 releaseFocus(); 86 releaseFocus();
85 } 87 }
86 88
87 function backgroundClicked() { 89 function backgroundClicked() {
88 if (isVisible) 90 if (isVisible)
89 changeVisibility(false); 91 changeVisibility(false);
90 } 92 }
91 93
92 function thumbClicked(event) { 94 function thumbClicked(event) {
93 if (!isVisible) 95 if (!isVisible)
94 changeVisibility(true); 96 changeVisibility(true);
95 event.stopPropagation(); 97 event.stopPropagation();
96 } 98 }
97 99
98 function mounterClicked(event) { 100 function mounterClicked(event) {
99 event.stopPropagation(); 101 event.stopPropagation();
100 } 102 }
101 103
102 function initMounterclient(mount, chooseFolder, 104 function MounterClient(mount, chooseFolder,
103 mountHandler, unmountHandler, terminal) { 105 mountHandler, unmountHandler, terminal) {
104 this.mount = mount; 106 this.mount = mount;
105 this.onChooseFolder = chooseFolder; 107 this.onChooseFolder = chooseFolder;
106 this.onMount = mountHandler; 108 this.onMount = mountHandler;
107 this.onUnmount = unmountHandler 109 this.onUnmount = unmountHandler;
108 this.terminal = terminal; 110 this.terminal = terminal;
109 } 111 }
110 112
111 function addMountControlItem(item, mountControl) { 113 function addMountControlItem(item, mountControl) {
112 mountControl.appendChild(item); 114 mountControl.appendChild(item);
113 item.mountControl = mountControl; 115 item.mountControl = mountControl;
114 } 116 }
115 117
116 function populateMountControl(mountControl) { 118 function populateMountControl(mountControl) {
117 mountControl.pathEdit.value = g_mount.mountPoint; 119 mountControl.pathEdit.value = g_mount.mountPoint;
118 // TODO(gdeepti): Enable this to accept mountPoint specified by th user. 120 // TODO(gdeepti): Enable this to accept mountPoint specified by th user.
119 // Temporarily disabled to fix sync issues. 121 // Temporarily disabled to fix sync issues.
120 mountControl.pathEdit.disabled = g_mount.mounted; 122 mountControl.pathEdit.disabled = g_mount.mounted;
121 mountControl.localPathEdit.value = g_mount.localPath; 123 mountControl.localPathEdit.value = g_mount.localPath;
122 mountControl.localPathEdit.disabled = g_mount.mounted; 124 mountControl.localPathEdit.disabled = g_mount.mounted;
123 mountControl.selectButton.disabled = g_mount.mounted; 125 mountControl.selectButton.disabled = g_mount.mounted;
124 mountControl.mountButton.disabled = 126 mountControl.mountButton.disabled =
125 (g_mount.mounted || 127 (g_mount.mounted ||
126 (g_mount.entry == null)); 128 (g_mount.entry === null));
127 mountControl.unmountButton.disabled = !g_mount.mounted; 129 mountControl.unmountButton.disabled = !g_mount.mounted;
128 } 130 }
129 131
130 function mountPointChanged(event) { 132 function mountPointChanged(event) {
131 var mountControl = event.target.mountControl; 133 var mountControl = event.target.mountControl;
132 mountControl.mount.mountPoint = event.target.value; 134 mountControl.mount.mountPoint = event.target.value;
133 populateMountControl(mountControl); 135 populateMountControl(mountControl);
134 } 136 }
135 137
136 function chooseFolderClicked(event) { 138 function chooseFolderClicked(event) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 unmountButton.textContent = 'Unmount'; 201 unmountButton.textContent = 'Unmount';
200 addMountControlItem(unmountButton, mountControl); 202 addMountControlItem(unmountButton, mountControl);
201 mountControl.unmountButton = unmountButton; 203 mountControl.unmountButton = unmountButton;
202 unmountButton.onclick = unmountClicked; 204 unmountButton.onclick = unmountClicked;
203 205
204 mountControl.mount = mount; 206 mountControl.mount = mount;
205 207
206 init(function() { 208 init(function() {
207 populateMountControl(mountControl); 209 populateMountControl(mountControl);
208 }); 210 });
209 mounter.appendChild(mountControl); 211 window.mounter.appendChild(mountControl);
210 212
211 return mountControl; 213 return mountControl;
212 } 214 }
213 215
214 function initMounter(makeVisible, aMounterClient, init) { 216 function initMounter(makeVisible, aMounterClient, init) {
215 mounterBackground.onclick = backgroundClicked; 217 mounterBackground.onclick = backgroundClicked;
216 mounter.onclick = mounterClicked; 218 mounter.onclick = mounterClicked;
217 mounterThumb.onclick = thumbClicked; 219 mounterThumb.onclick = thumbClicked;
218 220
219 mounterClient = aMounterClient; 221 mounterClient = aMounterClient;
220 222
221 addMountControl(g_mount, init); 223 addMountControl(g_mount, init);
222 changeVisibility(makeVisible); 224 changeVisibility(makeVisible);
223 225
224 window.onresize = function() { 226 window.onresize = sizeBackground;
225 sizeBackground();
226 }
227 } 227 }
OLDNEW
« no previous file with comments | « ports/devenv/devenvwidget/devenvwidget.js ('k') | ports/devenv/tests/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698