<commit_before>require('ember-views/views/view');

var states = {};

/**
@module ember
@submodule ember-views
*/

var get = Ember.get, set = Ember.set, meta = Ember.meta;
var forEach = Ember.EnumerableUtils.forEach;

var childViewsProperty = Ember.computed(function() {
  return get(this, '_childViews');
}).property('_childViews');

/**
  A `ContainerView` is an `Ember.View` subclass that allows for manual or
  programatic management of a view's `childViews` array that will correctly
  update the `ContainerView` instance's rendered DOM representation.

  ## Setting Initial Child Views

  The initial array of child views can be set in one of two ways. You can
  provide a `childViews` property at creation time that contains instance of
  `Ember.View`:

  ```javascript
  aContainer = Ember.ContainerView.create({
    childViews: [Ember.View.create(), Ember.View.create()]
  });
  ```

  You can also provide a list of property names whose values are instances of
  `Ember.View`:

  ```javascript
  aContainer = Ember.ContainerView.create({
    childViews: ['aView', 'bView', 'cView'],
    aView: Ember.View.create(),
    bView: Ember.View.create(),
    cView: Ember.View.create()
  });
  ```

  The two strategies can be combined:

  ```javascript
  aContainer = Ember.ContainerView.create({
    childViews: ['aView', Ember.View.create()],
    aView: Ember.View.create()
  });
  ```

  Each child view's rendering will be inserted into the container's rendered
  HTML in the same order as its position in the `childViews` property.

  ## Adding and Removing Child Views

  The views in a container's `childViews` array should be added and removed by
  manipulating the `childViews` property directly.

  To remove a view pass that view into a `removeObject` call on the container's
  `childViews` property.

  Given an empty `<body>` the following code

  ```javascript
  aContainer = Ember.ContainerView.create({
    classNames: ['the-container'],
    childViews: ['aView', 'bView'],
    aView: Ember.View.create({
      template: Ember.Handlebars.compile("A")
    }),
    bView: Ember.View.create({
      template: Ember.Handlebars.compile("B")
    })
  });

  aContainer.appendTo('body');
  ```

  Results in the HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
    <div class="ember-view">B</div>
  </div>
  ```

  Removing a view

  ```javascript
  aContainer.get('childViews');  // [aContainer.aView, aContainer.bView]
  aContainer.get('childViews').removeObject(aContainer.get('bView'));
  aContainer.get('childViews');  // [aContainer.aView]
  ```

  Will result in the following HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
  </div>
  ```

  Similarly, adding a child view is accomplished by adding `Ember.View` instances to the
  container's `childViews` property.

  Given an empty `<body>` the following code

  ```javascript
  aContainer = Ember.ContainerView.create({
    classNames: ['the-container'],
    childViews: ['aView', 'bView'],
    aView: Ember.View.create({
      template: Ember.Handlebars.compile("A")
    }),
    bView: Ember.View.create({
      template: Ember.Handlebars.compile("B")
    })
  });

  aContainer.appendTo('body');
  ```

  Results in the HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
    <div class="ember-view">B</div>
  </div>
  ```

  Adding a view

  ```javascript
  AnotherViewClass = Ember.View.extend({
    template: Ember.Handlebars.compile("Another view")
  });

  aContainer.get('childViews');  // [aContainer.aView, aContainer.bView]
  aContainer.get('childViews').pushObject(AnotherViewClass.create());
  aContainer.get('childViews');  // [aContainer.aView, aContainer.bView, <AnotherViewClass instance>]
  ```

  Will result in the following HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
    <div class="ember-view">B</div>
    <div class="ember-view">Another view</div>
  </div>
  ```

  Direct manipulation of `childViews` presence or absence in the DOM via calls
  to `remove` or `removeFromParent` or calls to a container's `removeChild` may
  not behave correctly.

  Calling `remove()` on a child view will remove the view's HTML, but it will
  remain as part of its container's `childView`s property.

  Calling `removeChild()` on the container will remove the passed view instance
  from the container's `childView`s but keep its HTML within the container's
  rendered view.

  Calling `removeFromParent()` behaves as expected but should be avoided in
  favor of direct manipulation of a container's `childViews` property.

  ```javascript
  aContainer = Ember.ContainerView.create({
    classNames: ['the-container'],
    childViews: ['aView', 'bView'],
    aView: Ember.View.create({
      template: Ember.Handlebars.compile("A")
    }),
    bView: Ember.View.create({
      template: Ember.Handlebars.compile("B")
    })
  });

  aContainer.appendTo('body');
  ```

  Results in the HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
    <div class="ember-view">B</div>
  </div>
  ```

  Calling `aContainer.get('aView').removeFromParent()` will result in the
  following HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">B</div>
  </div>
  ```

  And the `Ember.View` instance stored in `aContainer.aView` will be removed from `aContainer`'s
  `childViews` array.

  ## Templates and Layout

  A `template`, `templateName`, `defaultTemplate`, `layout`, `layoutName` or
  `defaultLayout` property on a container view will not result in the template
  or layout being rendered. The HTML contents of a `Ember.ContainerView`'s DOM
  representation will only be the rendered HTML of its child views.

  ## Binding a View to Display

  If you would like to display a single view in your ContainerView, you can set
  its `currentView` property. When the `currentView` property is set to a view
  instance, it will be added to the ContainerView's `childViews` array. If the
  `currentView` property is later changed to a different view, the new view
  will replace the old view. If `currentView` is set to `null`, the last
  `currentView` will be removed.

  This functionality is useful for cases where you want to bind the display of
  a ContainerView to a controller or state manager. For example, you can bind
  the `currentView` of a container to a controller like this:

  ```javascript
  App.appController = Ember.Object.create({
    view: Ember.View.create({
      templateName: 'person_template'
    })
  });
  ```

  ```handlebars
  {{view Ember.ContainerView currentViewBinding="App.appController.view"}}
  ```

  @class ContainerView
  @namespace Ember
  @extends Ember.View
*/

Ember.ContainerView = Ember.View.extend({
  states: states,

  init: function() {
    this._super();

    var childViews = get(this, 'childViews');
    Ember.defineProperty(this, 'childViews', childViewsProperty);

    var _childViews = this._childViews;

    forEach(childViews, function(viewName, idx) {
      var view;

      if ('string' === typeof viewName) {
        view = get(this, viewName);
        view = this.createChildView(view);
        set(this, viewName, view);
      } else {
        view = this.createChildView(viewName);
      }

      _childViews[idx] = view;
    }, this);

    var currentView = get(this, 'currentView');
    if (currentView) _childViews.push(this.createChildView(currentView));

    // Make the _childViews array observable
    Ember.A(_childViews);

    // Sets up an array observer on the child views array. This
    // observer will detect when child views are added or removed
    // and update the DOM to reflect the mutation.
    get(this, 'childViews').addArrayObserver(this, {
      willChange: 'childViewsWillChange',
      didChange: 'childViewsDidChange'
    });
  },

  /**
    @private

    Instructs each child view to render to the passed render buffer.

    @method render
    @param {Ember.RenderBuffer} buffer the buffer to render to
  */
  render: function(buffer) {
    this.forEachChildView(function(view) {
      view.renderToBuffer(buffer);
    });
  },

  instrumentName: 'render.container',

  /**
    @private

    When the container view is destroyed, tear down the child views
    array observer.

    @method willDestroy
  */
  willDestroy: function() {
    get(this, 'childViews').removeArrayObserver(this, {
      willChange: 'childViewsWillChange',
      didChange: 'childViewsDidChange'
    });

    this._super();
  },

  /**
    @private

    When a child view is removed, destroy its element so that
    it is removed from the DOM.

    The array observer that triggers this action is set up in the
    `renderToBuffer` method.

    @method childViewsWillChange
    @param {Ember.Array} views the child views array before mutation
    @param {Number} start the start position of the mutation
    @param {Number} removed the number of child views removed
  **/
  childViewsWillChange: function(views, start, removed) {
    if (removed === 0) { return; }

    var changedViews = views.slice(start, start+removed);
    this.initializeViews(changedViews, null, null);

    this.currentState.childViewsWillChange(this, views, start, removed);
  },

  /**
    @private

    When a child view is added, make sure the DOM gets updated appropriately.

    If the view has already rendered an element, we tell the child view to
    create an element and insert it into the DOM. If the enclosing container
    view has already written to a buffer, but not yet converted that buffer
    into an element, we insert the string representation of the child into the
    appropriate place in the buffer.

    @method childViewsDidChange
    @param {Ember.Array} views the array of child views afte the mutation has occurred
    @param {Number} start the start position of the mutation
    @param {Number} removed the number of child views removed
    @param {Number} the number of child views added
  */
  childViewsDidChange: function(views, start, removed, added) {
    var len = get(views, 'length');

    // No new child views were added; bail out.
    if (added === 0) return;

    var changedViews = views.slice(start, start+added);
    this.initializeViews(changedViews, this, get(this, 'templateData'));

    // Let the current state handle the changes
    this.currentState.childViewsDidChange(this, views, start, added);
  },

  initializeViews: function(views, parentView, templateData) {
    forEach(views, function(view) {
      set(view, '_parentView', parentView);

      if (!get(view, 'templateData')) {
        set(view, 'templateData', templateData);
      }
    });
  },

  currentView: null,

  _currentViewWillChange: Ember.beforeObserver(function() {
    var childViews = get(this, 'childViews'),
        currentView = get(this, 'currentView');

    if (currentView) {
      childViews.removeObject(currentView);
      currentView.destroy();
    }
  }, 'currentView'),

  _currentViewDidChange: Ember.observer(function() {
    var childViews = get(this, 'childViews'),
        currentView = get(this, 'currentView');

    if (currentView) {
      childViews.pushObject(currentView);
    }
  }, 'currentView'),

  _ensureChildrenAreInDOM: function () {
    this.currentState.ensureChildrenAreInDOM(this);
  }
});

