<commit_before>$(function() {

var example_data = [
    {
        label: 'node1',
        id: 123,  // extra data
        children: [
            { label: 'child1' },
            { label: 'child2' }
        ]
    },
    {
        label: 'node2',
        id: 124,
        children: [
            { label: 'child3' }
        ]
    }
];

var format_nodes = function(nodes) {
    var strings = $.map(nodes, function(node) {
        return node.name;
    });
    return strings.join(' ');
};

var isNodeClosed = function($node) {
    return (
        ($node.is('li.folder.closed')) &&
        ($node.find('a:eq(0)').is('a.toggler.closed')) &&
        ($node.find('ul:eq(0)').is('ul'))
    );
}

var isNodeOpen = function($node) {
    return (
        ($node.is('li.folder')) &&
        ($node.find('a:eq(0)').is('a.toggler')) &&
        ($node.find('ul:eq(0)').is('ul')) &&
        (! $node.is('li.folder.closed')) &&
        (! $node.find('span:eq(0)').is('a.toggler.closed'))
    );
}

module("jqtree", {
    teardown: function() {
        $('#tree1').tree('destroy');
    }
});

test("create jqtree from data", function() {
    $('#tree1').tree({
        data: example_data
    });

    equal(
        $('#tree1').children().length, 1,
        'number of children on level 0'
    );
    ok(
        $('#tree1').children().is('ul.tree'),
        'first element is ul.tree'
    );
    equal(
        $('#tree1 ul.tree > li').length, 2,
        'number of children on level 1'
    );
    ok(
        $('#tree1 ul.tree li:eq(0)').is('li.folder.closed'),
        'first child is li.folder.closed'
    );
    ok(
        $('#tree1 ul.tree li:eq(0) > div > a.toggler').is('a.toggler.closed'),
        'button in first folder'
    );
    equal(
        $('#tree1 ul.tree li:eq(0) > div span.title').text(),
        'node1'
    );
});

test('jqtree toggle', function() {
    // create tree
    var $tree = $('#tree1');
    $tree.tree({
        data: example_data
    });

    var tree = $tree.tree('getTree');
    var node1 = tree.children[0];
    var $node1 = $tree.find('ul.tree li:eq(0)');

    // node1 is initially closed
    ok(isNodeClosed($node1), 'node1 is open');

    stop();

    // open node1
    $tree.tree(
        'toggle',
        node1,
        function() {
            start();

            ok(isNodeOpen($node1), 'node1 is open');

            stop();

            // close node1
            $tree.tree(
                'toggle',
                node1,
                function() {
                    start();

                    ok(isNodeClosed($node1), 'node1 is closed');
                }
            );
        }
    );
});

// todo: test jqtree.getTree()

test("click event", function() {
    stop(2000);

    // create tree
    var $tree = $('#tree1');

    $tree.tree({
        data: example_data,
        onClick: function(node) {
            start();
            equal(node.name, 'node1');
        }
    });

    // click on node1
    var $node1 = $tree.find('ul.tree li:first');
    var $text_span = $node1.find('span:first');
    $text_span.click();
});

test('saveState', function() {
    var $tree = $('#tree1');

    var saved_state;

    function setState(state) {
        saved_state = state;
    }

    function getState() {
        return saved_state;
    }

    function createTree() {
        $tree.tree({
            data: example_data,
            saveState: true,
            onSetStateFromStorage: setState,
            onGetStateFromStorage: getState,
            selectable: true
        });
    }

    // create tree
    createTree();

    // nodes are initially closed
    var tree = $tree.tree('getTree');
    tree.iterate(function(node) {
        ok(! node.is_open, 'closed');
        return true;
    });

    // open node1
    $tree.tree('toggle', tree.children[0]);

    // node1 is open
    ok(tree.children[0].is_open, 'node1 is_open');

    // select node2
    $tree.tree('selectNode', tree.children[1]);

    // node2 is selected
    equal(
        $tree.tree('getSelectedNode').name,
        'node2',
        'getSelectedNode'
    );

    // create tree again
    $tree.tree('destroy');
    createTree();

    tree = $tree.tree('getTree');
    ok(tree.children[0].is_open, 'node1 is_open');
    ok(! tree.children[1].is_open, 'node2 is closed');

    // node2 is selected
    equal(
        $tree.tree('getSelectedNode').name,
        'node2',
        'getSelectedNode'
    );
});

test('getSelectedNode', function() {
    var $tree = $('#tree1');

    // create tree
    $tree.tree({
        data: example_data,
        selectable: true
    });

    // there is no node selected
    equal(
        $tree.tree('getSelectedNode'),
        false,
        'getSelectedNode'
    );

    // select node1
    var tree = $tree.tree('getTree');
    var node1 = tree.children[0];
    $tree.tree('selectNode', node1);

    // node1 is selected
    equal(
        $tree.tree('getSelectedNode').name,
        'node1',
        'getSelectedNode'
    );
});

test("tree toJson", function() {
    // setup
    var $tree = $('#tree1');
    $tree.tree({
        data: example_data
    });

    // 1. call toJson
    equal(
        $tree.tree('toJson'),
        '[{"name":"node1","children":'+
        '[{"name":"child1"},{"name":"child2"}],"id":123},'+
        '{"name":"node2","children":[{"name":"child3"}],"id":124}]'
    );

    // Check that properties 'children', 'parent' and 'element' still exist.
    var tree = $tree.tree('getTree');
    equal(tree.children.length, 2);
    ok(tree.children[0].parent != undefined, 'parent');
    ok($(tree.children[0].element).is('li'), 'element');
});

test("tree addNode", function() {
    // setup
    var $tree = $('#tree1');
    $tree.tree({
        data: {}
    });

    // 1. add node with children
    $tree.tree(
        'addNode',
        {
            label: 'abc',
            id: 1,
            children: [
                { label: 'c1' },
                { label: 'c2' }
            ]
        }
    );
});

module("Tree");
test("create tree from data", function() {
    var tree = new Tree.Tree();
    tree.loadFromData(example_data);

    equal(
        format_nodes(tree.children),
        'node1 node2',
        'nodes on level 1'
    );
    equal(
        format_nodes(tree.children[0].children),
        'child1 child2',
        'children of node1'
    );
    equal(
        format_nodes(tree.children[1].children),
        'child3',
        'children of node2'
    );
    equal(
        tree.children[0].id,
        123,
        'id'
    );
});

test("tree addChild", function() {
    var tree = new Tree.Tree('tree1');
    tree.addChild(
        new Tree.Node('abc')
    );
    tree.addChild(
        new Tree.Node('def')
    );

    equal(
        format_nodes(tree.children),
        'abc def',
        'children'
    );

    var node = tree.children[0];
    equal(
        node.parent.name,
        'tree1',
        'parent of node'
    );
});

test('tree addChildAtPosition', function() {
    var tree = new Tree.Tree();
    tree.addChildAtPosition(new Tree.Node('abc'), 0);  // first
    tree.addChildAtPosition(new Tree.Node('ghi'), 2);  // index 2 does not exist
    tree.addChildAtPosition(new Tree.Node('def'), 1);
    tree.addChildAtPosition(new Tree.Node('123'), 0);

    equal(
        format_nodes(tree.children),
        '123 abc def ghi',
        'children'
    );
});

test('tree removeChild', function() {
    var tree = new Tree.Tree();

    var abc = new Tree.Node('abc');
    var def = new Tree.Node('def');
    var ghi = new Tree.Node('ghi');
    tree.addChild(abc);
    tree.addChild(def);
    tree.addChild(ghi);

    equal(
        format_nodes(tree.children),
        'abc def ghi',
        'children'
    );

    // remove 'def'
    tree.removeChild(def);
    equal(
        format_nodes(tree.children),
        'abc ghi',
        'children'
    );

    // remove 'ghi'
    tree.removeChild(ghi);
    equal(
        format_nodes(tree.children),
        'abc',
        'children'
    );

    // remove 'abc'
    tree.removeChild(abc);
    equal(
        format_nodes(tree.children),
        '',
        'children'
    );
});

test('tree getChildIndex', function() {
    var tree = new Tree.Tree();

    var abc = new Tree.Node('abc');
    var def = new Tree.Node('def');
    var ghi = new Tree.Node('ghi');
    tree.addChild(abc);
    tree.addChild(def);
    tree.addChild(ghi);

    equal(
        tree.getChildIndex(def),
        1,
        'indef of def'
    );
});

test('tree hasChildren', function() {
    var tree = new Tree.Tree();
    equal(
        tree.hasChildren(),
        false,
        'tree without children'
    );

    tree.addChild(new Tree.Node('abc'));
    equal(
        tree.hasChildren(),
        true,
        'tree has children'
    );
});

test('tree iterate', function() {
    var tree = new Tree.Tree();
    tree.loadFromData(example_data);

    // iterate over all the nodes
    var nodes = [];
    tree.iterate(
        function(node, level) {
            nodes.push(node);
            return true;
        }
    );

    equal(
        format_nodes(nodes),
        'node1 child1 child2 node2 child3',
        'all nodes'
    );

    // iterate over nodes on first level
    nodes = [];
    tree.iterate(
        function(node, level) {
            nodes.push(node);
            return false;
        }
    );

    equal(
        format_nodes(nodes),
        'node1 node2',
        'nodes on first level'
    );
});

test('tree moveNode', function() {
    var tree = Tree.Tree.createFromData(example_data);

    /*
      node1
      ---child1
      ---child2
      node2
      ---child3
    */

    var node1 = tree.children[0];
    var node2 = tree.children[1];
    var child1 = node1.children[0];
    var child2 = node1.children[1];
    equal(node2.name, 'node2', 'node2 name');
    equal(child2.name, 'child2', 'child2 name');

    // move child2 after node2
    tree.moveNode(child2, node2, Tree.Position.AFTER);

    /*
      node1
      ---child1
      node2
      ---child3
      child2
    */
    equal(
        format_nodes(tree.children),
        'node1 node2 child2',
        'tree nodes at first level'
    );
    equal(
        format_nodes(node1.children),
        'child1',
        'node1 children'
    );

    // move child1 inside node2
    // this means it's the first child
    tree.moveNode(child1, node2, Tree.Position.INSIDE);

    /*
      node1
      node2
      ---child1
      ---child3
      child2
    */
    equal(
        format_nodes(node2.children),
        'child1 child3',
        'node2 children'
    );
    equal(
        format_nodes(node1.children),
        '',
        'node1 has no children'
    );

    // move child2 before child1
    tree.moveNode(child2, child1, Tree.Position.BEFORE);

    /*
      node1
      node2
      ---child2
      ---child1
      ---child3
    */
    equal(
        format_nodes(node2.children),
        'child2 child1 child3',
        'node2 children'
    );
    equal(
        format_nodes(tree.children),
        'node1 node2',
        'tree nodes at first level'
    );
});

});
<commit_msg>Fixed 'click event' test<commit_after>$(function() {

var example_data = [
    {
        label: 'node1',
        id: 123,  // extra data
        children: [
            { label: 'child1' },
            { label: 'child2' }
        ]
    },
    {
        label: 'node2',
        id: 124,
        children: [
            { label: 'child3' }
        ]
    }
];

var format_nodes = function(nodes) {
    var strings = $.map(nodes, function(node) {
        return node.name;
    });
    return strings.join(' ');
};

var isNodeClosed = function($node) {
    return (
        ($node.is('li.folder.closed')) &&
        ($node.find('a:eq(0)').is('a.toggler.closed')) &&
        ($node.find('ul:eq(0)').is('ul'))
    );
}

var isNodeOpen = function($node) {
    return (
        ($node.is('li.folder')) &&
        ($node.find('a:eq(0)').is('a.toggler')) &&
        ($node.find('ul:eq(0)').is('ul')) &&
        (! $node.is('li.folder.closed')) &&
        (! $node.find('span:eq(0)').is('a.toggler.closed'))
    );
}

module("jqtree", {
    teardown: function() {
        $('#tree1').tree('destroy');
    }
});

test("create jqtree from data", function() {
    $('#tree1').tree({
        data: example_data
    });

    equal(
        $('#tree1').children().length, 1,
        'number of children on level 0'
    );
    ok(
        $('#tree1').children().is('ul.tree'),
        'first element is ul.tree'
    );
    equal(
        $('#tree1 ul.tree > li').length, 2,
        'number of children on level 1'
    );
    ok(
        $('#tree1 ul.tree li:eq(0)').is('li.folder.closed'),
        'first child is li.folder.closed'
    );
    ok(
        $('#tree1 ul.tree li:eq(0) > div > a.toggler').is('a.toggler.closed'),
        'button in first folder'
    );
    equal(
        $('#tree1 ul.tree li:eq(0) > div span.title').text(),
        'node1'
    );
});

test('jqtree toggle', function() {
    // create tree
    var $tree = $('#tree1');
    $tree.tree({
        data: example_data
    });

    var tree = $tree.tree('getTree');
    var node1 = tree.children[0];
    var $node1 = $tree.find('ul.tree li:eq(0)');

    // node1 is initially closed
    ok(isNodeClosed($node1), 'node1 is open');

    stop();

    // open node1
    $tree.tree(
        'toggle',
        node1,
        function() {
            start();

            ok(isNodeOpen($node1), 'node1 is open');

            stop();

            // close node1
            $tree.tree(
                'toggle',
                node1,
                function() {
                    start();

                    ok(isNodeClosed($node1), 'node1 is closed');
                }
            );
        }
    );
});

// todo: test jqtree.getTree()

test("click event", function() {
    stop(2000);

    // create tree
    var $tree = $('#tree1');
    $tree.tree({
        data: example_data
    });

    $tree.bind('tree.click', function(e) {
        start();
        equal(e.node.name, 'node1');
    });

    // click on node1
    var $node1 = $tree.find('ul.tree li:first');
    var $text_span = $node1.find('span:first');
    $text_span.click();
});

test('saveState', function() {
    var $tree = $('#tree1');

    var saved_state;

    function setState(state) {
        saved_state = state;
    }

    function getState() {
        return saved_state;
    }

    function createTree() {
        $tree.tree({
            data: example_data,
            saveState: true,
            onSetStateFromStorage: setState,
            onGetStateFromStorage: getState,
            selectable: true
        });
    }

    // create tree
    createTree();

    // nodes are initially closed
    var tree = $tree.tree('getTree');
    tree.iterate(function(node) {
        ok(! node.is_open, 'closed');
        return true;
    });

    // open node1
    $tree.tree('toggle', tree.children[0]);

    // node1 is open
    ok(tree.children[0].is_open, 'node1 is_open');

    // select node2
    $tree.tree('selectNode', tree.children[1]);

    // node2 is selected
    equal(
        $tree.tree('getSelectedNode').name,
        'node2',
        'getSelectedNode'
    );

    // create tree again
    $tree.tree('destroy');
    createTree();

    tree = $tree.tree('getTree');
    ok(tree.children[0].is_open, 'node1 is_open');
    ok(! tree.children[1].is_open, 'node2 is closed');

    // node2 is selected
    equal(
        $tree.tree('getSelectedNode').name,
        'node2',
        'getSelectedNode'
    );
});

test('getSelectedNode', function() {
    var $tree = $('#tree1');

    // create tree
    $tree.tree({
        data: example_data,
        selectable: true
    });

    // there is no node selected
    equal(
        $tree.tree('getSelectedNode'),
        false,
        'getSelectedNode'
    );

    // select node1
    var tree = $tree.tree('getTree');
    var node1 = tree.children[0];
    $tree.tree('selectNode', node1);

    // node1 is selected
    equal(
        $tree.tree('getSelectedNode').name,
        'node1',
        'getSelectedNode'
    );
});

test("tree toJson", function() {
    // setup
    var $tree = $('#tree1');
    $tree.tree({
        data: example_data
    });

    // 1. call toJson
    equal(
        $tree.tree('toJson'),
        '[{"name":"node1","children":'+
        '[{"name":"child1"},{"name":"child2"}],"id":123},'+
        '{"name":"node2","children":[{"name":"child3"}],"id":124}]'
    );

    // Check that properties 'children', 'parent' and 'element' still exist.
    var tree = $tree.tree('getTree');
    equal(tree.children.length, 2);
    ok(tree.children[0].parent != undefined, 'parent');
    ok($(tree.children[0].element).is('li'), 'element');
});

test("tree addNode", function() {
    // setup
    var $tree = $('#tree1');
    $tree.tree({
        data: {}
    });

    // 1. add node with children
    $tree.tree(
        'addNode',
        {
            label: 'abc',
            id: 1,
            children: [
                { label: 'c1' },
                { label: 'c2' }
            ]
        }
    );
});

module("Tree");
test("create tree from data", function() {
    var tree = new Tree.Tree();
    tree.loadFromData(example_data);

    equal(
        format_nodes(tree.children),
        'node1 node2',
        'nodes on level 1'
    );
    equal(
        format_nodes(tree.children[0].children),
        'child1 child2',
        'children of node1'
    );
    equal(
        format_nodes(tree.children[1].children),
        'child3',
        'children of node2'
    );
    equal(
        tree.children[0].id,
        123,
        'id'
    );
});

test("tree addChild", function() {
    var tree = new Tree.Tree('tree1');
    tree.addChild(
        new Tree.Node('abc')
    );
    tree.addChild(
        new Tree.Node('def')
    );

    equal(
        format_nodes(tree.children),
        'abc def',
        'children'
    );

    var node = tree.children[0];
    equal(
        node.parent.name,
        'tree1',
        'parent of node'
    );
});

test('tree addChildAtPosition', function() {
    var tree = new Tree.Tree();
    tree.addChildAtPosition(new Tree.Node('abc'), 0);  // first
    tree.addChildAtPosition(new Tree.Node('ghi'), 2);  // index 2 does not exist
    tree.addChildAtPosition(new Tree.Node('def'), 1);
    tree.addChildAtPosition(new Tree.Node('123'), 0);

    equal(
        format_nodes(tree.children),
        '123 abc def ghi',
        'children'
    );
});

test('tree removeChild', function() {
    var tree = new Tree.Tree();

    var abc = new Tree.Node('abc');
    var def = new Tree.Node('def');
    var ghi = new Tree.Node('ghi');
    tree.addChild(abc);
    tree.addChild(def);
    tree.addChild(ghi);

    equal(
        format_nodes(tree.children),
        'abc def ghi',
        'children'
    );

    // remove 'def'
    tree.removeChild(def);
    equal(
        format_nodes(tree.children),
        'abc ghi',
        'children'
    );

    // remove 'ghi'
    tree.removeChild(ghi);
    equal(
        format_nodes(tree.children),
        'abc',
        'children'
    );

    // remove 'abc'
    tree.removeChild(abc);
    equal(
        format_nodes(tree.children),
        '',
        'children'
    );
});

test('tree getChildIndex', function() {
    var tree = new Tree.Tree();

    var abc = new Tree.Node('abc');
    var def = new Tree.Node('def');
    var ghi = new Tree.Node('ghi');
    tree.addChild(abc);
    tree.addChild(def);
    tree.addChild(ghi);

    equal(
        tree.getChildIndex(def),
        1,
        'indef of def'
    );
});

test('tree hasChildren', function() {
    var tree = new Tree.Tree();
    equal(
        tree.hasChildren(),
        false,
        'tree without children'
    );

    tree.addChild(new Tree.Node('abc'));
    equal(
        tree.hasChildren(),
        true,
        'tree has children'
    );
});

test('tree iterate', function() {
    var tree = new Tree.Tree();
    tree.loadFromData(example_data);

    // iterate over all the nodes
    var nodes = [];
    tree.iterate(
        function(node, level) {
            nodes.push(node);
            return true;
        }
    );

    equal(
        format_nodes(nodes),
        'node1 child1 child2 node2 child3',
        'all nodes'
    );

    // iterate over nodes on first level
    nodes = [];
    tree.iterate(
        function(node, level) {
            nodes.push(node);
            return false;
        }
    );

    equal(
        format_nodes(nodes),
        'node1 node2',
        'nodes on first level'
    );
});

test('tree moveNode', function() {
    var tree = Tree.Tree.createFromData(example_data);

    /*
      node1
      ---child1
      ---child2
      node2
      ---child3
    */

    var node1 = tree.children[0];
    var node2 = tree.children[1];
    var child1 = node1.children[0];
    var child2 = node1.children[1];
    equal(node2.name, 'node2', 'node2 name');
    equal(child2.name, 'child2', 'child2 name');

    // move child2 after node2
    tree.moveNode(child2, node2, Tree.Position.AFTER);

    /*
      node1
      ---child1
      node2
      ---child3
      child2
    */
    equal(
        format_nodes(tree.children),
        'node1 node2 child2',
        'tree nodes at first level'
    );
    equal(
        format_nodes(node1.children),
        'child1',
        'node1 children'
    );

    // move child1 inside node2
    // this means it's the first child
    tree.moveNode(child1, node2, Tree.Position.INSIDE);

    /*
      node1
      node2
      ---child1
      ---child3
      child2
    */
    equal(
        format_nodes(node2.children),
        'child1 child3',
        'node2 children'
    );
    equal(
        format_nodes(node1.children),
        '',
        'node1 has no children'
    );

    // move child2 before child1
    tree.moveNode(child2, child1, Tree.Position.BEFORE);

    /*
      node1
      node2
      ---child2
      ---child1
      ---child3
    */
    equal(
        format_nodes(node2.children),
        'child2 child1 child3',
        'node2 children'
    );
    equal(
        format_nodes(tree.children),
        'node1 node2',
        'tree nodes at first level'
    );
});

});
<|endoftext|>


