mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 08:28:50 +02:00
UI refactor to less gloabl
This commit is contained in:
parent
1d476af467
commit
4e30d1b511
4 changed files with 18 additions and 22 deletions
|
@ -22,8 +22,6 @@ function GitEngine(options) {
|
||||||
this.generalArgs = [];
|
this.generalArgs = [];
|
||||||
|
|
||||||
events.on('processCommand', _.bind(this.dispatch, this));
|
events.on('processCommand', _.bind(this.dispatch, this));
|
||||||
|
|
||||||
this.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GitEngine.prototype.init = function() {
|
GitEngine.prototype.init = function() {
|
||||||
|
|
|
@ -128,8 +128,6 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- My files! -->
|
<!-- My files! -->
|
||||||
<script src="main.js"></script>
|
|
||||||
|
|
||||||
<script src="async.js"></script>
|
<script src="async.js"></script>
|
||||||
<script src="constants.js"></script>
|
<script src="constants.js"></script>
|
||||||
<script src="errors.js"></script>
|
<script src="errors.js"></script>
|
||||||
|
@ -152,5 +150,7 @@
|
||||||
<!-- levels -->
|
<!-- levels -->
|
||||||
<script src="levels.js"></script>
|
<script src="levels.js"></script>
|
||||||
|
|
||||||
|
<!-- on ready -->
|
||||||
|
<script src="main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
29
src/main.js
29
src/main.js
|
@ -3,18 +3,14 @@
|
||||||
*/
|
*/
|
||||||
var events = _.clone(Backbone.Events);
|
var events = _.clone(Backbone.Events);
|
||||||
|
|
||||||
var gitEngine = null;
|
var ui = null;
|
||||||
var gitVisuals = null;
|
var animationFactory = new AnimationFactory();
|
||||||
|
|
||||||
var commandCollection = null;
|
|
||||||
var commandBuffer = null;
|
|
||||||
var animationFactory = null;
|
|
||||||
|
|
||||||
var paper = null;
|
var paper = null;
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
initUI();
|
ui = new UI();
|
||||||
var mainVis = new Visualization({
|
mainVis = new Visualization({
|
||||||
el: $('#canvasWrapper')[0]
|
el: $('#canvasWrapper')[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,22 +21,21 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function initUI() {
|
function UI() {
|
||||||
// static classes
|
// static classes
|
||||||
animationFactory = new AnimationFactory();
|
this.commandCollection = new CommandCollection();
|
||||||
commandCollection = new CommandCollection();
|
|
||||||
|
|
||||||
commandBuffer = new CommandBuffer({
|
this.commandBuffer = new CommandBuffer({
|
||||||
collection: commandCollection
|
collection: this.commandCollection
|
||||||
});
|
});
|
||||||
|
|
||||||
commandPromptView = new CommandPromptView({
|
this.commandPromptView = new CommandPromptView({
|
||||||
el: $('#commandLineBar'),
|
el: $('#commandLineBar'),
|
||||||
collection: commandCollection
|
collection: this.commandCollection
|
||||||
});
|
});
|
||||||
commandLineHistoryView = new CommandLineHistoryView({
|
this.commandLineHistoryView = new CommandLineHistoryView({
|
||||||
el: $('#commandLineHistory'),
|
el: $('#commandLineHistory'),
|
||||||
collection: commandCollection
|
collection: this.commandCollection
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#commandTextField').focus();
|
$('#commandTextField').focus();
|
||||||
|
|
|
@ -25,15 +25,18 @@ var Visualization = Backbone.View.extend({
|
||||||
branches: this.branchCollection,
|
branches: this.branchCollection,
|
||||||
gitVisuals: this.gitVisuals
|
gitVisuals: this.gitVisuals
|
||||||
});
|
});
|
||||||
|
this.gitEngine.init();
|
||||||
this.gitVisuals.assignGitEngine(this.gitEngine);
|
this.gitVisuals.assignGitEngine(this.gitEngine);
|
||||||
|
|
||||||
// needs to be called before raphael ready
|
// needs to be called before raphael ready
|
||||||
this.myResize();
|
this.myResize();
|
||||||
|
$(window).on('resize', _.bind(this.myResize, this));
|
||||||
|
|
||||||
this.gitVisuals.drawTreeFirstTime();
|
this.gitVisuals.drawTreeFirstTime();
|
||||||
},
|
},
|
||||||
|
|
||||||
myResize: function() {
|
myResize: function() {
|
||||||
var smaller = 10;
|
var smaller = 1;
|
||||||
var el = this.el;
|
var el = this.el;
|
||||||
|
|
||||||
var left = el.offsetLeft;
|
var left = el.offsetLeft;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue