{"size": 1584, "ext": "js", "max_stars_repo_path": "apps/settings/js/panels/display/panel.js", "max_stars_repo_name": "dlxswangli/gaia", "max_stars_repo_stars_event_min_datetime": "2018-10-10T16:23:17.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-10T16:23:17.000Z", "max_issues_repo_path": "apps/settings/js/panels/display/panel.js", "max_issues_repo_name": "dlxswangli/gaia", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "apps/settings/js/panels/display/panel.js", "max_forks_repo_name": "dlxswangli/gaia", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.4615384615, "max_line_length": 80, "alphanum_fraction": 0.6590909091}
/* global loadJSON */
/**
 * The display panel allow user to modify timeout forscreen-off, brightness, and
 * change wallpaper.
 */
define(function(require) {
  'use strict';

  var SettingsPanel = require('modules/settings_panel');
  var DisplayModule = require('panels/display/display');
  var WallpaperModule = require('panels/display/wallpaper');

  var wallpaperElements = {};
  var displayElements = {};

  return function ctor_display_panel() {
    var display = DisplayModule();
    var wallpaper = WallpaperModule();

    return SettingsPanel({
      onInit: function dp_onInit(panel) {
        displayElements = {
          brightnessManual: panel.querySelector('.brightness-manual'),
          brightnessAuto: panel.querySelector('.brightness-auto')
        };

        wallpaperElements = {
          wallpaper: panel.querySelector('.wallpaper'),
          wallpaperPreview: panel.querySelector('.wallpaper-preview')
        };

        wallpaperElements.wallpaper.addEventListener('click',
          wallpaper.selectWallpaper.bind(wallpaper));
        loadJSON(['/resources/device-features.json'], function(data) {
          display.init(displayElements, data);
        });
      },

      onBeforeShow: function dp_onBeforeShow() {
        wallpaper.observe('wallpaperSrc', function(newValue) {
          wallpaperElements.wallpaperPreview.src = newValue;
        });
        wallpaperElements.wallpaperPreview.src = wallpaper.wallpaperSrc;
      },

      onBeforeHide: function dp_onBeforeHide() {
        wallpaper.unobserve('wallpaperSrc');
      }
    });
  };
});