<commit_before>// Generated on 2014-10-09 using generator-angular 0.9.8
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Configurable paths for the application
    var appConfig = {
        app: require('./bower.json').appPath || 'app',
        dist: 'dist'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: appConfig,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['wiredep']
            },
            js: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
                tasks: ['newer:jshint:all'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            jsTest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['newer:jshint:test', 'karma']
            },
            compass: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            readme: {
                files: ['README.md'],
                tasks: ['wiki']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: {
                src: [
                    'Gruntfile.js',
                    '<%= yeoman.app %>/scripts/{,*/}*.js'
                ]
            },
            test: {
                options: {
                    jshintrc: 'test/.jshintrc'
                },
                src: ['test/spec/{,*/}*.js']
            }
        },

        // Empties folders to start fresh
        clean: {
            dist: {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            '<%= yeoman.dist %>/{,*/}*',
                            '!<%= yeoman.dist %>/.git*'
                        ]
                    }
                ]
            },
            server: '.tmp',
            coverage: 'coverage',
            wiki: 'wiki'
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/styles/',
                        src: '{,*/}*.css',
                        dest: '.tmp/styles/'
                    }
                ]
            }
        },

        // Automatically inject Bower components into the app
        wiredep: {
            app: {
                src: ['<%= yeoman.app %>/index.html'],
                ignorePath: /\.\.\//
            },
            sass: {
                src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                ignorePath: /(\.\.\/){1,2}bower_components\//
            }
        },

        // Compiles Sass to CSS and generates necessary files if requested
        compass: {
            options: {
                sassDir: '<%= yeoman.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%= yeoman.app %>/images',
                javascriptsDir: '<%= yeoman.app %>/scripts',
                fontsDir: '<%= yeoman.app %>/styles/fonts',
                importPath: './bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                relativeAssets: false,
                assetCacheBuster: false,
                raw: 'Sass::Script::Number.precision = 10\n'
            },
            dist: {
                options: {
                    generatedImagesDir: '<%= yeoman.dist %>/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: true
                }
            }
        },

        // Renames files for browser caching purposes
        filerev: {
            dist: {
                src: [
                    '<%= yeoman.dist %>/scripts/{,*/}*.js',
                    '<%= yeoman.dist %>/styles/{,*/}*.css',
                    '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                    '<%= yeoman.dist %>/styles/fonts/*'
                ]
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>',
                flow: {
                    html: {
                        steps: {
                            js: ['concat', 'uglifyjs'],
                            css: ['cssmin']
                        },
                        post: {}
                    }
                }
            }
        },

        // Performs rewrites based on filerev and the useminPrepare configuration
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/images']
            }
        },

        // The following *-min tasks will produce minified files in the dist folder
        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        // cssmin: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/styles/main.css': [
        //         '.tmp/styles/{,*/}*.css'
        //       ]
        //     }
        //   }
        // },
        // uglify: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/scripts/scripts.js': [
        //         '<%= yeoman.dist %>/scripts/scripts.js'
        //       ]
        //     }
        //   }
        // },
        // concat: {
        //   dist: {}
        // },

        imagemin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>/images',
                        src: '{,*/}*.{png,jpg,jpeg,gif}',
                        dest: '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },

        svgmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>/images',
                        src: '{,*/}*.svg',
                        dest: '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    collapseBooleanAttributes: true,
                    removeCommentsFromCDATA: true,
                    removeOptionalTags: true
                },
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.dist %>',
                        src: ['*.html', 'views/{,*/}*.html'],
                        dest: '<%= yeoman.dist %>'
                    }
                ]
            }
        },

        // ng-annotate tries to make the code safe for minification automatically
        // by using the Angular long form for dependency injection.
        ngAnnotate: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/concat/scripts',
                        src: ['*.js', '!oldieshim.js'],
                        dest: '.tmp/concat/scripts'
                    }
                ]
            }
        },

        // Replace Google CDN references
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= yeoman.app %>',
                        dest: '<%= yeoman.dist %>',
                        src: [
                            '*.{ico,png,txt}',
                            '.htaccess',
                            '*.html',
                            'views/{,*/}*.html',
                            'images/{,*/}*.{webp}',
                            'fonts/*'
                        ]
                    },
                    {
                        expand: true,
                        cwd: '.tmp/images',
                        dest: '<%= yeoman.dist %>/images',
                        src: ['generated/*']
                    },
                    {
                        expand: true,
                        cwd: '.',
                        src: 'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*',
                        dest: '<%= yeoman.dist %>'
                    },
                    {
                        // Stupid hardcoded copying of CodeMirror extras
                        src: [
                            'mode/javascript/javascript.js',
                            'theme/mdn-like.css'
                        ].map(function (path) {
                            return 'bower_components/codemirror/' + path;
                        }),
                        dest: '<%= yeoman.dist %>/'
                    },
                    {
                        src: 'README.md',
                        dest: '<%= yeoman.dist %>/'
                    }
                ]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },

        // Run some tasks in parallel to speed up the build process
        concurrent: {
            server: [
                'compass:server'
            ],
            test: [
                'compass'
            ],
            dist: [
                'compass:dist',
                'imagemin',
                'svgmin'
            ]
        },

        // GitHub Pages settings
        'gh-pages': {
            options: {
                base: 'dist',
                branch: 'master'
            },
            src: ['**']
        },

        // Shell scripts
        shell: {
            options: {
                stderr: true,
                stdout: true
            },
            markdown: {
                command: './utils/markup_render.rb ./wiki/HOME.md ./app/views/README.md.html'
            },
            wikiDir: {
                command: 'mkdir wiki'
            },
            wiki: {
                command: 'curl https://raw.githubusercontent.com/wiki/takorogo/takorogo.github.io/Home.md -o wiki/Home.md'
            },
            list: {
                command: 'ls -la ./wiki'
            }
        },

        // Test settings
        karma: {
            unit: {
                configFile: 'test/karma.conf.js',
                singleRun: true
            }
        },

        // Coveralls.io
        coveralls: {
            local: {
                dryRun: true
            },
            ci: {
                dryRun: false,
                force: true
            },
            options: {
                debug: true,
                'coverage_dir': 'coverage/',
                force: false,
                recursive: true
            }
        }
    });

    grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'wiki',
            'wiredep',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve:' + target]);
    });

    grunt.registerTask('wiki', [
        'clean:wiki',
        'shell:wikiDir',
        'shell:wiki',
        'shell:list',
        'shell:markdown'
    ]);

    grunt.registerTask('ci', [
        'test',
        'coveralls:ci'
    ]);

    grunt.registerTask('test', [
        'clean:server',
        'wiki',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'clean:wiki',
        'karma'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'wiki',
        'wiredep',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngAnnotate',
        'copy:dist',
        'cdnify',
        'cssmin',
        'uglify',
        'filerev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'test',
        'build'
    ]);

    grunt.registerTask('deploy', [
        'test',
        'build',
        'gh-pages'
    ]);
};
<commit_msg>Remove debug for Travis.ci and use absolute paths for markdown renderer.<commit_after>// Generated on 2014-10-09 using generator-angular 0.9.8
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Configurable paths for the application
    var appConfig = {
        app: require('./bower.json').appPath || 'app',
        dist: 'dist'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: appConfig,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['wiredep']
            },
            js: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
                tasks: ['newer:jshint:all'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            jsTest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['newer:jshint:test', 'karma']
            },
            compass: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            readme: {
                files: ['README.md'],
                tasks: ['wiki']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: {
                src: [
                    'Gruntfile.js',
                    '<%= yeoman.app %>/scripts/{,*/}*.js'
                ]
            },
            test: {
                options: {
                    jshintrc: 'test/.jshintrc'
                },
                src: ['test/spec/{,*/}*.js']
            }
        },

        // Empties folders to start fresh
        clean: {
            dist: {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            '<%= yeoman.dist %>/{,*/}*',
                            '!<%= yeoman.dist %>/.git*'
                        ]
                    }
                ]
            },
            server: '.tmp',
            coverage: 'coverage',
            wiki: 'wiki'
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/styles/',
                        src: '{,*/}*.css',
                        dest: '.tmp/styles/'
                    }
                ]
            }
        },

        // Automatically inject Bower components into the app
        wiredep: {
            app: {
                src: ['<%= yeoman.app %>/index.html'],
                ignorePath: /\.\.\//
            },
            sass: {
                src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                ignorePath: /(\.\.\/){1,2}bower_components\//
            }
        },

        // Compiles Sass to CSS and generates necessary files if requested
        compass: {
            options: {
                sassDir: '<%= yeoman.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%= yeoman.app %>/images',
                javascriptsDir: '<%= yeoman.app %>/scripts',
                fontsDir: '<%= yeoman.app %>/styles/fonts',
                importPath: './bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                relativeAssets: false,
                assetCacheBuster: false,
                raw: 'Sass::Script::Number.precision = 10\n'
            },
            dist: {
                options: {
                    generatedImagesDir: '<%= yeoman.dist %>/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: true
                }
            }
        },

        // Renames files for browser caching purposes
        filerev: {
            dist: {
                src: [
                    '<%= yeoman.dist %>/scripts/{,*/}*.js',
                    '<%= yeoman.dist %>/styles/{,*/}*.css',
                    '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                    '<%= yeoman.dist %>/styles/fonts/*'
                ]
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>',
                flow: {
                    html: {
                        steps: {
                            js: ['concat', 'uglifyjs'],
                            css: ['cssmin']
                        },
                        post: {}
                    }
                }
            }
        },

        // Performs rewrites based on filerev and the useminPrepare configuration
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/images']
            }
        },

        // The following *-min tasks will produce minified files in the dist folder
        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        // cssmin: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/styles/main.css': [
        //         '.tmp/styles/{,*/}*.css'
        //       ]
        //     }
        //   }
        // },
        // uglify: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/scripts/scripts.js': [
        //         '<%= yeoman.dist %>/scripts/scripts.js'
        //       ]
        //     }
        //   }
        // },
        // concat: {
        //   dist: {}
        // },

        imagemin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>/images',
                        src: '{,*/}*.{png,jpg,jpeg,gif}',
                        dest: '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },

        svgmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>/images',
                        src: '{,*/}*.svg',
                        dest: '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    collapseBooleanAttributes: true,
                    removeCommentsFromCDATA: true,
                    removeOptionalTags: true
                },
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.dist %>',
                        src: ['*.html', 'views/{,*/}*.html'],
                        dest: '<%= yeoman.dist %>'
                    }
                ]
            }
        },

        // ng-annotate tries to make the code safe for minification automatically
        // by using the Angular long form for dependency injection.
        ngAnnotate: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/concat/scripts',
                        src: ['*.js', '!oldieshim.js'],
                        dest: '.tmp/concat/scripts'
                    }
                ]
            }
        },

        // Replace Google CDN references
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= yeoman.app %>',
                        dest: '<%= yeoman.dist %>',
                        src: [
                            '*.{ico,png,txt}',
                            '.htaccess',
                            '*.html',
                            'views/{,*/}*.html',
                            'images/{,*/}*.{webp}',
                            'fonts/*'
                        ]
                    },
                    {
                        expand: true,
                        cwd: '.tmp/images',
                        dest: '<%= yeoman.dist %>/images',
                        src: ['generated/*']
                    },
                    {
                        expand: true,
                        cwd: '.',
                        src: 'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*',
                        dest: '<%= yeoman.dist %>'
                    },
                    {
                        // Stupid hardcoded copying of CodeMirror extras
                        src: [
                            'mode/javascript/javascript.js',
                            'theme/mdn-like.css'
                        ].map(function (path) {
                            return 'bower_components/codemirror/' + path;
                        }),
                        dest: '<%= yeoman.dist %>/'
                    },
                    {
                        src: 'README.md',
                        dest: '<%= yeoman.dist %>/'
                    }
                ]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },

        // Run some tasks in parallel to speed up the build process
        concurrent: {
            server: [
                'compass:server'
            ],
            test: [
                'compass'
            ],
            dist: [
                'compass:dist',
                'imagemin',
                'svgmin'
            ]
        },

        // GitHub Pages settings
        'gh-pages': {
            options: {
                base: 'dist',
                branch: 'master'
            },
            src: ['**']
        },

        // Shell scripts
        shell: {
            options: {
                stderr: true,
                stdout: true
            },
            markdown: {
                command: [
                    './utils/markup_render.rb',
                    __dirname + '/wiki/HOME.md',
                    __dirname + '/app/views/README.md.html'
                ].join(' ')
            },
            wikiDir: {
                command: 'mkdir wiki'
            },
            wiki: {
                command: 'curl https://raw.githubusercontent.com/wiki/takorogo/takorogo.github.io/Home.md -o wiki/Home.md'
            }
        },

        // Test settings
        karma: {
            unit: {
                configFile: 'test/karma.conf.js',
                singleRun: true
            }
        },

        // Coveralls.io
        coveralls: {
            local: {
                dryRun: true
            },
            ci: {
                dryRun: false,
                force: true
            },
            options: {
                debug: true,
                'coverage_dir': 'coverage/',
                force: false,
                recursive: true
            }
        }
    });

    grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'wiki',
            'wiredep',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve:' + target]);
    });

    grunt.registerTask('wiki', [
        'clean:wiki',
        'shell:wikiDir',
        'shell:wiki',
        'shell:markdown'
    ]);

    grunt.registerTask('ci', [
        'test',
        'coveralls:ci'
    ]);

    grunt.registerTask('test', [
        'clean:server',
        'wiki',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'clean:wiki',
        'karma'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'wiki',
        'wiredep',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngAnnotate',
        'copy:dist',
        'cdnify',
        'cssmin',
        'uglify',
        'filerev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'test',
        'build'
    ]);

    grunt.registerTask('deploy', [
        'test',
        'build',
        'gh-pages'
    ]);
};
<|endoftext|>


