<commit_before>var numberOfItemsToAdd = 100;
var Suites = [];

Suites.push({
    name: 'Vue',
    url: 'todomvc/vue/index.html',
    version: '0.10.0',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var app = contentWindow.app;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keyupEvent = document.createEvent('Event');
                keyupEvent.initEvent('keyup', true, true);
                keyupEvent.keyCode = 13;
                app.newTodo = 'Something to do ' + i;
                newTodo.dispatchEvent(keyupEvent)
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Backbone',
    url: 'todomvc/backbone/index.html',
    version: '1.1.2',
    prepare: function (runner, contentWindow, contentDocument) {
    contentWindow.Backbone.sync = function () {}
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var appView = contentWindow.appView;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keypressEvent = document.createEvent('Event');
                keypressEvent.initEvent('keypress', true, true);
                keypressEvent.which = 13;
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keypressEvent)
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Knockout',
    url: 'todomvc/knockoutjs/index.html',
    version: '3.1.0',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var viewModel = contentWindow.viewModel;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keyupEvent = document.createEvent('Event');
                keyupEvent.initEvent('keyup', true, true);
                keyupEvent.keyCode = 13;
                viewModel.current('Something to do ' + i);
                newTodo.dispatchEvent(keyupEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Ember',
    url: 'todomvc/emberjs/index.html',
    version: '1.4.0 + Handlebars 1.3.0',
    prepare: function (runner, contentWindow, contentDocument) {
        contentWindow.Todos.Store = contentWindow.DS.Store.extend({
            revision: 12,
            adapter: 'Todos.LSAdapter',
            commit: function () { }
        });

        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return {
                newTodo: element,
                views: contentWindow.Ember.View.views,
                emberRun: contentWindow.Ember.run
            }
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (params, contentWindow) {
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                params.emberRun(function () { params.views["new-todo"].set('value', 'Something to do' + i); });
                params.emberRun(function () {
                    var keyupEvent = document.createEvent('Event');
                    keyupEvent.initEvent('keyup', true, true);
                    keyupEvent.keyCode = 13;
                    params.newTodo.dispatchEvent(keyupEvent)
                });
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (params, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.ember-checkbox');
            for (var i = 0; i < checkboxes.length; i++) {
                var view = params.views[checkboxes[i].id];
                params.emberRun(function () { view.set('checked', true); });
            }
        }),
        new BenchmarkTestStep('DeletingItems', function (params, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                params.emberRun(function () { deleteButtons[i].click(); });
        })
    ]
});

Suites.push({
    name: 'Angular',
    url: 'todomvc/angularjs-perf/index.html',
    version: '1.2.14',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var submitEvent = document.createEvent('Event');
            submitEvent.initEvent('submit', true, true);
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var inputEvent = document.createEvent('Event');
                inputEvent.initEvent('input', true, true);
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(inputEvent);
                newTodo.form.dispatchEvent(submitEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'React',
    url: 'todomvc/react/index.html',
    version: '0.10.0',
    prepare: function (runner, contentWindow, contentDocument) {
        contentWindow.Utils.store = function () {}
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('keydown', true, true);
                keydownEvent.which = 13; // VK_ENTER
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Om',
    url: 'todomvc/om/index.html',
    version: '? + React 0.8.0',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var todomvc = contentWindow.todomvc;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('keydown', true, true);
                keydownEvent.which = 13; // VK_ENTER
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Om v',
    url: 'todomvc/om05/index.html',
    version: '0.5.0 + React 0.9.0',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var todomvc = contentWindow.todomvc;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('keydown', true, true);
                keydownEvent.which = 13; // VK_ENTER
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Ractive',
    url: 'todomvc/ractive/index.html',
    version: '0.3.9',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('keydown', true, true);
                keydownEvent.which = 13; // VK_ENTER
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Mercury',
    url: 'todomvc/mercury/index.html',
    version: '3.1.7',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('input', true, true);
                keydownEvent.keyCode = 13; // VK_ENTER
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});
<commit_msg>add enter event for mercury tests<commit_after>var numberOfItemsToAdd = 100;
var Suites = [];

Suites.push({
    name: 'Vue',
    url: 'todomvc/vue/index.html',
    version: '0.10.0',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var app = contentWindow.app;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keyupEvent = document.createEvent('Event');
                keyupEvent.initEvent('keyup', true, true);
                keyupEvent.keyCode = 13;
                app.newTodo = 'Something to do ' + i;
                newTodo.dispatchEvent(keyupEvent)
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Backbone',
    url: 'todomvc/backbone/index.html',
    version: '1.1.2',
    prepare: function (runner, contentWindow, contentDocument) {
    contentWindow.Backbone.sync = function () {}
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var appView = contentWindow.appView;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keypressEvent = document.createEvent('Event');
                keypressEvent.initEvent('keypress', true, true);
                keypressEvent.which = 13;
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keypressEvent)
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Knockout',
    url: 'todomvc/knockoutjs/index.html',
    version: '3.1.0',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var viewModel = contentWindow.viewModel;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keyupEvent = document.createEvent('Event');
                keyupEvent.initEvent('keyup', true, true);
                keyupEvent.keyCode = 13;
                viewModel.current('Something to do ' + i);
                newTodo.dispatchEvent(keyupEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Ember',
    url: 'todomvc/emberjs/index.html',
    version: '1.4.0 + Handlebars 1.3.0',
    prepare: function (runner, contentWindow, contentDocument) {
        contentWindow.Todos.Store = contentWindow.DS.Store.extend({
            revision: 12,
            adapter: 'Todos.LSAdapter',
            commit: function () { }
        });

        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return {
                newTodo: element,
                views: contentWindow.Ember.View.views,
                emberRun: contentWindow.Ember.run
            }
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (params, contentWindow) {
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                params.emberRun(function () { params.views["new-todo"].set('value', 'Something to do' + i); });
                params.emberRun(function () {
                    var keyupEvent = document.createEvent('Event');
                    keyupEvent.initEvent('keyup', true, true);
                    keyupEvent.keyCode = 13;
                    params.newTodo.dispatchEvent(keyupEvent)
                });
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (params, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.ember-checkbox');
            for (var i = 0; i < checkboxes.length; i++) {
                var view = params.views[checkboxes[i].id];
                params.emberRun(function () { view.set('checked', true); });
            }
        }),
        new BenchmarkTestStep('DeletingItems', function (params, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                params.emberRun(function () { deleteButtons[i].click(); });
        })
    ]
});

Suites.push({
    name: 'Angular',
    url: 'todomvc/angularjs-perf/index.html',
    version: '1.2.14',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var submitEvent = document.createEvent('Event');
            submitEvent.initEvent('submit', true, true);
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var inputEvent = document.createEvent('Event');
                inputEvent.initEvent('input', true, true);
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(inputEvent);
                newTodo.form.dispatchEvent(submitEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'React',
    url: 'todomvc/react/index.html',
    version: '0.10.0',
    prepare: function (runner, contentWindow, contentDocument) {
        contentWindow.Utils.store = function () {}
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('keydown', true, true);
                keydownEvent.which = 13; // VK_ENTER
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Om',
    url: 'todomvc/om/index.html',
    version: '? + React 0.8.0',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var todomvc = contentWindow.todomvc;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('keydown', true, true);
                keydownEvent.which = 13; // VK_ENTER
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Om v',
    url: 'todomvc/om05/index.html',
    version: '0.5.0 + React 0.9.0',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            var todomvc = contentWindow.todomvc;
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('keydown', true, true);
                keydownEvent.which = 13; // VK_ENTER
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Ractive',
    url: 'todomvc/ractive/index.html',
    version: '0.3.9',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('keydown', true, true);
                keydownEvent.which = 13; // VK_ENTER
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});

Suites.push({
    name: 'Mercury',
    url: 'todomvc/mercury/index.html',
    version: '3.1.7',
    prepare: function (runner, contentWindow, contentDocument) {
        return runner.waitForElement('#new-todo').then(function (element) {
            element.focus();
            return element;
        });
    },
    tests: [
        new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
            for (var i = 0; i < numberOfItemsToAdd; i++) {
                var inputEvent = document.createEvent('Event');
                inputEvent.initEvent('input', true, true);
                newTodo.value = 'Something to do ' + i;
                newTodo.dispatchEvent(inputEvent);

                var keydownEvent = document.createEvent('Event');
                keydownEvent.initEvent('keydown', true, true);
                keydownEvent.which = 13; // VK_ENTER
                newTodo.dispatchEvent(keydownEvent);
            }
        }),
        new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var checkboxes = contentDocument.querySelectorAll('.toggle');
            for (var i = 0; i < checkboxes.length; i++)
                checkboxes[i].click();
        }),
        new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
            var deleteButtons = contentDocument.querySelectorAll('.destroy');
            for (var i = 0; i < deleteButtons.length; i++)
                deleteButtons[i].click();
        })
    ]
});
<|endoftext|>


