OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 if (!WebInspector.isWin() || (!this._openBracketIdentifiers[event.keyIde ntifier] && !this._closeBracketIdentifiers[event.keyIdentifier])) { | 320 if (!WebInspector.isWin() || (!this._openBracketIdentifiers[event.keyIde ntifier] && !this._closeBracketIdentifiers[event.keyIdentifier])) { |
321 this._keyDownInternal(event); | 321 this._keyDownInternal(event); |
322 return; | 322 return; |
323 } | 323 } |
324 | 324 |
325 this._keyDownTimer = setTimeout(this._keyDownInternal.bind(this, event), 0); | 325 this._keyDownTimer = setTimeout(this._keyDownInternal.bind(this, event), 0); |
326 }, | 326 }, |
327 | 327 |
328 _keyDownInternal: function(event) | 328 _keyDownInternal: function(event) |
329 { | 329 { |
330 if (this._openBracketIdentifiers[event.keyIdentifier]) { | 330 var direction = this._openBracketIdentifiers[event.keyIdentifier] ? -1 : 0; |
vsevik
2014/03/04 18:02:48
I liked the previous version better :)
| |
331 var isRotateLeft = !event.shiftKey && !event.altKey; | 331 direction = this._closeBracketIdentifiers[event.keyIdentifier] ? 1 : dir ection; |
332 if (isRotateLeft) { | |
333 var panelOrder = this._tabbedPane.allTabs(); | |
334 var index = panelOrder.indexOf(this.currentPanel().name); | |
335 index = (index === 0) ? panelOrder.length - 1 : index - 1; | |
336 this.showPanel(panelOrder[index]); | |
337 event.consume(true); | |
338 return; | |
339 } | |
340 | 332 |
341 var isGoBack = event.altKey; | 333 if (!direction) |
342 if (isGoBack && this._canGoBackInHistory()) { | 334 return; |
343 this._goBackInHistory(); | 335 |
344 event.consume(true); | 336 if (!event.shiftKey && !event.altKey) { |
345 } | 337 this._changePanelInDirection(direction); |
338 event.consume(true); | |
346 return; | 339 return; |
347 } | 340 } |
348 | 341 |
349 if (this._closeBracketIdentifiers[event.keyIdentifier]) { | 342 if (event.altKey && this._moveInHistory(direction)) |
350 var isRotateRight = !event.shiftKey && !event.altKey; | 343 event.consume(true) |
351 if (isRotateRight) { | |
352 var panelOrder = this._tabbedPane.allTabs(); | |
353 var index = panelOrder.indexOf(this.currentPanel().name); | |
354 index = (index + 1) % panelOrder.length; | |
355 this.showPanel(panelOrder[index]); | |
356 event.consume(true); | |
357 return; | |
358 } | |
359 | |
360 var isGoForward = event.altKey; | |
361 if (isGoForward && this._canGoForwardInHistory()) { | |
362 this._goForwardInHistory(); | |
363 event.consume(true); | |
364 } | |
365 return; | |
366 } | |
367 }, | 344 }, |
368 | 345 |
369 _canGoBackInHistory: function() | 346 _changePanelInDirection: function(direction) |
370 { | 347 { |
371 return this._historyIterator > 0; | 348 var panelOrder = this._tabbedPane.allTabs(); |
349 var index = panelOrder.indexOf(this.currentPanel().name); | |
350 index = (index + panelOrder.length + direction) % panelOrder.length; | |
351 this.showPanel(panelOrder[index]); | |
372 }, | 352 }, |
373 | 353 |
374 _goBackInHistory: function() | 354 _moveInHistory: function(move) |
375 { | 355 { |
356 var newIndex = this._historyIterator + move; | |
357 if (newIndex >= this._history.length || newIndex < 0) | |
358 return false; | |
359 | |
376 this._inHistory = true; | 360 this._inHistory = true; |
377 this.setCurrentPanel(WebInspector.panels[this._history[--this._historyIt erator]]); | 361 this._historyIterator = newIndex; |
362 this.setCurrentPanel(WebInspector.panels[this._history[this._historyIter ator]]); | |
378 delete this._inHistory; | 363 delete this._inHistory; |
379 }, | |
380 | 364 |
381 _canGoForwardInHistory: function() | 365 return true; |
382 { | |
383 return this._historyIterator < this._history.length - 1; | |
384 }, | |
385 | |
386 _goForwardInHistory: function() | |
387 { | |
388 this._inHistory = true; | |
389 this.setCurrentPanel(WebInspector.panels[this._history[++this._historyIt erator]]); | |
390 delete this._inHistory; | |
391 }, | 366 }, |
392 | 367 |
393 _pushToHistory: function(panelName) | 368 _pushToHistory: function(panelName) |
394 { | 369 { |
395 if (this._inHistory) | 370 if (this._inHistory) |
396 return; | 371 return; |
397 | 372 |
398 this._history.splice(this._historyIterator + 1, this._history.length - t his._historyIterator - 1); | 373 this._history.splice(this._historyIterator + 1, this._history.length - t his._historyIterator - 1); |
399 if (!this._history.length || this._history[this._history.length - 1] !== panelName) | 374 if (!this._history.length || this._history[this._history.length - 1] !== panelName) |
400 this._history.push(panelName); | 375 this._history.push(panelName); |
401 this._historyIterator = this._history.length - 1; | 376 this._historyIterator = this._history.length - 1; |
402 }, | 377 }, |
403 | 378 |
404 onResize: function() | 379 onResize: function() |
405 { | 380 { |
406 WebInspector.Dialog.modalHostRepositioned(); | 381 WebInspector.Dialog.modalHostRepositioned(); |
407 }, | 382 }, |
408 | 383 |
409 /** | 384 /** |
410 * @return {!Element} | 385 * @return {!Element} |
411 */ | 386 */ |
412 topResizerElement: function() | 387 topResizerElement: function() |
413 { | 388 { |
414 return this._tabbedPane.headerElement(); | 389 return this._tabbedPane.headerElement(); |
415 }, | 390 }, |
416 | 391 |
392 _createImagedCounterElementIfNeeded: function(count, id, styleName) | |
393 { | |
394 if (!count) | |
395 return; | |
396 | |
397 var imageElement = this._errorWarningCountElement.createChild("div", sty leName); | |
398 var counterElement = this._errorWarningCountElement.createChild("span"); | |
399 counterElement.id = id; | |
400 counterElement.textContent = count; | |
401 }, | |
402 | |
417 /** | 403 /** |
418 * @param {number} errors | 404 * @param {number} errors |
419 * @param {number} warnings | 405 * @param {number} warnings |
420 */ | 406 */ |
421 setErrorAndWarningCounts: function(errors, warnings) | 407 setErrorAndWarningCounts: function(errors, warnings) |
422 { | 408 { |
423 if (!errors && !warnings) { | 409 this._errorWarningCountElement.classList.toggle("hidden", !errors && !wa rnings); |
424 this._errorWarningCountElement.classList.add("hidden"); | |
425 this._tabbedPane.headerResized(); | |
426 return; | |
427 } | |
428 | |
429 this._errorWarningCountElement.classList.remove("hidden"); | |
430 this._errorWarningCountElement.removeChildren(); | 410 this._errorWarningCountElement.removeChildren(); |
431 | 411 |
432 if (errors) { | 412 this._createImagedCounterElementIfNeeded(errors, "error-count", "error-i con-small"); |
433 var errorImageElement = this._errorWarningCountElement.createChild(" div", "error-icon-small"); | 413 this._createImagedCounterElementIfNeeded(warnings, "warning-count", "war ning-icon-small"); |
434 var errorElement = this._errorWarningCountElement.createChild("span" ); | |
435 errorElement.id = "error-count"; | |
436 errorElement.textContent = errors; | |
437 } | |
438 | 414 |
439 if (warnings) { | 415 var errorString = errors ? WebInspector.UIString("%d error%s", errors, errors > 1 ? "s" : "") : ""; |
440 var warningsImageElement = this._errorWarningCountElement.createChil d("div", "warning-icon-small"); | 416 var warningString = warnings ? WebInspector.UIString("%d warning%s", wa rnings, warnings > 1 ? "s" : "") : ""; |
441 var warningsElement = this._errorWarningCountElement.createChild("sp an"); | 417 var commaString = errors && warnings ? ", " : ""; |
442 warningsElement.id = "warning-count"; | 418 this._errorWarningCountElement.title = errorString + commaString + warni ngString; |
443 warningsElement.textContent = warnings; | |
444 } | |
445 | |
446 if (errors) { | |
447 if (warnings) { | |
448 if (errors == 1) { | |
449 if (warnings == 1) | |
450 this._errorWarningCountElement.title = WebInspector.UISt ring("%d error, %d warning", errors, warnings); | |
451 else | |
452 this._errorWarningCountElement.title = WebInspector.UISt ring("%d error, %d warnings", errors, warnings); | |
453 } else if (warnings == 1) | |
454 this._errorWarningCountElement.title = WebInspector.UIString ("%d errors, %d warning", errors, warnings); | |
455 else | |
456 this._errorWarningCountElement.title = WebInspector.UIString ("%d errors, %d warnings", errors, warnings); | |
457 } else if (errors == 1) | |
458 this._errorWarningCountElement.title = WebInspector.UIString("%d error", errors); | |
459 else | |
460 this._errorWarningCountElement.title = WebInspector.UIString("%d errors", errors); | |
461 } else if (warnings == 1) | |
462 this._errorWarningCountElement.title = WebInspector.UIString("%d war ning", warnings); | |
463 else if (warnings) | |
464 this._errorWarningCountElement.title = WebInspector.UIString("%d war nings", warnings); | |
465 else | |
466 this._errorWarningCountElement.title = null; | |
467 | |
468 this._tabbedPane.headerResized(); | 419 this._tabbedPane.headerResized(); |
469 }, | 420 }, |
470 | 421 |
471 __proto__: WebInspector.View.prototype | 422 __proto__: WebInspector.View.prototype |
472 }; | 423 }; |
473 | 424 |
474 /** | 425 /** |
475 * @type {!WebInspector.InspectorView} | 426 * @type {!WebInspector.InspectorView} |
476 */ | 427 */ |
477 WebInspector.inspectorView; | 428 WebInspector.inspectorView; |
478 | 429 |
479 /** | 430 /** |
480 * @constructor | 431 * @constructor |
481 * @extends {WebInspector.View} | 432 * @extends {WebInspector.View} |
482 */ | 433 */ |
483 WebInspector.RootView = function() | 434 WebInspector.RootView = function() |
484 { | 435 { |
485 WebInspector.View.call(this); | 436 WebInspector.View.call(this); |
486 this.markAsRoot(); | 437 this.markAsRoot(); |
487 this.element.classList.add("fill", "root-view"); | 438 this.element.classList.add("fill", "root-view"); |
488 this.element.setAttribute("spellcheck", false); | 439 this.element.setAttribute("spellcheck", false); |
489 window.addEventListener("resize", this.doResize.bind(this), true); | 440 window.addEventListener("resize", this.doResize.bind(this), true); |
490 }; | 441 }; |
491 | 442 |
492 WebInspector.RootView.prototype = { | 443 WebInspector.RootView.prototype = { |
493 __proto__: WebInspector.View.prototype | 444 __proto__: WebInspector.View.prototype |
494 }; | 445 }; |
OLD | NEW |