<commit_before>/*!
 * Dragster - drag'n'drop library v1.0.0
 * https://github.com/sunpietro/dragster
 *
 * Copyright 2015 Piotr Nalepa
 * http://blog.piotrnalepa.pl
 *
 * Released under the MIT license
 * https://github.com/sunpietro/dragster/blob/master/LICENSE
 *
 * Date: 2015-03-11T08:00Z
 */
(function(e,t){e.DD=function(e){var n="is-dragging",r="is-drag-over",o="dragster-draggable",i="dragster-drag-region",s="dragster-drop-placeholder",a="dragster-temp",l="dragster-is-hidden",c={elementSelector:".dragster-block",regionSelector:".dragster-region"},d="draggable",u="data-placeholder-position",f={top:false,bottom:false},p,m,h,v,g,L,y,E,b,w,A,C,S,B,N,T,q;for(p in e){if(e.hasOwnProperty(p)){c[p]=e[p]}}y=Array.prototype.slice.call(t.querySelectorAll(c.elementSelector));m=Array.prototype.slice.call(t.querySelectorAll(c.regionSelector));h=function(e,t){var n=e.parentNode;if(!n||e.classList&&e.classList.contains(i)){return undefined}if(t(e)){return e}return t(n)?n:h(n,t)};q=function(e){var n=Array.prototype.slice.call(t.querySelectorAll(e));n.forEach(function(e){e.parentNode.removeChild(e)})};B=function(){var e=t.createElement("div");e.setAttribute(d,true);e.classList.add(o);return e};T=function(){var e=t.createElement("div");e.classList.add(s);return e};N=function(){var e=t.createElement("div");e.classList.add(a);e.classList.add(l);t.body.appendChild(e);return e};C=function(e,t){e.parentNode.insertBefore(t,e.nextSibling)};S=function(e,t){e.parentNode.insertBefore(t,e)};A=function(e){return e.classList&&e.classList.contains(i)};w=function(e){return e.classList&&e.classList.contains(o)};b=function(e){return e.classList&&e.classList.contains(s)};E={mousedown:function(e){e.preventDefault();var t,r=e.type==="touchstart"?"touchmove":"mousemove";m.forEach(function(e){e.addEventListener(r,E.mousemove)});L=h(e.target,w);if(!L){return false}t=L.getBoundingClientRect();v=N();v.innerHTML=L.innerHTML;v.style.width=t.width+"px";v.style.height=t.height+"px";g=v.getBoundingClientRect();L.classList.add(n)},mousemove:function(e){e.preventDefault();var n=e.changedTouches?e.changedTouches[0]:e,r=t.elementFromPoint(n.clientX,n.clientY),a=h(r,w),c,d,p;v.style.top=n.clientY+25+"px";v.style.left=n.clientX-g.width/2+"px";v.classList.remove(l);if(a&&a!==L){p=T();c=a.getBoundingClientRect();d=c.height/2;if(n.clientY-c.top<d&&!f.top){q("."+s);p.setAttribute(u,"top");S(a.firstChild,p)}else if(c.bottom-n.clientY<d&&!f.bottom){q("."+s);p.setAttribute(u,"bottom");a.appendChild(p)}}else if(r.classList.contains(i)&&r.querySelectorAll("."+o).length===0){p=T();r.appendChild(p)}},mouseup:function(e){var o=t.querySelector("."+s),i,l,c=e.type==="touchstart"?"touchmove":"mousemove",d;if(!L||!o){return false}L.classList.remove(n);i=h(o,w);i=i||o;if(L!==i){d=B();d.innerHTML=L.innerHTML;l=o.getAttribute(u);if(l==="top"){S(i,d)}else{C(i,d)}i.classList.remove(r);L.parentNode.removeChild(L)}m.forEach(function(e){e.removeEventListener(c,E.mousemove)});q("."+s);q("."+a)}};y.forEach(function(e){var t=B(),n=e.parentNode;n.insertBefore(t,e);n.removeChild(e);t.appendChild(e)});m.forEach(function(e){e.classList.add(i);e.addEventListener("mousedown",E.mousedown,false);e.addEventListener("mouseup",E.mouseup,false);e.addEventListener("touchstart",E.mousedown,false);e.addEventListener("touchend",E.mouseup,false)})}})(window,window.document);
<commit_msg>Updated the minified version of dragster library<commit_after>/*!
 * Dragster - drag'n'drop library v1.0.0
 * https://github.com/sunpietro/dragster
 *
 * Copyright 2015 Piotr Nalepa
 * http://blog.piotrnalepa.pl
 *
 * Released under the MIT license
 * https://github.com/sunpietro/dragster/blob/master/LICENSE
 *
 * Date: 2015-03-11T08:00Z
 */
