<commit_before>// Copyright 2015-2018, University of Colorado Boulder

/**
 * This is the graphical representation of a stove that can be used to heat or cool things.  The HeaterCoolerNode is
 * composed of HeaterCoolerFront and HeaterCoolerBack so that objects can be layered inside of the heater to create a
 * 3D effect.  This is a convenience node that puts the back and the front together for cases where nothing other than
 * the flame and the ice needs to come out of the bucket.
 *
 * @author Siddhartha Chinthapally (Actual Concepts) on 20-11-2014.
 * @author Jesse Greenberg
 */

define( require => {
  'use strict';

  // modules
  const HeaterCoolerBack = require( 'SCENERY_PHET/HeaterCoolerBack' );
  const HeaterCoolerFront = require( 'SCENERY_PHET/HeaterCoolerFront' );
  const Node = require( 'SCENERY/nodes/Node' );
  const sceneryPhet = require( 'SCENERY_PHET/sceneryPhet' );
  const Tandem = require( 'TANDEM/Tandem' );

  class HeaterCoolerNode extends Node {
    /**
     * Constructor for a HeaterCoolerNode.
     *
     * @param {NumberProperty} [heatCoolAmountProperty] +1 for max heating, -1 for max cooling
     * @param {Object} [options] that can be passed on to the underlying node
     * @constructor
     */
    constructor( heatCoolAmountProperty, options ) {
      super();
      Tandem.indicateUninstrumentedCode();

      options = _.extend( {
        backOptions: null,
        frontOptions: null
      }, options );

      // @public
      this.heatCoolAmountProperty = heatCoolAmountProperty;

      // Add the HeaterCoolerBack which contains the heater opening and the fire/ice images
      let heaterCoolerBack = new HeaterCoolerBack( heatCoolAmountProperty, options.backOptions );
      this.addChild( heaterCoolerBack );

      // Add the HeaterCoolerFront which contains the labels, stove body, and control slider.
      let heaterCoolerFront = new HeaterCoolerFront( heatCoolAmountProperty, options.frontOptions );
      heaterCoolerFront.leftTop = heaterCoolerBack.getHeaterFrontPosition();
      this.addChild( heaterCoolerFront );

      // @public Dispose function used for GC
      this.disposeHeaterCoolerNode = function() {
        this.heatCoolAmountProperty.dispose();
        heaterCoolerBack.dispose();
        heaterCoolerFront.dispose();
      };

      this.mutate( options );
    }

    /**
     * @public
     */
    dispose() {
      Node.prototype.dispose.call( this );
      this.disposeHeaterCoolerNode();
    }
  }

  return sceneryPhet.register( 'HeaterCoolerNode', HeaterCoolerNode );
} );

<commit_msg>Removed improper disposal of heatCoolAmountProperty. https://github.com/phetsims/scenery-phet/issues/436#issue-389905552<commit_after>// Copyright 2015-2018, University of Colorado Boulder

/**
 * This is the graphical representation of a stove that can be used to heat or cool things.  The HeaterCoolerNode is
 * composed of HeaterCoolerFront and HeaterCoolerBack so that objects can be layered inside of the heater to create a
 * 3D effect.  This is a convenience node that puts the back and the front together for cases where nothing other than
 * the flame and the ice needs to come out of the bucket.
 *
 * @author Siddhartha Chinthapally (Actual Concepts) on 20-11-2014.
 * @author Jesse Greenberg
 */

define( require => {
  'use strict';

  // modules
  const HeaterCoolerBack = require( 'SCENERY_PHET/HeaterCoolerBack' );
  const HeaterCoolerFront = require( 'SCENERY_PHET/HeaterCoolerFront' );
  const Node = require( 'SCENERY/nodes/Node' );
  const sceneryPhet = require( 'SCENERY_PHET/sceneryPhet' );
  const Tandem = require( 'TANDEM/Tandem' );

  class HeaterCoolerNode extends Node {
    /**
     * Constructor for a HeaterCoolerNode.
     *
     * @param {NumberProperty} [heatCoolAmountProperty] +1 for max heating, -1 for max cooling
     * @param {Object} [options] that can be passed on to the underlying node
     * @constructor
     */
    constructor( heatCoolAmountProperty, options ) {
      super();
      Tandem.indicateUninstrumentedCode();

      options = _.extend( {
        backOptions: null,
        frontOptions: null
      }, options );

      // @public
      this.heatCoolAmountProperty = heatCoolAmountProperty;

      // Add the HeaterCoolerBack which contains the heater opening and the fire/ice images
      let heaterCoolerBack = new HeaterCoolerBack( heatCoolAmountProperty, options.backOptions );
      this.addChild( heaterCoolerBack );

      // Add the HeaterCoolerFront which contains the labels, stove body, and control slider.
      let heaterCoolerFront = new HeaterCoolerFront( heatCoolAmountProperty, options.frontOptions );
      heaterCoolerFront.leftTop = heaterCoolerBack.getHeaterFrontPosition();
      this.addChild( heaterCoolerFront );

      // @public Dispose function used for GC
      this.disposeHeaterCoolerNode = function() {
        heaterCoolerBack.dispose();
        heaterCoolerFront.dispose();
      };

      this.mutate( options );
    }

    /**
     * @public
     */
    dispose() {
      Node.prototype.dispose.call( this );
      this.disposeHeaterCoolerNode();
    }
  }

  return sceneryPhet.register( 'HeaterCoolerNode', HeaterCoolerNode );
} );

<|endoftext|>


<commit_before>import ApplicationSerializer from 'ghost/serializers/application';

var PostSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, {
    // settings for the EmbeddedRecordsMixin.
    attrs: {
        tags: { embedded: 'always' }
    },

    normalize: function (type, hash) {
        // this is to enable us to still access the raw author_id
        // without requiring an extra get request (since it is an
        // async relationship).
        hash.author_id = hash.author;

        return this._super(type, hash);
    },

    extractSingle: function (store, primaryType, payload) {
        var root = this.keyForAttribute(primaryType.typeKey),
            pluralizedRoot = Ember.String.pluralize(primaryType.typeKey);

        // make payload { post: { title: '', tags: [obj, obj], etc. } }.
        // this allows ember-data to pull the embedded tags out again,
        // in the function `updatePayloadWithEmbeddedHasMany` of the
        // EmbeddedRecordsMixin (line: `if (!partial[attribute])`):
        // https://github.com/emberjs/data/blob/master/packages/activemodel-adapter/lib/system/embedded_records_mixin.js#L499
        payload[root] = payload[pluralizedRoot][0];
        delete payload[pluralizedRoot];

        return this._super.apply(this, arguments);
    },

    keyForAttribute: function (attr) {
        return attr;
    },

    keyForRelationship: function (relationshipName) {
        // this is a hack to prevent Ember-Data from deleting our `tags` reference.
        // ref: https://github.com/emberjs/data/issues/2051
        // @TODO: remove this once the situation becomes clearer what to do.
        if (relationshipName === 'tags') {
            return 'tag';
        }

        return relationshipName;
    },

    serializeIntoHash: function (hash, type, record, options) {
        options = options || {};

        // We have a plural root in the API
        var root = Ember.String.pluralize(type.typeKey),
            data = this.serialize(record, options);

        // Don't ever pass uuid's
        delete data.uuid;

        hash[root] = [data];
    }
});

export default PostSerializer;
<commit_msg>Don't send HTML on post save.<commit_after>import ApplicationSerializer from 'ghost/serializers/application';

var PostSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, {
    // settings for the EmbeddedRecordsMixin.
    attrs: {
        tags: { embedded: 'always' }
    },

    normalize: function (type, hash) {
        // this is to enable us to still access the raw author_id
        // without requiring an extra get request (since it is an
        // async relationship).
        hash.author_id = hash.author;

        return this._super(type, hash);
    },

    extractSingle: function (store, primaryType, payload) {
        var root = this.keyForAttribute(primaryType.typeKey),
            pluralizedRoot = Ember.String.pluralize(primaryType.typeKey);

        // make payload { post: { title: '', tags: [obj, obj], etc. } }.
        // this allows ember-data to pull the embedded tags out again,
        // in the function `updatePayloadWithEmbeddedHasMany` of the
        // EmbeddedRecordsMixin (line: `if (!partial[attribute])`):
        // https://github.com/emberjs/data/blob/master/packages/activemodel-adapter/lib/system/embedded_records_mixin.js#L499
        payload[root] = payload[pluralizedRoot][0];
        delete payload[pluralizedRoot];

        return this._super.apply(this, arguments);
    },

    keyForAttribute: function (attr) {
        return attr;
    },

    keyForRelationship: function (relationshipName) {
        // this is a hack to prevent Ember-Data from deleting our `tags` reference.
        // ref: https://github.com/emberjs/data/issues/2051
        // @TODO: remove this once the situation becomes clearer what to do.
        if (relationshipName === 'tags') {
            return 'tag';
        }

        return relationshipName;
    },

    serializeIntoHash: function (hash, type, record, options) {
        options = options || {};

        // We have a plural root in the API
        var root = Ember.String.pluralize(type.typeKey),
            data = this.serialize(record, options);

        // Don't ever pass uuid's
        delete data.uuid;
        // Don't send HTML
        delete data.html;

        hash[root] = [data];
    }
});

export default PostSerializer;
<|endoftext|>


<commit_before>// Copyright 2015-2020, University of Colorado Boulder

/**
 * A laser pointer, with optional on/off button (toggle or momentary).
 * Default orientation is pointing to the right. Origin is at right center (the edge of the output nozzle).
 *
 * @author Chris Malley (PixelZoom, Inc.)
 */

import Property from '../../axon/js/Property.js';
import Dimension2 from '../../dot/js/Dimension2.js';
import Utils from '../../dot/js/Utils.js';
import InstanceRegistry from '../../phet-core/js/documentation/InstanceRegistry.js';
import inherit from '../../phet-core/js/inherit.js';
import merge from '../../phet-core/js/merge.js';
import Node from '../../scenery/js/nodes/Node.js';
import Rectangle from '../../scenery/js/nodes/Rectangle.js';
import LinearGradient from '../../scenery/js/util/LinearGradient.js';
import RoundMomentaryButton from '../../sun/js/buttons/RoundMomentaryButton.js';
import RoundStickyToggleButton from '../../sun/js/buttons/RoundStickyToggleButton.js';
import Tandem from '../../tandem/js/Tandem.js';
import sceneryPhet from './sceneryPhet.js';
import ShadedSphereNode from './ShadedSphereNode.js';

