addon-sdk/source/lib/sdk/tabs/events.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/events.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,39 @@
     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 +};
    1.12 +
    1.13 +const ON_PREFIX = "on";
    1.14 +const TAB_PREFIX = "Tab";
    1.15 +
    1.16 +const EVENTS = {
    1.17 +  ready: "DOMContentLoaded",
    1.18 +  load: "load", // Used for non-HTML content
    1.19 +  pageshow: "pageshow", // Used for cached content
    1.20 +  open: "TabOpen",
    1.21 +  close: "TabClose",
    1.22 +  activate: "TabSelect",
    1.23 +  deactivate: null,
    1.24 +  pinned: "TabPinned",
    1.25 +  unpinned: "TabUnpinned"
    1.26 +}
    1.27 +exports.EVENTS = EVENTS;
    1.28 +
    1.29 +Object.keys(EVENTS).forEach(function(name) {
    1.30 +  EVENTS[name] = {
    1.31 +    name: name,
    1.32 +    listener: createListenerName(name),
    1.33 +    dom: EVENTS[name]
    1.34 +  }
    1.35 +});
    1.36 +
    1.37 +function createListenerName (name) {
    1.38 +  if (name === 'pageshow')
    1.39 +    return 'onPageShow';
    1.40 +  else
    1.41 +    return ON_PREFIX + name.charAt(0).toUpperCase() + name.substr(1);
    1.42 +}

mercurial