API CHANGE Moved jsparty/tinymce_ssbuttons to cms/javascript/tinymce_ssbuttons

API CHANGE Moved jsparty/tinymce_ssmacron to cms/javascript/tinymce_ssmacron

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92612 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 02:36:34 +00:00
parent 58513992aa
commit 42daa43e7a
8 changed files with 269 additions and 0 deletions

View File

@ -0,0 +1,117 @@
(function() {
tinymce.PluginManager.requireLangPack("../../tinymce_ssbuttons");
var each = tinymce.each;
tinymce.create('tinymce.plugins.SSButtons', {
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @returns Name/value array containing information about the plugin.
* @type Array
*/
getInfo : function() {
return {
longname : 'Special buttons for SilverStripe CMS',
author : 'Sam Minnée',
authorurl : 'http://www.siverstripe.com/',
infourl : 'http://www.silverstripe.com/',
version : "1.0"
};
},
init : function(ed, url) {
/**
* These map the action buttons to the IDs of the forms that they open/close
*/
forms = {
'sslink' : 'Form_EditorToolbarLinkForm',
'ssimage' : 'Form_EditorToolbarImageForm',
'ssflash' : 'Form_EditorToolbarFlashForm'
};
ed.addButton('sslink', {title : ed.getLang('tinymce_ssbuttons.insertlink'), cmd : 'sslink', 'class' : 'mce_link'});
ed.addButton('ssimage', {title : ed.getLang('tinymce_ssbuttons.insertimage'), cmd : 'ssimage', 'class' : 'mce_image'});
ed.addButton('ssflash', {title : ed.getLang('tinymce_ssbuttons.insertflash'), cmd : 'ssflash', 'class' : 'mce_flash', 'image': url + '/img/flash.gif'});
/**
* Show a side panel, hiding others
* If showCommand isn't set, then this will simply hide panels
*/
function showSidePanel(showCommand, hideCommands) {
hideCommands.each(function(command) {
ed.controlManager.setActive(command,false);
Element.hide(forms[command]);
});
var showForm = null;
if(forms[showCommand]) {
showForm = $(forms[showCommand]);
showForm.toggle(ed);
}
if(!showForm || showForm.style.display == "none") {
ed.controlManager.setActive(showCommand, false);
// Can't use $('contentPanel'), as its in a different window
window.parent.document.getElementById('contentPanel').style.display = "none";
// toggle layout panel
jQuery('body.CMSMain').concrete('ss').MainLayout().close('east');
} else {
ed.controlManager.setActive(showCommand, true);
window.parent.document.getElementById('contentPanel').style.display = "block";
// toggle layout panel
jQuery('body.CMSMain').concrete('ss').MainLayout().resizeAll();
jQuery('body.CMSMain').concrete('ss').MainLayout().open('east');
}
}
ed.addCommand("ssclosesidepanel", function(ed) {
showSidePanel('', [ 'sslink', 'ssimage', 'ssflash' ]);
});
ed.addCommand("sslink", function(ed) {
showSidePanel('sslink', [ 'ssimage', 'ssflash' ]);
});
ed.addCommand("ssimage", function(ed) {
showSidePanel('ssimage', [ 'sslink', 'ssflash' ]);
});
ed.addCommand("ssflash", function(ed) {
showSidePanel('ssflash', [ 'ssimage', 'sslink' ]);
});
ed.onNodeChange.add(function(ed, o) {
//$('Form_EditorToolbarLinkForm').updateSelection(ed);
//$('Form_EditorToolbarLinkForm').respondToNodeChange(ed);
});
ed.onKeyUp.add(function(ed, o) {
//$('Form_EditorToolbarLinkForm').updateSelection(ed);
});
// resize image containers when the image is resized.
if(!tinymce.isOpera && !tinymce.isWebKit) ed.onMouseUp.add(function(ed, o) {
var node = ed.selection.getNode();
if(node.nodeName == 'IMG' && ed.dom.getParent(node, 'div')) {
// we have to delay the resize check here, as this event handler is called before the actual image
// resizing is done.
setTimeout(function() {
var ed = tinyMCE.activeEditor, // we need to redeclare these for IE.
node = ed.selection.getNode(),
container = ed.dom.getParent(node, 'div');
if(node.width && node.width != parseInt(ed.dom.getStyle(container, 'width'))) {
ed.dom.setStyle(container, 'width', parseInt(node.width));
ed.execCommand('mceRepaint');
}
}, 1);
}
});
}
});
// Adds the plugin class to the list of available TinyMCE plugins
tinymce.PluginManager.add("../../tinymce_ssbuttons", tinymce.plugins.SSButtons);
})();

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

View File

@ -0,0 +1,5 @@
tinyMCE.addI18n('de.tinymce_ssbuttons',{
insertlink: 'Link einfügen',
insertimage: 'Bild einfügen',
insertflash: 'Flash Objekt einfügen'
});

