<commit_before>/*jshint boss:true, expr:true, onevar:false */

/**
 * Provides the `Y.Rednose.TreeView` widget.
 *
 * @module rednose-treeview
 */

var TreeView,

    CSS_OUTER_CONTAINER = 'rednose-treeview-outer-container',
    CSS_INNER_CONTAINER = 'rednose-treeview-inner-container',
    CSS_TREEVIEW_ICON   = 'rednose-treeview-icon',

    CSS_BOOTSTRAP_ICON_WHITE = 'icon-white',
    CSS_BOOTSTRAP_NAV_HEADER = 'nav-header';

/**
 * A TreeView widget, implementing Y.View.
 * Quick Example:

 *
 *
var instance = new Y.Rednose.TreeView({
 *    model     : model,
 *    dragdrop  : true,
 *    selectable: true,
 *    groups    : ['rednose-treeview'],
 *    header    : 'RedNose TreeView'
 * });
 *

 *
 * @class TreeView
 * @param {Object} [config] The following configuration properties are required:
 *
 *     @param {Object} [config.container] The container to bind the treeView to.
 *     @param {Boolean} [config.dragdrop] Enable standalone drag and drop for this instance.
 *     @param {Boolean} [config.selectable] Enables selection of tree nodes. Only single selection
 *         is supported for now
 *     @param {Y.Rednose.ModelTree} [config.model] A RedNose Tree model. Change events are bound to update
 *         the view when the model changes.
 *     @param {Array} [config.groups] The DD groups that can interact with this
 *         TreeView instance.
 *     @param {String} [config.header] An optional header, needed for global dropping on the root node
 *
 * @constructor
 * @extends Y.TreeView
 */
