File: example_template.htm

package info (click to toggle)
tinymce2 2.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 3,192 kB
  • ctags: 1,107
  • sloc: makefile: 59; sh: 7
file content (145 lines) | stat: -rw-r--r-- 5,495 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Template plugin example</title>
<!-- TinyMCE -->
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce_dev.js"></script>
<script language="javascript" type="text/javascript">
	function exampleTemplateFunction(elm) {
		elm.innerHTML = prompt("Please enter your favourite colour.", "Color");
	}

	var Invoice = {
		calculate : function(table) {
			var _n = function(s) {
				var n = parseFloat(s.replace(/[^-\d\.]/g,''));
				return isNaN(n) ? 0 : n;
			}

			var total = 0;
			var r = table.tBodies[0].rows;

			for(var x = 0; x < r.length; x++) {
				var c = r[x].cells;
				var t = _n(c[1].innerHTML)*_n(c[2].innerHTML);
				total += t;
				c[3].innerHTML = '$' + t; 
			}

			table.tFoot.rows[0].cells[1].innerHTML = '$' + total;
		}
	}

	var WordCount = {
		getText : function() {
			var inst = tinyMCE.selectedInstance;
			var na = [];
			tinyMCE.getNodeTree(inst.getBody(), na, 3);
			for(var x = 0; x < na.length; x++) {
				if(na[x].nodeValue && na[x].nodeValue.length > 3) {
					na[x] = na[x].nodeValue;
				} else {
					na[x] = '';
				}
			}
			return na.join('');
		},

		count : function(elm) {
			var s = WordCount.getText();
			elm.innerHTML = '' + s.split(' ').length;
		},

		charCount : function(elm) {
			var s = WordCount.getText();
			elm.innerHTML = '' + s.length;
		}
	}

	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		plugins : "devkit,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		theme_advanced_buttons1_add_before : "save,newdocument,separator",
		theme_advanced_buttons1_add : "fontselect,fontsizeselect",
		theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor,advsearchreplace",
		theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
		theme_advanced_buttons3_add_before : "tablecontrols,separator",
		theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,|,visualchars,nonbreaking,|,template,|,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "bottom",
		content_css : "example_full.css",
	    plugin_insertdate_dateFormat : "%Y-%m-%d",
	    plugin_insertdate_timeFormat : "%H:%M:%S",
		extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style|title|tsrc],*[mcetmpldtesrc]",
		external_link_list_url : "example_link_list.js",
		external_image_list_url : "example_image_list.js",
		flash_external_list_url : "example_flash_list.js",
		media_external_list_url : "example_media_list.js",
		file_browser_callback : "fileBrowserCallBack",
		theme_advanced_resize_horizontal : false,
		theme_advanced_resizing : true,
		nonbreaking_force_tab : true,
		apply_source_formatting : true,
		template_cdate_classes : "cdate creationdate",
		template_mdate_classes : "mdate somedate",
		template_selected_content_classes : "selcontent",
		template_cdate_format : "%m/%d/%Y : %H:%M:%S",
		template_mdate_format : "%m/%d/%Y : %H:%M:%S",
		template_replace_values : {
			username : "Andrew Tetlaw",
			"invoice-items" : Invoice.calculate,
			"word-count" : WordCount.count,
			"char-count" : WordCount.charCount
		},
		template_templates : [
			{
				title : 'Editing Details',
				src : 'templates/editing_details.htm',
				description : "Timestamps, editor's name and a comment area"
			},
			{
				title : 'Invoice Template',
				src : 'templates/invoice.htm',
				description : 'Fill in the rows and the totals are calculated automatically'
			},
			{
				title : 'Word Count',
				src : 'templates/count.htm',
				description : 'Word count for editor content'
			},
			{
				title : 'Editors Comment',
				src : 'templates/editors_comment.htm',
				description : 'Add a comment about the selected text'
			}
		]
	});
	

</script>
<!-- /TinyMCE -->
</head>
<body>

<a href="example_full.htm">[Full featured example]</a> <a href="example_advanced.htm">[Advanced example]</a> <a href="example_simple.htm">[Simple example]</a>  <a href="example_word.htm">[Word example]</a>
<form method="get" action="">
	<h3>Template example</h3>
	This example shows how to make more advanced templates that execute logic.<br /><br />
	<textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 100%">
		&lt;span class=&quot;example1&quot;&gt;Test header 1&lt;/span&gt;&lt;br /&gt;
		&lt;span class=&quot;example2&quot;&gt;Test header 2&lt;/span&gt;&lt;br /&gt;
		&lt;span class=&quot;example3&quot;&gt;Test header 3&lt;/span&gt;&lt;br /&gt;
		Some &lt;b&gt;element&lt;/b&gt;, this is to be editor 1. &lt;br /&gt; This editor instance has a 100% width to it.
		&lt;p&gt;Some paragraph. &lt;a href=&quot;http://www.sourceforge.net&quot;&gt;Some link&lt;/a&gt;&lt;/p&gt;
		&lt;img src=&quot;logo.jpg&quot;&gt;
	</textarea>
	<br />
	<input type="submit" name="save" value="Submit" />
	<input type="reset" name="reset" value="Reset" />
</form>

</body>
</html>