<commit_before>jQuery(function() {

    'use strict';

    var $ = jQuery;

    angular.module('wp-admin', ['ui.sortable'])

    .config(['$interpolateProvider', '$httpProvider', function($interpolateProvider, $httpProvider) {
        // Avoid Twig conflicts
        $interpolateProvider.startSymbol('((').endSymbol('))');

        // Post data as form data because Wordpress doesn't support JSON
        $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
        $httpProvider.defaults.transformRequest = function(obj) {
            var encodedStr = [];
            $.each(obj || {}, function(key, value) {
                encodedStr.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
            });
            return encodedStr.join('&');
        };
    }])

    /*
     * Sequential boxes
     */

    .factory('$sequentialBoxes', function() {
        var itemJustAdded = false;

        return {
            get itemJustAdded() {
                var cache = itemJustAdded;
                itemJustAdded = false;
                return cache;
            },

            set itemJustAdded(value) {
                itemJustAdded = value;
            }
        };
    })

    .directive('sequentialBoxes', ['$sequentialBoxes', function($sequentialBoxes) {

        function link(scope) {

            scope.data = [];

            try {
                // Parse the data instead of using two-way binding because UI.sortable can't reorder a two-way binded
                // array directly outputted in the HTML code
                scope.data = JSON.parse(scope.dataTxt) || [];
            } catch(e) {}

            scope.add = function() {
                if (angular.isDefined(scope.options.max) && scope.data >= scope.options.max) {
                    return;
                }

                $sequentialBoxes.itemJustAdded = true;
                scope.data.push({});
            };

            scope.remove = function(dataSet) {
                var index = scope.data.indexOf(dataSet);
                scope.data.splice(index, 1);
            };

        }

        return {
            restrict: 'E',
            scope: {
                name: '@',
                fields: '=',
                options: '=',
                dataTxt: '@data'
            },
            templateUrl: 'sequential-boxes.html',
            link: link
        };

    }])

    /*
     * WP Editor
     */

    .directive('wpEditor', function() {

        var link = function(scope, element, attrs, NgModelCtrl) {
            var id = 'boxes-wysiwyg-' + (new Date).getTime();
            element.find('textarea').attr('id', id);

            // Retrieve the current data
            scope.$watch(NgModelCtrl, function() {
                scope.text = NgModelCtrl.$modelValue;
            });

            // Initialize the editor, based on this repository: https://github.com/hezachary/wordpress-wysiwyg-widget
            setTimeout(function() {
                tinymce.execCommand('mceRemoveEditor', true, id);

                var initParams = tinymce.extend(tinyMCEPreInit.mceInit.__boxes_defaults, {
                    selector: '#' + id,
                    setup: function(editor) {
                        editor.on('change', function(e) {
                            scope.$apply(function() {
                                scope.text = editor.getContent();
                                NgModelCtrl.$setViewValue(scope.text);
                            });
                        });
                    }
                });

                tinymce.init(initParams);
            }, 0);

        };

        return {
            restrict: 'E',
            replace: true,
            require: 'ngModel',
            scope: {},
            templateUrl: 'wp-editor.html',
            link: link
        };

    })

    /*
     * Upload box
     */

    .directive('uploadBox', ['$http', '$timeout', '$sequentialBoxes', function($http, $timeout, $sequentialBoxes) {

        var filesExtensions = [];
        filesExtensions['archive'] = ['bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z'];
        filesExtensions['audio'] = ['aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma'];
        filesExtensions['code'] = ['css', 'htm', 'html', 'php', 'js'];
        filesExtensions['document'] = ['doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf'];
        filesExtensions['image'] = ['jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico'];
        filesExtensions['interactive'] = ['swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp'];
        filesExtensions['spreadsheet'] = ['numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb'];
        filesExtensions['text'] = ['asc', 'csv', 'tsv', 'txt'];
        filesExtensions['video'] = ['3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv'];

        /**
         * A wrapper to manage the media modal
         */
        function newFrame(callback) {
            var frame = wp.media({
                title: 'Sélectionner un fichier',
                // library: { type: 'image' },
                multiple: false
            });

            frame.state('library').on('select', function () {
                var image = this.get('selection').first().toJSON();
                callback(image.id, image.url);
            });

            return frame;
        }

        function link(scope, element, attrs, NgModelCtrl) {

            /**
             * Return the url of the picture (picture or icon in function of the type of file)
             */
            function getUrlPicture(url) {
                var fileExtension = url.split('.').pop();
                var file = [];

                for (var type in filesExtensions) {
                    if (filesExtensions[type].indexOf(fileExtension) != -1) {
                        if (type == "image") {
                            file['fileIcon'] = url;
                            file['fileName'] = "";
                        } else {
                            file['fileIcon'] = scope.imagesDir + type + '.png';
                            file['fileName'] = url.split('/').pop();
                        }
                    }
                }
                return file;
            }

            function select(id, url) {
                $timeout(function() {
                    scope.file.id = id;

                    // Update the model value
                    if (scope.binded) NgModelCtrl.$setViewValue(id);

                    // Retrieve the URL if necessary
                    if (id !== undefined && !url) {
                        $http.post('/wp-admin/admin-ajax.php', {
                            action: 'upload_box',
                            id: id
                        }).success(function(url) {
                            var file = getUrlPicture(url);
                            scope.file.iconUrl = file['fileIcon'];
                            scope.file.name = file['fileName'];
                        });
                    } else {
                        if (url !== undefined) {
                            var file = getUrlPicture(url);
                            scope.file.iconUrl = file['fileIcon'];
                            scope.file.name = file['fileName'];
                        } else {
                            scope.file.iconUrl = url;
                            scope.file.name = "";
                        }
                    }
                });
            }

            scope.frame = null;
            scope.binded = angular.isDefined(attrs.ngModel);

            // Elements of the file
            scope.file = {
                id: null,
                name: null,
                iconUrl: null,
            };

            // Manage options
            scope.options = {
                label: 'Ajouter une image',
                openModalOnAddition: false
            };

            try {
                scope.options = $.extend(scope.options, JSON.parse(attrs.options));
            } catch(e) {}

            // Retrieve the current data
            if (scope.binded) {
                scope.$watch(NgModelCtrl, function() {
                    select(NgModelCtrl.$modelValue);
                });
            } else {
                try {
                    var id = JSON.parse(attrs.value) || null;
                    id = isNaN(parseInt(id)) ? undefined : parseInt(id);
                    select(id);
                } catch(e) {
                    select();
                }
            }

            // Create a function to open a new modal
            scope.openModal = function() {
                scope.frame = scope.frame || newFrame(select);
                scope.frame.open();
            };

            scope.reset = function() {
                delete scope.file.id;
                if (scope.binded) NgModelCtrl.$setViewValue(undefined);
            };

            // If the `openModalOnAddition` is set to `true`, open the modal when an item is added.
            if (scope.options.openModalOnAddition && $sequentialBoxes.itemJustAdded) {
                $timeout(function() {
                    scope.openModal();
                });
            }

        }

        return {
            restrict: 'E',
            replace: true,
            require: '?ngModel',
            scope: {
                name: '@',
                imagesDir: '@'
            },
            templateUrl: 'upload-box.html',
            link: link
        };

    }])

    /*
     * Post box
     */

    .directive('postBox', [
        '$rootScope', '$http', '$timeout', '$sce', '$sequentialBoxes',
        function($rootScope, $http, $timeout, $sce, $sequentialBoxes) {

            var lastInputId = 0;

            // Alter the wpLink API to intercept the `close` and `update` “events”
            ['update', 'close'].forEach(function(eventName) {
                wpLink[eventName] = (function(eventCallback) {
                    return function() {
                        $rootScope.$emit('postBox:' + eventName);
                        eventCallback();
                    };
                })(wpLink[eventName]);
            });

            function link(scope, element, attrs, NgModelCtrl) {

                scope.binded = angular.isDefined(attrs.ngModel);;
                scope.inputId = 'post-box-' + lastInputId++;

                // Manage options
                scope.options = {
                    label: 'Sélectionner un contenu',
                    hideLabel: false,
                    openModalOnAddition: false
                };

                try {
                    scope.options = $.extend(scope.options, JSON.parse(attrs.options));
                } catch(e) {}

                // Create a wrapper to manage the wpLink modal
                scope.modal = {

                    $modal: $('#wp-link-wrap'),
                    $title: $('#wp-link-wrap #link-modal-title').contents()[0],
                    $search: $('#wp-link-wrap #search-field'),
                    $submit: $('#wp-link-wrap #wp-link-submit'),

                    opened: false,

                    open: function() {
                        this.opened = true;

                        this.originalStates = {
                            searchPanelWasVisible: this.$modal.hasClass('search-panel-visible'),
                            title: this.$title.textContent,
                            submit: this.$submit.val()
                        };

                        this.$modal.addClass('search-panel-visible post-box-modal');
                        wpLink.open(scope.inputId);

                        this.$title.textContent = scope.options.label;
                        this.$submit.val('Valider');
                        this.$search.focus();
                    },

                    update: function() {
                        if (!this.opened) {
                            return;
                        }

                        scope.loading = true;

                        var formPost = wpLink.getAttrs();

                        // Retrieve the ID of the post
                        $http.post('/wp-admin/admin-ajax.php', {
                            action: 'post_box',
                            permalink: formPost.href
                        }).success(function(post) {
                            scope.post = post;
                            scope.post.title = $sce.trustAsHtml(scope.post.title);

                            if (scope.binded) {
                                NgModelCtrl.$setViewValue(post.id);
                            }
                        }).finally(function() {
                            scope.loading = false;
                        });
                    },

                    close: function() {
                        if (!this.opened) {
                            return;
                        }

                        this.opened = false;

                        this.$modal.toggleClass('search-panel-visible', this.originalStates.searchPanelWasVisible)
                                   .removeClass('post-box-modal');

                        this.$title.textContent = this.originalStates.title;
                        this.$submit.val(this.originalStates.submit);
                    }

                };

                // Retrieve the current data
                function postFromId(id) {
                    if (typeof id != 'number' && (typeof id != 'string' || id.length == 0)) {
                        return;
                    }

                    scope.loading = true;

                    $http.post('/wp-admin/admin-ajax.php', {
                        action: 'post_box',
                        id: id
                    }).success(function(post) {
                        scope.post = post;
                        scope.post.title = $sce.trustAsHtml(scope.post.title);
                        scope.loading = false;
                    });
                }

                if (scope.binded) {
                    scope.$watch(NgModelCtrl, function() {
                        postFromId(NgModelCtrl.$modelValue);
                    });
                } else {
                    postFromId(attrs.value);
                }

                // Register a method to reset the directive state
                scope.reset = function() {
                    delete scope.post;
                    if (scope.binded) NgModelCtrl.$setViewValue(undefined);
                };

                // Listen to wpLink events
                ['update', 'close'].forEach(function(eventName) {
                    $rootScope.$on('postBox:' + eventName, function() {
                        scope.modal[eventName]();
                    });
                });

                if (scope.options.openModalOnAddition && $sequentialBoxes.itemJustAdded) {
                    $timeout(function() {
                        scope.modal.open();
                    });
                }

            }

            return {
                restrict: 'E',
                replace: true,
                require: '?ngModel',
                scope: {
                    name: '@'
                },
                templateUrl: 'post-box.html',
                link: link
            };

        }
    ]);

    /*
     * Bootstrapping
     */

    $('[boxes-bootstrap]').each(function() {
        angular.bootstrap(this, ['wp-admin']);
    });

});
<commit_msg>Improve code organization in boxes.js<commit_after>jQuery(function() {

    'use strict';

    var $ = jQuery;

    angular.module('wp-admin', ['ui.sortable'])

    .config(['$interpolateProvider', '$httpProvider', function($interpolateProvider, $httpProvider) {
        // Avoid Twig conflicts
        $interpolateProvider.startSymbol('((').endSymbol('))');

        // Post data as form data because Wordpress doesn't support JSON
        $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
        $httpProvider.defaults.transformRequest = function(obj) {
            var encodedStr = [];
            $.each(obj || {}, function(key, value) {
                encodedStr.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
            });
            return encodedStr.join('&');
        };
    }])

    /*
     * Sequential boxes
     */

    .factory('$sequentialBoxes', function() {
        var itemJustAdded = false;

        return {
            get itemJustAdded() {
                var cache = itemJustAdded;
                itemJustAdded = false;
                return cache;
            },

            set itemJustAdded(value) {
                itemJustAdded = value;
            }
        };
    })

    .directive('sequentialBoxes', ['$sequentialBoxes', function($sequentialBoxes) {

        function link(scope) {

            scope.data = [];

            try {
                // Parse the data instead of using two-way binding because UI.sortable can't reorder a two-way binded
                // array directly outputted in the HTML code
                scope.data = JSON.parse(scope.dataTxt) || [];
            } catch(e) {}

            scope.add = function() {
                if (angular.isDefined(scope.options.max) && scope.data >= scope.options.max) {
                    return;
                }

                $sequentialBoxes.itemJustAdded = true;
                scope.data.push({});
            };

            scope.remove = function(dataSet) {
                var index = scope.data.indexOf(dataSet);
                scope.data.splice(index, 1);
            };

        }

        return {
            restrict: 'E',
            scope: {
                name: '@',
                fields: '=',
                options: '=',
                dataTxt: '@data'
            },
            templateUrl: 'sequential-boxes.html',
            link: link
        };

    }])

    /*
     * WP Editor
     */

    .directive('wpEditor', function() {

        var link = function(scope, element, attrs, NgModelCtrl) {
            var id = 'boxes-wysiwyg-' + (new Date).getTime();
            element.find('textarea').attr('id', id);

            // Retrieve the current data
            scope.$watch(NgModelCtrl, function() {
                scope.text = NgModelCtrl.$modelValue;
            });

            // Initialize the editor, based on this repository: https://github.com/hezachary/wordpress-wysiwyg-widget
            setTimeout(function() {
                tinymce.execCommand('mceRemoveEditor', true, id);

                var initParams = tinymce.extend(tinyMCEPreInit.mceInit.__boxes_defaults, {
                    selector: '#' + id,
                    setup: function(editor) {
                        editor.on('change', function(e) {
                            scope.$apply(function() {
                                scope.text = editor.getContent();
                                NgModelCtrl.$setViewValue(scope.text);
                            });
                        });
                    }
                });

                tinymce.init(initParams);
            }, 0);

        };

        return {
            restrict: 'E',
            replace: true,
            require: 'ngModel',
            scope: {},
            templateUrl: 'wp-editor.html',
            link: link
        };

    })

    /*
     * Upload box
     */

    .directive('uploadBox', ['$http', '$timeout', '$sequentialBoxes', function($http, $timeout, $sequentialBoxes) {

        var filesExtensions = {
            archive: ['bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z'],
            audio: [
                'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram',
                'wav', 'wma'
            ],
            code: ['css', 'htm', 'html', 'php', 'js'],
            document: [
                'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf'
            ],
            image: ['jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico'],
            interactive: ['swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp'],
            spreadsheet: ['numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb'],
            text: ['asc', 'csv', 'tsv', 'txt'],
            video: [
                '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg',
                'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv'
            ]
        };

        /**
         * A wrapper to manage the media modal
         */
        function newFrame(callback) {
            var frame = wp.media({
                title: 'Sélectionner un fichier',
                // library: { type: 'image' },
                multiple: false
            });

            frame.state('library').on('select', function () {
                var image = this.get('selection').first().toJSON();
                callback(image.id, image.url);
            });

            return frame;
        }

        function link(scope, element, attrs, NgModelCtrl) {

            /**
             * Return the url of the picture (picture or icon in function of the type of file)
             */
            function setUrlPicture(url) {
                if (angular.isDefined(url)) {
                    var fileExtension = url.split('.').pop();

                    for (var type in filesExtensions) {
                        if (filesExtensions[type].indexOf(fileExtension) != -1) {
                            if (type == "image") {
                                scope.file.iconUrl = url;
                                scope.file.name = "";
                            } else {
                                scope.file.iconUrl = scope.imagesDir + type + '.png';
                                scope.file.name = url.split('/').pop();
                            }
                        }
                    }
                } else {
                    scope.file.iconUrl = url;
                    scope.file.name = "";
                }
            }

            function select(id, url) {
                $timeout(function() {
                    scope.file.id = id;

                    // Update the model value
                    if (scope.binded) NgModelCtrl.$setViewValue(id);

                    // Retrieve the URL if necessary
                    if (id !== undefined && !url) {
                        $http.post('/wp-admin/admin-ajax.php', {
                            action: 'upload_box',
                            id: id
                        }).success(setUrlPicture);
                    } else {
                        setUrlPicture(url);
                    }
                });
            }

            scope.frame = null;
            scope.binded = angular.isDefined(attrs.ngModel);

            // Elements of the file
            scope.file = {
                id: null,
                name: null,
                iconUrl: null,
            };

            // Manage options
            scope.options = {
                label: 'Ajouter une image',
                openModalOnAddition: false
            };

            try {
                scope.options = $.extend(scope.options, JSON.parse(attrs.options));
            } catch(e) {}

            // Retrieve the current data
            if (scope.binded) {
                scope.$watch(NgModelCtrl, function() {
                    select(NgModelCtrl.$modelValue);
                });
            } else {
                try {
                    var id = JSON.parse(attrs.value) || null;
                    id = isNaN(parseInt(id)) ? undefined : parseInt(id);
                    select(id);
                } catch(e) {
                    select();
                }
            }

            // Create a function to open a new modal
            scope.openModal = function() {
                scope.frame = scope.frame || newFrame(select);
                scope.frame.open();
            };

            scope.reset = function() {
                delete scope.file.id;
                if (scope.binded) NgModelCtrl.$setViewValue(undefined);
            };

            // If the `openModalOnAddition` is set to `true`, open the modal when an item is added.
            if (scope.options.openModalOnAddition && $sequentialBoxes.itemJustAdded) {
                $timeout(function() {
                    scope.openModal();
                });
            }

        }

        return {
            restrict: 'E',
            replace: true,
            require: '?ngModel',
            scope: {
                name: '@',
                imagesDir: '@'
            },
            templateUrl: 'upload-box.html',
            link: link
        };

    }])

    /*
     * Post box
     */

    .directive('postBox', [
        '$rootScope', '$http', '$timeout', '$sce', '$sequentialBoxes',
        function($rootScope, $http, $timeout, $sce, $sequentialBoxes) {

            var lastInputId = 0;

            // Alter the wpLink API to intercept the `close` and `update` “events”
            ['update', 'close'].forEach(function(eventName) {
                wpLink[eventName] = (function(eventCallback) {
                    return function() {
                        $rootScope.$emit('postBox:' + eventName);
                        eventCallback();
                    };
                })(wpLink[eventName]);
            });

            function link(scope, element, attrs, NgModelCtrl) {

                scope.binded = angular.isDefined(attrs.ngModel);;
                scope.inputId = 'post-box-' + lastInputId++;

                // Manage options
                scope.options = {
                    label: 'Sélectionner un contenu',
                    hideLabel: false,
                    openModalOnAddition: false
                };

                try {
                    scope.options = $.extend(scope.options, JSON.parse(attrs.options));
                } catch(e) {}

                // Create a wrapper to manage the wpLink modal
                scope.modal = {

                    $modal: $('#wp-link-wrap'),
                    $title: $('#wp-link-wrap #link-modal-title').contents()[0],
                    $search: $('#wp-link-wrap #search-field'),
                    $submit: $('#wp-link-wrap #wp-link-submit'),

                    opened: false,

                    open: function() {
                        this.opened = true;

                        this.originalStates = {
                            searchPanelWasVisible: this.$modal.hasClass('search-panel-visible'),
                            title: this.$title.textContent,
                            submit: this.$submit.val()
                        };

                        this.$modal.addClass('search-panel-visible post-box-modal');
                        wpLink.open(scope.inputId);

                        this.$title.textContent = scope.options.label;
                        this.$submit.val('Valider');
                        this.$search.focus();
                    },

                    update: function() {
                        if (!this.opened) {
                            return;
                        }

                        scope.loading = true;

                        var formPost = wpLink.getAttrs();

                        // Retrieve the ID of the post
                        $http.post('/wp-admin/admin-ajax.php', {
                            action: 'post_box',
                            permalink: formPost.href
                        }).success(function(post) {
                            scope.post = post;
                            scope.post.title = $sce.trustAsHtml(scope.post.title);

                            if (scope.binded) {
                                NgModelCtrl.$setViewValue(post.id);
                            }
                        }).finally(function() {
                            scope.loading = false;
                        });
                    },

                    close: function() {
                        if (!this.opened) {
                            return;
                        }

                        this.opened = false;

                        this.$modal.toggleClass('search-panel-visible', this.originalStates.searchPanelWasVisible)
                                   .removeClass('post-box-modal');

                        this.$title.textContent = this.originalStates.title;
                        this.$submit.val(this.originalStates.submit);
                    }

                };

                // Retrieve the current data
                function postFromId(id) {
                    if (typeof id != 'number' && (typeof id != 'string' || id.length == 0)) {
                        return;
                    }

                    scope.loading = true;

                    $http.post('/wp-admin/admin-ajax.php', {
                        action: 'post_box',
                        id: id
                    }).success(function(post) {
                        scope.post = post;
                        scope.post.title = $sce.trustAsHtml(scope.post.title);
                        scope.loading = false;
                    });
                }

                if (scope.binded) {
                    scope.$watch(NgModelCtrl, function() {
                        postFromId(NgModelCtrl.$modelValue);
                    });
                } else {
                    postFromId(attrs.value);
                }

                // Register a method to reset the directive state
                scope.reset = function() {
                    delete scope.post;
                    if (scope.binded) NgModelCtrl.$setViewValue(undefined);
                };

                // Listen to wpLink events
                ['update', 'close'].forEach(function(eventName) {
                    $rootScope.$on('postBox:' + eventName, function() {
                        scope.modal[eventName]();
                    });
                });

                if (scope.options.openModalOnAddition && $sequentialBoxes.itemJustAdded) {
                    $timeout(function() {
                        scope.modal.open();
                    });
                }

            }

            return {
                restrict: 'E',
                replace: true,
                require: '?ngModel',
                scope: {
                    name: '@'
                },
                templateUrl: 'post-box.html',
                link: link
            };

        }
    ]);

    /*
     * Bootstrapping
     */

    $('[boxes-bootstrap]').each(function() {
        angular.bootstrap(this, ['wp-admin']);
    });

});
<|endoftext|>


