diff --git a/build/bundle.js b/build/bundle.js index cf274434..39bdc332 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -8435,35 +8435,30 @@ var GitError = exports.GitError = MyError.extend({ require.define("/src/js/views/rebaseView.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError; var _ = require('underscore'); +var Q = require('q'); // horrible hack to get localStorage Backbone plugin -var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone; +var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone; var ModalTerminal = require('../views').ModalTerminal; var BaseView = require('../views').BaseView; +var ConfirmCancelView = require('../views').ConfirmCancelView; var InteractiveRebaseView = BaseView.extend({ tagName: 'div', template: _.template($('#interactive-rebase-template').html()), - events: { - 'click #confirmButton': 'confirmed' - }, - initialize: function(options) { - this.hasClicked = false; this.deferred = options.deferred; - - this.rebaseArray = options.toRebase; - - this.rebaseEntries = new RebaseEntryCollection(); this.rebaseMap = {}; this.entryObjMap = {}; - this.rebaseArray.reverse(); - // make basic models for each commit - _.each(this.rebaseArray, function(commit) { + this.rebaseEntries = new RebaseEntryCollection(); + options.toRebase.reverse(); + _.each(options.toRebase, function(commit) { var id = commit.get('id'); this.rebaseMap[id] = commit; + + // make basic models for each commit this.entryObjMap[id] = new RebaseEntry({ id: id }); @@ -8473,22 +8468,13 @@ var InteractiveRebaseView = BaseView.extend({ this.container = new ModalTerminal({ title: 'Interactive Rebase' }); - this.render(); // show the dialog holder this.show(); }, - confirmed: function() { - // we hide the dialog anyways, but they might be fast clickers - if (this.hasClicked) { - return; - } - this.hasClicked = true; - - // first of all hide - this.$('#iRebaseDialog').css('display', 'none'); + confirm: function() { this.hide(); // get our ordering @@ -8500,7 +8486,7 @@ var InteractiveRebaseView = BaseView.extend({ // now get the real array var toRebase = []; _.each(uiOrder, function(id) { - // the model + // the model pick check if (this.entryObjMap[id].get('pick')) { toRebase.unshift(this.rebaseMap[id]); } @@ -8513,7 +8499,7 @@ var InteractiveRebaseView = BaseView.extend({ render: function() { var json = { - num: this.rebaseArray.length + num: _.keys(this.rebaseMap).length }; var destination = this.container.getInsideElement(); @@ -8535,6 +8521,27 @@ var InteractiveRebaseView = BaseView.extend({ placeholder: 'rebaseEntry transitionOpacity ui-state-highlight', appendTo: 'parent' }); + + this.makeButtons(); + }, + + makeButtons: function() { + // control for button + var deferred = Q.defer(); + deferred.promise + .then(_.bind(function() { + this.confirm(); + }, this)) + .fail(_.bind(function() { + this.deferred.reject(); + }, this)) + .done(); + + // finally get our buttons + new ConfirmCancelView({ + destination: this.$('.confirmCancel'), + deferred: deferred + }); } }); @@ -8589,6 +8596,44 @@ var _ = require('underscore'); // horrible hack to get localStorage Backbone plugin var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone; +var ConfirmCancelView = Backbone.View.extend({ + tagName: 'div', + className: 'box horizontal justify', + template: _.template($('#confirm-cancel-template').html()), + events: { + 'click .confirmButton': 'confirmed', + 'click .cancelButton': 'cancel' + }, + + initialize: function(options) { + if (!options.destination || !options.deferred) { + throw new Error('needmore'); + } + + this.destination = options.destination; + this.deferred = options.deferred; + this.JSON = { + confirm: options.confirm || 'Confirm', + cancel: options.cancel || 'Cancel' + }; + + this.render(); + }, + + confirmed: function() { + this.deferred.resolve(); + }, + + cancel: function() { + this.deferred.reject(); + }, + + render: function() { + this.$el.html(this.template(this.JSON)); + $(this.destination).append(this.el); + } +}); + var BaseView = Backbone.View.extend({ render: function() { var destination = this.container.getInsideElement(); @@ -8695,6 +8740,7 @@ exports.ModalView = ModalView; exports.ModalTerminal = ModalTerminal; exports.ModalAlert = ModalAlert; exports.BaseView = BaseView; +exports.ConfirmCancelView = ConfirmCancelView; }); @@ -14423,6 +14469,44 @@ var _ = require('underscore'); // horrible hack to get localStorage Backbone plugin var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone; +var ConfirmCancelView = Backbone.View.extend({ + tagName: 'div', + className: 'box horizontal justify', + template: _.template($('#confirm-cancel-template').html()), + events: { + 'click .confirmButton': 'confirmed', + 'click .cancelButton': 'cancel' + }, + + initialize: function(options) { + if (!options.destination || !options.deferred) { + throw new Error('needmore'); + } + + this.destination = options.destination; + this.deferred = options.deferred; + this.JSON = { + confirm: options.confirm || 'Confirm', + cancel: options.cancel || 'Cancel' + }; + + this.render(); + }, + + confirmed: function() { + this.deferred.resolve(); + }, + + cancel: function() { + this.deferred.reject(); + }, + + render: function() { + this.$el.html(this.template(this.JSON)); + $(this.destination).append(this.el); + } +}); + var BaseView = Backbone.View.extend({ render: function() { var destination = this.container.getInsideElement(); @@ -14529,6 +14613,7 @@ exports.ModalView = ModalView; exports.ModalTerminal = ModalTerminal; exports.ModalAlert = ModalAlert; exports.BaseView = BaseView; +exports.ConfirmCancelView = ConfirmCancelView; }); @@ -14690,35 +14775,30 @@ require("/src/js/views/miscViews.js"); require.define("/src/js/views/rebaseView.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError; var _ = require('underscore'); +var Q = require('q'); // horrible hack to get localStorage Backbone plugin -var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone; +var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone; var ModalTerminal = require('../views').ModalTerminal; var BaseView = require('../views').BaseView; +var ConfirmCancelView = require('../views').ConfirmCancelView; var InteractiveRebaseView = BaseView.extend({ tagName: 'div', template: _.template($('#interactive-rebase-template').html()), - events: { - 'click #confirmButton': 'confirmed' - }, - initialize: function(options) { - this.hasClicked = false; this.deferred = options.deferred; - - this.rebaseArray = options.toRebase; - - this.rebaseEntries = new RebaseEntryCollection(); this.rebaseMap = {}; this.entryObjMap = {}; - this.rebaseArray.reverse(); - // make basic models for each commit - _.each(this.rebaseArray, function(commit) { + this.rebaseEntries = new RebaseEntryCollection(); + options.toRebase.reverse(); + _.each(options.toRebase, function(commit) { var id = commit.get('id'); this.rebaseMap[id] = commit; + + // make basic models for each commit this.entryObjMap[id] = new RebaseEntry({ id: id }); @@ -14728,22 +14808,13 @@ var InteractiveRebaseView = BaseView.extend({ this.container = new ModalTerminal({ title: 'Interactive Rebase' }); - this.render(); // show the dialog holder this.show(); }, - confirmed: function() { - // we hide the dialog anyways, but they might be fast clickers - if (this.hasClicked) { - return; - } - this.hasClicked = true; - - // first of all hide - this.$('#iRebaseDialog').css('display', 'none'); + confirm: function() { this.hide(); // get our ordering @@ -14755,7 +14826,7 @@ var InteractiveRebaseView = BaseView.extend({ // now get the real array var toRebase = []; _.each(uiOrder, function(id) { - // the model + // the model pick check if (this.entryObjMap[id].get('pick')) { toRebase.unshift(this.rebaseMap[id]); } @@ -14768,7 +14839,7 @@ var InteractiveRebaseView = BaseView.extend({ render: function() { var json = { - num: this.rebaseArray.length + num: _.keys(this.rebaseMap).length }; var destination = this.container.getInsideElement(); @@ -14790,6 +14861,27 @@ var InteractiveRebaseView = BaseView.extend({ placeholder: 'rebaseEntry transitionOpacity ui-state-highlight', appendTo: 'parent' }); + + this.makeButtons(); + }, + + makeButtons: function() { + // control for button + var deferred = Q.defer(); + deferred.promise + .then(_.bind(function() { + this.confirm(); + }, this)) + .fail(_.bind(function() { + this.deferred.reject(); + }, this)) + .done(); + + // finally get our buttons + new ConfirmCancelView({ + destination: this.$('.confirmCancel'), + deferred: deferred + }); } }); diff --git a/src/index.html b/src/index.html index 145f7ae1..a4000b00 100644 --- a/src/index.html +++ b/src/index.html @@ -154,12 +154,20 @@ - - Confirm - +