<commit_before>IonPopup = {
  show: function (options) {
    this.template = Template.ionPopup;
    this.buttons = [];
    var innerTemplate;

    for (var i = 0; i < options.buttons.length; i++) {
      var button = options.buttons[i];
      this.buttons.push({
        text: button.text,
        type: button.type,
        index: i,
        onTap: button.onTap
      });
    }

    //Figure out if a template or just a html string was passed
    if (options.templateName) {
      innerTemplate = Template[options.templateName].renderFunction().value;
    } else {
      innerTemplate = '' + options.template + '';
    }

    var data = {
      title: options.title,
      subTitle: options.subTitle,
      buttons: this.buttons,
      template: innerTemplate
    };

    this.view = Blaze.renderWithData(this.template, data, $('.ionic-body').get(0));
    $('body').addClass('popup-open');

    var $backdrop = $(this.view.firstNode());
    $backdrop.addClass('visible active');
    var $popup = $backdrop.find('.popup-container');
    $popup.addClass('popup-showing active');
  },

  alert: function (options) {
    IonPopup.show({
      title: options.title,
      subTitle: options.subtitle,
      template: options.template,
      templateName: options.templateName,
      buttons: [
        {
          text: options.okText ? options.okText : 'Ok',
          type: options.okType ? options.okType : 'button-positive',
          onTap: function(event) {
            if (options.onOk) options.onOk(event);
            return true;
          }
        }
      ]
    });
  },

  confirm: function (options) {
    IonPopup.show({
      title: options.title,
      subTitle: options.subtitle,
      template: options.template,
      templateName: options.templateName,
      buttons: [
        {
          text: options.okText ? options.okText : 'Ok',
          type: options.okType ? options.okType : 'button-positive',
          onTap: function (event) {
            if (options.onOk) options.onOk(event);
            return true;
          }
        },
        {
          text: options.cancelText ? options.cancelText : 'Cancel',
          type: options.cancelType ? options.cancelType : 'button-default',
          onTap: function (event) {
            if (options.onCancel) options.onCancel(event);
            return true;
          }
        }
      ]
    });
  },

  prompt: function (options) {

    if (options.templateName) {
      template = Template[options.templateName].renderFunction().value;
    } else {
      template = '' + options.template + '';
    }

    template += '<input type="' + options.inputType + '" placeholder="' +
      options.inputPlaceholder + '" name="prompt" >';

    IonPopup.show({
      title: options.title,
      subTitle: options.subtitle,
      template: template,
      buttons: [
        {
          text: options.okText ? options.okText : 'Ok',
          type: options.okType ? options.okType : 'button-positive',
          onTap: function (event, template) {
            var inputVal = $(template.firstNode).find('[name=prompt]').val();
            if (options.onOk) options.onOk(event, inputVal);
            return true;
          }
        },
        {
          text: options.cancelText ? options.cancelText : 'Cancel',
          type: options.cancelType ? options.cancelType : 'button-default',
          onTap: function (event) {
            if (options.onCancel) options.onCancel(event);
            return true;
          }
        }
      ]
    });
  },

  close: function () {
    var $backdrop = $(this.view.firstNode());
    var $popup = $backdrop.find('.popup-container');
    $popup.addClass('popup-hidden').removeClass('active');

    setTimeout(function () {
      $('body').removeClass('popup-open');
      Blaze.remove(this.view);
    }.bind(this), 100);
  },

  buttonClicked: function (index, event, template) {
    var callback = this.buttons[index].onTap;
    if(callback){
      if (callback(event, template) === true) {
        IonPopup.close();
      }
    }
  }
};

Template.ionPopup.rendered = function () {
  $(window).on('keyup.ionPopup', function(event) {
    if (event.which == 27) {
      IonPopup.close();
    }
  });
};

Template.ionPopup.destroyed = function () {
  $(window).off('keyup.ionPopup');
};

Template.ionPopup.events({
  // Handle clicking the backdrop
  'click': function (event, template) {
    if ($(event.target).hasClass('popup-container')) {
      IonPopup.close();
    }
  },

  'click [data-index]': function (event, template) {
    var index = $(event.target).data('index');
    IonPopup.buttonClicked(index, event, template);
  }

});
<commit_msg>Added template reference to the callbacks and fixed subtitle bug<commit_after>IonPopup = {
  show: function (options) {
    this.template = Template.ionPopup;
    this.buttons = [];
    var innerTemplate;

    for (var i = 0; i < options.buttons.length; i++) {
      var button = options.buttons[i];
      this.buttons.push({
        text: button.text,
        type: button.type,
        index: i,
        onTap: button.onTap
      });
    }

    //Figure out if a template or just a html string was passed
    if (options.templateName) {
      innerTemplate = Template[options.templateName].renderFunction().value;
    } else {
      innerTemplate = '' + options.template + '';
    }

    var data = {
      title: options.title,
      subTitle: options.subTitle,
      buttons: this.buttons,
      template: innerTemplate
    };

    this.view = Blaze.renderWithData(this.template, data, $('.ionic-body').get(0));
    $('body').addClass('popup-open');

    var $backdrop = $(this.view.firstNode());
    $backdrop.addClass('visible active');
    var $popup = $backdrop.find('.popup-container');
    $popup.addClass('popup-showing active');
  },

  alert: function (options) {
    IonPopup.show({
      title: options.title,
      subTitle: options.subTitle,
      template: options.template,
      templateName: options.templateName,
      buttons: [
        {
          text: options.okText ? options.okText : 'Ok',
          type: options.okType ? options.okType : 'button-positive',
          onTap: function(event, template) {
            if (options.onOk) options.onOk(event, template);
            return true;
          }
        }
      ]
    });
  },

  confirm: function (options) {
    IonPopup.show({
      title: options.title,
      subTitle: options.subTitle,
      template: options.template,
      templateName: options.templateName,
      buttons: [
        {
          text: options.okText ? options.okText : 'Ok',
          type: options.okType ? options.okType : 'button-positive',
          onTap: function (event, template) {
            if (options.onOk) options.onOk(event, template);
            return true;
          }
        },
        {
          text: options.cancelText ? options.cancelText : 'Cancel',
          type: options.cancelType ? options.cancelType : 'button-default',
          onTap: function (event, template) {
            if (options.onCancel) options.onCancel(event, template);
            return true;
          }
        }
      ]
    });
  },

  prompt: function (options) {

    if (options.templateName) {
      template = Template[options.templateName].renderFunction().value;
    } else {
      template = '' + options.template + '';
    }

    template += '<input type="' + options.inputType + '" placeholder="' +
      options.inputPlaceholder + '" name="prompt" >';

    IonPopup.show({
      title: options.title,
      subTitle: options.subTitle,
      template: template,
      buttons: [
        {
          text: options.okText ? options.okText : 'Ok',
          type: options.okType ? options.okType : 'button-positive',
          onTap: function (event, template) {
            var inputVal = $(template.firstNode).find('[name=prompt]').val();
            if (options.onOk) options.onOk(event, inputVal);
            return true;
          }
        },
        {
          text: options.cancelText ? options.cancelText : 'Cancel',
          type: options.cancelType ? options.cancelType : 'button-default',
          onTap: function (event, template) {
            if (options.onCancel) options.onCancel(event, template);
            return true;
          }
        }
      ]
    });
  },

  close: function () {
    var $backdrop = $(this.view.firstNode());
    var $popup = $backdrop.find('.popup-container');
    $popup.addClass('popup-hidden').removeClass('active');

    setTimeout(function () {
      $('body').removeClass('popup-open');
      Blaze.remove(this.view);
    }.bind(this), 100);
  },

  buttonClicked: function (index, event, template) {
    var callback = this.buttons[index].onTap;
    if(callback){
      if (callback(event, template) === true) {
        IonPopup.close();
      }
    }
  }
};

Template.ionPopup.rendered = function () {
  $(window).on('keyup.ionPopup', function(event) {
    if (event.which == 27) {
      IonPopup.close();
    }
  });
};

Template.ionPopup.destroyed = function () {
  $(window).off('keyup.ionPopup');
};

Template.ionPopup.events({
  // Handle clicking the backdrop
  'click': function (event, template) {
    if ($(event.target).hasClass('popup-container')) {
      IonPopup.close();
    }
  },

  'click [data-index]': function (event, template) {
    var index = $(event.target).data('index');
    IonPopup.buttonClicked(index, event, template);
  }

});
<|endoftext|>


