tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

highlighter-settings.js (1663B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const {
      8  UPDATE_SHOW_GRID_AREAS,
      9  UPDATE_SHOW_GRID_LINE_NUMBERS,
     10  UPDATE_SHOW_INFINITE_LINES,
     11 } = require("resource://devtools/client/inspector/grids/actions/index.js");
     12 
     13 const SHOW_GRID_AREAS = "devtools.gridinspector.showGridAreas";
     14 const SHOW_GRID_LINE_NUMBERS = "devtools.gridinspector.showGridLineNumbers";
     15 const SHOW_INFINITE_LINES = "devtools.gridinspector.showInfiniteLines";
     16 
     17 const INITIAL_HIGHLIGHTER_SETTINGS = () => {
     18  return {
     19    showGridAreasOverlay: Services.prefs.getBoolPref(SHOW_GRID_AREAS),
     20    showGridLineNumbers: Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
     21    showInfiniteLines: Services.prefs.getBoolPref(SHOW_INFINITE_LINES),
     22  };
     23 };
     24 
     25 const reducers = {
     26  [UPDATE_SHOW_GRID_AREAS](highlighterSettings, { enabled }) {
     27    return Object.assign({}, highlighterSettings, {
     28      showGridAreasOverlay: enabled,
     29    });
     30  },
     31 
     32  [UPDATE_SHOW_GRID_LINE_NUMBERS](highlighterSettings, { enabled }) {
     33    return Object.assign({}, highlighterSettings, {
     34      showGridLineNumbers: enabled,
     35    });
     36  },
     37 
     38  [UPDATE_SHOW_INFINITE_LINES](highlighterSettings, { enabled }) {
     39    return Object.assign({}, highlighterSettings, {
     40      showInfiniteLines: enabled,
     41    });
     42  },
     43 };
     44 
     45 module.exports = function (
     46  highlighterSettings = INITIAL_HIGHLIGHTER_SETTINGS(),
     47  action
     48 ) {
     49  const reducer = reducers[action.type];
     50  if (!reducer) {
     51    return highlighterSettings;
     52  }
     53  return reducer(highlighterSettings, action);
     54 };