states._default = {};
states.preRender = Ember.create(states._default);
states.destroyed = Ember.create(states._default);
states.inBuffer = Ember.create(states._default);
states.hasElement = Ember.create(states._default);
states.inDOM = Ember.create(states.hasElement);

var viewStates = Ember.View.states, viewState;

for (var stateName in viewStates) {
  if (!viewStates.hasOwnProperty(stateName)) { continue; }
  Ember.merge(states[stateName], viewStates[stateName]);
}

Ember.merge(states._default, {
  childViewsWillChange: Ember.K,
  childViewsDidChange: Ember.K,
  ensureChildrenAreInDOM: Ember.K
});

Ember.merge(states.inBuffer, {
  childViewsDidChange: function(parentView, views, start, added) {
    throw new Error('You cannot modify child views while in the inBuffer state');

    /*
    var buffer = parentView.buffer,
        startWith, prev, prevBuffer, view;

    // Determine where to begin inserting the child view(s) in the
    // render buffer.
    if (start === 0) {
      // If views were inserted at the beginning, prepend the first
      // view to the render buffer, then begin inserting any
      // additional views at the beginning.
      view = views[start];
      startWith = start + 1;
      view.renderToBuffer(buffer, 'prepend');
    } else {
      // Otherwise, just insert them at the same place as the child
      // views mutation.
      view = views[start - 1];
      startWith = start;
    }

    for (var i=startWith; i<start+added; i++) {
      prev = view;
      view = views[i];
      prevBuffer = prev.buffer;
      view.renderToBuffer(prevBuffer, 'insertAfter');
    }
    */
  }
});

Ember.merge(states.hasElement, {
  childViewsWillChange: function(view, views, start, removed) {
    for (var i=start; i<start+removed; i++) {
      views[i].remove();
    }
  },

  childViewsDidChange: function(view, views, start, added) {
    Ember.run.scheduleOnce('render', view, '_ensureChildrenAreInDOM');
  },

  ensureChildrenAreInDOM: function(view) {
    var childViews = view.get('childViews'), i, len, childView, previous, buffer;
    for (i = 0, len = childViews.length; i < len; i++) {
      childView = childViews[i];
      buffer = childView.renderToBufferIfNeeded();
      if (buffer) {
        childView.triggerRecursively('willInsertElement');
        if (previous) {
          previous.domManager.after(previous, buffer.string());
        } else {
          view.domManager.prepend(view, buffer.string());
        }
        childView.transitionTo('inDOM');
        childView.propertyDidChange('element');
        childView.triggerRecursively('didInsertElement');
      }
      previous = childView;
    }
  }
});
<commit_msg>Remove commented code<commit_after>require('ember-views/views/view');

var states = {};

/**
@module ember
@submodule ember-views
*/

var get = Ember.get, set = Ember.set, meta = Ember.meta;
var forEach = Ember.EnumerableUtils.forEach;

var childViewsProperty = Ember.computed(function() {
  return get(this, '_childViews');
}).property('_childViews');

/**
  A `ContainerView` is an `Ember.View` subclass that allows for manual or
  programatic management of a view's `childViews` array that will correctly
  update the `ContainerView` instance's rendered DOM representation.

  ## Setting Initial Child Views

  The initial array of child views can be set in one of two ways. You can
  provide a `childViews` property at creation time that contains instance of
  `Ember.View`:

  ```javascript
  aContainer = Ember.ContainerView.create({
    childViews: [Ember.View.create(), Ember.View.create()]
  });
  ```

  You can also provide a list of property names whose values are instances of
  `Ember.View`:

  ```javascript
  aContainer = Ember.ContainerView.create({
    childViews: ['aView', 'bView', 'cView'],
    aView: Ember.View.create(),
    bView: Ember.View.create(),
    cView: Ember.View.create()
  });
  ```

  The two strategies can be combined:

  ```javascript
  aContainer = Ember.ContainerView.create({
    childViews: ['aView', Ember.View.create()],
    aView: Ember.View.create()
  });
  ```

  Each child view's rendering will be inserted into the container's rendered
  HTML in the same order as its position in the `childViews` property.

  ## Adding and Removing Child Views

  The views in a container's `childViews` array should be added and removed by
  manipulating the `childViews` property directly.

  To remove a view pass that view into a `removeObject` call on the container's
  `childViews` property.

  Given an empty `<body>` the following code

  ```javascript
  aContainer = Ember.ContainerView.create({
    classNames: ['the-container'],
    childViews: ['aView', 'bView'],
    aView: Ember.View.create({
      template: Ember.Handlebars.compile("A")
    }),
    bView: Ember.View.create({
      template: Ember.Handlebars.compile("B")
    })
  });

  aContainer.appendTo('body');
  ```

  Results in the HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
    <div class="ember-view">B</div>
  </div>
  ```

  Removing a view

  ```javascript
  aContainer.get('childViews');  // [aContainer.aView, aContainer.bView]
  aContainer.get('childViews').removeObject(aContainer.get('bView'));
  aContainer.get('childViews');  // [aContainer.aView]
  ```

  Will result in the following HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
  </div>
  ```

  Similarly, adding a child view is accomplished by adding `Ember.View` instances to the
  container's `childViews` property.

  Given an empty `<body>` the following code

  ```javascript
  aContainer = Ember.ContainerView.create({
    classNames: ['the-container'],
    childViews: ['aView', 'bView'],
    aView: Ember.View.create({
      template: Ember.Handlebars.compile("A")
    }),
    bView: Ember.View.create({
      template: Ember.Handlebars.compile("B")
    })
  });

  aContainer.appendTo('body');
  ```

  Results in the HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
    <div class="ember-view">B</div>
  </div>
  ```

  Adding a view

  ```javascript
  AnotherViewClass = Ember.View.extend({
    template: Ember.Handlebars.compile("Another view")
  });

  aContainer.get('childViews');  // [aContainer.aView, aContainer.bView]
  aContainer.get('childViews').pushObject(AnotherViewClass.create());
  aContainer.get('childViews');  // [aContainer.aView, aContainer.bView, <AnotherViewClass instance>]
  ```

  Will result in the following HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
    <div class="ember-view">B</div>
    <div class="ember-view">Another view</div>
  </div>
  ```

  Direct manipulation of `childViews` presence or absence in the DOM via calls
  to `remove` or `removeFromParent` or calls to a container's `removeChild` may
  not behave correctly.

  Calling `remove()` on a child view will remove the view's HTML, but it will
  remain as part of its container's `childView`s property.

  Calling `removeChild()` on the container will remove the passed view instance
  from the container's `childView`s but keep its HTML within the container's
  rendered view.

  Calling `removeFromParent()` behaves as expected but should be avoided in
  favor of direct manipulation of a container's `childViews` property.

  ```javascript
  aContainer = Ember.ContainerView.create({
    classNames: ['the-container'],
    childViews: ['aView', 'bView'],
    aView: Ember.View.create({
      template: Ember.Handlebars.compile("A")
    }),
    bView: Ember.View.create({
      template: Ember.Handlebars.compile("B")
    })
  });

  aContainer.appendTo('body');
  ```

  Results in the HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">A</div>
    <div class="ember-view">B</div>
  </div>
  ```

  Calling `aContainer.get('aView').removeFromParent()` will result in the
  following HTML

  ```html
  <div class="ember-view the-container">
    <div class="ember-view">B</div>
  </div>
  ```

  And the `Ember.View` instance stored in `aContainer.aView` will be removed from `aContainer`'s
  `childViews` array.

  ## Templates and Layout

  A `template`, `templateName`, `defaultTemplate`, `layout`, `layoutName` or
  `defaultLayout` property on a container view will not result in the template
  or layout being rendered. The HTML contents of a `Ember.ContainerView`'s DOM
  representation will only be the rendered HTML of its child views.

  ## Binding a View to Display

  If you would like to display a single view in your ContainerView, you can set
  its `currentView` property. When the `currentView` property is set to a view
  instance, it will be added to the ContainerView's `childViews` array. If the
  `currentView` property is later changed to a different view, the new view
  will replace the old view. If `currentView` is set to `null`, the last
  `currentView` will be removed.

  This functionality is useful for cases where you want to bind the display of
  a ContainerView to a controller or state manager. For example, you can bind
  the `currentView` of a container to a controller like this:

  ```javascript
  App.appController = Ember.Object.create({
    view: Ember.View.create({
      templateName: 'person_template'
    })
  });
  ```

  ```handlebars
  {{view Ember.ContainerView currentViewBinding="App.appController.view"}}
  ```

  @class ContainerView
  @namespace Ember
  @extends Ember.View
*/