<commit_before>import forestChangeIcon from 'assets/icons/forest-change.svg?sprite';
import landCoverIcon from 'assets/icons/land-cover.svg?sprite';
import landUseIcon from 'assets/icons/land-use.svg?sprite';
import climateIcon from 'assets/icons/climate.svg?sprite';
import biodiversityIcon from 'assets/icons/biodiversity.svg?sprite';
import testIcon from 'assets/icons/crosshair.svg?sprite';
import exploreIcon from 'assets/icons/explore.svg?sprite';
import layersIcon from 'assets/icons/layers.svg?sprite';
import globeIcon from 'assets/icons/globe.svg?sprite';
import analysisIcon from 'assets/icons/analysis.svg?sprite';
import searchIcon from 'assets/icons/search.svg?sprite';
import compact from 'lodash/compact';

// TODO: leave only one, refactor icon styles
import userIcon from 'assets/icons/user.svg?sprite';
import myGFWIcon from 'assets/icons/mygfw.svg?sprite';

import RecentImagerySettings from 'components/recent-imagery/components/recent-imagery-settings';
import Analysis from 'components/analysis';
import Legend from 'components/map/components/legend';

import Datasets from './components/sections/datasets';
import Explore from './components/sections/explore';
import Search from './components/sections/search';
import MyGFW from './components/sections/my-gfw';

const ENVIRONMENT = process.env.NEXT_PUBLIC_FEATURE_ENV;

export const mobileSections = [
  {
    label: 'layers',
    slug: 'datasets',
    icon: globeIcon,
    Component: Datasets,
  },
  {
    label: 'legend',
    slug: 'legend',
    icon: layersIcon,
    Component: Legend,
    embed: true,
  },
  {
    label: 'analysis',
    slug: 'analysis',
    icon: analysisIcon,
    Component: Analysis,
    embed: true,
  },
  {
    label: 'explore',
    slug: 'explore',
    icon: exploreIcon,
    Component: Explore,
  },
  {
    label: 'my gfw',
    slug: 'my-gfw',
    icon: myGFWIcon,
    Component: MyGFW,
  },
  {
    label: 'Recent Satellite Imagery',
    slug: 'recent-imagery',
    Component: RecentImagerySettings,
    hidden: true,
  },
  {
    label: 'Recent Satellite Imagery',
    slug: 'recent-imagery-collapsed',
    openSection: 'recent-imagery',
    collapsed: true,
    hidden: true,
  },
];

export const searchSections = [
  {
    label: 'explore',
    slug: 'explore',
    icon: exploreIcon,
    Component: Explore,
    large: true,
  },
  {
    label: 'search',
    slug: 'search',
    icon: searchIcon,
    Component: Search,
    large: true,
  },
  {
    label: 'my gfw',
    slug: 'my-gfw',
    icon: userIcon,
    Component: MyGFW,
  },
];

export const datasetsSections = compact([
  {
    label: 'layers',
    slug: 'datasets',
    category: 'forestChange',
    icon: forestChangeIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'deforestationAlerts',
        title: 'Deforestation Alerts',
      },
      {
        slug: 'fireAlerts',
        title: 'Fire Alerts',
      },
      {
        slug: 'treeCoverChange',
        title: 'Tree Cover Change',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'landCover',
    icon: landCoverIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'landCover',
        title: 'Land Cover',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'landUse',
    icon: landUseIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'concessions',
        title: 'Commodities',
      },
      {
        slug: 'conservation',
        title: 'Conservation',
      },
      {
        slug: 'infrastructure',
        title: 'Infrastructure',
      },
      {
        slug: 'people',
        title: 'People',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'climate',
    icon: climateIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'carbonEmissions',
        title: 'Carbon Flux',
      },
      {
        slug: 'carbonDensity',
        title: 'Carbon Density',
      },
      {
        slug: 'carbonGains',
        title: 'Potential Carbon Gains',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'biodiversity',
    icon: biodiversityIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'biodiversity',
        title: 'Biodiversity',
      },
    ],
  },
  ENVIRONMENT === 'staging' && {
    label: 'layers',
    slug: 'datasets',
    category: 'test',
    icon: testIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'test',
        title: 'Test',
      },
    ],
  },
]);
<commit_msg>Update carbon Flux to Carbon Emissions<commit_after>import forestChangeIcon from 'assets/icons/forest-change.svg?sprite';
import landCoverIcon from 'assets/icons/land-cover.svg?sprite';
import landUseIcon from 'assets/icons/land-use.svg?sprite';
import climateIcon from 'assets/icons/climate.svg?sprite';
import biodiversityIcon from 'assets/icons/biodiversity.svg?sprite';
import testIcon from 'assets/icons/crosshair.svg?sprite';
import exploreIcon from 'assets/icons/explore.svg?sprite';
import layersIcon from 'assets/icons/layers.svg?sprite';
import globeIcon from 'assets/icons/globe.svg?sprite';
import analysisIcon from 'assets/icons/analysis.svg?sprite';
import searchIcon from 'assets/icons/search.svg?sprite';
import compact from 'lodash/compact';

// TODO: leave only one, refactor icon styles
import userIcon from 'assets/icons/user.svg?sprite';
import myGFWIcon from 'assets/icons/mygfw.svg?sprite';

import RecentImagerySettings from 'components/recent-imagery/components/recent-imagery-settings';
import Analysis from 'components/analysis';
import Legend from 'components/map/components/legend';

import Datasets from './components/sections/datasets';
import Explore from './components/sections/explore';
import Search from './components/sections/search';
import MyGFW from './components/sections/my-gfw';

const ENVIRONMENT = process.env.NEXT_PUBLIC_FEATURE_ENV;

export const mobileSections = [
  {
    label: 'layers',
    slug: 'datasets',
    icon: globeIcon,
    Component: Datasets,
  },
  {
    label: 'legend',
    slug: 'legend',
    icon: layersIcon,
    Component: Legend,
    embed: true,
  },
  {
    label: 'analysis',
    slug: 'analysis',
    icon: analysisIcon,
    Component: Analysis,
    embed: true,
  },
  {
    label: 'explore',
    slug: 'explore',
    icon: exploreIcon,
    Component: Explore,
  },
  {
    label: 'my gfw',
    slug: 'my-gfw',
    icon: myGFWIcon,
    Component: MyGFW,
  },
  {
    label: 'Recent Satellite Imagery',
    slug: 'recent-imagery',
    Component: RecentImagerySettings,
    hidden: true,
  },
  {
    label: 'Recent Satellite Imagery',
    slug: 'recent-imagery-collapsed',
    openSection: 'recent-imagery',
    collapsed: true,
    hidden: true,
  },
];

export const searchSections = [
  {
    label: 'explore',
    slug: 'explore',
    icon: exploreIcon,
    Component: Explore,
    large: true,
  },
  {
    label: 'search',
    slug: 'search',
    icon: searchIcon,
    Component: Search,
    large: true,
  },
  {
    label: 'my gfw',
    slug: 'my-gfw',
    icon: userIcon,
    Component: MyGFW,
  },
];

export const datasetsSections = compact([
  {
    label: 'layers',
    slug: 'datasets',
    category: 'forestChange',
    icon: forestChangeIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'deforestationAlerts',
        title: 'Deforestation Alerts',
      },
      {
        slug: 'fireAlerts',
        title: 'Fire Alerts',
      },
      {
        slug: 'treeCoverChange',
        title: 'Tree Cover Change',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'landCover',
    icon: landCoverIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'landCover',
        title: 'Land Cover',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'landUse',
    icon: landUseIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'concessions',
        title: 'Commodities',
      },
      {
        slug: 'conservation',
        title: 'Conservation',
      },
      {
        slug: 'infrastructure',
        title: 'Infrastructure',
      },
      {
        slug: 'people',
        title: 'People',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'climate',
    icon: climateIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'carbonEmissions',
        title: 'Carbon Emissions',
      },
      {
        slug: 'carbonDensity',
        title: 'Carbon Density',
      },
      {
        slug: 'carbonGains',
        title: 'Potential Carbon Gains',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'biodiversity',
    icon: biodiversityIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'biodiversity',
        title: 'Biodiversity',
      },
    ],
  },
  ENVIRONMENT === 'staging' && {
    label: 'layers',
    slug: 'datasets',
    category: 'test',
    icon: testIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'test',
        title: 'Test',
      },
    ],
  },
]);
<|endoftext|>