<commit_before>module.exports = {
	redisPort: 6379,
	redisHost: '178.62.87.119',
	messageTimeout: 200
};<commit_msg>Update config.js<commit_after>module.exports = {
	redisPort: 6379,
	redisHost: '178.62.87.119',
	messageTimeout: 1000
};
<|endoftext|>


<commit_before>(function($) {
	var togetherJSButtonClicked = function() {
		TogetherJS(this);
		return false;
	};

	$(function () {
		var $togetherJSStartButton = $("#wp-admin-bar-start_together_js_button > a");
		$togetherJSStartButton.attr("id", "start_together_js_button");
  		$togetherJSStartButton.click(togetherJSButtonClicked);
	});

	TogetherJSConfig_on_ready = function () {
	  $("#wp-admin-bar-start_together_js_button > a").text("End TogetherJS");
	};
	TogetherJSConfig_on_close = function () {
	  $("#wp-admin-bar-start_together_js_button > a").text("Start TogetherJS");
	};

})(jQuery);<commit_msg>Cleaned up config<commit_after>(function($) {
	var togetherJSButtonClicked = function() {
		TogetherJS(this);
		return false;
	};

	$(function () {
		var $togetherJSStartButton = $("#wp-admin-bar-start_together_js_button > a");
		$togetherJSStartButton.attr("id", "start_together_js_button");
  		$togetherJSStartButton.click(togetherJSButtonClicked);
	});

	TogetherJSConfig_on = {
	  	ready: function () {
		  	$("#wp-admin-bar-start_together_js_button > a").text("End TogetherJS");
		},
	  	close: function () {
		  	$("#wp-admin-bar-start_together_js_button > a").text("Start TogetherJS");
		}
	};

})(jQuery);<|endoftext|>


