WYSIWYG Editor XBL für Notizen im Planner

This commit is contained in:
Andreas Österreicher
2011-12-15 16:13:26 +00:00
parent 6e7fa788a1
commit b207d25013
11 changed files with 171 additions and 11 deletions
+6 -1
View File
@@ -30,4 +30,9 @@ box.Notiz
box.Ressource box.Ressource
{ {
-moz-binding: url('projekt/ressource.xml.php#Ressource'); -moz-binding: url('projekt/ressource.xml.php#Ressource');
} }
box.WYSIWYG
{
-moz-binding: url('bindings.xml.php#wysiwyg');
}
+157
View File
@@ -588,4 +588,161 @@ echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
<handlers> <handlers>
</handlers> </handlers>
</binding> </binding>
<!--
WYSIWYG Editor Binding
-->
<binding id="wysiwyg">
<content>
<xul:vbox flex="1" style="margin: 5px;">
<xul:toolbar>
<xul:toolbarbutton tooltiptext="Fett" image="../skin/images/bold.png" stlye="font-weight: bold;" oncommand="document.getBindingParent(this).setBold()"/>
<xul:toolbarbutton tooltiptext="Kursiv" image="../skin/images/italic.png" style="font-style: italic;" oncommand="document.getBindingParent(this).setItalic()"/>
<xul:toolbarbutton tooltiptext="Unterstrichen" image="../skin/images/underline.png" style="text-decoration: underline" oncommand="document.getBindingParent(this).setUnderline()"/>
<xul:toolbarseparator />
<xul:toolbarbutton tooltiptext="Linksbündig" image="../skin/images/justifyleft.png" oncommand="document.getBindingParent(this).setJustifyLeft()"/>
<xul:toolbarbutton tooltiptext="Zentriert" image="../skin/images/justifycenter.png" oncommand="document.getBindingParent(this).setJustifyCenter()"/>
<xul:toolbarbutton tooltiptext="Rechtsbündig" image="../skin/images/justifyright.png" oncommand="document.getBindingParent(this).setJustifyRight()"/>
</xul:toolbar>
<html:iframe anonid="wysiwyg-editor" editortype="html" src="about:blank" flex="1" type="content-primary" style="min-width: 100px; min-height: 100px; border: 1px solid gray;"/>
</xul:vbox>
</content>
<implementation>
<field name="initialisiert" />
<field name="disabled_state" />
<property name="value">
<getter>
<![CDATA[
if(!this.initialisiert)
this.init();
try
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
return editor.contentWindow.document.body.innerHTML;
}
catch(e)
{
return false;
}
]]>
</getter>
<setter>
<![CDATA[
//editor initalisieren
if(!this.initialisiert)
this.init();
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
if(editor.contentWindow.document.body.innerHTML!='')
{
//Inhalt leeren
editor.contentDocument.execCommand("selectall", false, null);
editor.contentDocument.execCommand("delete", false, null);
}
//Value setzen
if(val!='')
editor.contentDocument.execCommand("inserthtml", false, val);
]]>
</setter>
</property>
<property name="disabled">
<getter>
return this.disabled_state;
</getter>
<setter>
<![CDATA[
if(val)
{
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
editor.contentDocument.designMode = 'off';
this.disabled_state=true;
}
else
{
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
editor.contentDocument.designMode = 'on';
this.disabled_state=false;
}
]]>
</setter>
</property>
<method name="setBold">
<body>
<![CDATA[
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
editor.contentDocument.execCommand("bold", false, null);
]]>
</body>
</method>
<method name="setItalic">
<body>
<![CDATA[
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
editor.contentDocument.execCommand("italic", false, null);
]]>
</body>
</method>
<method name="setUnderline">
<body>
<![CDATA[
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
editor.contentDocument.execCommand("underline", false, null);
]]>
</body>
</method>
<method name="setJustifyLeft">
<body>
<![CDATA[
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
editor.contentDocument.execCommand("justifyleft", false, null);
]]>
</body>
</method>
<method name="setJustifyCenter">
<body>
<![CDATA[
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
editor.contentDocument.execCommand("justifycenter", false, null);
]]>
</body>
</method>
<method name="setJustifyRight">
<body>
<![CDATA[
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
editor.contentDocument.execCommand("justifyright", false, null);
]]>
</body>
</method>
<method name="init">
<body>
<![CDATA[
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
editor = document.getAnonymousElementByAttribute(this ,'anonid', 'wysiwyg-editor');
editor.contentDocument.designMode = 'on';
]]>
</body>
</method>
<constructor>
//Intialisierung des Editors im Konstruktor funktioniert nicht immer
//deshalb wird er erst bei der ersten Verwendung initialisiert
</constructor>
<destructor>
</destructor>
</implementation>
</binding>
</bindings> </bindings>
+4 -8
View File
@@ -146,9 +146,9 @@ echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
<xul:label value="Titel"/> <xul:label value="Titel"/>
<xul:textbox anonid="textbox-notiz-titel" maxlength="256"/> <xul:textbox anonid="textbox-notiz-titel" maxlength="256"/>
</xul:row> </xul:row>
<xul:row> <xul:row flex="1">
<xul:label value="Text"/> <xul:label value="Text"/>
<xul:textbox anonid="textbox-notiz-text" multiline="true" rows="6"/> <xul:box class="WYSIWYG" anonid="textbox-notiz-text" flex="1"/>
</xul:row> </xul:row>
<xul:row> <xul:row>
<xul:label value="Start"/> <xul:label value="Start"/>
@@ -336,7 +336,7 @@ echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
var notiz = new SOAPObject("notiz"); var notiz = new SOAPObject("notiz");
notiz.appendChild(new SOAPObject("notiz_id")).val(notiz_id); notiz.appendChild(new SOAPObject("notiz_id")).val(notiz_id);
notiz.appendChild(new SOAPObject("titel")).val(titel); notiz.appendChild(new SOAPObject("titel")).val(titel);
notiz.appendChild(new SOAPObject("text")).val(text); notiz.appendChild(new SOAPObject("text")).cdataval(text);
notiz.appendChild(new SOAPObject("verfasser_uid")).val(verfasser_uid); notiz.appendChild(new SOAPObject("verfasser_uid")).val(verfasser_uid);
notiz.appendChild(new SOAPObject("bearbeiter_uid")).val(bearbeiter_uid); notiz.appendChild(new SOAPObject("bearbeiter_uid")).val(bearbeiter_uid);
notiz.appendChild(new SOAPObject("start")).val(start); notiz.appendChild(new SOAPObject("start")).val(start);
@@ -391,14 +391,9 @@ echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
<method name="NeueNotiz"> <method name="NeueNotiz">
<body> <body>
<![CDATA[ <![CDATA[
//debug('Neue Notiz');
this.ResetDetails(); this.ResetDetails();
this.DisableDetails(false); this.DisableDetails(false);
document.getAnonymousElementByAttribute(this ,'anonid', 'caption-notiz-detail').label="Neue Notiz"; document.getAnonymousElementByAttribute(this ,'anonid', 'caption-notiz-detail').label="Neue Notiz";
var sr = new SOAPRequest("saveNotiz",soapBody);
SOAPClient.Proxy="<?php echo APP_ROOT;?>soap/notiz.soap.php?"+gettimestamp();
]]> ]]>
</body> </body>
</method> </method>
@@ -825,6 +820,7 @@ echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
</method> </method>
<constructor> <constructor>
//debug('load notiz:'+this.getAttribute('id'));
this.DisableControls(true); this.DisableControls(true);
this.DisableDetails(true); this.DisableDetails(true);
var projekt_kurzbz = this.getAttribute('projekt_kurzbz'); var projekt_kurzbz = this.getAttribute('projekt_kurzbz');
@@ -609,6 +609,7 @@ function ProjekttaskLoadCategories(project_id)
{ {
if(project_id!='') if(project_id!='')
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
//Kategorien zu diesem Projekt laden //Kategorien zu diesem Projekt laden
menulist = document.getElementById('menulist-projekttask-mantis-issue_category'); menulist = document.getElementById('menulist-projekttask-mantis-issue_category');
var url = '<?php echo APP_ROOT; ?>rdf/mantis_categories.rdf.php?project_id='+project_id+'&'+gettimestamp(); var url = '<?php echo APP_ROOT; ?>rdf/mantis_categories.rdf.php?project_id='+project_id+'&'+gettimestamp();
+3 -2
View File
@@ -150,10 +150,11 @@ var SOAPObject = function(name) {
this.name=name; this.name=name;
this.attributes=[]; this.attributes=[];
this.children=[]; this.children=[];
this.value=null; this.value=null;v
this.attr=function(name, value){this.attributes.push({"name":name, "value":value});return this;}; this.attr=function(name, value){this.attributes.push({"name":name, "value":value});return this;};
this.appendChild=function(obj){this.children.push(obj);return obj;}; this.appendChild=function(obj){this.children.push(obj);return obj;};
this.hasChildren=function(){return (this.children.length > 0)?true:false;}; this.hasChildren=function(){return (this.children.length > 0)?true:false;};
this.val=function(v){if(!v){return this.value;}else{this.value=v;return this;}}; this.val=function(v){if(!v){return this.value;}else{this.value=v;return this;}};
this.cdataval=function(v){if(!v){return this.value;}else{this.value='<![CDATA['+v+']]>';return this;}};
this.toString=function(){return SOAPClient.ToXML(this);}; this.toString=function(){return SOAPClient.ToXML(this);};
}; };
Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B