<commit_before>import forestChangeIcon from 'assets/icons/forest-change.svg?sprite';
import landCoverIcon from 'assets/icons/land-cover.svg?sprite';
import landUseIcon from 'assets/icons/land-use.svg?sprite';
import climateIcon from 'assets/icons/climate.svg?sprite';
import biodiversityIcon from 'assets/icons/biodiversity.svg?sprite';
import testIcon from 'assets/icons/crosshair.svg?sprite';
import exploreIcon from 'assets/icons/explore.svg?sprite';
import layersIcon from 'assets/icons/layers.svg?sprite';
import globeIcon from 'assets/icons/globe.svg?sprite';
import analysisIcon from 'assets/icons/analysis.svg?sprite';
import searchIcon from 'assets/icons/search.svg?sprite';
import compact from 'lodash/compact';

// TODO: leave only one, refactor icon styles
import userIcon from 'assets/icons/user.svg?sprite';
import myGFWIcon from 'assets/icons/mygfw.svg?sprite';

import RecentImagerySettings from 'components/recent-imagery/components/recent-imagery-settings';
import Analysis from 'components/analysis';
import Legend from 'components/map/components/legend';

import Datasets from './components/sections/datasets';
import Explore from './components/sections/explore';
import Search from './components/sections/search';
import MyGFW from './components/sections/my-gfw';

const ENVIRONMENT = process.env.NEXT_PUBLIC_FEATURE_ENV;

export const mobileSections = [
  {
    label: 'layers',
    slug: 'datasets',
    icon: globeIcon,
    Component: Datasets,
  },
  {
    label: 'legend',
    slug: 'legend',
    icon: layersIcon,
    Component: Legend,
    embed: true,
  },
  {
    label: 'analysis',
    slug: 'analysis',
    icon: analysisIcon,
    Component: Analysis,
    embed: true,
  },
  {
    label: 'explore',
    slug: 'explore',
    icon: exploreIcon,
    Component: Explore,
  },
  {
    label: 'my gfw',
    slug: 'my-gfw',
    icon: myGFWIcon,
    Component: MyGFW,
  },
  {
    label: 'Recent Satellite Imagery',
    slug: 'recent-imagery',
    Component: RecentImagerySettings,
    hidden: true,
  },
  {
    label: 'Recent Satellite Imagery',
    slug: 'recent-imagery-collapsed',
    openSection: 'recent-imagery',
    collapsed: true,
    hidden: true,
  },
];

export const searchSections = [
  {
    label: 'explore',
    slug: 'explore',
    icon: exploreIcon,
    Component: Explore,
    large: true,
  },
  {
    label: 'search',
    slug: 'search',
    icon: searchIcon,
    Component: Search,
    large: true,
  },
  {
    label: 'my gfw',
    slug: 'my-gfw',
    icon: userIcon,
    Component: MyGFW,
  },
];

export const datasetsSections = compact([
  {
    label: 'layers',
    slug: 'datasets',
    category: 'forestChange',
    icon: forestChangeIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'deforestationAlerts',
        title: 'Deforestation Alerts',
      },
      {
        slug: 'fireAlerts',
        title: 'Fire Alerts',
      },
      {
        slug: 'treeCoverChange',
        title: 'Tree Cover Change',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'landCover',
    icon: landCoverIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'landCover',
        title: 'Land Cover',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'landUse',
    icon: landUseIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'concessions',
        title: 'Commodities',
      },
      {
        slug: 'conservation',
        title: 'Conservation',
      },
      {
        slug: 'infrastructure',
        title: 'Infrastructure',
      },
      {
        slug: 'people',
        title: 'People',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'climate',
    icon: climateIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'carbonEmissions',
        title: 'Carbon Emissions',
      },
      {
        slug: 'carbonDensity',
        title: 'Carbon Density',
      },
      {
        slug: 'carbonGains',
        title: 'Potential Carbon Gains',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'biodiversity',
    icon: biodiversityIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'biodiversity',
        title: 'Biodiversity',
      },
    ],
  },
  ENVIRONMENT === 'staging' && {
    label: 'layers',
    slug: 'datasets',
    category: 'test',
    icon: testIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'test',
        title: 'Test Layers',
      },
    ],
  },
]);
<commit_msg>Update section titles<commit_after>import forestChangeIcon from 'assets/icons/forest-change.svg?sprite';
import landCoverIcon from 'assets/icons/land-cover.svg?sprite';
import landUseIcon from 'assets/icons/land-use.svg?sprite';
import climateIcon from 'assets/icons/climate.svg?sprite';
import biodiversityIcon from 'assets/icons/biodiversity.svg?sprite';
import testIcon from 'assets/icons/crosshair.svg?sprite';
import exploreIcon from 'assets/icons/explore.svg?sprite';
import layersIcon from 'assets/icons/layers.svg?sprite';
import globeIcon from 'assets/icons/globe.svg?sprite';
import analysisIcon from 'assets/icons/analysis.svg?sprite';
import searchIcon from 'assets/icons/search.svg?sprite';
import compact from 'lodash/compact';

// TODO: leave only one, refactor icon styles
import userIcon from 'assets/icons/user.svg?sprite';
import myGFWIcon from 'assets/icons/mygfw.svg?sprite';

import RecentImagerySettings from 'components/recent-imagery/components/recent-imagery-settings';
import Analysis from 'components/analysis';
import Legend from 'components/map/components/legend';

import Datasets from './components/sections/datasets';
import Explore from './components/sections/explore';
import Search from './components/sections/search';
import MyGFW from './components/sections/my-gfw';

const ENVIRONMENT = process.env.NEXT_PUBLIC_FEATURE_ENV;

export const mobileSections = [
  {
    label: 'layers',
    slug: 'datasets',
    icon: globeIcon,
    Component: Datasets,
  },
  {
    label: 'legend',
    slug: 'legend',
    icon: layersIcon,
    Component: Legend,
    embed: true,
  },
  {
    label: 'analysis',
    slug: 'analysis',
    icon: analysisIcon,
    Component: Analysis,
    embed: true,
  },
  {
    label: 'explore',
    slug: 'explore',
    icon: exploreIcon,
    Component: Explore,
  },
  {
    label: 'my gfw',
    slug: 'my-gfw',
    icon: myGFWIcon,
    Component: MyGFW,
  },
  {
    label: 'Recent Satellite Imagery',
    slug: 'recent-imagery',
    Component: RecentImagerySettings,
    hidden: true,
  },
  {
    label: 'Recent Satellite Imagery',
    slug: 'recent-imagery-collapsed',
    openSection: 'recent-imagery',
    collapsed: true,
    hidden: true,
  },
];

export const searchSections = [
  {
    label: 'explore',
    slug: 'explore',
    icon: exploreIcon,
    Component: Explore,
    large: true,
  },
  {
    label: 'search',
    slug: 'search',
    icon: searchIcon,
    Component: Search,
    large: true,
  },
  {
    label: 'my gfw',
    slug: 'my-gfw',
    icon: userIcon,
    Component: MyGFW,
  },
];

export const datasetsSections = compact([
  {
    label: 'layers',
    slug: 'datasets',
    category: 'forestChange',
    icon: forestChangeIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'deforestationAlerts',
        title: 'Deforestation Alerts',
      },
      {
        slug: 'fireAlerts',
        title: 'Fire Alerts',
      },
      {
        slug: 'treeCoverChange',
        title: 'Tree Cover Change',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'landCover',
    icon: landCoverIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'landCover',
        title: 'Land Cover',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'landUse',
    icon: landUseIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'concessions',
        title: 'Commodities',
      },
      {
        slug: 'conservation',
        title: 'Conservation',
      },
      {
        slug: 'infrastructure',
        title: 'Infrastructure',
      },
      {
        slug: 'people',
        title: 'People',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'climate',
    icon: climateIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'carbonEmissions',
        title: 'Carbon Flux',
      },
      {
        slug: 'carbonDensity',
        title: 'Carbon Density',
      },
      {
        slug: 'carbonGains',
        title: 'Potential Carbon Gains',
      },
    ],
  },
  {
    label: 'layers',
    slug: 'datasets',
    category: 'biodiversity',
    icon: biodiversityIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'biodiversity',
        title: 'Biodiversity',
      },
    ],
  },
  ENVIRONMENT === 'staging' && {
    label: 'layers',
    slug: 'datasets',
    category: 'test',
    icon: testIcon,
    Component: Datasets,
    subCategories: [
      {
        slug: 'test',
        title: 'Test Layers',
      },
    ],
  },
]);
<|endoftext|>


