Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2012-03-07 06:27:05

Ecco
Xinha Community Member
From: Netherlands
Registered: 2005-03-08
Posts: 48
Website

Dynamic loading and unloading Xinha

After applying the patch in http://www.xinha.org/punbb/viewtopic.php?id=3782 to the Xinha nightly, I kind of managed to load and unload Xinha by pressing a button, in both Firefox and IE9. Doesn't work perfectly but I'm glad I got this far.

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>

<script>
_editor_url  = "/xinha/";
_editor_lang = "en";
_editor_skin = "blue-look";
</script>

<script type="text/javascript" src="/xinha/XinhaCore.js"></script>

<script>

editors=null;
xinha_init=null;
xinha_config=null;

xinha_config= new Xinha.Config();
Xinha.loadPlugin('CharacterMap', function (){} );
Xinha.loadPlugin('ContextMenu', function (){} );
Xinha.loadPlugin('PasteText', function (){} );
Xinha.loadPlugin('TableOperations', function (){} );
Xinha.loadPlugin('SuperClean', function (){} );
Xinha.loadPlugin('ListType', function (){} );
Xinha.loadPlugin('HtmlEntities', function (){} );

function MakeXinha(x_id){

var ta = x_id;
xinha_config.showLoading = false;
xinha_config.statusBar = false;
xinha_config.width  = 500;
xinha_config.height = 400;
xinha_config.baseHref = null;
xinha_config.expandRelativeUrl = true;
xinha_config.stripBaseHref = false;

xinha_config.TableOperations.showButtons = false;
xinha_config.killWordOnPaste = true;

xinha_config.toolbar = [
[ "undo", "redo", "selectall", "pastetext", "htmlmode", "killword" ],
(HTMLArea.is_gecko ? [] : ["cut","copy","paste"]),
[ "justifyleft","justifycenter","justifyright","justifyfull","insertorderedlist","insertunorderedlist", "insertimage", "insertcharacter", "linebreak" ],
[ "bold","italic","underline","strikethrough", "forecolor","hilitecolor","subscript","superscript","fontname","fontsize", "createlink" ]
];

editors = Xinha.makeEditors([ta], xinha_config);

editors[ta].registerPlugin("CharacterMap");
editors[ta].registerPlugin("ContextMenu");
editors[ta].registerPlugin("PasteText");
editors[ta].registerPlugin("TableOperations");
editors[ta].registerPlugin("SuperClean");
editors[ta].registerPlugin("ListType");
editors[ta].registerPlugin("HtmlEntities");

editors[ta].generate();
var editor = Xinha.getEditor(ta);
}

function CloseXinha(x_id){

editor = Xinha.getEditor(x_id);

if(editor){
    // (R95 problem) Xinha stops in IE if we don't select everything
    if(Xinha.is_ie)
        editor._toolbarObjects.selectall.cmd(editor);
    editor.setMode('textmode');
    editor._htmlArea.style.display = 'none';
    var ta = editor._textArea;
    var nc = editor._htmlArea.nextSibling;
    ta.parentNode.removeChild(ta);
    editor._htmlArea.parentNode.insertBefore(ta, nc);
    }
else{
    alert('something wrong here!');
    }

}

</script>


</head>
<body>

<textarea id="myTextArea" style="width:500px;height:400px"></textarea>

<input type=button value="start" onclick="MakeXinha('myTextArea')">

<input type=button value="stop" onclick="CloseXinha('myTextArea')">

</body>
</html>

Offline

Board footer

Powered by FluxBB