<commit_before>var config = (function(pgBrokerBaseURL) {
  return {
    "sukat": {
      "search": {
        "url": pgBrokerBaseURL + "/sukat/search"
      }
    },

    "map": {
      "autocomplete": {
        "url": pgBrokerBaseURL + "/geo/search"
      },
      "campuses": {
        "url": pgBrokerBaseURL + "/geo/campuses"
      },
      "location": {
        "url": pgBrokerBaseURL + "/geo/poi"
      },
      "icon": {
        "urlPrefix": pgBrokerBaseURL + "/image/view"
      }
    }
  };
})("http://pgbroker-dev.it.su.se");
<commit_msg>MOB-127 Remove autocomplete url from config since it will be removed from the broker<commit_after>var config = (function(pgBrokerBaseURL) {
  return {
    "sukat": {
      "search": {
        "url": pgBrokerBaseURL + "/sukat/search"
      }
    },

    "map": {
      "campuses": {
        "url": pgBrokerBaseURL + "/geo/campuses"
      },
      "location": {
        "url": pgBrokerBaseURL + "/geo/poi"
      },
      "icon": {
        "urlPrefix": pgBrokerBaseURL + "/image/view"
      }
    }
  };
})("http://pgbroker-dev.it.su.se");
<|endoftext|>