// constants
const DEFAULT_OPTIONS = {

  // {Property.<boolean>} Set this if you want to control enabled via your own Property.
  // Otherwise use this.enabledProperty or the setter/getter for enabled.
  enabledProperty: null,

  // nozzle and body options
  bodySize: new Dimension2( 110, 78 ),
  nozzleSize: new Dimension2( 20, 60 ),
  topColor: 'rgb( 170, 170, 170 )',
  bottomColor: 'rgb( 40, 40, 40 )',
  highlightColor: 'rgb( 245, 245, 245 )',
  highlightColorStop: 0.3,  // {number} color stop for highlight, (0,1) exclusive range
  stroke: 'black',
  lineWidth: 1,
  cornerRadius: 5,

  // button options
  hasButton: true, // {boolean} other button options are ignore if this is false
  buttonType: 'toggle', // {string} 'toggle'|'momentary'
  buttonColor: 'red',
  buttonRadius: 22,
  buttonTouchAreaDilation: 15,
  buttonMouseAreaDilation: 0,
  buttonRotation: 0, // {number} use this to adjust lighting on the button
  buttonAccessibleName: '',
  buttonDescriptionContent: '',

  // When enabled, the glass shows a semi-circular blue-ish lens on the output of the laser pointer node.
  // It does not change the origin of the laser pointer node, which is at the center of the casing.  The glass is
  // sometimes used to help cue the user that it is a non-laser light source.
  // See https://github.com/phetsims/scenery-phet/issues/366
  hasGlass: false,
  glassOptions: null, // {Object|null} to be filled in with defaults below, or overriden, see DEFAULT_GLASS_OPTIONS

  // PhET-iO
  tandem: Tandem.REQUIRED
};
assert && Object.freeze( DEFAULT_OPTIONS );

// Glass options, nested as discussed in https://github.com/phetsims/tasks/issues/730
const DEFAULT_GLASS_OPTIONS = {
  mainColor: 'rgb(188,225,238)',
  highlightColor: 'white',
  shadowColor: 'white',
  stroke: 'black',
  heightProportion: 0.7, // The fraction of the nozzle height, between 0 (no height) and 1 (the nozzle height)
  proportionStickingOut: 0.5 // The amount the glass "sticks out" between 0 (not at all) and 1 (hemisphere)
};
assert && Object.freeze( DEFAULT_GLASS_OPTIONS );

/**
 * @param {Property.<boolean>} onProperty - is the laser on?
 * @param {Object} [options]
 * @constructor
 */
function LaserPointerNode( onProperty, options ) {

  options = merge( {}, DEFAULT_OPTIONS, options );

  options.glassOptions = merge( {}, DEFAULT_GLASS_OPTIONS, options.glassOptions );

  assert && assert( options.highlightColorStop > 0 && options.highlightColorStop < 1 );

  this.enabledProperty = options.enabledProperty || new Property( true ); // @public

  // validate options
  assert && assert( options.buttonType === 'toggle' || options.buttonType === 'momentary',
    'invalid buttonType: ' + options.buttonType );

  const self = this;
  const children = [];

  // the narrow part that the light will come out of
  const nozzleNode = new Rectangle( 0, 0, options.nozzleSize.width + options.cornerRadius, options.nozzleSize.height, {
    cornerRadius: options.cornerRadius,
    fill: new LinearGradient( 0, 0, 0, options.nozzleSize.height )
      .addColorStop( 0, options.topColor )
      .addColorStop( options.highlightColorStop, options.highlightColor )
      .addColorStop( 1, options.bottomColor ),
    stroke: options.stroke,
    lineWidth: options.lineWidth,
    right: 0,
    centerY: 0
  } );
  children.push( nozzleNode );

  // the main body of the laser pointer
  const bodyNode = new Rectangle( 0, 0, options.bodySize.width, options.bodySize.height, {
    cornerRadius: options.cornerRadius,
    fill: new LinearGradient( 0, 0, 0, options.bodySize.height )
      .addColorStop( 0, options.topColor )
      .addColorStop( options.highlightColorStop, options.highlightColor )
      .addColorStop( 1, options.bottomColor ),
    stroke: options.stroke,
    lineWidth: options.lineWidth,
    right: nozzleNode.left + options.cornerRadius, // overlap to hide corner radius
    centerY: nozzleNode.centerY
  } );
  children.push( bodyNode );

  // the optional button that controls whether the laser is on or off
  if ( options.hasButton ) {

    const buttonOptions = {
      radius: options.buttonRadius,
      touchAreaDilation: options.buttonTouchAreaDilation,
      mouseAreaDilation: options.buttonMouseAreaDilation,
      baseColor: options.buttonColor,
      rotation: options.buttonRotation,
      center: bodyNode.center,
      tandem: options.tandem.createTandem( 'button' ),

      // pdom
      labelContent: options.buttonAccessibleName,
      labelTagName: 'label',
      descriptionContent: options.buttonDescriptionContent
    };

    // @private
    this.button = ( options.buttonType === 'toggle' ) ?
                  new RoundStickyToggleButton( false, true, onProperty, buttonOptions ) :
                  new RoundMomentaryButton( false, true, onProperty, buttonOptions );

    children.push( this.button );
  }

  // Add the glass, if any
  if ( options.hasGlass ) {
    const glassDiameter = options.nozzleSize.height * options.glassOptions.heightProportion;
    const glassOptions = merge( {}, options.glassOptions, {

      // The origin is at the output point of the nozzle, translate accordingly
      centerX: Utils.linear( 0, 1, -glassDiameter / 2, 0, options.glassOptions.proportionStickingOut ),

      // Center vertically
      centerY: 0
    } );
    const glassNode = new ShadedSphereNode( glassDiameter, glassOptions );

    // Glass is behind everything else.
    children.unshift( glassNode );
  }

  // add any children specified by the client
  options.children = children.concat( options.children || [] );
  Node.call( this, options );

  // enables and disables the button
  const enabledObserver = function( enabled ) {
    self.button && ( self.button.enabled = enabled );
  };
  this.enabledProperty.link( enabledObserver );

  // @private called by dispose
  this.disposeLaserPointerNode = function() {
    self.button && self.button.dispose();
    self.enabledProperty.unlink( enabledObserver );
  };

  // support for binder documentation, stripped out in builds and only runs when ?binder is specified
  assert && phet.chipper.queryParameters.binder && InstanceRegistry.registerDataURL( 'scenery-phet', 'LaserPointerNode', this );
}

sceneryPhet.register( 'LaserPointerNode', LaserPointerNode );

inherit( Node, LaserPointerNode, {

  // @public
  dispose: function() {
    this.disposeLaserPointerNode();
    Node.prototype.dispose.call( this );
  },

  /**
   * Sets the enabled state.
   * @param {boolean} value
   * @public
   */
  setEnabled: function( value ) { this.enabledProperty.set( value ); },
  set enabled( value ) { this.setEnabled( value ); },

  /**
   * Gets the enabled state.
   * @returns {boolean}
   * @public
   */
  getEnabled: function() {return this.enabledProperty.get(); },
  get enabled() { return this.getEnabled(); }
}, {

  DEFAULT_OPTIONS: DEFAULT_OPTIONS
} );

export default LaserPointerNode;<commit_msg>convert LaserPointerNode to ES6, https://github.com/phetsims/tasks/issues/1044<commit_after>// Copyright 2015-2020, University of Colorado Boulder

/**
 * A laser pointer, with optional on/off button (toggle or momentary).
 * Default orientation is pointing to the right. Origin is at right center (the edge of the output nozzle).
 *
 * @author Chris Malley (PixelZoom, Inc.)
 */

import Property from '../../axon/js/Property.js';
import Dimension2 from '../../dot/js/Dimension2.js';
import Utils from '../../dot/js/Utils.js';
import InstanceRegistry from '../../phet-core/js/documentation/InstanceRegistry.js';
import merge from '../../phet-core/js/merge.js';
import Node from '../../scenery/js/nodes/Node.js';
import Rectangle from '../../scenery/js/nodes/Rectangle.js';
import LinearGradient from '../../scenery/js/util/LinearGradient.js';
import RoundMomentaryButton from '../../sun/js/buttons/RoundMomentaryButton.js';
import RoundStickyToggleButton from '../../sun/js/buttons/RoundStickyToggleButton.js';
import Tandem from '../../tandem/js/Tandem.js';
import sceneryPhet from './sceneryPhet.js';
import ShadedSphereNode from './ShadedSphereNode.js';

// constants
const DEFAULT_OPTIONS = {

  // {Property.<boolean>} Set this if you want to control enabled via your own Property.
  // Otherwise use this.enabledProperty or the setter/getter for enabled.
  enabledProperty: null,

  // nozzle and body options
  bodySize: new Dimension2( 110, 78 ),
  nozzleSize: new Dimension2( 20, 60 ),
  topColor: 'rgb( 170, 170, 170 )',
  bottomColor: 'rgb( 40, 40, 40 )',
  highlightColor: 'rgb( 245, 245, 245 )',
  highlightColorStop: 0.3,  // {number} color stop for highlight, (0,1) exclusive range
  stroke: 'black',
  lineWidth: 1,
  cornerRadius: 5,

  // button options
  hasButton: true, // {boolean} other button options are ignore if this is false
  buttonType: 'toggle', // {string} 'toggle'|'momentary'
  buttonColor: 'red',
  buttonRadius: 22,
  buttonTouchAreaDilation: 15,
  buttonMouseAreaDilation: 0,
  buttonRotation: 0, // {number} use this to adjust lighting on the button
  buttonAccessibleName: '',
  buttonDescriptionContent: '',

  // When enabled, the glass shows a semi-circular blue-ish lens on the output of the laser pointer node.
  // It does not change the origin of the laser pointer node, which is at the center of the casing.  The glass is
  // sometimes used to help cue the user that it is a non-laser light source.
  // See https://github.com/phetsims/scenery-phet/issues/366
  hasGlass: false,
  glassOptions: null, // {Object|null} to be filled in with defaults below, or overriden, see DEFAULT_GLASS_OPTIONS

  // PhET-iO
  tandem: Tandem.REQUIRED
};
assert && Object.freeze( DEFAULT_OPTIONS );

// Glass options, nested as discussed in https://github.com/phetsims/tasks/issues/730
const DEFAULT_GLASS_OPTIONS = {
  mainColor: 'rgb(188,225,238)',
  highlightColor: 'white',
  shadowColor: 'white',
  stroke: 'black',
  heightProportion: 0.7, // The fraction of the nozzle height, between 0 (no height) and 1 (the nozzle height)
  proportionStickingOut: 0.5 // The amount the glass "sticks out" between 0 (not at all) and 1 (hemisphere)
};
assert && Object.freeze( DEFAULT_GLASS_OPTIONS );

class LaserPointerNode extends Node {

