mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
New build scripts
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5282 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.widget.Editor2Plugin.AlwaysShowToolbar");
|
||||
|
||||
//dojo.widget.Editor2Manager.registerPerInstancePlugin("dojo.widget.Editor2Plugin.AlwaysShowToolbar");
|
||||
|
||||
dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function(editor){
|
||||
if(editor.toolbarAlwaysVisible){
|
||||
var p = new dojo.widget.Editor2Plugin.AlwaysShowToolbar(editor);
|
||||
}
|
||||
});
|
||||
dojo.declare("dojo.widget.Editor2Plugin.AlwaysShowToolbar", null,
|
||||
function(editor){
|
||||
this.editor = editor;
|
||||
this.editor.registerLoadedPlugin(this);
|
||||
this.setup();
|
||||
},
|
||||
{
|
||||
_scrollSetUp: false,
|
||||
_fixEnabled: false,
|
||||
_scrollThreshold: false,
|
||||
_handleScroll: true,
|
||||
|
||||
setup: function(){
|
||||
var tdn = this.editor.toolbarWidget;
|
||||
if(!tdn.tbBgIframe){
|
||||
tdn.tbBgIframe = new dojo.html.BackgroundIframe(tdn.domNode);
|
||||
tdn.tbBgIframe.onResized();
|
||||
}
|
||||
this.scrollInterval = setInterval(dojo.lang.hitch(this, "globalOnScrollHandler"), 100);
|
||||
|
||||
dojo.event.connect("before", this.editor.toolbarWidget, "destroy", this, "destroy");
|
||||
},
|
||||
|
||||
globalOnScrollHandler: function(){
|
||||
var isIE = dojo.render.html.ie;
|
||||
if(!this._handleScroll){ return; }
|
||||
var dh = dojo.html;
|
||||
var tdn = this.editor.toolbarWidget.domNode;
|
||||
var db = dojo.body();
|
||||
|
||||
if(!this._scrollSetUp){
|
||||
this._scrollSetUp = true;
|
||||
var editorWidth = dh.getMarginBox(this.editor.domNode).width;
|
||||
this._scrollThreshold = dh.abs(tdn, true).y;
|
||||
// dojo.debug("threshold:", this._scrollThreshold);
|
||||
if((isIE)&&(db)&&(dh.getStyle(db, "background-image")=="none")){
|
||||
with(db.style){
|
||||
backgroundImage = "url(" + dojo.uri.dojoUri("src/widget/templates/images/blank.gif") + ")";
|
||||
backgroundAttachment = "fixed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var scrollPos = (window["pageYOffset"]) ? window["pageYOffset"] : (document["documentElement"]||document["body"]).scrollTop;
|
||||
|
||||
// FIXME: need to have top and bottom thresholds so toolbar doesn't keep scrolling past the bottom
|
||||
if(scrollPos > this._scrollThreshold){
|
||||
// dojo.debug(scrollPos);
|
||||
if(!this._fixEnabled){
|
||||
var tdnbox = dojo.html.getMarginBox(tdn);
|
||||
this.editor.editorObject.style.marginTop = tdnbox.height+"px";
|
||||
|
||||
if(isIE){
|
||||
// FIXME: should we just use setBehvior() here instead?
|
||||
tdn.style.left = dojo.html.abs(tdn, dojo.html.boxSizing.MARGIN_BOX).x;
|
||||
if(tdn.previousSibling){
|
||||
this._IEOriginalPos = ['after',tdn.previousSibling];
|
||||
}else if(tdn.nextSibling){
|
||||
this._IEOriginalPos = ['before',tdn.nextSibling];
|
||||
}else{
|
||||
this._IEOriginalPos = ['',tdn.parentNode];
|
||||
}
|
||||
dojo.body().appendChild(tdn);
|
||||
|
||||
dojo.html.addClass(tdn, "IEFixedToolbar");
|
||||
}else{
|
||||
with(tdn.style){
|
||||
position = "fixed";
|
||||
top = "0px";
|
||||
}
|
||||
}
|
||||
|
||||
tdn.style.width = tdnbox.width + "px";
|
||||
tdn.style.zIndex = 1000;
|
||||
this._fixEnabled = true;
|
||||
}
|
||||
// if we're showing the floating toolbar, make sure that if
|
||||
// we've scrolled past the bottom of the editor that we hide
|
||||
// the toolbar for this instance of the editor.
|
||||
|
||||
// TODO: when we get multiple editor toolbar support working
|
||||
// correctly, ensure that we check this against the scroll
|
||||
// position of the bottom-most editor instance.
|
||||
if(!dojo.render.html.safari){
|
||||
// safari reports a bunch of things incorrectly here
|
||||
var eHeight = (this.height) ? parseInt(this.editor.height) : this.editor._lastHeight;
|
||||
if(scrollPos > (this._scrollThreshold+eHeight)){
|
||||
tdn.style.display = "none";
|
||||
}else{
|
||||
tdn.style.display = "";
|
||||
}
|
||||
}
|
||||
}else if(this._fixEnabled){
|
||||
(this.editor.object || this.editor.iframe).style.marginTop = null;
|
||||
with(tdn.style){
|
||||
position = "";
|
||||
top = "";
|
||||
zIndex = "";
|
||||
display = "";
|
||||
}
|
||||
if(isIE){
|
||||
tdn.style.left = "";
|
||||
dojo.html.removeClass(tdn, "IEFixedToolbar");
|
||||
if(this._IEOriginalPos){
|
||||
dojo.html.insertAtPosition(tdn, this._IEOriginalPos[1], this._IEOriginalPos[0]);
|
||||
this._IEOriginalPos = null;
|
||||
}else{
|
||||
dojo.html.insertBefore(tdn, this.editor.object||this.editor.iframe);
|
||||
}
|
||||
}
|
||||
tdn.style.width = "";
|
||||
this._fixEnabled = false;
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function(){
|
||||
this._IEOriginalPos = null;
|
||||
this._handleScroll = false;
|
||||
clearInterval(this.scrollInterval);
|
||||
this.editor.unregisterLoadedPlugin(this);
|
||||
|
||||
if(dojo.render.html.ie){
|
||||
dojo.html.removeClass(this.editor.toolbarWidget.domNode, "IEFixedToolbar");
|
||||
}
|
||||
}
|
||||
});
|
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.widget.Editor2Plugin.ContextMenu");
|
||||
|
||||
// summary: dojo.widget.Editor2Plugin.ContextMenu provides context menu for Editor2 widget
|
||||
// description:
|
||||
// This plugin should be dojo.required-ed before all other plugins which
|
||||
// support contextmenu, otherwise the menu for that plugin won't be shown
|
||||
// For each Editor2, what will appear in its context menu can be set by changing
|
||||
// Editor2.contextMenuGroupSet property (by default it is empty, which means use the
|
||||
// default contextMenu). A contextMenuGroupSet has to be registered by calling
|
||||
// dojo.widget.Editor2Plugin.ContextMenuManager.registerGroupSet()
|
||||
// All Editor2 with the same contextMenuGroupSet will share the same ContextMenu
|
||||
|
||||
dojo.require("dojo.widget.Menu2");
|
||||
|
||||
dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function(editor){
|
||||
dojo.widget.Editor2Plugin.ContextMenuManager.getContextMenu(editor);
|
||||
// var p = new dojo.widget.Editor2Plugin.ContextMenu();
|
||||
});
|
||||
|
||||
dojo.widget.Editor2Plugin.ContextMenuManager = {
|
||||
menuGroups: ['Generic', 'Link', 'Anchor', 'Image', 'List', 'Table'],
|
||||
_contextMenuGroupSets: {},
|
||||
_registeredGroups: {},
|
||||
_menus: {},
|
||||
registerGroup: function(name, handler){
|
||||
if(this._registeredGroups[name]){
|
||||
alert("dojo.widget.Editor2Plugin.ContextMenuManager.registerGroup: menu group "+name+"is already registered. Ignored.");
|
||||
return;
|
||||
}
|
||||
this._registeredGroups[name] = handler;
|
||||
},
|
||||
removeGroup: function(name){
|
||||
delete this._registeredGroups[name];
|
||||
},
|
||||
getGroup: function(name, contextmenuplugin){
|
||||
if(this._registeredGroups[name]){
|
||||
var item = this._registeredGroups[name](name, contextmenuplugin);
|
||||
if(item){
|
||||
return item;
|
||||
}
|
||||
}
|
||||
switch(name){
|
||||
case 'Generic':
|
||||
case 'Link':
|
||||
case 'Image':
|
||||
return new dojo.widget.Editor2Plugin[name+"ContextMenuGroup"](contextmenuplugin);
|
||||
//TODO
|
||||
case 'Anchor':
|
||||
case 'List':
|
||||
}
|
||||
},
|
||||
registerGroupSet: function(/*String*/name, /*Array*/set){
|
||||
// summary: register a group set
|
||||
// name: name of the group set
|
||||
// set: an array of groups, such as ['Generic','Link']
|
||||
this._contextMenuGroupSets[name] = set;
|
||||
},
|
||||
removeGroupSet: function(name){
|
||||
var set = this._contextMenuGroupSets[name];
|
||||
delete this._contextMenuGroupSets[name];
|
||||
return set;
|
||||
},
|
||||
getContextMenu: function(editor){
|
||||
var set = editor.contextMenuGroupSet || 'defaultDojoEditor2MenuGroupSet';
|
||||
if(this._menus[set]){
|
||||
this._menus[set].bindEditor(editor);
|
||||
return this._menus[set];
|
||||
}
|
||||
|
||||
var gs = (editor.contextMenuGroupSet && this._contextMenuGroupSets[editor.contextMenuGroupSet]) || this.menuGroups;
|
||||
var menu = new dojo.widget.Editor2Plugin.ContextMenu(editor, gs);
|
||||
this._menus[set] = menu;
|
||||
return menu;
|
||||
}
|
||||
};
|
||||
|
||||
dojo.declare("dojo.widget.Editor2Plugin.ContextMenu", null,
|
||||
function(editor, gs){
|
||||
this.groups = [];
|
||||
this.separators = [];
|
||||
this.editor = editor;
|
||||
this.editor.registerLoadedPlugin(this);
|
||||
this.contextMenu = dojo.widget.createWidget("PopupMenu2", {});
|
||||
dojo.body().appendChild(this.contextMenu.domNode);
|
||||
this.bindEditor(this.editor);
|
||||
|
||||
dojo.event.connect(this.contextMenu, "aboutToShow", this, "aboutToShow");
|
||||
dojo.event.connect(this.editor, "destroy", this, "destroy");
|
||||
|
||||
this.setup(gs);
|
||||
},
|
||||
{
|
||||
bindEditor: function(editor){
|
||||
this.contextMenu.bindDomNode(editor.document.body);
|
||||
},
|
||||
setup: function(gs){
|
||||
for(var i in gs){
|
||||
var g = dojo.widget.Editor2Plugin.ContextMenuManager.getGroup(gs[i], this);
|
||||
if(g){
|
||||
this.groups.push(g);
|
||||
}
|
||||
}
|
||||
},
|
||||
aboutToShow: function(){
|
||||
var first = true;
|
||||
for(var i in this.groups){
|
||||
if(i>0 && this.separators.length != this.groups.length-1){
|
||||
this.separators.push(dojo.widget.createWidget("MenuSeparator2", {}));
|
||||
this.contextMenu.addChild(this.separators[this.separators.length-1]);
|
||||
}
|
||||
if(this.groups[i].refresh()){
|
||||
if(i>0){
|
||||
if(first){
|
||||
this.separators[i-1].hide();
|
||||
}else{
|
||||
this.separators[i-1].show();
|
||||
}
|
||||
}
|
||||
if(first){ first = false; }
|
||||
}else{
|
||||
if(i>0){
|
||||
this.separators[i-1].hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
destroy: function(){
|
||||
this.editor.unregisterLoadedPlugin(this);
|
||||
delete this.groups;
|
||||
delete this.separators;
|
||||
this.contextMenu.destroy();
|
||||
delete this.contextMenu;
|
||||
}
|
||||
});
|
||||
|
||||
dojo.widget.defineWidget(
|
||||
"dojo.widget.Editor2ContextMenuItem",
|
||||
dojo.widget.MenuItem2,
|
||||
{
|
||||
command: '',
|
||||
buildRendering: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
this.caption = curInst.getCommand(this.command).getText();
|
||||
|
||||
dojo.widget.Editor2ContextMenuItem.superclass.buildRendering.apply(this, arguments);
|
||||
},
|
||||
onClick: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
if(curInst){
|
||||
var _command = curInst.getCommand(this.command);
|
||||
if(_command){
|
||||
_command.execute();
|
||||
}
|
||||
}
|
||||
},
|
||||
refresh: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
if(curInst){
|
||||
var _command = curInst.getCommand(this.command);
|
||||
if(_command){
|
||||
if(_command.getState() == dojo.widget.Editor2Manager.commandState.Disabled){
|
||||
this.disable();
|
||||
return false;
|
||||
}else{
|
||||
this.enable();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
//improve performance by skipping animation
|
||||
hide: function(){
|
||||
this.domNode.style.display = "none";
|
||||
},
|
||||
show: function(){
|
||||
this.domNode.style.display = "";
|
||||
}
|
||||
});
|
||||
dojo.declare("dojo.widget.Editor2Plugin.SimpleContextMenuGroup", null,
|
||||
function(contextmenuplugin){
|
||||
this.contextMenu = contextmenuplugin.contextMenu;
|
||||
this.items = [];
|
||||
|
||||
dojo.event.connect(contextmenuplugin, "destroy", this, "destroy");
|
||||
},
|
||||
{
|
||||
refresh: function(){
|
||||
if(!this.items.length){
|
||||
this.createItems();
|
||||
for(var i in this.items){
|
||||
this.contextMenu.addChild(this.items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return this.checkVisibility();
|
||||
},
|
||||
destroy: function(){
|
||||
this.contextmenu = null;
|
||||
delete this.items;
|
||||
delete this.contextMenu;
|
||||
},
|
||||
//implement this to fill in the menu items
|
||||
createItems: function(){ },
|
||||
|
||||
//overload this to show/hide items
|
||||
checkVisibility: function(){
|
||||
var show = false;
|
||||
for(var i in this.items){
|
||||
show = show || this.items[i].refresh();
|
||||
}
|
||||
var action = show ? "show" : "hide";
|
||||
for(var i in this.items){
|
||||
this.items[i][action]();
|
||||
}
|
||||
return show;
|
||||
}
|
||||
});
|
||||
dojo.declare("dojo.widget.Editor2Plugin.GenericContextMenuGroup",
|
||||
dojo.widget.Editor2Plugin.SimpleContextMenuGroup,
|
||||
{
|
||||
createItems: function(){
|
||||
this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {command: "cut", iconClass: "dojoE2TBIcon dojoE2TBIcon_Cut"}));
|
||||
this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {command: "copy", iconClass: "dojoE2TBIcon dojoE2TBIcon_Copy"}));
|
||||
this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {command: "paste", iconClass: "dojoE2TBIcon dojoE2TBIcon_Paste"}));
|
||||
}
|
||||
});
|
||||
dojo.declare("dojo.widget.Editor2Plugin.LinkContextMenuGroup",
|
||||
dojo.widget.Editor2Plugin.SimpleContextMenuGroup,
|
||||
{
|
||||
createItems: function(){
|
||||
this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {command: 'createlink', iconClass: "dojoE2TBIcon dojoE2TBIcon_Link"}));
|
||||
this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {command: 'unlink', iconClass: "dojoE2TBIcon dojoE2TBIcon_UnLink"}));
|
||||
},
|
||||
checkVisibility: function(){
|
||||
var show = this.items[1].refresh();
|
||||
if(show){
|
||||
this.items[0].refresh();
|
||||
for(var i in this.items){
|
||||
this.items[i].show();
|
||||
}
|
||||
}else{
|
||||
for(var i in this.items){
|
||||
this.items[i].hide();
|
||||
}
|
||||
}
|
||||
|
||||
return show;
|
||||
}
|
||||
});
|
||||
dojo.declare("dojo.widget.Editor2Plugin.ImageContextMenuGroup",
|
||||
dojo.widget.Editor2Plugin.SimpleContextMenuGroup,
|
||||
{
|
||||
createItems: function(){
|
||||
this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {command: 'insertimage', iconClass: "dojoE2TBIcon dojoE2TBIcon_Image"}));
|
||||
},
|
||||
checkVisibility: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
var img = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection);
|
||||
|
||||
if(img && img.tagName.toLowerCase() == 'img'){
|
||||
this.items[0].show();
|
||||
return true;
|
||||
}else{
|
||||
this.items[0].hide();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.widget.Editor2Plugin.CreateLinkDialog");
|
||||
|
||||
dojo.widget.defineWidget(
|
||||
"dojo.widget.Editor2CreateLinkDialog",
|
||||
dojo.widget.Editor2DialogContent,
|
||||
{
|
||||
templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/createlink.html"),
|
||||
|
||||
editableAttributes: ['href', 'target', 'class'],
|
||||
loadContent: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
|
||||
curInst.saveSelection(); //save selection (none-activeX IE)
|
||||
|
||||
this.linkNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['a']);
|
||||
var linkAttributes = {};
|
||||
this.extraAttribText = "";
|
||||
if(this.linkNode){
|
||||
var attrs = this.linkNode.attributes;
|
||||
for(var i=0; i<attrs.length; i++) {
|
||||
if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){
|
||||
linkAttributes[attrs[i].name] = attrs[i].value;
|
||||
}else{
|
||||
//IE lists all attributes, even default ones, filter them
|
||||
if(attrs[i].specified == undefined || attrs[i].specified){
|
||||
this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
var html = dojo.withGlobal(curInst.window, "getSelectedText", dojo.html.selection);
|
||||
if(html == null || html.length == 0){
|
||||
alert("Please select some text to create a link.");
|
||||
return false;//do not show the dialog
|
||||
}
|
||||
}
|
||||
|
||||
for(var i=0; i<this.editableAttributes.length; ++i){
|
||||
name = this.editableAttributes[i];
|
||||
this["link_"+name].value = (linkAttributes[name] == undefined) ? "" : linkAttributes[name] ;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
ok: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
curInst.restoreSelection(); //restore previous selection, required for none-activeX IE
|
||||
|
||||
if(!this.linkNode){
|
||||
var html = dojo.withGlobal(curInst.window, "getSelectedHtml", dojo.html.selection);
|
||||
}else{
|
||||
var html = this.linkNode.innerHTML;
|
||||
dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.linkNode]);
|
||||
}
|
||||
|
||||
var attstr='';
|
||||
for(var i=0; i<this.editableAttributes.length; ++i){
|
||||
name = this.editableAttributes[i];
|
||||
var value = this["link_"+name].value;
|
||||
if(value.length > 0){
|
||||
attstr += name + '="'+value+'" ';
|
||||
}
|
||||
}
|
||||
|
||||
curInst.execCommand('inserthtml', '<a '+attstr+this.extraAttribText+'>'+html+'</a>');
|
||||
|
||||
this.cancel();
|
||||
}
|
||||
});
|
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.widget.Editor2Plugin.FindReplace");
|
||||
|
||||
dojo.require("dojo.widget.Editor2");
|
||||
|
||||
//TODO replace, better GUI
|
||||
|
||||
dojo.declare("dojo.widget.Editor2Plugin.FindCommand", dojo.widget.Editor2DialogCommand,{
|
||||
SearchOption: {
|
||||
CaseSensitive: 4,
|
||||
SearchBackwards: 64,
|
||||
WholeWord: 2,
|
||||
WrapSearch: 128
|
||||
},
|
||||
find: function(text, option){
|
||||
this._editor.focus();
|
||||
if(window.find){ //moz
|
||||
this._editor.window.find(text,
|
||||
option & this.SearchOption.CaseSensitive ? true : false,
|
||||
option & this.SearchOption.SearchBackwards ? true : false,
|
||||
option & this.SearchOption.WrapSearch ? true : false,
|
||||
option & this.SearchOption.WholeWord ? true : false
|
||||
);
|
||||
}else if(dojo.body().createTextRange){ //IE
|
||||
var range = this._editor.document.body.createTextRange();
|
||||
var found = range.findText(text, (option&this.SearchOption.SearchBackwards)?1:-1, option );
|
||||
if(found){
|
||||
range.scrollIntoView() ;
|
||||
range.select() ;
|
||||
}else{
|
||||
alert("Can not find "+text+" in the document");
|
||||
}
|
||||
}else{
|
||||
alert("No idea how to search in this browser. Please submit patch if you know.");
|
||||
}
|
||||
},
|
||||
getText: function(){
|
||||
return 'Find';
|
||||
}
|
||||
});
|
||||
|
||||
dojo.widget.Editor2Plugin.FindReplace ={
|
||||
getCommand: function(editor, name){
|
||||
var name = name.toLowerCase();
|
||||
var command;
|
||||
if(name == 'find'){
|
||||
command = new dojo.widget.Editor2Plugin.FindCommand(editor, 'find',
|
||||
{contentFile: "dojo.widget.Editor2Plugin.FindReplaceDialog",
|
||||
contentClass: "Editor2FindDialog",
|
||||
title: "Find", width: "350px", height: "150px", modal: false});
|
||||
}else if(name == 'replace') {
|
||||
command = new dojo.widget.Editor2DialogCommand(editor, 'replace',
|
||||
{contentFile: "dojo.widget.Editor2Plugin.FindReplaceDialog",
|
||||
contentClass: "Editor2ReplaceDialog",
|
||||
href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/replace.html"),
|
||||
title: "Replace", width: "350px", height: "200px", modal: false});
|
||||
}
|
||||
|
||||
return command;
|
||||
},
|
||||
getToolbarItem: function(name){
|
||||
var name = name.toLowerCase();
|
||||
|
||||
var item;
|
||||
if(name == 'replace'){
|
||||
item = new dojo.widget.Editor2ToolbarButton('Replace');
|
||||
}else if(name == 'find') {
|
||||
item = new dojo.widget.Editor2ToolbarButton('Find');
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
dojo.widget.Editor2Manager.registerHandler(dojo.widget.Editor2Plugin.FindReplace.getCommand);
|
||||
dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.FindReplace.getToolbarItem);
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.widget.Editor2Plugin.FindReplaceDialog");
|
||||
|
||||
dojo.widget.defineWidget(
|
||||
"dojo.widget.Editor2FindDialog",
|
||||
dojo.widget.Editor2DialogContent,
|
||||
{
|
||||
templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/find.html"),
|
||||
|
||||
find: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
var findcmd = curInst.getCommand('find');
|
||||
var option = 0;
|
||||
|
||||
if(this["find_option_casesens"].checked){
|
||||
option |= findcmd.SearchOption.CaseSensitive;
|
||||
}
|
||||
if(this["find_option_backwards"].checked){
|
||||
option |= findcmd.SearchOption.SearchBackwards;
|
||||
}
|
||||
|
||||
if(this["find_option_wholeword"].checked){
|
||||
option |= findcmd.SearchOption.WholeWord;
|
||||
}
|
||||
findcmd.find(this["find_text"].value, option);
|
||||
}
|
||||
});
|
||||
|
||||
dojo.widget.defineWidget(
|
||||
"dojo.widget.Editor2ReplaceDialog",
|
||||
dojo.widget.Editor2DialogContent,
|
||||
{
|
||||
templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/replace.html"),
|
||||
|
||||
replace: function(){
|
||||
alert("not implemented yet");
|
||||
},
|
||||
replaceAll: function(){
|
||||
alert("not implemented yet");
|
||||
}
|
||||
});
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.widget.Editor2Plugin.InsertImageDialog");
|
||||
|
||||
dojo.widget.defineWidget(
|
||||
"dojo.widget.Editor2InsertImageDialog",
|
||||
dojo.widget.Editor2DialogContent,
|
||||
{
|
||||
templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/insertimage.html"),
|
||||
|
||||
editableAttributes: ['src', 'alt', 'width', 'height', 'hspace', 'vspace', 'border', 'align'],
|
||||
loadContent: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
this.imageNode = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection);
|
||||
if(!this.imageNode){
|
||||
this.imageNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['img']);
|
||||
}
|
||||
var imageAttributes = {};
|
||||
this.extraAttribText = "";
|
||||
if(this.imageNode){
|
||||
var attrs = this.imageNode.attributes;
|
||||
for(var i=0; i<attrs.length; i++) {
|
||||
if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){
|
||||
imageAttributes[attrs[i].name] = attrs[i].value;
|
||||
}else{
|
||||
this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" ';
|
||||
}
|
||||
}
|
||||
}
|
||||
for(var i=0; i<this.editableAttributes.length; ++i){
|
||||
name = this.editableAttributes[i];
|
||||
this["image_"+name].value = (imageAttributes[name] == undefined) ? "" : imageAttributes[name] ;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
ok: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
var insertcmd = curInst.getCommand('inserthtml');
|
||||
var option = 0;
|
||||
|
||||
var attstr='';
|
||||
for(var i=0; i<this.editableAttributes.length; ++i){
|
||||
name = this.editableAttributes[i];
|
||||
var value = this["image_"+name].value;
|
||||
if(value.length > 0){
|
||||
attstr += name + '="'+value+'" ';
|
||||
}
|
||||
}
|
||||
if(this.imageNode){
|
||||
dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.imageNode]);
|
||||
}
|
||||
insertcmd.execute('<img '+attstr+this.extraAttribText+'/>');
|
||||
|
||||
this.cancel();
|
||||
}
|
||||
});
|
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.widget.Editor2Plugin.InsertTableDialog");
|
||||
|
||||
dojo.widget.defineWidget(
|
||||
"dojo.widget.Editor2InsertTableDialog",
|
||||
dojo.widget.Editor2DialogContent,
|
||||
{
|
||||
templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/inserttable.html"),
|
||||
|
||||
editableAttributes: ['summary', 'height', 'cellspacing', 'cellpadding', 'border', 'align'],
|
||||
|
||||
loadContent: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
curInst.saveSelection(); //save selection (none-activeX IE)
|
||||
this.tableNode = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection);
|
||||
if(!this.tableNode || this.tableNode.tagName.toLowerCase() != 'table'){
|
||||
this.tableNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['table']);
|
||||
}
|
||||
|
||||
var tableAttributes = {};
|
||||
this.extraAttribText = "";
|
||||
if(this.tableNode){
|
||||
this["table_rows"].value = this.tableNode.rows.length;
|
||||
this["table_rows"].disabled = true;
|
||||
this["table_cols"].value = this.tableNode.rows[0].cells.length;
|
||||
this["table_cols"].disabled = true;
|
||||
|
||||
if (this.tableNode.caption){
|
||||
this["table_caption"].value = this.tableNode.caption.innerHTML;
|
||||
}else{
|
||||
this["table_caption"].value = "";
|
||||
}
|
||||
|
||||
var width = this.tableNode.style.width || this.tableNode.width;
|
||||
if(width){
|
||||
this["table_width"].value = parseInt(width);
|
||||
if (width.indexOf('%') > -1){
|
||||
this["table_widthtype"].value = "percent";
|
||||
}else{
|
||||
this["table_widthtype"].value = "pixels";
|
||||
}
|
||||
}else{
|
||||
this["table_width"].value = "100";
|
||||
}
|
||||
|
||||
var height = this.tableNode.style.height || this.tableNode.height;
|
||||
if(height){
|
||||
this["table_height"].value = parseInt(width);
|
||||
}else{
|
||||
this["table_height"].value = "";
|
||||
}
|
||||
|
||||
var attrs = this.tableNode.attributes;
|
||||
for(var i=0; i<attrs.length; i++) {
|
||||
if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){
|
||||
tableAttributes[attrs[i].name] = attrs[i].value;
|
||||
}else{
|
||||
this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" ';
|
||||
}
|
||||
}
|
||||
}else{
|
||||
this["table_rows"].value = 3;
|
||||
this["table_rows"].disabled = false;
|
||||
this["table_cols"].value = 2;
|
||||
this["table_cols"].disabled = false;
|
||||
this["table_width"].value = 100;
|
||||
this["table_widthtype"].value = "percent";
|
||||
this["table_height"].value = "";
|
||||
}
|
||||
|
||||
for(var i=0; i<this.editableAttributes.length; ++i){
|
||||
name = this.editableAttributes[i];
|
||||
this["table_"+name].value = (tableAttributes[name] == undefined) ? "" : tableAttributes[name];
|
||||
if(name == 'height' && tableAttributes[name] != undefined){
|
||||
this["table_"+name].value = tableAttributes[name];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
ok: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
var args = {};
|
||||
|
||||
args['rows'] = this["table_rows"].value;
|
||||
args['cols'] = this["table_cols"].value;
|
||||
args['caption'] = this["table_caption"].value;
|
||||
args["tableattrs"] = "";
|
||||
if(this["table_widthtype"].value == "percent"){
|
||||
args["tableattrs"] += 'width="'+this["table_width"].value +'%" ';
|
||||
}else{
|
||||
args["tableattrs"] += 'width="'+this["table_width"].value +'px" ';
|
||||
}
|
||||
for(var i=0; i<this.editableAttributes.length; ++i){
|
||||
var name = this.editableAttributes[i];
|
||||
var value = this["table_"+name].value;
|
||||
if(value.length > 0){
|
||||
args["tableattrs"] += name + '="'+value+'" ';
|
||||
}
|
||||
}
|
||||
|
||||
if(!args["tableattrs"]){
|
||||
args["tableattrs"] = "";
|
||||
}
|
||||
|
||||
//show the border in IE by applying a custom class
|
||||
if(dojo.render.html.ie && !this["table_border"].value){
|
||||
args["tableattrs"] += 'class="dojoShowIETableBorders" ';
|
||||
}
|
||||
|
||||
var html = "<table "+args["tableattrs"]+">";
|
||||
if(args['caption']){
|
||||
html += "<caption>"+args["caption"]+"</caption>";
|
||||
}
|
||||
var outertbody = "<tbody>";
|
||||
if(this.tableNode){
|
||||
//retain the content
|
||||
var tbody = this.tableNode.getElementsByTagName("tbody")[0];
|
||||
outertbody = tbody.outerHTML;
|
||||
if(!outertbody){
|
||||
var cnode = tbody.cloneNode(true);
|
||||
var tmpnode = tbody.ownerDocument.createElement("div");
|
||||
tmpnode.appendChild(cnode);
|
||||
outertbody = tmpnode.innerHTML;
|
||||
}
|
||||
//TODO: save current selection and restore it later
|
||||
dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.tableNode]);
|
||||
}else{
|
||||
var cols = "<tr>";
|
||||
for (var i = 0; i < +args.cols; i++) { cols += "<td></td>"; }
|
||||
cols += "</tr>";
|
||||
for (var i = 0; i < args.rows; i++) { outertbody += cols; }
|
||||
outertbody += "</tbody>";
|
||||
}
|
||||
html += outertbody+"</table>";
|
||||
curInst.restoreSelection(); //restore previous selection, required for none-activeX IE
|
||||
curInst.execCommand("inserthtml", html);
|
||||
|
||||
this.cancel();
|
||||
}
|
||||
});
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
/*
|
||||
* This plugin adds save() and insertImage() to Editor2 widget, and two commands for each
|
||||
* of them. When the corresponding button is clicked in the toolbar, the added function in the
|
||||
* Editor2 widget is called. This mimics the original Editor2 behavior. If you want to have other
|
||||
* signals on the Editor2 widget, add them to dojo.widget.Editor2Plugin.SimpleSignalCommands.signals
|
||||
* NOTE: Please consider writing your own Editor2 plugin rather than using this backward compatible
|
||||
* plugin
|
||||
* ATTENTION: This plugin overwrites the new built-in insertImage dialog. (If this is not desired, set
|
||||
* dojo.widget.Editor2Plugin.SimpleSignalCommands.signals to not contain insertImage)
|
||||
*/
|
||||
|
||||
//uncomment this line to add save only (do not overwrite the new built-in insertImage dialog
|
||||
//this line should present before require dojo.widget.Editor2Plugin.SimpleSignalCommands
|
||||
//dojo.widget.Editor2Plugin['SimpleSignalCommands'] = {signals: ['save']};
|
||||
|
||||
dojo.provide("dojo.widget.Editor2Plugin.SimpleSignalCommands");
|
||||
|
||||
dojo.require("dojo.widget.Editor2");
|
||||
|
||||
dojo.declare("dojo.widget.Editor2Plugin.SimpleSignalCommand", dojo.widget.Editor2Command,
|
||||
function(editor, name){
|
||||
if(dojo.widget.Editor2.prototype[name] == undefined){
|
||||
dojo.widget.Editor2.prototype[name] = function(){ /*dojo.debug("Editor2::"+name);*/ };
|
||||
}
|
||||
},
|
||||
{
|
||||
execute: function(){
|
||||
this._editor[this._name]();
|
||||
}
|
||||
});
|
||||
|
||||
if(dojo.widget.Editor2Plugin['SimpleSignalCommands']){
|
||||
dojo.widget.Editor2Plugin['_SimpleSignalCommands']=dojo.widget.Editor2Plugin['SimpleSignalCommands'];
|
||||
}
|
||||
|
||||
dojo.widget.Editor2Plugin.SimpleSignalCommands = {
|
||||
signals: ['save', 'insertImage'],
|
||||
Handler: function(name){
|
||||
if(name.toLowerCase() == 'save'){
|
||||
return new dojo.widget.Editor2ToolbarButton('Save');
|
||||
}else if(name.toLowerCase() == 'insertimage'){
|
||||
return new dojo.widget.Editor2ToolbarButton('InsertImage');
|
||||
}
|
||||
},
|
||||
getCommand: function(editor, name){
|
||||
var signal;
|
||||
dojo.lang.every(this.signals,function(s){
|
||||
if(s.toLowerCase() == name.toLowerCase()){
|
||||
signal = s;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if(signal){
|
||||
return new dojo.widget.Editor2Plugin.SimpleSignalCommand(editor, signal);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if(dojo.widget.Editor2Plugin['_SimpleSignalCommands']){
|
||||
dojo.lang.mixin(dojo.widget.Editor2Plugin.SimpleSignalCommands, dojo.widget.Editor2Plugin['_SimpleSignalCommands']);
|
||||
}
|
||||
dojo.widget.Editor2Manager.registerHandler(dojo.widget.Editor2Plugin.SimpleSignalCommands, 'getCommand');
|
||||
dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.SimpleSignalCommands.Handler);
|
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.widget.Editor2Plugin.TableOperation");
|
||||
|
||||
dojo.require("dojo.widget.Editor2");
|
||||
|
||||
//subscribe to dojo.widget.RichText::init, not onLoad because after onLoad
|
||||
//the stylesheets for the editing areas are already applied and the prefilters
|
||||
//are executed, so we have to insert our own trick before that point
|
||||
dojo.event.topic.subscribe("dojo.widget.RichText::init", function(editor){
|
||||
if(dojo.render.html.ie){
|
||||
//add/remove a class to a table with border=0 to show the border when loading/saving
|
||||
editor.contentDomPreFilters.push(dojo.widget.Editor2Plugin.TableOperation.showIETableBorder);
|
||||
editor.contentDomPostFilters.push(dojo.widget.Editor2Plugin.TableOperation.removeIEFakeClass);
|
||||
}
|
||||
//create a toggletableborder command for this editor so that tables without border can be seen
|
||||
editor.getCommand("toggletableborder");
|
||||
});
|
||||
|
||||
dojo.lang.declare("dojo.widget.Editor2Plugin.deleteTableCommand", dojo.widget.Editor2Command,
|
||||
{
|
||||
execute: function(){
|
||||
var table = dojo.withGlobal(this._editor.window, "getAncestorElement", dojo.html.selection, ['table']);
|
||||
if(table){
|
||||
dojo.withGlobal(this._editor.window, "selectElement", dojo.html.selection, [table]);
|
||||
this._editor.execCommand("inserthtml", " "); //Moz does not like an empty string, so a space here instead
|
||||
}
|
||||
},
|
||||
getState: function(){
|
||||
if(this._editor._lastStateTimestamp > this._updateTime || this._state == undefined){
|
||||
this._updateTime = this._editor._lastStateTimestamp;
|
||||
var table = dojo.withGlobal(this._editor.window, "hasAncestorElement", dojo.html.selection, ['table']);
|
||||
this._state = table ? dojo.widget.Editor2Manager.commandState.Enabled : dojo.widget.Editor2Manager.commandState.Disabled;
|
||||
}
|
||||
return this._state;
|
||||
},
|
||||
getText: function(){
|
||||
return 'Delete Table';
|
||||
}
|
||||
});
|
||||
|
||||
dojo.lang.declare("dojo.widget.Editor2Plugin.toggleTableBorderCommand", dojo.widget.Editor2Command,
|
||||
function(){
|
||||
this._showTableBorder = false;
|
||||
dojo.event.connect(this._editor, "editorOnLoad", this, 'execute');
|
||||
},
|
||||
{
|
||||
execute: function(){
|
||||
if(this._showTableBorder){
|
||||
this._showTableBorder = false;
|
||||
if(dojo.render.html.moz){
|
||||
this._editor.removeStyleSheet(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_gecko.css"));
|
||||
}else if(dojo.render.html.ie){
|
||||
this._editor.removeStyleSheet(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_ie.css"));
|
||||
}
|
||||
}else{
|
||||
this._showTableBorder = true;
|
||||
if(dojo.render.html.moz){
|
||||
this._editor.addStyleSheet(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_gecko.css"));
|
||||
}else if(dojo.render.html.ie){
|
||||
this._editor.addStyleSheet(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_ie.css"));
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
getText: function(){
|
||||
return 'Toggle Table Border';
|
||||
},
|
||||
getState: function(){
|
||||
return this._showTableBorder ? dojo.widget.Editor2Manager.commandState.Latched : dojo.widget.Editor2Manager.commandState.Enabled;
|
||||
}
|
||||
});
|
||||
|
||||
dojo.widget.Editor2Plugin.TableOperation = {
|
||||
getCommand: function(editor, name){
|
||||
switch(name.toLowerCase()){
|
||||
case 'toggletableborder':
|
||||
return new dojo.widget.Editor2Plugin.toggleTableBorderCommand(editor, name);
|
||||
case 'inserttable':
|
||||
return new dojo.widget.Editor2DialogCommand(editor, 'inserttable',
|
||||
{contentFile: "dojo.widget.Editor2Plugin.InsertTableDialog",
|
||||
contentClass: "Editor2InsertTableDialog",
|
||||
title: "Insert/Edit Table", width: "450px", height: "250px"})
|
||||
case 'deletetable':
|
||||
return new dojo.widget.Editor2Plugin.deleteTableCommand(editor, name);
|
||||
}
|
||||
},
|
||||
getToolbarItem: function(name){
|
||||
var name = name.toLowerCase();
|
||||
|
||||
var item;
|
||||
switch(name){
|
||||
case 'inserttable':
|
||||
case 'toggletableborder':
|
||||
item = new dojo.widget.Editor2ToolbarButton(name);
|
||||
}
|
||||
|
||||
return item;
|
||||
},
|
||||
getContextMenuGroup: function(name, contextmenuplugin){
|
||||
return new dojo.widget.Editor2Plugin.TableContextMenuGroup(contextmenuplugin);
|
||||
},
|
||||
showIETableBorder: function(dom){
|
||||
var tables = dom.getElementsByTagName('table');
|
||||
dojo.lang.forEach(tables, function(t){
|
||||
dojo.html.addClass(t, "dojoShowIETableBorders");
|
||||
});
|
||||
return dom;
|
||||
},
|
||||
removeIEFakeClass: function(dom){
|
||||
var tables = dom.getElementsByTagName('table');
|
||||
dojo.lang.forEach(tables, function(t){
|
||||
dojo.html.removeClass(t, "dojoShowIETableBorders");
|
||||
});
|
||||
return dom;
|
||||
}
|
||||
}
|
||||
|
||||
//register commands: toggletableborder, inserttable, deletetable
|
||||
dojo.widget.Editor2Manager.registerHandler(dojo.widget.Editor2Plugin.TableOperation.getCommand);
|
||||
|
||||
//register toggletableborder and inserttable as toolbar item
|
||||
dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.TableOperation.getToolbarItem);
|
||||
|
||||
//add context menu support if dojo.widget.Editor2Plugin.ContextMenu is included before this plugin
|
||||
if(dojo.widget.Editor2Plugin.ContextMenuManager){
|
||||
dojo.widget.Editor2Plugin.ContextMenuManager.registerGroup('Table', dojo.widget.Editor2Plugin.TableOperation.getContextMenuGroup);
|
||||
|
||||
dojo.declare("dojo.widget.Editor2Plugin.TableContextMenuGroup",
|
||||
dojo.widget.Editor2Plugin.SimpleContextMenuGroup,
|
||||
{
|
||||
createItems: function(){
|
||||
this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Delete Table", command: 'deletetable'}));
|
||||
this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Table Property", command: 'inserttable', iconClass: "TB_Button_Icon TB_Button_Table"}));
|
||||
},
|
||||
checkVisibility: function(){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
var table = dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table']);
|
||||
|
||||
if(dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table'])){
|
||||
this.items[0].show();
|
||||
this.items[1].show();
|
||||
return true;
|
||||
}else{
|
||||
this.items[0].hide();
|
||||
this.items[1].hide();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
/*TODO:
|
||||
* Add a command to toggle DnD support for a toolbar
|
||||
* Save/restore order of toolbar/item
|
||||
*/
|
||||
dojo.provide("dojo.widget.Editor2Plugin.ToolbarDndSupport");
|
||||
dojo.require("dojo.dnd.*");
|
||||
|
||||
dojo.event.topic.subscribe("dojo.widget.Editor2::preLoadingToolbar", function(editor){
|
||||
dojo.dnd.dragManager.nestedTargets = true;
|
||||
var p = new dojo.widget.Editor2Plugin.ToolbarDndSupport(editor);
|
||||
});
|
||||
|
||||
dojo.declare("dojo.widget.Editor2Plugin.ToolbarDndSupport", null,{
|
||||
lookForClass: "dojoEditorToolbarDnd TB_ToolbarSet TB_Toolbar",
|
||||
initializer: function(editor){
|
||||
this.editor = editor;
|
||||
dojo.event.connect(this.editor, "toolbarLoaded", this, "setup");
|
||||
this.editor.registerLoadedPlugin(this);
|
||||
},
|
||||
|
||||
setup: function(){
|
||||
dojo.event.disconnect(this.editor, "toolbarLoaded", this, "setup");
|
||||
var tbw = this.editor.toolbarWidget;
|
||||
dojo.event.connect("before", tbw, "destroy", this, "destroy");
|
||||
|
||||
var nodes = dojo.html.getElementsByClass(this.lookForClass, tbw.domNode, null, dojo.html.classMatchType.ContainsAny);
|
||||
if(!nodes){
|
||||
dojo.debug("dojo.widget.Editor2Plugin.ToolbarDndSupport: No dom node with class in "+this.lookForClass);
|
||||
return;
|
||||
}
|
||||
for(var i=0; i<nodes.length; i++){
|
||||
var node = nodes[i];
|
||||
var droptarget = node.getAttribute("dojoETDropTarget");
|
||||
if(droptarget){
|
||||
(new dojo.dnd.HtmlDropTarget(node, [droptarget+tbw.widgetId])).vertical = true;
|
||||
}
|
||||
var dragsource = node.getAttribute("dojoETDragSource");
|
||||
if(dragsource){
|
||||
new dojo.dnd.HtmlDragSource(node, dragsource+tbw.widgetId);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function(){
|
||||
this.editor.unregisterLoadedPlugin(this);
|
||||
}
|
||||
});
|
||||
|
||||
//let's have a command to enable DnD
|
||||
/*dojo.declare("dojo.widget.Editor2Plugin.ToolbarDndCommand", dojo.widget.Editor2Command,{
|
||||
execute: function(text, option){
|
||||
var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
|
||||
if(curInst){
|
||||
}
|
||||
},
|
||||
getState: function(){
|
||||
}
|
||||
});*/
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.kwCompoundRequire({
|
||||
common: [ "dojo.widget.Editor2",
|
||||
"dojo.widget.Editor2Toolbar"]
|
||||
});
|
||||
dojo.provide("dojo.widget.Editor2Plugin.*");
|
Reference in New Issue
Block a user