<commit_before>const { mkdirSync } = require("fs");
const { resolve } = require("path");

const vsce = require("vsce");

const package = require(resolve(__dirname, "..", "package.json"));

try {
    mkdirSync(resolve(__dirname, "..", "vsix"));
} catch (err) {
    if (err.code !== "EEXIST")
        throw err;
}

vsce.createVSIX({
    packagePath: resolve(__dirname, "..", "vsix", `${package.name}-${package.version}-${process.arch}.vsix`)
});
<commit_msg>Throw error when package failed<commit_after>const { mkdirSync } = require("fs");
const { resolve } = require("path");

const vsce = require("vsce");

const package = require(resolve(__dirname, "..", "package.json"));

try {
    mkdirSync(resolve(__dirname, "..", "vsix"));
} catch (err) {
    if (err.code !== "EEXIST")
        throw err;
}

vsce.createVSIX({
    packagePath: resolve(__dirname, "..", "vsix", `${package.name}-${package.version}-${process.arch}.vsix`)
}).catch(function(err) {
    console.error(err.stack);
    process.exit(-1);
});
<|endoftext|>


<commit_before>// ==UserScript==
// @id             iitc-plugin-show-linked-portals@fstopienski
// @name           IITC plugin: Show linked portals
// @category       Portal Info
// @version        0.0.8.@@DATETIMEVERSION@@
// @namespace      https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL      @@UPDATEURL@@
// @downloadURL    @@DOWNLOADURL@@
// @description    [@@BUILDNAME@@-@@BUILDDATE@@] Tries to show the linked portals (image, name and address) in portal detail view and jump to linked portal on click
// @include        https://www.ingress.com/intel*
// @include        http://www.ingress.com/intel*
// @match          https://www.ingress.com/intel*
// @match          http://www.ingress.com/intel*
// @grant          none
// ==/UserScript==