  /**
   * @param {Property.<boolean>} onProperty - is the laser on?
   * @param {Object} [options]
   */
  constructor( onProperty, options ) {

    options = merge( {}, DEFAULT_OPTIONS, options );

    options.glassOptions = merge( {}, DEFAULT_GLASS_OPTIONS, options.glassOptions );

    assert && assert( options.highlightColorStop > 0 && options.highlightColorStop < 1 );

    // validate options
    assert && assert( options.buttonType === 'toggle' || options.buttonType === 'momentary',
      'invalid buttonType: ' + options.buttonType );

    const children = [];

    // the narrow part that the light will come out of
    const nozzleNode = new Rectangle( 0, 0, options.nozzleSize.width + options.cornerRadius, options.nozzleSize.height, {
      cornerRadius: options.cornerRadius,
      fill: new LinearGradient( 0, 0, 0, options.nozzleSize.height )
        .addColorStop( 0, options.topColor )
        .addColorStop( options.highlightColorStop, options.highlightColor )
        .addColorStop( 1, options.bottomColor ),
      stroke: options.stroke,
      lineWidth: options.lineWidth,
      right: 0,
      centerY: 0
    } );
    children.push( nozzleNode );

    // the main body of the laser pointer
    const bodyNode = new Rectangle( 0, 0, options.bodySize.width, options.bodySize.height, {
      cornerRadius: options.cornerRadius,
      fill: new LinearGradient( 0, 0, 0, options.bodySize.height )
        .addColorStop( 0, options.topColor )
        .addColorStop( options.highlightColorStop, options.highlightColor )
        .addColorStop( 1, options.bottomColor ),
      stroke: options.stroke,
      lineWidth: options.lineWidth,
      right: nozzleNode.left + options.cornerRadius, // overlap to hide corner radius
      centerY: nozzleNode.centerY
    } );
    children.push( bodyNode );

    // the optional button that controls whether the laser is on or off
    let onOffButton = null;
    if ( options.hasButton ) {

      const buttonOptions = {
        radius: options.buttonRadius,
        touchAreaDilation: options.buttonTouchAreaDilation,
        mouseAreaDilation: options.buttonMouseAreaDilation,
        baseColor: options.buttonColor,
        rotation: options.buttonRotation,
        center: bodyNode.center,
        tandem: options.tandem.createTandem( 'button' ),

        // pdom
        labelContent: options.buttonAccessibleName,
        labelTagName: 'label',
        descriptionContent: options.buttonDescriptionContent
      };

      onOffButton = ( options.buttonType === 'toggle' ) ?
                    new RoundStickyToggleButton( false, true, onProperty, buttonOptions ) :
                    new RoundMomentaryButton( false, true, onProperty, buttonOptions );

      children.push( onOffButton );
    }

    // Add the glass, if any
    if ( options.hasGlass ) {
      const glassDiameter = options.nozzleSize.height * options.glassOptions.heightProportion;
      const glassOptions = merge( {}, options.glassOptions, {

        // The origin is at the output point of the nozzle, translate accordingly
        centerX: Utils.linear( 0, 1, -glassDiameter / 2, 0, options.glassOptions.proportionStickingOut ),

        // Center vertically
        centerY: 0
      } );
      const glassNode = new ShadedSphereNode( glassDiameter, glassOptions );

      // Glass is behind everything else.
      children.unshift( glassNode );
    }

    // add any children specified by the client
    options.children = children.concat( options.children || [] );

    super( options );

    // @public
    this.enabledProperty = options.enabledProperty || new Property( true );

    // enables and disables the button
    const enabledObserver = enabled => {
      this.button && ( this.button.enabled = enabled );
    };
    this.enabledProperty.link( enabledObserver );

    // @private called by dispose
    this.disposeLaserPointerNode = () => {
      onOffButton && onOffButton.dispose();
      this.enabledProperty.unlink( enabledObserver );
    };

    // support for binder documentation, stripped out in builds and only runs when ?binder is specified
    assert && phet.chipper.queryParameters.binder && InstanceRegistry.registerDataURL( 'scenery-phet', 'LaserPointerNode', this );
  }

  get enabled() { return this.getEnabled(); }

  set enabled( value ) { this.setEnabled( value ); }

  /**
   * @public
   * @override
   */
  dispose() {
    this.disposeLaserPointerNode();
    super.dispose();
  }

  /**
   * Sets the enabled state.
   * @param {boolean} enabled
   * @public
   */
  setEnabled( enabled ) { this.enabledProperty.set( enabled ); }

  /**
   * Gets the enabled state.
   * @returns {boolean}
   * @public
   */
  getEnabled() { return this.enabledProperty.get(); }
}

LaserPointerNode.DEFAULT_OPTIONS = DEFAULT_OPTIONS;

sceneryPhet.register( 'LaserPointerNode', LaserPointerNode );
export default LaserPointerNode;<|endoftext|>


<commit_before>angular.module('TeaCommerce').controller('DiscountCodeRuleController', function ($scope, $http) {
  $scope.editMode = false;

  $scope.resetManual = function () {
    $scope.manualSettings = { codes: '', maxUses: 1 };
  };

  $scope.resetGenerate = function () {
    $scope.generateSettings = { numberToGenerate: 1000, maxUses: 1, length: 6, prefix: '', postfix: '' };
  };

  $scope.getNumber = function (number) {
    if (number == '') {
      number = 0;
    }
    return new Array(parseInt(number));
  };

  $scope.view = 'manual';
  $http.get('/umbraco/backoffice/teacommerce/discountcodes/getcount/?storeId=' + $scope.campaign.storeId + '&ruleId=' + $scope.rule.id).success(function (data) {
    $scope.numberOfDiscountCodes = data.total;
    $scope.numberOfUnusedDiscountCodes = data.unused;
  });

  $scope.resetManual();
  $scope.resetGenerate();

  $scope.manual = function () {
    $http.post('/umbraco/backoffice/teacommerce/discountcodes/add', {
      ruleId: $scope.rule.id,
      maxUses: $scope.manualSettings.maxUses,
      codes: $scope.manualSettings.codes
    }).success(function (data) {
      $scope.numberOfDiscountCodes += data.length;
      $scope.numberOfUnusedDiscountCodes += data.length;
    });

    $scope.resetManual();
    $scope.editMode = false;
  };

  $scope.generate = function () {
    $http.post('/umbraco/backoffice/teacommerce/discountcodes/generate', {
      storeId: $scope.campaign.storeId,
      ruleId: $scope.rule.id,
      numberToGenerate: $scope.generateSettings.numberToGenerate,
      maxUses: $scope.generateSettings.maxUses,
      length: $scope.generateSettings.length,
      prefix: $scope.generateSettings.prefix,
      postfix: $scope.generateSettings.postfix
    }).success(function (data) {
      $scope.numberOfDiscountCodes += data.length;
      $scope.numberOfUnusedDiscountCodes += data.length;
    });

    $scope.resetGenerate();
    $scope.editMode = false;
  };

  $scope.download = function () {
    window.open('/umbraco/backoffice/teacommerce/discountcodes/getdownload/?storeId=' + $scope.campaign.storeId + '&campaignId=' + $scope.campaign.id + '&ruleId=' + $scope.rule.id, '_blank', '');
  };
});<commit_msg>Changed discount code generate settings. NumberToGenerate from 1000 to 1.<commit_after>angular.module('TeaCommerce').controller('DiscountCodeRuleController', function ($scope, $http) {
  $scope.editMode = false;

  $scope.resetManual = function () {
    $scope.manualSettings = { codes: '', maxUses: 1 };
  };

  $scope.resetGenerate = function () {
    $scope.generateSettings = { numberToGenerate: 1, maxUses: 1, length: 6, prefix: '', postfix: '' };
  };

  $scope.getNumber = function (number) {
    if (number == '') {
      number = 0;
    }
    return new Array(parseInt(number));
  };

  $scope.view = 'manual';
  $http.get('/umbraco/backoffice/teacommerce/discountcodes/getcount/?storeId=' + $scope.campaign.storeId + '&ruleId=' + $scope.rule.id).success(function (data) {
    $scope.numberOfDiscountCodes = data.total;
    $scope.numberOfUnusedDiscountCodes = data.unused;
  });

  $scope.resetManual();
  $scope.resetGenerate();

  $scope.manual = function () {
    $http.post('/umbraco/backoffice/teacommerce/discountcodes/add', {
      ruleId: $scope.rule.id,
      maxUses: $scope.manualSettings.maxUses,
      codes: $scope.manualSettings.codes
    }).success(function (data) {
      $scope.numberOfDiscountCodes += data.length;
      $scope.numberOfUnusedDiscountCodes += data.length;
    });

    $scope.resetManual();
    $scope.editMode = false;
  };

  $scope.generate = function () {
    $http.post('/umbraco/backoffice/teacommerce/discountcodes/generate', {
      storeId: $scope.campaign.storeId,
      ruleId: $scope.rule.id,
      numberToGenerate: $scope.generateSettings.numberToGenerate,
      maxUses: $scope.generateSettings.maxUses,
      length: $scope.generateSettings.length,
      prefix: $scope.generateSettings.prefix,
      postfix: $scope.generateSettings.postfix
    }).success(function (data) {
      $scope.numberOfDiscountCodes += data.length;
      $scope.numberOfUnusedDiscountCodes += data.length;
    });

    $scope.resetGenerate();
    $scope.editMode = false;
  };

  $scope.download = function () {
    window.open('/umbraco/backoffice/teacommerce/discountcodes/getdownload/?storeId=' + $scope.campaign.storeId + '&campaignId=' + $scope.campaign.id + '&ruleId=' + $scope.rule.id, '_blank', '');
  };
});<|endoftext|>


<commit_before>//  Copyright 2002-2014, University of Colorado Boulder

/**
 *
 *
 * @author Sam Reid (PhET Interactive Simulations)
 * @author Sharfudeen Ashraf (for Ghent University)
 */
define( function( require ) {
    'use strict';

    // modules
    var inherit = require( 'PHET_CORE/inherit' );
    var Node = require( 'SCENERY/nodes/Node' );
    var Line = require( 'SCENERY/nodes/Line' );
    var Bounds2 = require( 'DOT/Bounds2' );

    var bounds2 = new Bounds2( 0, 0, 0, 0 );

    function computeShapeBounds() {
      return bounds2;
    }

    /**
     *
     * @constructor
     */
    function XYDataSeriesNode( xyDataSeries, options ) {
      var xyDataSeriesNode = this;
      Node.call( this, options );

      var listener = function( x, y, xPrevious, yPrevious ) {
        if ( xPrevious && yPrevious && (xPrevious !== 0 || yPrevious !== 0 ) ) {
          xyDataSeriesNode.addChild( new Line( xPrevious, yPrevious, x, y, { stroke: xyDataSeries.color } ) );
        }
      };
      xyDataSeries.addDataSeriesListener( listener );

      /**
       * @public
       */
      this.dispose = function() {
        xyDataSeries.removeDataSeriesListener( listener );
      };
    }

    return inherit( Node, XYDataSeriesNode );
  }
);<commit_msg>remove extra space from copyright comment on line 1 of .js files<commit_after>// Copyright 2002-2014, University of Colorado Boulder

/**
 *
 *
 * @author Sam Reid (PhET Interactive Simulations)
 * @author Sharfudeen Ashraf (for Ghent University)
 */
define( function( require ) {
    'use strict';

    // modules
    var inherit = require( 'PHET_CORE/inherit' );
    var Node = require( 'SCENERY/nodes/Node' );
    var Line = require( 'SCENERY/nodes/Line' );
    var Bounds2 = require( 'DOT/Bounds2' );

    var bounds2 = new Bounds2( 0, 0, 0, 0 );

    function computeShapeBounds() {
      return bounds2;
    }

    /**
     *
     * @constructor
     */
    function XYDataSeriesNode( xyDataSeries, options ) {
      var xyDataSeriesNode = this;
      Node.call( this, options );

      var listener = function( x, y, xPrevious, yPrevious ) {
        if ( xPrevious && yPrevious && (xPrevious !== 0 || yPrevious !== 0 ) ) {
          xyDataSeriesNode.addChild( new Line( xPrevious, yPrevious, x, y, { stroke: xyDataSeries.color } ) );
        }
      };
      xyDataSeries.addDataSeriesListener( listener );

      /**
       * @public
       */
      this.dispose = function() {
        xyDataSeries.removeDataSeriesListener( listener );
      };
    }

    return inherit( Node, XYDataSeriesNode );
  }
);<|endoftext|>


