tinymce/3rdparty/themes/advanced/js/source_editor.js
author Dan Fuhry <dan@enanocms.org>
Thu, 02 Jun 2011 06:24:03 -0400
changeset 0 c78d206bf01c
permissions -rw-r--r--
First commit... it works I guess
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     1
tinyMCEPopup.requireLangPack();
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     2
tinyMCEPopup.onInit.add(onLoadInit);
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     3
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     4
function saveContent() {
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     5
	tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value, {source_view : true});
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     6
	tinyMCEPopup.close();
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     7
}
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     8
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
     9
function onLoadInit() {
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    10
	tinyMCEPopup.resizeToInnerSize();
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    11
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    12
	// Remove Gecko spellchecking
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    13
	if (tinymce.isGecko)
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    14
		document.body.spellcheck = tinyMCEPopup.editor.getParam("gecko_spellcheck");
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    15
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    16
	document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent({source_view : true});
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    17
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    18
	if (tinyMCEPopup.editor.getParam("theme_advanced_source_editor_wrap", true)) {
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    19
		setWrap('soft');
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    20
		document.getElementById('wraped').checked = true;
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    21
	}
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    22
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    23
	resizeInputs();
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    24
}
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    25
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    26
function setWrap(val) {
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    27
	var v, n, s = document.getElementById('htmlSource');
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    28
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    29
	s.wrap = val;
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    30
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    31
	if (!tinymce.isIE) {
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    32
		v = s.value;
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    33
		n = s.cloneNode(false);
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    34
		n.setAttribute("wrap", val);
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    35
		s.parentNode.replaceChild(n, s);
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    36
		n.value = v;
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    37
	}
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    38
}
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    39
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    40
function toggleWordWrap(elm) {
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    41
	if (elm.checked)
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    42
		setWrap('soft');
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    43
	else
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    44
		setWrap('off');
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    45
}
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    46
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    47
var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    48
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    49
function resizeInputs() {
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    50
	var el = document.getElementById('htmlSource');
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    51
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    52
	if (!tinymce.isIE) {
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    53
		 wHeight = self.innerHeight - 65;
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    54
		 wWidth = self.innerWidth - 16;
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    55
	} else {
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    56
		 wHeight = document.body.clientHeight - 70;
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    57
		 wWidth = document.body.clientWidth - 16;
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    58
	}
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    59
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    60
	el.style.height = Math.abs(wHeight) + 'px';
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    61
	el.style.width  = Math.abs(wWidth) + 'px';
c78d206bf01c First commit... it works I guess
Dan Fuhry <dan@enanocms.org>
parents:
diff changeset
    62
}