@@PLUGINSTART@@

// PLUGIN START ////////////////////////////////////////////////////////

/*
* 0.0.1 initial release, show images, names and addresses of linked portal in portal detailview
* - mouse click of the linked portal image selected the portal and adjust map
* - click of "Linked Portal is out of range" zoom a step out
*/

// use own namespace for plugin
window.plugin.showLinkedPortal = function () {
};

window.plugin.showLinkedPortal.handleUpdate = function () {
    if (!requests.isLastRequest('getThinnedEntitiesV4')) {
        return;
    }
}

window.plugin.showLinkedPortal.portalDetail = function (data) {
    // don't render linked portal data if portal is neutral.
    // (the data can remain sometimes - when a portal decays?)
    if (data.portalDetails.controllingTeam.team == 'NEUTRAL')
        return;

    var d = data.portalDetails.portalV2,
        c = 1;
    //get linked portals
    $(d.linkedEdges).each(function () {
        var portalInfo = window.plugin.showLinkedPortal.getPortalByGuid(this.otherPortalGuid);
        $('#portaldetails').append('
' + portalInfo + '
');
        c = c + 1;
    });

    $('.showLinkedPortalLink:not(.outOfRange)').bind('click', function () {
        var guid = $(this).attr('data-guid');
        if (window.portals[guid] !== undefined) {
            window.selectPortal($(this).attr('data-guid'));
            window.renderPortalDetails(window.selectedPortal);
            var portalDetails = window.portals[guid].options.details;
            var lat0 = portalDetails.locationE6.latE6 / 1E6;
            var lon0 = portalDetails.locationE6.lngE6 / 1E6;
            var Rlatlng = [lat0, lon0];
            map.setView(Rlatlng, map.getZoom());
        }
        else {
            map.setZoom((map.getZoom() - 1));
        }
    });
}

window.plugin.showLinkedPortal.getPortalByGuid = function (guid) {
    var portalInfoString = 'Linked  Portal out of range.';
    if (window.portals[guid] !== undefined) {
        var portalDetails = window.portals[guid].options.details;
        portalInfoString = '';
        var portalNameAdressAlt = "'" + portalDetails.portalV2.descriptiveText.TITLE + "' (" + portalDetails.portalV2.descriptiveText.ADDRESS + ")";
        var portalNameAdressTitle = $('
').append('\'')
                                               .append($('').text(portalDetails.portalV2.descriptiveText.TITLE))
                                               .append('\'')
                                               .append($('
'))
                                               .append($('').text('(' + portalDetails.portalV2.descriptiveText.ADDRESS + ')'))
                                               .html();
        var imageUrl = getPortalImageUrl(portalDetails);
        portalInfoString = $('
').html($('').attr('src', imageUrl)
                                                       .attr('class', 'minImg')
                                                       .attr('alt', portalNameAdressAlt)
                                                       .attr('title', portalNameAdressTitle))
                                      .html();
    }
    return portalInfoString;
};

window.plugin.showLinkedPortal.setupCallback = function () {
    // make the value update when the map data updates
    var handleDataResponseOrig = window.handleDataResponse;
    window.handleDataResponse = function (data, textStatus, jqXHR) {
        handleDataResponseOrig(data, textStatus, jqXHR);
        window.renderPortalDetails(window.selectedPortal);
    }
}

var setup = function () {
    window.addHook('requestFinished', window.plugin.showLinkedPortal.handleUpdate);
    window.addHook('portalDetailsUpdated', window.plugin.showLinkedPortal.portalDetail);
    $('head').append('');
    window.plugin.showLinkedPortal.setupCallback();
}
// PLUGIN END //////////////////////////////////////////////////////////

@@PLUGINEND@@
<commit_msg>add link direction info to tooltop on portal some tweaks/fixes to the formatting<commit_after>// ==UserScript==
// @id             iitc-plugin-show-linked-portals@fstopienski
// @name           IITC plugin: Show linked portals
// @category       Portal Info
// @version        0.1.0.@@DATETIMEVERSION@@
// @namespace      https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL      @@UPDATEURL@@
// @downloadURL    @@DOWNLOADURL@@
// @description    [@@BUILDNAME@@-@@BUILDDATE@@] Tries to show the linked portals (image, name and address) in portal detail view and jump to linked portal on click
// @include        https://www.ingress.com/intel*
// @include        http://www.ingress.com/intel*
// @match          https://www.ingress.com/intel*
// @match          http://www.ingress.com/intel*
// @grant          none
// ==/UserScript==

@@PLUGINSTART@@

// PLUGIN START ////////////////////////////////////////////////////////

/*
* 0.0.1 initial release, show images, names and addresses of linked portal in portal detailview
* - mouse click of the linked portal image selected the portal and adjust map
* - click of "Linked Portal is out of range" zoom a step out
*/

// use own namespace for plugin
window.plugin.showLinkedPortal = function () {
};

window.plugin.showLinkedPortal.handleUpdate = function () {
    if (!requests.isLastRequest('getThinnedEntitiesV4')) {
        return;
    }
}

window.plugin.showLinkedPortal.portalDetail = function (data) {
    // don't render linked portal data if portal is neutral.
    // (the data can remain sometimes - when a portal decays?)
    if (data.portalDetails.controllingTeam.team == 'NEUTRAL')
        return;

    var d = data.portalDetails.portalV2,
        c = 1;
    //get linked portals
    $(d.linkedEdges).each(function () {
        var portalInfo = window.plugin.showLinkedPortal.getPortalByGuid(this.otherPortalGuid, this.isOrigin);
        $('#portaldetails').append('
' + portalInfo + '
');
        c = c + 1;
    });

    $('.showLinkedPortalLink:not(.outOfRange)').bind('click', function () {
        var guid = $(this).attr('data-guid');
        if (window.portals[guid] !== undefined) {
            window.selectPortal($(this).attr('data-guid'));
            window.renderPortalDetails(window.selectedPortal);
            var portalDetails = window.portals[guid].options.details;
            var lat0 = portalDetails.locationE6.latE6 / 1E6;
            var lon0 = portalDetails.locationE6.lngE6 / 1E6;
            var Rlatlng = [lat0, lon0];
            map.setView(Rlatlng, map.getZoom());
        }
        else {
            // TODO: instead of just zooming out one level, check the link data for the start+end coordinates,
            // and fit the map view to the bounding box
            map.setZoom((map.getZoom() - 1));
        }
    });
}

window.plugin.showLinkedPortal.getPortalByGuid = function (guid,isorigin) {
    var linkDirection = $('').text(isorigin?'↴ outgoing link':'↳ incoming link');

    var portalInfoString;

    if (window.portals[guid] !== undefined) {
        var portalDetails = window.portals[guid].options.details;

        var portalNameAdressAlt = "'" + portalDetails.portalV2.descriptiveText.TITLE + "' (" + portalDetails.portalV2.descriptiveText.ADDRESS + ")";
        var portalNameAdressTitle = $('
').append($('').text(portalDetails.portalV2.descriptiveText.TITLE))
                                               .append($('
'))
                                               .append($('').text('(' + portalDetails.portalV2.descriptiveText.ADDRESS + ')'))
                                               .append($('
'))
                                               .append(linkDirection)
                                               .html();
        var imageUrl = getPortalImageUrl(portalDetails);
        portalInfoString = $('
').html($('').attr('src', imageUrl)
                                                       .attr('class', 'minImg')
                                                       .attr('alt', portalNameAdressAlt)
                                                       .attr('title', portalNameAdressTitle))
                                      .html();
    } else {
        var title = $('
').append($('').text('Zoom out'))
                               .append($('
'))
                               .append(linkDirection)
                               .html();

        portalInfoString = $('
').html($('').attr('class','outOfRange')
                                                        .attr('title',title)
                                                        .text('Portal out of range.'))
                                      .html();
    }

    return portalInfoString;
};

window.plugin.showLinkedPortal.setupCallback = function () {
    // make the value update when the map data updates
    var handleDataResponseOrig = window.handleDataResponse;
    window.handleDataResponse = function (data, textStatus, jqXHR) {
        handleDataResponseOrig(data, textStatus, jqXHR);
        window.renderPortalDetails(window.selectedPortal);
    }
}

var setup = function () {
    window.addHook('requestFinished', window.plugin.showLinkedPortal.handleUpdate);
    window.addHook('portalDetailsUpdated', window.plugin.showLinkedPortal.portalDetail);
    $('head').append('');
    window.plugin.showLinkedPortal.setupCallback();
}
// PLUGIN END //////////////////////////////////////////////////////////

@@PLUGINEND@@
<|endoftext|>


<commit_before>// Basic business process print data view
'use strict';

var _      = require('mano').i18n.bind('User')
  , format = require('es5-ext/date/#/format')
  , generateSections = require('eregistrations/view/components/generate-sections');

exports._parent = require('./print-base');

exports['print-page-title'] = function () {
	h2(_("Data of"), " ", this.businessProcess._businessName);
	p(format.call(new Date(), '%d/%m/%Y'));
};

exports.main = function () {
	insert(generateSections(this.businessProcess.cumulatedSections, {
		cssClass: ["section-primary", "entity-data-section-primary", "entity-data-section"]
	}));
};
<commit_msg>Proper data generation for bussiness process print data. #754<commit_after>// Basic business process print data view
'use strict';

var _      = require('mano').i18n.bind('User')
  , format = require('es5-ext/date/#/format')
  , generateSections = require('eregistrations/view/components/generate-sections');

exports._parent = require('./print-base');

exports['print-page-title'] = function () {
	h2(_("Data of"), " ", this.businessProcess._businessName);
	p(format.call(new Date(), '%d/%m/%Y'));
};

exports.main = function () {
	insert(generateSections(this.businessProcess.dataForms.processChainApplicable, {
		cssClass: ["section-primary", "entity-data-section-primary", "entity-data-section"]
	}));
};
<|endoftext|>


<commit_before>require(['event-bus'], function(bus) {
    bus.on('audio:play', function(e) {
        console.log('playing: ' + e.sound.attributes.title);
    })
});<commit_msg>Updated soundcloud-dom-inject script to post messages on PLAY and PAUSE.<commit_after>/**
 * Last.fm Scrobbler for Chrome - Soundcloud connector
 * @author Jeppe Hasseriis - https://github.com/cenobitedk
 *
 * This script runs in the context of soundcloud itself.
 * It listens to the page event bus, and propagates these
 * events to the extension via 'postMessage'.
 */

(function() {
  require(['event-bus'], function(bus) {
    bus.on('audio:play', function(e) {
      window.postMessage({
        type: 'SC_PLAY',
        metadata: e.sound.attributes
      }, '*');
    });
    bus.on('audio:pause', function(e) {
      window.postMessage({
        type: 'SC_PAUSE',
        metadata: e.sound.attributes
      }, '*');
    });
  });
}());
<|endoftext|>


<commit_before>/**
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * @version 1.0 Beta 2
 *
 * Ajaxifying likes - WIP
 */

/**
 * Simply invoke the constructor by calling dragDropAttachment
 *
 */
(function() {
	function likePosts() {}

	likePosts.prototype = function() {
		var likeUnlikePosts = function(e, mId, tId, ssId, ssVar) {
			var messageId = parseInt(mId, 10),
				topicId = parseInt(tId, 10),
				sessionId = sessionId,
				sessionVar = ssVar;

			$.ajax({
				url: elk_scripturl + '?action=likes;sa=unlikepost;topic=2;msg=2;dad5b604146=17d230dace20ed32359d95b065512fce',
				type: 'GET',
				error: function(err) {
					console.log('error');
					console.log(err);
				},
				success: function(resp) {
					console.log('success');
					console.log(resp);
				},
			});
		};

		return {
			likeUnlikePosts: likeUnlikePosts
		};
	}();

	// instead of this, we can use namespace too
	this.likePosts = likePosts;
}());
<commit_msg>- likes via ajax WIP<commit_after>/**
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * @version 1.0 Beta 2
 *
 * Ajaxifying likes - WIP
 */

/**
 * Simply invoke the constructor by calling dragDropAttachment
 *
 */
(function() {
	function likePosts() {}

	likePosts.prototype = function() {
		var likeUnlikePosts = function(e, mId, tId, ssId, ssVar) {
			var messageId = parseInt(mId, 10),
				topicId = parseInt(tId, 10),
				sessionId = ssId,
				sessionVar = ssVar,
				isLike = false;

			var check = $(e.target).attr('class');
			if (check.indexOf('unlike_button') >= 0) isLike = true;

			var values = {
				'action': 'likes',
				'sa': (isLike === false) ? 'likepost' : 'unlikepost',
				'topic': topicId,
				'msg': messageId,
			};
			values[sessionVar] = sessionId;

			$.ajax({
				url: elk_scripturl,
				type: 'GET',
				data: values,
				error: function(err) {
					console.log('error');
					// console.log(err);
				},
				success: function(resp) {
					console.log('success');
					// console.log(resp);
				},
			});
		};

		return {
			likeUnlikePosts: likeUnlikePosts
		};
	}();

	// instead of this, we can use namespace too
	this.likePosts = likePosts;
}());
<|endoftext|>


<commit_before>module.exports = function(grunt) {

	//Loads all grunt tasks matching the ['grunt-*', '@*/grunt-*'] patterns.
	require('load-grunt-tasks')(grunt);

	var now = new Date(); // Used for git commit message.

	grunt.initConfig({

		pkg: grunt.file.readJSON('package.json'),

		watch: {
			options: {
				livereload: true,
			},
			scss: {
				files: ['css/sass/*.scss', 'css/sass/**/*.scss'],
				tasks: ['compass', 'combine_mq', 'cssmin'],
				options: {
					spawn: false
				}
			},
			scripts: {
				files: ['js/config.js', 'js/modules/**/*.js'],
				tasks: ['jshint', 'requirejs']
			},
			src: {
				files: [
					'**/*.php',
					'**/*.css',
					'js/**/*.js',
					'css/sass/**/*.scss',
					'package.json',
					'**/*.png',
					'**/*.jpg',
					'**/*.gif',
					'Gruntfile.js',
					'!node_modules/*',
				],
				tasks: ['gitadd', 'gitcommit']
			}
		},

		gitadd: {
			task: {
				options: {
					force: true
				},
				files: {
					src: ['*']
				}
			}
		},

		gitcommit: {
			your_target: {
				options: {
					cwd: '../../',
					message: 'Repo updated on: ' + grunt.template.today()
				},
				files: [{
					src: ["*"],
					expand: true,
					cwd: 'themes/digitalportfolio'
				}]
			}
		},

		compass: {
			dist: {
				options: {
					config: 'config.rb',
					sassDir: 'css/sass',
					cssDir: 'css',
					environment: 'development'
				}
			}
		},

		combine_mq: {
			options: {
				beautify: true
			},
			main: {
				src: 'style.css',
				dest: 'style.css'
			}
		},

		cssmin: {
			target: {
				files: [{
					expand: true,
					cwd: 'css/sass',
					src: ['*.css']
				}]
			}
		},

		jshint: {
			all: ['Gruntfile.js']
		},

		requirejs: {
			compile: {
				options: {
					baseUrl: 'js',
					name: 'config',
					paths: {
						jquery: 'libraries/jquery-1.11.3.min',
						app: 'modules/app'
					},
					out: 'js/optimize.min.js'
				}
			}
		}
	});
	grunt.registerTask('default', [
		'grunt-contrib-grunt-git',
		'grunt-contrib-cssmin',
		'grunt-contrib-combine-mq',
		'grunt-contrib-compass',
		'grunt-contrib-jshint',
		'grunt-contrib-requirejs'
	]);
};<commit_msg>Repo updated on: Sun Dec 20 2015 13:59:23<commit_after>module.exports = function(grunt) {

	//Loads all grunt tasks matching the ['grunt-*', '@*/grunt-*'] patterns.
	require('load-grunt-tasks')(grunt);

	var now = new Date(); // Used for git commit message.

	grunt.initConfig({

		pkg: grunt.file.readJSON('package.json'),

		watch: {
			options: {
				livereload: true,
			},
			scss: {
				files: ['css/sass/*.scss', 'css/sass/**/*.scss'],
				tasks: ['compass', 'combine_mq', 'cssmin'],
				options: {
					spawn: false
				}
			},
			scripts: {
				files: ['js/config.js', 'js/modules/**/*.js'],
				tasks: ['jshint', 'requirejs']
			},
			src: {
				files: [
					'**/*.php',
					'**/*.css',
					'js/**/*.js',
					'css/sass/**/*.scss',
					'package.json',
					'**/*.png',
					'**/*.jpg',
					'**/*.gif',
					'Gruntfile.js',
					'!node_modules/*',
				],
				tasks: ['gitadd', 'gitcommit']
			}
		},

		gitadd: {
			task: {
				options: {
					force: true
				},
				files: {
					src: ['*']
				}
			}
		},

		gitcommit: {
			your_target: {
				options: {
					cwd: '../../',
					message: 'Repo updated on: ' + grunt.template.today()
				},
				files: [{
					src: ['**/**/**'],
					expand: true,
					cwd: 'themes/digitalportfolio'
				}]
			}
		},

		compass: {
			dist: {
				options: {
					config: 'config.rb',
					sassDir: 'css/sass',
					cssDir: 'css',
					environment: 'development'
				}
			}
		},

		combine_mq: {
			options: {
				beautify: true
			},
			main: {
				src: 'style.css',
				dest: 'style.css'
			}
		},

		cssmin: {
			target: {
				files: [{
					expand: true,
					cwd: 'css/sass',
					src: ['*.css']
				}]
			}
		},

		jshint: {
			all: ['Gruntfile.js']
		},

		requirejs: {
			compile: {
				options: {
					baseUrl: 'js',
					name: 'config',
					paths: {
						jquery: 'libraries/jquery-1.11.3.min',
						app: 'modules/app'
					},
					out: 'js/optimize.min.js'
				}
			}
		}
	});
	grunt.registerTask('default', [
		'grunt-contrib-grunt-git',
		'grunt-contrib-cssmin',
		'grunt-contrib-combine-mq',
		'grunt-contrib-compass',
		'grunt-contrib-jshint',
		'grunt-contrib-requirejs'
	]);
};<|endoftext|>