]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/tiny_mce/plugins/xhtmlxtras/js/attributes.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / tiny_mce / plugins / xhtmlxtras / js / attributes.js
1 /**
2  * attributes.js
3  *
4  * Copyright 2009, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://tinymce.moxiecode.com/license
8  * Contributing: http://tinymce.moxiecode.com/contributing
9  */
10
11 function init() {
12         tinyMCEPopup.resizeToInnerSize();
13         var inst = tinyMCEPopup.editor;
14         var dom = inst.dom;
15         var elm = inst.selection.getNode();
16         var f = document.forms[0];
17         var onclick = dom.getAttrib(elm, 'onclick');
18
19         setFormValue('title', dom.getAttrib(elm, 'title'));
20         setFormValue('id', dom.getAttrib(elm, 'id'));
21         setFormValue('style', dom.getAttrib(elm, "style"));
22         setFormValue('dir', dom.getAttrib(elm, 'dir'));
23         setFormValue('lang', dom.getAttrib(elm, 'lang'));
24         setFormValue('tabindex', dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : ""));
25         setFormValue('accesskey', dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : ""));
26         setFormValue('onfocus', dom.getAttrib(elm, 'onfocus'));
27         setFormValue('onblur', dom.getAttrib(elm, 'onblur'));
28         setFormValue('onclick', onclick);
29         setFormValue('ondblclick', dom.getAttrib(elm, 'ondblclick'));
30         setFormValue('onmousedown', dom.getAttrib(elm, 'onmousedown'));
31         setFormValue('onmouseup', dom.getAttrib(elm, 'onmouseup'));
32         setFormValue('onmouseover', dom.getAttrib(elm, 'onmouseover'));
33         setFormValue('onmousemove', dom.getAttrib(elm, 'onmousemove'));
34         setFormValue('onmouseout', dom.getAttrib(elm, 'onmouseout'));
35         setFormValue('onkeypress', dom.getAttrib(elm, 'onkeypress'));
36         setFormValue('onkeydown', dom.getAttrib(elm, 'onkeydown'));
37         setFormValue('onkeyup', dom.getAttrib(elm, 'onkeyup'));
38         className = dom.getAttrib(elm, 'class');
39
40         addClassesToList('classlist', 'advlink_styles');
41         selectByValue(f, 'classlist', className, true);
42
43         TinyMCE_EditableSelects.init();
44 }
45
46 function setFormValue(name, value) {
47         if(value && document.forms[0].elements[name]){
48                 document.forms[0].elements[name].value = value;
49         }
50 }
51
52 function insertAction() {
53         var inst = tinyMCEPopup.editor;
54         var elm = inst.selection.getNode();
55
56         setAllAttribs(elm);
57         tinyMCEPopup.execCommand("mceEndUndoLevel");
58         tinyMCEPopup.close();
59 }
60
61 function setAttrib(elm, attrib, value) {
62         var formObj = document.forms[0];
63         var valueElm = formObj.elements[attrib.toLowerCase()];
64         var inst = tinyMCEPopup.editor;
65         var dom = inst.dom;
66
67         if (typeof(value) == "undefined" || value == null) {
68                 value = "";
69
70                 if (valueElm)
71                         value = valueElm.value;
72         }
73
74         dom.setAttrib(elm, attrib.toLowerCase(), value);
75 }
76
77 function setAllAttribs(elm) {
78         var f = document.forms[0];
79
80         setAttrib(elm, 'title');
81         setAttrib(elm, 'id');
82         setAttrib(elm, 'style');
83         setAttrib(elm, 'class', getSelectValue(f, 'classlist'));
84         setAttrib(elm, 'dir');
85         setAttrib(elm, 'lang');
86         setAttrib(elm, 'tabindex');
87         setAttrib(elm, 'accesskey');
88         setAttrib(elm, 'onfocus');
89         setAttrib(elm, 'onblur');
90         setAttrib(elm, 'onclick');
91         setAttrib(elm, 'ondblclick');
92         setAttrib(elm, 'onmousedown');
93         setAttrib(elm, 'onmouseup');
94         setAttrib(elm, 'onmouseover');
95         setAttrib(elm, 'onmousemove');
96         setAttrib(elm, 'onmouseout');
97         setAttrib(elm, 'onkeypress');
98         setAttrib(elm, 'onkeydown');
99         setAttrib(elm, 'onkeyup');
100
101         // Refresh in old MSIE
102 //      if (tinyMCE.isMSIE5)
103 //              elm.outerHTML = elm.outerHTML;
104 }
105
106 function insertAttribute() {
107         tinyMCEPopup.close();
108 }
109
110 tinyMCEPopup.onInit.add(init);
111 tinyMCEPopup.requireLangPack();