How to use the panel.prototype function in panel

To help you get started, we’ve selected a few panel 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 mozilla-b2g / gaia / apps / clock / js / panels / stopwatch / main.js View on Github external
Stopwatch.Panel.prototype.handleEvent = function(event) {
    if (event.type == 'animationend') {
      Panel.prototype.handleEvent.apply(this, arguments);
      return;
    }

    var swp = priv.get(this);
    var button = priv.get(event.target);

    if (swp.stopwatch && swp.stopwatch[button.action]) {
      try {
        // call action on stopwatch
        var val = swp.stopwatch[button.action]();

        // call panel handler
        this['on' + button.action](val);
      } catch (err) {
        if (err instanceof Stopwatch.MaxLapsException) {
          // do nothing
github mozilla-b2g / gaia / dead_apps / clock / js / panels / timer / main.js View on Github external
var onTimerEvent = this.onTimerEvent.bind(this);
    window.addEventListener('timer-start', onTimerEvent);
    window.addEventListener('timer-pause', onTimerEvent);
    window.addEventListener('timer-tick', onTimerEvent);
    window.addEventListener('timer-end', onTimerEvent);
    IntlHelper.observe('timer-hms', this.update.bind(this));
    if (this.visible) {
      // If the timer panel already became visible before we fetched
      // the timer, we must update the display to show the proper
      // timer status.
      this.onvisibilitychange({ detail: { isVisible: true } });
    }
  }.bind(this));
};

Timer.Panel.prototype = Object.create(Panel.prototype);

Timer.Panel.prototype.restoreDefaults = function() {
  return new Promise((resolve) => {
    asyncStorage.getItem('timer-defaults', (values) => {
      values = values || {};
      if (values.sound != null) {
        this.soundButton.value = values.sound;
      }
      if (values.time != null) {
        this.picker.value = values.time;
      }
      if (values.vibrate != null) {
        this.nodes.vibrate.checked = values.vibrate;
      }
      resolve();
    });
github mozilla-b2g / gaia / apps / clock / js / panels / timer / main.js View on Github external
var onTimerEvent = this.onTimerEvent.bind(this);
    window.addEventListener('timer-start', onTimerEvent);
    window.addEventListener('timer-pause', onTimerEvent);
    window.addEventListener('timer-tick', onTimerEvent);
    window.addEventListener('timer-end', onTimerEvent);
    IntlHelper.observe('timer-hms', this.update.bind(this));
    if (this.visible) {
      // If the timer panel already became visible before we fetched
      // the timer, we must update the display to show the proper
      // timer status.
      this.onvisibilitychange({ detail: { isVisible: true } });
    }
  }.bind(this));
};

Timer.Panel.prototype = Object.create(Panel.prototype);

Timer.Panel.prototype.restoreDefaults = function() {
  return new Promise((resolve) => {
    asyncStorage.getItem('timer-defaults', (values) => {
      values = values || {};
      if (values.sound != null) {
        this.soundButton.value = values.sound;
      }
      if (values.time != null) {
        this.picker.value = values.time;
      }
      if (values.vibrate != null) {
        this.nodes.vibrate.checked = values.vibrate;
      }
      resolve();
    });
github mozilla-b2g / gaia / apps / clock / js / stopwatch_panel.js View on Github external
Stopwatch.Panel.prototype.handleEvent = function(event) {
    if (event.type == 'animationend') {
      Panel.prototype.handleEvent.apply(this, arguments);
      return;
    }

    var swp = priv.get(this);
    var button = priv.get(event.target);

    if (swp.stopwatch && swp.stopwatch[button.action]) {
      try {
        // call action on stopwatch
        var val = swp.stopwatch[button.action]();

        // call panel handler
        this['on' + button.action](val);
      } catch (err) {
        if (err instanceof Stopwatch.MaxLapsException) {
          // do nothing
github mozilla-b2g / gaia / apps / clock / js / panels / alarm_edit / main.js View on Github external
this.inputs.volume.addEventListener('change', handleDomEvent);

  this.isSaving = false;

  // If the phone locks during preview, or an alarm fires, pause the sound.
  // TODO: When this is no longer a singleton, unbind the listener.
  window.addEventListener('visibilitychange', function() {
    if (document.hidden) {
      this.stopPreviewSound();
      // Ensure the keyboard goes away.
      document.activeElement.blur();
    }
  }.bind(this));
};

AlarmEdit.prototype = Object.create(Panel.prototype);

Utils.extend(AlarmEdit.prototype, {

  alarm: null,
  ringtonePlayer: AudioManager.createAudioPlayer(),

  handleNameInput: function(evt) {
    // If the user presses enter on the name label, dismiss the
    // keyboard to allow them to continue filling out the other
    // fields. This is not in the `handleEvent` function because we
    // only want to call `.preventDefault` sometimes.
    if (evt.keyCode === KeyEvent.DOM_VK_RETURN) {
      evt.preventDefault();
      evt.target.blur();
    }
  },
github mozilla-b2g / gaia / apps / clock / js / panels / alarm / main.js View on Github external
var Panel = require('panel');
var ClockView = require('panels/alarm/clock_view');
var AlarmListPanel = require('panels/alarm/alarm_list');
var ActiveAlarm = require('panels/alarm/active_alarm');
var html = require('text!panels/alarm/panel.html');

function AlarmPanel() {
  Panel.apply(this, arguments);

  this.element.innerHTML = html;
  ClockView.init();
  this.alarmListPanel = new AlarmListPanel(document.getElementById('alarms'));
  this.activeAlarm = new ActiveAlarm();
}

AlarmPanel.prototype = Object.create(Panel.prototype);

return AlarmPanel;
});
github mozilla-b2g / gaia / apps / clock / js / stopwatch_panel.js View on Github external
action: action == 'resume' ? 'start' : action
      });

      e.addEventListener('click', this);
    }, this);

    View.instance(element).on(
      'visibilitychange',
      this.onvisibilitychange.bind(this)
    );

    this.setStopwatch(new Stopwatch());

  };

  Stopwatch.Panel.prototype = Object.create(Panel.prototype);

  Stopwatch.Panel.prototype.update = function() {
    var swp = priv.get(this);
    var e = swp.stopwatch.getElapsedTime();
    var time = Utils.format.durationMs(e);
    this.nodes.time.textContent = time;
    this.activeLap(false);
  };

  Stopwatch.Panel.prototype.showButtons = function() {
    Array.prototype.forEach.call(arguments, function(a) {
      this.nodes[a].classList.remove('hidden');
    }, this);
  };

  Stopwatch.Panel.prototype.hideButtons = function() {
github mozilla-b2g / gaia / apps / clock / js / panels / stopwatch / main.js View on Github external
action: action == 'resume' ? 'start' : action
      });

      e.addEventListener('click', this);
    }, this);

    element.addEventListener(
      'panel-visibilitychange', this.onvisibilitychange.bind(this));

    IntlHelper.observe('timer-msS', this.updateTimeStrings.bind(this));

    this.setStopwatch(new Stopwatch());

  };

  Stopwatch.Panel.prototype = Object.create(Panel.prototype);

  Stopwatch.Panel.prototype.updateTimeStrings = function() {
    var formatter = IntlHelper.get('timer-msS');
    
    var stopwatch = priv.get(this).stopwatch;
    var e = stopwatch.getElapsedTime();

    formatter.format(e).then(time => {
      this.nodes.time.textContent = time;

      var node = this.nodes.laps;
      var laps = stopwatch.getLaps();
      laps.push(stopwatch.nextLap());
      var lapnodes = node.querySelectorAll('li.lap-cell');

      var lapFormatter = IntlHelper.get('lap-number');