<commit_before>'use strict';
define(
    ['three', 'app/classes/SpaceObject'],
    function(THREE, SpaceObject) {
        return class Grid extends SpaceObject {

            // ##############################################
            // # Constructor ################################
            // ##############################################

            constructor(scene, name, position, width, height, segments, camera) {
                super();

                this.scene  = scene;
                if(camera) {
                    this.camera = camera;
                }

                this.name     = name;
                this.position = position;
                this.width    = width;
                this.height   = height;
                this.segments = segments;

                if(camera) {
                    this.cameraOffset   = this.position.clone().add(this.camera.position);
                }

                this._createMesh(segments);
                this.scene.add(this.mesh);
            }

            // ##############################################
            // # Private functions ##########################
            // ##############################################

            _createMesh(segments) {
                let geometry = new THREE.Geometry();

                for(let x = -this.width / 2; x <= this.width / 2; x += this.width / segments) {
                    geometry.vertices.push(
                        new THREE.Vector3(x, -this.height / 2, 0),
                        new THREE.Vector3(x,  this.height / 2, 0)
                    );
                }

                for(let y = -this.height / 2; y <= this.height / 2; y += this.height / segments) {
                    geometry.vertices.push(
                        new THREE.Vector3(-this.width / 2, y, 0),
                        new THREE.Vector3( this.width / 2, y, 0)
                    );
                }

                let material = new THREE.LineBasicMaterial({ color:0x333333 });

                this.mesh = new THREE.LineSegments(geometry, material);
                this.mesh.position.set(this.position.x, this.position.y, this.position.z);
            }

            // ##############################################
            // # Public functions ###########################
            // ##############################################

            update(deltaT) {
                super.update(deltaT);

                if(this.camera) {
                    let roundedOffset = new THREE.Vector3(
                    );

                    let newPosition = this.camera.position
                        .clone()
                        .sub(this.cameraOffset)
                        .sub(roundedOffset);

                    this.position.set(
                        newPosition.x,
                        newPosition.y,
                        newPosition.z
                    );

                    this.mesh.position.set(this.position.x, this.position.y, this.position.z);
                }
            }

            // ##############################################

        } // class
    }
);<commit_msg>Grid moves segment-wise now<commit_after>'use strict';
define(
    ['three', 'app/classes/SpaceObject'],
    function(THREE, SpaceObject) {
        return class Grid extends SpaceObject {

            // ##############################################
            // # Constructor ################################
            // ##############################################

            constructor(scene, name, position, width, height, segments, camera) {
                super();

                this.scene  = scene;
                if(camera) {
                    this.camera = camera;
                }

                this.name     = name;
                this.position = position;
                this.width    = width;
                this.height   = height;
                this.segments = segments;

                if(camera) {
                    this.cameraOffset   = this.position.clone().add(this.camera.position);
                }

                this._createMesh(segments);
                this.scene.add(this.mesh);
            }

            // ##############################################
            // # Private functions ##########################
            // ##############################################

            _createMesh(segments) {
                let geometry = new THREE.Geometry();

                for(let x = -this.width / 2; x <= this.width / 2; x += this.width / segments) {
                    geometry.vertices.push(
                        new THREE.Vector3(x, -this.height / 2, 0),
                        new THREE.Vector3(x,  this.height / 2, 0)
                    );
                }

                for(let y = -this.height / 2; y <= this.height / 2; y += this.height / segments) {
                    geometry.vertices.push(
                        new THREE.Vector3(-this.width / 2, y, 0),
                        new THREE.Vector3( this.width / 2, y, 0)
                    );
                }

                let material = new THREE.LineBasicMaterial({ color:0x333333 });

                this.mesh = new THREE.LineSegments(geometry, material);
                this.mesh.position.set(this.position.x, this.position.y, this.position.z);
            }

            // ##############################################
            // # Public functions ###########################
            // ##############################################

            update(deltaT) {
                super.update(deltaT);

                if(this.camera) {
                    let roundedOffset = new THREE.Vector3(
                        (this.camera.position.x - this.cameraOffset.x) % (this.width  / this.segments),
                        (this.camera.position.y - this.cameraOffset.y) % (this.height / this.segments),
                        this.camera.position.z - this.cameraOffset.z
                    );

                    let newPosition = this.camera.position
                        .clone()
                        .sub(this.cameraOffset)
                        .sub(roundedOffset);

                    this.position.set(
                        newPosition.x,
                        newPosition.y,
                        newPosition.z
                    );

                    this.mesh.position.set(this.position.x, this.position.y, this.position.z);
                }
            }

            // ##############################################

        } // class
    }
);<|endoftext|>


