kopia lustrzana https://github.com/c9/core
61 wiersze
1.7 KiB
JavaScript
61 wiersze
1.7 KiB
JavaScript
|
/**
|
||
|
* Image Viewer for the Cloud9
|
||
|
*
|
||
|
* @copyright 2010, Ajax.org B.V.
|
||
|
* @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
|
||
|
*/
|
||
|
define(function(require, exports, module) {
|
||
|
main.consumes = ["Editor", "editors", "ui"];
|
||
|
main.provides = ["htmlview"];
|
||
|
return main;
|
||
|
|
||
|
function main(options, imports, register) {
|
||
|
var Editor = imports.Editor;
|
||
|
var editors = imports.editors;
|
||
|
|
||
|
/***** Initialization *****/
|
||
|
|
||
|
var extensions = [];
|
||
|
|
||
|
function HtmlView(){
|
||
|
var plugin = new Editor("Ajax.org", main.consumes, extensions);
|
||
|
var container;
|
||
|
|
||
|
plugin.on("draw", function(e) {
|
||
|
// Create UI element
|
||
|
container = e.htmlNode;
|
||
|
});
|
||
|
|
||
|
/***** Method *****/
|
||
|
|
||
|
/***** Lifecycle *****/
|
||
|
|
||
|
plugin.on("documentLoad", function(e) {
|
||
|
var session = e.doc.getSession();
|
||
|
session.value = e.state.value;
|
||
|
});
|
||
|
|
||
|
plugin.on("documentActivate", function(e) {
|
||
|
var session = e.doc.getSession();
|
||
|
container.innerHTML = session.value;
|
||
|
});
|
||
|
|
||
|
/***** Register and define API *****/
|
||
|
|
||
|
/**
|
||
|
* Read Only Image Editor
|
||
|
**/
|
||
|
plugin.freezePublicAPI({});
|
||
|
|
||
|
plugin.load(null, "htmlview");
|
||
|
|
||
|
return plugin;
|
||
|
}
|
||
|
HtmlView.autoload = false;
|
||
|
|
||
|
register(null, {
|
||
|
htmlview: editors.register("htmlview", "Html View",
|
||
|
HtmlView, extensions)
|
||
|
});
|
||
|
}
|
||
|
});
|