<commit_before>/*
 *  Init shell script module
 */

(function(global, $) {

    var codiad = global.codiad;

    codiad.shellScript = {
        controller: 'components/shell_script/controller.php',
        dialog: 'components/shell_script/dialog.php',
        //////////////////////////////////////////////////////////////////
        // Analyze source code
        //////////////////////////////////////////////////////////////////

        analyzeCode: function() {

            // Run controller to analyze source code of client
            $.get(this.controller + '?action=analyze_code', function(data) {
            });

        },
        //////////////////////////////////////////////////////////////////
        // Deploy application
        //////////////////////////////////////////////////////////////////

        deployApp: function() {
            alert('Deploy application in progress. You will receivce deployment result by mail.');
            // Run controller to deploy application
            $.get(this.controller + '?action=deploy_app', function(data) {
                var testResponse = codiad.jsend.parse(data);
                if (testResponse !== 'error') {
                    alert(testResponse.toString());
                    codiad.message.success(testResponse.toString());
                } else {
                    codiad.message.error('ERROR');
                }
            });
        },

        //////////////////////////////////////////////////////////////////
        // Finish exam
        //////////////////////////////////////////////////////////////////

        finishExam: function() {
            alert('Finish exam.');
            // Run controller to finish exam
            $.get(this.controller + '?action=finish_exam', function(data) {
                var testResponse = codiad.jsend.parse(data);
                testResponse = testResponse.join('\n');
                if (testResponse !== 'error') {
                    alert(testResponse.toString());
                    codiad.message.success('Exam finished');
                } else {
                    codiad.message.error('ERROR');
                }
            });
        },

        //////////////////////////////////////////////////////////////////
        // Commit active file
        //////////////////////////////////////////////////////////////////

        commit: function() {
            var _this = this;
            $.get(this.controller+'?action=check_commit');
            codiad.modal.load(600, this.dialog + '?action=load');
            $('#modal-content form').live('submit', function(e) {
                e.preventDefault();
                var selectedFiles = $('#txt_selected_files').val();
                var commitMessage = $.trim($('textarea[name=commit_message]').val());
                $.get(_this.controller + '?action=commit&list=' + selectedFiles + '&message=' + commitMessage, function(data) {
                    var commitResponse = codiad.jsend.parse(data);
                    if (commitResponse !== 'error') {
                        codiad.message.success('Commited successfully');
                    } else {
                        codiad.message.error('ERROR Commit failed !!!');
                    }
                });
                codiad.modal.unload();
            });
        },

        //////////////////////////////////////////////////////////////////
        // Test command line from GUI
        //////////////////////////////////////////////////////////////////

        test: function() {
            // Run controller to test command line
            $.get(this.controller + '?action=test_command', function(data) {
                var testResponse = codiad.jsend.parse(data);
                testResponse = testResponse.join('\n');
                if (testResponse !== 'error') {
                    alert(testResponse.toString());
                    codiad.message.success('Run command with success');
                } else {
                    codiad.message.error('ERROR');
                }
            });
        }
    };

})(this, jQuery);
<commit_msg>support deploy application action<commit_after>/*
 *  Init shell script module
 */

(function(global, $) {

    var codiad = global.codiad;

    codiad.shellScript = {
        controller: 'components/shell_script/controller.php',
        dialog: 'components/shell_script/dialog.php',
        //////////////////////////////////////////////////////////////////
        // Analyze source code
        //////////////////////////////////////////////////////////////////

        analyzeCode: function() {

            // Run controller to analyze source code of client
            $.get(this.controller + '?action=analyze_code', function(data) {
            });

        },
        //////////////////////////////////////////////////////////////////
        // Deploy application
        //////////////////////////////////////////////////////////////////

        deployApp: function() {
            alert('Deploy application in progress. You will receivce deployment result by mail.');
            // Run controller to deploy application
            $.get(this.controller + '?action=deploy_app', function(data) {
                var deployReponse = codiad.jsend.parse(data);
                if (deployReponse !== 'error') {
                    codiad.message.success(deployReponse);
                } else {
                    codiad.message.error(deployReponse);
                }
            });
        },

        //////////////////////////////////////////////////////////////////
        // Finish exam
        //////////////////////////////////////////////////////////////////

        finishExam: function() {
            alert('Finish exam.');
            // Run controller to finish exam
            $.get(this.controller + '?action=finish_exam', function(data) {
                var testResponse = codiad.jsend.parse(data);
                testResponse = testResponse.join('\n');
                if (testResponse !== 'error') {
                    alert(testResponse.toString());
                    codiad.message.success('Exam finished');
                } else {
                    codiad.message.error('ERROR');
                }
            });
        },

        //////////////////////////////////////////////////////////////////
        // Commit active file
        //////////////////////////////////////////////////////////////////

        commit: function() {
            var _this = this;
            $.get(this.controller+'?action=check_commit');
            codiad.modal.load(600, this.dialog + '?action=load');
            $('#modal-content form').live('submit', function(e) {
                e.preventDefault();
                var selectedFiles = $('#txt_selected_files').val();
                var commitMessage = $.trim($('textarea[name=commit_message]').val());
                $.get(_this.controller + '?action=commit&list=' + selectedFiles + '&message=' + commitMessage, function(data) {
                    var commitResponse = codiad.jsend.parse(data);
                    if (commitResponse !== 'error') {
                        codiad.message.success(commitResponse);
                    } else {
                        codiad.message.error(commitResponse);
                    }
                });
                codiad.modal.unload();
            });
        },

        //////////////////////////////////////////////////////////////////
        // Test command line from GUI
        //////////////////////////////////////////////////////////////////

        test: function() {
            // Run controller to test command line
            $.get(this.controller + '?action=test_command', function(data) {
                var testResponse = codiad.jsend.parse(data);
                testResponse = testResponse.join('\n');
                if (testResponse !== 'error') {
                    alert(testResponse.toString());
                    codiad.message.success('Run command with success');
                } else {
                    codiad.message.error('ERROR');
                }
            });
        }
    };

})(this, jQuery);
<|endoftext|>


<commit_before>/**
 * Button UI element
 *
 * @class button
 * @augments elation.ui.base
 * @memberof elation.ui
 *
 * @param {object} args
 * @param {string} args.tag
 * @param {string} args.classname
 * @param {string} args.label
 * @param {string} args.title
 * @param {boolean} args.draggable
 * @param {boolean} args.autoblur
 * @param {boolean} args.autofocus
 */
elation.component.add('ui.button', function() {
  this.init = function(name, container, args) {
    this.tag = this.args.tag || "BUTTON";
    this.classname = this.args.classname || "";
    this.title = this.args.title || false;
    this.draggable = this.args.draggable || false;
    this.label = this.args.label || container.innerHTML;
    this.autoblur = this.args.autoblur || false;

    elation.html.addclass(this.container, 'ui_button');
    this.create();
    elation.events.add(this.container, 'click', this);

    for (var k in this.events) {
      elation.events.add(this.container, k, this.events[k]);
    }
  }
  /**
   * Initialize HTML element
   * @function create
   * @memberof elation.ui.button#
   */
  this.create = function() {
    //this.element = document.createElement(this.tag);
    this.container.innerHTML = this.label;
    var classname = '';
    if (this.draggable) {
      classname = 'elation_ui_button_draggable';
      this.container.draggable = true;
    }
    classname += this.classname;
    if (classname.length > 0) {
      this.container.className = classname;
    }
    if (this.title)
      this.container.title = this.title;
  }
  /**
   * Add as a child of the specified element, removing from current parent if necessary
   * @function addTo
   * @memberof elation.ui.button#
   * @returns {boolean}
   */
  this.addTo = function(parent) {
    if (typeof parent != 'undefined') {
      if (!this.container)
        this.create();
      parent.appendChild(this.container);
      return true;
    }
    return false;
  }
  /**
   * Sets the text label of the button
   * @function setLabel
   * @memberof elation.ui.button#
   */
  this.setLabel = function(label) {
    this.label = label;
    if (this.container)
      this.container.innerHTML = label;
  }
  /**
   * Set whether the element is active or not
   * @function setActive
   * @memberof elation.ui.button#
   * @param {boolean} active
   */
  this.setActive = function(active) {
    if (active) {
      elation.html.addclass(this.container, 'state_active');
    } else {
      elation.html.removeclass(this.container, 'state_active');
    }
  }
  /**
   * Event handler for HTML button's click event
   * @function click
   * @memberof elation.ui.button#
   * @param {boolean} active
   * @emits ui_button_click
   */
  this.click = function(ev) {
    elation.events.fire({type: 'ui_button_click', element: this});
    if (this.autoblur) {
      this.container.blur();
    }
  }
}, elation.ui.base);