View File

@ -0,0 +1,5 @@
tinyMCE.addI18n('en.tinymce_ssbuttons', {
insertlink: 'Insert Link',
insertimage: 'Insert Image',
insertflash: 'Insert Flash Object'
});

View File

@ -0,0 +1,40 @@
(function() {
var each = tinymce.each;
tinymce.create('tinymce.plugins.InsertMacron', {
getInfo : function() {
return {
longname : 'Button to insert macrons',
author : 'Hamish Friedlander. Heavily based on charmap that comes with TinyMCE',
authorurl : 'http://www.siverstripe.com/',
infourl : 'http://www.silverstripe.com/',
version : "1.0"
};
},
init : function(ed, url) {
// Register commands
ed.addCommand('mceInsertMacron', function() {
ed.windowManager.open({
file : url + '/macron.htm',
width : 350 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),
height : 150 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),
inline : true
}, {
plugin_url : url
});
});
// Register buttons
ed.addButton('ssmacron', {
title : 'Insert a Macron',
cmd : 'mceInsertMacron',
image : url + '/img/macron.png'
});
}
});
// Adds the plugin class to the list of available TinyMCE plugins
tinymce.PluginManager.add("../../tinymce_ssmacron", tinymce.plugins.InsertMacron);
})();

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -0,0 +1,71 @@
tinyMCEPopup.requireLangPack();
var charmap = [
['Ā', 'Ā', true, 'A - macron'],
['Ē', 'Ē', true, 'E - macron'],
['Ī', 'Ī', true, 'I - macron'],
['Ō', 'Ō', true, 'O - macron'],
['Ū', 'Ū', true, 'U - macron'],
['ā', 'ā', true, 'a - macron'],
['ē', 'ē', true, 'e - macron'],
['ī', 'ī', true, 'i - macron'],
['ō', 'ō', true, 'o - macron'],
['ū', 'ū', true, 'u - macron']
];
tinyMCEPopup.onInit.add(function() {
tinyMCEPopup.dom.setHTML('charmapView', renderCharMapHTML());
});
function renderCharMapHTML() {
var charsPerRow = 5, tdWidth=20, tdHeight=20, i;
var html = '<table border="0" cellspacing="1" cellpadding="0" width="' + (tdWidth*charsPerRow) + '"><tr height="' + tdHeight + '">';
var cols=-1;
for (i=0; i<charmap.length; i++) {
if (charmap[i][2]==true) {
cols++;
html += ''
+ '<td class="charmap">'
+ '<a onmouseover="previewChar(\'' + charmap[i][1].substring(1,charmap[i][1].length) + '\',\'' + charmap[i][0].substring(1,charmap[i][0].length) + '\',\'' + charmap[i][3] + '\');" onfocus="previewChar(\'' + charmap[i][1].substring(1,charmap[i][1].length) + '\',\'' + charmap[i][0].substring(1,charmap[i][0].length) + '\',\'' + charmap[i][3] + '\');" href="javascript:void(0)" onclick="insertChar(\'' + charmap[i][1].substring(2,charmap[i][1].length-1) + '\');" onclick="return false;" onmousedown="return false;" title="' + charmap[i][3] + '">'
+ charmap[i][1]
+ '</a></td>';
if ((cols+1) % charsPerRow == 0)
html += '</tr><tr height="' + tdHeight + '">';
}
}
if (cols % charsPerRow > 0) {
var padd = charsPerRow - (cols % charsPerRow);
for (var i=0; i<padd-1; i++)
html += '<td width="' + tdWidth + '" height="' + tdHeight + '" class="charmap">&nbsp;</td>';
}
html += '</tr></table>';
return html;
}
function insertChar(chr) {
tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';');
// Refocus in window
if (tinyMCEPopup.isWindow)
window.focus();
tinyMCEPopup.editor.focus();
tinyMCEPopup.close();
}
function previewChar(codeA, codeB, codeN) {
var elmV = document.getElementById('codeV');
var elmN = document.getElementById('codeN');
if (codeA=='#160;') {
elmV.innerHTML = '__';
} else {
elmV.innerHTML = '&' + codeA;
}
elmN.innerHTML = codeN;
}

View File

@ -0,0 +1,31 @@
<!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">
<head>
<title>Insert a Macron</title>
<script type="text/javascript" src="../tiny_mce/tiny_mce_popup.js"></script>
<script type="text/javascript" src="js/macron.js"></script>
</head>
<body id="charmap" style="display:none">
<table align="center" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2" class="title">Insert a Macron</td>
</tr>
<tr>
<td id="charmapView" align="left" valign="top">
<!-- Chars will be rendered here -->
</td>
<td width="100" align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100" style="height:100px">
<tr>
<td id="codeV">&nbsp;</td>
</tr>
<tr>
<td id="codeN">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>