bgneal@312: /** bgneal@312: * attributes.js bgneal@312: * bgneal@312: * Copyright 2009, Moxiecode Systems AB bgneal@312: * Released under LGPL License. bgneal@312: * bgneal@312: * License: http://tinymce.moxiecode.com/license bgneal@312: * Contributing: http://tinymce.moxiecode.com/contributing bgneal@312: */ bgneal@312: bgneal@312: function init() { bgneal@312: tinyMCEPopup.resizeToInnerSize(); bgneal@312: var inst = tinyMCEPopup.editor; bgneal@312: var dom = inst.dom; bgneal@312: var elm = inst.selection.getNode(); bgneal@312: var f = document.forms[0]; bgneal@312: var onclick = dom.getAttrib(elm, 'onclick'); bgneal@312: bgneal@312: setFormValue('title', dom.getAttrib(elm, 'title')); bgneal@312: setFormValue('id', dom.getAttrib(elm, 'id')); bgneal@312: setFormValue('style', dom.getAttrib(elm, "style")); bgneal@312: setFormValue('dir', dom.getAttrib(elm, 'dir')); bgneal@312: setFormValue('lang', dom.getAttrib(elm, 'lang')); bgneal@312: setFormValue('tabindex', dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : "")); bgneal@312: setFormValue('accesskey', dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : "")); bgneal@312: setFormValue('onfocus', dom.getAttrib(elm, 'onfocus')); bgneal@312: setFormValue('onblur', dom.getAttrib(elm, 'onblur')); bgneal@312: setFormValue('onclick', onclick); bgneal@312: setFormValue('ondblclick', dom.getAttrib(elm, 'ondblclick')); bgneal@312: setFormValue('onmousedown', dom.getAttrib(elm, 'onmousedown')); bgneal@312: setFormValue('onmouseup', dom.getAttrib(elm, 'onmouseup')); bgneal@312: setFormValue('onmouseover', dom.getAttrib(elm, 'onmouseover')); bgneal@312: setFormValue('onmousemove', dom.getAttrib(elm, 'onmousemove')); bgneal@312: setFormValue('onmouseout', dom.getAttrib(elm, 'onmouseout')); bgneal@312: setFormValue('onkeypress', dom.getAttrib(elm, 'onkeypress')); bgneal@312: setFormValue('onkeydown', dom.getAttrib(elm, 'onkeydown')); bgneal@312: setFormValue('onkeyup', dom.getAttrib(elm, 'onkeyup')); bgneal@312: className = dom.getAttrib(elm, 'class'); bgneal@312: bgneal@312: addClassesToList('classlist', 'advlink_styles'); bgneal@312: selectByValue(f, 'classlist', className, true); bgneal@312: bgneal@312: TinyMCE_EditableSelects.init(); bgneal@312: } bgneal@312: bgneal@312: function setFormValue(name, value) { bgneal@312: if(value && document.forms[0].elements[name]){ bgneal@312: document.forms[0].elements[name].value = value; bgneal@312: } bgneal@312: } bgneal@312: bgneal@312: function insertAction() { bgneal@312: var inst = tinyMCEPopup.editor; bgneal@312: var elm = inst.selection.getNode(); bgneal@312: bgneal@312: setAllAttribs(elm); bgneal@312: tinyMCEPopup.execCommand("mceEndUndoLevel"); bgneal@312: tinyMCEPopup.close(); bgneal@312: } bgneal@312: bgneal@312: function setAttrib(elm, attrib, value) { bgneal@312: var formObj = document.forms[0]; bgneal@312: var valueElm = formObj.elements[attrib.toLowerCase()]; bgneal@312: var inst = tinyMCEPopup.editor; bgneal@312: var dom = inst.dom; bgneal@312: bgneal@312: if (typeof(value) == "undefined" || value == null) { bgneal@312: value = ""; bgneal@312: bgneal@312: if (valueElm) bgneal@312: value = valueElm.value; bgneal@312: } bgneal@312: bgneal@442: dom.setAttrib(elm, attrib.toLowerCase(), value); bgneal@312: } bgneal@312: bgneal@312: function setAllAttribs(elm) { bgneal@312: var f = document.forms[0]; bgneal@312: bgneal@312: setAttrib(elm, 'title'); bgneal@312: setAttrib(elm, 'id'); bgneal@312: setAttrib(elm, 'style'); bgneal@312: setAttrib(elm, 'class', getSelectValue(f, 'classlist')); bgneal@312: setAttrib(elm, 'dir'); bgneal@312: setAttrib(elm, 'lang'); bgneal@312: setAttrib(elm, 'tabindex'); bgneal@312: setAttrib(elm, 'accesskey'); bgneal@312: setAttrib(elm, 'onfocus'); bgneal@312: setAttrib(elm, 'onblur'); bgneal@312: setAttrib(elm, 'onclick'); bgneal@312: setAttrib(elm, 'ondblclick'); bgneal@312: setAttrib(elm, 'onmousedown'); bgneal@312: setAttrib(elm, 'onmouseup'); bgneal@312: setAttrib(elm, 'onmouseover'); bgneal@312: setAttrib(elm, 'onmousemove'); bgneal@312: setAttrib(elm, 'onmouseout'); bgneal@312: setAttrib(elm, 'onkeypress'); bgneal@312: setAttrib(elm, 'onkeydown'); bgneal@312: setAttrib(elm, 'onkeyup'); bgneal@312: bgneal@312: // Refresh in old MSIE bgneal@312: // if (tinyMCE.isMSIE5) bgneal@312: // elm.outerHTML = elm.outerHTML; bgneal@312: } bgneal@312: bgneal@312: function insertAttribute() { bgneal@312: tinyMCEPopup.close(); bgneal@312: } bgneal@312: bgneal@312: tinyMCEPopup.onInit.add(init); bgneal@312: tinyMCEPopup.requireLangPack();