Ember.ContainerView = Ember.View.extend({
  states: states,

  init: function() {
    this._super();

    var childViews = get(this, 'childViews');
    Ember.defineProperty(this, 'childViews', childViewsProperty);

    var _childViews = this._childViews;

    forEach(childViews, function(viewName, idx) {
      var view;

      if ('string' === typeof viewName) {
        view = get(this, viewName);
        view = this.createChildView(view);
        set(this, viewName, view);
      } else {
        view = this.createChildView(viewName);
      }

      _childViews[idx] = view;
    }, this);

    var currentView = get(this, 'currentView');
    if (currentView) _childViews.push(this.createChildView(currentView));

    // Make the _childViews array observable
    Ember.A(_childViews);

    // Sets up an array observer on the child views array. This
    // observer will detect when child views are added or removed
    // and update the DOM to reflect the mutation.
    get(this, 'childViews').addArrayObserver(this, {
      willChange: 'childViewsWillChange',
      didChange: 'childViewsDidChange'
    });
  },

  /**
    @private

    Instructs each child view to render to the passed render buffer.

    @method render
    @param {Ember.RenderBuffer} buffer the buffer to render to
  */
  render: function(buffer) {
    this.forEachChildView(function(view) {
      view.renderToBuffer(buffer);
    });
  },

  instrumentName: 'render.container',

  /**
    @private

    When the container view is destroyed, tear down the child views
    array observer.

    @method willDestroy
  */
  willDestroy: function() {
    get(this, 'childViews').removeArrayObserver(this, {
      willChange: 'childViewsWillChange',
      didChange: 'childViewsDidChange'
    });

    this._super();
  },

  /**
    @private

    When a child view is removed, destroy its element so that
    it is removed from the DOM.

    The array observer that triggers this action is set up in the
    `renderToBuffer` method.

    @method childViewsWillChange
    @param {Ember.Array} views the child views array before mutation
    @param {Number} start the start position of the mutation
    @param {Number} removed the number of child views removed
  **/
  childViewsWillChange: function(views, start, removed) {
    if (removed === 0) { return; }

    var changedViews = views.slice(start, start+removed);
    this.initializeViews(changedViews, null, null);

    this.currentState.childViewsWillChange(this, views, start, removed);
  },

  /**
    @private

    When a child view is added, make sure the DOM gets updated appropriately.

    If the view has already rendered an element, we tell the child view to
    create an element and insert it into the DOM. If the enclosing container
    view has already written to a buffer, but not yet converted that buffer
    into an element, we insert the string representation of the child into the
    appropriate place in the buffer.

    @method childViewsDidChange
    @param {Ember.Array} views the array of child views afte the mutation has occurred
    @param {Number} start the start position of the mutation
    @param {Number} removed the number of child views removed
    @param {Number} the number of child views added
  */
  childViewsDidChange: function(views, start, removed, added) {
    var len = get(views, 'length');

    // No new child views were added; bail out.
    if (added === 0) return;

    var changedViews = views.slice(start, start+added);
    this.initializeViews(changedViews, this, get(this, 'templateData'));

    // Let the current state handle the changes
    this.currentState.childViewsDidChange(this, views, start, added);
  },

  initializeViews: function(views, parentView, templateData) {
    forEach(views, function(view) {
      set(view, '_parentView', parentView);

      if (!get(view, 'templateData')) {
        set(view, 'templateData', templateData);
      }
    });
  },

  currentView: null,

  _currentViewWillChange: Ember.beforeObserver(function() {
    var childViews = get(this, 'childViews'),
        currentView = get(this, 'currentView');

    if (currentView) {
      childViews.removeObject(currentView);
      currentView.destroy();
    }
  }, 'currentView'),

  _currentViewDidChange: Ember.observer(function() {
    var childViews = get(this, 'childViews'),
        currentView = get(this, 'currentView');

    if (currentView) {
      childViews.pushObject(currentView);
    }
  }, 'currentView'),

  _ensureChildrenAreInDOM: function () {
    this.currentState.ensureChildrenAreInDOM(this);
  }
});

states._default = {};
states.preRender = Ember.create(states._default);
states.destroyed = Ember.create(states._default);
states.inBuffer = Ember.create(states._default);
states.hasElement = Ember.create(states._default);
states.inDOM = Ember.create(states.hasElement);

var viewStates = Ember.View.states, viewState;

for (var stateName in viewStates) {
  if (!viewStates.hasOwnProperty(stateName)) { continue; }
  Ember.merge(states[stateName], viewStates[stateName]);
}

Ember.merge(states._default, {
  childViewsWillChange: Ember.K,
  childViewsDidChange: Ember.K,
  ensureChildrenAreInDOM: Ember.K
});

Ember.merge(states.inBuffer, {
  childViewsDidChange: function(parentView, views, start, added) {
    throw new Error('You cannot modify child views while in the inBuffer state');
  }
});

Ember.merge(states.hasElement, {
  childViewsWillChange: function(view, views, start, removed) {
    for (var i=start; i<start+removed; i++) {
      views[i].remove();
    }
  },

  childViewsDidChange: function(view, views, start, added) {
    Ember.run.scheduleOnce('render', view, '_ensureChildrenAreInDOM');
  },

  ensureChildrenAreInDOM: function(view) {
    var childViews = view.get('childViews'), i, len, childView, previous, buffer;
    for (i = 0, len = childViews.length; i < len; i++) {
      childView = childViews[i];
      buffer = childView.renderToBufferIfNeeded();
      if (buffer) {
        childView.triggerRecursively('willInsertElement');
        if (previous) {
          previous.domManager.after(previous, buffer.string());
        } else {
          view.domManager.prepend(view, buffer.string());
        }
        childView.transitionTo('inDOM');
        childView.propertyDidChange('element');
        childView.triggerRecursively('didInsertElement');
      }
      previous = childView;
    }
  }
});
<|endoftext|>


<commit_before>"use strict";
/*!
 * Module dependencies.
 */

var dummy
  , path = require('path')
  , hotplate = require('hotplate')
  , hotCoreStoreRegistry = require('hotCoreStoreRegistry')
;

hotplate.hotEvents.onCollect('pageElements', 'hotCoreStoreVars', hotplate.cachable( function( done ){

  var storesVarsData = {};
  //var storesPerCollection = {};

  hotCoreStoreRegistry.getAllStores( function( err, allStores ){

    Object.keys( allStores ).forEach( function( storeName ){
      var store = allStores[ storeName ];

      if( store.publicURL && store.hotExpose ){
        var url = path.join( hotplate.config.get( 'hotCoreStoreExposer.storesUrlsPrefix' ), store.publicURL );
        storesVarsData[ store.storeName ] = {
          target: url,
          sortParam: 'sortBy',
          alsoNotify: store.alsoNotify,
          enabledField: store.enabledField,
          defaultNewToStart: store.defaultNewToStart,
          preserveCacheOnReset: !!store.preserveCacheOnReset,
          alwaysRefreshOnChange: store.alwaysRefreshOnChange,
          type: store.type ? store.type : 'cached',
        };
        if( store.collectionName ) storesVarsData[ store.storeName ].collectionName = store.collectionName;
        if( store.nested ) storesVarsData[ store.storeName ].nested = simplify( store.nested );

        //storesPerCollection[ store.collectionName ] = storesPerCollection[ store.collectionName ] || [];
        //storesPerCollection[ store.collectionName ].push( store.storeName );
      }
    });
  });

  done( null, { vars: [
    { name: 'stores', value: storesVarsData },
    //{ name: 'storesPerCollection', value: storesPerCollection }
  ]});

}));

