Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/mybp1/js/tinymce/tests/
Upload File :
Current File : /var/www/html/mmishra/mybp1/js/tinymce/tests/formatting_check.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Unit tests for check formatting</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="qunit/qunit.js"></script>
<script type="text/javascript" src="qunit/runner.js"></script>
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script>
var editor;

QUnit.config.autostart = false;
module("Check formatting", {
	autostart: false
});

function getContent() {
	return editor.getContent().toLowerCase().replace(/[\r\n]+/g, '');
};

test('Formatter - match', function() {
	var rng;

	expect(11);

	// Selected style element text
	editor.formatter.register('bold', {inline : 'b'});
	editor.getBody().innerHTML = '<p><b>1234</b></p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('b')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('b')[0].firstChild, 4);
	editor.selection.setRng(rng);
	ok(editor.formatter.match('bold'), 'Selected style element text');

	// Selected style element with css styles
	editor.formatter.register('color', {inline : 'span', styles : {color : '#ff0000'}});
	editor.getBody().innerHTML = '<p><span style="color:#ff0000">1234</span></p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('span')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('span')[0].firstChild, 4);
	editor.selection.setRng(rng);
	ok(editor.formatter.match('color'), 'Selected style element with css styles');

	// Selected style element with attributes
	editor.formatter.register('fontsize', {inline : 'font', attributes : {size : '7'}});
	editor.getBody().innerHTML = '<p><font size="7">1234</font></p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('font')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('font')[0].firstChild, 4);
	editor.selection.setRng(rng);
	ok(editor.formatter.match('fontsize'), 'Selected style element with attributes');

	// Selected style element text multiple formats
	editor.formatter.register('multiple', [
		{inline : 'b'},
		{inline : 'strong'}
	]);
	editor.getBody().innerHTML = '<p><strong>1234</strong></p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('strong')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('strong')[0].firstChild, 4);
	editor.selection.setRng(rng);
	ok(editor.formatter.match('multiple'), 'Selected style element text multiple formats');

	// Selected complex style element
	editor.formatter.register('complex', {inline : 'span', styles : {fontWeight : 'bold'}});
	editor.getBody().innerHTML = '<p><span style="color:#ff0000; font-weight:bold">1234</span></p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('span')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('span')[0].firstChild, 4);
	editor.selection.setRng(rng);
	ok(editor.formatter.match('complex'), 'Selected complex style element');

	// Selected non style element text
	editor.formatter.register('bold', {inline : 'b'});
	editor.getBody().innerHTML = '<p>1234</p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('p')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('p')[0].firstChild, 4);
	editor.selection.setRng(rng);
	ok(!editor.formatter.match('bold'), 'Selected non style element text');

	// Selected partial style element (start)
	editor.formatter.register('bold', {inline : 'b'});
	editor.getBody().innerHTML = '<p><b>1234</b>5678</p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('b')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('p')[0].lastChild, 4);
	editor.selection.setRng(rng);
	ok(editor.formatter.match('bold'), 'Selected partial style element (start)');

	// Selected partial style element (end)
	editor.formatter.register('bold', {inline : 'b'});
	editor.getBody().innerHTML = '<p>1234<b>5678</b></p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('p')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('b')[0].lastChild, 4);
	editor.selection.setRng(rng);
	ok(!editor.formatter.match('bold'), 'Selected partial style element (end)');

	// Selected element text with parent inline element
	editor.formatter.register('bold', {inline : 'b'});
	editor.getBody().innerHTML = '<p><b><em><span>1234</span></em></b></p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('span')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('span')[0].firstChild, 4);
	editor.selection.setRng(rng);
	ok(editor.formatter.match('bold'), 'Selected element text with parent inline element');

	// Selected element match with variable
	editor.formatter.register('complex', {inline : 'span', styles : {color : '%color'}});
	editor.getBody().innerHTML = '<p><span style="color:#ff0000">1234</span></p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('span')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('span')[0].firstChild, 4);
	editor.selection.setRng(rng);
	ok(editor.formatter.match('complex', {color : '#ff0000'}), 'Selected element match with variable');

	// Selected element match with variable and function
	editor.formatter.register('complex', {
		inline : 'span',
		styles : {
			color : function(vars) {
				return vars.color + '00';
			}
		}
	});
	editor.getBody().innerHTML = '<p><span style="color:#ff0000">1234</span></p>';
	rng = editor.dom.createRng();
	rng.setStart(editor.dom.select('span')[0].firstChild, 0);
	rng.setEnd(editor.dom.select('span')[0].firstChild, 4);
	editor.selection.setRng(rng);
	ok(editor.formatter.match('complex', {color : '#ff00'}), 'Selected element match with variable and function');
});

tinyMCE.init({
	mode : "exact",
	elements : "elm1",
	theme : "advanced",
	add_unload_trigger : false,
	theme_advanced_styles : 'test1=test1;test2=test2',
	valid_elements : '@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong,b,em,i,strike,u,#p,-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big',
	apply_source_formatting : 0,
	fix_list_elements : 0,
	fix_table_elements : 0,
	entities : 'raw',
	valid_styles : {
		'*' : 'color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display'
	},
	init_instance_callback : function(ed) {
		editor = ed;

		ed.onNodeChange.addToTop(function() {
			return false;
		});

		QUnit.start();
	}
});
</script>
</head>
<body>
	<h1 id="qunit-header">Unit tests for text formatting</h1>
	<h2 id="qunit-banner"></h2>
	<div id="qunit-testrunner-toolbar"></div>
	<h2 id="qunit-userAgent"></h2>
	<ol id="qunit-tests"></ol>
	<textarea id="elm1" name="elm1"></textarea>
	<div>
		<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
		<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
	</div>
</body>
</html>