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

Side by Side Diff: Source/devtools/front_end/ResponsiveDesignView.js

Issue 315003008: [DevTools] UI for network conditions emulation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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
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
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, 4, "2.5e m", WebInspector.OverridesSupport.doubleInputValidator, true)); 463 fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingInputFi eld("", WebInspector.overridesSupport.settings.deviceScaleFactor, true, 4, "2.5e m", WebInspector.OverridesSupport.doubleInputValidator, 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 responsive-design-network");
472 var networkCheckbox = WebInspector.SettingsUI.createSettingCheckbox(WebI nspector.UIString("Network"), WebInspector.overridesSupport.settings.emulateNetw orkConditions, true);
473 this._networkSection.appendChild(networkCheckbox);
474 this._networkSection.appendChild(WebInspector.overridesSupport.createNet workThroughputSelect(document));
475
476 this._networkDomainsSection = document.createElementWithClass("div", "re sponsive-design-section");
477 fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebInspe ctor.overridesSupport.settings.emulateNetworkConditions);
478 var networkDomainsInput = WebInspector.SettingsUI.createSettingInputFiel d("", WebInspector.overridesSupport.settings.networkConditionsDomains, false, 0, "190px", WebInspector.OverridesSupport.networkDomainsValidator, false);
479 networkDomainsInput.querySelector("input").placeholder = WebInspector.UI String("Leave empty to limit all domains");
480 fieldsetElement.appendChild(networkDomainsInput);
481 this._networkDomainsSection.appendChild(fieldsetElement);
482
483 updateNetworkCheckboxTitle();
484 WebInspector.overridesSupport.settings.networkConditionsDomains.addChang eListener(updateNetworkCheckboxTitle);
485
486 function updateNetworkCheckboxTitle()
487 {
488 var domains = WebInspector.overridesSupport.settings.networkConditio nsDomains.get();
489 if (!domains.trim()) {
490 networkCheckbox.title = WebInspector.UIString("Limit for all dom ains");
491 } else {
492 var trimmed = domains.split(",").map(function(s) { return s.trim (); }).join(", ");
493 if (trimmed.length > 40)
494 trimmed = trimmed.substring(0, 40) + "...";
495 networkCheckbox.title = WebInspector.UIString("Limit for ") + tr immed;
496 }
497 }
498
469 // User agent. 499 // User agent.
470 this._userAgentSection = document.createElementWithClass("div", "respons ive-design-composite-section vbox solid"); 500 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"); 501 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)); 502 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); 503 var userAgentSelectAndInput = WebInspector.overridesSupport.createUserAg entSelectAndInput(document);
474 userAgentRow.createChild("div", "responsive-design-section hbox").append Child(userAgentSelectAndInput.select); 504 userAgentRow.createChild("div", "responsive-design-section hbox").append Child(userAgentSelectAndInput.select);
475 this._userAgentSection.createChild("div", "responsive-design-section hbo x").appendChild(userAgentSelectAndInput.input); 505 this._userAgentSection.createChild("div", "responsive-design-section hbo x").appendChild(userAgentSelectAndInput.input);
476 506
477 this._toolbarExpandedChanged(); 507 this._toolbarExpandedChanged();
478 }, 508 },
479 509
480 _toggleToolbarExpanded: function() 510 _toggleToolbarExpanded: function()
481 { 511 {
482 WebInspector.settings.responsiveDesign.toolbarExpanded.set(!WebInspector .settings.responsiveDesign.toolbarExpanded.get()); 512 WebInspector.settings.responsiveDesign.toolbarExpanded.set(!WebInspector .settings.responsiveDesign.toolbarExpanded.get());
483 }, 513 },
484 514
485 _toolbarExpandedChanged: function() 515 _toolbarExpandedChanged: function()
486 { 516 {
487 var expanded = WebInspector.settings.responsiveDesign.toolbarExpanded.ge t(); 517 var expanded = WebInspector.settings.responsiveDesign.toolbarExpanded.ge t();
488 this._expandButton.classList.toggle("expanded", expanded); 518 this._expandButton.classList.toggle("expanded", expanded);
489 this._expandButton.querySelector("span").textContent = WebInspector.UISt ring(expanded ? "Collapse" : "Expand"); 519 this._expandButton.querySelector("span").textContent = WebInspector.UISt ring(expanded ? "Collapse" : "Expand");
490 520
491 if (expanded) { 521 if (expanded) {
492 this._expandedScreenTouchSection.setChildren([this._screenSection, t his._touchSection]); 522 this._expandedScreenTouchSection.setChildren([this._screenSection, t his._touchSection]);
493 this._expandedDeviceSection.setChildren([this._deviceSection, this._ expandedScreenTouchSection]); 523 this._expandedDeviceSection.setChildren([this._deviceSection, this._ expandedScreenTouchSection]);
494 this._toolbarSection.setChildren([this._expandSection, this._expande dDeviceSection, this._userAgentSection]); 524 this._expandedNetworkSection.setChildren([this._networkSection, this ._networkDomainsSection]);
525 this._toolbarSection.setChildren([this._expandSection, this._expande dDeviceSection, this._userAgentSection, this._expandedNetworkSection]);
495 } else { 526 } else {
496 this._toolbarSection.setChildren([this._expandSection, this._deviceS ection, this._screenSection, this._touchSection]); 527 this._toolbarSection.setChildren([this._expandSection, this._deviceS ection, this._screenSection, this._touchSection, this._networkSection]);
497 } 528 }
498 529
499 this.onResize(); 530 this.onResize();
500 }, 531 },
501 532
502 _overridesWarningUpdated: function() 533 _overridesWarningUpdated: function()
503 { 534 {
504 var message = WebInspector.overridesSupport.warningMessage(); 535 var message = WebInspector.overridesSupport.warningMessage();
505 if (this._warningMessage.textContent === message) 536 if (this._warningMessage.textContent === message)
506 return; 537 return;
507 this._warningMessage.classList.toggle("hidden", !message); 538 this._warningMessage.classList.toggle("hidden", !message);
508 this._warningMessage.textContent = message; 539 this._warningMessage.textContent = message;
509 this._invalidateCache(); 540 this._invalidateCache();
510 this.onResize(); 541 this.onResize();
511 }, 542 },
512 543
513 __proto__: WebInspector.VBox.prototype 544 __proto__: WebInspector.VBox.prototype
514 }; 545 };
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/OverridesView.js » ('j') | Source/devtools/front_end/sdk/OverridesSupport.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698