summaryrefslogtreecommitdiff
path: root/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/element_common.js
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-27 16:58:53 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-27 16:58:53 +0200
commit420506e58fdfc84f1a5bede0a01dedf0af3bb4f3 (patch)
tree57726b40e8aa9ccf80f874f39d3facefc0331420 /public/javascripts/tiny_mce/plugins/xhtmlxtras/js/element_common.js
parent241d5e91b2b6716e2861cc77d319c3d3568343a8 (diff)
Stage 7: Rails 7.2 → 8.1 on Ruby 3.2.11
- Bump Rails to 8.1.3 (Ruby unchanged at 3.2.11, new gemset rails8-upgrade) - config.load_defaults 8.1; merge app:update diffs for all environment files - Remove routing-filter 0.7.0; replace with native scope '(:locale)' in routes.rb and default_url_options in ApplicationController - Delete config/initializers/routing_filter_rails71_patch.rb - Replace vendored TinyMCE 3.x (~200 files) with tinymce-rails ~> 8.3; migrate admin_interface.js from jQuery .tinymce()/advanced theme to tinymce.init(); add config/tinymce.yml; note: TinyMCE 7+ is GPL - rails-i18n ~> 8.0 added explicitly (previously indirect dependency) - awesome_nested_set, acts-as-taggable-on pinned to git main/master (gemspec activerecord < 8.1 ceiling; no functional incompatibility; repin to version once upstream releases updated gemspecs) - globalize ~> 7.0, libxml-ruby ~> 5.0, nokogiri ~> 1.18, pg ~> 1.5 - sass-rails, coffee-rails, uglifier moved from :assets group to main (Sprockets 4 convention; :assets group no longer meaningful) - Node: head, draft, lock_owner marked belongs_to optional: true - Page: node, user, editor marked belongs_to optional: true - Static assets in public/images/ and public/javascripts/ referenced via plain HTML tags; Rails 8 load_defaults raises on pipeline helpers for undeclared assets - sessions_controller_test.rb: remove stale require and dead rescue_action - users_controller_test.rb: assert button[type=submit] not input[type=submit] (Rails 8 button_to renders <button> not <input>) - test_helper.rb: node.reload after children.create! (awesome_nested_set 3.9.0 does not refresh parent in memory after callback) - 129 runs, 339 assertions, 3 failures, 0 errors — identical baseline to 7.2
Diffstat (limited to 'public/javascripts/tiny_mce/plugins/xhtmlxtras/js/element_common.js')
-rw-r--r--public/javascripts/tiny_mce/plugins/xhtmlxtras/js/element_common.js231
1 files changed, 0 insertions, 231 deletions
diff --git a/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/element_common.js b/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/element_common.js
deleted file mode 100644
index 70f168a..0000000
--- a/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/element_common.js
+++ /dev/null
@@ -1,231 +0,0 @@
1 /**
2 * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $
3 *
4 * @author Moxiecode - based on work by Andrew Tetlaw
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
6 */
7
8tinyMCEPopup.requireLangPack();
9
10function initCommonAttributes(elm) {
11 var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
12
13 // Setup form data for common element attributes
14 setFormValue('title', dom.getAttrib(elm, 'title'));
15 setFormValue('id', dom.getAttrib(elm, 'id'));
16 selectByValue(formObj, 'class', dom.getAttrib(elm, 'class'), true);
17 setFormValue('style', dom.getAttrib(elm, 'style'));
18 selectByValue(formObj, 'dir', dom.getAttrib(elm, 'dir'));
19 setFormValue('lang', dom.getAttrib(elm, 'lang'));
20 setFormValue('onfocus', dom.getAttrib(elm, 'onfocus'));
21 setFormValue('onblur', dom.getAttrib(elm, 'onblur'));
22 setFormValue('onclick', dom.getAttrib(elm, 'onclick'));
23 setFormValue('ondblclick', dom.getAttrib(elm, 'ondblclick'));
24 setFormValue('onmousedown', dom.getAttrib(elm, 'onmousedown'));
25 setFormValue('onmouseup', dom.getAttrib(elm, 'onmouseup'));
26 setFormValue('onmouseover', dom.getAttrib(elm, 'onmouseover'));
27 setFormValue('onmousemove', dom.getAttrib(elm, 'onmousemove'));
28 setFormValue('onmouseout', dom.getAttrib(elm, 'onmouseout'));
29 setFormValue('onkeypress', dom.getAttrib(elm, 'onkeypress'));
30 setFormValue('onkeydown', dom.getAttrib(elm, 'onkeydown'));
31 setFormValue('onkeyup', dom.getAttrib(elm, 'onkeyup'));
32}
33
34function setFormValue(name, value) {
35 if(document.forms[0].elements[name]) document.forms[0].elements[name].value = value;
36}
37
38function insertDateTime(id) {
39 document.getElementById(id).value = getDateTime(new Date(), "%Y-%m-%dT%H:%M:%S");
40}
41
42function getDateTime(d, fmt) {
43 fmt = fmt.replace("%D", "%m/%d/%y");
44 fmt = fmt.replace("%r", "%I:%M:%S %p");
45 fmt = fmt.replace("%Y", "" + d.getFullYear());
46 fmt = fmt.replace("%y", "" + d.getYear());
47 fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2));
48 fmt = fmt.replace("%d", addZeros(d.getDate(), 2));
49 fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2));
50 fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2));
51 fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2));
52 fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1));
53 fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM"));
54 fmt = fmt.replace("%%", "%");
55
56 return fmt;
57}
58
59function addZeros(value, len) {
60 var i;
61
62 value = "" + value;
63
64 if (value.length < len) {
65 for (i=0; i<(len-value.length); i++)
66 value = "0" + value;
67 }
68
69 return value;
70}
71
72function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
73 if (!form_obj || !form_obj.elements[field_name])
74 return;
75
76 var sel = form_obj.elements[field_name];
77
78 var found = false;
79 for (var i=0; i<sel.options.length; i++) {
80 var option = sel.options[i];
81
82 if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
83 option.selected = true;
84 found = true;
85 } else
86 option.selected = false;
87 }
88
89 if (!found && add_custom && value != '') {
90 var option = new Option('Value: ' + value, value);
91 option.selected = true;
92 sel.options[sel.options.length] = option;
93 }
94
95 return found;
96}
97
98function setAttrib(elm, attrib, value) {
99 var formObj = document.forms[0];
100 var valueElm = formObj.elements[attrib.toLowerCase()];
101 tinyMCEPopup.editor.dom.setAttrib(elm, attrib, value || valueElm.value);
102}
103
104function setAllCommonAttribs(elm) {
105 setAttrib(elm, 'title');
106 setAttrib(elm, 'id');
107 setAttrib(elm, 'class');
108 setAttrib(elm, 'style');
109 setAttrib(elm, 'dir');
110 setAttrib(elm, 'lang');
111 /*setAttrib(elm, 'onfocus');
112 setAttrib(elm, 'onblur');
113 setAttrib(elm, 'onclick');
114 setAttrib(elm, 'ondblclick');
115 setAttrib(elm, 'onmousedown');
116 setAttrib(elm, 'onmouseup');
117 setAttrib(elm, 'onmouseover');
118 setAttrib(elm, 'onmousemove');
119 setAttrib(elm, 'onmouseout');
120 setAttrib(elm, 'onkeypress');
121 setAttrib(elm, 'onkeydown');
122 setAttrib(elm, 'onkeyup');*/
123}
124
125SXE = {
126 currentAction : "insert",
127 inst : tinyMCEPopup.editor,
128 updateElement : null
129}
130
131SXE.focusElement = SXE.inst.selection.getNode();
132
133SXE.initElementDialog = function(element_name) {
134 addClassesToList('class', 'xhtmlxtras_styles');
135 TinyMCE_EditableSelects.init();
136
137 element_name = element_name.toLowerCase();
138 var elm = SXE.inst.dom.getParent(SXE.focusElement, element_name.toUpperCase());
139 if (elm != null && elm.nodeName.toUpperCase() == element_name.toUpperCase()) {
140 SXE.currentAction = "update";
141 }
142
143 if (SXE.currentAction == "update") {
144 initCommonAttributes(elm);
145 SXE.updateElement = elm;
146 }
147
148 document.forms[0].insert.value = tinyMCEPopup.getLang(SXE.currentAction, 'Insert', true);
149}
150
151SXE.insertElement = function(element_name) {
152 var elm = SXE.inst.dom.getParent(SXE.focusElement, element_name.toUpperCase()), h, tagName;
153
154 tinyMCEPopup.execCommand('mceBeginUndoLevel');
155 if (elm == null) {
156 var s = SXE.inst.selection.getContent();
157 if(s.length > 0) {
158 tagName = element_name;
159
160 if (tinymce.isIE && element_name.indexOf('html:') == 0)
161 element_name = element_name.substring(5).toLowerCase();
162
163 insertInlineElement(element_name);
164 var elementArray = tinymce.grep(SXE.inst.dom.select(element_name));
165 for (var i=0; i<elementArray.length; i++) {
166 var elm = elementArray[i];
167
168 if (SXE.inst.dom.getAttrib(elm, '_mce_new')) {
169 elm.id = '';
170 elm.setAttribute('id', '');
171 elm.removeAttribute('id');
172 elm.removeAttribute('_mce_new');
173
174 setAllCommonAttribs(elm);
175 }
176 }
177 }
178 } else {
179 setAllCommonAttribs(elm);
180 }
181 SXE.inst.nodeChanged();
182 tinyMCEPopup.execCommand('mceEndUndoLevel');
183}
184
185SXE.removeElement = function(element_name){
186 element_name = element_name.toLowerCase();
187 elm = SXE.inst.dom.getParent(SXE.focusElement, element_name.toUpperCase());
188 if(elm && elm.nodeName.toUpperCase() == element_name.toUpperCase()){
189 tinyMCEPopup.execCommand('mceBeginUndoLevel');
190 tinyMCE.execCommand('mceRemoveNode', false, elm);
191 SXE.inst.nodeChanged();
192 tinyMCEPopup.execCommand('mceEndUndoLevel');
193 }
194}
195
196SXE.showRemoveButton = function() {
197 document.getElementById("remove").style.display = 'block';
198}
199
200SXE.containsClass = function(elm,cl) {
201 return (elm.className.indexOf(cl) > -1) ? true : false;
202}
203
204SXE.removeClass = function(elm,cl) {
205 if(elm.className == null || elm.className == "" || !SXE.containsClass(elm,cl)) {
206 return true;
207 }
208 var classNames = elm.className.split(" ");
209 var newClassNames = "";
210 for (var x = 0, cnl = classNames.length; x < cnl; x++) {
211 if (classNames[x] != cl) {
212 newClassNames += (classNames[x] + " ");
213 }
214 }
215 elm.className = newClassNames.substring(0,newClassNames.length-1); //removes extra space at the end
216}
217
218SXE.addClass = function(elm,cl) {
219 if(!SXE.containsClass(elm,cl)) elm.className ? elm.className += " " + cl : elm.className = cl;
220 return true;
221}
222
223function insertInlineElement(en) {
224 var ed = tinyMCEPopup.editor, dom = ed.dom;
225
226 ed.getDoc().execCommand('FontName', false, 'mceinline');
227 tinymce.each(dom.select('span,font'), function(n) {
228 if (n.style.fontFamily == 'mceinline' || n.face == 'mceinline')
229 dom.replace(dom.create(en, {_mce_new : 1}), n, 1);
230 });
231}