Autotext at the RichTextEditor

Moderator: crythias

Locked
Cetacea
Znuny newbie
Posts: 8
Joined: 10 May 2011, 23:22
Znuny Version: 3.07

Autotext at the RichTextEditor

Post by Cetacea »

Hello!

I want an autotext in the standart RichTextEditor at Phoneticket for each Queue. Have your any idea how i can do that?
OTRS: 3.0.7
BS: Win 7
Cetacea
Znuny newbie
Posts: 8
Joined: 10 May 2011, 23:22
Znuny Version: 3.07

Re: Autotext at the RichTextEditor

Post by Cetacea »

I done it by myself with an javascript:

<script type="text/javascript">//<![CDATA[
var Texte = new Array();
Texte['E-Mails'] = 'Text 1';
Texte['Postmaster'] = 'Text 2';

$("#Subject").change(function(){
var selectedValue = $(this).find(":selected").val();
if (typeof(Texte[selectedValue]) != 'undefined'){
var element = $('iframe').contents().find('body.cke_show_borders').get(0);
elem=CKEDITOR.dom.element.get( element )
elem.setText(Texte[selectedValue]);
}
});
OTRS: 3.0.7
BS: Win 7
scareface
Znuny newbie
Posts: 19
Joined: 22 Nov 2011, 09:05
Znuny Version: 3.1.7

Re: Autotext at the RichTextEditor

Post by scareface »

I had same idea to populate the Editor during runtime and found a better way to get the Editor

Code: Select all

var Texte = new Array();
Texte['E-Mails'] = 'Text 1';
Texte['Postmaster'] = 'Text 2';

$("#Subject").change(function(){
    var selectedValue = $(this).find(":selected").val();
    if (typeof(Texte[selectedValue]) != 'undefined'){
        var oEditor = CKEDITOR.instances.RichText; //RichText is the id of the instance
        var oldHTMLText = oEditor.getData();
        var newHTMLText = '<p>Texte[selectedValue]</p>';
        //set new
        elem.setData(newHTMLText )
        // append HTML
        oEditor.insertHtml(newHTMLText )
        // append Text
        oEditor.insertText(Texte[selectedValue]);
    }
});
 
see http://docs.cksource.com/ckeditor_api/ for further documentation
OTRS: 3.1.7 (Test) 3.1.7(Prod)
OS: CentOS
Web/DB: Apache2/MySQL 5 ? MSSQL
Locked