TreeView = Y.Base.create('treeView', Y.TreeView, [Y.Rednose.TreeView.Anim, Y.Rednose.TreeView.DD, Y.Rednose.TreeView.Selectable], {
    // -- Protected Properties -------------------------------------------------

    /**
     * Stores the state of the opened tree nodes.
     *
     * @property {Array} _stateMap
     * @protected
     */
    _stateMap: [],

    // -- Lifecycle Methods ----------------------------------------------------

    initializer: function (config) {
        config || (config = {});

        var model = config.model || new Y.Rednose.ModelTree();

        // Hook into the initializer chain to set the nodes.
        config.nodes = model.get('items');

        if (config.header) {
            this.header = config.header;
        }

        // Initialize the state map so it doesn't contain any garbage from previous instances.
        this._stateMap = [];

        this.set('model', model);

        this._attachEventHandles();
    },

    destructor: function () {
        this._detachEventHandles();

        // Free the reference so the property is eligible for garbage collection.
        this._stateMap = null;

        // Remove the container from the DOM and destroy it.
        this._destroyContainer();
    },

    // -- Public Methods -------------------------------------------------------

    /**
     * Overrides TreeView's `render()` method to wrap the container into a parent container,
     * and hook into the rendering process.
     *
     * @method render
     * @chainable
     * @see Y.TreeView.render()
     */
    render: function () {
        var container     = this.get('container'),
            isTouchDevice = 'ontouchstart' in Y.config.win,
            header        = this.header,
            subContainer  = Y.Node.create('

');

        container.addClass(this.classNames.treeview);
        container.addClass(this.classNames[isTouchDevice ? 'touch' : 'noTouch']);

        // Append a subcontainer to render the tree.
        container.addClass(CSS_OUTER_CONTAINER);
        container.append(subContainer);

        if (header) {
            subContainer.append('
' + header + '
');
        }

        this._childrenNode = this.renderChildren(this.rootNode, {
            // Pass the subcontainer.
            container: subContainer
        });

        this.rendered = true;

        return this;
    },

    /**
     * Return a CSS class string, modified by the given tree node and it's associated model.
     *
     * @method icon
     * @param  {Y.Tree.Node} node Tee Node.
     * @return {String} A composed CSS string.
     */
    icon: function (node) {
        var model     = node.data,
            icons     = this.get('model').get('icons'),
            className = CSS_TREEVIEW_ICON;

        if (icons && model instanceof Y.Model  && icons[model.name]) {
            var icon = icons[model.name];

            if (this.get('selectable') && node.isSelected()) {
                className += (' ' + CSS_BOOTSTRAP_ICON_WHITE);
            }

            if (Y.Lang.isString(icon)) {
                return className + ' ' + icon;
            }

            if (Y.Lang.isArray(icon)) {
                return className + ' ' + (node.isOpen() ? icon[0] : icon[1]);
            }
        }

        return className;
    },

    /**
     * Generate a unique RedNose record ID, composed of the class type and the model ID.
     *
     * @method generateRednoseRecordID
     * @param  {Y.Model} model A model instance.
     * @return {String} A unique ID.
     */
    generateRednoseRecordId: function (model) {
        if (model instanceof Y.Model) {
            return model.name + '_' + model.get('id');
        }

        return null;
    },

    /**
     * Parse a unique RedNose model id.
     *
     * @method parseRednoseRecordID
     * @param  {String} id A RedNose record ID.
     * @return {Array} An array containing type and ID.
     */
    parseRednoseRecordId: function (id) {
        return id.split('_');
    },

    // -- Protected Methods ----------------------------------------------------

    _attachEventHandles: function () {
        this._eventHandles || (this._eventHandles = []);

        var model = this.get('model');

        this._eventHandles.push(
            this.on('open', this._handleExpand, this),
            this.on('close', this._handleCollapse, this),

            this.after(['open', 'close'], this._handleToggle, this),

            model.after('change', this._handleModelChange, this)
        );
    },

    _detachEventHandles: function () {
        (new Y.EventHandle(this._eventHandles)).detach();
    },

    _restoreTreeOpenState: function () {
        var self     = this,
            rootNode = this.rootNode;

        if (rootNode.hasChildren() && this._stateMap && this._stateMap.length > 0) {
            Y.Array.each(rootNode.children, function (node) {
                self._restoreNodeOpenState(node);
            });
        }
    },

    _restoreNodeOpenState: function (node) {
         var id    = this.generateRednoseRecordId(node.data),
             index = this._stateMap.indexOf(id);

         if (index !== -1) {
            node.open({silent: true});
         }

         // Look for child nodes to open, even if their parent is closed.
        if (node.hasChildren()) {
            Y.Array.each(node.children, function (child) {
                this._restoreNodeOpenState(child);
            }, this);
        }
    },

    // _fixWidth: function (node) {
    //     var li = this.getHTMLNode(node);
    //     var count = 0;
    //     var current = li.ancestor('.' + this.classNames.children);

    //     while (current.ancestor('.' + this.classNames.children)) {
    //         count++;
    //         current = current.ancestor('.' + this.classNames.children);
    //     }

    //     if (count > 0) {
    //         var ml = count * 20;

    //         if (ml) {
    //             li.setStyle('marginLeft', -ml);
    //             li.one('div').setStyle('paddingLeft', ml + 20);
    //             li.ancestor('.' + this.classNames.children).setStyle('marginLeft', ml);
    //             li.one('.' + this.classNames.indicator).setStyle('marginLeft', ml);
    //         }
    //     }
    // },

    // -- Protected Event Handlers ---------------------------------------------

    _handleModelChange: function () {
        var nodes = this.get('model').get('items');

        // This is a full tree refresh, so handle the tree methods silently, we don't propagate the
        // events to our animation listeners etc.
        this.clear(false, {silent: true});

        // Clean up, normally this would be handled by the original Treeview's handler, but we are clearing
        // the tree silently.
       if (this.rendered) {
            var childNodes = this.get('container').get('childNodes');

            delete this._childrenNode;

            childNodes.remove();

            // Fix for DD. YUI creates the shims on a 100 ms timer after DD init, so if we destroy
            // the node within 100 ms after initialization, the internal node property points to NULL and
            // we get an error.
            Y.later(150, Y, function () {
                childNodes.destroy(true);
            });
        }

        // Build a new tree silently, and trigger a new render if needed.
        if (nodes) {
            // Returns an array of references to the created tree nodes.
            treeNodes = this.insertNode(this.rootNode, nodes, {silent: true});
            this._restoreTreeOpenState();
        }

        this.rendered && this.render();
    },

    _handleToggle: function (e) {
        if (this.rendered === false) {
            return;
        }

        var node      = e.node,
            htmlNode  = this.getHTMLNode(e.node);

        htmlNode.one('.' + CSS_TREEVIEW_ICON).set('className', this.icon(node));
    },

    _handleExpand: function (e) {
         var id    = this.generateRednoseRecordId(e.node.data),
             index = this._stateMap.indexOf(id);

        if (index === -1) {
            this._stateMap.push(id);
        }
    },

    _handleCollapse: function (e) {
        var id    = this.generateRednoseRecordId(e.node.data),
            index = this._stateMap.indexOf(id);

        if (index !== -1) {
            this._stateMap.splice(index, 1);
        }
    },

    /**
     * Removes the `container` from the DOM and purges all its event listeners.
     *
     * @method _destroyContainer
     * @protected
     */
    _destroyContainer: function () {
        var container = this.get('container');
        container && container.remove(true);
    }
});

// -- Namespace ----------------------------------------------------------------
Y.namespace('Rednose').TreeView = TreeView;
<commit_msg>Monkey patching the treeview CSS<commit_after>/*jshint boss:true, expr:true, onevar:false */

/**
 * Provides the `Y.Rednose.TreeView` widget.
 *
 * @module rednose-treeview
 */

var TreeView,

    CSS_OUTER_CONTAINER = 'rednose-treeview-outer-container',
    CSS_INNER_CONTAINER = 'rednose-treeview-inner-container',
    CSS_TREEVIEW_ICON   = 'rednose-treeview-icon',

    CSS_BOOTSTRAP_ICON_WHITE = 'icon-white',
    CSS_BOOTSTRAP_NAV_HEADER = 'nav-header';

/**
 * A TreeView widget, implementing Y.View.
 * Quick Example:

 *
 *
var instance = new Y.Rednose.TreeView({
 *    model     : model,
 *    dragdrop  : true,
 *    selectable: true,
 *    groups    : ['rednose-treeview'],
 *    header    : 'RedNose TreeView'
 * });
 *

 *
 * @class TreeView
 * @param {Object} [config] The following configuration properties are required:
 *
 *     @param {Object} [config.container] The container to bind the treeView to.
 *     @param {Boolean} [config.dragdrop] Enable standalone drag and drop for this instance.
 *     @param {Boolean} [config.selectable] Enables selection of tree nodes. Only single selection
 *         is supported for now
 *     @param {Y.Rednose.ModelTree} [config.model] A RedNose Tree model. Change events are bound to update
 *         the view when the model changes.
 *     @param {Array} [config.groups] The DD groups that can interact with this
 *         TreeView instance.
 *     @param {String} [config.header] An optional header, needed for global dropping on the root node
 *
 * @constructor
 * @extends Y.TreeView
 */
TreeView = Y.Base.create('treeView', Y.TreeView, [Y.Rednose.TreeView.Anim, Y.Rednose.TreeView.DD, Y.Rednose.TreeView.Selectable], {
    // -- Protected Properties -------------------------------------------------

    /**
     * Stores the state of the opened tree nodes.
     *
     * @property {Array} _stateMap
     * @protected
     */
    _stateMap: [],

    // -- Lifecycle Methods ----------------------------------------------------

    initializer: function (config) {
        config || (config = {});

        var model = config.model || new Y.Rednose.ModelTree();

        // Hook into the initializer chain to set the nodes.
        config.nodes = model.get('items');

        if (config.header) {
            this.header = config.header;
        }

        // Initialize the state map so it doesn't contain any garbage from previous instances.
        this._stateMap = [];

        this.set('model', model);

        this._attachEventHandles();
    },

    destructor: function () {
        this._detachEventHandles();

        // Free the reference so the property is eligible for garbage collection.
        this._stateMap = null;

        // Remove the container from the DOM and destroy it.
        this._destroyContainer();
    },

    // -- Public Methods -------------------------------------------------------

    /**
     * Overrides TreeView's `render()` method to wrap the container into a parent container,
     * and hook into the rendering process.
     *
     * @method render
     * @chainable
     * @see Y.TreeView.render()
     */
    render: function () {
        var container     = this.get('container'),
            isTouchDevice = 'ontouchstart' in Y.config.win,
            header        = this.header,
            subContainer  = Y.Node.create('

');

        container.addClass(this.classNames.treeview);
        container.addClass(this.classNames[isTouchDevice ? 'touch' : 'noTouch']);

        // Append a subcontainer to render the tree.
        container.addClass(CSS_OUTER_CONTAINER);
        container.append(subContainer);

        if (header) {
            subContainer.append('
' + header + '
');
        }

        this._childrenNode = this.renderChildren(this.rootNode, {
            // Pass the subcontainer.
            container: subContainer
        });

        this.rendered = true;

        return this;
    },

    /**
     * Return a CSS class string, modified by the given tree node and it's associated model.
     *
     * @method icon
     * @param  {Y.Tree.Node} node Tee Node.
     * @return {String} A composed CSS string.
     */
    icon: function (node) {
        var model     = node.data,
            icons     = this.get('model').get('icons'),
            className = CSS_TREEVIEW_ICON;

        if (icons && model instanceof Y.Model  && icons[model.name]) {
            var icon = icons[model.name];

            if (this.get('selectable') && node.isSelected()) {
                className += (' ' + CSS_BOOTSTRAP_ICON_WHITE);
            }

            if (Y.Lang.isString(icon)) {
                return className + ' ' + icon;
            }

            if (Y.Lang.isArray(icon)) {
                return className + ' ' + (node.isOpen() ? icon[0] : icon[1]);
            }
        }

        return className;
    },

    /**
     * Generate a unique RedNose record ID, composed of the class type and the model ID.
     *
     * @method generateRednoseRecordID
     * @param  {Y.Model} model A model instance.
     * @return {String} A unique ID.
     */
    generateRednoseRecordId: function (model) {
        if (model instanceof Y.Model) {
            return model.name + '_' + model.get('id');
        }

        return null;
    },

    /**
     * Parse a unique RedNose model id.
     *
     * @method parseRednoseRecordID
     * @param  {String} id A RedNose record ID.
     * @return {Array} An array containing type and ID.
     */
    parseRednoseRecordId: function (id) {
        return id.split('_');
    },

    // -- Protected Methods ----------------------------------------------------

    _attachEventHandles: function () {
        this._eventHandles || (this._eventHandles = []);

        var model = this.get('model');

        this._eventHandles.push(
            this.on('open', this._handleExpand, this),
            this.on('close', this._handleCollapse, this),

            this.after(['open', 'close'], this._handleToggle, this),

            model.after('change', this._handleModelChange, this),

            // CSS Margin correction
            Y.Do.after(this._afterRender, this, 'render', this),
            this.after('open', this._handleMarginCorrection, this)
        );
    },

    _detachEventHandles: function () {
        (new Y.EventHandle(this._eventHandles)).detach();
    },

    _restoreTreeOpenState: function () {
        var self     = this,
            rootNode = this.rootNode;

        if (rootNode.hasChildren() && this._stateMap && this._stateMap.length > 0) {
            Y.Array.each(rootNode.children, function (node) {
                self._restoreNodeOpenState(node);
            });
        }
    },

    _restoreNodeOpenState: function (node) {
         var id    = this.generateRednoseRecordId(node.data),
             index = this._stateMap.indexOf(id);

         if (index !== -1) {
            node.open({silent: true});
         }

         // Look for child nodes to open, even if their parent is closed.
        if (node.hasChildren()) {
            Y.Array.each(node.children, function (child) {
                this._restoreNodeOpenState(child);
            }, this);
        }
    },

    /**
     * Removes the `container` from the DOM and purges all its event listeners.
     *
     * @method _destroyContainer
     * @protected
     */
    _destroyContainer: function () {
        var container = this.get('container');
        container && container.remove(true);
    },

    _getHTMLNodeDepth: function (htmlNode) {
        var self = this,
            ancestorNodes;

        ancestorNodes = htmlNode.ancestors(function (ancestor) {
            return ancestor.hasClass(self.classNames.node);
        });

        return ancestorNodes.size();
    },

    _correctMargin: function (htmlNode) {
        var depth = this._getHTMLNodeDepth(htmlNode);

        htmlNode.setStyle('margin-left', depth * -20);
        htmlNode.one('.' + this.classNames.indicator).setStyle('margin-left', depth * 20);
        htmlNode.one('.' + CSS_TREEVIEW_ICON).setStyle('margin-left', depth * 20);

        this._correctChildrenMargin(htmlNode);
    },

    _correctChildrenMargin: function (htmlNode) {
        var depth = this._getHTMLNodeDepth(htmlNode);

        if (htmlNode.one('.' + this.classNames.children)) {
            htmlNode.one('.' + this.classNames.children).setStyle('margin-left', 20 + depth * 20);
        }
    },

    // -- Protected Event Handlers ---------------------------------------------

    _handleModelChange: function () {
        var nodes = this.get('model').get('items');

        // This is a full tree refresh, so handle the tree methods silently, we don't propagate the
        // events to our animation listeners etc.
        this.clear(false, {silent: true});

        // Clean up, normally this would be handled by the original Treeview's handler, but we are clearing
        // the tree silently.
       if (this.rendered) {
            var childNodes = this.get('container').get('childNodes');

            delete this._childrenNode;

            childNodes.remove();

            // Fix for DD. YUI creates the shims on a 100 ms timer after DD init, so if we destroy
            // the node within 100 ms after initialization, the internal node property points to NULL and
            // we get an error.
            Y.later(150, Y, function () {
                childNodes.destroy(true);
            });
        }

        // Build a new tree silently, and trigger a new render if needed.
        if (nodes) {
            // Returns an array of references to the created tree nodes.
            treeNodes = this.insertNode(this.rootNode, nodes, {silent: true});
            this._restoreTreeOpenState();
        }

        this.rendered && this.render();
    },

    _handleToggle: function (e) {
        if (this.rendered === false) {
            return;
        }

        var node      = e.node,
            htmlNode  = this.getHTMLNode(e.node);

        htmlNode.one('.' + CSS_TREEVIEW_ICON).set('className', this.icon(node));
    },

    _handleExpand: function (e) {
         var id    = this.generateRednoseRecordId(e.node.data),
             index = this._stateMap.indexOf(id);

        if (index === -1) {
            this._stateMap.push(id);
        }
    },

    _handleCollapse: function (e) {
        var id    = this.generateRednoseRecordId(e.node.data),
            index = this._stateMap.indexOf(id);

        if (index !== -1) {
            this._stateMap.splice(index, 1);
        }
    },

    _afterRender: function () {
        var htmlNodes = this.get('container').all('.' + this.classNames.node),
            self      = this;

        htmlNodes.each(function (htmlNode) {
            self._correctMargin(htmlNode);
        });
    },

    _handleMarginCorrection: function (e) {
        var treeNode = e.node,
            self     = this;

        if (this.rendered) {
            this._correctChildrenMargin(self.getHTMLNode(treeNode));

            Y.Array.each(treeNode.children, function (child) {
                htmlNode = self.getHTMLNode(child);

                self._correctMargin(self.getHTMLNode(child));
            });
        }
    }
});

// -- Namespace ----------------------------------------------------------------
Y.namespace('Rednose').TreeView = TreeView;
<|endoftext|>


<commit_before>//component/icon.js

var Icon = React.createClass({
  propTypes: {
    style: React.PropTypes.object,
    fixed: React.PropTypes.bool,
  },
  render: function() {
    var className = 'icon ' + ('fixed' in this.props ? 'icon-fixed-width ' : '') + this.props.icon;
    return
  }
});

var TruncatedText = React.createClass({
  propTypes: {
    lines: React.PropTypes.number,
    height: React.PropTypes.string,
    auto: React.PropTypes.bool,
  },
  getDefaultProps: function() {
    return {
      lines: null,
      height: null,
      auto: true,
    }
  },
  componentDidMount: function() {
    console.log('span is', this.refs.span);
    console.log('type of lines is', typeof this.props.lines)
    $clamp(this.refs.span, {
      clamp: this.props.lines || this.props.height || 'auto',
    });
  },
  render: function() {
    var text = this.props.children;
    return {text};
  }
});

var BusyMessage = React.createClass({
  propTypes: {
    message: React.PropTypes.string
  },
  render: function() {
    return {this.props.message}
  }
});

var toolTipStyle = {
  position: 'absolute',
  zIndex: '1',
  top: '100%',
  left: '-120px',
  width: '260px',
  padding: '15px',
  border: '1px solid #aaa',
  backgroundColor: '#fff',
  fontSize: '14px',
};
var ToolTip = React.createClass({
  propTypes: {
    open: React.PropTypes.bool.isRequired,
    onMouseOut: React.PropTypes.func
  },
  render: function() {
    return (

        {this.props.children}

    );
  }
});

var creditAmountStyle = {
  color: '#216C2A',
  fontWeight: 'bold',
  fontSize: '0.8em'
}, estimateStyle = {
  fontSize: '0.8em',
  color: '#aaa',
};

var CurrencySymbol = React.createClass({
  render: function() { return LBC; }
});

var CreditAmount = React.createClass({
  propTypes: {
    amount: React.PropTypes.number,
    precision: React.PropTypes.number
  },
  render: function() {
    var formattedAmount = lbry.formatCredits(this.props.amount, this.props.precision ? this.props.precision : 1);
    return (

        {formattedAmount} {parseFloat(formattedAmount) == 1.0 ? 'credit' : 'credits'}
        { this.props.isEstimate ?  (est) : null }

    );
  }
});

var addressStyle = {
  fontFamily: '"Consolas", "Lucida Console", "Adobe Source Code Pro", monospace',
};
var Address = React.createClass({
  propTypes: {
    address: React.PropTypes.string,
  },
  render: function() {
    return (
      {this.props.address}
    );
  }
});

var Thumbnail = React.createClass({
  _defaultImageUri: '/img/default-thumb.svg',
  _maxLoadTime: 10000,

  propTypes: {
    src: React.PropTypes.string.isRequired,
  },
  handleError: function() {
    if (this.state.imageUrl != this._defaultImageUri) {
      this.setState({
        imageUri: this._defaultImageUri,
      });
    }
  },
  getInitialState: function() {
    return {
      imageUri: this.props.src || this._defaultImageUri,
    };
  },
  componentDidMount: function() {
    setTimeout(() => {
      if (!this.refs.img.complete) {
        this.setState({
          imageUri: this._defaultImageUri,
        });
      }
    }, this._maxLoadTime);
  },
  render: function() {
    return
  },
});
<commit_msg>Add className prop to Icon<commit_after>//component/icon.js

var Icon = React.createClass({
  propTypes: {
    style: React.PropTypes.object,
    fixed: React.PropTypes.bool,
    className: React.PropTypes.string,
  },
  render: function() {
    var className = ('icon ' + ('fixed' in this.props ? 'icon-fixed-width ' : '') + this.props.icon + ' ' +
                     (this.props.className || ''));
    return
  }
});

var TruncatedText = React.createClass({
  propTypes: {
    lines: React.PropTypes.number,
    height: React.PropTypes.string,
    auto: React.PropTypes.bool,
  },
  getDefaultProps: function() {
    return {
      lines: null,
      height: null,
      auto: true,
    }
  },
  componentDidMount: function() {
    console.log('span is', this.refs.span);
    console.log('type of lines is', typeof this.props.lines)
    $clamp(this.refs.span, {
      clamp: this.props.lines || this.props.height || 'auto',
    });
  },
  render: function() {
    var text = this.props.children;
    return {text};
  }
});

var BusyMessage = React.createClass({
  propTypes: {
    message: React.PropTypes.string
  },
  render: function() {
    return {this.props.message}
  }
});

var toolTipStyle = {
  position: 'absolute',
  zIndex: '1',
  top: '100%',
  left: '-120px',
  width: '260px',
  padding: '15px',
  border: '1px solid #aaa',
  backgroundColor: '#fff',
  fontSize: '14px',
};
var ToolTip = React.createClass({
  propTypes: {
    open: React.PropTypes.bool.isRequired,
    onMouseOut: React.PropTypes.func
  },
  render: function() {
    return (

        {this.props.children}

    );
  }
});

var creditAmountStyle = {
  color: '#216C2A',
  fontWeight: 'bold',
  fontSize: '0.8em'
}, estimateStyle = {
  fontSize: '0.8em',
  color: '#aaa',
};

var CurrencySymbol = React.createClass({
  render: function() { return LBC; }
});

var CreditAmount = React.createClass({
  propTypes: {
    amount: React.PropTypes.number,
    precision: React.PropTypes.number
  },
  render: function() {
    var formattedAmount = lbry.formatCredits(this.props.amount, this.props.precision ? this.props.precision : 1);
    return (

        {formattedAmount} {parseFloat(formattedAmount) == 1.0 ? 'credit' : 'credits'}
        { this.props.isEstimate ?  (est) : null }

    );
  }
});

var addressStyle = {
  fontFamily: '"Consolas", "Lucida Console", "Adobe Source Code Pro", monospace',
};
var Address = React.createClass({
  propTypes: {
    address: React.PropTypes.string,
  },
  render: function() {
    return (
      {this.props.address}
    );
  }
});

var Thumbnail = React.createClass({
  _defaultImageUri: '/img/default-thumb.svg',
  _maxLoadTime: 10000,

  propTypes: {
    src: React.PropTypes.string.isRequired,
  },
  handleError: function() {
    if (this.state.imageUrl != this._defaultImageUri) {
      this.setState({
        imageUri: this._defaultImageUri,
      });
    }
  },
  getInitialState: function() {
    return {
      imageUri: this.props.src || this._defaultImageUri,
    };
  },
  componentDidMount: function() {
    setTimeout(() => {
      if (!this.refs.img.complete) {
        this.setState({
          imageUri: this._defaultImageUri,
        });
      }
    }, this._maxLoadTime);
  },
  render: function() {
    return
  },
});
<|endoftext|>


<commit_before>import _ from 'lodash';

import * as ActionTypes from '../action-types';
import * as ActionHelpers from '../action-helpers';

const { request, response, fail } = ActionHelpers;
const indexById = list => _.keyBy(list || [], 'id');

const updateCommentViews = (state, comments) => {
  const commentViews = comments.map(comment => ({
    id: comment.id,
    isEditing: false
  }));
  const viewStateMap = indexById(commentViews);
  return { ...viewStateMap, ...state };
};

export default function commentViews(state={}, action) {
  if (ActionHelpers.isFeedResponse(action)) {
    return updateCommentViews(state, action.payload.comments || []);
  }
  switch (action.type) {
    case response(ActionTypes.SHOW_MORE_COMMENTS): {
      return updateCommentViews(state, action.payload.comments || []);
    }
    case response(ActionTypes.GET_SINGLE_POST): {
      return updateCommentViews(state, action.payload.comments || []);
    }
    case ActionTypes.TOGGLE_EDITING_COMMENT: {
      return {
        ...state,
        [action.commentId]: {
          ...state[action.commentId],
          isEditing: !state[action.commentId].isEditing,
          errorMessage: ''
        }
      };
    }
    case request(ActionTypes.SAVE_EDITING_COMMENT): {
      return { ...state, [action.payload.commentId]: { ...state[action.payload.commentId], isSaving: true } };
    }
    case response(ActionTypes.SAVE_EDITING_COMMENT): {
      return { ...state, [action.payload.comments.id]: { ...state[action.payload.comments.id], isEditing: false, isSaving: false, errorMessage: '' } };
    }
    case fail(ActionTypes.SAVE_EDITING_COMMENT): {
      return { ...state, [action.request.commentId]: { ...state[action.request.commentId], isEditing: true, isSaving: false, errorMessage: (action.payload || {}).err } };
    }
    case response(ActionTypes.DELETE_COMMENT): {
      const newState = { ...state };
      delete newState[action.request.commentId];
      return newState;
    }
    case response(ActionTypes.ADD_COMMENT): {
      return { ...state,
        [action.payload.comments.id]: {
          id: action.payload.comments.id,
          isEditing: false
        }
      };
    }
    case ActionTypes.REALTIME_COMMENT_NEW:
    case ActionTypes.REALTIME_COMMENT_UPDATE: {
      return { ...state,
        [action.comment.id]: {
          id: action.comment.id,
          isEditing: false
        }
      };
    }
    case ActionTypes.REALTIME_COMMENT_DESTROY: {
      return { ...state,
        [action.commentId]: undefined
      };
    }
    case ActionTypes.REALTIME_POST_NEW: {
      return updateCommentViews(state, action.comments || []);
    }

    case ActionTypes.UPDATE_HIGHLIGHTED_COMMENTS: {
      const newState = { ...state };
      _.forEach(newState, (view, commentId) => {
        const prev = !!view.isHighlighted; // "!!" is NOT redundant here, it casts undefined to false for proper comparison
        const next = (action.payload.comments.indexOf(commentId) > -1);
        if (prev !== next) {
          newState[commentId] = { ...newState[commentId], isHighlighted: next };
        }
      });
      return newState;
    }

    case ActionTypes.UNAUTHENTICATED: {
      return {};
    }
  }
  return state;
}
<commit_msg>Fix pointer "leaks" on removing comments, part 2<commit_after>import _ from 'lodash';

import * as ActionTypes from '../action-types';
import * as ActionHelpers from '../action-helpers';

const { request, response, fail } = ActionHelpers;
const indexById = list => _.keyBy(list || [], 'id');

const updateCommentViews = (state, comments) => {
  const commentViews = comments.map(comment => ({
    id: comment.id,
    isEditing: false
  }));
  const viewStateMap = indexById(commentViews);
  return { ...viewStateMap, ...state };
};

export default function commentViews(state={}, action) {
  if (ActionHelpers.isFeedResponse(action)) {
    return updateCommentViews(state, action.payload.comments || []);
  }
  switch (action.type) {
    case response(ActionTypes.SHOW_MORE_COMMENTS): {
      return updateCommentViews(state, action.payload.comments || []);
    }
    case response(ActionTypes.GET_SINGLE_POST): {
      return updateCommentViews(state, action.payload.comments || []);
    }
    case ActionTypes.TOGGLE_EDITING_COMMENT: {
      return {
        ...state,
        [action.commentId]: {
          ...state[action.commentId],
          isEditing: !state[action.commentId].isEditing,
          errorMessage: ''
        }
      };
    }
    case request(ActionTypes.SAVE_EDITING_COMMENT): {
      return { ...state, [action.payload.commentId]: { ...state[action.payload.commentId], isSaving: true } };
    }
    case response(ActionTypes.SAVE_EDITING_COMMENT): {
      return { ...state, [action.payload.comments.id]: { ...state[action.payload.comments.id], isEditing: false, isSaving: false, errorMessage: '' } };
    }
    case fail(ActionTypes.SAVE_EDITING_COMMENT): {
      return { ...state, [action.request.commentId]: { ...state[action.request.commentId], isEditing: true, isSaving: false, errorMessage: (action.payload || {}).err } };
    }
    case response(ActionTypes.DELETE_COMMENT): {
      const newState = { ...state };
      delete newState[action.request.commentId];
      return newState;
    }
    case response(ActionTypes.ADD_COMMENT): {
      return { ...state,
        [action.payload.comments.id]: {
          id: action.payload.comments.id,
          isEditing: false
        }
      };
    }
    case ActionTypes.REALTIME_COMMENT_NEW:
    case ActionTypes.REALTIME_COMMENT_UPDATE: {
      return { ...state,
        [action.comment.id]: {
          id: action.comment.id,
          isEditing: false
        }
      };
    }
    case ActionTypes.REALTIME_COMMENT_DESTROY: {
      const newState = { ...state };
      delete newState[action.commentId];
      return newState;
    }
    case ActionTypes.REALTIME_POST_NEW: {
      return updateCommentViews(state, action.comments || []);
    }

    case ActionTypes.UPDATE_HIGHLIGHTED_COMMENTS: {
      const newState = { ...state };
      _.forEach(newState, (view, commentId) => {
        const prev = !!view.isHighlighted; // "!!" is NOT redundant here, it casts undefined to false for proper comparison
        const next = (action.payload.comments.indexOf(commentId) > -1);
        if (prev !== next) {
          newState[commentId] = { ...newState[commentId], isHighlighted: next };
        }
      });
      return newState;
    }

    case ActionTypes.UNAUTHENTICATED: {
      return {};
    }
  }
  return state;
}
<|endoftext|>


<commit_before>/**
 * Controller for cover page (index template).
 */

app.controller('mainCtrl', ['$scope', '$routeParams', 'segmentio', '$rootScope', '$timeout', 'orderByFilter', 'miaThumbnailAdapter', '$sce', 'resolvedNotes', 'initIsotope', '$location',
  function($scope, $routeParams, segmentio, $rootScope, $timeout, orderByFilter, thumbnailAdapter, $sce, notes, initIsotope, $location) {
    var dc = $rootScope.defaultCluster
    if(dc && dc !== 'highlights') $location.path('/clusters/'+$rootScope.defaultCluster)

    var data = $scope.data = notes
    $rootScope.loaded = false
    var japanObjects = [122167, 122102, 122502, 122505, 3369, 122189, 122166, 122492, 122113, 122115, 6612]

    var cluster = $rootScope.defaultCluster || $routeParams.cluster || 'highlights'
    var clusterObjectIds = data.clusters[cluster.replace(/^(g)?(\d+)/i, '$1$2')]
    if(clusterObjectIds) {
      $scope.cluster = $rootScope.defaultCluster = cluster
      $scope.isGallery = cluster.match(/^G\d/i)
      $scope.gallery = $scope.cluster.replace('G', '')
      $rootScope.showingCluster = $scope.showingCluster =
        (typeof $rootScope.showingCluster === 'undefined') ? true : $rootScope.showingCluster
      if(!$rootScope.clusterObjects) {
        $scope.clusterObjects = clusterObjectIds.map(function(objectId) {
          var isStory = objectId.match && objectId.match(/stories\/(\d+)/)
          if(isStory) return data.stories[isStory[1]]
          return data.objects[objectId]
        }).filter(function(o) { return o })
        var startPanels = addPanelsToClusterObjects()
        $rootScope.clusterObjects = $scope.clusterObjects = orderByFilter($scope.clusterObjects, random)
        startPanels.map(function(p) { $scope.clusterObjects.unshift(p) })

        $rootScope.otherObjects = $scope.otherObjects = $rootScope.otherObjects = loadAllObjects()
      } else {
        $scope.clusterObjects = $rootScope.clusterObjects
        $scope.otherObjects = $rootScope.otherObjects
      }
    } else { // not a valid cluster
      $location.path('/')
    }

    $scope.toggleSeeAll = function() {
      var container = $('.cover-wrapper')[0]
      if($scope.showingCluster) $timeout(function() { container.scrollLeft = container.scrollWidth-window.innerWidth }, 0)
      $scope.loading = true
      $rootScope.showingCluster = $scope.showingCluster = !$scope.showingCluster

      $timeout(function() {
        $timeout(initIsotope, 0)
        $scope.loading = false
      }, 0)
    }

    // Maintain the random order of the cluster objects, and add all the others
    // in random order. Then any 'end' panels.
    function loadAllObjects() {
      var c = $scope.clusterObjects
      var others = []

      angular.forEach(data.objects, function(o) {
        if(japanObjects.indexOf(parseInt(o.id)) > -1) return console.info('rejecting', o.id);
        (c.indexOf(o) > -1) || others.push(o)
      })
      others = orderByFilter(others, random)

      angular.forEach(data.panels, function(p) {
        if(c.indexOf(p) == -1 && p.position == 'end') others.push(p)
      })

      return others
      return angular.copy(c).map(function(o) {
        // angular.copy and $sce.trust don't work together. this prevents an sce.unsafe
        if(o.recordType == 'panel') o.trustedContent = $sce.trustAsHtml(o.content)
        return o
      }).concat(others)
    }

    // Add the panels that should be randomized to `clusterObjects` and
    // return the panels that need to be at the beginning so they can be
    // `unshifted` after randomization happens
    // TODO: should panels go into the cluster objects or the other objects?
    function addPanelsToClusterObjects() {
      var panels = []
      angular.forEach(data.panels, function(p) { panels.push(p) })
      panels.filter(function(p) { return p.position == 'random' })
        .map(function(p) { $scope.clusterObjects.push(p) })
      return panels.filter(function(p) { return p.position == 'start' })
    }

    $rootScope.nextView = undefined

    $timeout(initIsotope, 0)

    function random() { return 0.5 - Math.random() }

    if(!$rootScope.identifier) {
      var adjs = ["autumn", "hidden", "bitter", "misty", "silent", "empty", "dry",
        "dark", "summer", "icy", "delicate", "quiet", "white", "cool", "spring",
        "patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue"]
      , nouns = ["waterfall", "river", "breeze", "moon", "rain", "wind", "sea",
        "morning", "snow", "lake", "sunset", "pine", "shadow", "leaf", "dawn",
        "glitter", "forest", "hill", "cloud", "meadow", "sun", "glade", "bird",
        "brook", "butterfly", "bush", "dew", "dust", "field", "fire", "flower"]
      , number = Math.floor(Math.random()*100)
      , name = adjs[Math.floor(Math.random()*(adjs.length-1))]+"-"+nouns[Math.floor(Math.random()*(nouns.length-1))]+"-"+number
      $rootScope.identifier = name
      segmentio.identify(name)
    }

    segmentio.track('Landed on the homepage')

    // When returning to the home page from an object page, scroll to
    // that object.
    $rootScope.$watch('loaded', function(val) {
      if(val && $rootScope.lastObjectId) {
        var lastObjContainer = $('a[href*='+$rootScope.lastObjectId+']').parent()
        lastObjContainer && lastObjContainer[0].scrollIntoView()
      }
    })

    if(typeof $rootScope.showSplash == 'undefined') $rootScope.showSplash = true
    $scope.closeSplashScreen = function() {
      $rootScope.showSplash = false
    }
  }
])
<commit_msg>Revert "(temporarily) hide new TDX japan"<commit_after>/**
 * Controller for cover page (index template).
 */

app.controller('mainCtrl', ['$scope', '$routeParams', 'segmentio', '$rootScope', '$timeout', 'orderByFilter', 'miaThumbnailAdapter', '$sce', 'resolvedNotes', 'initIsotope', '$location',
  function($scope, $routeParams, segmentio, $rootScope, $timeout, orderByFilter, thumbnailAdapter, $sce, notes, initIsotope, $location) {
    var dc = $rootScope.defaultCluster
    if(dc && dc !== 'highlights') $location.path('/clusters/'+$rootScope.defaultCluster)

    var data = $scope.data = notes
    $rootScope.loaded = false

    var cluster = $rootScope.defaultCluster || $routeParams.cluster || 'highlights'
    var clusterObjectIds = data.clusters[cluster.replace(/^(g)?(\d+)/i, '$1$2')]
    if(clusterObjectIds) {
      $scope.cluster = $rootScope.defaultCluster = cluster
      $scope.isGallery = cluster.match(/^G\d/i)
      $scope.gallery = $scope.cluster.replace('G', '')
      $rootScope.showingCluster = $scope.showingCluster =
        (typeof $rootScope.showingCluster === 'undefined') ? true : $rootScope.showingCluster
      if(!$rootScope.clusterObjects) {
        $scope.clusterObjects = clusterObjectIds.map(function(objectId) {
          var isStory = objectId.match && objectId.match(/stories\/(\d+)/)
          if(isStory) return data.stories[isStory[1]]
          return data.objects[objectId]
        }).filter(function(o) { return o })
        var startPanels = addPanelsToClusterObjects()
        $rootScope.clusterObjects = $scope.clusterObjects = orderByFilter($scope.clusterObjects, random)
        startPanels.map(function(p) { $scope.clusterObjects.unshift(p) })

        $rootScope.otherObjects = $scope.otherObjects = $rootScope.otherObjects = loadAllObjects()
      } else {
        $scope.clusterObjects = $rootScope.clusterObjects
        $scope.otherObjects = $rootScope.otherObjects
      }
    } else { // not a valid cluster
      $location.path('/')
    }

    $scope.toggleSeeAll = function() {
      var container = $('.cover-wrapper')[0]
      if($scope.showingCluster) $timeout(function() { container.scrollLeft = container.scrollWidth-window.innerWidth }, 0)
      $scope.loading = true
      $rootScope.showingCluster = $scope.showingCluster = !$scope.showingCluster

      $timeout(function() {
        $timeout(initIsotope, 0)
        $scope.loading = false
      }, 0)
    }

    // Maintain the random order of the cluster objects, and add all the others
    // in random order. Then any 'end' panels.
    function loadAllObjects() {
      var c = $scope.clusterObjects
      var others = []

      angular.forEach(data.objects, function(o) {
        (c.indexOf(o) > -1) || others.push(o)
      })
      others = orderByFilter(others, random)

      angular.forEach(data.panels, function(p) {
        if(c.indexOf(p) == -1 && p.position == 'end') others.push(p)
      })

      return others
      return angular.copy(c).map(function(o) {
        // angular.copy and $sce.trust don't work together. this prevents an sce.unsafe
        if(o.recordType == 'panel') o.trustedContent = $sce.trustAsHtml(o.content)
        return o
      }).concat(others)
    }

    // Add the panels that should be randomized to `clusterObjects` and
    // return the panels that need to be at the beginning so they can be
    // `unshifted` after randomization happens
    // TODO: should panels go into the cluster objects or the other objects?
    function addPanelsToClusterObjects() {
      var panels = []
      angular.forEach(data.panels, function(p) { panels.push(p) })
      panels.filter(function(p) { return p.position == 'random' })
        .map(function(p) { $scope.clusterObjects.push(p) })
      return panels.filter(function(p) { return p.position == 'start' })
    }

    $rootScope.nextView = undefined

    $timeout(initIsotope, 0)

    function random() { return 0.5 - Math.random() }

    if(!$rootScope.identifier) {
      var adjs = ["autumn", "hidden", "bitter", "misty", "silent", "empty", "dry",
        "dark", "summer", "icy", "delicate", "quiet", "white", "cool", "spring",
        "patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue"]
      , nouns = ["waterfall", "river", "breeze", "moon", "rain", "wind", "sea",
        "morning", "snow", "lake", "sunset", "pine", "shadow", "leaf", "dawn",
        "glitter", "forest", "hill", "cloud", "meadow", "sun", "glade", "bird",
        "brook", "butterfly", "bush", "dew", "dust", "field", "fire", "flower"]
      , number = Math.floor(Math.random()*100)
      , name = adjs[Math.floor(Math.random()*(adjs.length-1))]+"-"+nouns[Math.floor(Math.random()*(nouns.length-1))]+"-"+number
      $rootScope.identifier = name
      segmentio.identify(name)
    }

    segmentio.track('Landed on the homepage')

    // When returning to the home page from an object page, scroll to
    // that object.
    $rootScope.$watch('loaded', function(val) {
      if(val && $rootScope.lastObjectId) {
        var lastObjContainer = $('a[href*='+$rootScope.lastObjectId+']').parent()
        lastObjContainer && lastObjContainer[0].scrollIntoView()
      }
    })

    if(typeof $rootScope.showSplash == 'undefined') $rootScope.showSplash = true
    $scope.closeSplashScreen = function() {
      $rootScope.showSplash = false
    }
  }
])
<|endoftext|>


<commit_before>/**
* Main AngularJS Web Application
*/
var app = angular.module('tutorialWebApp', [
'ngRoute'
]);

/**
* Configure the Routes
*/
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
// Home
.when("/", {templateUrl: "partials/home.html", controller: "PageCtrl"})
// Pages
.when("/about", {templateUrl: "partials/about.html", controller: "PageCtrl"})
.when("/faq", {templateUrl: "partials/faq.html", controller: "PageCtrl"})
/* etc… routes to other pages… */
// Blog
.when("/blog", {templateUrl: "partials/blog.html", controller: "BlogCtrl"})
.when("/blog/post", {templateUrl: "partials/blog_item.html", controller: "BlogCtrl"})
// else 404
.otherwise("/404", {templateUrl: "partials/404.html", controller: "PageCtrl"});
}]);
<commit_msg>Update main.js<commit_after>/**
* Main AngularJS Web Application
*/
var app = angular.module('tutorialWebApp', [
'ngRoute'
]);

/**
* Configure the Routes
*/
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
// Home
.when("/", {templateUrl: "partials/home.html", controller: "PageCtrl"})
// Pages
.when("/about", {templateUrl: "partials/about.html", controller: "PageCtrl"})
.when("/faq", {templateUrl: "partials/faq.html", controller: "PageCtrl"})
/* etc… routes to other pages… */
// Blog
.when("/blog", {templateUrl: "partials/blog.html", controller: "BlogCtrl"})
.when("/blog/post", {templateUrl: "partials/blog_item.html", controller: "BlogCtrl"})
// else 404
.otherwise("/404", {templateUrl: "partials/404.html", controller: "PageCtrl"});
}]);
markup/**
* Controls the Blog
*/
app.controller('BlogCtrl', function (/* $scope, $location, $http */) {
console.log("Blog Controller reporting for duty.");
});

