How to use the devtools/sham/services.Services.strings function in devtools

To help you get started, we’ve selected a few devtools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joewalker / devtools.html / client / webide / modules / runtime-list.js View on Github external
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

const {Cu} = require("devtools/sham/chrome");

const {Services} = require("devtools/sham/services");
const {AppManager} = require("devtools/client/webide/modules/app-manager");
const EventEmitter = require("devtools/shared/event-emitter");
const {RuntimeScanners, WiFiScanner} = require("devtools/client/webide/modules/runtimes");
const {Devices} = require("devtools/shared/apps/Devices");
const {Task} = require("devtools/sham/task");
const utils = require("devtools/client/webide/modules/utils");

const Strings = Services.strings.createBundle(require("l10n/webide.properties"));

var RuntimeList;

module.exports = RuntimeList = function(window, parentWindow) {
  EventEmitter.decorate(this);
  this._doc = window.document;
  this._UI = parentWindow.UI;
  this._Cmds = parentWindow.Cmds;
  this._parentWindow = parentWindow;
  this._panelNodeEl = "button";
  this._panelBoxEl = "div";

  this.onWebIDEUpdate = this.onWebIDEUpdate.bind(this);
  this._UI.on("webide-update", this.onWebIDEUpdate);

  AppManager.init();
github joewalker / devtools.html / client / shared / devices.js View on Github external
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

const { Ci, Cc } = require("devtools/sham/chrome");
const { getJSON } = require("devtools/client/shared/getjson");
const { Services } = require("devtools/sham/services");
const promise = require("devtools/sham/promise");

const DEVICES_URL = "devtools.devices.url";
const Strings = Services.strings.createBundle(require("l10n/device.properties"));

/* This is a catalog of common web-enabled devices and their properties,
 * intended for (mobile) device emulation.
 *
 * The properties of a device are:
 * - name: brand and model(s).
 * - width: viewport width.
 * - height: viewport height.
 * - pixelRatio: ratio from viewport to physical screen pixels.
 * - userAgent: UA string of the device's browser.
 * - touch: whether it has a touch screen.
 * - firefoxOS: whether Firefox OS is supported.
 *
 * The device types are:
 *   ["phones", "tablets", "laptops", "televisions", "consoles", "watches"].
 *
github joewalker / devtools.html / client / aboutdebugging / components / target-list.js View on Github external
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global React, TargetComponent */

"use strict";

const React = require("devtools/client/shared/vendor/react");
const { TargetComponent } = require("devtools/client/aboutdebugging/components/target");
const { Services } = require("devtools/sham/services");

const Strings = Services.strings.createBundle(
  require("l10n/aboutdebugging.properties"));
const LocaleCompare = (a, b) => {
  return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
};

exports.TargetListComponent = React.createClass({
  displayName: "TargetListComponent",

  render() {
    let client = this.props.client;
    let targets = this.props.targets.sort(LocaleCompare).map(target => {
      return React.createElement(TargetComponent, { client, target });
    });
    return (
      React.createElement("div", { className: "targets" },
        React.createElement("h4", null, this.props.name),
github joewalker / devtools.html / client / shared / widgets / ViewHelpers.js View on Github external
ViewHelpers.L10N = function(aStringBundleName) {
  this.stringBundle = Services.strings.createBundle(aStringBundleName);
  this.ellipsis = "…"; // Should be l10n'd
};
github joewalker / devtools.html / client / webide / modules / app-validator.js View on Github external
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

var {Ci,Cu,CC} = require("devtools/sham/chrome");
const promise = require("devtools/shared/deprecated-sync-thenables");

const { FileUtils } = require("devtools/sham/fileutils");
const {Services} = require("devtools/sham/services");
const {Task} = require("devtools/sham/task");
var XMLHttpRequest = CC("@mozilla.org/xmlextras/xmlhttprequest;1");
var strings = Services.strings.createBundle(require("l10n/app-manager.properties"));

function AppValidator({ type, location }) {
  this.type = type;
  this.location = location;
  this.errors = [];
  this.warnings = [];
}

AppValidator.prototype.error = function (message) {
  this.errors.push(message);
};

AppValidator.prototype.warning = function (message) {
  this.warnings.push(message);
};
github joewalker / devtools.html / client / responsivedesign / responsivedesign.js View on Github external
},

  /**
   * Store the list of all registered presets as a pref.
   */
  savePresets: function RUI_savePresets() {
    // We exclude the custom one
    let registeredPresets = this.presets.filter(function (aPreset) {
      return !aPreset.custom;
    });

    Services.prefs.setCharPref("devtools.responsiveUI.presets", JSON.stringify(registeredPresets));
  },
}

ResponsiveUI.prototype.strings = Services.strings.createBundle("l10n/responsiveUI.properties");

exports.ResponsiveUIManager = this.ResponsiveUIManager;
github joewalker / devtools.html / client / webide / content / webide.js View on Github external
const {Services} = require("devtools/sham/services");
const {AppProjects} = require("devtools/client/webide/modules/app-projects");
const {Connection} = require("devtools/shared/client/connection-manager");
const {AppManager} = require("devtools/client/webide/modules/app-manager");
const EventEmitter = require("devtools/shared/event-emitter");
const promise = require("devtools/sham/promise");
const ProjectEditor = require("devtools/client/projecteditor/lib/projecteditor");
const {GetAvailableAddons} = require("devtools/client/webide/modules/addons");
const {getJSON} = require("devtools/client/shared/getjson");
const utils = require("devtools/client/webide/modules/utils");
const Telemetry = require("devtools/client/shared/telemetry");
const {RuntimeScanners} = require("devtools/client/webide/modules/runtimes");
const {showDoorhanger} = require("devtools/client/shared/doorhanger");
const {Simulators} = require("devtools/client/webide/modules/simulators");

const Strings = Services.strings.createBundle(require("l10n/webide.properties"));

const HTML = "http://www.w3.org/1999/xhtml";
const HELP_URL = "https://developer.mozilla.org/docs/Tools/WebIDE/Troubleshooting";

const MAX_ZOOM = 1.4;
const MIN_ZOOM = 0.6;

const MS_PER_DAY = 86400000;

[["AppManager", AppManager],
 ["AppProjects", AppProjects],
 ["Connection", Connection]].forEach(([key, value]) => {
   Object.defineProperty(this, key, {
     value: value,
     enumerable: true,
     writable: false
github joewalker / devtools.html / client / webide / modules / runtimes.js View on Github external
* License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

const {Cu, Ci} = require("devtools/sham/chrome");
const {Devices} = require("devtools/shared/apps/Devices");
const {Services} = require("devtools/sham/services");
const {Connection} = require("devtools/shared/client/connection-manager");
const {DebuggerServer} = require("devtools/server/main");
const {Simulators} = require("devtools/client/webide/modules/simulators");
const discovery = require("devtools/shared/discovery/discovery");
const EventEmitter = require("devtools/shared/event-emitter");
const promise = require("devtools/sham/promise");
const { AuthenticationResult } = require("devtools/shared/security/auth");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");

const Strings = Services.strings.createBundle(require("l10n/webide.properties"));

/**
 * Runtime and Scanner API
 *
 * |RuntimeScanners| maintains a set of |Scanner| objects that produce one or
 * more |Runtime|s to connect to.  Add-ons can extend the set of known runtimes
 * by registering additional |Scanner|s that emit them.
 *
 * Each |Scanner| must support the following API:
 *
 * enable()
 *   Bind any event handlers and start any background work the scanner needs to
 *   maintain an updated set of |Runtime|s.
 *   Called when the first consumer (such as WebIDE) actively interested in
 *   maintaining the |Runtime| list enables the registry.
 * disable()
github joewalker / devtools.html / client / projecteditor / lib / plugins / app-manager / plugin.js View on Github external
const { Cu } = require("devtools/sham/chrome");
const { Class } = require("sdk/core/heritage");
const { EventTarget } = require("sdk/event/target");
const { emit } = require("sdk/event/core");
const promise = require("devtools/sham/promise");
var { registerPlugin, Plugin } = require("devtools/client/projecteditor/lib/plugins/core");
const { AppProjectEditor } = require("./app-project-editor");
const OPTION_URL = "/devtools/client/themes/images/tool-options.svg";
const {Services} = require("devtools/sham/services");
const Strings = Services.strings.createBundle(require("l10n/webide.properties"));

var AppManagerRenderer = Class({
  extends: Plugin,

  isAppManagerProject: function() {
    return !!this.host.project.appManagerOpts;
  },
  editorForResource: function(resource) {
    if (!resource.parent && this.isAppManagerProject()) {
      return AppProjectEditor;
    }
  },
  getUI: function(parent) {
    let doc = parent.ownerDocument;
    if (parent.childElementCount == 0) {
      let image = doc.createElement("image");
github joewalker / devtools.html / client / markupview / markup-view.js View on Github external
span => span.classList.remove("theme-fg-contrast")
  );
}

/**
 * Map a number from one range to another.
 */
function map(value, oldMin, oldMax, newMin, newMax) {
  let ratio = oldMax - oldMin;
  if (ratio == 0) {
    return value;
  }
  return newMin + (newMax - newMin) * ((value - oldMin) / ratio);
}

MarkupView.prototype.strings = Services.strings.createBundle(require("l10n/inspector.properties"));