forked from unconed/TermKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Output frame for multicommand output
- Loading branch information
Showing
4 changed files
with
60 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(function ($) { | ||
|
||
/** | ||
* Controller for output frame. | ||
*/ | ||
var of = termkit.outputView.outputFrame = function () { | ||
var self = this; | ||
|
||
this.$element = this.$markup(); | ||
this.views = []; | ||
}; | ||
|
||
of.prototype = { | ||
|
||
// Return active markup for this widget. | ||
$markup: function () { | ||
var $outputFrame = $('<div class="termkitOutputFrame"></div>').data('controller', this); | ||
var self = this; | ||
|
||
return $outputFrame; | ||
}, | ||
|
||
// Hook into the given set of handlers. | ||
hook: function (handlers) { | ||
var self = this; | ||
handlers = handlers || {}; | ||
handlers['view'] = function (m,a) { self.viewHandler(m, a); }; | ||
return handlers; | ||
}, | ||
|
||
viewHandler: function (method, args) { | ||
var subview = args.subview || 0; | ||
this.allocate(subview + 1); | ||
this.views[subview].viewHandler(method, args); | ||
}, | ||
|
||
// Update the element's markup in response to internal changes. | ||
allocate: function (subviews) { | ||
if (this.views.length < subviews) { | ||
subviews -= this.views.length; | ||
while (subviews--) { | ||
this.views.push(new termkit.outputView()); | ||
this.$element.append(this.views[this.views.length - 1].$element); | ||
}; | ||
} | ||
}, | ||
|
||
}; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters