Ticket #5674: tiny_mce-3.0_RC2

File tiny_mce-3.0_RC2, 6.5 kB (added by azaozz, 8 months ago)

TinyMCE-3.0_RC2

Line 
1 Index: tiny_mce.js
2 ===================================================================
3 --- tiny_mce.js (revision 6633)
4 +++ tiny_mce.js (working copy)
5 @@ -4,7 +4,7 @@
6  var tinymce = {
7         majorVersion : '3',
8         minorVersion : '0rc2',
9 -       releaseDate : '2008-01-xx',
10 +       releaseDate : '2008-01-18',
11  
12         _init : function() {
13                 var t = this, ua = navigator.userAgent, i, nl, n, base;
14 @@ -919,7 +919,8 @@
15  
16                         this.settings = s = tinymce.extend({
17                                 keep_values : false,
18 -                               hex_colors : 1
19 +                               hex_colors : 1,
20 +                               process_html : 1
21                         }, s);
22  
23                         // Fix IE6SP2 flicker and check it failed for pre SP2
24 @@ -1203,7 +1204,7 @@
25                                         if (h.nodeType)
26                                                 e.appendChild(h);
27                                         else
28 -                                               e.innerHTML = h;
29 +                                               t.setHTML(e, h);
30                                 }
31  
32                                 return !c ? p.appendChild(e) : e;
33 @@ -1498,7 +1499,7 @@
34                 },
35  
36                 getPos : function(n) {
37 -                       var t = this, x = 0, y = 0, e, d = t.doc;
38 +                       var t = this, x = 0, y = 0, e, d = t.doc, r;
39  
40                         n = t.get(n);
41  
42 @@ -1513,14 +1514,25 @@
43                                 return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x};
44                         }
45  
46 -                       while (n) {
47 -                               x += n.offsetLeft || 0;
48 -                               y += n.offsetTop || 0;
49 -                               x -= n.scrollLeft || 0;
50 -                               y -= n.scrollTop || 0;
51 -                               n = n.offsetParent;
52 +                       r = n;
53 +                       while (r) {
54 +                               x += r.offsetLeft || 0;
55 +                               y += r.offsetTop || 0;
56 +
57 +                               r = r.offsetParent;
58                         }
59  
60 +                       r = n;
61 +                       while (r) {
62 +                               x -= r.scrollLeft || 0;
63 +                               y -= r.scrollTop || 0;
64 +
65 +                               r = r.parentNode;
66 +
67 +                               if (r == d.body)
68 +                                       break;
69 +                       }
70 +
71                         return {x : x, y : y};
72                 },
73  
74 @@ -1722,13 +1734,28 @@
75                         var t = this;
76  
77                         return this.run(e, function(e) {
78 -                               var r;
79 +                               var x;
80  
81                                 h = t.processHTML(h);
82  
83                                 if (isIE) {
84 -                                       e.innerHTML = '<br />' + h;
85 -                                       e.removeChild(e.firstChild);
86 +                                       try {
87 +                                               // IE will remove comments from the beginning
88 +                                               // unless you padd the contents with something
89 +                                               e.innerHTML = '<br />' + h;
90 +                                               e.removeChild(e.firstChild);
91 +                                       } catch (ex) {
92 +                                               // IE sometimes produces an unknown runtime error on innerHTML
93 +                                               // This seems to fix this issue, don't know why.
94 +                                               x = t.create('div');
95 +                                               x.innerHTML = '<br />' + h;
96 +
97 +                                               each (x.childNodes, function(n, i) {
98 +                                                       // Skip the BR
99 +                                                       if (i > 1)
100 +                                                               e.appendChild(n);
101 +                                               });
102 +                                       }
103                                 } else
104                                         e.innerHTML = h;
105  
106 @@ -1739,6 +1766,9 @@
107                 processHTML : function(h) {
108                         var t = this, s = t.settings;
109  
110 +                       if (!s.process_html)
111 +                               return h;
112 +
113                         // Convert strong and em to b and i in FF since it can't handle them
114                         if (tinymce.isGecko) {
115                                 h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>');
116 @@ -2059,7 +2089,7 @@
117                 });
118  
119         // Setup page DOM
120 -       tinymce.DOM = new tinymce.dom.DOMUtils(document);
121 +       tinymce.DOM = new tinymce.dom.DOMUtils(document, {process_html : 0});
122  })();
123  
124  /* file:jscripts/tiny_mce/classes/dom/Event.js */
125 @@ -3147,10 +3177,10 @@
126                 },
127  
128                 setEntities : function(s) {
129 -                       var a, i, l = {}, re = '', v;
130 +                       var t = this, a, i, l = {}, re = '', v;
131  
132                         // No need to setup more than once
133 -                       if (this.entityLookup)
134 +                       if (t.entityLookup)
135                                 return;
136  
137                         // Build regex and lookup array
138 @@ -3168,8 +3198,13 @@
139                                 re += '\\u' + '0000'.substring(v.length) + v;
140                         }
141  
142 -                       this.entitiesRE = new RegExp('[' + re + ']', 'g');
143 -                       this.entityLookup = l;
144 +                       if (!re) {
145 +                               t.settings.entity_encoding = 'raw';
146 +                               return;
147 +                       }
148 +
149 +                       t.entitiesRE = new RegExp('[' + re + ']', 'g');
150 +                       t.entityLookup = l;
151                 },
152  
153                 setValidChildRules : function(s) {
154 @@ -4115,7 +4150,7 @@
155                 },
156  
157                 renderTo : function(n) {
158 -                       n.innerHTML = this.renderHTML();
159 +                       DOM.setHTML(n, this.renderHTML());
160                 },
161  
162                 postRender : function() {
163 @@ -4318,6 +4353,10 @@
164                         s.offset_y = s.offset_y || 0;
165                         s.vp_offset_x = s.vp_offset_x || 0;
166                         s.vp_offset_y = s.vp_offset_y || 0;
167 +
168 +                       if (is(s.icons) && !s.icons)
169 +                               s['class'] += ' noIcons';
170 +
171                         this.parent(id, s);
172                         this.onHideMenu = new tinymce.util.Dispatcher(this);
173                         this.classPrefix = 'mceMenu';
174 @@ -4460,7 +4499,7 @@
175                         }
176                 },
177  
178 -               hideMenu : function() {
179 +               hideMenu : function(c) {
180                         var t = this, co = DOM.get('menu_' + t.id), e;
181  
182                         if (!t.isMenuVisible)
183 @@ -4471,6 +4510,9 @@
184                         DOM.hide(co);
185                         t.isMenuVisible = 0;
186  
187 +                       if (!c)
188 +                               t.collapse(1);
189 +
190                         if (t.element)
191                                 t.element.hide();
192  
193 @@ -4493,7 +4535,7 @@
194  
195                 collapse : function(d) {
196                         this.parent(d);
197 -                       this.hideMenu();
198 +                       this.hideMenu(1);
199                 },
200  
201                 remove : function(o) {
202 @@ -4942,7 +4984,8 @@
203  
204                         m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
205                                 menu_line : 1,
206 -                               'class' : this.classPrefix + 'Menu'
207 +                               'class' : this.classPrefix + 'Menu',
208 +                               icons : t.settings.icons
209                         });
210  
211                         m.onHideMenu.add(t.hideMenu, t);
212 @@ -6182,6 +6225,18 @@
213                                 });
214                         }
215  
216 +                       if (isGecko) {
217 +                               try {
218 +                                       // Design mode must be set here once again to fix a bug where
219 +                                       // Ctrl+A/Delete/Backspace didn't work if the editor was added using mceAddControl then removed then added again
220 +                                       d.designMode = 'Off';
221 +                                       d.designMode = 'On';
222 +                               } catch (ex) {
223 +                                       // Will fail on Gecko if the editor is placed in an hidden container element
224 +                                       // The design mode will be set ones the editor is focused
225 +                               }
226 +                       }
227 +
228                         // A small timeout was needed since firefox will remove. Bug: #1838304
229                         setTimeout(function () {
230                                 if (t.removed)
231 @@ -6216,7 +6271,7 @@
232                                         }, 100);
233                                 }
234                         }, 1);
235 -
236 +       
237                         e = null;
238                 },
239  
240 @@ -6897,20 +6952,45 @@
241                                 function tabHandler(ed, e) {
242                                         var v, f, el;
243  
244 +                                       function find(d) {
245 +                                               f = DOM.getParent(ed.id, 'form'), el = f.elements;
246 +
247 +                                               if (f) {
248 +                                                       each(f.elements, function(e, i) {
249 +                                                               if (e.id == ed.id) {
250 +                                                                       i = i + d;
251 +
252 +                                                                       if (i < 0 || i > el.length)
253 +                                                                               return;
254 +
255 +                                                                       el = el[i];
256 +                                                               }
257 +                                                       });
258 +                                               }
259 +
260 +                                               return el;
261 +                                       };
262 +
263                                         if (e.keyCode === 9) {
264 -                                               v = ed.getParam('tab_focus');
265 +                                               v = ed.getParam('tab_focus').split(',');
266  
267 -                                               if (v == ':next') {
268 -                                                       f = DOM.getParent(ed.id, 'form');
269 +                                               if (v.length == 1) {
270 +                                                       v[1] = v[0];
271 +                                                       v[0] = ':prev';
272 +                                               }
273  
274 -                                                       if (f) {
275 -                                                               each(f.elements, function(e, i) {
276 -                                                                       if (e.id == ed.id)
277 -                                                                               el = f.elements[i + 1];
278 -                                                               });
279 -                                                       }
280 -                                               } else
281 -                                                       el = DOM.get(v);
282 +                                               // Find element to focus
283 +                                               if (e.shiftKey) {
284 +                                                       if (v[0] == ':prev')
285 +                                                               el = find(-1);
286 +                                                       else
287 +                                                               el = DOM.get(v[0]);
288 +                                               } else {
289 +                                                       if (v[1] == ':next')
290 +                                                               el = find(1);
291 +                                                       else
292 +                                                               el = DOM.get(v[1]);
293 +                                               }
294  
295                                                 if (el) {
296                                                         window.setTimeout(function() {window.focus();el.focus();}, 10);