function simplify( storeNested ){
  var newNested = [];
  storeNested.forEach( function( n ){
    var collectionName = n.layer.table;
    newNested.push( {
      layer: collectionName,
      type: n.type,
    });
  })
  return newNested;
}
<commit_msg>Added nester information to vars<commit_after>"use strict";
/*!
 * Module dependencies.
 */

var dummy
  , path = require('path')
  , hotplate = require('hotplate')
  , hotCoreStoreRegistry = require('hotCoreStoreRegistry')
;

hotplate.hotEvents.onCollect('pageElements', 'hotCoreStoreVars', hotplate.cachable( function( done ){

  var storesVarsData = {};
  var parentStores = {};

  hotCoreStoreRegistry.getAllStores( function( err, allStores ){

    Object.keys( allStores ).forEach( function( storeName ){
      var store = allStores[ storeName ];

      if( store.publicURL && store.hotExpose ){
        var url = path.join( hotplate.config.get( 'hotCoreStoreExposer.storesUrlsPrefix' ), store.publicURL );
        storesVarsData[ store.storeName ] = {
          target: url,
          sortParam: 'sortBy',
          alsoNotify: store.alsoNotify,
          enabledField: store.enabledField,
          defaultNewToStart: store.defaultNewToStart,
          preserveCacheOnReset: !!store.preserveCacheOnReset,
          alwaysRefreshOnChange: store.alwaysRefreshOnChange,
          type: store.type ? store.type : 'cached',
        };
        if( store.collectionName ) storesVarsData[ store.storeName ].collectionName = store.collectionName;

        if( store.nested ){

          // Add the nested entry to teh vars if `nested` is defined in the store
          storesVarsData[ store.storeName ].nested = varifyNested( store.nested );

          // Adds entry to parentStores if needed
          store.nested.forEach( function( e ){

            // One-record piggyback stores don't have children by definition
            if( store.piggyField ) return;

            // Add this nested store to the parent's list
            parentStores[ e.store.storeName ] = parentStores[ e.store.storeName ] || [];
            parentStores[ e.store.storeName ].push( { storeName: store.storeName, type: e.type, localField: e.localField, join: e.join } );
          })
        }

      }
    });
  });

  done( null, { vars: [
    { name: 'stores', value: storesVarsData },
    { name: 'parentStores', value: parentStores }
  ]});

}));

function varifyNested( storeNested ){
  var newNested = [];
  storeNested.forEach( function( e ){
    newNested.push( varifyNestedEntry( e ) );
  })
  return newNested;
}

function varifyNestedEntry( entry ){
  var newEntry = {};
  newEntry.type = entry.type;
  newEntry.storeName = entry.store.storeName;
  newEntry.localField = entry.localField;
  newEntry.join = entry.join;

  //if( entry.type === 'multiple') console.log("IT IS: ", newEntry );

  return newEntry;
}
<|endoftext|>


<commit_before>/**
 * This is just an example file
 */
import uniqueId from 'lodash/uniqueId';
import kebabCase from 'lodash/kebabCase';

class PinguComponent {
  constructor($el, _defaultOptions, _defaultData) {
    this.name = this.constructor.name;
    this.options = Object.assign({}, _defaultOptions);
    this.data = Object.assign({}, _defaultData);

    this.log = window.pingu.logger(this.name);
    this.listeners = {};

    this.uuid = uniqueId(this.name);

    this.registerInWindow();
    this.registerNodes($el);
  }

  /**
   * Register the instance in window, to be global accessible
   */
  registerInWindow() {
    window.pingu.components[this.name].instances[this.uuid] = this;
  }

  /**
   * Registering all the nodes, automatic grabbed by the options
   * @param {$el} the element of the component
   */
  registerNodes($el) {
    const nodeClasses = this.options.classes.dom;

    this.nodes = {
      el: $el,
    };

    Object.keys(nodeClasses).forEach((key) => {
      if (Object.prototype.hasOwnProperty.call(nodeClasses, key)) {
        const elementQuery = this.nodes.el.querySelectorAll(nodeClasses[key]);

        if (elementQuery.length === 0) {
          this.error(`A node for ${key} was not found`);
        } else {
          this.nodes[key] = elementQuery.length === 1 ? elementQuery[0] : elementQuery;
        }
      }
    });
  }

  /**
   * Creates the proper regex and returns the match
   * @param {string} modifier
   * @param {Node} node
   * @param {boolean} isAdd (if it's adding modifier)
   */
  regexOnNode(modifier, node, isAdd) {
    const add2Regex = isAdd ? '' : `--${modifier}`;
    const regex = new RegExp(`${kebabCase(this.name)}[^\\s]*${add2Regex}`, 'g');
    const classAttribute = node.getAttribute('class');

    return classAttribute.match(regex)[0];
  }

  /**
   * Checks if the node param is a NodeList or undefined
   * @param {Node|undefined} node
   */
  checkSelectedNode(node) {
    if (typeof node === typeof NodeList) this.error('Modifiers cannot be added on a NodeList');

    return typeof node === typeof undefined ? this.nodes.el : node;
  }

  /**
   * Add modifier classes to any given node
   * @param {string} modifier
   * @param {Node|undefined} node
   */
  addModifier(modifier, node) {
    const selectedNode = this.checkSelectedNode(node);
    const regexMatch = this.regexOnNode(modifier, selectedNode, true);
    const newClassName = `${regexMatch}--${modifier}`;

    selectedNode.classList.add(newClassName);
  }

  /**
   * Removes modifier class on given node, if no node is given, then use base element
   * @param {string} modifier
   * @param {Node|undefined} node
   */
  removeModifier(modifier, node) {
    const selectedNode = this.checkSelectedNode(node);
    const regexMatch = this.regexOnNode(modifier, selectedNode, false);

    selectedNode.classList.remove(regexMatch);
  }

  /**
   * Adds and saves an event listener
   * @param {string} listenerName
   * @param {Node} node
   * @param {string} eventType
   * @param {function} handler
   * @param {object} options
   */
  addListener(listenerName, node, eventType, handler, options) {
    node.addEventListener(eventType, handler, options);

    this.listeners[listenerName] = {
      node,
      eventType,
      handler,
      options,
    };
  }

  /**
   * Removes a given event listener by name
   * @param {string} listenerName
   */
  removeEventListener(listenerName) {
    const listener = this.listeners[listenerName];

    listener.node.removeEventListener(listener.eventType, listener.handler);
  }

  /**
   *
   * @param {string} eventName
   * @param {*} eventData
   * @param {Node} node
   */
  dispatchCustomEvent(eventName, eventData, node) {
    const activeNode = typeof node === typeof undefined ? window : node;
    const event = new CustomEvent(`${this.name}.${eventName}`, eventData);

    activeNode.dispatchEvent(event);
  }

  /**
   * A display of error
   * @param {string} msg
   */
  error(msg) {
    console.error(`${this.name} |`, msg); //eslint-disable-line
  }

  /**
   * Destroys the object
   */
  destroy() {
    delete window.pingu.components[this.name].instances[this.uuid];
  }
}

export default PinguComponent;
<commit_msg>Added remove event listening to destroy<commit_after>/**
 * This is just an example file
 */
import uniqueId from 'lodash/uniqueId';
import kebabCase from 'lodash/kebabCase';

class PinguComponent {
  constructor($el, _defaultOptions, _defaultData) {
    this.name = this.constructor.name;
    this.options = Object.assign({}, _defaultOptions);
    this.data = Object.assign({}, _defaultData);

    this.log = window.pingu.logger(this.name);
    this.listeners = {};

    this.uuid = uniqueId(this.name);

    this.registerInWindow();
    this.registerNodes($el);
  }

  /**
   * Register the instance in window, to be global accessible
   */
  registerInWindow() {
    window.pingu.components[this.name].instances[this.uuid] = this;
  }

  /**
   * Registering all the nodes, automatic grabbed by the options
   * @param {$el} the element of the component
   */
  registerNodes($el) {
    const nodeClasses = this.options.classes.dom;

    this.nodes = {
      el: $el,
    };

    Object.keys(nodeClasses).forEach((key) => {
      if (Object.prototype.hasOwnProperty.call(nodeClasses, key)) {
        const elementQuery = this.nodes.el.querySelectorAll(nodeClasses[key]);

        if (elementQuery.length === 0) {
          this.error(`A node for ${key} was not found`);
        } else {
          this.nodes[key] = elementQuery.length === 1 ? elementQuery[0] : elementQuery;
        }
      }
    });
  }

