(Experimental) Replace htmlarea with XINHA. Thanks to abdussamad!
This commit is contained in:
93
htmlarea/plugins/InsertSnippet/InsertSnippet.css
Executable file
93
htmlarea/plugins/InsertSnippet/InsertSnippet.css
Executable file
@@ -0,0 +1,93 @@
|
||||
.navi_links {
|
||||
width: 177px;
|
||||
margin: 0;
|
||||
padding: 0px;
|
||||
list-style:none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.navi_links li {
|
||||
margin:0 0 3px 0;
|
||||
}
|
||||
|
||||
.navi_links li a {
|
||||
font-size: 13px;
|
||||
line-height: 16px;
|
||||
height: 16px;
|
||||
display:block;
|
||||
color:#000;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
background-color: #fff;
|
||||
cursor: pointer;
|
||||
border: 2px solid white;
|
||||
|
||||
}
|
||||
|
||||
.Link1 {
|
||||
background-color: #DF1D1F !important;
|
||||
|
||||
}
|
||||
|
||||
.Link2 {
|
||||
background-color: #F9A413 !important;
|
||||
|
||||
}
|
||||
|
||||
.Link3 {
|
||||
background-color: #167730 !important;
|
||||
}
|
||||
|
||||
.Link4 {
|
||||
background-color: #233350 !important;
|
||||
}
|
||||
|
||||
.Link5 {
|
||||
background-color: #70685B !important;
|
||||
}
|
||||
|
||||
a.Link1:hover span{
|
||||
background-color: #DF1D1F !important;
|
||||
}
|
||||
|
||||
a.Link2:hover span {
|
||||
background-color: #F9A413 !important;
|
||||
|
||||
}
|
||||
|
||||
.Link3:hover span {
|
||||
background-color: #167730 !important;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.Link4:hover span {
|
||||
background-color: #233350 !important;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.Link5:hover span {
|
||||
background-color: #70685B !important;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.navi_links li a span {
|
||||
height: 16px;
|
||||
text-indent: 4px;
|
||||
display:block;
|
||||
margin-left: 15px;
|
||||
background-color: #FFF;
|
||||
}
|
||||
|
||||
div.message_box {
|
||||
border: dotted 1px black;
|
||||
margin: 1em;
|
||||
padding:1em;
|
||||
}
|
||||
|
||||
.red {
|
||||
color:red;
|
||||
}
|
||||
|
||||
.green {
|
||||
color:green;
|
||||
}
|
17
htmlarea/plugins/InsertSnippet/demosnippets.js
Normal file
17
htmlarea/plugins/InsertSnippet/demosnippets.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
|
||||
/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */
|
||||
/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/plugins/InsertSnippet/demosnippets.js */
|
||||
var snippets=[];
|
||||
var i=0;
|
||||
snippets[i]={};
|
||||
snippets[i]["id"]="Box 1";
|
||||
snippets[i]["HTML"]="<div class=\"message_box red\">\n Visit the <a href=\"http://xinha.org\">Xinha website</a></div>";
|
||||
i++;
|
||||
snippets[i]={};
|
||||
snippets[i]["id"]="INFORMATION ABOUT SOMETHING";
|
||||
snippets[i]["HTML"]="<div class=\"message_box green\">\n This is an information about something\n</div>";
|
||||
i++;
|
||||
snippets[i]={};
|
||||
snippets[i]["id"]="Menu";
|
||||
snippets[i]["HTML"]="<ul class=\"navi_links\">\n\t<li class=\"navi\">\n\t\t<a href=\"Link1\" class=\"Link1\" tabindex=\"1\"><span class=\"span_class\">Link1</span></a>\n </li>\n\t\n\t<li class=\"navi\">\n\t\t<a href=\"Link2\" class=\"Link2\" tabindex=\"2\"><span class=\"span_class\">Link2</span></a>\n </li>\n\n\t\n\t<li class=\"navi\">\n\t\t<a href=\"Link3\" class=\"Link3\" tabindex=\"3\"><span class=\"span_class\">Link3</span></a>\n </li>\n\t\n\t<li class=\"navi\">\n\t\t<a href=\"Link4\" class=\"Link4\" tabindex=\"4\"><span class=\"span_class\">Link4</span></a>\n </li>\n\t\n\t<li class=\"navi\">\n\t\t<a href=\"Link5\" class=\"Link5\" tabindex=\"5\"><span class=\"span_class\">Link5</span></a>\n\n </li>\n\n</ul>";
|
||||
|
BIN
htmlarea/plugins/InsertSnippet/img/ed_snippet.gif
Executable file
BIN
htmlarea/plugins/InsertSnippet/img/ed_snippet.gif
Executable file
Binary file not shown.
After Width: | Height: | Size: 606 B |
55
htmlarea/plugins/InsertSnippet/insert-snippet.js
Normal file
55
htmlarea/plugins/InsertSnippet/insert-snippet.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
|
||||
/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */
|
||||
/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/plugins/InsertSnippet/insert-snippet.js */
|
||||
function InsertSnippet(_1){
|
||||
this.editor=_1;
|
||||
var _2=_1.config;
|
||||
var _3=this;
|
||||
_2.registerButton({id:"insertsnippet",tooltip:this._lc("Insert Snippet"),image:_1.imgURL("ed_snippet.gif","InsertSnippet"),textMode:false,action:function(_4){
|
||||
_3.buttonPress(_4);
|
||||
}});
|
||||
_2.addToolbarElement("insertsnippet","insertimage",-1);
|
||||
this.snippets=null;
|
||||
var _5=_2.InsertSnippet.snippets+"?";
|
||||
if(_2.InsertSnippet.backend_data!=null){
|
||||
for(var i in _2.InsertSnippet.backend_data){
|
||||
_5+="&"+i+"="+encodeURIComponent(_2.InsertSnippet.backend_data[i]);
|
||||
}
|
||||
}
|
||||
Xinha._getback(_5,function(_7){
|
||||
eval(_7);
|
||||
_3.snippets=snippets;
|
||||
});
|
||||
}
|
||||
InsertSnippet.prototype.onUpdateToolbar=function(){
|
||||
if(!this.snippets){
|
||||
this.editor._toolbarObjects.insertsnippet.state("enabled",false);
|
||||
}else{
|
||||
InsertSnippet.prototype.onUpdateToolbar=null;
|
||||
}
|
||||
};
|
||||
InsertSnippet._pluginInfo={name:"InsertSnippet",version:"1.2",developer:"Raimund Meyer",developer_url:"http://rheinauf.de",c_owner:"Raimund Meyer",sponsor:"",sponsor_url:"",license:"htmlArea"};
|
||||
InsertSnippet.prototype._lc=function(_8){
|
||||
return Xinha._lc(_8,"InsertSnippet");
|
||||
};
|
||||
InsertSnippet.prototype.onGenerate=function(){
|
||||
this.editor.addEditorStylesheet(Xinha.getPluginDir("InsertSnippet")+"/InsertSnippet.css");
|
||||
};
|
||||
Xinha.Config.prototype.InsertSnippet={"snippets":Xinha.getPluginDir("InsertSnippet")+"/demosnippets.js","css":["../InsertSnippet.css"],"showInsertVariable":false,"backend_data":null};
|
||||
InsertSnippet.prototype.buttonPress=function(_9){
|
||||
var _a=_9.config;
|
||||
_a.snippets=this.snippets;
|
||||
var _b=this;
|
||||
_9._popupDialog("plugin://InsertSnippet/insertsnippet",function(_c){
|
||||
if(!_c){
|
||||
return false;
|
||||
}
|
||||
_9.focusEditor();
|
||||
if(_c["how"]=="variable"){
|
||||
_9.insertHTML("{"+_b.snippets[_c["snippetnum"]].id+"}");
|
||||
}else{
|
||||
_9.insertHTML(_b.snippets[_c["snippetnum"]].HTML);
|
||||
}
|
||||
},_a);
|
||||
};
|
||||
|
10
htmlarea/plugins/InsertSnippet/lang/de.js
Normal file
10
htmlarea/plugins/InsertSnippet/lang/de.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// I18N constants
|
||||
// LANG: "de", ENCODING: UTF-8
|
||||
{
|
||||
"Insert Snippet": "Snippet einfügen",
|
||||
"Cancel": "Abbrechen",
|
||||
"Variable":"Variable",
|
||||
"Insert as":"Einfügen als",
|
||||
"Show preview":"Vorschau zeigen",
|
||||
"Hide preview":"Vorschau verbergen"
|
||||
};
|
10
htmlarea/plugins/InsertSnippet/lang/ja.js
Normal file
10
htmlarea/plugins/InsertSnippet/lang/ja.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// I18N constants
|
||||
// LANG: "ja", ENCODING: UTF-8
|
||||
{
|
||||
"Insert Snippet": "スニペットの挿入",
|
||||
"Cancel": "中止",
|
||||
"Variable":"変数",
|
||||
"Insert as":"形式を選んで挿入",
|
||||
"Show preview":"プレビュー表示",
|
||||
"Hide preview":"プレビュー非表示"
|
||||
};
|
11
htmlarea/plugins/InsertSnippet/lang/nb.js
Normal file
11
htmlarea/plugins/InsertSnippet/lang/nb.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// I18N constants
|
||||
// LANG: "nb", ENCODING: UTF-8
|
||||
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
|
||||
{
|
||||
"Insert Snippet": "Sett inn snutt",
|
||||
"Cancel": "Avbryt",
|
||||
"Variable":"Variabel",
|
||||
"Insert as":"Sett inn som",
|
||||
"Show preview":"Vis forhåndsvisning",
|
||||
"Hide preview":"Skjul forhåndsvisning"
|
||||
};
|
11
htmlarea/plugins/InsertSnippet/lang/nl.js
Normal file
11
htmlarea/plugins/InsertSnippet/lang/nl.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// I18N constants
|
||||
// LANG: "nl", ENCODING: UTF-8
|
||||
// Author: Maarten Molenschot, maarten@nrgmm.nl
|
||||
{
|
||||
"Insert Snippet": "Snippet invoegen",
|
||||
"Cancel": "Annuleren",
|
||||
"Variable":"Variabele",
|
||||
"Insert as":"Invoegen als",
|
||||
"Show preview":"Laat voorbeeld zien",
|
||||
"Hide preview":"Verberg voorbeeld"
|
||||
};
|
25
htmlarea/plugins/InsertSnippet/lang/pt_br.js
Normal file
25
htmlarea/plugins/InsertSnippet/lang/pt_br.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// I18N constants
|
||||
//
|
||||
// LANG: "pt_br", ENCODING: UTF-8
|
||||
// Portuguese Brazilian Translation
|
||||
//
|
||||
// Author: Marcio Barbosa, <marcio@mpg.com.br>
|
||||
// MSN: tomarshall@msn.com - ICQ: 69419933
|
||||
// Site: http://www.mpg.com.br
|
||||
//
|
||||
// Last revision: 06 september 2007
|
||||
// Please don´t remove this information
|
||||
// If you modify any source, please insert a comment with your name and e-mail
|
||||
//
|
||||
// Distributed under the same terms as HTMLArea itself.
|
||||
// This notice MUST stay intact for use (see license.txt).
|
||||
{
|
||||
"Cancel": "Cancelar",
|
||||
"Hide preview": "Esconder Visualização",
|
||||
"Insert Snippet": "Inserir Fragmento de Código",
|
||||
"Insert as": "Inserir como",
|
||||
"InsertSnippet for Xinha": "Fragmento de Códigos para o Xinha",
|
||||
"Show preview": "Mostrar Visualização",
|
||||
"This is an information about something": "Isto é uma informação sobre alguma coisa",
|
||||
"Variable": "Variável"
|
||||
}
|
133
htmlarea/plugins/InsertSnippet/popups/insertsnippet.html
Executable file
133
htmlarea/plugins/InsertSnippet/popups/insertsnippet.html
Executable file
@@ -0,0 +1,133 @@
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>Insert Snippet</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../InsertSnippet.css" />
|
||||
<script type="text/javascript" src="../../../popups/popup.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var InsertSnippet = window.opener.InsertSnippet;
|
||||
var editor = null;
|
||||
|
||||
|
||||
function Init() {
|
||||
__dlg_translate("InsertSnippet");
|
||||
__dlg_init(null, {width:800,height:600});
|
||||
|
||||
var config = window.dialogArguments;
|
||||
|
||||
var snippets = config.snippets;
|
||||
|
||||
if ( config.pageStyle && !Xinha.is_ie)
|
||||
{
|
||||
var style = document.createElement("style");
|
||||
style.type = "text/css";
|
||||
style.innerHTML = config.pageStyle;
|
||||
document.getElementsByTagName("HEAD")[0].appendChild(style);
|
||||
}
|
||||
|
||||
if ( typeof config.pageStyleSheets !== 'undefined' )
|
||||
{
|
||||
for ( var i = 0; i < config.pageStyleSheets.length; i++ )
|
||||
{
|
||||
var style = document.createElement("link");
|
||||
style.type = "text/css";
|
||||
style.rel = 'stylesheet';
|
||||
style.href = config.pageStyleSheets[i];
|
||||
document.getElementsByTagName("HEAD")[0].appendChild(style);
|
||||
}
|
||||
}
|
||||
|
||||
var tbody = document.getElementById("snippettable");
|
||||
var snippet_html;
|
||||
var snippet_name;
|
||||
var trow;
|
||||
for(var i = 0; i < snippets.length; i++)
|
||||
{
|
||||
trow = tbody.insertRow(i);
|
||||
snippet_html = snippets[i]['HTML'];
|
||||
snippet_name = snippets[i]['id'];
|
||||
|
||||
var insertAsVariable = '';
|
||||
if (config.InsertSnippet.showInsertVariable)
|
||||
{
|
||||
insertAsVariable = ' | <a href="javascript:onOK('+i+','+'\'variable\''+')">'+Xinha._lc("Variable","InsertSnippet")+'</a>';
|
||||
}
|
||||
var new_cell = trow.insertCell(0);
|
||||
new_cell.innerHTML = snippet_name +': '+Xinha._lc("Insert as","InsertSnippet")+' <a href="javascript:onOK('+i+','+'\'html\''+')">HTML</a>'+insertAsVariable + ' (<a id="show_preview'+i+'" href="javascript:preview(\'show\','+i+')">'+Xinha._lc("Show preview","InsertSnippet")+'</a>)<div id="preview'+i+'" style="display:none">'+snippets[i]['HTML']+'</div>';
|
||||
new_cell.id = 'cell' + i;
|
||||
|
||||
}
|
||||
|
||||
document.body.onkeypress = __dlg_key_press;
|
||||
}
|
||||
|
||||
function preview(action,i) {
|
||||
var show_preview_link = document.getElementById('show_preview'+i);
|
||||
switch(action)
|
||||
{
|
||||
case 'show':
|
||||
document.getElementById('preview'+i).style.display = 'block';
|
||||
show_preview_link.innerHTML = Xinha._lc("Hide preview","InsertSnippet");
|
||||
show_preview_link.href = "javascript:preview('hide','"+i+"');";
|
||||
|
||||
break;
|
||||
case 'hide':
|
||||
document.getElementById('preview'+i).style.display = 'none';
|
||||
show_preview_link.innerHTML = Xinha._lc("Show preview","InsertSnippet");
|
||||
show_preview_link.href = "javascript:preview('show','"+i+"');";
|
||||
break;
|
||||
}
|
||||
}
|
||||
function onCancel() {
|
||||
__dlg_close(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
function onOK(snippetnum,how) {
|
||||
var params = new Object();
|
||||
params["snippetnum"] = snippetnum;
|
||||
params["how"] = how;
|
||||
__dlg_close(params);
|
||||
return false;
|
||||
}
|
||||
|
||||
function __dlg_key_press(ev) {
|
||||
ev || (ev = window.event);
|
||||
switch(ev.keyCode) {
|
||||
case 13:
|
||||
document.getElementById('bt_ok').click();
|
||||
break;
|
||||
case 27:
|
||||
__dlg_close();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
body {margin:0 !IMPORTANT;padding:0 !IMPORTANT;}
|
||||
.buttons {border-top: 1px solid #999; padding: 5px; text-align: right; height: 20px; }
|
||||
td {background:white;padding:5px;border:1px solid;border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;}
|
||||
.preview {}
|
||||
</style>
|
||||
</head>
|
||||
<body class="dialog" onload="Init()">
|
||||
<form action="" method="get">
|
||||
<div class="title" >Insert Snippet</div>
|
||||
<div style="height:470px;overflow:auto;">
|
||||
<table style="border: 0; width: 100%;" id="snippettable">
|
||||
</table>
|
||||
</div>
|
||||
<div class="space"></div>
|
||||
<div class="buttons">
|
||||
<button type="button" onclick="return onCancel();">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
57
htmlarea/plugins/InsertSnippet/readme.html
Executable file
57
htmlarea/plugins/InsertSnippet/readme.html
Executable file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>InsertSnippet for Xinha</title>
|
||||
|
||||
<style type="text/css">
|
||||
body { font-family: sans-serif; }
|
||||
pre {border: dotted grey thin; background-color:LightYellow;padding:10px }
|
||||
p { width:500px }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body >
|
||||
<h1>InsertSnippet for Xinha</h1>
|
||||
<p>Insert HTML fragments in your document.
|
||||
|
||||
</p>
|
||||
<h2>Usage</h2>
|
||||
<p>
|
||||
In order to use your own snippets you have to al least one parameter to your xinha_config:
|
||||
</p>
|
||||
<pre>
|
||||
xinha_config.InsertSnippet.snippets = _editor_url+"plugins/InsertSnippet/snippets.php";
|
||||
</pre>
|
||||
<p>
|
||||
The path above indicates the use of the provided backend. This parses a file that contains the snippets and
|
||||
should have the following format:
|
||||
</p>
|
||||
<pre>
|
||||
<!--Snippet ID-->
|
||||
Snippet content
|
||||
<!--/Snippet ID-->
|
||||
...and so on
|
||||
</pre>
|
||||
<p>
|
||||
You can use the snippets.html in the plugin folder or tell the backend where to find the file like this
|
||||
</p>
|
||||
<pre>
|
||||
with (xinha_config.InsertSnippet)
|
||||
{
|
||||
<?php
|
||||
|
||||
// define backend configuration for the plugin
|
||||
$backend_data['snippets_file'] = '/file/containing/snippets.html';
|
||||
require_once '../contrib/php-xinha.php';
|
||||
xinha_pass_to_php_backend($backend_data);
|
||||
|
||||
?>
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p style="font-size:80%">Raimund Meyer (xinha@raimundmeyer.de)</p>
|
||||
</body>
|
||||
</html>
|
29
htmlarea/plugins/InsertSnippet/snippets.html
Executable file
29
htmlarea/plugins/InsertSnippet/snippets.html
Executable file
@@ -0,0 +1,29 @@
|
||||
<!--Box 1-->
|
||||
<div class="message_box red">
|
||||
Visit the <a href="http://xinha.org">Xinha website</a>
|
||||
</div>
|
||||
<!--/Box 1-->
|
||||
<!--INFORMATION ABOUT SOMETHING-->
|
||||
<div class="message_box green">
|
||||
This is an information about something
|
||||
</div>
|
||||
<!--/INFORMATION ABOUT SOMETHING-->
|
||||
<!--Menu-->
|
||||
<ul class="navi_links">
|
||||
<li class="navi">
|
||||
<a href="Link1" class="Link1" tabindex="1"><span class="span_class"> Link1 </span></a>
|
||||
</li>
|
||||
<li class="navi">
|
||||
<a href="Link2" class="Link2" tabindex="2"><span class="span_class"> Link2 </span></a>
|
||||
</li>
|
||||
<li class="navi">
|
||||
<a href="Link3" class="Link3" tabindex="3"><span class="span_class"> Link3 </span></a>
|
||||
</li>
|
||||
<li class="navi">
|
||||
<a href="Link4" class="Link4" tabindex="4"><span class="span_class"> Link4 </span></a>
|
||||
</li>
|
||||
<li class="navi">
|
||||
<a href="Link5" class="Link5" tabindex="5"><span class="span_class"> Link5 </span></a>
|
||||
</li>
|
||||
</ul>
|
||||
<!--/Menu-->
|
22
htmlarea/plugins/InsertSnippet/snippets.php
Executable file
22
htmlarea/plugins/InsertSnippet/snippets.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
$snippets_file = 'snippets.html';
|
||||
|
||||
include_once('../../contrib/php-xinha.php');
|
||||
|
||||
if($passed_data = xinha_read_passed_data())
|
||||
{
|
||||
extract($passed_data);
|
||||
}
|
||||
$snippets = file_get_contents($snippets_file);
|
||||
preg_match_all('/<!--(.*?)-->(.*?)<!--\/.*?-->/s',$snippets,$matches);
|
||||
|
||||
$array=array();
|
||||
for ($i=0;$i<count($matches[1]);$i++)
|
||||
{
|
||||
$id = $matches[1][$i];
|
||||
$html = $matches[2][$i];
|
||||
$array[] = array('id'=>$id,'HTML'=>$html);
|
||||
}
|
||||
print "var snippets = " . xinha_to_js($array);
|
||||
|
||||
?>
|
Reference in New Issue
Block a user