/**
* Controls all other Pages
*/
app.controller('PageCtrl', function (/* $scope, $location, $http */) {
console.log("Page Controller reporting for duty.");

// Activates the Carousel
$('.carousel').carousel({
interval: 5000
});

// Activates Tooltips for Social Links
$('.tooltip-social').tooltip({
selector: "a[data-toggle=tooltip]"
})
<|endoftext|>


<commit_before>/*   RSence
 *   Copyright 2006 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
  * The extended object model.
  *
  * HClass is the foundation class of all other classes. It implements
  * a proper object oriented environment in Javascript. It supports
  * inheritance (HClass.extend), superclass invocation ( this.base ),
  * interfaces (HClass.implement) and such.
  *
  * It's derived from and backwards compatible with  Dean Edward's Base.js,
  * so you can mix and match code written against Base.js.
  *
  * It is intended for the following main purposes:
  *   * To easily create classes without the MyClass.prototype cruft
  *   * Method overriding with intuitive access to the overridden method (like Ruby's super)
  *   * To avoid calling a class' constructor function during the prototyping phase
  *   * To easily add static (class) properties and methods
  *   * To achieve the above without resorting to global functions to build prototype chains
  *   * To achieve the above without affecting Object.prototype
  *
  * The HClass class extends the 'Object' object by adding one instance method (base)
  * and two class methods (extend, implement). Instance method extend can be also called directly.
  *
  * == Example:
  *    MyClass = HClass.extend({
  *      constructor: function( foo ){
  *        this.setFoo( foo );
  *      },
  *      setFoo: function( foo ){
  *        this.foo = foo;
  *      }
  *    });
  *
  *    myClassInstance1 = MyClass.nu( 'rabbids' );
  *    myClassInstance2 = new MyClass( 'ribbit' );
  *
  *    MyEqualsClass = MyClass.extend({
  *      testFoo: function( that ){
  *        return this.foo === that.foo;
  *      }
  *    });
  *    myEqualsClassInstance1 = MyEqualsClass.nu( 'woof' );
  *    equals1 = myEqualsClassInstance1.testFoo( myClassIntance1 );
  *    myClassInstance2.setFoo( myEqualsClassInstance1.foo );
  *    equals2 = myEqualsClassInstance1.testFoo( myClassIntance2 );
  *
  **/
var//RSence.Core
HClass = function() {
  if ( arguments.length ) {
    if (this === window) {
      HClass.prototype.extend.call( arguments[0], arguments.callee.prototype );
    }
    else {
      this.extend( arguments[0] );
    }
  }
};

HClass.prototype = {

 /* The property copying method. */
  extend: function(_source, _value) {
    var _extend = HClass.prototype.extend,
        _ancestor, _method, _returnValue, i, _name, _prototype, _protected;
    if (arguments.length === 2) {
      _ancestor = this[_source];
      // only methods are inherited
      if ((_ancestor instanceof Function) && (_value instanceof Function) &&
          _ancestor.valueOf() !== _value.valueOf() && (/\bbase\b/).test(_value)) {
        _method = _value;
        _value = function() {
          // saves the this.base that is the this.base method of this child
          var _previous = this.base;
          // copies previous this.base from the direction from HClass
          this.base = _ancestor;
          // current class's method is called
          // now inside the function when called this.base points to parent method
          _returnValue = _method.apply(this, arguments);
          // then because event this function can be called from child method
          // resets the base to as is was before calling this function
          this.base = _previous;
          return _returnValue;
        };
        _value.valueOf = function() {
          return _method;
        };
        _value.toString = function() {
          return String(_method);
        };
      }
      return this[_source] = _value;
    // this is called when called by HClass.extend
    } else if (_source) {
      _prototype = {toSource: null};
      _protected = ["toString", "valueOf"];
      // we want default constructor function
      if (HClass._prototyping) {
        // 3. index
        _protected.push("constructor");
      }
      for (i = 0; (_name = _protected[i]); i++) {
        if (_source[_name] !== _prototype[_name]) {
          _extend.call(this, _name, _source[_name]);
        }
      }
      for (_name in _source) {
        if (!_prototype[_name]) {
          _extend.call(this, _name, _source[_name]);
        }
      }
    }

    // alternative constructor (use instead of the new keywoard)
    this.nu = function() {
      return new (
        this.extend( {
          constructor: function( args ){
            this.base.apply( this, args );
          }
        } )
      )( arguments );
    };
    this['new'] = this.nu;
    return this;
  },
  /** = Description
    * If a method has been overridden then the base method provides access to the overridden method.
    * Call this method from any other method to invoke that method's ancestor.
    * It is also possible to call the base method from within a constructor function.
    *
    **/
  base: function() {
    // this method can be called from any other method to invoke that method's parent
  }
};

/** = Description
  * The class method method to create a new extended class.
  *
  * If the method name constructor is defined null as the +_instance+ parameter,
  * it will return a single instance.
  *
  * = Parameters:
  * +_instance+:: An object that has properties and methods of inherited class.
  * +_static+::   An object that has properties and methods of inherited class's
  *               class methods if the method named constructor is defined null
  *               in _instance parameter.
  *
  * = Returns:
  *   Returns the extended class object.
  *
  * = Usage:
  *   Point = HClass.extend({
  *   constructor: function(x, y) {
  *     this.x = x;
  *     this.y = y;
  *   }
  *   });
  *   Rectangle = Point.extend({
  *   constructor: function(x, y, width, height) {
  *     this.base(x, y);
  *     this.width = width;
  *     this.height = height;
  *   },
  *   getWidth: function() {
  *     return this.width;
  *   },
  *   getHeight: function() {
  *     return this.height;
  *   }
  *   },
  *   {
  *   // class methods
  *   description: "this is a Rectangle",
  *   getClass: function() {
  *     return this;
  *   }
  *   });
  *
  **/
HClass.extend = function(_instance, _static) {
  // reference to HClass's prototype extend method (HClass's class structure extend method)
  var _extend = HClass.prototype.extend,
      _prototype, _constructor, _klass, _object;
  // if _instance is undefined,null,"" etc. creates object so that code below works
  if (!_instance) {
    _instance = {};
  }
  HClass._prototyping = true;
  // this is base for single instance or prototype (class structure) for object that are created
  // from this class
  _prototype = new this;
  // copies properties and methods from _instance to _prototype (class structure)
  _extend.call(_prototype, _instance);
  // this constructor came from _instance
  _constructor = _prototype.constructor;
  _prototype.constructor = this;
  delete HClass._prototyping;

  _klass = function() {
    if (!HClass._prototyping) {
      _constructor.apply(this, arguments);
    }
    this.constructor = _klass;
  };
  // this is the new class's prototype (class structure)
  _klass.prototype = _prototype;
  // copies static method (class method)
  // acts like HClass.extend
  _klass.extend = this.extend;
  // copies static method (class method)
  // acts like HClass.implement
  _klass.implement = this.implement;
  _klass.toString = function() {
    return String(_constructor);
  };
  // copies properties and methods from _static directly to statc methods (class methods)
  // of new class
  _extend.call(_klass, _static);
  // if _constructor is marked as null returns the created instance (that is also class structure for
  // instances if class is returned
  _object = (_constructor !== null) ? _klass : _prototype;
  if (_object.init instanceof Function) {
    _object.init();
  }
  return _object;
};

/** = Description
  * Copies the prototype properties and methods from _interface or if it is an object it's properties and functions
  * to HClass or class inherited from HClass. Mimics the interface behaviour of ordinary programming languages.
  *
  * = Usage:
  * Defines an interface:
  *
  *  AreaInterface = HClass.extend({
  *  constructor: null,
  *    // implement
  *    // don't define here
  *    //getWidth: function() {},
  *    //getHeight: function() {},
  *  area: function() {
  *    return this.getWidth() * this.getHeight();
  *  }
  *  });
  *
  *  Rectangle = HClass.extend({
  *  constructor: function(x, y, width, height) {
  *    this.x = x;
  *    this.y = y;
  *    this.width = width;
  *    this.height = height;
  *  },
  *  getWidth: function() {
  *    return this.width;
  *  },
  *  getHeight: function() {
  *    return this.height;
  *  }
  *  });
  *
  *  Rectangle.implement(AreaInterface);
  *
  **/
HClass.implement = function(_interface) {
  // copies prototype fields and methods (class structures properties and methods)
  if (_interface instanceof Function) {
    _interface = _interface.prototype;
  }
  this.prototype.extend(_interface);
};

//var Base = HClass;

// Array fix
if ([]['indexOf']===undefined) {
  // Object.extend = function(_destination, _source) {
  //   for (var _property in _source) {
  //     _destination[_property] = _source[_property];
  //   }
  //   return _destination;
  // };
  // Object.extend(Array.prototype, {
  Array.prototype.indexOf = function(_anObject){
    var i = 0, l = this.length;
    for (; i < l; i++) {
      if (this[i] === _anObject) {
        return i;
      }
    }
    return -1;
  };
}

// ff version 3.0.3 fails on this, when firebug installed: try/catch block
try {

// console.log surrogate for browsers without a console
if(window['console']===undefined){
  window.console = {
    log: function(){
    }
  };
}

} catch(e) {}

<commit_msg>Added an ancestors array and hasAncestors method to test for inheritance. Works both on the class as well as its instance.<commit_after>/*   RSence
 *   Copyright 2006 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
  * The extended object model.
  *
  * HClass is the foundation class of all other classes. It implements
  * a proper object oriented environment in Javascript. It supports
  * inheritance (HClass.extend), superclass invocation ( this.base ),
  * interfaces (HClass.implement) and such.
  *
  * It's derived from and backwards compatible with  Dean Edward's Base.js,
  * so you can mix and match code written against Base.js.
  *
  * It is intended for the following main purposes:
  *   * To easily create classes without the MyClass.prototype cruft
  *   * Method overriding with intuitive access to the overridden method (like Ruby's super)
  *   * To avoid calling a class' constructor function during the prototyping phase
  *   * To easily add static (class) properties and methods
  *   * To achieve the above without resorting to global functions to build prototype chains
  *   * To achieve the above without affecting Object.prototype
  *
  * The HClass class extends the 'Object' object by adding one instance method (base)
  * and two class methods (extend, implement). Instance method extend can be also called directly.
  *
  * == Example:
  *    MyClass = HClass.extend({
  *      constructor: function( foo ){
  *        this.setFoo( foo );
  *      },
  *      setFoo: function( foo ){
  *        this.foo = foo;
  *      }
  *    });
  *
  *    myClassInstance1 = MyClass.nu( 'rabbids' );
  *    myClassInstance2 = new MyClass( 'ribbit' );
  *
  *    MyEqualsClass = MyClass.extend({
  *      testFoo: function( that ){
  *        return this.foo === that.foo;
  *      }
  *    });
  *    myEqualsClassInstance1 = MyEqualsClass.nu( 'woof' );
  *    equals1 = myEqualsClassInstance1.testFoo( myClassIntance1 );
  *    myClassInstance2.setFoo( myEqualsClassInstance1.foo );
  *    equals2 = myEqualsClassInstance1.testFoo( myClassIntance2 );
  *
  **/
var//RSence.Core
HClass = function() {
  if ( arguments.length ) {
    if (this === window) {
      HClass.prototype.extend.call( arguments[0], arguments.callee.prototype );
    }
    else {
      this.extend( arguments[0] );
    }
  }
};

HClass.prototype = {

 /* The property copying method. */
  extend: function(_source, _value) {
    var _extend = HClass.prototype.extend,
        _ancestor, _method, _returnValue, i, _name, _prototype, _protected;
    if (arguments.length === 2) {
      _ancestor = this[_source];
      // only methods are inherited
      if ((_ancestor instanceof Function) && (_value instanceof Function) &&
          _ancestor.valueOf() !== _value.valueOf() && (/\bbase\b/).test(_value)) {
        _method = _value;
        _value = function() {
          // saves the this.base that is the this.base method of this child
          var _previous = this.base;
          // copies previous this.base from the direction from HClass
          this.base = _ancestor;
          // current class's method is called
          // now inside the function when called this.base points to parent method
          _returnValue = _method.apply(this, arguments);
          // then because event this function can be called from child method
          // resets the base to as is was before calling this function
          this.base = _previous;
          return _returnValue;
        };
        _value.valueOf = function() {
          return _method;
        };
        _value.toString = function() {
          return String(_method);
        };
      }
      return this[_source] = _value;
    // this is called when called by HClass.extend
    } else if (_source) {
      _prototype = {toSource: null};
      _protected = ["toString", "valueOf"];
      // we want default constructor function
      if (HClass._prototyping) {
        // 3. index
        _protected.push("constructor");
      }
      for (i = 0; (_name = _protected[i]); i++) {
        if (_source[_name] !== _prototype[_name]) {
          _extend.call(this, _name, _source[_name]);
        }
      }
      for (_name in _source) {
        if (!_prototype[_name]) {
          _extend.call(this, _name, _source[_name]);
        }
      }
    }

    // alternative constructor (use instead of the new keywoard)
    this.nu = function() {
      return new (
        this.extend( {
          constructor: function( args ){
            this.base.apply( this, args );
          }
        } )
      )( arguments );
    };
    this.hasAncestor = function( _obj ){
      return this.ancestors.indexOf( _obj ) !== -1;
    };
    this['new'] = this.nu;
    return this;
  },
  /** = Description
    * If a method has been overridden then the base method provides access to the overridden method.
    * Call this method from any other method to invoke that method's ancestor.
    * It is also possible to call the base method from within a constructor function.
    *
    **/
  base: function() {
    // this method can be called from any other method to invoke that method's parent
  }
};

/** = Description
  * The class method method to create a new extended class.
  *
  * If the method name constructor is defined null as the +_instance+ parameter,
  * it will return a single instance.
  *
  * = Parameters:
  * +_instance+:: An object that has properties and methods of inherited class.
  * +_static+::   An object that has properties and methods of inherited class's
  *               class methods if the method named constructor is defined null
  *               in _instance parameter.
  *
  * = Returns:
  *   Returns the extended class object.
  *
  * = Usage:
  *   Point = HClass.extend({
  *   constructor: function(x, y) {
  *     this.x = x;
  *     this.y = y;
  *   }
  *   });
  *   Rectangle = Point.extend({
  *   constructor: function(x, y, width, height) {
  *     this.base(x, y);
  *     this.width = width;
  *     this.height = height;
  *   },
  *   getWidth: function() {
  *     return this.width;
  *   },
  *   getHeight: function() {
  *     return this.height;
  *   }
  *   },
  *   {
  *   // class methods
  *   description: "this is a Rectangle",
  *   getClass: function() {
  *     return this;
  *   }
  *   });
  *
  **/
HClass.extend = function(_instance, _static) {
  // reference to HClass's prototype extend method (HClass's class structure extend method)
  var _extend = HClass.prototype.extend,
      _prototype, _constructor, _klass, _object,
      _ancestors, i=0;
  // if _instance is undefined,null,"" etc. creates object so that code below works
  if (!_instance) {
    _instance = {};
  }
  HClass._prototyping = true;
  // this is base for single instance or prototype (class structure) for object that are created
  // from this class
  _prototype = new this;
  // copies properties and methods from _instance to _prototype (class structure)
  _extend.call(_prototype, _instance);
  // this constructor came from _instance
  _constructor = _prototype.constructor;
  _prototype.constructor = this;
  delete HClass._prototyping;

  _ancestors = [];
  _klass = function() {
    if (!HClass._prototyping) {
      _constructor.apply(this, arguments);
    }
    this.constructor = _klass;
    this.ancestors = _ancestors;
  };
  // this is the new class's prototype (class structure)
  _klass.prototype = _prototype;
  // copies static method (class method)
  // acts like HClass.extend
  _klass.extend = this.extend;
  // copies static method (class method)
  // acts like HClass.implement
  _klass.implement = this.implement;
  _klass.toString = function() {
    return String(_constructor);
  };
  // copies properties and methods from _static directly to statc methods (class methods)
  // of new class
  _extend.call(_klass, _static);
  // if _constructor is marked as null returns the created instance (that is also class structure for
  // instances if class is returned
  _object = (_constructor !== null) ? _klass : _prototype;
  if (_object.init instanceof Function) {
    _object.init();
  }
  _ancestors.push( _object );
  for( ; i < this.ancestors.length; i++ ){
    _ancestors.push( this.ancestors[i] );
  }
  _object.ancestors = _ancestors;
  return _object;
};
HClass.ancestors = [ HClass ];

/** = Description
  * Copies the prototype properties and methods from _interface or if it is an object it's properties and functions
  * to HClass or class inherited from HClass. Mimics the interface behaviour of ordinary programming languages.
  *
  * = Usage:
  * Defines an interface:
  *
  *  AreaInterface = HClass.extend({
  *  constructor: null,
  *    // implement
  *    // don't define here
  *    //getWidth: function() {},
  *    //getHeight: function() {},
  *  area: function() {
  *    return this.getWidth() * this.getHeight();
  *  }
  *  });
  *
  *  Rectangle = HClass.extend({
  *  constructor: function(x, y, width, height) {
  *    this.x = x;
  *    this.y = y;
  *    this.width = width;
  *    this.height = height;
  *  },
  *  getWidth: function() {
  *    return this.width;
  *  },
  *  getHeight: function() {
  *    return this.height;
  *  }
  *  });
  *
  *  Rectangle.implement(AreaInterface);
  *
  **/
HClass.implement = function(_interface) {
  // copies prototype fields and methods (class structures properties and methods)
  if (_interface instanceof Function) {
    _interface = _interface.prototype;
  }
  this.prototype.extend(_interface);
};

//var Base = HClass;

// Array fix
if ([]['indexOf']===undefined) {
  // Object.extend = function(_destination, _source) {
  //   for (var _property in _source) {
  //     _destination[_property] = _source[_property];
  //   }
  //   return _destination;
  // };
  // Object.extend(Array.prototype, {
  Array.prototype.indexOf = function(_anObject){
    var i = 0, l = this.length;
    for (; i < l; i++) {
      if (this[i] === _anObject) {
        return i;
      }
    }
    return -1;
  };
}

// ff version 3.0.3 fails on this, when firebug installed: try/catch block
try {

// console.log surrogate for browsers without a console
if(window['console']===undefined){
  window.console = {
    log: function(){
    }
  };
}

} catch(e) {}

<|endoftext|>


<commit_before>var easyPeasyParallax = function () {
	var scrollPos = $(this).scrollTop();

	$('#header .info').css({
		'-webkit-transform': 'translate3d(0px, ' + (scrollPos) + 'px, 0px)',
		'-ms-transform': 'translate3d(0px, ' + (scrollPos) + 'px, 0px)',
		'transform': 'translate3d(0px, ' + (scrollPos) + 'px, 0px)',
		'opacity': 1-(scrollPos/250)
	});
}

var removeTransform = function (item) {
	item.css({
		'-webkit-transform': 'translate3d(0px, 0px, 0px)',
		'-ms-transform': 'translate3d(0px, 0px, 0px)',
		'transform': 'translate3d(0px, 0px, 0px)'
	});
}

var easyPeasyNav = function () {
	var scrollPos = $(this).scrollTop();
	var header = $('#header');
	var offCanvas = $('#off-canvas');

	if(scrollPos >= header.height() + 1) {
		offCanvas.addClass('visible');
	} else {
		offCanvas.removeClass('visible');
	}
}

var centerModal = function () {
	var modal = $('#modal .holder');

	modal.css({
		'margin-top': -(modal.height()/2) +'px'
	});
}

var centerArrow = function (elem) {
	var containerWidth = $('#about .container').width();

	$('#member-nav a').removeClass('active');
	elem.addClass('active');

	$('#member-list ul').removeClass('active');
	$('#member-list ul').eq(parseInt(elem.parent().index()) - 1).addClass('active');

	var itemWidth = elem.width() / 2;
	var thisPos = elem.position();
}

$(document).ready(function() {
	// center modal window
	$(window).resize(function() {
		centerModal();
	});

	// do parallax for top title
	$(window).scroll(function() {
		if($(window).width() >= 690) easyPeasyParallax();
		easyPeasyNav();
	});

	// fetch one tweet
	// var tweetConfig = {
	//	"id": '558200865941909504',
	//	"domId": 'twitter-feed',
	//	"maxTweets": 3,
	//	"enableLinks": true
	// };
	// twitterFetcher.fetch(tweetConfig);

	// get flickr
	// var flickrURL = "http://api.flickr.com/services/feeds/photos_public.gne?ids=128548450@N05&format=json&jsoncallback=?";
	// $.getJSON(flickrURL, function(data){
	//	var imageCollection = "";
	//
	//	imageCollection += '
';
	//	for (var item in data.items) {
	//		if(item == 16) break;
	//
	//		var width = data.items[item].description.match(/width=["']([0-9]+)["']/)[1];
	//		var height = data.items[item].description.match(/height=["']([0-9]+)["']/)[1];
	//
	//		if(height > width) continue;
	//		imageCollection += '

';
	//	}
	//	imageCollection += '
';

	//	$("#flickr-feed").append(imageCollection);
	// });

	// digest subscription
	$('#subscription form').submit(function(e) {
		e.preventDefault();
		var email = $('#subscription input[name=email]').val();
  		var subscribers = new Firebase('https://radiant-fire-3288.firebaseio.com/subscribers');

		var subForm = $('#subscription'),
			subError = subForm.find('.error'),
			subSuccess = subForm.find('.success');

		subscribers.push(email, function(error) {
		  if (error) {
			subError.addClass('active');
			subSuccess.removeClass('active');
		  } else {
			subError.removeClass('active');
			subSuccess.addClass('active');
		  }
		});

	});
	$('#subscription a').click(function() {
	    $(this).parents('.success, .error').removeClass('active');
	});

	// open close reserve seat
	var modal = $('#modal');
	$('#reserve-seat').click(function(e) {
		e.preventDefault();
		modal.addClass("open");
		centerModal();
	});
	modal.click(function() {
		modal.removeClass("open");
	});

	// open/close off-canvas
	$('#off-canvas a.open').click(function(e) {
		e.preventDefault();

	    $(this).parent().toggleClass('active');
	});
	$('#off-canvas ul a, .logo a, .scroll-button, .scroll-arrow').click(function(e) {
		var $this = $(this);
		if($this.hasClass('network')) return;

	    var href = $(this).attr('href');

	    if(href === "#events") {
	    	$(href).animatescroll();
	    } else {
	    	$(href).animatescroll({padding: 100});
	    }

	    return false;
	});

	// google map
	var overlay;
	function initialize() {
	    // var myLatLng = new google.maps.LatLng(56.959081,24.114304); // Microsoft
		// var myLatLng = new google.maps.LatLng(56.9550172,24.1000566); // Visma
	    var myLatLng = new google.maps.LatLng(56.9536058,24.0977563); // Citadele

	    var mapOptions = {
	        zoom: 15,
	        center: myLatLng,
	        mapTypeId: google.maps.MapTypeId.ROADMAP,
			disableDefaultUI: true,
			scrollwheel: false,
		    clickable: false,
		    draggable: false,
		    styles: [{"featureType":"all","elementType":"labels","stylers":[{"visibility":"on"}]},{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":"20"},{"gamma":"1.04"},{"saturation":"0"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.highway","elementType":"labels","stylers":[{"visibility":"off"},{"lightness":"-64"},{"saturation":"-100"}]},{"featureType":"road.highway","elementType":"labels.icon","stylers":[{"visibility":"on"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":"17"}]},{"featureType":"road.arterial","elementType":"geometry.stroke","stylers":[{"visibility":"on"}]},{"featureType":"road.arterial","elementType":"labels","stylers":[{"weight":"2.12"},{"visibility":"on"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":"18"},{"visibility":"on"},{"weight":"2.17"}]},{"featureType":"road.local","elementType":"geometry.stroke","stylers":[{"visibility":"off"},{"lightness":"-32"}]},{"featureType":"road.local","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#282529"},{"saturation":"-49"},{"lightness":"-9"}]}]
	    };

	    var gmap = new google.maps.Map(document.getElementById('map'), mapOptions);

	    var beachMarker = new google.maps.Marker({
			position: myLatLng,
			map: gmap,
			icon: "img/marker.png"
		});

	}

	google.maps.event.addDomListener(window, 'load', initialize);
});
<commit_msg>updated coordinates<commit_after>var easyPeasyParallax = function () {
	var scrollPos = $(this).scrollTop();

	$('#header .info').css({
		'-webkit-transform': 'translate3d(0px, ' + (scrollPos) + 'px, 0px)',
		'-ms-transform': 'translate3d(0px, ' + (scrollPos) + 'px, 0px)',
		'transform': 'translate3d(0px, ' + (scrollPos) + 'px, 0px)',
		'opacity': 1-(scrollPos/250)
	});
}