/*
plop = new function() {
  this.extend = function(name, definition, implement) {
    plop[name] = definition;
//    elation.utils.arrayset(this, name, definition);
    foo = elation.utils.arrayget(this, name);
    foo.prototype = new plop.Object;
    foo.prototype.constructor = plop[name];
    foo.prototype.supr = plop.Object.prototype;
    if (implement instanceof Array) {
      console.log(implement);
    }
  }
}

plop.Object = function() {
  this.implement = function(from) {
console.log('inherit', this.constructor.prototype, 'from', from);
    for (var k in from) {
      if (k != 'constructor' && k != 'prototype') {
        this[k] = from[k];
      }
    }
  }
  this.implements = function(constructor) {
//console.log('see if',this,'implements',constructor);
    if (this instanceof constructor) {
//console.log('ya');
      return true;
    }
    var k, b = true, po = this, pc = new constructor;
//console.log('check 4 rlz', pc);
    for (k in pc) {
      b = b && k in po;
    }
//console.log((!!k && b) ? "probably" : "nope");
    return !!k && b;
  }
}
*/
/*
// Thing
plop.Thing = function() {
  this.doThing = function(n) {
    alert('thing it up ' + n + 'times');
  }
}
plop.Thing.prototype = new plop.Object;
//plop.Thing.prototype.constructor = plop.Thing;
// Magic
plop.Magic = function() {
  this.doMagic = function(n) {
    alert('magic it up ' + n + 'times');
  }
}
plop.Magic.prototype = new plop.Object;
//plop.Magic.prototype.constructor = plop.Magic;
// MagicThing
plop.MagicThing = function() {
  this.doMagicThing = function(n) {
    this.doThing(n);
    this.doMagic(n);
  }
  this.doThing = function(n) {
    alert('CUSTOM THINGER: ' + n);
  }
}
plop.MagicThing.prototype = new plop.Object;
plop.MagicThing.prototype.implement(new plop.Thing);
plop.MagicThing.prototype.implement(new plop.Magic);
//plop.MagicThing.prototype.constructor = plop.MagicThing.prototype;

function dump(thing) {
  console.log(thing, thing.implements(plop.Object), thing.implements(plop.Magic), thing.implements(plop.Thing));
}

var thing = new plop.Thing();
var magic = new plop.Magic();
var magicthing = new plop.MagicThing();
dump(thing);
dump(magic);
dump(magicthing);
*/
<commit_msg>Added defaultcomponent to ui.button<commit_after>/**
 * Button UI element
 *
 * @class button
 * @augments elation.ui.base
 * @memberof elation.ui
 *
 * @param {object} args
 * @param {string} args.tag
 * @param {string} args.classname
 * @param {string} args.label
 * @param {string} args.title
 * @param {boolean} args.draggable
 * @param {boolean} args.autoblur
 * @param {boolean} args.autofocus
 */
elation.component.add('ui.button', function() {
  this.defaultcontainer = { tag: 'button', classname: 'ui_button' };

  this.init = function(name, container, args) {
    this.tag = this.args.tag || "BUTTON";
    this.classname = this.args.classname || "";
    this.title = this.args.title || false;
    this.draggable = this.args.draggable || false;
    this.label = this.args.label || container.innerHTML;
    this.autoblur = this.args.autoblur || false;

    elation.html.addclass(this.container, 'ui_button');
    this.create();
    elation.events.add(this.container, 'click', this);

    for (var k in this.events) {
      elation.events.add(this.container, k, this.events[k]);
    }
  }
  /**
   * Initialize HTML element
   * @function create
   * @memberof elation.ui.button#
   */
  this.create = function() {
    //this.element = document.createElement(this.tag);
    this.container.innerHTML = this.label;
    var classname = '';
    if (this.draggable) {
      classname = 'elation_ui_button_draggable';
      this.container.draggable = true;
    }
    classname += this.classname;
    if (classname.length > 0) {
      this.container.className = classname;
    }
    if (this.title)
      this.container.title = this.title;
  }
  /**
   * Add as a child of the specified element, removing from current parent if necessary
   * @function addTo
   * @memberof elation.ui.button#
   * @returns {boolean}
   */
  this.addTo = function(parent) {
    if (typeof parent != 'undefined') {
      if (!this.container)
        this.create();
      parent.appendChild(this.container);
      return true;
    }
    return false;
  }
  /**
   * Sets the text label of the button
   * @function setLabel
   * @memberof elation.ui.button#
   */
  this.setLabel = function(label) {
    this.label = label;
    if (this.container)
      this.container.innerHTML = label;
  }
  /**
   * Set whether the element is active or not
   * @function setActive
   * @memberof elation.ui.button#
   * @param {boolean} active
   */
  this.setActive = function(active) {
    if (active) {
      elation.html.addclass(this.container, 'state_active');
    } else {
      elation.html.removeclass(this.container, 'state_active');
    }
  }
  /**
   * Event handler for HTML button's click event
   * @function click
   * @memberof elation.ui.button#
   * @param {boolean} active
   * @emits ui_button_click
   */
  this.click = function(ev) {
    elation.events.fire({type: 'ui_button_click', element: this});
    if (this.autoblur) {
      this.container.blur();
    }
  }
}, elation.ui.base);

/*
plop = new function() {
  this.extend = function(name, definition, implement) {
    plop[name] = definition;
//    elation.utils.arrayset(this, name, definition);
    foo = elation.utils.arrayget(this, name);
    foo.prototype = new plop.Object;
    foo.prototype.constructor = plop[name];
    foo.prototype.supr = plop.Object.prototype;
    if (implement instanceof Array) {
      console.log(implement);
    }
  }
}

plop.Object = function() {
  this.implement = function(from) {
console.log('inherit', this.constructor.prototype, 'from', from);
    for (var k in from) {
      if (k != 'constructor' && k != 'prototype') {
        this[k] = from[k];
      }
    }
  }
  this.implements = function(constructor) {
//console.log('see if',this,'implements',constructor);
    if (this instanceof constructor) {
//console.log('ya');
      return true;
    }
    var k, b = true, po = this, pc = new constructor;
//console.log('check 4 rlz', pc);
    for (k in pc) {
      b = b && k in po;
    }
//console.log((!!k && b) ? "probably" : "nope");
    return !!k && b;
  }
}
*/
/*
// Thing
plop.Thing = function() {
  this.doThing = function(n) {
    alert('thing it up ' + n + 'times');
  }
}
plop.Thing.prototype = new plop.Object;
//plop.Thing.prototype.constructor = plop.Thing;
// Magic
plop.Magic = function() {
  this.doMagic = function(n) {
    alert('magic it up ' + n + 'times');
  }
}
plop.Magic.prototype = new plop.Object;
//plop.Magic.prototype.constructor = plop.Magic;
// MagicThing
plop.MagicThing = function() {
  this.doMagicThing = function(n) {
    this.doThing(n);
    this.doMagic(n);
  }
  this.doThing = function(n) {
    alert('CUSTOM THINGER: ' + n);
  }
}
plop.MagicThing.prototype = new plop.Object;
plop.MagicThing.prototype.implement(new plop.Thing);
plop.MagicThing.prototype.implement(new plop.Magic);
//plop.MagicThing.prototype.constructor = plop.MagicThing.prototype;

function dump(thing) {
  console.log(thing, thing.implements(plop.Object), thing.implements(plop.Magic), thing.implements(plop.Thing));
}

var thing = new plop.Thing();
var magic = new plop.Magic();
var magicthing = new plop.MagicThing();
dump(thing);
dump(magic);
dump(magicthing);
*/
<|endoftext|>