(function(e,t){e.DD=function(e){var n="is-dragging",r="is-drag-over",o="dragster-draggable",i="dragster-drag-region",s="dragster-drop-placeholder",a="dragster-temp",l="dragster-is-hidden",c={elementSelector:".dragster-block",regionSelector:".dragster-region"},d="draggable",u="data-placeholder-position",f={top:false,bottom:false},p,m,h,g,v,L,y,E,b,w,A,C,S,q,B,N,T;for(p in e){if(e.hasOwnProperty(p)){c[p]=e[p]}}y=Array.prototype.slice.call(t.querySelectorAll(c.elementSelector));m=Array.prototype.slice.call(t.querySelectorAll(c.regionSelector));h=function(e,t){var n=e.parentNode;if(!n||e.classList&&e.classList.contains(i)){return undefined}if(t(e)){return e}return t(n)?n:h(n,t)};T=function(e){var n=Array.prototype.slice.call(t.querySelectorAll(e));n.forEach(function(e){e.parentNode.removeChild(e)})};q=function(){var e=t.createElement("div");e.setAttribute(d,true);e.classList.add(o);return e};N=function(){var e=t.createElement("div");e.classList.add(s);return e};B=function(){var e=t.createElement("div");e.classList.add(a);e.classList.add(l);t.body.appendChild(e);return e};C=function(e,t){e.parentNode.insertBefore(t,e.nextSibling)};S=function(e,t){e.parentNode.insertBefore(t,e)};A=function(e){return e.classList&&e.classList.contains(i)};w=function(e){return e.classList&&e.classList.contains(o)};b=function(e){return e.classList&&e.classList.contains(s)};E={mousedown:function(e){e.preventDefault();var t,r=e.type==="touchstart"?"touchmove":"mousemove";m.forEach(function(e){e.addEventListener(r,E.mousemove)});L=h(e.target,w);if(!L){return false}t=L.getBoundingClientRect();g=B();g.innerHTML=L.innerHTML;g.style.width=t.width+"px";g.style.height=t.height+"px";v=g.getBoundingClientRect();L.classList.add(n)},mousemove:function(e){e.preventDefault();var n=e.changedTouches?e.changedTouches[0]:e,r=t.elementFromPoint(n.clientX,n.clientY),a=h(r,w),c,d,p;g.style.top=n.clientY+25+"px";g.style.left=n.clientX-v.width/2+"px";g.classList.remove(l);if(a&&a!==L){p=N();c=a.getBoundingClientRect();d=c.height/2;if(n.clientY-c.top<d&&!f.top){T("."+s);p.setAttribute(u,"top");S(a.firstChild,p)}else if(c.bottom-n.clientY<d&&!f.bottom){T("."+s);p.setAttribute(u,"bottom");a.appendChild(p)}}else if(r.classList.contains(i)&&r.querySelectorAll("."+o).length===0&&r.querySelectorAll("."+s).length===0){p=N();r.appendChild(p)}},mouseup:function(e){var o=t.querySelector("."+s),i,l,c=e.type==="touchstart"?"touchmove":"mousemove",d;if(!L||!o){return false}L.classList.remove(n);i=h(o,w);i=i||o;if(L!==i){d=q();d.innerHTML=L.innerHTML;l=o.getAttribute(u);if(l==="top"){S(i,d)}else{C(i,d)}i.classList.remove(r);L.parentNode.removeChild(L)}m.forEach(function(e){e.removeEventListener(c,E.mousemove)});T("."+s);T("."+a)}};y.forEach(function(e){var t=q(),n=e.parentNode;n.insertBefore(t,e);n.removeChild(e);t.appendChild(e)});m.forEach(function(e){e.classList.add(i);e.addEventListener("mousedown",E.mousedown,false);e.addEventListener("mouseup",E.mouseup,false);e.addEventListener("touchstart",E.mousedown,false);e.addEventListener("touchend",E.mouseup,false)})}})(window,window.document);
<|endoftext|>


