MWF.xApplication.MinderEditor.TopToolbar = new Class({
Extends: MWF.widget.Common,
initialize: function (editor, container) {
this.editor = editor;
this.minder = editor.minder;
this.container = container;
this.commands = this.editor.commands;
this.path = "../x_component_MinderEditor/$ToolbarInEditMode/";
this.cssPath = this.path + this.editor.options.style + "/css.wcss";
this._loadCss();
},
getHtml : function(){
var items;
var tools = this.editor.options.tools;
if( tools && tools.top ){
items = tools.top;
}else{
items = [
"menu", "|",
"save", "|",
"undoredo", "|",
"append", "|",
"arrange", "|",
"edit_remove", "|",
"hyperLink", "image", "priority", "progress", "|",
"style",
"help"
];
}
var disableTools = this.editor.options.disableTools || [];
disableTools.each( function( tool ){
items.erase( tool )
});
var html = "";
var style = "toolItem";
items.each( function( item ){
switch( item ){
case "|":
html += "
";
break;
case "menu":
html += "";
break;
case "save" :
html += "";
break;
case "undoredo" :
html += "";
break;
case "append" :
html += "";
break;
case "arrange" :
html += "";
break;
case "edit_remove" :
html += "";
break;
case "hyperLink" :
html += "";
break;
case "image" :
html += "";
break;
case "priority" :
html += "";
break;
case "progress" :
html += "";
break;
case "style" :
html += "";
break;
case "help" :
html += "";
break;
}
});
return html;
},
load: function () {
/*
var style = "toolItem";
var html =
//"" +
//"" +
//"" +
"" +
"" +
"" +
//"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
"" +
//"" +
"" +
"" +
//"" +
//"" +
//"" +
//"" +
//"" +
//"" +
//"" +
//"" +
//""+
"";
*/
var html = this.getHtml();
this.container.set("html", html);
this.container.getElements("[styles]").each(function (el) {
if (!el.get("item")) {
el.setStyles(this.css[el.get("styles")]);
}
}.bind(this));
this.commands.addContainer( "toptoolbar", this.container, this.css );
},
getCommandNode : function( name ){
return this.commands.getItemNode( name, "toptoolbar" );
}
});
MWF.xApplication.MinderEditor.RightToolbar = new Class({
Extends: MWF.widget.Common,
initialize: function (editor, container) {
this.editor = editor;
this.minder = editor.minder;
this.container = container;
this.commands = this.editor.commands;
this.path = "../x_component_MinderEditor/$ToolbarInEditMode/";
this.cssPath = this.path + this.editor.options.style + "/css.wcss";
this._loadCss();
},
getItems : function(){
var items;
var tools = this.editor.options.tools;
if( tools && tools.right ){
items = tools.right;
}else{
items = [
"font", "resource", "note"
];
}
var disableTools = this.editor.options.disableTools || [];
disableTools.each( function( tool ){
items.erase( tool )
});
return items;
},
load: function(){
this.styleActive = true;
this.resourceActive = false;
this.noteActive = false;
if( this.editor.status ){
this.styleActive = this.editor.status.styleActive;
this.resourceActive = this.editor.status.resourceActive;
this.noteActive = this.editor.status.noteActive;
}
this.styleLoaded = this.styleActive;
this.resourceLoaded = this.resourceActive;
this.noteLoaded = this.noteActive;
var items = this.getItems();
var styleLazyLoding = " lazyLoading='" + (this.styleActive ? "false" : "true") + "'";
var html="";
if( items.contains("font") ){
html += ""+
"";
}
if( items.contains("resource") ){
html += ""+
"";
}
if( items.contains("note") ){
html += ""+
""
}
/*
""+
""+
""+
""+
""+
"";
*/
this.container.set("html", html);
this.container.getElements("[styles]").each( function( el ){
if( !el.get("item") ){
el.setStyles( this.css[ el.get("styles") ] );
}
}.bind(this));
this.container.getElements("[action]").each( function( el ){
var action = el.get("action");
el.addEvents( {"click": function( e ){
this[action]( e.target );
}.bind(this)})
}.bind(this));
this.styleTooltip = this.container.getElement("#styleTooltip");
this.resourceTooltip = this.container.getElement("#resourceTooltip");
this.noteTooltip = this.container.getElement("#noteTooltip");
this.setTooltipsSize();
this.commands.addContainer( "righttoolbar", this.container, this.css );
},
closeStyle : function(el){
this.switchStyle( this.container.getElement("[action='switchStyle']"), false );
},
switchStyle: function( el, forceFlag ){
if( typeOf( forceFlag ) == "boolean" )this.styleActive = !forceFlag;
var tooltip = this.styleTooltip;
if( tooltip ){
if( !this.styleActive ){
tooltip.setStyle("display","");
el.setStyles( this.css.rightToolbarItem_style_active );
if( !this.styleLoaded ){
this.commands.loadItemsByNameList( ["fontsize","bold","italic","forecolor","background","fontfamily"], "righttoolbar" );
this.styleLoaded = true;
}
}else{
tooltip.setStyle("display","none");
el.setStyles( this.css.rightToolbarItem_style )
}
this.styleActive = !this.styleActive;
}
this.setTooltipsSize();
},
closeResource : function(el){
this.switchResource( this.container.getElement("[action='switchResource']"), false );
},
switchResource : function(el, forceFlag){
if( typeOf( forceFlag ) == "boolean" )this.resourceActive = !forceFlag;
var tooltip = this.resourceTooltip;
if( tooltip ){
if( !this.resourceActive ){
tooltip.setStyle("display","");
el.setStyles( this.css.rightToolbarItem_resource_active );
if( !this.resourceLoaded ){
this.commands.loadItemByName("resource", "righttoolbar" );
this.resourceLoaded = true;
}
}else{
tooltip.setStyle("display","none");
el.setStyles( this.css.rightToolbarItem_resource )
}
this.resourceActive = !this.resourceActive;
}
this.setTooltipsSize();
},
closeNote: function(el){
this.switchNote( this.container.getElement("[action='switchNote']"), false )
},
switchNote : function(el, forceFlag){
if( typeOf( forceFlag ) == "boolean" )this.noteActive = !forceFlag;
var tooltip = this.noteTooltip;
if( tooltip ){
if( !this.noteActive ){
tooltip.setStyle("display","");
el.setStyles( this.css.rightToolbarItem_note_active );
if( !this.noteLoaded ){
this.commands.loadItemByName("note", "righttoolbar" );
this.noteLoaded = true;
}
}else{
tooltip.setStyle("display","none");
el.setStyles( this.css.rightToolbarItem_note )
}
this.noteActive = !this.noteActive;
}
this.setTooltipsSize();
},
setTooltipsSize : function(){
var noneC = { bottom : 0, y : 0 };
var containTop = this.editor.Content_Offset_Top + 5; //73横向菜单的高度, 5是间距
var y = this.editor.content.getSize().y - containTop;
var styleC = this.styleActive ? this.styleTooltip.getCoordinates() : noneC;
if( this.resourceActive ){
var top = styleC.height ? (styleC.height + 10 ) : 0;
this.resourceTooltip.setStyle("top",top);
}
var resourceC = this.resourceActive ? this.resourceTooltip.getCoordinates() : noneC;
if( this.noteActive ){
var top = styleC.height ? (styleC.height + 10 ) : 0;
top += resourceC.height ? (resourceC.height + 10 ) : 0;
var height = y - top - 10;
this.noteTooltip.setStyles({
"top" : top,
"height" : Math.min( height , 500 ) //500是 notetoooltip 的最大高度
});
//var noteC = this.noteActive ? this.noteTooltip.getCoordinates() : noneC;
}
if(this.commands)this.commands.setSizes();
}
});