web/wp-includes/js/tinymce/plugins/directionality/editor_plugin_src.js
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    13 		init : function(ed, url) {
    13 		init : function(ed, url) {
    14 			var t = this;
    14 			var t = this;
    15 
    15 
    16 			t.editor = ed;
    16 			t.editor = ed;
    17 
    17 
       
    18 			function setDir(dir) {
       
    19 				var dom = ed.dom, curDir, blocks = ed.selection.getSelectedBlocks();
       
    20 
       
    21 				if (blocks.length) {
       
    22 					curDir = dom.getAttrib(blocks[0], "dir");
       
    23 
       
    24 					tinymce.each(blocks, function(block) {
       
    25 						// Add dir to block if the parent block doesn't already have that dir
       
    26 						if (!dom.getParent(block.parentNode, "*[dir='" + dir + "']", dom.getRoot())) {
       
    27 							if (curDir != dir) {
       
    28 								dom.setAttrib(block, "dir", dir);
       
    29 							} else {
       
    30 								dom.setAttrib(block, "dir", null);
       
    31 							}
       
    32 						}
       
    33 					});
       
    34 
       
    35 					ed.nodeChanged();
       
    36 				}
       
    37 			}
       
    38 
    18 			ed.addCommand('mceDirectionLTR', function() {
    39 			ed.addCommand('mceDirectionLTR', function() {
    19 				var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);
    40 				setDir("ltr");
    20 
       
    21 				if (e) {
       
    22 					if (ed.dom.getAttrib(e, "dir") != "ltr")
       
    23 						ed.dom.setAttrib(e, "dir", "ltr");
       
    24 					else
       
    25 						ed.dom.setAttrib(e, "dir", "");
       
    26 				}
       
    27 
       
    28 				ed.nodeChanged();
       
    29 			});
    41 			});
    30 
    42 
    31 			ed.addCommand('mceDirectionRTL', function() {
    43 			ed.addCommand('mceDirectionRTL', function() {
    32 				var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);
    44 				setDir("rtl");
    33 
       
    34 				if (e) {
       
    35 					if (ed.dom.getAttrib(e, "dir") != "rtl")
       
    36 						ed.dom.setAttrib(e, "dir", "rtl");
       
    37 					else
       
    38 						ed.dom.setAttrib(e, "dir", "");
       
    39 				}
       
    40 
       
    41 				ed.nodeChanged();
       
    42 			});
    45 			});
    43 
    46 
    44 			ed.addButton('ltr', {title : 'directionality.ltr_desc', cmd : 'mceDirectionLTR'});
    47 			ed.addButton('ltr', {title : 'directionality.ltr_desc', cmd : 'mceDirectionLTR'});
    45 			ed.addButton('rtl', {title : 'directionality.rtl_desc', cmd : 'mceDirectionRTL'});
    48 			ed.addButton('rtl', {title : 'directionality.rtl_desc', cmd : 'mceDirectionRTL'});
    46 
    49