<commit_before>'use strict';

/* global Connector */

Connector.playerSelector = '.lecteur';

Connector.artistSelector = '.artiste .inside_call';

Connector.getTrack = function () {
	var text = $('.info-text .name').text().trim();
	return text || null;
};

Connector.isPlaying = function () {
	return $('.playing').length;
};
<commit_msg>Return boolean value in `isPlaying` function<commit_after>'use strict';

/* global Connector */

Connector.playerSelector = '.lecteur';

Connector.artistSelector = '.artiste .inside_call';

Connector.getTrack = function () {
	var text = $('.info-text .name').text().trim();
	return text || null;
};

Connector.isPlaying = function () {
	return $('.playing').length > 0;
};
<|endoftext|>


<commit_before>paper.install(window);
var SQRT_3 = Math.pow(3, 0.5);
var blue = '#1485E0';
var lightBlue = '#C4E1F7';
var triangle;

window.onload = function() {
  paper.setup('triangle-with-a-shadow');
  triangle = new Triangle(calcA());
  paper.view.draw();

  paper.view.onFrame = function (event) {
    project.clear();
    triangle.draw();
  };
};

window.onresize = function() {
  project.clear();
  triangle.resize(calcA());
};

var calcA = function() {
  return Math.max(250, Math.min(paper.view.size.width, paper.view.size.height) - 400);
};

// ---------------------------------------------------
//  Triangle
// ---------------------------------------------------
var Triangle = function(a) {
  this.resize(a);
};

Triangle.prototype.resize = function(a) {
  // Offset
  var x_off = paper.view.center.x;
  var y_off = 1.25 * paper.view.center.y;
  // The points of the triangle
  this.pts = [new paper.Point(0 + x_off, -a / SQRT_3 + y_off),
              new paper.Point(-a/2 + x_off, a * 0.5 / SQRT_3 + y_off),
              new paper.Point(a/2 + x_off, a * 0.5 / SQRT_3 + y_off)];
  // Make the shadow
  this.shadow = new Shadow(this.pts);
};

Triangle.prototype.draw = function() {
  // Draw the shadow
  this.shadow.draw();
  // Draw Sides
  var path = new Path();
      path.fillColor = '#fff';
      path.strokeColor = blue;
      path.strokeWidth = 2;
      path.strokeJoin = 'round';
      path.add(new Point(this.pts[0], this.pts[2]));
      path.add(new Point(this.pts[2], this.pts[1]));
      path.add(new Point(this.pts[1], this.pts[0]));
      path.closed = true;
};

// ---------------------------------------------------
//  Triangle Shadow
// ---------------------------------------------------
var Shadow = function(_pts) {
  this.pts = [];
  for (var i = 0; i < _pts.length; i++) {
    this.pts.push(_pts[i].clone());
  };
  this.y = [this.pts[1].y, this.pts[0].y];
  this.x = this.pts[0].x;
  this.update();
};

Shadow.prototype.update = function(m_x, m_y) {
  if (!m_x || !m_y)
    return;
  if (m_x > paper.view.getSize().width / 2)
    this.pts[0].x = this.map(m_x,
                             paper.view.getSize().width / 2,
                             paper.view.getSize().width,
                             this.x, -this.x);
  else
    this.pts[0].x = this.map(m_x, 0,
                             paper.view.getSize().width / 2,
                             this.x * 2, this.x);
  if (m_y <= this.y[0])
    this.pts[0].y = this.map(m_y, 0, this.y[0], this.y[0], this.y[1]);
};

Shadow.prototype.map = function (n, start1, stop1, start2, stop2) {
  return (n - start1) / (stop1 - start1) * (stop2 - start2) + start2;
};

Shadow.prototype.draw = function() {
  // Draw Sides
  var path = new Path();
      path.fillColor = lightBlue;
      path.add(new Point(this.pts[0], this.pts[2]));
      path.add(new Point(this.pts[2], this.pts[1]));
      path.add(new Point(this.pts[1], this.pts[0]));
      path.closed = true;
};

window.onmousemove = function(event) {
  triangle.shadow.update(event.x, event.y);
}<commit_msg>make shadow rounded<commit_after>paper.install(window);
var SQRT_3 = Math.pow(3, 0.5);
var blue = '#1485E0';
var lightBlue = '#C4E1F7';
var triangle;

window.onload = function() {
  paper.setup('triangle-with-a-shadow');
  triangle = new Triangle(calcA());
  paper.view.draw();

  paper.view.onFrame = function (event) {
    project.clear();
    triangle.draw();
  };
};

window.onresize = function() {
  project.clear();
  triangle.resize(calcA());
};

var calcA = function() {
  return Math.max(250, Math.min(paper.view.size.width, paper.view.size.height) - 400);
};

// ---------------------------------------------------
//  Triangle
// ---------------------------------------------------
var Triangle = function(a) {
  this.resize(a);
};

Triangle.prototype.resize = function(a) {
  // Offset
  var x_off = paper.view.center.x;
  var y_off = 1.25 * paper.view.center.y;
  // The points of the triangle
  this.pts = [new paper.Point(0 + x_off, -a / SQRT_3 + y_off),
              new paper.Point(-a/2 + x_off, a * 0.5 / SQRT_3 + y_off),
              new paper.Point(a/2 + x_off, a * 0.5 / SQRT_3 + y_off)];
  // Make the shadow
  this.shadow = new Shadow(this.pts);
};

Triangle.prototype.draw = function() {
  // Draw the shadow
  this.shadow.draw();
  // Draw Sides
  var path = new Path();
      path.fillColor = '#fff';
      path.strokeColor = blue;
      path.strokeWidth = 2;
      path.strokeJoin = 'round';
      path.add(new Point(this.pts[0], this.pts[2]));
      path.add(new Point(this.pts[2], this.pts[1]));
      path.add(new Point(this.pts[1], this.pts[0]));
      path.closed = true;
};

// ---------------------------------------------------
//  Triangle Shadow
// ---------------------------------------------------
var Shadow = function(_pts) {
  this.pts = [];
  for (var i = 0; i < _pts.length; i++) {
    this.pts.push(_pts[i].clone());
  };
  this.y = [this.pts[1].y, this.pts[0].y];
  this.x = this.pts[0].x;
  this.update();
};

Shadow.prototype.update = function(m_x, m_y) {
  if (!m_x || !m_y)
    return;
  if (m_x > paper.view.getSize().width / 2)
    this.pts[0].x = this.map(m_x,
                             paper.view.getSize().width / 2,
                             paper.view.getSize().width,
                             this.x, -this.x);
  else
    this.pts[0].x = this.map(m_x, 0,
                             paper.view.getSize().width / 2,
                             this.x * 2, this.x);
  if (m_y <= this.y[0])
    this.pts[0].y = this.map(m_y, 0, this.y[0], this.y[0], this.y[1]);
};

Shadow.prototype.map = function (n, start1, stop1, start2, stop2) {
  return (n - start1) / (stop1 - start1) * (stop2 - start2) + start2;
};

Shadow.prototype.draw = function() {
  // Draw Sides
  var path = new Path();
      path.fillColor = lightBlue;
      path.strokeColor = lightBlue;
      path.strokeWidth = 2;
      path.strokeJoin = 'round';
      path.add(new Point(this.pts[0], this.pts[2]));
      path.add(new Point(this.pts[2], this.pts[1]));
      path.add(new Point(this.pts[1], this.pts[0]));
      path.closed = true;
};

window.onmousemove = function(event) {
  triangle.shadow.update(event.x, event.y);
}<|endoftext|>


<commit_before>var webpack = require('webpack');
var path = require("path");
var BundleTracker = require('webpack-bundle-tracker');
const { config, babelSharedLoader } = require(path.resolve("./webpack.config.shared.js"));

const prodBabelConfig = Object.assign({}, babelSharedLoader);