  /**
   * Creates the proper regex and returns the match
   * @param {string} modifier
   * @param {Node} node
   * @param {boolean} isAdd (if it's adding modifier)
   */
  regexOnNode(modifier, node, isAdd) {
    const add2Regex = isAdd ? '' : `--${modifier}`;
    const regex = new RegExp(`${kebabCase(this.name)}[^\\s]*${add2Regex}`, 'g');
    const classAttribute = node.getAttribute('class');

    return classAttribute.match(regex)[0];
  }

  /**
   * Checks if the node param is a NodeList or undefined
   * @param {Node|undefined} node
   */
  checkSelectedNode(node) {
    if (typeof node === typeof NodeList) this.error('Modifiers cannot be added on a NodeList');

    return typeof node === typeof undefined ? this.nodes.el : node;
  }

  /**
   * Add modifier classes to any given node
   * @param {string} modifier
   * @param {Node|undefined} node
   */
  addModifier(modifier, node) {
    const selectedNode = this.checkSelectedNode(node);
    const regexMatch = this.regexOnNode(modifier, selectedNode, true);
    const newClassName = `${regexMatch}--${modifier}`;

    selectedNode.classList.add(newClassName);
  }

  /**
   * Removes modifier class on given node, if no node is given, then use base element
   * @param {string} modifier
   * @param {Node|undefined} node
   */
  removeModifier(modifier, node) {
    const selectedNode = this.checkSelectedNode(node);
    const regexMatch = this.regexOnNode(modifier, selectedNode, false);

    selectedNode.classList.remove(regexMatch);
  }

  /**
   * Adds and saves an event listener
   * @param {string} listenerName
   * @param {Node} node
   * @param {string} eventType
   * @param {function} handler
   * @param {object} options
   */
  addListener(listenerName, node, eventType, handler, options) {
    node.addEventListener(eventType, handler, options);

    this.listeners[listenerName] = {
      node,
      eventType,
      handler,
      options,
    };
  }

  /**
   * Removes a given event listener by name
   * @param {string} listenerName
   */
  removeListener(listenerName) {
    const listener = this.listeners[listenerName];

    listener.node.removeEventListener(listener.eventType, listener.handler);
  }

  /**
   *
   * @param {string} eventName
   * @param {*} eventData
   * @param {Node} node
   */
  dispatchCustomEvent(eventName, eventData, node) {
    const activeNode = typeof node === typeof undefined ? window : node;
    const event = new CustomEvent(`${this.name}.${eventName}`, eventData);

    activeNode.dispatchEvent(event);
  }

  /**
   * A display of error
   * @param {string} msg
   */
  error(msg) {
    console.error(`${this.name} |`, msg); //eslint-disable-line
  }

  /**
   * Destroys the object
   */
  destroy() {
    const listeners = Object.keys(this.listeners);

    listeners.forEach((listenerName) => {
      this.removeListener(listenerName);
    });

    delete window.pingu.components[this.name].instances[this.uuid];
  }
}

export default PinguComponent;
<|endoftext|>


<commit_before>/* global toastr:false, moment:false */
(function() {
  'use strict';

  angular
    .module('nowplaying')
    .constant('toastr', toastr)
    .constant('moment', moment);

})();
<commit_msg>Index constants<commit_after>/* global toastr:false, moment:false */
(function() {
  'use strict';

  angular
    .module('nowplaying')
    .constant('toastr', toastr)
    .constant('toastr', toastr)
    .constant('tUser', 'dev+biplaying@bunnyinc.com')
    .constant('tUsername', 'BInowplaying')
    .constant('tKey', 'gEFEbGdkVTDfzVgyiiCbzUImi')
    .constant('moment', moment);

})();
<|endoftext|>


<commit_before>'use strict';

var Reflux = require('reflux');

module.exports = Reflux.createActions([

]);<commit_msg>Removed unused server actions<commit_after><|endoftext|>


<commit_before>'use strict';
define(['app'], function(App) {
    App.module('Entities', function(Entities, App, Backbone, Marionette, $, _) {
        var contextName = 'Challenge.Entity';
        Entities.Challenge = Backbone.Model.extend({
            urlRoot: 'challenge',

            defaults: {
                name: '',
                slug: ''
            },

            validate: function(attrs) { // , options
                var errors = {};
                if (!attrs.fileName) {
                    errors.fileName = 'can\'t be blank';
                }
                //     if (! attrs.somethingelse) {
                //       errors.lastName = 'can't be blank';
                //     }
                //     else{
                //       if (attrs.somethingelse.length < 2) {
                //         errors.somethingelse = 'is too short';
                //       }
                //     }
                if (!_.isEmpty(errors)) {
                    return errors;
                }
            }
        });

        Entities.ChallengeCollection = Backbone.Collection.extend({
            url: '/challanges',
            model: Entities.Challenge
        });

        var initializeChallenges = function() {
            App.log('Initializing Fake Challenges', contextName, 1);

            Entities.fakeChallenges = new Entities.ChallengeCollection([
                {
                    id: 1,
                    name: 'Discovering and using my talents',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-talents',
                    domain: 5,
                    resources: [1, 2],
                    activities: [7, 8],
                    icon: 'icon-talents.svg',
                }, {
                    id: 2,
                    name: 'I want to start a business',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-business',
                    domain: 5,
                    resources: [1],
                    activities: [6],
                    icon: 'icon-business.svg',
                }, {
                    id: 3,
                    name: 'I want to find ways to make a contribution to society',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-society',
                    domain: 5,
                    resources: [1, 2, 3, 4],
                    activities: [4, 5, 6],
                    icon: 'icon-volunteer.svg',
                }, {
                    id: 4,
                    name: 'Continuing my education',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-education',
                    domain: 5,
                    activities: [7],
                    icon: 'icon-degree.svg',
                }, {
                    id: 5,
                    name: 'Finding a job after unemployment',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-unemployment',
                    domain: 5,
                    activities: [8],
                    icon: 'icon-briefcase.svg',
                }, {
                    id: 6,
                    name: 'Disclosing my lived experience to an employer ',
                    desc: 'You don\'t have to disclose you have a diagnosis when you are applying for a job, unless you think it will stop you from being able to do the job - but it still might be a good idea. Disclosing your mental distress can be risky and scary so it\'s important we make good decisions about if, when and how to',
                    slug: 'work-disclose',
                    domain: 5,
                    resources: [1, 2, 3, 4, 5],
                    activities: [4, 5, 6, 7, 8, 9],
                    icon: 'icon-flag.svg',
                }, {
                    id: 7,
                    name: 'Negotiating work conditions related to my distress ',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-negotiate',
                    domain: 5,
                    activities: [],
                    icon: 'icon-handshake.svg',
                }, {
                    name: 'Keeping my job',
                    id: 8,
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-keepmyjob',
                    domain: 5,
                    activities: [],
                    icon: 'icon-ratrace.svg',
                }
            ]);

            return Entities.fakeChallenges;
        };

        var API = {
            getChallengeEntities: function() {
                if (undefined === Entities.fakeChallenges) {
                    initializeChallenges();
                }
                return Entities.fakeChallenges;
            },

            getChallengeEntity: function(id) {
                if (undefined === Entities.fakeChallenges) {
                    initializeChallenges();
                }

                var model = Entities.fakeChallenges.findWhere({
                    id: parseInt(id)
                });

                return model;
            },

            getChallengeByDomain: function(domain) {
                if (undefined === Entities.fakeChallenges) {
                    initializeChallenges();
                }

                var models = Entities.fakeChallenges.where({
                    // NOTE: this is a gotcha:
                    domain: parseInt(domain)
                });

                return new Entities.ChallengeCollection(models);
            },
        };

        App.reqres.setHandler('challenge:entities', function() {
            return API.getChallengeEntities();
        });

        App.reqres.setHandler('challenge:entity', function(id) {
            return API.getChallengeEntity(id);
        });

        App.reqres.setHandler('challenge:domain:entities', function(id) {
            return API.getChallengeByDomain(id);
        });

    });

    return;
});<commit_msg>Closes #55<commit_after>'use strict';
define(['app'], function(App) {
    App.module('Entities', function(Entities, App, Backbone, Marionette, $, _) {
        var contextName = 'Challenge.Entity';
        Entities.Challenge = Backbone.Model.extend({
            urlRoot: 'challenge',

            defaults: {
                name: '',
                slug: ''
            },

            validate: function(attrs) { // , options
                var errors = {};
                if (!attrs.fileName) {
                    errors.fileName = 'can\'t be blank';
                }
                //     if (! attrs.somethingelse) {
                //       errors.lastName = 'can't be blank';
                //     }
                //     else{
                //       if (attrs.somethingelse.length < 2) {
                //         errors.somethingelse = 'is too short';
                //       }
                //     }
                if (!_.isEmpty(errors)) {
                    return errors;
                }
            }
        });

        Entities.ChallengeCollection = Backbone.Collection.extend({
            url: '/challanges',
            model: Entities.Challenge
        });

        var initializeChallenges = function() {
            App.log('Initializing Fake Challenges', contextName, 1);

            Entities.fakeChallenges = new Entities.ChallengeCollection([
                {
                    id: 1,
                    name: 'Discovering and using my talents',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-talents',
                    domain: 5,
                    resources: [1, 2],
                    activities: [7, 8],
                    icon: 'icon-talents.svg',
                }, {
                    id: 2,
                    name: 'I want to start a business',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-business',
                    domain: 5,
                    resources: [1],
                    activities: [6],
                    icon: 'icon-business.svg',
                }, {
                    id: 3,
                    name: 'I want to find ways to make a contribution to society',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-society',
                    domain: 5,
                    resources: [1, 2, 3, 4],
                    activities: [4, 5, 6],
                    icon: 'icon-volunteer.svg',
                }, {
                    id: 4,
                    name: 'Continuing my education',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-education',
                    domain: 5,
                    activities: [7],
                    icon: 'icon-degree.svg',
                }, {
                    id: 5,
                    name: 'Finding a job after unemployment',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-unemployment',
                    domain: 5,
                    activities: [8],
                    icon: 'icon-briefcase.svg',
                }, {
                    id: 6,
                    name: 'Disclosing my lived experience to an employer ',
                    desc: 'You don\'t have to disclose you have a diagnosis when you are applying for a job, unless you think it will stop you from being able to do the job - but it still might be a good idea. Disclosing your mental distress can be risky and scary so it\'s important we make good decisions about if, when and how to.',
                    slug: 'work-disclose',
                    domain: 5,
                    resources: [1, 2, 3, 4, 5],
                    activities: [4, 5, 6, 7, 8, 9],
                    icon: 'icon-flag.svg',
                }, {
                    id: 7,
                    name: 'Negotiating work conditions related to my distress ',
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-negotiate',
                    domain: 5,
                    activities: [],
                    icon: 'icon-handshake.svg',
                }, {
                    name: 'Keeping my job',
                    id: 8,
                    desc: 'A very short description of the challenge. About this many words:Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deleniti voluptatum ut, perferendis temporibus magnam velit qui necessitatibus officia deserunt inventore tempora architecto, illo nemo? Ab.',
                    slug: 'work-keepmyjob',
                    domain: 5,
                    activities: [],
                    icon: 'icon-ratrace.svg',
                }
            ]);

            return Entities.fakeChallenges;
        };

        var API = {
            getChallengeEntities: function() {
                if (undefined === Entities.fakeChallenges) {
                    initializeChallenges();
                }
                return Entities.fakeChallenges;
            },

            getChallengeEntity: function(id) {
                if (undefined === Entities.fakeChallenges) {
                    initializeChallenges();
                }

                var model = Entities.fakeChallenges.findWhere({
                    id: parseInt(id)
                });

                return model;
            },

            getChallengeByDomain: function(domain) {
                if (undefined === Entities.fakeChallenges) {
                    initializeChallenges();
                }

                var models = Entities.fakeChallenges.where({
                    // NOTE: this is a gotcha:
                    domain: parseInt(domain)
                });

                return new Entities.ChallengeCollection(models);
            },
        };

        App.reqres.setHandler('challenge:entities', function() {
            return API.getChallengeEntities();
        });

        App.reqres.setHandler('challenge:entity', function(id) {
            return API.getChallengeEntity(id);
        });

        App.reqres.setHandler('challenge:domain:entities', function(id) {
            return API.getChallengeByDomain(id);
        });

    });

    return;
});<|endoftext|>


