addon-sdk/source/lib/sdk/tabs.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/lib/sdk/tabs.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +"use strict";
     1.8 +
     1.9 +module.metadata = {
    1.10 +  "stability": "unstable",
    1.11 +  "engines": {
    1.12 +    "Firefox": "*",
    1.13 +    "Fennec": "*"
    1.14 +  }
    1.15 +};
    1.16 +
    1.17 +const { modelFor } = require("./model/core");
    1.18 +const { viewFor } = require("./view/core");
    1.19 +const { isTab } = require("./tabs/utils");
    1.20 +
    1.21 +
    1.22 +if (require("./system/xul-app").is("Fennec")) {
    1.23 +  module.exports = require("./windows/tabs-fennec").tabs;
    1.24 +}
    1.25 +else {
    1.26 +  module.exports = require("./tabs/tabs-firefox");
    1.27 +}
    1.28 +
    1.29 +const tabs = module.exports;
    1.30 +
    1.31 +// Implement `modelFor` function for the Tab instances.
    1.32 +// Finds a right model by iterating over all tab models
    1.33 +// and finding one that wraps given `view`.
    1.34 +modelFor.when(isTab, view => {
    1.35 +  for (let model of tabs) {
    1.36 +    if (viewFor(model) === view)
    1.37 +      return model;
    1.38 +  }
    1.39 +  return null;
    1.40 +});

mercurial