<commit_before>'use strict'

module.exports = {
  d: 'delayBetweenWorkers',
  n: 'maxConcurrentWorkers',
  w: 'maxConcurrentCallsPerWorker',
  r: 'maxRetries',
  autostart: 'autoStart'
}
<commit_msg>Improve alias<commit_after>'use strict'

module.exports = {
  d: 'delayBetweenWorkers',
  delay: 'delayBetweenWorkers',
  n: 'maxConcurrentWorkers',
  cores: 'maxConcurrentWorkers',
  w: 'maxConcurrentCallsPerWorker',
  workers: 'maxConcurrentCallsPerWorker',
  r: 'maxRetries',
  retries: 'maxRetries',
  autostart: 'autoStart'
}
<|endoftext|>


<commit_before>/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

window.$ = window.jQuery = require('jquery');
window.Popper = require('popper.js').default;

require('bootstrap');
<commit_msg>Configuring axios for headers and csrf<commit_after>/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

window.$ = window.jQuery = require('jquery');
window.Popper = require('popper.js').default;

require('bootstrap');

/**
 * We'll load the axios HTTP library which allows us to easily issue requests
 * to our Laravel back-end. This library automatically handles sending the
 * CSRF token as a header based on the value of the "XSRF" token cookie.
 */

window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

