<commit_before>/*
 *  asf-list -- List helpers
 *  Copyright (C) 2012, 2013, 2014 Stephane Carrez
 *  Written by Stephane Carrez (Stephane.Carrez@gmail.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
(function($, undefined) {

    $.widget( "ui.list", $.ui.mouse, {
        currentNode: null,

        /**
         * The active or highlighted item in the list.  This is the item which has the action element
         * as last child.
         */
        activeItem: null,

        /**
         * Indicates whether the bloc is active (has the mouse focus).
         */
        isActive: false,

        /**
         * The current item
         */
        currentItem: null,

        /**
         * The current inline edit node.
         */
        currentEdit: null,
        options: {
            min: 0,

            /**
             * The CSS class that is set on active elements.
             */
            activeClass: "asf-active",

            /**
             * The CSS class that is set on the list element when it has the focus.
             */
            activeListClass: "asf-active-list",

            /**
             * The CSS class that is set on the selected element.
             */
            selectClass: "asf-selected",

            /**
             * The CSS class that indicates an element is being deleted.
             */
            deletingClass: "asf-deleting",

            /**
             * URL to edit an item of the list.
             */
            editUrl: null,

            /**
             * URL to delete an item of the list.
             */
            deleteUrl: null,

            /**
             * Relative URL to refresh the item (after edit or view mode for example).
             */
            refreshUrl: null,

            /**
             * Disable the mouseover effect.  When set to 'true', the mouseover effect implemented by
             * setting the 'active' CSS class on the item is disabled.
             */
            disableMouseover: false,

            /**
             * Prefix for item ids in the DOM tree.
             */
            itemPrefix: '',

            /**
             * A function which is called when an element of the list is selected.
             */
            selectAction: null,

            /**
             * The optional ID of a DOM element that must be re-parented under the active
             * element when the mouse is entered in the element.  This DOM element is intended to
             * contain a set of actions that a user can make on the active element.
             * The action ID must NOT start with the itemPrefix.
             */
            actionId: null
        },

        _create: function() {
            var self = this;

            $.ui.mouse.prototype._create.apply(this, arguments);
            this.element.addClass("ui-list");
            this.element.bind('click', function(event) {
                return self.click(event);
            }).bind('blur', function(event) {
                return self.blur(event);
            });
            this.setMouseOver(!this.options.disableMouseover);

            /**
             * Get the action element (a div in most cases) which contains the actions
             * to be displayed for the active/highlighted element.
             */
            this.action = $(this.options.actionId);
            if (this.options.currentItem != null) {
                this.selectAction($(this.options.currentItem));
            }
        },

        /**
         * Enable or disable the mouseover effect on the full list.
         *
         * @param status when true, enable the mouseover effect.
         */
        setMouseOver: function(status) {
            var self = this;

            if (status == true) {
                this.element.bind('mouseover', function(event) {
                    return self.mouseOver(event);
                }).bind('mouseout', function(event) {
                    return self.mouseOut(event);
                });
            } else {
                this.element.unbind('mouseover');
                this.element.unbind('mouseout');
            }
            this.mouseOverEnable = status;
        },

        /**
         * Select the list item identified by <tt>node</tt> as the current selected item.
         *
         * @param node the list item to select
         */
        selectAction: function(node, event) {
            if (this.currentItem != null) {
                $(this.currentItem).removeClass(this.options.selectClass);
            }
            this.currentItem = node;
            $(this.currentItem).addClass(this.options.selectClass);
            if (this.options.selectAction != null) {
                return this.options.selectAction(this, node, event);
            }
            return false;
        },

        /**
         * Set the active item.  The active item is marked with the 'active' class and kept as reference
         * in the 'activeItem' member.
         *
         * @param item the active item or null to disable any active item
         */
        setActiveItem: function(item) {
            if (this.activeItem != null && this.activeItem[0] != item) {
                // Ensure that previously active line is deactivated.
                this.activeItem.removeClass(this.options.activeClass);
            }
            if (item != null) {
                this.activeItem = $(item);
                this.activeItem.addClass(this.options.activeClass);
            } else {
                this.activeItem = null;
            }
        },

        /**
         * Get the object ID of the selected node.  This operation assumes that the HTML element has
         * an id of the form 'itemPrefix' + object Id.  This operation removes the item prefix.
         *
         * @param node the node element that was selected
         * @return the ID of the object
         */
        getSelectedId: function(node) {
            if (node == null) {
                return null;
            }
            var id = $(node).attr('id');
            return id == null ? null : id.substring(this.options.itemPrefix.length);
        },

        /**
         * Find the parent node that should receive the event.
         *
         */
        _getTargetNode: function(node) {
            while (node) {
                var name = node.tagName;
                if (name) {
                    name = name.toUpperCase();
                    if (name != "EM" && name != "I" && name != "B" && name != "IMG" && name != "SPAN") {
                        if (node.id && node.id != "" && this.action[0] != node) {
                            return node;
                        }
                        if (name == 'A') {
                            return node;
                        }
                    }
                }
                if (node == this.element[0]) {
                    return null;
                }

                node = node.parentNode;
            }
            return null;
        },

        /**
         * Get the item list node that contains the inner element represented by <tt>node</tt>.
         * Returns null if the node element is not part of a list item component.
         */
        getTarget: function(node) {
            if (node == this.element[0]) {
                return null;
            }
            while (node) {
                var name = node.tagName;
                if (name) {
                    name = name.toUpperCase();
                    if (name == "DIV" || name == "DL") {
                        var id = node.id;
                        if (id && id.indexOf(this.options.itemPrefix) === 0
                            && id != this.options.actionId) {
                            return node;
                        }
                    }
                }
                node = node.parentNode;
                if (node == this.element[0]) {
                    return null;
                }
            }
            /* $("#current").html(node.id); */
            return node;
        },

        /**
         * Mouse over callback invoked when the mouse over event is received on a list element.
         *
         * @param event the mouse over event
         */
        mouseOver: function(event) {
            /*
             * We want to know when a new list item is selected.  Find the list item which has the focus.
             */
            var node = this.getTarget(event.target);
            if (node && this.currentNode != node) {
                /* $("#current").html("Mover " + node.id + " Cnt=" + this.counter
                + " T=" + event.target.id); */
                this.setActiveItem(node);
                if (this.action[0]) {
                    this.action.detach();
                    this.action.prependTo(this.activeItem);
                }
                this.currentNode = node;
            }
            if (this.isActive == false) {
                this.isActive = true;
                this.element.addClass(this.options.activeListClass);
            }
        } ,

        /**
         * Mouse out callback invoked when the mouse out event is received on a list element.
         *
         * @param event the mouse out event
         */
        mouseOut: function(event) {
            if (!this.disableMouseover) {
                var node = event.target;
                while (node && node != document) {
                    if (node == this.activeItem) {
                        this.setActiveItem(null);
                        /* $("#current").html("Mouse out"  + " Cnt=" + this.counter);*/
                        break;
                    } else {
                        if (node == this.element[0]) {
                            break;
                        }
                        node = node.parentNode;
                    }
                }
                if (node && node != document) {
                    this.isActive = false;
                    this.element.removeClass(this.options.activeListClass);
                }
            }
        },

        /**
         * Get the URL to execute an AJAX operation on the given item.  Override this operation to customize
         * the URL.
         *
         * @param item the item
         * @param id the item identifier
         * @param url the relative URL
         * @return the URL to invoke an AJAX operation on the given item
         */
        getOperationUrl: function(item, id, url) {
            return url ? url + id : null;
        },

        /**
         * Enter the edit mode for the current active list element.
         */
        enterEdit: function(event) {
            var url, item = this.activeItem,
                id = this.getSelectedId(item);
            if (id) {
                url = this.getOperationUrl(item, id, this.options.editUrl);
                if (url) {
                    ASF.Update(item, url, item);
                }
            }
            return false;
        },

        /**
         * Enter delete mode for the current active element.
         * The 'deletingCss' is applied on the element being deleted.  The delete dialog box is opened
         * to confirm the deletion of our item.  The 'deletingCSS' is removed once the dialog box is closed.
         */
        enterDelete: function(event) {
            var url, css,
                item = this.activeItem,
                id   = this.getSelectedId(item);
            if (id) {
                url = this.getOperationUrl(item, id, this.options.deleteUrl);
                if (url) {
                    css = this.options.deletingClass;

                    item.addClass(css);
                    ASF.OpenDialog(item, 'deleteDialog_' + id, url, {
                        close: function() {
                            item.removeClass(css);
                        }
                    });
                }
            }
            return false;
        },
        enterCreate: function(event) {

        },

        /**
         * Click action executed when one inner HTML element is clicked.
         *
         * @param event the event that was clicked
         */
        click: function(event) {
            var name, node = this._getTargetNode(event.target);
            if (node) {

                if ($(node).hasClass("asf-edit")) {
                    this.enterEdit(event);
                } else if ($(node).hasClass("asf-delete")) {
                    this.enterDelete(event);

                } else if ($(node).hasClass("asf-editable")) {
                    if (! $(node).hasClass("asf-editing")) {
                        this.currentEdit = node;
                        $(node).addClass("asf-editing");
                        this.enterCreate(event);
                    }
                } else if (this.options.selectAction != null) {
                    return this.selectAction(node, event);
                } else {
                    return true;
                }
                return false;
            } else {
                name = event.target.tagName;
                node = event.target;

                if ($(node).hasClass("asf-edit")) {
                    this.enterEdit(event);
                } else if ($(node).hasClass("asf-delete")) {
                    this.enterDelete(event);
                }

            }
            // event.stopPropagation();
            return false;
        },
        blur: function(event) {
            if (this.currentEdit) {
                this.currentEdit.remove();
                this.currentEdit = null;
            }
        },
        destroy: function() {
            this.element.removeClass("ui-list");
            $.Widget.prototype.destroy.apply(this, arguments);
        }

    });
})( jQuery );
<commit_msg>Add some documentation<commit_after>/*
 *  asf-list -- List helpers
 *  Copyright (C) 2012, 2013, 2014 Stephane Carrez
 *  Written by Stephane Carrez (Stephane.Carrez@gmail.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/**
 * @namespace ui.list
 */