<commit_before>module.exports = function nl2br (str, isXhtml) {
  //  discuss at: http://locutus.io/php/nl2br/
  // original by: Kevin van Zonneveld (http://kvz.io)
  // improved by: Philip Peterson
  // improved by: Onno Marsman (https://twitter.com/onnomarsman)
  // improved by: Atli Þór
  // improved by: Brett Zamir (http://brett-zamir.me)
  // improved by: Maximusya
  // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)
  // bugfixed by: Kevin van Zonneveld (http://kvz.io)
  // bugfixed by: Reynier de la Rosa (http://scriptinside.blogspot.com.es/)
  //    input by: Brett Zamir (http://brett-zamir.me)
  //   example 1: nl2br('Kevin\nvan\nZonneveld')
  //   returns 1: 'Kevin
\nvan
\nZonneveld'
  //   example 2: nl2br("\nOne\nTwo\n\nThree\n", false)
  //   returns 2: '
\nOne
\nTwo
\n
\nThree
\n'
  //   example 3: nl2br("\nOne\nTwo\n\nThree\n", true)
  //   returns 3: '
\nOne
\nTwo
\n
\nThree
\n'
  //   example 4: nl2br(null)
  //   returns 4: ''

  // Some latest browsers when str is null return and unexpected null value
  if (typeof str === 'undefined' || str === null) {
    return ''
  }

  // Adjust comment to avoid issue on locutus.io display
  var breakTag = (isXhtml || typeof isXhtml === 'undefined') ? '
' : '
'

  return (str + '')
    .replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2')
}
<commit_msg>Remove useless regex part (#326)<commit_after>module.exports = function nl2br (str, isXhtml) {
  //  discuss at: http://locutus.io/php/nl2br/
  // original by: Kevin van Zonneveld (http://kvz.io)
  // improved by: Philip Peterson
  // improved by: Onno Marsman (https://twitter.com/onnomarsman)
  // improved by: Atli Þór
  // improved by: Brett Zamir (http://brett-zamir.me)
  // improved by: Maximusya
  // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)
  // bugfixed by: Kevin van Zonneveld (http://kvz.io)
  // bugfixed by: Reynier de la Rosa (http://scriptinside.blogspot.com.es/)
  //    input by: Brett Zamir (http://brett-zamir.me)
  //   example 1: nl2br('Kevin\nvan\nZonneveld')
  //   returns 1: 'Kevin
\nvan
\nZonneveld'
  //   example 2: nl2br("\nOne\nTwo\n\nThree\n", false)
  //   returns 2: '
\nOne
\nTwo
\n
\nThree
\n'
  //   example 3: nl2br("\nOne\nTwo\n\nThree\n", true)
  //   returns 3: '
\nOne
\nTwo
\n
\nThree
\n'
  //   example 4: nl2br(null)
  //   returns 4: ''

  // Some latest browsers when str is null return and unexpected null value
  if (typeof str === 'undefined' || str === null) {
    return ''
  }

  // Adjust comment to avoid issue on locutus.io display
  var breakTag = (isXhtml || typeof isXhtml === 'undefined') ? '
' : '
'

  return (str + '')
    .replace(/(\r\n|\n\r|\r|\n)/g, breakTag + '$1')
}
<|endoftext|>


<commit_before>
var bio = {
    "name": "Mark Crowther",
    "role": "Front-end Test Architect",
    "welcome": "Welcome to my Udacity pages, part of the Front-end Web Developer course. Here you'll find a list of the web programming skills I'm developing as part of the Udacity course. A Totally Udacious Mindblow™!",
    "contacts": {
        "mobile": "+44 (0)7725 838417",
        "email": "mark@cyreath.co.uk",
        "github": "MarkCTest",
        "twitter": "@MarkCTest",
        "blog": "http://cyreath.blogspot.com/",
        "location": "London, UK"
        },
    "skills": ["HTML5", "CSS3", "JavaScript", "JQuery", "JSON", "Test Automation"],
    "biopic": "http://cyreath.co.uk/dev/udacity/images/mark-crowther.png"
};

// Function to add skills if there are any in the skills array within the bio object
bio.display = function() {
    if (bio.skills === 0) {
            console.log("Nothing in Skills so skills header is hidden");
        } else {
            var formattedSkillsStart = HTMLskillsStart;
            $("#header").append(formattedSkillsStart);

// The solution at the end of [JavaScript Basics > Flow Control > Quiz] seemed very repetative, so I went for this instead
            bio.skills.forEach(function(item) {
                var formattedSkills = HTMLskills.replace("%data%", item);
                $("#skills").append(formattedSkills);
            });
            console.log("Skills added to the resume");
        }; //end Else
}; // end bio.display function

 // ###########################      EDUCATION          ##############################