var removeTransform = function (item) {
	item.css({
		'-webkit-transform': 'translate3d(0px, 0px, 0px)',
		'-ms-transform': 'translate3d(0px, 0px, 0px)',
		'transform': 'translate3d(0px, 0px, 0px)'
	});
}

var easyPeasyNav = function () {
	var scrollPos = $(this).scrollTop();
	var header = $('#header');
	var offCanvas = $('#off-canvas');

	if(scrollPos >= header.height() + 1) {
		offCanvas.addClass('visible');
	} else {
		offCanvas.removeClass('visible');
	}
}

var centerModal = function () {
	var modal = $('#modal .holder');

	modal.css({
		'margin-top': -(modal.height()/2) +'px'
	});
}

var centerArrow = function (elem) {
	var containerWidth = $('#about .container').width();

	$('#member-nav a').removeClass('active');
	elem.addClass('active');

	$('#member-list ul').removeClass('active');
	$('#member-list ul').eq(parseInt(elem.parent().index()) - 1).addClass('active');

	var itemWidth = elem.width() / 2;
	var thisPos = elem.position();
}

$(document).ready(function() {
	// center modal window
	$(window).resize(function() {
		centerModal();
	});

	// do parallax for top title
	$(window).scroll(function() {
		if($(window).width() >= 690) easyPeasyParallax();
		easyPeasyNav();
	});

	// fetch one tweet
	// var tweetConfig = {
	//	"id": '558200865941909504',
	//	"domId": 'twitter-feed',
	//	"maxTweets": 3,
	//	"enableLinks": true
	// };
	// twitterFetcher.fetch(tweetConfig);

	// get flickr
	// var flickrURL = "http://api.flickr.com/services/feeds/photos_public.gne?ids=128548450@N05&format=json&jsoncallback=?";
	// $.getJSON(flickrURL, function(data){
	//	var imageCollection = "";
	//
	//	imageCollection += '
';
	//	for (var item in data.items) {
	//		if(item == 16) break;
	//
	//		var width = data.items[item].description.match(/width=["']([0-9]+)["']/)[1];
	//		var height = data.items[item].description.match(/height=["']([0-9]+)["']/)[1];
	//
	//		if(height > width) continue;
	//		imageCollection += '

';
	//	}
	//	imageCollection += '
';

	//	$("#flickr-feed").append(imageCollection);
	// });

	// digest subscription
	$('#subscription form').submit(function(e) {
		e.preventDefault();
		var email = $('#subscription input[name=email]').val();
  		var subscribers = new Firebase('https://radiant-fire-3288.firebaseio.com/subscribers');

		var subForm = $('#subscription'),
			subError = subForm.find('.error'),
			subSuccess = subForm.find('.success');

		subscribers.push(email, function(error) {
		  if (error) {
			subError.addClass('active');
			subSuccess.removeClass('active');
		  } else {
			subError.removeClass('active');
			subSuccess.addClass('active');
		  }
		});

	});
	$('#subscription a').click(function() {
	    $(this).parents('.success, .error').removeClass('active');
	});

	// open close reserve seat
	var modal = $('#modal');
	$('#reserve-seat').click(function(e) {
		e.preventDefault();
		modal.addClass("open");
		centerModal();
	});
	modal.click(function() {
		modal.removeClass("open");
	});

	// open/close off-canvas
	$('#off-canvas a.open').click(function(e) {
		e.preventDefault();

	    $(this).parent().toggleClass('active');
	});
	$('#off-canvas ul a, .logo a, .scroll-button, .scroll-arrow').click(function(e) {
		var $this = $(this);
		if($this.hasClass('network')) return;

	    var href = $(this).attr('href');

	    if(href === "#events") {
	    	$(href).animatescroll();
	    } else {
	    	$(href).animatescroll({padding: 100});
	    }

	    return false;
	});

	// google map
	var overlay;
	function initialize() {
	    // var myLatLng = new google.maps.LatLng(56.959081,24.114304); // Microsoft
		// var myLatLng = new google.maps.LatLng(56.9550172,24.1000566); // Visma
	    var myLatLng = new google.maps.LatLng(56.9536087,24.0977563); // Citadele

	    var mapOptions = {
	        zoom: 15,
	        center: myLatLng,
	        mapTypeId: google.maps.MapTypeId.ROADMAP,
			disableDefaultUI: true,
			scrollwheel: false,
		    clickable: false,
		    draggable: false,
		    styles: [{"featureType":"all","elementType":"labels","stylers":[{"visibility":"on"}]},{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":"20"},{"gamma":"1.04"},{"saturation":"0"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.highway","elementType":"labels","stylers":[{"visibility":"off"},{"lightness":"-64"},{"saturation":"-100"}]},{"featureType":"road.highway","elementType":"labels.icon","stylers":[{"visibility":"on"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":"17"}]},{"featureType":"road.arterial","elementType":"geometry.stroke","stylers":[{"visibility":"on"}]},{"featureType":"road.arterial","elementType":"labels","stylers":[{"weight":"2.12"},{"visibility":"on"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":"18"},{"visibility":"on"},{"weight":"2.17"}]},{"featureType":"road.local","elementType":"geometry.stroke","stylers":[{"visibility":"off"},{"lightness":"-32"}]},{"featureType":"road.local","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#282529"},{"saturation":"-49"},{"lightness":"-9"}]}]
	    };

	    var gmap = new google.maps.Map(document.getElementById('map'), mapOptions);

	    var beachMarker = new google.maps.Marker({
			position: myLatLng,
			map: gmap,
			icon: "img/marker.png"
		});

	}

	google.maps.event.addDomListener(window, 'load', initialize);
});
<|endoftext|>