(function($, undefined) {

    /**
     * @class List management
     */
    $.widget( "ui.list", $.ui.mouse, {
        currentNode: null,

        /**
         * The active or highlighted item in the list.  This is the item which has the action element
         * as last child.
         */
        activeItem: null,

        /**
         * Indicates whether the bloc is active (has the mouse focus).
         */
        isActive: false,

        /**
         * The current item
         */
        currentItem: null,

        /**
         * The current inline edit node.
         */
        currentEdit: null,
        options: {
            min: 0,

            /**
             * The CSS class that is set on active elements.
             */
            activeClass: "asf-active",

            /**
             * The CSS class that is set on the list element when it has the focus.
             */
            activeListClass: "asf-active-list",

            /**
             * The CSS class that is set on the selected element.
             */
            selectClass: "asf-selected",

            /**
             * The CSS class that indicates an element is being deleted.
             */
            deletingClass: "asf-deleting",

            /**
             * URL to edit an item of the list.
             */
            editUrl: null,

            /**
             * URL to delete an item of the list.
             */
            deleteUrl: null,

            /**
             * Relative URL to refresh the item (after edit or view mode for example).
             */
            refreshUrl: null,

            /**
             * Disable the mouseover effect.  When set to 'true', the mouseover effect implemented by
             * setting the 'active' CSS class on the item is disabled.
             */
            disableMouseover: false,

            /**
             * Prefix for item ids in the DOM tree.
             */
            itemPrefix: '',

            /**
             * A function which is called when an element of the list is selected.
             */
            selectAction: null,

            /**
             * The optional ID of a DOM element that must be re-parented under the active
             * element when the mouse is entered in the element.  This DOM element is intended to
             * contain a set of actions that a user can make on the active element.
             * The action ID must NOT start with the itemPrefix.
             */
            actionId: null
        },

        _create: function() {
            var self = this;

            $.ui.mouse.prototype._create.apply(this, arguments);
            this.element.addClass("ui-list");
            this.element.bind('click', function(event) {
                return self.click(event);
            }).bind('blur', function(event) {
                return self.blur(event);
            });
            this.setMouseOver(!this.options.disableMouseover);

            /**
             * Get the action element (a div in most cases) which contains the actions
             * to be displayed for the active/highlighted element.
             */
            this.action = $(this.options.actionId);
            if (this.options.currentItem != null) {
                this.selectAction($(this.options.currentItem));
            }
        },

        /**
         * @name ui.list Enable or disable the mouseover effect on the full list.
         *
         * @param status when true, enable the mouseover effect.
         */
        setMouseOver: function(status) {
            var self = this;

            if (status == true) {
                this.element.bind('mouseover', function(event) {
                    return self.mouseOver(event);
                }).bind('mouseout', function(event) {
                    return self.mouseOut(event);
                });
            } else {
                this.element.unbind('mouseover');
                this.element.unbind('mouseout');
            }
            this.mouseOverEnable = status;
        },

        /**
         * Select the list item identified by <tt>node</tt> as the current selected item.
         *
         * @param node the list item to select
         */
        selectAction: function(node, event) {
            if (this.currentItem != null) {
                $(this.currentItem).removeClass(this.options.selectClass);
            }
            this.currentItem = node;
            $(this.currentItem).addClass(this.options.selectClass);
            if (this.options.selectAction != null) {
                return this.options.selectAction(this, node, event);
            }
            return false;
        },

        /**
         * Set the active item.  The active item is marked with the 'active' class and kept as reference
         * in the 'activeItem' member.
         *
         * @param item the active item or null to disable any active item
         */
        setActiveItem: function(item) {
            if (this.activeItem != null && this.activeItem[0] != item) {
                // Ensure that previously active line is deactivated.
                this.activeItem.removeClass(this.options.activeClass);
            }
            if (item != null) {
                this.activeItem = $(item);
                this.activeItem.addClass(this.options.activeClass);
            } else {
                this.activeItem = null;
            }
        },

        /**
         * Get the object ID of the selected node.  This operation assumes that the HTML element has
         * an id of the form 'itemPrefix' + object Id.  This operation removes the item prefix.
         *
         * @param node the node element that was selected
         * @return the ID of the object
         */
        getSelectedId: function(node) {
            if (node == null) {
                return null;
            }
            var id = $(node).attr('id');
            return id == null ? null : id.substring(this.options.itemPrefix.length);
        },

        /**
         * Find the parent node that should receive the event.
         *
         */
        _getTargetNode: function(node) {
            while (node) {
                var name = node.tagName;
                if (name) {
                    name = name.toUpperCase();
                    if (name != "EM" && name != "I" && name != "B" && name != "IMG" && name != "SPAN") {
                        if (node.id && node.id != "" && this.action[0] != node) {
                            return node;
                        }
                        if (name == 'A') {
                            return node;
                        }
                    }
                }
                if (node == this.element[0]) {
                    return null;
                }

                node = node.parentNode;
            }
            return null;
        },

        /**
         * Get the item list node that contains the inner element represented by <tt>node</tt>.
         * Returns null if the node element is not part of a list item component.
         */
        getTarget: function(node) {
            if (node == this.element[0]) {
                return null;
            }
            while (node) {
                var name = node.tagName;
                if (name) {
                    name = name.toUpperCase();
                    if (name == "DIV" || name == "DL") {
                        var id = node.id;
                        if (id && id.indexOf(this.options.itemPrefix) === 0
                            && id != this.options.actionId) {
                            return node;
                        }
                    }
                }
                node = node.parentNode;
                if (node == this.element[0]) {
                    return null;
                }
            }
            /* $("#current").html(node.id); */
            return node;
        },

        /**
         * Mouse over callback invoked when the mouse over event is received on a list element.
         *
         * @param event the mouse over event
         */
        mouseOver: function(event) {
            /*
             * We want to know when a new list item is selected.  Find the list item which has the focus.
             */
            var node = this.getTarget(event.target);
            if (node && this.currentNode != node) {
                /* $("#current").html("Mover " + node.id + " Cnt=" + this.counter
                + " T=" + event.target.id); */
                this.setActiveItem(node);
                if (this.action[0]) {
                    this.action.detach();
                    this.action.prependTo(this.activeItem);
                }
                this.currentNode = node;
            }
            if (this.isActive == false) {
                this.isActive = true;
                this.element.addClass(this.options.activeListClass);
            }
        } ,

        /**
         * Mouse out callback invoked when the mouse out event is received on a list element.
         *
         * @param event the mouse out event
         */
        mouseOut: function(event) {
            if (!this.disableMouseover) {
                var node = event.target;
                while (node && node != document) {
                    if (node == this.activeItem) {
                        this.setActiveItem(null);
                        /* $("#current").html("Mouse out"  + " Cnt=" + this.counter);*/
                        break;
                    } else {
                        if (node == this.element[0]) {
                            break;
                        }
                        node = node.parentNode;
                    }
                }
                if (node && node != document) {
                    this.isActive = false;
                    this.element.removeClass(this.options.activeListClass);
                }
            }
        },

        /**
         * Get the URL to execute an AJAX operation on the given item.  Override this operation to customize
         * the URL.
         *
         * @param item the item
         * @param id the item identifier
         * @param url the relative URL
         * @return the URL to invoke an AJAX operation on the given item
         */
        getOperationUrl: function(item, id, url) {
            return url ? url + id : null;
        },

        /**
         * Enter the edit mode for the current active list element.
         */
        enterEdit: function(event) {
            var url, item = this.activeItem,
                id = this.getSelectedId(item);
            if (id) {
                url = this.getOperationUrl(item, id, this.options.editUrl);
                if (url) {
                    ASF.Update(item, url, item);
                }
            }
            return false;
        },

        /**
         * Enter delete mode for the current active element.
         * The 'deletingCss' is applied on the element being deleted.  The delete dialog box is opened
         * to confirm the deletion of our item.  The 'deletingCSS' is removed once the dialog box is closed.
         */
        enterDelete: function(event) {
            var url, css,
                item = this.activeItem,
                id   = this.getSelectedId(item);
            if (id) {
                url = this.getOperationUrl(item, id, this.options.deleteUrl);
                if (url) {
                    css = this.options.deletingClass;

                    item.addClass(css);
                    ASF.OpenDialog(item, 'deleteDialog_' + id, url, {
                        close: function() {
                            item.removeClass(css);
                        }
                    });
                }
            }
            return false;
        },
        enterCreate: function(event) {

        },

        /**
         * Click action executed when one inner HTML element is clicked.
         *
         * @param event the event that was clicked
         */
        click: function(event) {
            var name, node = this._getTargetNode(event.target);
            if (node) {

                if ($(node).hasClass("asf-edit")) {
                    this.enterEdit(event);
                } else if ($(node).hasClass("asf-delete")) {
                    this.enterDelete(event);

                } else if ($(node).hasClass("asf-editable")) {
                    if (! $(node).hasClass("asf-editing")) {
                        this.currentEdit = node;
                        $(node).addClass("asf-editing");
                        this.enterCreate(event);
                    }
                } else if (this.options.selectAction != null) {
                    return this.selectAction(node, event);
                } else {
                    return true;
                }
                return false;
            } else {
                name = event.target.tagName;
                node = event.target;

                if ($(node).hasClass("asf-edit")) {
                    this.enterEdit(event);
                } else if ($(node).hasClass("asf-delete")) {
                    this.enterDelete(event);
                }

            }
            // event.stopPropagation();
            return false;
        },
        blur: function(event) {
            if (this.currentEdit) {
                this.currentEdit.remove();
                this.currentEdit = null;
            }
        },
        destroy: function() {
            this.element.removeClass("ui-list");
            $.Widget.prototype.destroy.apply(this, arguments);
        }

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


<commit_before>describe('classes', function() {
  var classes = document.documentElement.className.split(' ');

  it('_version exists', function() {
    expect(Modernizr._version).to.not.be(undefined);
  });

  it('_version did not add a class', function() {
    expect(document.documentElement).to.not.contain('_version');
  });

  it('all classes are lower case', function() {
    expect(document.documentElement.className).to.not.match(/[A-Z]/);
  });

  describe('everythings ship shape', function() {
    _.chain(classes)
      .filter()
      .sort()
      .forEach(function(name) {
        var result = name.indexOf('no-') === -1;
        name = name.replace(/no-/, '');
        it(name + ' is correctly ' + result + ' in the classes and object', function() {
          if (_.contains(name, '-')) {

            if (name.replace('-', '') in Modernizr) {
              name = name.replace('-', '');
              expect(Modernizr[name]).to.be(result);
            } else {
              name = name.split('-');
              expect(Modernizr[name[0]]).to.not.be(undefined);
              expect(!!Modernizr[name[0]][name[1]]).to.equal(result);
            }
          } else {
            expect(!!Modernizr[name]).to.equal(result);
          }
        });
      })
      .value();
  });

});
<commit_msg>fix another bool comparison<commit_after>describe('classes', function() {
  var classes = document.documentElement.className.split(' ');

  it('_version exists', function() {
    expect(Modernizr._version).to.not.be(undefined);
  });

  it('_version did not add a class', function() {
    expect(document.documentElement).to.not.contain('_version');
  });

  it('all classes are lower case', function() {
    expect(document.documentElement.className).to.not.match(/[A-Z]/);
  });

  describe('everythings ship shape', function() {
    _.chain(classes)
      .filter()
      .sort()
      .forEach(function(name) {
        var result = name.indexOf('no-') === -1;
        name = name.replace(/no-/, '');
        it(name + ' is correctly ' + result + ' in the classes and object', function() {
          if (_.contains(name, '-')) {

            if (name.replace('-', '') in Modernizr) {
              name = name.replace('-', '');
              expect(Modernizr[name]).to.be(result);
            } else {
              name = name.split('-');
              expect(Modernizr[name[0]]).to.not.be(undefined);
              expect(!!Modernizr[name[0]][name[1]]).to.equal(result);
            }
          } else {
            var test = Modernizr[name];
            var modernizrResult = test instanceof Boolean ? test.valueOf() : !!test;
            expect(modernizrResult).to.equal(result);
          }
        });
      })
      .value();
  });

});
<|endoftext|>


<commit_before>import {a, b as B} from "abc";

import * as abc from "abc";

import { fn } from "exportKinds";

import { one, two } from "exportKinds";

import { test1, test2 } from "exportKinds";

import { a as rea, b as reb, c as rec, o as reo, two as retwo } from "reexport";

import threeIsOdd, { even } from "circularEven";

import { specA, specB } from "exports-specifier";

import Thing, { Other } from "commonjs";
import Thing2, { Other as Other2 } from "commonjs-trans";

it("should import an identifier from a module", function() {
	a.should.be.eql("a");
	B.should.be.eql("b");
});

it("should import a whole module", function() {
	abc.a.should.be.eql("a");
	abc.b.should.be.eql("b");
	var copy = (function(a) { return a; }(abc));
	copy.a.should.be.eql("a");
	copy.b.should.be.eql("b");
	(typeof abc).should.be.eql("object");
});

it("should export functions", function() {
	fn.should.have.type("function");
	fn().should.be.eql("fn");
});

it("should multiple variables with one statement", function() {
	one.should.be.eql("one");
	two.should.be.eql("two");
});

it("should still be able to use exported stuff", function() {
	test1.should.be.eql("fn");
	test2.should.be.eql("two");
});

it("should reexport a module", function() {
	rea.should.be.eql("a");
	reb.should.be.eql("b");
	rec.should.be.eql("c");
	reo.should.be.eql("one");
	retwo.should.be.eql("two");
});

it("should support circular dependencies", function() {
	threeIsOdd.should.be.eql(true);
	even(4).should.be.eql(true);
});

it("should support export specifier", function() {
	specA.should.be.eql(1);
	specB.should.be.eql(2);
});

it("should be able to import commonjs", function() {
	function x() { throw new Error("should not be executed"); }
	// next line doesn't end with semicolon
	x
	Thing.should.have.type("function");
	Thing().should.be.eql("thing");
	Other.should.be.eql("other");

	Thing2.should.have.type("function");
	new Thing2().value.should.be.eql("thing");
	Other2.should.be.eql("other");
});
<commit_msg>fixed test to include star import of reexported module<commit_after>import {a, b as B} from "abc";

import * as abc from "abc";

import { fn } from "exportKinds";

import { one, two } from "exportKinds";

import { test1, test2 } from "exportKinds";

import { a as rea, b as reb, c as rec, o as reo, two as retwo } from "reexport";

import threeIsOdd, { even } from "circularEven";

import { specA, specB } from "exports-specifier";

import Thing, { Other } from "commonjs";
import Thing2, { Other as Other2 } from "commonjs-trans";

it("should import an identifier from a module", function() {
	a.should.be.eql("a");
	B.should.be.eql("b");
});

it("should import a whole module", function() {
	abc.a.should.be.eql("a");
	abc.b.should.be.eql("b");
	abc.c.should.be.eql("c");
	var copy = (function(a) { return a; }(abc));
	copy.a.should.be.eql("a");
	copy.b.should.be.eql("b");
	copy.c.should.be.eql("c");
	(typeof abc).should.be.eql("object");
});

it("should export functions", function() {
	fn.should.have.type("function");
	fn().should.be.eql("fn");
});

it("should multiple variables with one statement", function() {
	one.should.be.eql("one");
	two.should.be.eql("two");
});

it("should still be able to use exported stuff", function() {
	test1.should.be.eql("fn");
	test2.should.be.eql("two");
});

it("should reexport a module", function() {
	rea.should.be.eql("a");
	reb.should.be.eql("b");
	rec.should.be.eql("c");
	reo.should.be.eql("one");
	retwo.should.be.eql("two");
});

it("should support circular dependencies", function() {
	threeIsOdd.should.be.eql(true);
	even(4).should.be.eql(true);
});

it("should support export specifier", function() {
	specA.should.be.eql(1);
	specB.should.be.eql(2);
});

it("should be able to import commonjs", function() {
	function x() { throw new Error("should not be executed"); }
	// next line doesn't end with semicolon
	x
	Thing.should.have.type("function");
	Thing().should.be.eql("thing");
	Other.should.be.eql("other");

	Thing2.should.have.type("function");
	new Thing2().value.should.be.eql("thing");
	Other2.should.be.eql("other");
});
<|endoftext|>


<commit_before>!function(global, $, _) {
	'use strict';

	function ConcreteMenu($element, options) {
		var my = this;
		options = options || {};
		options = $.extend({
			'handle': 'this',
			'menu': false,
			'highlightClassName': 'ccm-menu-highlight',
			'highlightOffset': 0,
			'menuContainerClass': false,
			'menuActiveClass': 'ccm-menu-item-active',
			'menuActiveParentClass': 'ccm-parent-menu-item-active',
			'menuLauncherHoverClass': 'ccm-menu-item-hover',
			'menuLauncherHoverParentClass': 'ccm-parent-menu-item-hover',
			'enabled': true,
			'onHide': false
		}, options);

		my.$element = $element;
		my.options = options;
		if (options.handle == 'none') {
			my.$launcher = false;
		} else {
			my.$launcher = (options.handle == 'this') ? my.$element : $(options.handle);
			my.$launcher.each(function() {
				var $specificLauncher = $(this);
				$specificLauncher.on('mousemove.concreteMenu', function(e) {
					my.hoverProxy(e, $(this));
				});
			});
		}
		my.$menu = $(options.menu);
		my.setup();

        Concrete.event.bind('EditModeBlockDragInitialization', function() {
            my.hide();
        });
	}

	ConcreteMenu.prototype = {

		setup: function() {
			var my = this, options = my.options, global = ConcreteMenuManager;

			if (!global.$clickProxy) {
				global.$clickProxy = $("<div />", {'id': 'ccm-menu-click-proxy'});
				global.$clickProxy.on('mouseout.concreteMenuProxy', function(e) {
					var menu = global.hoverMenu;
					menu.mouseout(e);
				});
				global.$clickProxy.on('mouseover.concreteMenuProxy', function(e) {
					var menu = global.hoverMenu;
					menu.mouseover(e);
				});
				global.$clickProxy.on('click.concreteMenuProxy', function(e) {
					var menu = global.hoverMenu;
					menu.show(e);
				});
				$(document.body).append(global.$clickProxy);
			}
			if (!global.$highlighter) {
				global.$highlighter = $("<div />", {'id': 'ccm-menu-highlighter'});
				$(document.body).append(global.$highlighter);
			}
			if (!global.$container) {
				global.$container = $("<div />", {'id': 'ccm-popover-menu-container', 'class': 'ccm-ui'});
				$(document.body).append(global.$container);
			}
		},

		destroy: function() {
			var my = this, global = ConcreteMenuManager;
			my.hide();
			my.$launcher.each(function() {
				$(this).unbind('mousemove.concreteMenu');
			});
		},

		positionAt: function($elementToPosition, $elementToInspect) {
			if (!$elementToInspect) {
				return false;
			}

			var my = this,
				offset = $elementToInspect.offset(),
				properties = {
					'top': offset.top - my.options.highlightOffset,
					'left': offset.left - my.options.highlightOffset,
					'width': $elementToInspect.outerWidth() + (my.options.highlightOffset * 2),
					'height': $elementToInspect.outerHeight() + (my.options.highlightOffset * 2),
					'border-top-left-radius': $elementToInspect.css('border-top-left-radius'),
					'border-top-right-radius': $elementToInspect.css('border-top-right-radius'),
					'border-bottom-left-radius': $elementToInspect.css('border-bottom-left-radius'),
					'border-bottom-right-radius': $elementToInspect.css('border-bottom-right-radius')
				};

			$elementToPosition.css(properties);
		},

		hoverProxy: function(e, $specificLauncher) {
			e.stopPropagation();

			// we pass $launcher in because some menus can have multiple items
			// launch the same and we want to know which item triggered the launch
			var my = this,
				global = ConcreteMenuManager,
				menuLauncherHoverClass = my.options.menuLauncherHoverClass,
				$clickProxy = global.$clickProxy;

			if (!global.enabled || global.activeMenu) {
				return false;
			}

			my.positionAt($clickProxy, $specificLauncher);
			$clickProxy.removeClass().addClass(menuLauncherHoverClass);
			ConcreteMenuManager.hoverMenu = my;
		},

		mouseover: function(e) {
			var $launcher = this.$launcher, options = this.options;
			$launcher.addClass(options.menuLauncherHoverClass);
			$launcher.parents('*').slice(0,3).addClass(options.menuLauncherHoverParentClass);
		},

		mouseout: function(e) {
			var $launcher = this.$launcher, options = this.options;
			$launcher.removeClass(options.menuLauncherHoverClass);
			$launcher.parents('*').slice(0,3).removeClass(options.menuLauncherHoverParentClass);
		},

		setupMenuOptions: function($menu) {
			$menu.find('.dialog-launch').dialog();
		},

		show: function(e) {
			var my = this,
				global = ConcreteMenuManager,
				options = my.options,
				$launcher = my.$launcher,
				$element = my.$element,
				$container = global.$container,
				$highlighter = global.$highlighter,
				$menu = my.$menu.clone(true,true),
				posX = e.pageX + 2,
				posY = e.pageY + 2;

			e.stopPropagation();
			$highlighter.removeClass();
			my.positionAt($highlighter, $launcher);
			_.defer(function() {
				$highlighter.addClass(options.highlightClassName)
			});

			$element.addClass(options.menuActiveClass);
			$element.parents('*').slice(0,3).addClass(options.menuActiveParentClass);

			my.setupMenuOptions($menu);
			$container.html('');
			$menu.appendTo($container);
			if (options.menuContainerClass) {
				$container.addClass(options.menuContainerClass);
			}
			$menu.css('opacity', 0).show();
			var	mwidth = $menu.width(),
				mheight = $menu.height(); // have to do this after you show the element

			if ($(window).height() < (e.clientY + mheight + 30)) {
				posY = posY - mheight - 10;
				posX = posX - (mwidth / 2);
				$menu.removeClass('bottom');
				$menu.addClass('top');
			} else {
				posX = posX - (mwidth / 2);
				posY = posY + 10;
				$menu.removeClass('top');
				$menu.addClass('bottom');
			}

            var bodyWidth = $('body').innerWidth();
            if (posX < 0) {
                // menu is falling off the left side of the screen
                $menu.find(".arrow").css({'left': Math.abs(posX + (mwidth / 2) - 6) + 'px'});
                posX = 4;
            } else if (posX + mwidth > bodyWidth) {
                // menu is falling off the right side of the screen
                $menu.find(".arrow").css({'left': (mwidth - (bodyWidth - e.pageX) + 4) + 'px'});
                posX = bodyWidth.innerWidth() - mwidth - 4;
            } else {
                $menu.find(".arrow").css({'left': '50%'});
            }

			$menu.css({'top': posY + 'px', 'left': posX + 'px'});
			_.defer(function() {
				$menu.css('opacity', 1);
			});

			$menu.find('a').click(function(e) {
				my.hide(e);
			});

			$(document).unbind('.concreteMenuDisable').on('click.concreteMenuDisable', function(e) {
				my.hide(e);
			});

			my.$menuPointer = $menu;
			ConcreteMenuManager.activeMenu = my;
		},

		hide: function(e) {
			var my = this,
				global = ConcreteMenuManager,
				reset = {'class': '', 'width': 0, 'height': 0, 'top': 0, 'left': 0};

			if (e) {
				e.stopPropagation();
			}

			if (my.$menuPointer) {
				my.$menuPointer.css('opacity',0);
				_.defer(function() { my.$menuPointer.hide(); });
			}

			_.defer(function() {
				my.$element.removeClass(my.options.menuActiveClass);
				my.$element.parents('*').slice(0,3).removeClass(my.options.menuActiveParentClass);
				global.$container.removeClass().addClass('ccm-ui').html('');
			});

			global.$clickProxy.css(reset);
			global.$highlighter.css(reset);

			ConcreteMenuManager.activeMenu = false;

			if(my.options.onHide) {
				my.options.onHide(my);
			}

		}

	};

	var ConcreteMenuManager = {

		enabled: true,
		$clickProxy: false,
		$highlighter: false,
		$container: false,
		hoverMenu: false,
		activeMenu: false,

		reset: function() {

		},

		enable: function() {
			this.enabled = true;
		},

		disable: function() {
			this.enabled = false;
		},

		getActiveMenu: function() {
			return this.activeMenu;
		}

	};

	// jQuery Plugin
	$.fn.concreteMenu = function(options) {
		return $.each($(this), function(i, obj) {
			new ConcreteMenu($(this), options);
		});
	};

	global.ConcreteMenu = ConcreteMenu;
	global.ConcreteMenuManager = ConcreteMenuManager;

}(this, $, _);
<commit_msg>tabs to spaces<commit_after>!function (global, $, _) {
    'use strict';

    function ConcreteMenu($element, options) {
        var my = this;
        options = options || {};
        options = $.extend({
            'handle': 'this',
            'menu': false,
            'highlightClassName': 'ccm-menu-highlight',
            'highlightOffset': 0,
            'menuContainerClass': false,
            'menuActiveClass': 'ccm-menu-item-active',
            'menuActiveParentClass': 'ccm-parent-menu-item-active',
            'menuLauncherHoverClass': 'ccm-menu-item-hover',
            'menuLauncherHoverParentClass': 'ccm-parent-menu-item-hover',
            'enabled': true,
            'onHide': false
        }, options);

        my.$element = $element;
        my.options = options;
        if (options.handle == 'none') {
            my.$launcher = false;
        } else {
            my.$launcher = (options.handle == 'this') ? my.$element : $(options.handle);
            my.$launcher.each(function () {
                var $specificLauncher = $(this);
                $specificLauncher.on('mousemove.concreteMenu', function (e) {
                    my.hoverProxy(e, $(this));
                });
            });
        }
        my.$menu = $(options.menu);
        my.setup();

        Concrete.event.bind('EditModeBlockDragInitialization', function () {
            my.hide();
        });
    }

    ConcreteMenu.prototype = {

        setup: function () {
            var my = this, options = my.options, global = ConcreteMenuManager;

            if (!global.$clickProxy) {
                global.$clickProxy = $("<div />", {'id': 'ccm-menu-click-proxy'});
                global.$clickProxy.on('mouseout.concreteMenuProxy', function (e) {
                    var menu = global.hoverMenu;
                    menu.mouseout(e);
                });
                global.$clickProxy.on('mouseover.concreteMenuProxy', function (e) {
                    var menu = global.hoverMenu;
                    menu.mouseover(e);
                });
                global.$clickProxy.on('click.concreteMenuProxy', function (e) {
                    var menu = global.hoverMenu;
                    menu.show(e);
                });
                $(document.body).append(global.$clickProxy);
            }
            if (!global.$highlighter) {
                global.$highlighter = $("<div />", {'id': 'ccm-menu-highlighter'});
                $(document.body).append(global.$highlighter);
            }
            if (!global.$container) {
                global.$container = $("<div />", {'id': 'ccm-popover-menu-container', 'class': 'ccm-ui'});
                $(document.body).append(global.$container);
            }
        },

        destroy: function () {
            var my = this, global = ConcreteMenuManager;
            my.hide();
            my.$launcher.each(function () {
                $(this).unbind('mousemove.concreteMenu');
            });
        },

        positionAt: function ($elementToPosition, $elementToInspect) {
            if (!$elementToInspect) {
                return false;
            }

            var my = this,
                offset = $elementToInspect.offset(),
                properties = {
                    'top': offset.top - my.options.highlightOffset,
                    'left': offset.left - my.options.highlightOffset,
                    'width': $elementToInspect.outerWidth() + (my.options.highlightOffset * 2),
                    'height': $elementToInspect.outerHeight() + (my.options.highlightOffset * 2),
                    'border-top-left-radius': $elementToInspect.css('border-top-left-radius'),
                    'border-top-right-radius': $elementToInspect.css('border-top-right-radius'),
                    'border-bottom-left-radius': $elementToInspect.css('border-bottom-left-radius'),
                    'border-bottom-right-radius': $elementToInspect.css('border-bottom-right-radius')
                };

            $elementToPosition.css(properties);
        },

        hoverProxy: function (e, $specificLauncher) {
            e.stopPropagation();

            // we pass $launcher in because some menus can have multiple items
            // launch the same and we want to know which item triggered the launch
            var my = this,
                global = ConcreteMenuManager,
                menuLauncherHoverClass = my.options.menuLauncherHoverClass,
                $clickProxy = global.$clickProxy;

            if (!global.enabled || global.activeMenu) {
                return false;
            }

            my.positionAt($clickProxy, $specificLauncher);
            $clickProxy.removeClass().addClass(menuLauncherHoverClass);
            ConcreteMenuManager.hoverMenu = my;
        },

        mouseover: function (e) {
            var $launcher = this.$launcher, options = this.options;
            $launcher.addClass(options.menuLauncherHoverClass);
            $launcher.parents('*').slice(0, 3).addClass(options.menuLauncherHoverParentClass);
        },

        mouseout: function (e) {
            var $launcher = this.$launcher, options = this.options;
            $launcher.removeClass(options.menuLauncherHoverClass);
            $launcher.parents('*').slice(0, 3).removeClass(options.menuLauncherHoverParentClass);
        },

        setupMenuOptions: function ($menu) {
            $menu.find('.dialog-launch').dialog();
        },

        show: function (e) {
            var my = this,
                global = ConcreteMenuManager,
                options = my.options,
                $launcher = my.$launcher,
                $element = my.$element,
                $container = global.$container,
                $highlighter = global.$highlighter,
                $menu = my.$menu.clone(true, true),
                posX = e.pageX + 2,
                posY = e.pageY + 2;

            e.stopPropagation();
            $highlighter.removeClass();
            my.positionAt($highlighter, $launcher);
            _.defer(function () {
                $highlighter.addClass(options.highlightClassName)
            });

            $element.addClass(options.menuActiveClass);
            $element.parents('*').slice(0, 3).addClass(options.menuActiveParentClass);

            my.setupMenuOptions($menu);
            $container.html('');
            $menu.appendTo($container);
            if (options.menuContainerClass) {
                $container.addClass(options.menuContainerClass);
            }
            $menu.css('opacity', 0).show();
            var mwidth = $menu.width(),
                mheight = $menu.height(); // have to do this after you show the element

            if ($(window).height() < (e.clientY + mheight + 30)) {
                posY = posY - mheight - 10;
                posX = posX - (mwidth / 2);
                $menu.removeClass('bottom');
                $menu.addClass('top');
            } else {
                posX = posX - (mwidth / 2);
                posY = posY + 10;
                $menu.removeClass('top');
                $menu.addClass('bottom');
            }

            var bodyWidth = $('body').innerWidth();
            if (posX < 0) {
                // menu is falling off the left side of the screen
                $menu.find(".arrow").css({'left': Math.abs(posX + (mwidth / 2) - 6) + 'px'});
                posX = 4;
            } else if (posX + mwidth > bodyWidth) {
                // menu is falling off the right side of the screen
                $menu.find(".arrow").css({'left': (mwidth - (bodyWidth - e.pageX) + 4) + 'px'});
                posX = bodyWidth.innerWidth() - mwidth - 4;
            } else {
                $menu.find(".arrow").css({'left': '50%'});
            }

            $menu.css({'top': posY + 'px', 'left': posX + 'px'});
            _.defer(function () {
                $menu.css('opacity', 1);
            });

            $menu.find('a').click(function (e) {
                my.hide(e);
            });

            $(document).unbind('.concreteMenuDisable').on('click.concreteMenuDisable', function (e) {
                my.hide(e);
            });

            my.$menuPointer = $menu;
            ConcreteMenuManager.activeMenu = my;
        },

        hide: function (e) {
            var my = this,
                global = ConcreteMenuManager,
                reset = {'class': '', 'width': 0, 'height': 0, 'top': 0, 'left': 0};

            if (e) {
                e.stopPropagation();
            }

            if (my.$menuPointer) {
                my.$menuPointer.css('opacity', 0);
                _.defer(function () {
                    my.$menuPointer.hide();
                });
            }

            _.defer(function () {
                my.$element.removeClass(my.options.menuActiveClass);
                my.$element.parents('*').slice(0, 3).removeClass(my.options.menuActiveParentClass);
                global.$container.removeClass().addClass('ccm-ui').html('');
            });

            global.$clickProxy.css(reset);
            global.$highlighter.css(reset);

            ConcreteMenuManager.activeMenu = false;

            if (my.options.onHide) {
                my.options.onHide(my);
            }

        }

    };

    var ConcreteMenuManager = {

        enabled: true,
        $clickProxy: false,
        $highlighter: false,
        $container: false,
        hoverMenu: false,
        activeMenu: false,

        reset: function () {

        },

        enable: function () {
            this.enabled = true;
        },

        disable: function () {
            this.enabled = false;
        },

        getActiveMenu: function () {
            return this.activeMenu;
        }

    };

    // jQuery Plugin
    $.fn.concreteMenu = function (options) {
        return $.each($(this), function (i, obj) {
            new ConcreteMenu($(this), options);
        });
    };

    global.ConcreteMenu = ConcreteMenu;
    global.ConcreteMenuManager = ConcreteMenuManager;

}(this, $, _);
<|endoftext|>


<commit_before>!function(global, $, _) {
	'use strict';

	function ConcreteMenu($element, options) {
		var my = this;
		options = options || {};
		options = $.extend({
			'handle': 'this',
			'menu': false,
			'highlightClassName': 'ccm-menu-highlight',
			'highlightOffset': 0,
			'menuContainerClass': false,
			'menuActiveClass': 'ccm-menu-item-active',
			'menuActiveParentClass': 'ccm-parent-menu-item-active',
			'menuLauncherHoverClass': 'ccm-menu-item-hover',
			'menuLauncherHoverParentClass': 'ccm-parent-menu-item-hover',
			'enabled': true,
			'onHide': false
		}, options);

		my.$element = $element;
		my.options = options;
		if (options.handle == 'none') {
			my.$launcher = false;
		} else {
			my.$launcher = (options.handle == 'this') ? my.$element : $(options.handle);
			my.$launcher.each(function() {
				var $specificLauncher = $(this);
				$specificLauncher.on('mousemove.concreteMenu', function(e) {
					my.hoverProxy(e, $(this));
				});
			});
		}
		my.$menu = $(options.menu);
		my.setup();

        Concrete.event.bind('EditModeBlockDragInitialization', function() {
            my.hide();
        });
	}

	ConcreteMenu.prototype = {

		setup: function() {
			var my = this, options = my.options, global = ConcreteMenuManager;

			if (!global.$clickProxy) {
				global.$clickProxy = $("<div />", {'id': 'ccm-menu-click-proxy'});
				global.$clickProxy.on('mouseout.concreteMenuProxy', function(e) {
					var menu = global.hoverMenu;
					menu.mouseout(e);
				});
				global.$clickProxy.on('mouseover.concreteMenuProxy', function(e) {
					var menu = global.hoverMenu;
					menu.mouseover(e);
				});
				global.$clickProxy.on('click.concreteMenuProxy', function(e) {
					var menu = global.hoverMenu;
					menu.show(e);
				});
				$(document.body).append(global.$clickProxy);
			}
			if (!global.$highlighter) {
				global.$highlighter = $("<div />", {'id': 'ccm-menu-highlighter'});
				$(document.body).append(global.$highlighter);
			}
			if (!global.$container) {
				global.$container = $("<div />", {'id': 'ccm-popover-menu-container', 'class': 'ccm-ui'});
				$(document.body).append(global.$container);
			}
		},

		destroy: function() {
			var my = this, global = ConcreteMenuManager;
			my.hide();
			my.$launcher.each(function() {
				$(this).unbind('mousemove.concreteMenu');
			});
		},

		positionAt: function($elementToPosition, $elementToInspect) {
			if (!$elementToInspect) {
				return false;
			}

			var my = this,
				offset = $elementToInspect.offset(),
				properties = {
					'top': offset.top - my.options.highlightOffset,
					'left': offset.left - my.options.highlightOffset,
					'width': $elementToInspect.outerWidth() + (my.options.highlightOffset * 2),
					'height': $elementToInspect.outerHeight() + (my.options.highlightOffset * 2),
					'border-top-left-radius': $elementToInspect.css('border-top-left-radius'),
					'border-top-right-radius': $elementToInspect.css('border-top-right-radius'),
					'border-bottom-left-radius': $elementToInspect.css('border-bottom-left-radius'),
					'border-bottom-right-radius': $elementToInspect.css('border-bottom-right-radius'),
				};

			$elementToPosition.css(properties);
		},

		hoverProxy: function(e, $specificLauncher) {
			e.stopPropagation();

			// we pass $launcher in because some menus can have multiple items
			// launch the same and we want to know which item triggered the launch
			var my = this,
				global = ConcreteMenuManager,
				menuLauncherHoverClass = my.options.menuLauncherHoverClass,
				$clickProxy = global.$clickProxy;

			if (!global.enabled || global.activeMenu) {
				return false;
			}

			my.positionAt($clickProxy, $specificLauncher);
			$clickProxy.removeClass().addClass(menuLauncherHoverClass);
			ConcreteMenuManager.hoverMenu = my;
		},

		mouseover: function(e) {
			var $launcher = this.$launcher, options = this.options;
			$launcher.addClass(options.menuLauncherHoverClass);
			$launcher.parents('*').slice(0,3).addClass(options.menuLauncherHoverParentClass);
		},

		mouseout: function(e) {
			var $launcher = this.$launcher, options = this.options;
			$launcher.removeClass(options.menuLauncherHoverClass);
			$launcher.parents('*').slice(0,3).removeClass(options.menuLauncherHoverParentClass);
		},

		setupMenuOptions: function($menu) {
			$menu.find('.dialog-launch').dialog();
		},

		show: function(e) {
			var my = this,
				global = ConcreteMenuManager,
				options = my.options,
				$launcher = my.$launcher,
				$element = my.$element,
				$container = global.$container,
				$highlighter = global.$highlighter,
				$menu = my.$menu.clone(true,true),
				posX = e.pageX + 2,
				posY = e.pageY + 2;

			e.stopPropagation();
			$highlighter.removeClass();
			my.positionAt($highlighter, $launcher);
			_.defer(function() {
				$highlighter.addClass(options.highlightClassName)
			});

			$element.addClass(options.menuActiveClass);
			$element.parents('*').slice(0,3).addClass(options.menuActiveParentClass);

			my.setupMenuOptions($menu);
			$container.html('');
			$menu.appendTo($container);
			if (options.menuContainerClass) {
				$container.addClass(options.menuContainerClass);
			}
			$menu.css('opacity', 0).show();
			var	mwidth = $menu.width(),
				mheight = $menu.height(); // have to do this after you show the element

			if ($(window).height() < (e.clientY + mheight + 30)) {
				posY = posY - mheight - 10;
				posX = posX - (mwidth / 2);
				$menu.removeClass('bottom');
				$menu.addClass('top');
			} else {
				posX = posX - (mwidth / 2);
				posY = posY + 10;
				$menu.removeClass('top');
				$menu.addClass('bottom');
			}

            var bodyWidth = $('body').innerWidth();
            if (posX < 0) {
                // menu is falling off the left side of the screen
                $menu.find(".arrow").css({'left': Math.abs(posX + (mwidth / 2) - 6) + 'px'});
                posX = 4;
            } else if (posX + mwidth > bodyWidth) {
                // menu is falling off the right side of the screen
                $menu.find(".arrow").css({'left': (mwidth - (bodyWidth - e.pageX) + 4) + 'px'});
                posX = bodyWidth.innerWidth() - mwidth - 4;
            } else {
                $menu.find(".arrow").css({'left': '50%'});
            }

			$menu.css({'top': posY + 'px', 'left': posX + 'px'});
			_.defer(function() {
				$menu.css('opacity', 1);
			});

			$menu.find('a').click(function(e) {
				my.hide(e);
			});

			$(document).unbind('.concreteMenuDisable').on('click.concreteMenuDisable', function(e) {
				my.hide(e);
			});

			my.$menuPointer = $menu;
			ConcreteMenuManager.activeMenu = my;
		},

		hide: function(e) {
			var my = this,
				global = ConcreteMenuManager,
				reset = {'class': '', 'width': 0, 'height': 0, 'top': 0, 'left': 0}

			if (e) {
				e.stopPropagation();
			}

			if (my.$menuPointer) {
				my.$menuPointer.css('opacity',0);
				_.defer(function() { my.$menuPointer.hide(); });
			}

			_.defer(function() {
				my.$element.removeClass(my.options.menuActiveClass);
				my.$element.parents('*').slice(0,3).removeClass(my.options.menuActiveParentClass);
				global.$container.removeClass().addClass('ccm-ui').html('');
			});

			global.$clickProxy.css(reset);
			global.$highlighter.css(reset);

			ConcreteMenuManager.activeMenu = false;

			if(my.options.onHide) {
				my.options.onHide(my);
			}

		}

	}

	var ConcreteMenuManager = {

		enabled: true,
		$clickProxy: false,
		$highlighter: false,
		$container: false,
		hoverMenu: false,
		activeMenu: false,

		reset: function() {

		},

		enable: function() {
			this.enabled = true;
		},

		disable: function() {
			this.enabled = false;
		},

		getActiveMenu: function() {
			return this.activeMenu;
		}

	}

	// jQuery Plugin
	$.fn.concreteMenu = function(options) {
		return $.each($(this), function(i, obj) {
			new ConcreteMenu($(this), options);
		});
	}

	global.ConcreteMenu = ConcreteMenu;
	global.ConcreteMenuManager = ConcreteMenuManager;

}(this, $, _);
<commit_msg>Missing semicolons and other stuff<commit_after>!function(global, $, _) {
	'use strict';

	function ConcreteMenu($element, options) {
		var my = this;
		options = options || {};
		options = $.extend({
			'handle': 'this',
			'menu': false,
			'highlightClassName': 'ccm-menu-highlight',
			'highlightOffset': 0,
			'menuContainerClass': false,
			'menuActiveClass': 'ccm-menu-item-active',
			'menuActiveParentClass': 'ccm-parent-menu-item-active',
			'menuLauncherHoverClass': 'ccm-menu-item-hover',
			'menuLauncherHoverParentClass': 'ccm-parent-menu-item-hover',
			'enabled': true,
			'onHide': false
		}, options);

		my.$element = $element;
		my.options = options;
		if (options.handle == 'none') {
			my.$launcher = false;
		} else {
			my.$launcher = (options.handle == 'this') ? my.$element : $(options.handle);
			my.$launcher.each(function() {
				var $specificLauncher = $(this);
				$specificLauncher.on('mousemove.concreteMenu', function(e) {
					my.hoverProxy(e, $(this));
				});
			});
		}
		my.$menu = $(options.menu);
		my.setup();

        Concrete.event.bind('EditModeBlockDragInitialization', function() {
            my.hide();
        });
	}

	ConcreteMenu.prototype = {

		setup: function() {
			var my = this, options = my.options, global = ConcreteMenuManager;

			if (!global.$clickProxy) {
				global.$clickProxy = $("<div />", {'id': 'ccm-menu-click-proxy'});
				global.$clickProxy.on('mouseout.concreteMenuProxy', function(e) {
					var menu = global.hoverMenu;
					menu.mouseout(e);
				});
				global.$clickProxy.on('mouseover.concreteMenuProxy', function(e) {
					var menu = global.hoverMenu;
					menu.mouseover(e);
				});
				global.$clickProxy.on('click.concreteMenuProxy', function(e) {
					var menu = global.hoverMenu;
					menu.show(e);
				});
				$(document.body).append(global.$clickProxy);
			}
			if (!global.$highlighter) {
				global.$highlighter = $("<div />", {'id': 'ccm-menu-highlighter'});
				$(document.body).append(global.$highlighter);
			}
			if (!global.$container) {
				global.$container = $("<div />", {'id': 'ccm-popover-menu-container', 'class': 'ccm-ui'});
				$(document.body).append(global.$container);
			}
		},

		destroy: function() {
			var my = this, global = ConcreteMenuManager;
			my.hide();
			my.$launcher.each(function() {
				$(this).unbind('mousemove.concreteMenu');
			});
		},

		positionAt: function($elementToPosition, $elementToInspect) {
			if (!$elementToInspect) {
				return false;
			}

			var my = this,
				offset = $elementToInspect.offset(),
				properties = {
					'top': offset.top - my.options.highlightOffset,
					'left': offset.left - my.options.highlightOffset,
					'width': $elementToInspect.outerWidth() + (my.options.highlightOffset * 2),
					'height': $elementToInspect.outerHeight() + (my.options.highlightOffset * 2),
					'border-top-left-radius': $elementToInspect.css('border-top-left-radius'),
					'border-top-right-radius': $elementToInspect.css('border-top-right-radius'),
					'border-bottom-left-radius': $elementToInspect.css('border-bottom-left-radius'),
					'border-bottom-right-radius': $elementToInspect.css('border-bottom-right-radius')
				};

			$elementToPosition.css(properties);
		},

		hoverProxy: function(e, $specificLauncher) {
			e.stopPropagation();

			// we pass $launcher in because some menus can have multiple items
			// launch the same and we want to know which item triggered the launch
			var my = this,
				global = ConcreteMenuManager,
				menuLauncherHoverClass = my.options.menuLauncherHoverClass,
				$clickProxy = global.$clickProxy;

			if (!global.enabled || global.activeMenu) {
				return false;
			}

			my.positionAt($clickProxy, $specificLauncher);
			$clickProxy.removeClass().addClass(menuLauncherHoverClass);
			ConcreteMenuManager.hoverMenu = my;
		},

		mouseover: function(e) {
			var $launcher = this.$launcher, options = this.options;
			$launcher.addClass(options.menuLauncherHoverClass);
			$launcher.parents('*').slice(0,3).addClass(options.menuLauncherHoverParentClass);
		},

		mouseout: function(e) {
			var $launcher = this.$launcher, options = this.options;
			$launcher.removeClass(options.menuLauncherHoverClass);
			$launcher.parents('*').slice(0,3).removeClass(options.menuLauncherHoverParentClass);
		},

		setupMenuOptions: function($menu) {
			$menu.find('.dialog-launch').dialog();
		},

		show: function(e) {
			var my = this,
				global = ConcreteMenuManager,
				options = my.options,
				$launcher = my.$launcher,
				$element = my.$element,
				$container = global.$container,
				$highlighter = global.$highlighter,
				$menu = my.$menu.clone(true,true),
				posX = e.pageX + 2,
				posY = e.pageY + 2;

			e.stopPropagation();
			$highlighter.removeClass();
			my.positionAt($highlighter, $launcher);
			_.defer(function() {
				$highlighter.addClass(options.highlightClassName)
			});

			$element.addClass(options.menuActiveClass);
			$element.parents('*').slice(0,3).addClass(options.menuActiveParentClass);

			my.setupMenuOptions($menu);
			$container.html('');
			$menu.appendTo($container);
			if (options.menuContainerClass) {
				$container.addClass(options.menuContainerClass);
			}
			$menu.css('opacity', 0).show();
			var	mwidth = $menu.width(),
				mheight = $menu.height(); // have to do this after you show the element

			if ($(window).height() < (e.clientY + mheight + 30)) {
				posY = posY - mheight - 10;
				posX = posX - (mwidth / 2);
				$menu.removeClass('bottom');
				$menu.addClass('top');
			} else {
				posX = posX - (mwidth / 2);
				posY = posY + 10;
				$menu.removeClass('top');
				$menu.addClass('bottom');
			}

            var bodyWidth = $('body').innerWidth();
            if (posX < 0) {
                // menu is falling off the left side of the screen
                $menu.find(".arrow").css({'left': Math.abs(posX + (mwidth / 2) - 6) + 'px'});
                posX = 4;
            } else if (posX + mwidth > bodyWidth) {
                // menu is falling off the right side of the screen
                $menu.find(".arrow").css({'left': (mwidth - (bodyWidth - e.pageX) + 4) + 'px'});
                posX = bodyWidth.innerWidth() - mwidth - 4;
            } else {
                $menu.find(".arrow").css({'left': '50%'});
            }

			$menu.css({'top': posY + 'px', 'left': posX + 'px'});
			_.defer(function() {
				$menu.css('opacity', 1);
			});

			$menu.find('a').click(function(e) {
				my.hide(e);
			});

			$(document).unbind('.concreteMenuDisable').on('click.concreteMenuDisable', function(e) {
				my.hide(e);
			});

			my.$menuPointer = $menu;
			ConcreteMenuManager.activeMenu = my;
		},

		hide: function(e) {
			var my = this,
				global = ConcreteMenuManager,
				reset = {'class': '', 'width': 0, 'height': 0, 'top': 0, 'left': 0};

			if (e) {
				e.stopPropagation();
			}

			if (my.$menuPointer) {
				my.$menuPointer.css('opacity',0);
				_.defer(function() { my.$menuPointer.hide(); });
			}

			_.defer(function() {
				my.$element.removeClass(my.options.menuActiveClass);
				my.$element.parents('*').slice(0,3).removeClass(my.options.menuActiveParentClass);
				global.$container.removeClass().addClass('ccm-ui').html('');
			});

			global.$clickProxy.css(reset);
			global.$highlighter.css(reset);

			ConcreteMenuManager.activeMenu = false;

			if(my.options.onHide) {
				my.options.onHide(my);
			}

		}

	};

	var ConcreteMenuManager = {

		enabled: true,
		$clickProxy: false,
		$highlighter: false,
		$container: false,
		hoverMenu: false,
		activeMenu: false,

		reset: function() {

		},

		enable: function() {
			this.enabled = true;
		},

		disable: function() {
			this.enabled = false;
		},

		getActiveMenu: function() {
			return this.activeMenu;
		}

	};

	// jQuery Plugin
	$.fn.concreteMenu = function(options) {
		return $.each($(this), function(i, obj) {
			new ConcreteMenu($(this), options);
		});
	};

	global.ConcreteMenu = ConcreteMenu;
	global.ConcreteMenuManager = ConcreteMenuManager;

}(this, $, _);
<|endoftext|>


<commit_before>/*
 * Provides an example of Tengwar runes from The Treason Of Isengard, title page top.
 */
var TengwarExampleTTOI1 =
{
    IMAGE: "https://runetranscriber.googlecode.com/svn/trunk/core/doc/images/treasonofisengard/TTOI_TitlePage1.jpg",

    LANGUAGE_LETTERS: "In the Treason of Isengard the story of the Fellowship of the Ring is traced\n"
            + "from Rivendell through Moria and the Land of Lothlorien to the days\n"
            + "of its ending at Salembel beside Anduin the Great river, then is told of the return of Gandalf Mithrandir, of the meeting of the hobbits with Fangorn and of the war upon the Riders of Rohan by the traitor Saruman.",

    RUNES: [
            // Line 1
            // in
            [ TengwaRune.ACUTE, TengwaRune.NUMEN ],
            TengwaRune.SPACE,
            // the
            TengwaRune.THE,
            TengwaRune.SPACE,
            // treason
            TengwaRune.TINCO,
            TengwaRune.ROMEN,
            [ TengwaRune.DOT, TengwaRune.SHORT_CARRIER,
                    TengwaRune.THREE_UNDER_DOTS ],
            TengwaRune.SILME,
            [ TengwaRune.LEFT_CURL, TengwaRune.NUMEN ],
            TengwaRune.SPACE,
            // of
            TengwaRune.OF,
            TengwaRune.SPACE,
            // isengard
            [ TengwaRune.ACUTE, TengwaRune.SILME ],
            [ TengwaRune.DOT, TengwaRune.NUMEN ],
            TengwaRune.UNGWE,
            [ TengwaRune.THREE_DOTS, TengwaRune.ORE ],
            TengwaRune.ANDO,
            TengwaRune.SPACE,
            // the
            TengwaRune.THE,
            TengwaRune.SPACE,
            // story
            TengwaRune.SILME,
            TengwaRune.TINCO,
            [ TengwaRune.LEFT_CURL, TengwaRune.ROMEN ],
            TengwaRune.ANNA,
            TengwaRune.SPACE,
            // of the
            TengwaRune.OF_THE,
            TengwaRune.SPACE,
            // fellowship
            TengwaRune.FORMEN,
            [ TengwaRune.DOT, TengwaRune.LAMBE, TengwaRune.UNDER_BAR ],
            [ TengwaRune.LEFT_CURL, TengwaRune.VALA ],
            TengwaRune.HARMA,
            [ TengwaRune.ACUTE, TengwaRune.PARMA ],
            TengwaRune.SPACE,
            // of the
            TengwaRune.OF_THE,
            TengwaRune.SPACE,
            // ring
            TengwaRune.ROMEN,
            [ TengwaRune.ACUTE, TengwaRune.NGWALME ],
            TengwaRune.SPACE,
            // is
            [ TengwaRune.ACUTE, TengwaRune.SILME ],
            TengwaRune.SPACE,
            // traced
            TengwaRune.TINCO,
            TengwaRune.ROMEN,
            [ TengwaRune.THREE_DOTS, TengwaRune.SILME_NUQUERNA,
                    TengwaRune.UNDER_DOT ],
            TengwaRune.ANDO,
            TengwaRune.NEWLINE,

            // Line 2
            // from
            TengwaRune.FORMEN,
            TengwaRune.ROMEN,
            [ TengwaRune.LEFT_CURL, TengwaRune.MALTA ],
            TengwaRune.SPACE,
            // rivendell
            TengwaRune.ROMEN,
            [ TengwaRune.ACUTE, TengwaRune.AMPA ],
            [ TengwaRune.DOT, TengwaRune.NUMEN ],
            TengwaRune.ANDO,
            [ TengwaRune.DOT, TengwaRune.LAMBE, TengwaRune.UNDER_BAR ],
            TengwaRune.SPACE,
            // through
            TengwaRune.THULE,
            TengwaRune.ROMEN,
            [TengwaRune.LEFT_CURL,TengwaRune.URE],
            TengwaRune.UNGWE,
            TengwaRune.SPACE,
            // moria
            TengwaRune.MALTA,
            [ TengwaRune.LEFT_CURL, TengwaRune.ROMEN ],
            [ TengwaRune.ACUTE, TengwaRune.SHORT_CARRIER,
                    TengwaRune.THREE_UNDER_DOTS ],
            TengwaRune.SPACE,
            // and
            [ TengwaRune.BAR, TengwaRune.ANDO ],
            TengwaRune.SPACE,
            // the
            TengwaRune.THE,
            TengwaRune.SPACE,
            // land
            TengwaRune.LAMBE,
            [ TengwaRune.THREE_DOTS, TengwaRune.NUMEN ],
            TengwaRune.ANDO,
            TengwaRune.SPACE,
            // of
            TengwaRune.OF,
            TengwaRune.SPACE,
            // lothlorien
            TengwaRune.LAMBE,
            [ TengwaRune.LEFT_CURL, TengwaRune.THULE ],
            TengwaRune.LAMBE,
            [ TengwaRune.LEFT_CURL, TengwaRune.ROMEN ],
            [ TengwaRune.ACUTE, TengwaRune.SHORT_CARRIER, TengwaRune.UNDER_DOT ],
            TengwaRune.NUMEN, TengwaRune.SPACE,
            // to
            TengwaRune.TINCO,
            [ TengwaRune.LEFT_CURL, TengwaRune.SHORT_CARRIER ],
            TengwaRune.SPACE,
            // the
            TengwaRune.THE, TengwaRune.SPACE,
            // days
            TengwaRune.ANDO, [ TengwaRune.THREE_DOTS, TengwaRune.ANNA ],TengwaRune.SILME ],
}

if (Object.freeze)
{
    Object.freeze(TengwarExampleTTOI1)
};
<commit_msg>Code cleanup.<commit_after>/*
 * Provides an example of Tengwar runes from The Treason Of Isengard, title page top.
 */
var TengwarExampleTTOI1 =
{
    IMAGE: "https://runetranscriber.googlecode.com/svn/trunk/core/doc/images/treasonofisengard/TTOI_TitlePage1.jpg",

    LANGUAGE_LETTERS: "In the Treason of Isengard the story of the Fellowship of the Ring is traced\n"
            + "from Rivendell through Moria and the Land of Lothlorien to the days",

    RUNES: [
            // Line 1
            // in
            [ TengwaRune.ACUTE, TengwaRune.NUMEN ],
            TengwaRune.SPACE,
            // the
            TengwaRune.THE,
            TengwaRune.SPACE,
            // treason
            TengwaRune.TINCO,
            TengwaRune.ROMEN,
            [ TengwaRune.DOT, TengwaRune.SHORT_CARRIER,
                    TengwaRune.THREE_UNDER_DOTS ],
            TengwaRune.SILME,
            [ TengwaRune.LEFT_CURL, TengwaRune.NUMEN ],
            TengwaRune.SPACE,
            // of
            TengwaRune.OF,
            TengwaRune.SPACE,
            // isengard
            [ TengwaRune.ACUTE, TengwaRune.SILME ],
            [ TengwaRune.DOT, TengwaRune.NUMEN ],
            TengwaRune.UNGWE,
            [ TengwaRune.THREE_DOTS, TengwaRune.ORE ],
            TengwaRune.ANDO,
            TengwaRune.SPACE,
            // the
            TengwaRune.THE,
            TengwaRune.SPACE,
            // story
            TengwaRune.SILME,
            TengwaRune.TINCO,
            [ TengwaRune.LEFT_CURL, TengwaRune.ROMEN ],
            TengwaRune.ANNA,
            TengwaRune.SPACE,
            // of the
            TengwaRune.OF_THE,
            TengwaRune.SPACE,
            // fellowship
            TengwaRune.FORMEN,
            [ TengwaRune.DOT, TengwaRune.LAMBE, TengwaRune.UNDER_BAR ],
            [ TengwaRune.LEFT_CURL, TengwaRune.VALA ],
            TengwaRune.HARMA,
            [ TengwaRune.ACUTE, TengwaRune.PARMA ],
            TengwaRune.SPACE,
            // of the
            TengwaRune.OF_THE,
            TengwaRune.SPACE,
            // ring
            TengwaRune.ROMEN,
            [ TengwaRune.ACUTE, TengwaRune.NGWALME ],
            TengwaRune.SPACE,
            // is
            [ TengwaRune.ACUTE, TengwaRune.SILME ],
            TengwaRune.SPACE,
            // traced
            TengwaRune.TINCO,
            TengwaRune.ROMEN,
            [ TengwaRune.THREE_DOTS, TengwaRune.SILME_NUQUERNA,
                    TengwaRune.UNDER_DOT ],
            TengwaRune.ANDO,
            TengwaRune.NEWLINE,

            // Line 2
            // from
            TengwaRune.FORMEN,
            TengwaRune.ROMEN,
            [ TengwaRune.LEFT_CURL, TengwaRune.MALTA ],
            TengwaRune.SPACE,
            // rivendell
            TengwaRune.ROMEN,
            [ TengwaRune.ACUTE, TengwaRune.AMPA ],
            [ TengwaRune.DOT, TengwaRune.NUMEN ],
            TengwaRune.ANDO,
            [ TengwaRune.DOT, TengwaRune.LAMBE, TengwaRune.UNDER_BAR ],
            TengwaRune.SPACE,
            // through
            TengwaRune.THULE,
            TengwaRune.ROMEN,
            [TengwaRune.LEFT_CURL,TengwaRune.URE],
            TengwaRune.UNGWE,
            TengwaRune.SPACE,
            // moria
            TengwaRune.MALTA,
            [ TengwaRune.LEFT_CURL, TengwaRune.ROMEN ],
            [ TengwaRune.ACUTE, TengwaRune.SHORT_CARRIER,
                    TengwaRune.THREE_UNDER_DOTS ],
            TengwaRune.SPACE,
            // and
            [ TengwaRune.BAR, TengwaRune.ANDO ],
            TengwaRune.SPACE,
            // the
            TengwaRune.THE,
            TengwaRune.SPACE,
            // land
            TengwaRune.LAMBE,
            [ TengwaRune.THREE_DOTS, TengwaRune.NUMEN ],
            TengwaRune.ANDO,
            TengwaRune.SPACE,
            // of
            TengwaRune.OF,
            TengwaRune.SPACE,
            // lothlorien
            TengwaRune.LAMBE,
            [ TengwaRune.LEFT_CURL, TengwaRune.THULE ],
            TengwaRune.LAMBE,
            [ TengwaRune.LEFT_CURL, TengwaRune.ROMEN ],
            [ TengwaRune.ACUTE, TengwaRune.SHORT_CARRIER, TengwaRune.UNDER_DOT ],
            TengwaRune.NUMEN, TengwaRune.SPACE,
            // to
            TengwaRune.TINCO,
            [ TengwaRune.LEFT_CURL, TengwaRune.SHORT_CARRIER ],
            TengwaRune.SPACE,
            // the
            TengwaRune.THE, TengwaRune.SPACE,
            // days
            TengwaRune.ANDO, [ TengwaRune.THREE_DOTS, TengwaRune.ANNA ],TengwaRune.SILME ],
}

if (Object.freeze)
{
    Object.freeze(TengwarExampleTTOI1)
};
<|endoftext|>


<commit_before>import fs from 'fs'
import path from 'path'
import resolve from 'resolve'
import detective from 'detective'

function createModule(file) {
  const source = fs.readFileSync(file, 'utf-8')
  const requires = detective(source)

  return { file, requires }
}

export default function getModuleDependencies(entryFile) {
  const rootModule = createModule(entryFile)
  const modules = [rootModule]

  // Iterate over the modules, even when new
  // ones are being added
  for (const mdl of modules) {
    mdl.requires.forEach(dep => {
      try {
        const basedir = path.dirname(mdl.file)
        const depPath = resolve.sync(dep, { basedir })
        const depModule = createModule(depPath)

        modules.push(depModule)
      } catch (_err) {
        // eslint-disable-next-line no-empty
      }
    })
  }

  return modules
}
<commit_msg>Don't watch files in node_modules<commit_after>import fs from 'fs'
import path from 'path'
import resolve from 'resolve'
import detective from 'detective'

function createModule(file) {
  const source = fs.readFileSync(file, 'utf-8')
  const requires = detective(source)

  return { file, requires }
}

export default function getModuleDependencies(entryFile) {
  const rootModule = createModule(entryFile)
  const modules = [rootModule]

  // Iterate over the modules, even when new
  // ones are being added
  for (const mdl of modules) {
    mdl.requires
      .filter(dep => {
        // Only track local modules, not node_modules
        return dep.startsWith('./') || dep.startsWith('../')
      })
      .forEach(dep => {
        try {
          const basedir = path.dirname(mdl.file)
          const depPath = resolve.sync(dep, { basedir })
          const depModule = createModule(depPath)

          modules.push(depModule)
        } catch (_err) {
          // eslint-disable-next-line no-empty
        }
      })
  }

  return modules
}
<|endoftext|>


<commit_before>import { expect, renderComponent } from '../test-helper'
import LivePreview from '../../src/components/LivePreview'

describe('LivePreview', () => {
  let component

  beforeEach(() => {
    const props = {
      code: `var HelloMessage = React.createClass({
              render: function() {
                return
Hello {this.props.name}
;
              }
            });

            export default <HelloMessage name="CodeSheep" />;`,
    }
    component = renderComponent(LivePreview, props)
  })

  it('should have a correct class', () => {
    expect(component).to.have.class('live-preview')
  })

  it('should transform and execute code, then, display result', () => {
    expect(component).to.have.html(
      '
Hello ' +
      'CodeSheep
')
  })
})
<commit_msg>Fix test to use ReactDOM.render<commit_after>import { expect, renderComponent } from '../test-helper'
import LivePreview from '../../src/components/LivePreview'

describe('LivePreview', () => {
  let component

  beforeEach(() => {
    const props = {
      code: `var HelloMessage = React.createClass({
              render: function() {
                return
Hello {this.props.name}
;
              }
            });

            ReactDOM.render(<HelloMessage name="CodeSheep" />, mountNode);`,
    }
    component = renderComponent(LivePreview, props)
  })

  it('should have a correct class', () => {
    expect(component).to.have.class('live-preview')
  })

  it('should transform and execute code, then, display result', () => {
    expect(component).to.have.html(
      '
Hello ' +
      'CodeSheep
')
  })
})
<|endoftext|>


<commit_before>'use strict';

const common = require('../common/common');
const functions = require('../common/functions');

const expect = common.expect;
const wrapError = functions.wrapError;
const createAccount = functions.createAccount;
const util = common.util;

const currentApp = common.currentApp;

describe('bank transactions', () => {
  let sharedTransaction;
  let expenseAccountId;
  let expenseAccountCode;
  let bankAccountId;

  before('create an expense account for testing', () =>
    createAccount({ Type: 'EXPENSE' }).then(response => {
      expenseAccountId = response.entities[0].AccountID;
      expenseAccountCode = response.entities[0].Code;
    })
  );

  before('create a bank account for testing', () =>
    createAccount({
      Type: 'BANK',
      BankAccountNumber: '062-021-0000000',
    }).then(response => {
      bankAccountId = response.entities[0].AccountID;
    })
  );

  after('archive the expense account for testing', () => {
    currentApp.core.accounts.getAccount(expenseAccountId).then(response => {
      const account = response;
      account.Status = 'ARCHIVED';
      return account.save();
    });
  });

  it('creates a new transaction', done => {
    const transaction = currentApp.core.bankTransactions.newBankTransaction({
      Type: 'SPEND',
      Contact: {
        Name: 'Johnny McGibbons',
      },
      LineItems: [
        {
          Description: 'Annual Bank Account Fee',
          UnitAmount: 250,
          AccountCode: expenseAccountCode,
        },
      ],
      BankAccount: {
        AccountID: bankAccountId,
      },
    });

    transaction
      .save()
      .then(response => {
        expect(response.entities).to.have.length.greaterThan(0);
        expect(response.entities[0].BankTransactionID).to.not.equal('');
        expect(response.entities[0].BankTransactionID).to.not.equal(undefined);
        sharedTransaction = response.entities[0].BankTransactionID;
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

  it('get (no paging)', done => {
    currentApp.core.bankTransactions
      .getBankTransactions()
      .then(bankTransactions => {
        expect(bankTransactions).to.have.length.greaterThan(0);
        bankTransactions.forEach(bankTransaction => {
          expect(bankTransaction.BankTransactionID).to.not.equal('');
          expect(bankTransaction.BankTransactionID).to.not.equal(undefined);
        });
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

  it('get by id', done => {
    currentApp.core.bankTransactions
      .getBankTransaction(sharedTransaction)
      .then(bankTransaction => {
        expect(bankTransaction.BankTransactionID).to.not.equal('');
        expect(bankTransaction.BankTransactionID).to.not.equal(undefined);
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

  it('create multiple banktransactions', done => {
    const banktransactions = [];

    for (let i = 0; i < 2; i += 1) {
      banktransactions.push(
        currentApp.core.bankTransactions.newBankTransaction({
          Type: 'SPEND',
          Contact: {
            Name: 'Johnny McGibbons',
          },
          LineItems: [
            {
              Description: 'Annual Bank Account Fee',
              UnitAmount: Math.random(),
              AccountCode: expenseAccountCode,
            },
          ],
          BankAccount: {
            AccountID: bankAccountId,
          },
        })
      );
    }

    currentApp.core.bankTransactions
      .saveBankTransactions(banktransactions)
      .then(response => {
        expect(response.entities).to.have.length.greaterThan(0);
        response.entities.forEach(bankTransaction => {
          expect(bankTransaction.BankTransactionID).to.not.equal('');
          expect(bankTransaction.BankTransactionID).to.not.equal(undefined);
        });
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });
  it('get attachments for bankTransactions', done => {
    const filter = 'HasAttachments == true';
    currentApp.core.bankTransactions
      .getBankTransactions({ where: filter })
      .then(bankTransactions => {
        if (bankTransactions.length === 0) done();
        let objectsProcessed = 0;
        bankTransactions.forEach(transaction => {
          transaction
            .getAttachments()
            .then(attachments => {
              objectsProcessed += 1;
              attachments.forEach((attachment, index) => {
                expect(attachment.AttachmentID).to.not.equal('');
                expect(attachment.AttachmentID).to.not.equal(undefined);

                if (
                  objectsProcessed === bankTransactions.length &&
                  index === attachments.length - 1
                ) {
                  done();
                }
              });
            })
            .catch(err => {
              console.error(util.inspect(err, null, null));
            });
        });
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

  it('create multiple banktransactions', done => {
    const banktransactions = [];

    for (let i = 0; i < 2; i += 1) {
      banktransactions.push(
        currentApp.core.bankTransactions.newBankTransaction({
          Type: 'SPEND',
          Contact: {
            Name: 'Johnny McGibbons',
          },
          LineItems: [
            {
              Description: 'Annual Bank Account Fee',
              UnitAmount: Math.random(),
              AccountCode: expenseAccountCode,
            },
          ],
          BankAccount: {
            AccountID: bankAccountId,
          },
        })
      );
    }

    currentApp.core.bankTransactions
      .saveBankTransactions(banktransactions)
      .then(response => {
        expect(response.entities).to.have.length.greaterThan(0);
        response.entities.forEach(bankTransaction => {
          expect(bankTransaction.BankTransactionID).to.not.equal('');
          expect(bankTransaction.BankTransactionID).to.not.equal(undefined);
        });
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });
});
<commit_msg>I dont think it liked the math.random. It make it flicky<commit_after>'use strict';

const common = require('../common/common');
const functions = require('../common/functions');

const expect = common.expect;
const wrapError = functions.wrapError;
const createAccount = functions.createAccount;
const util = common.util;

const currentApp = common.currentApp;

describe('bank transactions', () => {
  let sharedTransaction;
  let expenseAccountId;
  let expenseAccountCode;
  let bankAccountId;

  before('create an expense account for testing', () =>
    createAccount({ Type: 'EXPENSE' }).then(response => {
      expenseAccountId = response.entities[0].AccountID;
      expenseAccountCode = response.entities[0].Code;
    })
  );

  before('create a bank account for testing', () =>
    createAccount({
      Type: 'BANK',
      BankAccountNumber: '062-021-0000000',
    }).then(response => {
      bankAccountId = response.entities[0].AccountID;
    })
  );

  after('archive the expense account for testing', () => {
    currentApp.core.accounts.getAccount(expenseAccountId).then(response => {
      const account = response;
      account.Status = 'ARCHIVED';
      return account.save();
    });
  });

  it('creates a new transaction', done => {
    const transaction = currentApp.core.bankTransactions.newBankTransaction({
      Type: 'SPEND',
      Contact: {
        Name: 'Johnny McGibbons',
      },
      LineItems: [
        {
          Description: 'Annual Bank Account Fee',
          UnitAmount: 250,
          AccountCode: expenseAccountCode,
        },
      ],
      BankAccount: {
        AccountID: bankAccountId,
      },
    });

    transaction
      .save()
      .then(response => {
        expect(response.entities).to.have.length.greaterThan(0);
        expect(response.entities[0].BankTransactionID).to.not.equal('');
        expect(response.entities[0].BankTransactionID).to.not.equal(undefined);
        sharedTransaction = response.entities[0].BankTransactionID;
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

  it('get (no paging)', done => {
    currentApp.core.bankTransactions
      .getBankTransactions()
      .then(bankTransactions => {
        expect(bankTransactions).to.have.length.greaterThan(0);
        bankTransactions.forEach(bankTransaction => {
          expect(bankTransaction.BankTransactionID).to.not.equal('');
          expect(bankTransaction.BankTransactionID).to.not.equal(undefined);
        });
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

  it('get by id', done => {
    currentApp.core.bankTransactions
      .getBankTransaction(sharedTransaction)
      .then(bankTransaction => {
        expect(bankTransaction.BankTransactionID).to.not.equal('');
        expect(bankTransaction.BankTransactionID).to.not.equal(undefined);
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

  it('create multiple banktransactions', done => {
    const banktransactions = [];

    for (let i = 0; i < 2; i += 1) {
      banktransactions.push(
        currentApp.core.bankTransactions.newBankTransaction({
          Type: 'SPEND',
          Contact: {
            Name: 'Johnny McGibbons',
          },
          LineItems: [
            {
              Description: 'Annual Bank Account Fee',
              UnitAmount: 0.01,
              AccountCode: expenseAccountCode,
            },
          ],
          BankAccount: {
            AccountID: bankAccountId,
          },
        })
      );
    }

    currentApp.core.bankTransactions
      .saveBankTransactions(banktransactions)
      .then(response => {
        expect(response.entities).to.have.length.greaterThan(0);
        response.entities.forEach(bankTransaction => {
          expect(bankTransaction.BankTransactionID).to.not.equal('');
          expect(bankTransaction.BankTransactionID).to.not.equal(undefined);
        });
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

  it('get attachments for bankTransactions', done => {
    const filter = 'HasAttachments == true';
    currentApp.core.bankTransactions
      .getBankTransactions({ where: filter })
      .then(bankTransactions => {
        if (bankTransactions.length === 0) done();
        let objectsProcessed = 0;
        bankTransactions.forEach(transaction => {
          transaction
            .getAttachments()
            .then(attachments => {
              objectsProcessed += 1;
              attachments.forEach((attachment, index) => {
                expect(attachment.AttachmentID).to.not.equal('');
                expect(attachment.AttachmentID).to.not.equal(undefined);

                if (
                  objectsProcessed === bankTransactions.length &&
                  index === attachments.length - 1
                ) {
                  done();
                }
              });
            })
            .catch(err => {
              console.error(util.inspect(err, null, null));
            });
        });
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });

  it('create multiple banktransactions', done => {
    const banktransactions = [];

    for (let i = 0; i < 2; i += 1) {
      banktransactions.push(
        currentApp.core.bankTransactions.newBankTransaction({
          Type: 'SPEND',
          Contact: {
            Name: 'Johnny McGibbons',
          },
          LineItems: [
            {
              Description: 'Annual Bank Account Fee',
              UnitAmount: Math.random(),
              AccountCode: expenseAccountCode,
            },
          ],
          BankAccount: {
            AccountID: bankAccountId,
          },
        })
      );
    }

    currentApp.core.bankTransactions
      .saveBankTransactions(banktransactions)
      .then(response => {
        expect(response.entities).to.have.length.greaterThan(0);
        response.entities.forEach(bankTransaction => {
          expect(bankTransaction.BankTransactionID).to.not.equal('');
          expect(bankTransaction.BankTransactionID).to.not.equal(undefined);
        });
        done();
      })
      .catch(err => {
        console.error(util.inspect(err, null, null));
        done(wrapError(err));
      });
  });
});
<|endoftext|>


<commit_before>"use strict";

var GLTexture = function (mage) {
    this.image = mage;
};

GLTexture.prototype.texture = null;
GLTexture.prototype.image = null;
GLTexture.prototype.uniform = null;

GLTexture.prototype.create = function (gl) {

    this.texture = gl.createTexture();

    if(!this.texture) {
        return console.error('failed to create texture');
    }

    return this;
};

GLTexture.prototype.bind = function (gl, program, uniformName, textureNum) {

    this.uniform = gl.getUniformLocation(program, uniformName);

    gl.activeTexture(gl.TEXTURE0);
    gl.bindTexture(gl.TEXTURE_2D, this.texture);

    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);

    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.image);
    gl.uniform1i(this.uniform, textureNum);

    return this;

};

module.exports = GLTexture;
<commit_msg>only bind image if image exists<commit_after>"use strict";

var GLTexture = function (mage) {
    this.image = mage;
};

GLTexture.prototype.texture = null;
GLTexture.prototype.image = null;
GLTexture.prototype.uniform = null;

GLTexture.prototype.create = function (gl) {
    this.texture = gl.createTexture();

    if(!this.texture) {
        return console.error('failed to create texture');
    }

    return this;
};

GLTexture.prototype.bind = function (gl, program, uniformName, textureNum) {
    this.uniform = gl.getUniformLocation(program, uniformName);

    gl.activeTexture(gl.TEXTURE0);
    gl.bindTexture(gl.TEXTURE_2D, this.texture);

    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);

    if (this.image) {
      gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.image);
    }
    gl.uniform1i(this.uniform, textureNum);

    return this;
};

module.exports = GLTexture;
<|endoftext|>