<commit_before>cur_frm.cscript.onload = function(doc, dt, dn, callback) {
	if(has_common(user_roles, ["Administrator", "System Manager"])) {
		if(!cur_frm.roles_editor) {
			var role_area = $('
')
				.appendTo(cur_frm.fields_dict.roles_html.wrapper);
			cur_frm.roles_editor = new wn.RoleEditor(role_area);
		} else {
			cur_frm.roles_editor.show();
		}
	}
}

cur_frm.cscript.before_load = function(doc, dt, dn, callback) {
	wn.provide("wn.langauges");

	var update_language_select = function() {
		cur_frm.set_df_property("language", "options", wn.languages || ["", "English"]);
		callback();
	}

	if(!wn.languages) {
		wn.call({
			method: "core.doctype.profile.profile.get_languages",
			callback: function(r) {
				wn.languages = r.message;
				update_language_select();
			}
		})
	} else {
		update_language_select();
	}
}

cur_frm.cscript.user_image = function(doc) {
	refresh_field("user_image_show");
}

cur_frm.cscript.refresh = function(doc) {
	cur_frm.toggle_display('change_password', !doc.__islocal);

	cur_frm.toggle_display(['sb1', 'sb3'], false);

 	if(!doc.__islocal){
		cur_frm.add_custom_button("Set Properties", function() {
			wn.set_route("user-properties", doc.name);
		})

		if(has_common(user_roles, ["Administrator", "System Manager"])) {
			cur_frm.toggle_display(['sb1', 'sb3'], true);
		}
		cur_frm.cscript.enabled(doc);

		cur_frm.roles_editor && cur_frm.roles_editor.show();

		if(user==doc.name) {
			// update display settings
			if(doc.background_image) {
				wn.ui.set_user_background(doc.background_image);
			}
			if(doc.user_image) {
				wn.boot.user_info[user].image = wn.utils.get_file_link(doc.user_image);
			}
		}
	}
}

cur_frm.cscript.enabled = function(doc) {
	if(!doc.__islocal && has_common(user_roles, ["Administrator", "System Manager"])) {
		cur_frm.toggle_display(['sb1', 'sb3'], doc.enabled);
		cur_frm.toggle_enable('*', doc.enabled);
		cur_frm.set_df_property('enabled', 'read_only', 0);
	}

	if(user!="Administrator") {
		cur_frm.toggle_enable('email', doc.__islocal);
	}
}

cur_frm.cscript.validate = function(doc) {
	if(cur_frm.roles_editor) {
		cur_frm.roles_editor.set_roles_in_table()
	}
}

wn.RoleEditor = Class.extend({
	init: function(wrapper) {
		var me = this;
		this.wrapper = wrapper;
		$(wrapper).html('
Loading...
')
		return wn.call({
			method:'core.doctype.profile.profile.get_all_roles',
			callback: function(r) {
				me.roles = r.message;
				me.show_roles();

				// refresh call could've already happened
				// when all role checkboxes weren't created
				if(cur_frm.doc) {
					cur_frm.roles_editor.show();
				}
			}
		});
	},
	show_roles: function() {
		var me = this;
		$(this.wrapper).empty();
		var add_all_roles = $('
<button class="btn btn-default">Add all roles</button>
').appendTo($(this.wrapper));
		add_all_roles.find("button").on("click", function() {
			$(me.wrapper).find('input[type="checkbox"]').each(function(i, check) {
				if(!$(check).is(":checked")) {
					check.checked = true;
				}
			});
		});

		for(var i in this.roles) {
			$(this.wrapper).append(repl('
\
				<input type="checkbox" style="margin-top:0px;"> \
				%(role)s\

', {role: this.roles[i]}));
		}
		$(this.wrapper).find('input[type="checkbox"]').change(function() {
			cur_frm.dirty();
		});
		$(this.wrapper).find('.user-role a').click(function() {
			me.show_permissions($(this).parent().attr('data-user-role'))
			return false;
		});
	},
	show: function() {
		var me = this;

		// uncheck all roles
		$(this.wrapper).find('input[type="checkbox"]')
			.each(function(i, checkbox) { checkbox.checked = false; });

		// set user roles as checked
		$.each(wn.model.get("UserRole", {parent: cur_frm.doc.name,
			parentfield: "user_roles"}), function(i, user_role) {
				var checkbox = $(me.wrapper)
					.find('[data-user-role="'+user_role.role+'"] input[type="checkbox"]').get(0);
				if(checkbox) checkbox.checked = true;
			});
	},
	set_roles_in_table: function() {
		var opts = this.get_roles();
		var existing_roles_map = {};
		var existing_roles_list = [];

		$.each(wn.model.get("UserRole", {parent: cur_frm.doc.name,
			parentfield: "user_roles"}), function(i, user_role) {
				existing_roles_map[user_role.role] = user_role.name;
				existing_roles_list.push(user_role.role);
			});

		// remove unchecked roles
		$.each(opts.unchecked_roles, function(i, role) {
			if(existing_roles_list.indexOf(role)!=-1) {
				wn.model.clear_doc("UserRole", existing_roles_map[role]);
			}
		});

		// add new roles that are checked
		$.each(opts.checked_roles, function(i, role) {
			if(existing_roles_list.indexOf(role)==-1) {
				var user_role = wn.model.add_child(cur_frm.doc, "UserRole", "user_roles");
				user_role.role = role;
			}
		});

		refresh_field("user_roles");
	},
	get_roles: function() {
		var checked_roles = [];
		var unchecked_roles = [];
		$(this.wrapper).find('[data-user-role]').each(function() {
			if($(this).find('input[type="checkbox"]:checked').length) {
				checked_roles.push($(this).attr('data-user-role'));
			} else {
				unchecked_roles.push($(this).attr('data-user-role'));
			}
		});

		return {
			checked_roles: checked_roles,
			unchecked_roles: unchecked_roles
		}
	},
	show_permissions: function(role) {
		// show permissions for a role
		var me = this;
		if(!this.perm_dialog)
			this.make_perm_dialog()
		$(this.perm_dialog.body).empty();
		return wn.call({
			method:'core.doctype.profile.profile.get_perm_info',
			args: {role: role},
			callback: function(r) {
				var $body = $(me.perm_dialog.body);
				$body.append('

\
					Document Type	\
					Level	\
					Read	\
					Write	\
					Submit	\
					Cancel	\
					Amend

');
				for(var i in r.message) {
					var perm = r.message[i];

					// if permission -> icon
					for(key in perm) {
						if(key!='parent' && key!='permlevel') {
							if(perm[key]) {
								perm[key] = '';
							} else {
								perm[key] = '';
							}
						}
					}

					$body.find('tbody').append(repl('
\
						%(parent)s	\
						%(permlevel)s	\
						%(read)s	\
						%(write)s	\
						%(submit)s	\
						%(cancel)s	\
						%(amend)s	\

', perm))
				}

				me.perm_dialog.show();
			}
		});

	},
	make_perm_dialog: function() {
		this.perm_dialog = new wn.ui.Dialog({
			title:'Role Permissions',
			width: 500
		});
	}
});

<commit_msg>[minor] [profile] added button to unset all roles webnotes/erpnext#723<commit_after>cur_frm.cscript.onload = function(doc, dt, dn, callback) {
	if(has_common(user_roles, ["Administrator", "System Manager"])) {
		if(!cur_frm.roles_editor) {
			var role_area = $('
')
				.appendTo(cur_frm.fields_dict.roles_html.wrapper);
			cur_frm.roles_editor = new wn.RoleEditor(role_area);
		} else {
			cur_frm.roles_editor.show();
		}
	}
}

cur_frm.cscript.before_load = function(doc, dt, dn, callback) {
	wn.provide("wn.langauges");

	var update_language_select = function() {
		cur_frm.set_df_property("language", "options", wn.languages || ["", "English"]);
		callback();
	}

	if(!wn.languages) {
		wn.call({
			method: "core.doctype.profile.profile.get_languages",
			callback: function(r) {
				wn.languages = r.message;
				update_language_select();
			}
		})
	} else {
		update_language_select();
	}
}

cur_frm.cscript.user_image = function(doc) {
	refresh_field("user_image_show");
}

cur_frm.cscript.refresh = function(doc) {
	cur_frm.toggle_display('change_password', !doc.__islocal);

	cur_frm.toggle_display(['sb1', 'sb3'], false);

 	if(!doc.__islocal){
		cur_frm.add_custom_button("Set Properties", function() {
			wn.set_route("user-properties", doc.name);
		})

		if(has_common(user_roles, ["Administrator", "System Manager"])) {
			cur_frm.toggle_display(['sb1', 'sb3'], true);
		}
		cur_frm.cscript.enabled(doc);

		cur_frm.roles_editor && cur_frm.roles_editor.show();

		if(user==doc.name) {
			// update display settings
			if(doc.background_image) {
				wn.ui.set_user_background(doc.background_image);
			}
			if(doc.user_image) {
				wn.boot.user_info[user].image = wn.utils.get_file_link(doc.user_image);
			}
		}
	}
}

cur_frm.cscript.enabled = function(doc) {
	if(!doc.__islocal && has_common(user_roles, ["Administrator", "System Manager"])) {
		cur_frm.toggle_display(['sb1', 'sb3'], doc.enabled);
		cur_frm.toggle_enable('*', doc.enabled);
		cur_frm.set_df_property('enabled', 'read_only', 0);
	}

	if(user!="Administrator") {
		cur_frm.toggle_enable('email', doc.__islocal);
	}
}

cur_frm.cscript.validate = function(doc) {
	if(cur_frm.roles_editor) {
		cur_frm.roles_editor.set_roles_in_table()
	}
}

wn.RoleEditor = Class.extend({
	init: function(wrapper) {
		var me = this;
		this.wrapper = wrapper;
		$(wrapper).html('
Loading...
')
		return wn.call({
			method:'core.doctype.profile.profile.get_all_roles',
			callback: function(r) {
				me.roles = r.message;
				me.show_roles();

				// refresh call could've already happened
				// when all role checkboxes weren't created
				if(cur_frm.doc) {
					cur_frm.roles_editor.show();
				}
			}
		});
	},
	show_roles: function() {
		var me = this;
		$(this.wrapper).empty();
		var add_all_roles = $('
<button class="btn btn-default btn-add">Add all roles</button>\
			<button class="btn btn-default btn-remove">Clear all roles</button>
').appendTo($(this.wrapper));
		add_all_roles.find(".btn-add").on("click", function() {
			$(me.wrapper).find('input[type="checkbox"]').each(function(i, check) {
				if(!$(check).is(":checked")) {
					check.checked = true;
				}
			});
		});

		add_all_roles.find(".btn-remove").on("click", function() {
			$(me.wrapper).find('input[type="checkbox"]').each(function(i, check) {
				if($(check).is(":checked")) {
					check.checked = false;
				}
			});
		});

		for(var i in this.roles) {
			$(this.wrapper).append(repl('
\
				<input type="checkbox" style="margin-top:0px;"> \
				%(role)s\

', {role: this.roles[i]}));
		}
		$(this.wrapper).find('input[type="checkbox"]').change(function() {
			cur_frm.dirty();
		});
		$(this.wrapper).find('.user-role a').click(function() {
			me.show_permissions($(this).parent().attr('data-user-role'))
			return false;
		});
	},
	show: function() {
		var me = this;

		// uncheck all roles
		$(this.wrapper).find('input[type="checkbox"]')
			.each(function(i, checkbox) { checkbox.checked = false; });

		// set user roles as checked
		$.each(wn.model.get("UserRole", {parent: cur_frm.doc.name,
			parentfield: "user_roles"}), function(i, user_role) {
				var checkbox = $(me.wrapper)
					.find('[data-user-role="'+user_role.role+'"] input[type="checkbox"]').get(0);
				if(checkbox) checkbox.checked = true;
			});
	},
	set_roles_in_table: function() {
		var opts = this.get_roles();
		var existing_roles_map = {};
		var existing_roles_list = [];

		$.each(wn.model.get("UserRole", {parent: cur_frm.doc.name,
			parentfield: "user_roles"}), function(i, user_role) {
				existing_roles_map[user_role.role] = user_role.name;
				existing_roles_list.push(user_role.role);
			});

		// remove unchecked roles
		$.each(opts.unchecked_roles, function(i, role) {
			if(existing_roles_list.indexOf(role)!=-1) {
				wn.model.clear_doc("UserRole", existing_roles_map[role]);
			}
		});

		// add new roles that are checked
		$.each(opts.checked_roles, function(i, role) {
			if(existing_roles_list.indexOf(role)==-1) {
				var user_role = wn.model.add_child(cur_frm.doc, "UserRole", "user_roles");
				user_role.role = role;
			}
		});

		refresh_field("user_roles");
	},
	get_roles: function() {
		var checked_roles = [];
		var unchecked_roles = [];
		$(this.wrapper).find('[data-user-role]').each(function() {
			if($(this).find('input[type="checkbox"]:checked').length) {
				checked_roles.push($(this).attr('data-user-role'));
			} else {
				unchecked_roles.push($(this).attr('data-user-role'));
			}
		});

		return {
			checked_roles: checked_roles,
			unchecked_roles: unchecked_roles
		}
	},
	show_permissions: function(role) {
		// show permissions for a role
		var me = this;
		if(!this.perm_dialog)
			this.make_perm_dialog()
		$(this.perm_dialog.body).empty();
		return wn.call({
			method:'core.doctype.profile.profile.get_perm_info',
			args: {role: role},
			callback: function(r) {
				var $body = $(me.perm_dialog.body);
				$body.append('

\
					Document Type	\
					Level	\
					Read	\
					Write	\
					Submit	\
					Cancel	\
					Amend

');
				for(var i in r.message) {
					var perm = r.message[i];

					// if permission -> icon
					for(key in perm) {
						if(key!='parent' && key!='permlevel') {
							if(perm[key]) {
								perm[key] = '';
							} else {
								perm[key] = '';
							}
						}
					}

					$body.find('tbody').append(repl('
\
						%(parent)s	\
						%(permlevel)s	\
						%(read)s	\
						%(write)s	\
						%(submit)s	\
						%(cancel)s	\
						%(amend)s	\

', perm))
				}

				me.perm_dialog.show();
			}
		});

	},
	make_perm_dialog: function() {
		this.perm_dialog = new wn.ui.Dialog({
			title:'Role Permissions',
			width: 500
		});
	}
});

<|endoftext|>


<commit_before>/**
 * The main module
 *
 * @context atl.general
 */
var $ = require('speakeasy/jquery').jQuery;
var images = $.map(
        [ 'alert.jpg', 'bad_ass.jpg', 'thumb_up.jpg' ],
        function(img) {
            return require('speakeasy/resources').getImageUrl(module, img);
        });

$(document).ready(function() {
    var imageIndex = Math.floor(4 * Math.random());
    $('.welcome-message').prepend('

');

    $('#chuckImage').attr('src', images[imageIndex]);

    $('#chuckImage').load(function() {
        $.ajax({
            dataType: 'json',
            url: 'http://api.icndb.com/jokes/random',
            success: function(data) {
                if (data.type === 'success') {
                    $('#chuck-norris-facts').html(data.value.joke);
                }

            }
        });
    });

    $('#chuck').bind('click', function() {
        imageIndex = (imageIndex + 1) % images.length;
        $('#chuckImage').attr('src', images[imageIndex]);

    }).trigger('click');
});
<commit_msg>Edit from the UI<commit_after>/**
 * The main module
 *
 * @context atl.general
 */
var $ = require('speakeasy/jquery').jQuery;
var images = $.map(
        [ 'alert.jpg', 'bad_ass.jpg', 'thumb_up.jpg' ],
        function(img) {
            return require('speakeasy/resources').getImageUrl(module, img);
        });

$(document).ready(function() {
    var imageIndex = Math.floor(4 * Math.random());
    $('.welcome-message').prepend('

');

    $('#chuckImage').attr('src', images[imageIndex]);

    $('#chuckImage').load(function() {
        $.ajax({
            dataType: 'json',
            url: 'http://api.icndb.com/jokes/random',
            success: function(data) {
                if (data.type === 'success') {
                    $('#chuck-norris-facts').text(data.value.joke.replace(/"/, '"'));
                }

            }
        });
    });

    $('#chuck').bind('click', function() {
        imageIndex = (imageIndex + 1) % images.length;
        $('#chuckImage').attr('src', images[imageIndex]);

    }).trigger('click');
});
<|endoftext|>


<commit_before>var React = require('react');

var Index = React.createClass({
  render: function () {
    return (
      <main>
        Index component
      </main>
    )
  }
});

module.exports = Index;
<commit_msg>Index now uses ES6<commit_after>import React from 'react';

export default React.createClass({
  render: function () {
    return (
      <main>
        Index component
      </main>
    )
  }
});
<|endoftext|>


<commit_before>
function SendController($scope,modals,$rootScope,Wallet){
  $scope.pageClass = 'page-send';
  $scope.item = {};

  console.log('logged');
  $scope.inputAddress='';
  $scope.inputAmount='';
  var wallet1= new Wallet();
  $scope.assets = [
        {moniker: "burger" , colordef: 'acsr35gadgasf' },
        {moniker: "mcdonalds" , colordef: 'Uac9r35gadgasfXdf' }
    ];
  $scope.changeAsset= function(option){
     //change asset
    }

    //check balance
    $rootScope.$watch( 'balance', function() {
    $scope.balanceInt = $rootScope.balanceInt
    $scope.balance = $rootScope.balance
    })

    var satoshies=100000000;

    $scope.send = function(item) {
      var value=$scope.inputAmount * satoshies;
      var formData ={
      addr:$scope.inputAddress,
      amount:value
      }
      modals.password();
      console.log(formData);
      wallet1.buildTransaction(formData,function(data){
        console.log(data);
      });

      console.log( $scope.inputAddress);

     console.log('submitted');
      //$scope.$apply( function() {

    };

}
<commit_msg>send needs to make working<commit_after>
function SendController($scope,modals,$rootScope,Wallet,WalletManager){

	/****SendController init************/
	$scope.pageClass = 'page-send';
	$scope.item = {};
	$scope.inputAddress='';
	$scope.inputAmount='';
	$scope.changeAsset= function(option){

	};
	/****SendController init end************/
    //check balance
    $rootScope.$watch( 'balance', function() {
		$scope.balanceInt = $rootScope.balanceInt
		$scope.balance = $rootScope.balance
    });

    var satoshies=100000000;

    $scope.send = function(item) {
		var value=$scope.inputAmount * satoshies;
		var formData ={
		addr:$scope.inputAddress,
		amount:value
		}
		modals.password();
		console.log(formData);
		WalletManager.getCurrentWallet().buildTransaction(formData,function(data){
		console.log(data);
		});
    };
}
<|endoftext|>


<commit_before>/*   RSence
 *   Copyright 2007 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact licensing@riassence.com
 */

/*** = Description
  ** Abstracts the DOM Event differences between browsers.
***/
var//RSence.Core
Event = {

/** Returns the element of the event.
  **/
  element: function(e) {
    return e.target || e.srcElement;
  },

/** Returns the mouse cursor x -coordinate of the event.
  **/
  pointerX: function(e) {
    return e.pageX || e.clientX + document.documentElement.scrollLeft;
  },

/** Returns the mouse cursor y -coordinate of the event.
  **/
  pointerY: function(e) {
    return e.pageY || e.clientY + document.documentElement.scrollTop;
  },

/** Stops event propagation
  **/
  stop: function(e) {
    if (e.preventDefault) {
      e.preventDefault();
      e.stopPropagation();
    }
    else {
      e.returnValue = false;
      e.cancelBubble = true;
    }
  },

/** Returns true if the left mouse butten was clicked.
  **/
  isLeftClick: function(e) {
    // IE: left 1, middle 4, right 2
    if (BROWSER_TYPE.ie) {
      return (e.button === 1 || e.button === 3 || e.button === 5);
    }
    else {
      return (e.button === 0);
    }
  },

/** List of event observers
  **/
  observers: false,

  /* Implementation of observe */
  _observeAndCache: function(_elem, _name, _function, _useCapture) {
    if (!Event.observers) {
      Event.observers = [];
    }
    if (_elem.addEventListener) {
      this.observers.push([_elem, _name, _function, _useCapture]);
      _elem.addEventListener(_name, _function, _useCapture);
    }
    else if (_elem.attachEvent) {
      this.observers.push([_elem, _name, _function, _useCapture]);
      _elem.attachEvent("on" + _name, _function);
    }
  },

/** Flushes the event observer cache.
  **/
  unloadCache: function() {
    if (!Event.observers) {
      return;
    }
    var i,
        l = Event.observers.length;
    for (i = 0; i < l; i++) {
      try {
        Event.stopObserving.apply(this, Event.observers[0]);
      }
      catch(e){}
    }
    Event.observers = false;
  },

/** Starts observing the named event of the element and
  * specifies a callback function.
  **/
  observe: function(_elem, _name, _function, _useCapture) {
    _useCapture = _useCapture || false;
    Event._observeAndCache(_elem, _name, _function, _useCapture);
  },

/** Stops observing the named event of the element and
  * removes the callback function.
  **/
  stopObserving: function(_elem, _name, _function, _useCapture) {
    if (_elem === undefined) {
      console.log('Warning Event.stopObserving of event name: "' + _name + '" called with an undefined elem!');
      return;
    }
    _useCapture = _useCapture || false;
    if (_elem['removeEventListener']) {
      _elem.removeEventListener(_name, _function, _useCapture);
    }
    else if (detachEvent) {
      _elem.detachEvent("on" + _name, _function);
    }
    var i = 0;
    while (i < Event.observers.length) {
      var eo = Event.observers[i];
      if (eo && eo[0] === _elem && eo[1] === _name && eo[2] === _function && eo[3] === _useCapture) {
        Event.observers[i] = null;
        Event.observers.splice(i, 1);
      }
      else {
        i++;
      }
    }
  },

  // List of ASCII "special characters":
  KEY_BACKSPACE: 8,
  KEY_TAB: 9,
  KEY_RETURN: 13,
  KEY_ESC: 27,
  KEY_LEFT: 37,
  KEY_UP: 38,
  KEY_RIGHT: 39,
  KEY_DOWN: 40,
  KEY_DELETE: 46,
  KEY_HOME: 36,
  KEY_END: 35,
  KEY_PAGEUP: 33,
  KEY_PAGEDOWN: 34

};

// Activates the garbage collector of Internet Explorer
// when the document is unloaded:
if (BROWSER_TYPE.ie) {
  Event.observe(window, "unload", Event.unloadCache, false);
}

<commit_msg>The Event Wrapper no longer treats IE9 as an IE.<commit_after>/*   RSence
 *   Copyright 2007 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact licensing@riassence.com
 */

/*** = Description
  ** Abstracts the DOM Event differences between browsers.
***/
var//RSence.Core
Event = {

/** Returns the element of the event.
  **/
  element: function(e) {
    return e.target || e.srcElement;
  },

/** Returns the mouse cursor x -coordinate of the event.
  **/
  pointerX: function(e) {
    return e.pageX || e.clientX + document.documentElement.scrollLeft;
  },

/** Returns the mouse cursor y -coordinate of the event.
  **/
  pointerY: function(e) {
    return e.pageY || e.clientY + document.documentElement.scrollTop;
  },

/** Stops event propagation
  **/
  stop: function(e) {
    if (e.preventDefault) {
      e.preventDefault();
      e.stopPropagation();
    }
    else {
      e.returnValue = false;
      e.cancelBubble = true;
    }
  },

/** Returns true if the left mouse butten was clicked.
  **/
  isLeftClick: function(e) {
    // IE: left 1, middle 4, right 2
    if (BROWSER_TYPE.ie && !BROWSER_TYPE.ie9) {
      return (e.button === 1 || e.button === 3 || e.button === 5);
    }
    else {
      return (e.button === 0);
    }
  },

/** List of event observers
  **/
  observers: false,

  /* Implementation of observe */
  _observeAndCache: function(_elem, _name, _function, _useCapture) {
    if (!Event.observers) {
      Event.observers = [];
    }
    if (_elem.addEventListener) {
      this.observers.push([_elem, _name, _function, _useCapture]);
      _elem.addEventListener(_name, _function, _useCapture);
    }
    else if (_elem.attachEvent) {
      this.observers.push([_elem, _name, _function, _useCapture]);
      _elem.attachEvent("on" + _name, _function);
    }
  },

/** Flushes the event observer cache.
  **/
  unloadCache: function() {
    if (!Event.observers) {
      return;
    }
    var i,
        l = Event.observers.length;
    for (i = 0; i < l; i++) {
      try {
        Event.stopObserving.apply(this, Event.observers[0]);
      }
      catch(e){}
    }
    Event.observers = false;
  },

/** Starts observing the named event of the element and
  * specifies a callback function.
  **/
  observe: function(_elem, _name, _function, _useCapture) {
    _useCapture = _useCapture || false;
    Event._observeAndCache(_elem, _name, _function, _useCapture);
  },

/** Stops observing the named event of the element and
  * removes the callback function.
  **/
  stopObserving: function(_elem, _name, _function, _useCapture) {
    if (_elem === undefined) {
      console.log('Warning Event.stopObserving of event name: "' + _name + '" called with an undefined elem!');
      return;
    }
    _useCapture = _useCapture || false;
    if (_elem['removeEventListener']) {
      _elem.removeEventListener(_name, _function, _useCapture);
    }
    else if (detachEvent) {
      _elem.detachEvent("on" + _name, _function);
    }
    var i = 0;
    while (i < Event.observers.length) {
      var eo = Event.observers[i];
      if (eo && eo[0] === _elem && eo[1] === _name && eo[2] === _function && eo[3] === _useCapture) {
        Event.observers[i] = null;
        Event.observers.splice(i, 1);
      }
      else {
        i++;
      }
    }
  },

  // List of ASCII "special characters":
  KEY_BACKSPACE: 8,
  KEY_TAB: 9,
  KEY_RETURN: 13,
  KEY_ESC: 27,
  KEY_LEFT: 37,
  KEY_UP: 38,
  KEY_RIGHT: 39,
  KEY_DOWN: 40,
  KEY_DELETE: 46,
  KEY_HOME: 36,
  KEY_END: 35,
  KEY_PAGEUP: 33,
  KEY_PAGEDOWN: 34

};

// Activates the garbage collector of Internet Explorer
// when the document is unloaded:
if (BROWSER_TYPE.ie && !BROWSER_TYPE.ie9) {
  Event.observe(window, "unload", Event.unloadCache, false);
}

<|endoftext|>


<commit_before>/* global React, d3, _ */

// BASIC GRAPH
var Graph = React.createClass({
  render: function () {
    var data = [4, 8, 15, 16, 23, 42]
    var chart = d3.select(document.createElement('div'))

    chart
      .selectAll('.bar')
      .data(data)
      .enter().append('div')
      .prop({
        className: 'bar',
        key: function (d, i) {
          return i
        },
        style: function (d, i) {
          return {
            width: d * 10
          }
        }
      })
      .text(function (d) {
        return d
      })

    return chart.toReact()
  }
})

React.render(
  React.createElement(Graph),
  document.getElementById('mount-chart')
)

// PARTICLES
var width = 960
var height = 500

var circles = []
var i = 0

var Particles = React.createClass({
  propTypes: {
    circles: React.PropTypes.array
  },
  render: function () {
    var svg = d3.select(document.createElement('svg'))
      .prop('width', width)
      .prop('height', height)

    svg.selectAll('.particle').data(this.props.circles).enter()
      .append('circle')
      .prop('className', 'particle')
      .prop('key', function (d) { return d.i })
      .prop('style', function (d) {
        return {
          cx: d.x,
          cy: d.y,
          r: d.r,
          stroke: d3.hsl(d.i % 360, 1, 0.5),
          strokeOpacity: d.o
        }
      })

    svg.append('rect')
      .prop('className', 'cover')
      .prop('width', width)
      .prop('height', height)
      .prop('key', 'cover')
      .prop('onMouseMove', function () { return addParticle })

    function addParticle (e) {
      var circle = {
        x: e.nativeEvent.offsetX,
        y: e.nativeEvent.offsetY,
        i: i++,
        o: 1,
        r: 1e-6
      }

      setTimeout(function () {
        _.remove(circles, circle)
        renderParticles()
      }, 1200)

      circles.push(circle)
      renderParticles()
    }

    return svg.toReact()
  }
})

function animloop () {
  _.each(circles, function (c) {
    c.o -= 0.02
    c.r += 1.1
  })
  renderParticles()
  window.requestAnimationFrame(animloop)
}
animloop()

function renderParticles () {
  React.render(React.createElement(Particles, {
    circles: circles
  }), document.getElementById('mount-particles'))
}

renderParticles()
<commit_msg>Correct particles width<commit_after>/* global React, d3, _ */

// BASIC GRAPH
var Graph = React.createClass({
  render: function () {
    var data = [4, 8, 15, 16, 23, 42]
    var chart = d3.select(document.createElement('div'))

    chart
      .selectAll('.bar')
      .data(data)
      .enter().append('div')
      .prop({
        className: 'bar',
        key: function (d, i) {
          return i
        },
        style: function (d, i) {
          return {
            width: d * 10
          }
        }
      })
      .text(function (d) {
        return d
      })

    return chart.toReact()
  }
})

React.render(
  React.createElement(Graph),
  document.getElementById('mount-chart')
)

// PARTICLES
var width = 921
var height = 500

var circles = []
var i = 0

var Particles = React.createClass({
  propTypes: {
    circles: React.PropTypes.array
  },
  render: function () {
    var svg = d3.select(document.createElement('svg'))
      .prop('width', width)
      .prop('height', height)

    svg.selectAll('.particle').data(this.props.circles).enter()
      .append('circle')
      .prop('className', 'particle')
      .prop('key', function (d) { return d.i })
      .prop('style', function (d) {
        return {
          cx: d.x,
          cy: d.y,
          r: d.r,
          stroke: d3.hsl(d.i % 360, 1, 0.5),
          strokeOpacity: d.o
        }
      })

    svg.append('rect')
      .prop('className', 'cover')
      .prop('width', width)
      .prop('height', height)
      .prop('key', 'cover')
      .prop('onMouseMove', function () { return addParticle })

    function addParticle (e) {
      var circle = {
        x: e.nativeEvent.offsetX,
        y: e.nativeEvent.offsetY,
        i: i++,
        o: 1,
        r: 1e-6
      }

      setTimeout(function () {
        _.remove(circles, circle)
        renderParticles()
      }, 1200)

      circles.push(circle)
      renderParticles()
    }

    return svg.toReact()
  }
})

function animloop () {
  _.each(circles, function (c) {
    c.o -= 0.02
    c.r += 1.1
  })
  renderParticles()
  window.requestAnimationFrame(animloop)
}
animloop()

function renderParticles () {
  React.render(React.createElement(Particles, {
    circles: circles
  }), document.getElementById('mount-particles'))
}

renderParticles()
<|endoftext|>


<commit_before>

 var duration_longue = true;
  var  duration_courte = false;
  var  enfant = false;
   var adult = true;
   var duree = "longue";

  $(document).ready(function(){
  //on initialise les variables avec les valeurs par défaut

    var pub = "adu";
    var nbDePersonnes = 16;
    var sce = 1;
  //localStorage.numGroupe = nbDePersonnes;

  //  localStorage.duree = 'longue_adult';

  //on appuie les boutons en conséquence
    $("#dur_lon").addClass("active");
    $("#pub_adu").addClass("active");
    $("#sce_1").addClass("active");
    //$("#car").load('carousel_long.html');

    //On remplit le champ du bouton +/- avec la valeur par défaut
    $("#inputnb").val(nbDePersonnes);

   //localStorage.duree = 'longue_adult';
    //var carousel_c = $.get("carousel_court.html");
    //var carousel_l = $.get("carousel_long.html");
  //On change la valeur des variables en fonction des actions utilisateurs
   $("#inputnb").change(function(e){
     var numpers = $("#inputnb").val();
     localStorage.numGroupe = numpers;
   });

  //Pour la durée :
    $("#dur_cou").click(function(e){

  //    localStorage.duree = 'courte';

      duree = "courte";
      duration_courte = true;
      duration_longue = false;
      $("#dur_lon").removeClass("active");
      $("#dur_cou").addClass("active");
      //var code = load("carousel_court.html");
      //$("#myCarousel").replaceWith("
 This text is strong
  This text is italic
");
      //alert(carousel_c);
      //$("#car").empty();
      $("#car").load('carousel_court.html');
      $("#p1").show();
//       alert("Chargement terminé \n Guide pour atelier court !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();});

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";

    });
    $("#dur_lon").click(function(e){

    //  localStorage.duree = 'longue';

      duree = "longue";
      duration_longue = true;
      duration_courte = false;
      $("#dur_cou").removeClass("active");
      $("#dur_lon").addClass("active");
      //$("#myCarousel").replaceWith(carousel_l);
      //$("#car").empty();
      $("#car").load('carousel_long.html');
      $("#p1").show();
//       alert("Chargement terminé \n Guide pour atelier long !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();})

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
  //Pour le public :
    $("#pub_enf").click(function(e){

      localStorage.type = 'enfant';

      pub = "enf";
      adult = false;
      enfant = true;
      $("#pub_adu").removeClass("active");
      $("#pub_enf").addClass("active");

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
    $("#pub_adu").click(function(e){

      localStorage.type = 'adult';

      pub = "adu";
      adult = true;
      enfant = false;
      $("#pub_enf").removeClass("active");
      $("#pub_adu").addClass("active");

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
  //Pour le scénario :
    $("#sce_2").click(function(e){
      sce = 2;
     localStorage.dataset = "deux";
      $("#sce_1").removeClass("active");
      $("#sce_2").addClass("active");
    });
    $("#sce_1").click(function(e){
      sce = 1;
      localStorage.dataset = "un";
      $("#sce_2").removeClass("active");
      $("#sce_1").addClass("active");
    });

    $("#pointLien").click(function(e){
      if(pub == "enf"){
        $("#pointLien").attr('href','graphiques_enfants.html');
      }else{
        $("#pointLien").attr('href','graphiques_adultes.html');
      }
    });

  });

function generer() {

     var pdf = new jsPDF('p', 'pt', 'a4', false);

  //   alert(localStorage.duree);
groupe = 1;
    var logo = new Image();

    var numPErs =  (parseInt(localStorage.numGroupe));

          if(localStorage.duree == "longue_adult"){
            if(localStorage.dataset == "un"){

             alert("canvicanvi");

              var logo = new Image();
      //       for (groupe = 1; groupe < 5; groupe++) {

                 logo.src = "/pdf_images/long/Long_adults/long_adults_dataset1_1.PNG";

                 pdf.addImage(logo, 'PNG', 2, 2, 590,850);

                 groupe = groupe +1;
             pdf.addPage();
            var logo2 = new Image();
                 logo2.src = "/pdf_images/long/Long_adults/long_adults_dataset1_2.PNG";

                    pdf.addImage(logo2, 'PNG', 2, 2, 590,850);

                 groupe = groupe +1;
             pdf.addPage();

             /*var logo3 = new Image();
                 logo3.src = "/pdf_images/long/Long_adults/long_adults_dataset1_3.PNG";
                 logo3.onload = function(){
                    pdf.addImage(logo3, 'PNG', 2, 2, 590,850);
                 };
                 groupe = groupe +1;
             pdf.addPage();
             var logo4 = new Image();
                 logo4.src = "/pdf_images/long/Long_adults/long_adults_dataset1_4.PNG";
                 logo4.onload = function(){
                    pdf.addImage(logo4, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }*/
           //  }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset2_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }
          }
          else if(localStorage.duree == "longue_enfant"){
            if(localStorage.dataset == "un"){
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset1_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset2_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 }
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }

      }
      else if(localStorage.duree == "courte_enfant"){
            if(localStorage.dataset == "un"){
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset1_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 }
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset2_"+groupe+".PNG";
                logo.onload = function(){
                   pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                }
              }
            }

          }
          else {
            if(localStorage.dataset == "un"){
             for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_adults/court_adults_dataset1_"+groupe+".PNG";
                logo.onload = function(){
                  pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                 }

             }
            }else{
             for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_adults/court_adults_dataset2_"+groupe+".PNG";
                logo.onload = function(){
                   pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                 }
             }
            }
          // var uno= 1;
          }

pdf.output("dataurlnewwindow");
}
function visualiser() {

}
<commit_msg>Update dynamic_carousel.js<commit_after>

 var duration_longue = true;
  var  duration_courte = false;
  var  enfant = false;
   var adult = true;
   var duree = "longue";

  $(document).ready(function(){
  //on initialise les variables avec les valeurs par défaut

    var pub = "adu";
    var nbDePersonnes = 16;
    var sce = 1;
  //localStorage.numGroupe = nbDePersonnes;

  //  localStorage.duree = 'longue_adult';

  //on appuie les boutons en conséquence
    $("#dur_lon").addClass("active");
    $("#pub_adu").addClass("active");
    $("#sce_1").addClass("active");
    //$("#car").load('carousel_long.html');

    //On remplit le champ du bouton +/- avec la valeur par défaut
    $("#inputnb").val(nbDePersonnes);

   //localStorage.duree = 'longue_adult';
    //var carousel_c = $.get("carousel_court.html");
    //var carousel_l = $.get("carousel_long.html");
  //On change la valeur des variables en fonction des actions utilisateurs
   $("#inputnb").change(function(e){
     var numpers = $("#inputnb").val();
     localStorage.numGroupe = numpers;
   });

  //Pour la durée :
    $("#dur_cou").click(function(e){

  //    localStorage.duree = 'courte';

      duree = "courte";
      duration_courte = true;
      duration_longue = false;
      $("#dur_lon").removeClass("active");
      $("#dur_cou").addClass("active");
      //var code = load("carousel_court.html");
      //$("#myCarousel").replaceWith("
 This text is strong
  This text is italic
");
      //alert(carousel_c);
      //$("#car").empty();
      $("#car").load('carousel_court.html');
      $("#p1").show();
//       alert("Chargement terminé \n Guide pour atelier court !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();});

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";

    });
    $("#dur_lon").click(function(e){

    //  localStorage.duree = 'longue';

      duree = "longue";
      duration_longue = true;
      duration_courte = false;
      $("#dur_cou").removeClass("active");
      $("#dur_lon").addClass("active");
      //$("#myCarousel").replaceWith(carousel_l);
      //$("#car").empty();
      $("#car").load('carousel_long.html');
      $("#p1").show();
//       alert("Chargement terminé \n Guide pour atelier long !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();})

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
  //Pour le public :
    $("#pub_enf").click(function(e){

      localStorage.type = 'enfant';

      pub = "enf";
      adult = false;
      enfant = true;
      $("#pub_adu").removeClass("active");
      $("#pub_enf").addClass("active");

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
    $("#pub_adu").click(function(e){

      localStorage.type = 'adult';

      pub = "adu";
      adult = true;
      enfant = false;
      $("#pub_enf").removeClass("active");
      $("#pub_adu").addClass("active");

      if (duree == "longue" && enfant) localStorage.duree = "longue_enfant";
      else if (duree == "courte" && adult) localStorage.duree = "courte_adult";
      else if (duree == "courte" && enfant) localStorage.duree = "courte_enfant";
      else  localStorage.duree = "longue_adult";
    });
  //Pour le scénario :
    $("#sce_2").click(function(e){
      sce = 2;
     localStorage.dataset = "deux";
      $("#sce_1").removeClass("active");
      $("#sce_2").addClass("active");
    });
    $("#sce_1").click(function(e){
      sce = 1;
      localStorage.dataset = "un";
      $("#sce_2").removeClass("active");
      $("#sce_1").addClass("active");
    });

    $("#pointLien").click(function(e){
      if(pub == "enf"){
        $("#pointLien").attr('href','graphiques_enfants.html');
      }else{
        $("#pointLien").attr('href','graphiques_adultes.html');
      }
    });

  });

function generer() {

     var pdf = new jsPDF('p', 'pt', 'a4', false);

  //   alert(localStorage.duree);
groupe = 1;
    var logo = new Image();

    var numPErs =  (parseInt(localStorage.numGroupe));

          if(localStorage.duree == "longue_adult"){
            if(localStorage.dataset == "un"){

             alert("canvicanvi");

              var logo = new Image();
      //       for (groupe = 1; groupe < 5; groupe++) {

                 logo.src = "/pdf_images/long/Long_adults/long_adults_dataset1_1.PNG";

                 pdf.addImage(logo, 'PNG', 2, 2, 590,850);

                 groupe = groupe +1;
             pdf.addPage();
     /*       var logo2 = new Image();
                 logo2.src = "/pdf_images/long/Long_adults/long_adults_dataset1_2.PNG";

                    pdf.addImage(logo2, 'PNG', 2, 2, 590,850);

                 groupe = groupe +1;
             pdf.addPage();*/

             /*var logo3 = new Image();
                 logo3.src = "/pdf_images/long/Long_adults/long_adults_dataset1_3.PNG";
                 logo3.onload = function(){
                    pdf.addImage(logo3, 'PNG', 2, 2, 590,850);
                 };
                 groupe = groupe +1;
             pdf.addPage();
             var logo4 = new Image();
                 logo4.src = "/pdf_images/long/Long_adults/long_adults_dataset1_4.PNG";
                 logo4.onload = function(){
                    pdf.addImage(logo4, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }*/
           //  }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset2_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }
          }
          else if(localStorage.duree == "longue_enfant"){
            if(localStorage.dataset == "un"){
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset1_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 };
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset2_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 }
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }

      }
      else if(localStorage.duree == "courte_enfant"){
            if(localStorage.dataset == "un"){
              for (groupe = 1; groupe < 5; groupe++) {
                 var logo = new Image();
                 logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset1_"+groupe+".PNG";
                 logo.onload = function(){
                    pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                 }
                 if(groupe < numPErs){
                   pdf.addPage();
                 }
              }
            }else{
              for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset2_"+groupe+".PNG";
                logo.onload = function(){
                   pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                }
              }
            }

          }
          else {
            if(localStorage.dataset == "un"){
             for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_adults/court_adults_dataset1_"+groupe+".PNG";
                logo.onload = function(){
                  pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                 }

             }
            }else{
             for (groupe = 1; groupe < 5; groupe++) {
                var logo = new Image();
                logo.src = "https://vizkit.github.io/pdf_images/court/Court_adults/court_adults_dataset2_"+groupe+".PNG";
                logo.onload = function(){
                   pdf.addImage(logo, 'PNG', 2, 2, 590,850);
                }
                if(groupe < numPErs){
                   pdf.addPage();
                 }
             }
            }
          // var uno= 1;
          }

pdf.output("dataurlnewwindow");
}
function visualiser() {

}
<|endoftext|>


<commit_before>var duree = "longue";
var duration_longue = true;
var duration_courte = false;
var enfant = false;
var adult = true;

  $(document).ready(function(){
  //on initialise les variables avec les valeurs par défaut
    var duree = "longue";
    var pub = "adu";
    var nbDePersonnes = 16;
    var sce = 1;
  //on appuie les boutons en conséquence
    $("#dur_lon").addClass("active");
    $("#pub_adu").addClass("active");
    $("#sce_1").addClass("active");
    //$("#car").load('carousel_long.html');

    //On remplit le champ du bouton +/- avec la valeur par défaut
    $("#inputnb").val(nbDePersonnes);

    //var carousel_c = $.get("carousel_court.html");
    //var carousel_l = $.get("carousel_long.html");
  //On change la valeur des variables en fonction des actions utilisateurs
  //Pour la durée :
    $("#dur_cou").click(function(e){
      duree = "courte";
      duration_courte = true;
      duration_longue = false;
      $("#dur_lon").removeClass("active");
      $("#dur_cou").addClass("active");
      //var code = load("carousel_court.html");
      //$("#myCarousel").replaceWith("
 This text is strong
  This text is italic
");
      //alert(carousel_c);
      //$("#car").empty();
      $("#car").load('carousel_court.html');
      $("#p1").show();
      alert("Chargement terminé \n Guide pour atelier court !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();});
    });
    $("#dur_lon").click(function(e){
      duree = "longue";
      duration_longue = true;
      duration_courte =false;
      $("#dur_cou").removeClass("active");
      $("#dur_lon").addClass("active");
      //$("#myCarousel").replaceWith(carousel_l);
      //$("#car").empty();
      $("#car").load('carousel_long.html');
      $("#p1").show();
      alert("Chargement terminé \n Guide pour atelier long !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();})
    });
  //Pour le public :
    $("#pub_enf").click(function(e){
      pub = "enf";
      adult = false;
      enfant = true;
      $("#pub_adu").removeClass("active");
      $("#pub_enf").addClass("active");
    });
    $("#pub_adu").click(function(e){
      pub = "adu";
      adult = true;
      enfant = false;
      $("#pub_enf").removeClass("active");
      $("#pub_adu").addClass("active");
    });
  //Pour le scénario :
    $("#sce_2").click(function(e){
      sce = 2;
      $("#sce_1").removeClass("active");
      $("#sce_2").addClass("active");
    });
    $("#sce_1").click(function(e){
      sce = 1;
      $("#sce_2").removeClass("active");
      $("#sce_1").addClass("active");
    });

    $("#pointLien").click(function(e){
      if(pub == "enf"){
        $("#pointLien").attr('href','graphiques_enfants.html');
      }else{
        $("#pointLien").attr('href','graphiques_adultes.html');
      }
    });

  });

function demoFromHTML() {

alert("hola");

     var pdf = new jsPDF('p', 'pt', 'a4', false);
     //var pdf = new jsPDF();
  /*var logo = new Image();
         pdf.text("hello", 30,30);
       logo.src = "1.png";
       pdf.addImage(logo, 'PNG', 2, 2, 590,850);*/

          if(duration_longue && adult){
            var logo = new Image();
            logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_1.PNG";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
            pdf.addPage();
     //       var logo = new Image();
      //      logo.src = "/pdf_images/1.png";
       //     pdf.addImage(logo, 'PNG', 2, 2, 590,850);

          }else if(duration_longue && enfant) {
            logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset1_1.PNG";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
            pdf.addPage();
            logo.src = "/pdf_images/1.png";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);

          }else if(duration_courte && enfant){
            logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset1_1.PNG";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
            pdf.addPage();
            logo.src = "/pdf_images/1.png";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);

          }else if(duration_courte && enfant){

            logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset1_1.PNG";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
            pdf.addPage();
            logo.src = "/pdf_images/1.png";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);

          }

           var uno= 1;

       /*   var paso;
        for (paso = 4; paso < 6; paso++) {
            pdf.addPage();
            var logo = new Image();
            logo.src = paso+".png";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
          // Se ejecuta 5 veces, con valores desde paso desde 0 hasta 4.

          };*/

     pdf.output("dataurlnewwindow");

        }
<commit_msg>Update dynamic_carousel.js<commit_after>var duree = "longue";
var duration_longue = true;
var duration_courte = false;
var enfant = false;
var adult = true;

  $(document).ready(function(){
  //on initialise les variables avec les valeurs par défaut
    var duree = "longue";
    var pub = "adu";
    var nbDePersonnes = 16;
    var sce = 1;
  //on appuie les boutons en conséquence
    $("#dur_lon").addClass("active");
    $("#pub_adu").addClass("active");
    $("#sce_1").addClass("active");
    //$("#car").load('carousel_long.html');

    //On remplit le champ du bouton +/- avec la valeur par défaut
    $("#inputnb").val(nbDePersonnes);

    //var carousel_c = $.get("carousel_court.html");
    //var carousel_l = $.get("carousel_long.html");
  //On change la valeur des variables en fonction des actions utilisateurs
  //Pour la durée :
    $("#dur_cou").click(function(e){
      duree = "courte";
      duration_courte = true;
      duration_longue = false;
      $("#dur_lon").removeClass("active");
      $("#dur_cou").addClass("active");
      //var code = load("carousel_court.html");
      //$("#myCarousel").replaceWith("
 This text is strong
  This text is italic
");
      //alert(carousel_c);
      //$("#car").empty();
      $("#car").load('carousel_court.html');
      $("#p1").show();
      alert("Chargement terminé \n Guide pour atelier court !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();});
    });
    $("#dur_lon").click(function(e){
      duree = "longue";
      duration_longue = true;
      duration_courte =false;
      $("#dur_cou").removeClass("active");
      $("#dur_lon").addClass("active");
      //$("#myCarousel").replaceWith(carousel_l);
      //$("#car").empty();
      $("#car").load('carousel_long.html');
      $("#p1").show();
      alert("Chargement terminé \n Guide pour atelier long !");
      $("#rest").hide();
      $("#plusbtn, #minubtn").click(function(){$("#rest").show();})
    });
  //Pour le public :
    $("#pub_enf").click(function(e){
      pub = "enf";
      adult = false;
      enfant = true;
      $("#pub_adu").removeClass("active");
      $("#pub_enf").addClass("active");
    });
    $("#pub_adu").click(function(e){
      pub = "adu";
      adult = true;
      enfant = false;
      $("#pub_enf").removeClass("active");
      $("#pub_adu").addClass("active");
    });
  //Pour le scénario :
    $("#sce_2").click(function(e){
      sce = 2;
      $("#sce_1").removeClass("active");
      $("#sce_2").addClass("active");
    });
    $("#sce_1").click(function(e){
      sce = 1;
      $("#sce_2").removeClass("active");
      $("#sce_1").addClass("active");
    });

    $("#pointLien").click(function(e){
      if(pub == "enf"){
        $("#pointLien").attr('href','graphiques_enfants.html');
      }else{
        $("#pointLien").attr('href','graphiques_adultes.html');
      }
    });

  });

function demoFromHTML() {

alert("hola");

     var pdf = new jsPDF('p', 'pt', 'a4', false);
     //var pdf = new jsPDF();
  /*var logo = new Image();
         pdf.text("hello", 30,30);
       logo.src = "1.png";
       pdf.addImage(logo, 'PNG', 2, 2, 590,850);*/

          if(duration_longue && adult){
            var logo = new Image();
            logo.src = "https://vizkit.github.io/pdf_images/long/Long_adults/long_adults_dataset1_1.PNG";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
            pdf.addPage();

          }else if(duration_longue && enfant) {
            logo.src = "https://vizkit.github.io/pdf_images/long/Long_enfants/long_enfants_dataset1_1.PNG";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
            pdf.addPage();

          }else if(duration_courte && enfant){
            logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset1_1.PNG";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
            pdf.addPage();

          }else if(duration_courte && enfant){

            logo.src = "https://vizkit.github.io/pdf_images/court/Court_enfants/court_enfants_dataset1_1.PNG";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
            pdf.addPage();

          }

           var uno= 1;

       /*   var paso;
        for (paso = 4; paso < 6; paso++) {
            pdf.addPage();
            var logo = new Image();
            logo.src = paso+".png";
            pdf.addImage(logo, 'PNG', 2, 2, 590,850);
          // Se ejecuta 5 veces, con valores desde paso desde 0 hasta 4.

          };*/

     pdf.output("dataurlnewwindow");

        }
<|endoftext|>