OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
8 * @implements {WebInspector.OverridesSupport.PageResizer} | 8 * @implements {WebInspector.OverridesSupport.PageResizer} |
9 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder | 9 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder |
10 */ | 10 */ |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 this._updateUI(); | 384 this._updateUI(); |
385 }, | 385 }, |
386 | 386 |
387 _createToolbar: function() | 387 _createToolbar: function() |
388 { | 388 { |
389 var toolbarElement = this._responsiveDesignContainer.element.createChild
("div", "responsive-design-toolbar"); | 389 var toolbarElement = this._responsiveDesignContainer.element.createChild
("div", "responsive-design-toolbar"); |
390 this._toolbarSection = toolbarElement.createChild("div", "responsive-des
ign-composite-section hbox"); | 390 this._toolbarSection = toolbarElement.createChild("div", "responsive-des
ign-composite-section hbox"); |
391 | 391 |
392 this._expandedDeviceSection = document.createElementWithClass("div", "re
sponsive-design-composite-section vbox"); | 392 this._expandedDeviceSection = document.createElementWithClass("div", "re
sponsive-design-composite-section vbox"); |
393 this._expandedScreenTouchSection = document.createElementWithClass("div"
, "responsive-design-composite-section hbox"); | 393 this._expandedScreenTouchSection = document.createElementWithClass("div"
, "responsive-design-composite-section hbox"); |
| 394 this._expandedNetworkSection = document.createElementWithClass("div", "r
esponsive-design-composite-section vbox solid"); |
394 | 395 |
395 this._expandSection = document.createElementWithClass("div", "responsive
-design-section vbox"); | 396 this._expandSection = document.createElementWithClass("div", "responsive
-design-section vbox"); |
396 WebInspector.settings.responsiveDesign.toolbarExpanded = WebInspector.se
ttings.createSetting("responsiveDesign.toolbarExpanded", false); | 397 WebInspector.settings.responsiveDesign.toolbarExpanded = WebInspector.se
ttings.createSetting("responsiveDesign.toolbarExpanded", false); |
397 this._expandButton = this._expandSection.createChild("div", "responsive-
design-expand"); | 398 this._expandButton = this._expandSection.createChild("div", "responsive-
design-expand"); |
398 this._expandButton.createChild("div", "responsive-design-icon responsive
-design-icon-expand"); | 399 this._expandButton.createChild("div", "responsive-design-icon responsive
-design-icon-expand"); |
399 this._expandButton.createChild("span"); | 400 this._expandButton.createChild("span"); |
400 this._expandButton.addEventListener("click", this._toggleToolbarExpanded
.bind(this)); | 401 this._expandButton.addEventListener("click", this._toggleToolbarExpanded
.bind(this)); |
401 WebInspector.settings.responsiveDesign.toolbarExpanded.addChangeListener
(this._toolbarExpandedChanged, this); | 402 WebInspector.settings.responsiveDesign.toolbarExpanded.addChangeListener
(this._toolbarExpandedChanged, this); |
402 | 403 |
403 // Device | 404 // Device |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 this._swapDimensionsElement.addEventListener("click", WebInspector.overr
idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false); | 460 this._swapDimensionsElement.addEventListener("click", WebInspector.overr
idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false); |
460 | 461 |
461 fieldsetElement.createChild("div", "responsive-design-icon responsive-de
sign-icon-dpr").title = WebInspector.UIString("Device pixel ratio"); | 462 fieldsetElement.createChild("div", "responsive-design-icon responsive-de
sign-icon-dpr").title = WebInspector.UIString("Device pixel ratio"); |
462 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi
eld("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 2, "2em"
, WebInspector.OverridesSupport.inputValidator, true)); | 463 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi
eld("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 2, "2em"
, WebInspector.OverridesSupport.inputValidator, true)); |
463 | 464 |
464 // Touch and viewport | 465 // Touch and viewport |
465 this._touchSection = document.createElementWithClass("div", "responsive-
design-section"); | 466 this._touchSection = document.createElementWithClass("div", "responsive-
design-section"); |
466 this._touchSection.appendChild(WebInspector.SettingsUI.createSettingChec
kbox(WebInspector.UIString("Touch"), WebInspector.overridesSupport.settings.emul
ateTouchEvents, true)); | 467 this._touchSection.appendChild(WebInspector.SettingsUI.createSettingChec
kbox(WebInspector.UIString("Touch"), WebInspector.overridesSupport.settings.emul
ateTouchEvents, true)); |
467 this._touchSection.appendChild(WebInspector.SettingsUI.createSettingChec
kbox(WebInspector.UIString("Viewport"), WebInspector.overridesSupport.settings.e
mulateViewport, true)); | 468 this._touchSection.appendChild(WebInspector.SettingsUI.createSettingChec
kbox(WebInspector.UIString("Viewport"), WebInspector.overridesSupport.settings.e
mulateViewport, true)); |
468 | 469 |
| 470 // Network. |
| 471 this._networkSection = document.createElementWithClass("div", "responsiv
e-design-section"); |
| 472 var networkCheckbox = WebInspector.SettingsUI.createSettingCheckbox(WebI
nspector.UIString("Offline"), WebInspector.overridesSupport.settings.emulateNetw
orkConditions, true); |
| 473 this._networkSection.appendChild(networkCheckbox); |
| 474 updateNetworkCheckboxTitle(); |
| 475 |
| 476 this._networkDomainsSection = document.createElementWithClass("div", "re
sponsive-design-section"); |
| 477 this._networkDomainsSection.appendChild(WebInspector.SettingsUI.createSe
ttingInputField("", WebInspector.overridesSupport.settings.networkDomains, false
, 0, "200px", WebInspector.OverridesSupport.networkDomainsValidator, false)); |
| 478 |
| 479 WebInspector.overridesSupport.settings.networkDomains.addChangeListener(
updateNetworkCheckboxTitle); |
| 480 |
| 481 function updateNetworkCheckboxTitle() |
| 482 { |
| 483 var domains = WebInspector.overridesSupport.settings.networkDomains.
get(); |
| 484 if (!domains.trim()) { |
| 485 networkCheckbox.title = WebInspector.UIString("Offline for all d
omains"); |
| 486 } else { |
| 487 var trimmed = domains.split(",").map(function(s) { return s.trim
(); }).join(", "); |
| 488 if (trimmed.length > 40) |
| 489 trimmed = trimmed.substring(0, 40) + "..."; |
| 490 networkCheckbox.title = WebInspector.UIString("Offline for ") +
trimmed; |
| 491 } |
| 492 } |
| 493 |
469 // User agent. | 494 // User agent. |
470 this._userAgentSection = document.createElementWithClass("div", "respons
ive-design-composite-section vbox solid"); | 495 this._userAgentSection = document.createElementWithClass("div", "respons
ive-design-composite-section vbox solid"); |
471 var userAgentRow = this._userAgentSection.createChild("div", "responsive
-design-composite-section hbox solid"); | 496 var userAgentRow = this._userAgentSection.createChild("div", "responsive
-design-composite-section hbox solid"); |
472 userAgentRow.createChild("div", "responsive-design-section hbox").append
Child(WebInspector.SettingsUI.createSettingCheckbox("User Agent", WebInspector.o
verridesSupport.settings.overrideUserAgent, true)); | 497 userAgentRow.createChild("div", "responsive-design-section hbox").append
Child(WebInspector.SettingsUI.createSettingCheckbox("User Agent", WebInspector.o
verridesSupport.settings.overrideUserAgent, true)); |
473 var userAgentSelectAndInput = WebInspector.overridesSupport.createUserAg
entSelectAndInput(document); | 498 var userAgentSelectAndInput = WebInspector.overridesSupport.createUserAg
entSelectAndInput(document); |
474 userAgentRow.createChild("div", "responsive-design-section hbox").append
Child(userAgentSelectAndInput.select); | 499 userAgentRow.createChild("div", "responsive-design-section hbox").append
Child(userAgentSelectAndInput.select); |
475 this._userAgentSection.createChild("div", "responsive-design-section hbo
x").appendChild(userAgentSelectAndInput.input); | 500 this._userAgentSection.createChild("div", "responsive-design-section hbo
x").appendChild(userAgentSelectAndInput.input); |
476 | 501 |
477 this._toolbarExpandedChanged(); | 502 this._toolbarExpandedChanged(); |
478 }, | 503 }, |
(...skipping 11 matching lines...) Expand all Loading... |
490 | 515 |
491 if (expanded) { | 516 if (expanded) { |
492 this._expandedScreenTouchSection.textContent = ""; | 517 this._expandedScreenTouchSection.textContent = ""; |
493 this._expandedScreenTouchSection.appendChild(this._screenSection); | 518 this._expandedScreenTouchSection.appendChild(this._screenSection); |
494 this._expandedScreenTouchSection.appendChild(this._touchSection); | 519 this._expandedScreenTouchSection.appendChild(this._touchSection); |
495 | 520 |
496 this._expandedDeviceSection.textContent = ""; | 521 this._expandedDeviceSection.textContent = ""; |
497 this._expandedDeviceSection.appendChild(this._deviceSection); | 522 this._expandedDeviceSection.appendChild(this._deviceSection); |
498 this._expandedDeviceSection.appendChild(this._expandedScreenTouchSec
tion); | 523 this._expandedDeviceSection.appendChild(this._expandedScreenTouchSec
tion); |
499 | 524 |
| 525 this._expandedNetworkSection.textContent = ""; |
| 526 this._expandedNetworkSection.appendChild(this._networkSection); |
| 527 this._expandedNetworkSection.appendChild(this._networkDomainsSection
); |
| 528 |
500 this._toolbarSection.textContent = ""; | 529 this._toolbarSection.textContent = ""; |
501 this._toolbarSection.appendChild(this._expandSection); | 530 this._toolbarSection.appendChild(this._expandSection); |
502 this._toolbarSection.appendChild(this._expandedDeviceSection); | 531 this._toolbarSection.appendChild(this._expandedDeviceSection); |
503 this._toolbarSection.appendChild(this._userAgentSection); | 532 this._toolbarSection.appendChild(this._userAgentSection); |
| 533 this._toolbarSection.appendChild(this._expandedNetworkSection); |
504 } else { | 534 } else { |
505 this._toolbarSection.textContent = ""; | 535 this._toolbarSection.textContent = ""; |
506 this._toolbarSection.appendChild(this._expandSection); | 536 this._toolbarSection.appendChild(this._expandSection); |
507 this._toolbarSection.appendChild(this._deviceSection); | 537 this._toolbarSection.appendChild(this._deviceSection); |
508 this._toolbarSection.appendChild(this._screenSection); | 538 this._toolbarSection.appendChild(this._screenSection); |
509 this._toolbarSection.appendChild(this._touchSection); | 539 this._toolbarSection.appendChild(this._touchSection); |
| 540 this._toolbarSection.appendChild(this._networkSection); |
510 } | 541 } |
511 | 542 |
512 this.onResize(); | 543 this.onResize(); |
513 }, | 544 }, |
514 | 545 |
515 _overridesWarningUpdated: function() | 546 _overridesWarningUpdated: function() |
516 { | 547 { |
517 var message = WebInspector.overridesSupport.warningMessage(); | 548 var message = WebInspector.overridesSupport.warningMessage(); |
518 if (this._warningMessage.textContent === message) | 549 if (this._warningMessage.textContent === message) |
519 return; | 550 return; |
520 this._warningMessage.classList.toggle("hidden", !message); | 551 this._warningMessage.classList.toggle("hidden", !message); |
521 this._warningMessage.textContent = message; | 552 this._warningMessage.textContent = message; |
522 this._responsiveDesignEnabledChanged(); | 553 this._responsiveDesignEnabledChanged(); |
523 this.onResize(); | 554 this.onResize(); |
524 }, | 555 }, |
525 | 556 |
526 __proto__: WebInspector.VBox.prototype | 557 __proto__: WebInspector.VBox.prototype |
527 }; | 558 }; |
OLD | NEW |