var education = {
    "schools": [
        {
            "name": "The Open University",
            "location": "Milton Keynes",
            "degree": "Computing and Systems Practice",
            "major": "Automation",
            "dates": "2011",
            "url": "http://www.open.ac.uk/"
        }
    ],
    "onlineCourses": [
        {
            "title": "Tenable Certified Nessus Auditor",
            "school": "Tenable",
            "dates": "2014",
            "url": "http://elearn.tenable.com/course/info.php?id=55"
        },
        {
            "name": "Udacity",
            "location": "Mountain View",
            "degree": "Front-end Web Developer",
            "major": "Web Development",
            "dates": "2015",
            "url": "https://www.udacity.com"
        }
    ]
}

// FUNCTION to add each of the EDUCATION items in the work object onto the page

education.display = function() {
    console.log("education.display not implemented");
};

 // ###########################      WORK          ##############################

var work = {
    "jobs": [
        {
            "employer": "Piccadilly Group",
            "title": "Principal Consultant",
            "location": "London, UK",
            "dates": "April 2013 to present",
            "description": "In this current role I deliver on-site consulting in Test Management for finance and banking clients. This can involve analysis and planning to execution and reporting. I'm responsbile for coding automated unit and functional system tests using tools such as Selenium and NightWatch.js along with integrated dashbaords."
        },
        {
            "employer": "Pride Systems Ltd",
            "title": "Front-end Test Architect",
            "location": "Malaga, Spain",
            "dates": "May 2011 to March 2013",
            "description": "In this role I was responsible for developing web based dashboards and reports to help display and visualise testing data. I was required to design and code HTML, CSS and JavaScript web solutions that could be used by the team and senior management alike."
        }
    ]
}

// FUNCTION to add each of the WORK items in the work object onto the page

work.display = function() {
    for (eachJob in work.jobs) {
        $("#workExperience").append(HTMLworkStart);
    //
        var formattedWorkEmployer = HTMLworkEmployer.replace("%data%", work.jobs[eachJob].employer);
        var formattedWorkTitle = HTMLworkTitle.replace("%data%", work.jobs[eachJob].title);
        var concatEmployerAndTitle = formattedWorkEmployer + formattedWorkTitle;
        $(".work-entry:last").append(concatEmployerAndTitle);

        var formattedLocation = HTMLworkLocation.replace("%data%", work.jobs[eachJob].location);
        $(".work-entry:last").append(formattedLocation);

        var formattedDates = HTMLworkDates.replace("%data%", work.jobs[eachJob].dates);
        $(".work-entry:last").append(formattedDates);

        var formattedDescription = HTMLworkDescription.replace("%data%", work.jobs[eachJob].description);
        $(".work-entry:last").append(formattedDescription);

    }
    console.log("Work added to the resume");
};

// #############################   PROJECTS    #####################################

var projects = {
    "projects": [
        {
            "title": "Automation Engineer",
            "dates": "2014",
            "description": "Test Automation of over 300 applications for an investment bank",
            "images": "http://logodatabases.com/wp-content/uploads/2012/03/deutsche-bank.jpg"
        },
        {
            "title": "Test Support Architect",
            "dates": "2015",
            "description": "Analysis and design of test environments",
            "images": "http://www.barclaycard.co.uk/personal/images/barclaycard_logo.png"
        }
    ]
}

// FUNCTION to add each of the work items in the work object onto the page

projects.display = function() {
    console.log("projects.display not implemented");
};

// TO DO: Convert all the Code for adding elements to the webpage into FUNCTIONS
// #############################################################################

var formattedRole = HTMLheaderRole.replace("%data%", bio.role);
    $("#header").prepend(formattedRole);

var formattedName = HTMLheaderName.replace("%data%", bio.name);
    $("#header").prepend(formattedName);

console.log("Name and Role added to the resume");

// TOP CONTACTS
// ############# TODO: Change this to a forEach loop #############

var formattedMobile = HTMLmobile.replace("%data%", bio.contacts.mobile);
    $("#topContacts").append(formattedMobile);

var formattedEmail = HTMLemail.replace("%data%", bio.contacts.email);
    $("#topContacts").append(formattedEmail);

var formattedGithub = HTMLgithub.replace("%data%", bio.contacts.github);
    $("#topContacts").append(formattedGithub);

var formattedTwitter = HTMLtwitter.replace("%data%", bio.contacts.twitter);
    $("#topContacts").append(formattedTwitter);

var formattedBlog = HTMLblog.replace("%data%", bio.contacts.blog);
    $("#topContacts").append(formattedBlog);

var formattedLocation = HTMLlocation.replace("%data%", bio.contacts.location);
    $("#topContacts").append(formattedLocation);

// Extra #Header Items

var formattedBioPic = HTMLbioPic.replace("%data%", bio.biopic);
    $("#header").append(formattedBioPic);

var formattedWelcome = HTMLwelcomeMsg.replace("%data%",bio.welcome);
    $("#header").append(formattedWelcome);

// Call the resumeBuilder Functions to build the resume content
bio.display();
work.display();
projects.display();
education.display();<commit_msg>Added Projects and project logos<commit_after>
var bio = {
    "name": "Mark Crowther",
    "role": "Front-end Test Architect",
    "welcome": "Welcome to my Udacity pages, part of the Front-end Web Developer course. Here you'll find a list of the web programming skills I'm developing as part of the Udacity course. A Totally Udacious Mindblow™!",
    "contacts": {
        "youtube": "http://www.youtube.com/user/Cyreath",
        "email": "mark@cyreath.co.uk",
        "github": "MarkCTest",
        "twitter": "@MarkCTest",
        "blog": "http://cyreath.blogspot.com/",
        "location": "London, UK"
        },
    "skills": ["HTML5", "CSS3", "JavaScript", "JQuery", "JSON", "Test Automation"],
    "biopic": "images/mark001.jpg"
};

// FUNCTION to add each of the BIO items in the work object onto the page

bio.display = function() {
    if (bio.skills === 0) {
            console.log("Nothing in Skills so skills header is hidden");
        } else {
            var formattedRole = HTMLheaderRole.replace("%data%", bio.role);
                $("#header").prepend(formattedRole);

            var formattedName = HTMLheaderName.replace("%data%", bio.name);
                $("#header").prepend(formattedName);

            console.log("Name and Role added to the resume");

            var formattedEmail = HTMLemail.replace("%data%", bio.contacts.email);
                $("#topContacts").append(formattedEmail);

            var formattedGithub = HTMLgithub.replace("%data%", bio.contacts.github);
                $("#topContacts").append(formattedGithub);

            var formattedTwitter = HTMLtwitter.replace("%data%", bio.contacts.twitter);
                $("#topContacts").append(formattedTwitter);

            var formattedBlog = HTMLblog.replace("%data%", bio.contacts.blog);
                $("#topContacts").append(formattedBlog);

            var formattedYoutube = HTMLyoutube.replace("%data%", bio.contacts.youtube);
                $("#topContacts").append(formattedYoutube);

            var formattedLocation = HTMLlocation.replace("%data%", bio.contacts.location);
                $("#topContacts").append(formattedLocation);

            var formattedBioPic = HTMLbioPic.replace("%data%", bio.biopic);
                $("#header").append(formattedBioPic);

            var formattedWelcome = HTMLwelcomeMsg.replace("%data%",bio.welcome);
                $("#header").append(formattedWelcome);

            var formattedSkillsStart = HTMLskillsStart;
                $("#header").append(formattedSkillsStart);

            // The solution at the end of [JavaScript Basics > Flow Control > Quiz] seemed very repetative, so I went for this instead
            bio.skills.forEach(function(item) {
                var formattedSkills = HTMLskills.replace("%data%", item);
                $("#skills").append(formattedSkills);
            });
            console.log("Bio added to the resume");
        }; //end Else
}; // end bio.display function

 // ###########################      EDUCATION          ##############################
var education = {
    "schools": [
        {
            "name": "The Open University",
            "location": "Milton Keynes",
            "degree": "Computing and Systems Practice",
            "major": "Automation",
            "dates": "2011",
            "url": "http://www.open.ac.uk/"
        }
    ],
    "onlineCourses": [
        {
            "title": "Tenable Certified Nessus Auditor",
            "school": "Tenable",
            "dates": "2014",
            "url": "http://elearn.tenable.com/course/info.php?id=55"
        },
        {
            "name": "Udacity",
            "location": "Mountain View",
            "degree": "Front-end Web Developer",
            "major": "Web Development",
            "dates": "2015",
            "url": "https://www.udacity.com"
        }
    ]
}