/**
 * Next we will register the CSRF Token as a common header with Axios so that
 * all outgoing HTTP requests automatically have it attached. This is just
 * a simple convenience so we don't have to attach every token manually.
 */

let token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {
    window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
    console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
<|endoftext|>


<commit_before>const router = require('express').Router();
const bodyParser = require('body-parser').json();
const petModel = require('../models/pet');
const petSnapshotModel = require('../models/pet-snapshot');

router
    .get('/:animalId/all', bodyParser, (req, res, next) => {
        //get all data related to a specific pet
        const animalId = req.params.animalId;
        const datapoints = 50; //arbitrary number of data points
        Promise
            .all([
                petModel
                    .findById(animalId)
                    .lean(),
                petSnapshotModel
                    .find({animalId})
                    .select('_id date animalId')
                    .sort('date')
                    .limit(datapoints)
                    .lean()
            ])
            .then(([pet,data]) => {
                pet.data = data;
                res.send(pet);
            })
            .catch(next);
    })
    .get('/:id', bodyParser, (req, res, next) => {
        // will get a specific snapshot
        const id = req.params.id;
        petSnapshotModel
            .findById(id)
            .lean()
            .then(snapshot => {
                res.send(snapshot);
            })
            .catch(next);
    })
    .put('/:id', bodyParser, (req, res, next) => {
        const id = req.params.id;
        petSnapshotModel
            .findByIdAndUpdate(id, req.body, { new: true, runValidators: true })
            .then(snapshot => {
                res.send(snapshot);
            })
            .catch(next);
    })
    .post('/:animalId', bodyParser, (req, res, next) => {
        // body must contain the pets id
        req.body.animalId = req.params.animalId;
        new petSnapshotModel(req.body).save()
            .then(data => {
                res.send(data);
            })
            .catch(next);
    })
    .delete('/:id', bodyParser, (req, res, next) => {
        // deletes a specific snapshot
        petSnapshotModel
            .findByIdAndRemove(req.params.id)
            .then(removedData => {
                res.send(removedData);
            })
            .catch(next);
    });

module.exports = router;
<commit_msg>made it so get all returned snapshot name<commit_after>const router = require('express').Router();
const bodyParser = require('body-parser').json();
const petModel = require('../models/pet');
const petSnapshotModel = require('../models/pet-snapshot');

router
    .get('/:animalId/all', bodyParser, (req, res, next) => {
        //get all data related to a specific pet
        const animalId = req.params.animalId;
        const datapoints = 50; //arbitrary number of data points
        Promise
            .all([
                petModel
                    .findById(animalId)
                    .lean(),
                petSnapshotModel
                    .find({animalId})
                    .select('_id date animalId snapshotName')
                    .sort('date')
                    .limit(datapoints)
                    .lean()
            ])
            .then(([pet,data]) => {
                pet.data = data;
                res.send(pet);
            })
            .catch(next);
    })
    .get('/:id', bodyParser, (req, res, next) => {
        // will get a specific snapshot
        const id = req.params.id;
        petSnapshotModel
            .findById(id)
            .lean()
            .then(snapshot => {
                res.send(snapshot);
            })
            .catch(next);
    })
    .put('/:id', bodyParser, (req, res, next) => {
        const id = req.params.id;
        petSnapshotModel
            .findByIdAndUpdate(id, req.body, { new: true, runValidators: true })
            .then(snapshot => {
                res.send(snapshot);
            })
            .catch(next);
    })
    .post('/:animalId', bodyParser, (req, res, next) => {
        // body must contain the pets id
        req.body.animalId = req.params.animalId;
        new petSnapshotModel(req.body).save()
            .then(data => {
                res.send(data);
            })
            .catch(next);
    })
    .delete('/:id', bodyParser, (req, res, next) => {
        // deletes a specific snapshot
        petSnapshotModel
            .findByIdAndRemove(req.params.id)
            .then(removedData => {
                res.send(removedData);
            })
            .catch(next);
    });

module.exports = router;
<|endoftext|>


<commit_before>const zlib = require('zlib');
const qs = require('querystring');
const http = require('http');
const https = require('https');
const URL = require('url');
const Stream = require('stream');
const FormData = require('./FormData');

const transports = {
  http,
  https,
  file: require('./transports/file'),
  http2: require('./transports/http2'),
};

function buildRequest(method, url) {
  const options = URL.parse(url);
  if (!options.protocol) throw new Error('URL must have a valid protocol');
  const transport = this.options.version === 2 ? transports.http2 : transports[options.protocol.replace(':', '')];
  options.method = method.toUpperCase();
  if (this.options.headers) options.headers = this.options.headers;
  if (this.options.agent) {
    options.agent = this.options.agent;
  } else if (transport.Agent && this.options.followRedirects !== false) {
    options.agent = new transport.Agent({ keepAlive: true });
  }
  this.options._req = options;
  const request = transport.request(options);
  return request;
}

function finalizeRequest({ data }) {
  return new Promise((resolve, reject) => {
    const request = this.request;

    const handleError = (err) => {
      if (!err) err = new Error('Unknown error occured');
      err.request = request;
      reject(err);
    };

    request.once('abort', handleError);
    request.once('aborted', handleError);
    request.once('error', handleError);

    request.once('response', (response) => {
      let stream = response;
      if (this._shouldUnzip(response)) {
        stream = response.pipe(zlib.createUnzip({
          flush: zlib.Z_SYNC_FLUSH,
          finishFlush: zlib.Z_SYNC_FLUSH,
        }));
      }

      const body = [];

      stream.on('data', (chunk) => {
        if (this.options.version !== 2) if (!this.push(chunk)) this.pause();
        body.push(chunk);
      });

      stream.once('end', () => {
        if (this.options.version === 2) for (const item of body) this.push(item);
        this.push(null);
        const raw = Buffer.concat(body);

        let redirect = false;
        if (this._shouldRedirect(response)) {
          redirect = /^https?:\/\//i.test(response.headers.location) ?
            response.headers.location :
            URL.resolve(makeURLFromRequest(request), response.headers.location);
        }
        resolve({ response, raw, redirect });
      });
    });

    this._addFinalHeaders();
    if (this.request.query) this.request.path = `${this.request.path}?${qs.stringify(this.request.query)}`;
    if (Array.isArray(data)) {
      for (const chunk of data) request.write(chunk);
      request.end();
    } else if (data instanceof Stream) {
      data.pipe(request);
    } else if (data instanceof Buffer) {
      this.set('Content-Length', Buffer.byteLength(data));
      request.end(data);
    } else {
      request.end(data);
    }
  });
}

function shouldSendRaw(data) {
  return data instanceof Buffer || data instanceof Stream;
}

function makeURLFromRequest(request) {
  return URL.format({
    protocol: request.connection.encrypted ? 'https:' : 'http:',
    hostname: request.getHeader('host'),
    pathname: request.path.split('?')[0],
    query: request.query,
  });
}

module.exports = {
  buildRequest, finalizeRequest, shouldSendRaw,
  METHODS: http.METHODS,
  STATUS_CODES: http.STATUS_CODES,
  FormData,
  extension: Stream.Readable,
};
<commit_msg>handle socket errors in a way that only node could think of<commit_after>const zlib = require('zlib');
const qs = require('querystring');
const http = require('http');
const https = require('https');
const URL = require('url');
const Stream = require('stream');
const FormData = require('./FormData');

const transports = {
  http,
  https,
  file: require('./transports/file'),
  http2: require('./transports/http2'),
};

function buildRequest(method, url) {
  const options = URL.parse(url);
  if (!options.protocol) throw new Error('URL must have a valid protocol');
  const transport = this.options.version === 2 ? transports.http2 : transports[options.protocol.replace(':', '')];
  options.method = method.toUpperCase();
  if (this.options.headers) options.headers = this.options.headers;
  if (this.options.agent) {
    options.agent = this.options.agent;
  } else if (transport.Agent && this.options.followRedirects !== false) {
    options.agent = new transport.Agent({ keepAlive: true });
  }
  this.options._req = options;
  const request = transport.request(options);
  return request;
}

function finalizeRequest({ data }) {
  return new Promise((resolve, reject) => {
    const request = this.request;

    const handleError = (err) => {
      if (!err) err = new Error('Unknown error occured');
      err.request = request;
      reject(err);
    };

    request.once('abort', handleError);
    request.once('error', handleError);
    request.once('socket', (socket) => {
      socket.once('error', handleError);
    });

    request.once('response', (response) => {
      let stream = response;
      if (this._shouldUnzip(response)) {
        stream = response.pipe(zlib.createUnzip({
          flush: zlib.Z_SYNC_FLUSH,
          finishFlush: zlib.Z_SYNC_FLUSH,
        }));
      }

      const body = [];

      stream.on('data', (chunk) => {
        if (this.options.version !== 2) if (!this.push(chunk)) this.pause();
        body.push(chunk);
      });

      stream.once('end', () => {
        if (this.options.version === 2) for (const item of body) this.push(item);
        this.push(null);
        const raw = Buffer.concat(body);

        let redirect = false;
        if (this._shouldRedirect(response)) {
          redirect = /^https?:\/\//i.test(response.headers.location) ?
            response.headers.location :
            URL.resolve(makeURLFromRequest(request), response.headers.location);
        }
        resolve({ response, raw, redirect });
      });
    });

    this._addFinalHeaders();
    if (this.request.query) this.request.path = `${this.request.path}?${qs.stringify(this.request.query)}`;
    if (Array.isArray(data)) {
      for (const chunk of data) request.write(chunk);
      request.end();
    } else if (data instanceof Stream) {
      data.pipe(request);
    } else if (data instanceof Buffer) {
      this.set('Content-Length', Buffer.byteLength(data));
      request.end(data);
    } else {
      request.end(data);
    }
  });
}

function shouldSendRaw(data) {
  return data instanceof Buffer || data instanceof Stream;
}

function makeURLFromRequest(request) {
  return URL.format({
    protocol: request.connection.encrypted ? 'https:' : 'http:',
    hostname: request.getHeader('host'),
    pathname: request.path.split('?')[0],
    query: request.query,
  });
}

module.exports = {
  buildRequest, finalizeRequest, shouldSendRaw,
  METHODS: http.METHODS,
  STATUS_CODES: http.STATUS_CODES,
  FormData,
  extension: Stream.Readable,
};
<|endoftext|>