prodBabelConfig.query.plugins.push(
  "transform-react-constant-elements",
  "transform-react-inline-elements"
);

const prodConfig = Object.assign({}, config);
prodConfig.module.rules = [prodBabelConfig, ...config.module.rules];

module.exports = Object.assign(prodConfig, {
  context: __dirname,
  output: {
    path: path.resolve('./static/bundles/'),
    filename: "[name]-[chunkhash].js",
    chunkFilename: "[id]-[chunkhash].js",
    crossOriginLoading: "use-credentials",
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      },
      sourceMap: true,
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'common',
      minChunks: 2,
    }),
    new BundleTracker({
      filename: './webpack-stats.json'
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    }),
    new webpack.optimize.AggressiveMergingPlugin(),
  ],
  devtool: 'source-map'
});
<commit_msg>Changed the `crossOriginLoading` option for webpack<commit_after>var webpack = require('webpack');
var path = require("path");
var BundleTracker = require('webpack-bundle-tracker');
const { config, babelSharedLoader } = require(path.resolve("./webpack.config.shared.js"));

const prodBabelConfig = Object.assign({}, babelSharedLoader);

prodBabelConfig.query.plugins.push(
  "transform-react-constant-elements",
  "transform-react-inline-elements"
);

const prodConfig = Object.assign({}, config);
prodConfig.module.rules = [prodBabelConfig, ...config.module.rules];

module.exports = Object.assign(prodConfig, {
  context: __dirname,
  output: {
    path: path.resolve('./static/bundles/'),
    filename: "[name]-[chunkhash].js",
    chunkFilename: "[id]-[chunkhash].js",
    crossOriginLoading: "anonymous",
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      },
      sourceMap: true,
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'common',
      minChunks: 2,
    }),
    new BundleTracker({
      filename: './webpack-stats.json'
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    }),
    new webpack.optimize.AggressiveMergingPlugin(),
  ],
  devtool: 'source-map'
});
<|endoftext|>


<commit_before>const webpack = require('webpack');
const { join } = require('path');
const include = join(__dirname, 'src');

const COMPONENTS = `${__dirname}/src/components`;

const DEFAULT_RULES = [
  {
    test: /\.js$/,
    loader: 'babel-loader',
    include,
    exclude: /node_modules/
  }
];

module.exports = [
  {
    entry: {
      checkbox: `${COMPONENTS}/checkbox`,
      editor: `${COMPONENTS}/editor`,
      layout: `${COMPONENTS}/layout`
    },
    output: {
      path: join(__dirname, 'dist', 'js'),
      filename: '[name].js'
    },
    devtool: 'source-map',
    module: {
      rules: DEFAULT_RULES
    }
  },

  {
    entry: {
      formed: `${__dirname}/src/formed`
    },
    output: {
      path:  join(__dirname, 'dist', 'js'),
      filename: '[name].min.js',
      library: '[name]',
      libraryTarget: 'umd'
    },
    devtool: 'source-map',
    module: {
      rules: DEFAULT_RULES
    },
    plugins: [
      // Minification of code.
      new webpack.optimize.UglifyJsPlugin({
        sourceMap: true,
        compress: {
          screw_ie8: true,
          drop_console: false
        },
        mangle: {
          screw_ie8: true
        },
        output: {
          comments: false,
          screw_ie8: true
        }
      }),
      new webpack.optimize.AggressiveMergingPlugin({
        minSizeReduce: 1.5,
        moveToParents: true
      })
    ]
  }
];
<commit_msg>chore(build): webpack<commit_after>const webpack = require('webpack');
const { join } = require('path');
const include = join(__dirname, 'src');

const COMPONENTS = `${__dirname}/src/components`;

const DEFAULT_RULES = [
  {
    test: /\.js$/,
    loader: 'babel-loader',
    include,
    exclude: /node_modules/
  }
];

module.exports = [
  {
    entry: {
      checkbox: `${COMPONENTS}/checkbox`,
      editor: `${COMPONENTS}/editor`,
      layout: `${COMPONENTS}/layout`,
      radio: `${COMPONENTS}/radio`
    },
    output: {
      path: join(__dirname, 'dist', 'js'),
      filename: '[name].js'
    },
    devtool: 'source-map',
    module: {
      rules: DEFAULT_RULES
    }
  },

  {
    entry: {
      formed: `${__dirname}/src/formed`
    },
    output: {
      path:  join(__dirname, 'dist', 'js'),
      filename: '[name].min.js',
      library: '[name]',
      libraryTarget: 'umd'
    },
    devtool: 'source-map',
    module: {
      rules: DEFAULT_RULES
    },
    plugins: [
      // Minification of code.
      new webpack.optimize.UglifyJsPlugin({
        sourceMap: true,
        compress: {
          screw_ie8: true,
          drop_console: false
        },
        mangle: {
          screw_ie8: true
        },
        output: {
          comments: false,
          screw_ie8: true
        }
      }),
      new webpack.optimize.AggressiveMergingPlugin({
        minSizeReduce: 1.5,
        moveToParents: true
      })
    ]
  }
];
<|endoftext|>


<commit_before>var webpack = require('webpack');
var path    = require('path');
var config  = require('./webpack.config');

config.output = {
  filename: '[name].bundle.js',
  publicPath: '',
  path: path.resolve(__dirname, 'dist')
};

config.plugins = config.plugins.concat([

  // Reduces bundles total size
  new webpack.optimize.UglifyJsPlugin({
    mangle: {

      // You can specify all variables that should not be mangled.
      // For example if your vendor dependency doesn't use modules
      // and relies on global variables. Most of angular modules relies on
      // angular global variable, so we should keep it unchanged
      except: ['$super', '$', 'exports', 'require', 'angular']
    }
  })
]);

module.exports = config;
<commit_msg>Fix publicPath in prod webpack config<commit_after>var webpack = require('webpack');
var path    = require('path');
var config  = require('./webpack.config');

config.output = {
  filename: '[name].bundle.js',
  publicPath: '/word-game',
  path: path.resolve(__dirname, 'dist')
};

config.plugins = config.plugins.concat([

  // Reduces bundles total size
  new webpack.optimize.UglifyJsPlugin({
    mangle: {

      // You can specify all variables that should not be mangled.
      // For example if your vendor dependency doesn't use modules
      // and relies on global variables. Most of angular modules relies on
      // angular global variable, so we should keep it unchanged
      except: ['$super', '$', 'exports', 'require', 'angular']
    }
  })
]);

module.exports = config;
<|endoftext|>


<commit_before>const webpack = require("webpack");
const config = require("./webpack.base.config");
const ExtractTextPlugin = require("extract-text-webpack-plugin");

config.output.filename = "[name].[chunkhash:8].js";
config.output.chunkFilename = "[id].[chunkhash:8].chunk.js";

config.module.rules.push(
    {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract({
            loader: "css-loader?minimize",
            fallbackLoader: "style-loader"
        }),
        include: /node_modules/
    },
    {
        test: /\.less$/,
        loader: ExtractTextPlugin.extract({
            loader: ["css-loader?minimize", "less-loader"],
            fallbackLoader: "style-loader"
        }),
        include: /node_modules/
    },
    {
        test: /\.less$/,
        loader: ExtractTextPlugin.extract({
            loader: [
                "css-loader?modules&minimize&localIdentName=[hash:base64:8]",
                "less-loader"
            ],
            fallbackLoader: "style-loader"
        }),
        exclude: /node_modules/
    }
);

config.plugins.push(
    new ExtractTextPlugin({
        filename: "res/[name].[contenthash:8].css",
        allChunks: true
    }),
    new webpack.DefinePlugin({
        "process.env":
        {
            NODE_ENV: JSON.stringify("production")
        }
    }),
    new webpack.optimize.UglifyJsPlugin({
        compress:
        {
            warnings: false
        }
    })
);

module.exports = config;
<commit_msg>add LoaderOptionsPlugin<commit_after>const webpack = require("webpack");
const config = require("./webpack.base.config");
const ExtractTextPlugin = require("extract-text-webpack-plugin");

config.output.filename = "[name].[chunkhash:8].js";
config.output.chunkFilename = "[id].[chunkhash:8].chunk.js";

