Skip to content
This repository
Browse code

API-CHANGE Move tinymce plugins in thirdparty

  • Loading branch information...
commit b4e155258f48a023210c7f7a4dfa6e1033391600 1 parent 9fdcf34
Simon Welsh authored April 12, 2012
52  thirdparty/tinymce_ssbuttons/editor_plugin_src.js
... ...
@@ -0,0 +1,52 @@
  1
+(function() {
  2
+
  3
+	// TinyMCE will stop loading if it encounters non-existent external script file
  4
+	// when included through tiny_mce_gzip.php. Only load the external lang package if it is available.
  5
+	var availableLangs = ['en', 'de'];
  6
+	if(jQuery.inArray(tinymce.settings.language, availableLangs) != -1) {
  7
+		tinymce.PluginManager.requireLangPack("ssbuttons");
  8
+	}
  9
+
  10
+	var each = tinymce.each;
  11
+
  12
+	tinymce.create('tinymce.plugins.SSButtons', {
  13
+		/**
  14
+		 * Returns information about the plugin as a name/value array.
  15
+		 * The current keys are longname, author, authorurl, infourl and version.
  16
+		 *
  17
+		 * @returns Name/value array containing information about the plugin.
  18
+		 * @type Array 
  19
+		 */
  20
+		getInfo : function() {
  21
+			return {
  22
+				longname : 'Special buttons for SilverStripe CMS',
  23
+				author : 'Sam Minnée',
  24
+				authorurl : 'http://www.siverstripe.com/',
  25
+				infourl : 'http://www.silverstripe.com/',
  26
+				version : "1.0"
  27
+			};
  28
+		},
  29
+
  30
+		init : function(ed, url) {
  31
+			ed.addButton('sslink', {title : ed.getLang('tinymce_ssbuttons.insertlink'), cmd : 'sslink', 'class' : 'mce_link'}); 
  32
+			ed.addButton('ssimage', {title : ed.getLang('tinymce_ssbuttons.insertimage'), cmd : 'ssimage', 'class' : 'mce_image'}); 
  33
+
  34
+			ed.addCommand("sslink", function(ed) {
  35
+				jQuery('#Form_EditorToolbarLinkForm').entwine('ss').open();
  36
+			});
  37
+
  38
+			ed.addCommand("ssimage", function(ed) {
  39
+				jQuery('#Form_EditorToolbarMediaForm').entwine('ss').open();
  40
+			});
  41
+			
  42
+			// Disable link button when no link is selected
  43
+			ed.onNodeChange.add(function(ed, cm, n, co) {
  44
+				cm.setDisabled('sslink', co && n.nodeName != 'A');
  45
+				cm.setActive('sslink', n.nodeName == 'A' && !n.name);
  46
+			});
  47
+		}
  48
+	});
  49
+
  50
+	// Adds the plugin class to the list of available TinyMCE plugins
  51
+	tinymce.PluginManager.add("ssbuttons", tinymce.plugins.SSButtons);
  52
+})();
BIN  thirdparty/tinymce_ssbuttons/img/flash.gif
5  thirdparty/tinymce_ssbuttons/langs/de.js
... ...
@@ -0,0 +1,5 @@
  1
+tinyMCE.addI18n('de.tinymce_ssbuttons',{
  2
+insertlink: 'Link einfügen',
  3
+insertimage: 'Bild einfügen',
  4
+insertflash: 'Flash Objekt einfügen'
  5
+});
5  thirdparty/tinymce_ssbuttons/langs/en.js
... ...
@@ -0,0 +1,5 @@
  1
+tinyMCE.addI18n('en.tinymce_ssbuttons', {
  2
+insertlink: 'Insert Link',
  3
+insertimage: 'Insert Image',
  4
+insertflash: 'Insert Flash Object'
  5
+});
46  thirdparty/tinymce_ssmacron/editor_plugin_src.js
... ...
@@ -0,0 +1,46 @@
  1
+(function() {
  2
+	var each = tinymce.each;
  3
+
  4
+	/**
  5
+	 * Load via: 
  6
+	 * HtmlEditorConfig::get('cms')->enablePlugins(array('ssmacron', '../tinymce_ssmacron'))
  7
+	 * HtmlEditorConfig::get('cms')->insertButtonsAfter ('advcode', 'ssmacron');
  8
+	 */
  9
+	tinymce.create('tinymce.plugins.InsertMacron', {
  10
+		getInfo : function() {
  11
+			return {
  12
+				longname : 'Button to insert macrons',
  13
+				author : 'Hamish Friedlander. Heavily based on charmap that comes with TinyMCE',
  14
+				authorurl : 'http://www.siverstripe.com/',
  15
+				infourl : 'http://www.silverstripe.com/',
  16
+				version : "1.0"
  17
+			};
  18
+		},
  19
+
  20
+
  21
+		init : function(ed, url) {
  22
+	      // Register commands
  23
+	      ed.addCommand('mceInsertMacron', function() {
  24
+				ed.windowManager.open({
  25
+					file : url + '/macron.htm',
  26
+					width : 350 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),
  27
+					height : 150 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),
  28
+					inline : true
  29
+				}, {
  30
+					plugin_url : url
  31
+				});
  32
+			});
  33
+	
  34
+	      // Register buttons
  35
+	      ed.addButton('ssmacron', {
  36
+	        title : 'Insert a Macron',
  37
+	        cmd : 'mceInsertMacron',
  38
+	        image : url + '/img/macron.png'
  39
+	      });
  40
+	      
  41
+		}
  42
+	});
  43