// FUNCTION to add each of the EDUCATION items in the work object onto the page

education.display = function() {
    $("#education").append(HTMLschoolStart);
    $("#education").append(HTMLonlineClasses);

    for (eachSchool in education.schools) {
        var formattedSchoolName = HTMLschoolName.replace("%data%", education.schools[eachSchool].name);
        $(".education-entry:last").append(formattedSchoolName);

        var formattedSchoolLocation = HTMLschoolLocation.replace("%data%", education.schools[eachSchool].location);
        $(".education-entry:last").append(formattedSchoolLocation);

        var formattedSchoolDegree = HTMLschoolDegree.replace("%data%", education.schools[eachSchool].degree);
        $(".education-entry:last").append(formattedSchoolDegree);

        var formattedSchoolMajor = HTMLschoolMajor.replace("%data%", education.schools[eachSchool].major);
        $(".education-entry:last").append(formattedSchoolMajor);

        var formattedSchoolDates = HTMLschoolDates.replace("%data%", education.schools[eachSchool].dates);
        $(".education-entry:last").append(formattedSchoolDates);

        var formattedSchoolURL = HTMLschoolName.replace("#", education.schools[eachSchool].url);
        $(".education-entry:last").append(formattedSchoolURL);

    }

    console.log("Schools added to the resume")
};

 // ###########################      WORK          ##############################

var work = {
    "jobs": [
        {
            "employer": "Piccadilly Group",
            "title": "Principal Consultant",
            "location": "London, UK",
            "dates": "April 2013 to present",
            "description": "In this current role I deliver on-site consulting in Test Management for finance and banking clients. This can involve analysis and planning to execution and reporting. I'm responsbile for coding automated unit and functional system tests using tools such as Selenium and NightWatch.js along with integrated dashbaords."
        },
        {
            "employer": "Pride Systems Ltd",
            "title": "Front-end Test Architect",
            "location": "Malaga, Spain",
            "dates": "May 2011 to March 2013",
            "description": "In this role I was responsible for developing web based dashboards and reports to help display and visualise testing data. I was required to design and code HTML, CSS and JavaScript web solutions that could be used by the team and senior management alike."
        }
    ]
}

// FUNCTION to add each of the WORK items in the work object onto the page

work.display = function() {
    for (eachJob in work.jobs) {
        $("#workExperience").append(HTMLworkStart);

        var formattedWorkEmployer = HTMLworkEmployer.replace("%data%", work.jobs[eachJob].employer);
        var formattedWorkTitle = HTMLworkTitle.replace("%data%", work.jobs[eachJob].title);
        var concatEmployerAndTitle = formattedWorkEmployer + formattedWorkTitle;
        $(".work-entry:last").append(concatEmployerAndTitle);

        var formattedLocation = HTMLworkLocation.replace("%data%", work.jobs[eachJob].location);
        $(".work-entry:last").append(formattedLocation);

        var formattedDates = HTMLworkDates.replace("%data%", work.jobs[eachJob].dates);
        $(".work-entry:last").append(formattedDates);

        var formattedDescription = HTMLworkDescription.replace("%data%", work.jobs[eachJob].description);
        $(".work-entry:last").append(formattedDescription);

        console.log("Work items added to the resume");

    }
};

// #############################   PROJECTS    #####################################

var projects = {
    "theProjects": [
        {
            "title": "Automation Engineer",
            "dates": "2014",
            "description": "Test Automation of over 300 applications for an investment bank. This involved tool selection based on the unique needs of the application team's testing problem, design of HTML based reporting interface, PoC build and deployment via a third party automation vendor.",
            "images": ["images/logo-db.png", "images/icon-nightwatch.png", "images/logo-sel.png", "images/icon-html5.png", "images/icon-css3.png"]
        },
        {
            "title": "Test Support Architect",
            "dates": "2015",
            "description": "Analysis and design of test environments",
            "images": ["images/logo-bc.png", "images/logo-itil.png"]
        }
    ]
}

// FUNCTION to add each of the work items in the work object onto the page

projects.display = function() {
    for (eachProject in projects.theProjects) {
        $("#projects").append(HTMLprojectStart);

        var formattedProjectTitle = HTMLprojectTitle.replace("%data%", projects.theProjects[eachProject].title);
        $(".project-entry:last").append(formattedProjectTitle);

        var formattedProjectDates = HTMLprojectDates.replace("%data%", projects.theProjects[eachProject].dates);
        $(".project-entry:last").append(formattedProjectDates);

        var formattedProjectDescription = HTMLprojectDescription.replace("%data%", projects.theProjects[eachProject].description);
        $(".project-entry:last").append(formattedProjectDescription);

            if (projects.theProjects[eachProject].images.length === 0) {
                console.log("Nothing in Images so Images won't be shown");
            } else {
                for (eachImage in projects.theProjects[eachProject].images) {
                     var formattedProjectImage = HTMLprojectImage.replace("%data%", projects.theProjects[eachProject].images[eachImage]);
                    $(".project-entry:last").append(formattedProjectImage);
                } // end FOR
            } //end of ELSE

        console.log("Projects added to the resume");

    } // end of FOR
};

// Call the resumeBuilder Functions to build the resume content
bio.display();
work.display();
projects.display();
education.display();<|endoftext|>


<commit_before>/* global Airbrake*/
import Ember from "ember";
import config from "../config/environment.js";

var isSetup = false;

function setupAirbrake(){
  Airbrake.addReporter(Airbrake.consoleReporter);
  Airbrake.setProject(config.airbrake.projectId, config.airbrake.projectKey);
  Airbrake.setEnvironmentName(config.environment);
  if (config.airbrake.host) {
    Airbrake.setHost(config.airbrake.host);
  }
  Airbrake.addEnvironment({
    user_agent: window.navigator.userAgent
  });

  var preprocessor = config.preprocessor || function(err) { return err; };
  function pushError(err) {
    Airbrake.push(preprocessor(err));
  }

  var originalOnError = Ember.onerror || Ember.K;
  Ember.onerror = function(err) { // any ember error
    originalOnError(err);
    pushError(err)
  };
  Ember.RSVP.on('error',function(err){ // any promise error
    pushError(err)
  });
  window.onerror = function(message, file, line, column, error){ // window general errors.
    if (message === 'Script error.') {
      // Ignore.
      return;
    }

    if (error) {
      pushError({error: error})
    } else {
      pushError({error: {
        message: message,
        fileName: file,
        lineNumber: line,
        columnNumber: column || 0
      }});
    }
  };
}

export function initialize(/* container, application */) {
  if (config.airbrake && !isSetup) {
    isSetup = true;
    if (Airbrake.setProject) {
      setupAirbrake();
    } else {
      Airbrake.onload = setupAirbrake;
    }
  }
}

export default {
  name: 'airbrake',
  initialize: initialize
};
<commit_msg>get preprocessor from correct config setting<commit_after>/* global Airbrake*/
import Ember from "ember";
import config from "../config/environment.js";

var isSetup = false;

function setupAirbrake(){
  Airbrake.addReporter(Airbrake.consoleReporter);
  Airbrake.setProject(config.airbrake.projectId, config.airbrake.projectKey);
  Airbrake.setEnvironmentName(config.environment);
  if (config.airbrake.host) {
    Airbrake.setHost(config.airbrake.host);
  }
  Airbrake.addEnvironment({
    user_agent: window.navigator.userAgent
  });

  var preprocessor = config.airbrake.preprocessor || function(err) { return err; };
  function pushError(err) {
    Airbrake.push(preprocessor(err));
  }

  var originalOnError = Ember.onerror || Ember.K;
  Ember.onerror = function(err) { // any ember error
    originalOnError(err);
    pushError(err)
  };
  Ember.RSVP.on('error',function(err){ // any promise error
    pushError(err)
  });
  window.onerror = function(message, file, line, column, error){ // window general errors.
    if (message === 'Script error.') {
      // Ignore.
      return;
    }

    if (error) {
      pushError({error: error})
    } else {
      pushError({error: {
        message: message,
        fileName: file,
        lineNumber: line,
        columnNumber: column || 0
      }});
    }
  };
}

export function initialize(/* container, application */) {
  if (config.airbrake && !isSetup) {
    isSetup = true;
    if (Airbrake.setProject) {
      setupAirbrake();
    } else {
      Airbrake.onload = setupAirbrake;
    }
  }
}

export default {
  name: 'airbrake',
  initialize: initialize
};
<|endoftext|>