config.module.rules.push(
    {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract({
            loader: "css-loader?minimize",
            fallbackLoader: "style-loader"
        }),
        include: /node_modules/
    },
    {
        test: /\.less$/,
        loader: ExtractTextPlugin.extract({
            loader: ["css-loader?minimize", "less-loader"],
            fallbackLoader: "style-loader"
        }),
        include: /node_modules/
    },
    {
        test: /\.less$/,
        loader: ExtractTextPlugin.extract({
            loader: [
                "css-loader?modules&minimize&localIdentName=[hash:base64:8]",
                "less-loader"
            ],
            fallbackLoader: "style-loader"
        }),
        exclude: /node_modules/
    }
);

config.plugins.push(
    new webpack.LoaderOptionsPlugin({
        minimize: true
    }),
    new ExtractTextPlugin({
        filename: "res/[name].[contenthash:8].css",
        allChunks: true
    }),
    new webpack.DefinePlugin({
        "process.env": {
            NODE_ENV: JSON.stringify("production")
        }
    }),
    new webpack.optimize.UglifyJsPlugin({
        compress: {
            warnings: false
        }
    })
);

module.exports = config;
<|endoftext|>


<commit_before>
const { resolve, join } = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

const config = {
  context: resolve(__dirname, 'src'),
  entry: {
    bundle: [
      './clientRender.js'
    ],
    'vendor/js': [
      'react',
      'react-dom',
      'redux',
      'react-redux'
    ]
  },
  output: {
    path: resolve(__dirname, 'public/static'),
    filename: '[name].js',
    publicPath: '/static/'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
          'babel-loader'
        ],
        exclude: '/node_modules/'
      },
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
          use: [
            {
              loader: 'css-loader',
              options: {
                modules: true,
                importLoaders: 1,
                localIdentName: '[name]_[local]___[hash:base64:5]'
              }
            },
            {
              loader: 'postcss-loader'
            }
          ]
        })
      }
    ]
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks: function (module) {
         // this assumes your vendor imports exist in the node_modules directory
         return module.context && module.context.indexOf('node_modules') !== -1
      }
    }),
    new ExtractTextPlugin({
      filename: '[name].css',
      disable: false,
      allChunks: true
    })
  ]
}

module.exports = config
<commit_msg>Fix: production config<commit_after>
const { resolve, join } = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

const config = {
  context: resolve(__dirname, 'src'),
  entry: {
    bundle: [
      './clientRender.js'
    ],
    'vendor/js': [
      'react',
      'react-dom',
      'redux',
      'react-redux'
    ]
  },
  output: {
    path: resolve(__dirname, 'dist/public/static'),
    filename: '[name].js',
    publicPath: '/static/'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
          'babel-loader'
        ],
        exclude: '/node_modules/'
      },
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
          use: [
            {
              loader: 'css-loader',
              options: {
                modules: true,
                importLoaders: 1,
                localIdentName: '[name]_[local]___[hash:base64:5]'
              }
            },
            {
              loader: 'postcss-loader'
            }
          ]
        })
      }
    ]
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks: function (module) {
         // this assumes your vendor imports exist in the node_modules directory
         return module.context && module.context.indexOf('node_modules') !== -1
      }
    }),
    new ExtractTextPlugin({
      filename: '[name].css',
      disable: false,
      allChunks: true
    })
  ]
}

module.exports = config
<|endoftext|>


<commit_before>const path = require('path');

module.exports = {
    mode: 'development',
    output: {
        filename: 'index.js',
        libraryTarget: 'umd',
        library: 'D3Funnel',
    },
    resolve: {
        alias: {
            'd3-funnel': path.resolve(__dirname, 'src/d3-funnel/D3Funnel'),
        },
    },
    module: {
        rules: [
            {
                test: /\.js?$/,
                exclude: /(node_modules)/,
                loader: 'babel-loader',
            },
        ],
    },
};
<commit_msg>Use preferred library.type for webpack test config<commit_after>const path = require('path');

module.exports = {
    mode: 'development',
    output: {
        filename: 'index.js',
        library: {
            name: 'D3Funnel',
            type: 'umd',
        },
    },
    resolve: {
        alias: {
            'd3-funnel': path.resolve(__dirname, 'src/d3-funnel/D3Funnel'),
        },
    },
    module: {
        rules: [
            {
                test: /\.js?$/,
                exclude: /(node_modules)/,
                loader: 'babel-loader',
            },
        ],
    },
};
<|endoftext|>


<commit_before>/*
 * This takes all bundles defined in our production webpack configuration and adds inline source maps to all of them
 * for easier debugging.
 * Any dev specific modifications to the build should be specified in here, where each bundles[i] object is a webpack
 * configuration object that needs to be edited/manipulated to add features to.
 */

var webpack = require('webpack');
var bundles = require('./webpack.config.js');

for (var i=0; i < bundles.length; i++) {
  bundles[i].devtool = '#inline-source-map';
  bundles[i].plugins = bundles[i].plugins.concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"debug"'
      }
    })
  ]);
}

module.exports = bundles;
<commit_msg>Use cheaper source maps to increase build performance.<commit_after>/*
 * This takes all bundles defined in our production webpack configuration and adds inline source maps to all of them
 * for easier debugging.
 * Any dev specific modifications to the build should be specified in here, where each bundles[i] object is a webpack
 * configuration object that needs to be edited/manipulated to add features to.
 */

var webpack = require('webpack');
var bundles = require('./webpack.config.js');

for (var i=0; i < bundles.length; i++) {
  bundles[i].devtool = '#cheap-module-eval-source-map';
  bundles[i].plugins = bundles[i].plugins.concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"debug"'
      }
    })
  ]);
}

module.exports = bundles;
<|endoftext|>


<commit_before>'use strict';

const mongoose = require('mongoose');
const { ServiceProvider } = require('@adonisjs/fold');

const connection = use('Src/mongo/connection');

class MongooseProvider extends ServiceProvider {
  async register() {
    this.app.singleton('Adonis/Addons/Mongoose', () => {
      connection.connect();
      return mongoose;
    });
    this.app.alias('Adonis/Addons/Mongoose', 'Mongoose');
  }
}

module.exports = MongooseProvider;
<commit_msg>fix(api): connect to MongoDB on boot<commit_after>'use strict';

const mongoose = require('mongoose');
const { ServiceProvider } = require('@adonisjs/fold');

const connection = use('Src/mongo/connection');

class MongooseProvider extends ServiceProvider {
  register() {
    this.app.singleton('Adonis/Addons/Mongoose', () => {
      return mongoose;
    });
    this.app.alias('Adonis/Addons/Mongoose', 'Mongoose');
  }
  async boot() {
    await connection.connect();
  }
}

module.exports = MongooseProvider;
<|endoftext|>


<commit_before>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react')

class Footer extends React.Component {
  docUrl(doc, language) {
    const baseUrl = this.props.config.baseUrl
    return baseUrl + 'docs/' + (language ? language + '/' : '') + doc
  }

  pageUrl(doc, language) {
    const baseUrl = this.props.config.baseUrl
    return baseUrl + (language ? language + '/' : '') + doc
  }

  render() {
    const currentYear = new Date().getFullYear()
    return (

            {this.props.config.footerIcon && (

            )}

Docs

            Getting Started
            Create a plugin
            API Reference

Community

              User Showcase

              Stack Overflow

            Gitter Chat

              Twitter

More

            Blog
            GitHub

              Star

          Copyright © {currentYear} Hemera.

    )
  }
}

module.exports = Footer
<commit_msg>[ci skip] fixed stackoverflow link<commit_after>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react')

class Footer extends React.Component {
  docUrl(doc, language) {
    const baseUrl = this.props.config.baseUrl
    return baseUrl + 'docs/' + (language ? language + '/' : '') + doc
  }

  pageUrl(doc, language) {
    const baseUrl = this.props.config.baseUrl
    return baseUrl + (language ? language + '/' : '') + doc
  }

  render() {
    const currentYear = new Date().getFullYear()
    return (

            {this.props.config.footerIcon && (

            )}

Docs

            Getting Started
            Create a plugin
            API Reference

Community

              User Showcase

              Stack Overflow

            Gitter Chat

              Twitter

More

            Blog
            GitHub

              Star

          Copyright © {currentYear} Hemera.

    )
  }
}

module.exports = Footer
<|endoftext|>