+
  44
+	// Adds the plugin class to the list of available TinyMCE plugins
  45
+	tinymce.PluginManager.add("ssmacron", tinymce.plugins.InsertMacron);
  46
+})();
BIN  thirdparty/tinymce_ssmacron/img/macron.png
71  thirdparty/tinymce_ssmacron/js/macron.js
... ...
@@ -0,0 +1,71 @@
  1
+tinyMCEPopup.requireLangPack();
  2
+
  3
+var charmap = [
  4
+	['Ā',    'Ā',  true, 'A - macron'],
  5
+	['Ē',    'Ē',  true, 'E - macron'],
  6
+	['Ī',    'Ī',  true, 'I - macron'], 
  7
+	['Ō',    'Ō',  true, 'O - macron'], 
  8
+	['Ū',    'Ū',  true, 'U - macron'], 
  9
+	['ā',    'ā',  true, 'a - macron'], 
  10
+	['ē',    'ē',  true, 'e - macron'], 
  11
+	['ī',    'ī',  true, 'i - macron'], 
  12
+	['ō',    'ō',  true, 'o - macron'], 
  13
+	['ū',    'ū',  true, 'u - macron']
  14
+];
  15
+
  16
+tinyMCEPopup.onInit.add(function() {
  17
+	tinyMCEPopup.dom.setHTML('charmapView', renderCharMapHTML());
  18
+});
  19
+
  20
+function renderCharMapHTML() {
  21
+	var charsPerRow = 5, tdWidth=20, tdHeight=20, i;
  22
+	var html = '<table border="0" cellspacing="1" cellpadding="0" width="' + (tdWidth*charsPerRow) + '"><tr height="' + tdHeight + '">';
  23
+	var cols=-1;
  24
+
  25
+	for (i=0; i<charmap.length; i++) {
  26
+		if (charmap[i][2]==true) {
  27
+			cols++;
  28
+			html += ''
  29
+				+ '<td class="charmap">'
  30
+				+ '<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] + '">'
  31
+				+ charmap[i][1]
  32
+				+ '</a></td>';
  33
+			if ((cols+1) % charsPerRow == 0)
  34
+				html += '</tr><tr height="' + tdHeight + '">';
  35
+		}
  36
+	 }
  37
+
  38
+	if (cols % charsPerRow > 0) {
  39
+		var padd = charsPerRow - (cols % charsPerRow);
  40
+		for (var i=0; i<padd-1; i++)
  41
+			html += '<td width="' + tdWidth + '" height="' + tdHeight + '" class="charmap">&nbsp;</td>';
  42
+	}
  43
+
  44
+	html += '</tr></table>';
  45
+
  46
+	return html;
  47
+}
  48
+
  49
+function insertChar(chr) {
  50
+	tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';');
  51
+
  52
+	// Refocus in window
  53
+	if (tinyMCEPopup.isWindow)
  54
+		window.focus();
  55
+
  56
+	tinyMCEPopup.editor.focus();
  57
+	tinyMCEPopup.close();
  58
+}
  59
+
  60
+function previewChar(codeA, codeB, codeN) {
  61
+	var elmV = document.getElementById('codeV');
  62
+	var elmN = document.getElementById('codeN');
  63
+
  64
+	if (codeA=='#160;') {
  65
+		elmV.innerHTML = '__';
  66
+	} else {
  67
+		elmV.innerHTML = '&' + codeA;
  68
+	}
  69
+
  70
+	elmN.innerHTML = codeN;
  71
+}
31  thirdparty/tinymce_ssmacron/macron.htm
... ...
@@ -0,0 +1,31 @@
  1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2
+<html xmlns="http://www.w3.org/1999/xhtml">
  3
+<head>
  4
+	<title>Insert a Macron</title>
  5
+   <script type="text/javascript" src="../tinymce/tiny_mce_popup.js"></script>
  6
+	<script type="text/javascript" src="js/macron.js"></script>
  7
+</head>
  8
+<body id="charmap" style="display:none">
  9
+<table align="center" border="0" cellspacing="0" cellpadding="2">
  10
+    <tr>
  11
+        <td colspan="2" class="title">Insert a Macron</td>
  12
+    </tr>
  13
+    <tr>
  14
+        <td id="charmapView" align="left" valign="top">
  15
+			<!-- Chars will be rendered here -->
  16
+        </td>
  17
+        <td width="100" align="center" valign="top">
  18
+            <table border="0" cellpadding="0" cellspacing="0" width="100" style="height:100px">
  19
+                <tr>
  20
+                    <td id="codeV">&nbsp;</td>
  21
+                </tr>
  22
+                <tr>
  23
+                    <td id="codeN">&nbsp;</td>
  24
+                </tr>
  25
+            </table>
  26
+        </td>
  27
+    </tr>
  28
+</table>
  29
+
  30
+</body>
  31
+</html>

0 notes on commit b4e1552

Please sign in to comment.
Something went wrong with that request. Please try again.