Merge lp:~openerp-dev/openerp-web/saas-3-updated-cleditor-lib into lp:~openerp/openerp-web/saas-3
- saas-3-updated-cleditor-lib
- Merge into saas-3
Status: | Merged |
---|---|
Merged at revision: | 3961 |
Proposed branch: | lp:~openerp-dev/openerp-web/saas-3-updated-cleditor-lib |
Merge into: | lp:~openerp/openerp-web/saas-3 |
Diff against target: |
632 lines (+136/-124) 3 files modified
addons/web/static/lib/cleditor/jquery.cleditor.css (+1/-1) addons/web/static/lib/cleditor/jquery.cleditor.js (+135/-92) addons/web/static/lib/cleditor/jquery.cleditor.min.js (+0/-31) |
To merge this branch: | bzr merge lp:~openerp-dev/openerp-web/saas-3-updated-cleditor-lib |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email:
|
Commit message
Description of the change
[UPD] [FIX] Update the cleditor library from 1.3.0 to 1.4.4. This version notably fixes some bugs when using IE 9.
(Monkey) Patches done on the version 1.3 have been applied on this version as well to avoid having regression. The saas-3 commits linked to those (monkey) patches are :
- 3328: original commit by chm: [FIX] cleditor: When the DOM is modify, the event resize try to call refresh and refresh has not DOM available. Correction : If the DOM as no prent, don't call refresh.
- 3664 (7.0 forward port): commit 1 by fme: [FIX] html widget: fix cleditor width when the field was invisible before becoming editable + commit 2 by tde: [IMP] cleditor: stop using custom font-size, font-family.
- 3755 (saas-1 forward port): commit by msh: [FIX]Fixed the issue of cleditor, on window resize blur event not triggered except firefox so due to which value disappears from the container.
- 3961. By Paramjit Singh Sahota(OpenERP)
-
[REM] REmoved the jquery.
cleditor. min.js for the lib. - 3962. By Paramjit Singh Sahota(OpenERP)
-
[MERGE] Merged lp:~openerp/openerp-web/saas-3
- 3963. By Thibault Delavallée (OpenERP)
-
[DUMMY] Void commit with a space change, because this cause a crash in bazaar.
- 3964. By Thibault Delavallée (OpenERP)
-
[IMP] [MONKEY] Re-apply changes introduced at version 3328.
Original commit by chm.[FIX] cleditor: When the DOM is modify, the event resize try to call refresh and refresh has not DOM available. Correction : If the DOM as no prent, don't call refresh.
- 3965. By Thibault Delavallée (OpenERP)
-
[IMP] [MONKEY] Re-apply changes introduced at version 3664 that was
a forward port of 7.0 commits.
Commit 1 by fme.
[FIX] html widget: fix cleditor width when the field was invisible before becoming editable
Commit 2 by tde.
[IMP] cleditor: stop using custom font-size, font-family. - 3966. By Thibault Delavallée (OpenERP)
-
[IMP] [MONKEY] Re-apply changes introduced at version 3755.
This commit was a forward-pord of saas-1 commits.
Commit by msh
[FIX]Fixed the issue of cleditor, on window resize blur event not triggered except firefox so due to which value disappears from the container.
Preview Diff
1 | === modified file 'addons/web/static/lib/cleditor/jquery.cleditor.css' |
2 | --- addons/web/static/lib/cleditor/jquery.cleditor.css 2012-06-15 13:32:37 +0000 |
3 | +++ addons/web/static/lib/cleditor/jquery.cleditor.css 2014-03-05 10:59:43 +0000 |
4 | @@ -6,7 +6,7 @@ |
5 | .cleditorButton {float:left; width:24px; height:24px; margin:1px 0 1px 0; background: url('images/buttons.gif')} |
6 | .cleditorDisabled {opacity:0.3; filter:alpha(opacity=30)} |
7 | .cleditorDivider {float:left; width:1px; height:23px; margin:1px 0 1px 0; background:#CCC} |
8 | -.cleditorPopup {border:solid 1px #999; background-color:white; position:absolute; font:10pt Arial,Verdana; cursor:default; z-index:10000} |
9 | +.cleditorPopup {border:solid 1px #999; background-color:white; color:#333333; position:absolute; font:10pt Arial,Verdana; cursor:default; z-index:10000} |
10 | .cleditorList div {padding:2px 4px 2px 4px} |
11 | .cleditorList p, |
12 | .cleditorList h1, |
13 | |
14 | === modified file 'addons/web/static/lib/cleditor/jquery.cleditor.js' |
15 | --- addons/web/static/lib/cleditor/jquery.cleditor.js 2013-06-06 14:44:37 +0000 |
16 | +++ addons/web/static/lib/cleditor/jquery.cleditor.js 2014-03-05 10:59:43 +0000 |
17 | @@ -1,18 +1,13 @@ |
18 | -/** |
19 | - @preserve CLEditor WYSIWYG HTML Editor v1.3.0 |
20 | - http://premiumsoftware.net/cleditor |
21 | +/*! |
22 | + CLEditor WYSIWYG HTML Editor v1.4.4 |
23 | + http://premiumsoftware.net/CLEditor |
24 | requires jQuery v1.4.2 or later |
25 | |
26 | Copyright 2010, Chris Landowski, Premium Software, LLC |
27 | Dual licensed under the MIT or GPL Version 2 licenses. |
28 | */ |
29 | |
30 | -// ==ClosureCompiler== |
31 | -// @compilation_level SIMPLE_OPTIMIZATIONS |
32 | -// @output_file_name jquery.cleditor.min.js |
33 | -// ==/ClosureCompiler== |
34 | - |
35 | -(function($) { |
36 | +(function ($) { |
37 | |
38 | //============== |
39 | // jQuery Plugin |
40 | @@ -22,7 +17,7 @@ |
41 | |
42 | // Define the defaults used for all new cleditor instances |
43 | defaultOptions: { |
44 | - width: 500, // width not including margins, borders or padding |
45 | + width: 'auto', // width not including margins, borders or padding |
46 | height: 250, // height not including margins, borders or padding |
47 | controls: // controls to add to the toolbar |
48 | "bold italic underline strikethrough subscript superscript | font size " + |
49 | @@ -46,7 +41,7 @@ |
50 | [["Paragraph", "<p>"], ["Header 1", "<h1>"], ["Header 2", "<h2>"], |
51 | ["Header 3", "<h3>"], ["Header 4","<h4>"], ["Header 5","<h5>"], |
52 | ["Header 6","<h6>"]], |
53 | - useCSS: false, // use CSS to style HTML when possible (not supported in ie) |
54 | + useCSS: true, // use CSS to style HTML when possible (not supported in ie) |
55 | docType: // Document type contained within the editor |
56 | '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">', |
57 | docCSSFile: // CSS file used to style the document contained within the editor |
58 | @@ -57,7 +52,7 @@ |
59 | |
60 | // Define all usable toolbar buttons - the init string property is |
61 | // expanded during initialization back into the buttons object and |
62 | - // seperate object properties are created for each button. |
63 | + // separate object properties are created for each button. |
64 | // e.g. buttons.size.title = "Font Size" |
65 | buttons: { |
66 | // name,title,command,popupName (""=use name) |
67 | @@ -109,7 +104,7 @@ |
68 | |
69 | // Loop through all matching textareas and create the editors |
70 | this.each(function(idx, elem) { |
71 | - if (elem.tagName == "TEXTAREA") { |
72 | + if (elem.tagName.toUpperCase() === "TEXTAREA") { |
73 | var data = $.data(elem, CLEDITOR); |
74 | if (!data) data = new cleditor(elem, options); |
75 | $result = $result.add(data); |
76 | @@ -129,6 +124,7 @@ |
77 | |
78 | // Misc constants |
79 | BACKGROUND_COLOR = "backgroundColor", |
80 | + BLURRED = "blurred", |
81 | BUTTON = "button", |
82 | BUTTON_NAME = "buttonName", |
83 | CHANGE = "change", |
84 | @@ -136,6 +132,7 @@ |
85 | CLICK = "click", |
86 | DISABLED = "disabled", |
87 | DIV_TAG = "<div>", |
88 | + FOCUSED = "focused", |
89 | TRANSPARENT = "transparent", |
90 | UNSELECTABLE = "unselectable", |
91 | |
92 | @@ -152,12 +149,15 @@ |
93 | PROMPT_CLASS = "cleditorPrompt", // prompt popup divs inside body |
94 | MSG_CLASS = "cleditorMsg", // message popup div inside body |
95 | |
96 | - // Test for ie |
97 | - ie = $.browser.msie, |
98 | - ie6 = /msie\s6/i.test(navigator.userAgent), |
99 | + // Browser detection |
100 | + ua = navigator.userAgent.toLowerCase(), |
101 | + ie = /msie/.test(ua), |
102 | + ie6 = /msie\s6/.test(ua), |
103 | + iege11 = /(trident)(?:.*rv:([\w.]+))?/.test(ua), |
104 | + webkit = /webkit/.test(ua), |
105 | |
106 | // Test for iPhone/iTouch/iPad |
107 | - iOS = /iphone|ipad|ipod/i.test(navigator.userAgent), |
108 | + iOS = /iphone|ipad|ipod/i.test(ua), |
109 | |
110 | // Popups are created once as needed and shared by all editor instances |
111 | popups = {}, |
112 | @@ -223,19 +223,26 @@ |
113 | var $group = $(DIV_TAG) |
114 | .addClass(GROUP_CLASS) |
115 | .appendTo($toolbar); |
116 | + |
117 | + // Initialize the group width |
118 | + var groupWidth = 0; |
119 | |
120 | // Add the buttons to the toolbar |
121 | $.each(options.controls.split(" "), function(idx, buttonName) { |
122 | if (buttonName === "") return true; |
123 | |
124 | // Divider |
125 | - if (buttonName == "|") { |
126 | + if (buttonName === "|") { |
127 | |
128 | // Add a new divider to the group |
129 | var $div = $(DIV_TAG) |
130 | .addClass(DIVIDER_CLASS) |
131 | .appendTo($group); |
132 | |
133 | + // Update the group width |
134 | + $group.width(groupWidth + 1); |
135 | + groupWidth = 0; |
136 | + |
137 | // Create a new group |
138 | $group = $(DIV_TAG) |
139 | .addClass(GROUP_CLASS) |
140 | @@ -258,6 +265,10 @@ |
141 | .appendTo($group) |
142 | .hover(hoverEnter, hoverLeave); |
143 | |
144 | + // Update the group width |
145 | + groupWidth += 24; |
146 | + $group.width(groupWidth + 1); |
147 | + |
148 | // Prepare the button image |
149 | var map = {}; |
150 | if (button.css) map = button.css; |
151 | @@ -295,7 +306,7 @@ |
152 | |
153 | // Bind the window resize event when the width or height is auto or % |
154 | if (/auto|%/.test("" + options.width + options.height)) |
155 | - $(window).resize(function() { |
156 | + $(window).bind('resize.cleditor', function () { |
157 | //Forcefully blurred iframe contentWindow, chrome, IE, safari doesn't trigger blur on window resize and due to which text disappears |
158 | var contentWindow = editor.$frame[0].contentWindow; |
159 | if(!$.browser.mozilla && contentWindow){ |
160 | @@ -306,7 +317,6 @@ |
161 | refresh(editor); |
162 | } |
163 | }); |
164 | - |
165 | // Create the iframe and resize the controls |
166 | refresh(editor); |
167 | |
168 | @@ -347,13 +357,26 @@ |
169 | return editor; |
170 | }; |
171 | }); |
172 | + |
173 | + // blurred - shortcut for .bind("blurred", handler) or .trigger("blurred") |
174 | + fn.blurred = function(handler) { |
175 | + var $this = $(this); |
176 | + return handler ? $this.bind(BLURRED, handler) : $this.trigger(BLURRED); |
177 | + }; |
178 | |
179 | // change - shortcut for .bind("change", handler) or .trigger("change") |
180 | - fn.change = function(handler) { |
181 | + fn.change = function change(handler) { |
182 | + console.log('change test'); |
183 | var $this = $(this); |
184 | return handler ? $this.bind(CHANGE, handler) : $this.trigger(CHANGE); |
185 | }; |
186 | |
187 | + // focused - shortcut for .bind("focused", handler) or .trigger("focused") |
188 | + fn.focused = function(handler) { |
189 | + var $this = $(this); |
190 | + return handler ? $this.bind(FOCUSED, handler) : $this.trigger(FOCUSED); |
191 | + }; |
192 | + |
193 | //=============== |
194 | // Event Handlers |
195 | //=============== |
196 | @@ -369,7 +392,7 @@ |
197 | popup = popups[popupName]; |
198 | |
199 | // Check if disabled |
200 | - if (editor.disabled || $(buttonDiv).attr(DISABLED) == DISABLED) |
201 | + if (editor.disabled || $(buttonDiv).attr(DISABLED) === DISABLED) |
202 | return; |
203 | |
204 | // Fire the buttonClick event |
205 | @@ -387,7 +410,7 @@ |
206 | return false; |
207 | |
208 | // Toggle source |
209 | - if (buttonName == "source") { |
210 | + if (buttonName === "source") { |
211 | |
212 | // Show the iframe |
213 | if (sourceMode(editor)) { |
214 | @@ -418,10 +441,10 @@ |
215 | var $popup = $(popup); |
216 | |
217 | // URL |
218 | - if (popupName == "url") { |
219 | + if (popupName === "url") { |
220 | |
221 | // Check for selection before showing the link url popup |
222 | - if (buttonName == "link" && selectedText(editor) === "") { |
223 | + if (buttonName === "link" && selectedText(editor) === "") { |
224 | showMessage(editor, "A selection is required when inserting a link.", buttonDiv); |
225 | return false; |
226 | } |
227 | @@ -447,7 +470,7 @@ |
228 | } |
229 | |
230 | // Paste as Text |
231 | - else if (popupName == "pastetext") { |
232 | + else if (popupName === "pastetext") { |
233 | |
234 | // Wire up the submit button click event handler |
235 | $popup.children(":button") |
236 | @@ -475,13 +498,13 @@ |
237 | return false; // stop propagination to document click |
238 | } |
239 | |
240 | - // propaginate to documnt click |
241 | + // propaginate to document click |
242 | return; |
243 | |
244 | } |
245 | |
246 | |
247 | - else if (buttonName == "print") |
248 | + else if (buttonName === "print") |
249 | editor.$frame[0].contentWindow.print(); |
250 | |
251 | // All other buttons |
252 | @@ -526,19 +549,19 @@ |
253 | useCSS = editor.options.useCSS; |
254 | |
255 | // Get the command value |
256 | - if (buttonName == "font") |
257 | + if (buttonName === "font") |
258 | // Opera returns the fontfamily wrapped in quotes |
259 | value = target.style.fontFamily.replace(/"/g, ""); |
260 | - else if (buttonName == "size") { |
261 | - if (target.tagName == "DIV") |
262 | + else if (buttonName === "size") { |
263 | + if (target.tagName.toUpperCase() === "DIV") |
264 | target = target.children[0]; |
265 | value = target.innerHTML; |
266 | } |
267 | - else if (buttonName == "style") |
268 | + else if (buttonName === "style") |
269 | value = "<" + target.tagName + ">"; |
270 | - else if (buttonName == "color") |
271 | + else if (buttonName === "color") |
272 | value = hex(target.style.backgroundColor); |
273 | - else if (buttonName == "highlight") { |
274 | + else if (buttonName === "highlight") { |
275 | value = hex(target.style.backgroundColor); |
276 | if (ie) command = 'backcolor'; |
277 | else useCSS = true; |
278 | @@ -610,7 +633,7 @@ |
279 | $popup.html(popupContent); |
280 | |
281 | // Color |
282 | - else if (popupName == "color") { |
283 | + else if (popupName === "color") { |
284 | var colors = options.colors.split(" "); |
285 | if (colors.length < 10) |
286 | $popup.width("auto"); |
287 | @@ -622,7 +645,7 @@ |
288 | } |
289 | |
290 | // Font |
291 | - else if (popupName == "font") |
292 | + else if (popupName === "font") |
293 | $.each(options.fonts.split(","), function(idx, font) { |
294 | $(DIV_TAG).appendTo($popup) |
295 | .css("fontFamily", font) |
296 | @@ -630,28 +653,28 @@ |
297 | }); |
298 | |
299 | // Size |
300 | - else if (popupName == "size") |
301 | + else if (popupName === "size") |
302 | $.each(options.sizes.split(","), function(idx, size) { |
303 | $(DIV_TAG).appendTo($popup) |
304 | - .html("<font size=" + size + ">" + size + "</font>"); |
305 | + .html('<font size="' + size + '">' + size + '</font>'); |
306 | }); |
307 | |
308 | // Style |
309 | - else if (popupName == "style") |
310 | + else if (popupName === "style") |
311 | $.each(options.styles, function(idx, style) { |
312 | $(DIV_TAG).appendTo($popup) |
313 | .html(style[1] + style[0] + style[1].replace("<", "</")); |
314 | }); |
315 | |
316 | // URL |
317 | - else if (popupName == "url") { |
318 | - $popup.html('Enter URL:<br><input type=text value="http://" size=35><br><input type=button value="Submit">'); |
319 | + else if (popupName === "url") { |
320 | + $popup.html('Enter URL:<br /><input type="text" value="http://" size="35" /><br /><input type="button" value="Submit" />'); |
321 | popupTypeClass = PROMPT_CLASS; |
322 | } |
323 | |
324 | // Paste as Text |
325 | - else if (popupName == "pastetext") { |
326 | - $popup.html('Paste your content here and click submit.<br /><textarea cols=40 rows=3></textarea><br /><input type=button value=Submit>'); |
327 | + else if (popupName === "pastetext") { |
328 | + $popup.html('Paste your content here and click submit.<br /><textarea cols="40" rows="3"></textarea><br /><input type="button" value="Submit" />'); |
329 | popupTypeClass = PROMPT_CLASS; |
330 | } |
331 | |
332 | @@ -720,12 +743,12 @@ |
333 | } |
334 | |
335 | // Execute the command and check for error |
336 | - var success = true, description; |
337 | - if (ie && command.toLowerCase() == "inserthtml") |
338 | + var success = true, message; |
339 | + if (ie && command.toLowerCase() === "inserthtml") |
340 | getRange(editor).pasteHTML(value); |
341 | else { |
342 | try { success = editor.doc.execCommand(command, 0, value || null); } |
343 | - catch (err) { description = err.description; success = false; } |
344 | + catch (err) { message = err.message; success = false; } |
345 | if (!success) { |
346 | if ("cutcopypaste".indexOf(command) > -1) |
347 | showMessage(editor, "For security reasons, your browser does not support the " + |
348 | @@ -733,13 +756,14 @@ |
349 | button); |
350 | else |
351 | showMessage(editor, |
352 | - (description ? description : "Error executing the " + command + " command."), |
353 | + (message ? message : "Error executing the " + command + " command."), |
354 | button); |
355 | } |
356 | } |
357 | |
358 | - // Enable the buttons |
359 | + // Enable the buttons and update the textarea |
360 | refreshButtons(editor); |
361 | + updateTextArea(editor, true); |
362 | return success; |
363 | |
364 | } |
365 | @@ -765,19 +789,26 @@ |
366 | return editor.$frame[0].contentWindow.getSelection(); |
367 | } |
368 | |
369 | - // Returns the hex value for the passed in string. |
370 | - // hex("rgb(255, 0, 0)"); // #FF0000 |
371 | - // hex("#FF0000"); // #FF0000 |
372 | - // hex("#F00"); // #FF0000 |
373 | + // hex - returns the hex value for the passed in color string |
374 | function hex(s) { |
375 | - var m = /rgba?\((\d+), (\d+), (\d+)/.exec(s), |
376 | - c = s.split(""); |
377 | + |
378 | + // hex("rgb(255, 0, 0)") returns #FF0000 |
379 | + var m = /rgba?\((\d+), (\d+), (\d+)/.exec(s); |
380 | if (m) { |
381 | - s = ( m[1] << 16 | m[2] << 8 | m[3] ).toString(16); |
382 | + s = (m[1] << 16 | m[2] << 8 | m[3]).toString(16); |
383 | while (s.length < 6) |
384 | s = "0" + s; |
385 | + return "#" + s; |
386 | } |
387 | - return "#" + (s.length == 6 ? s : c[1] + c[1] + c[2] + c[2] + c[3] + c[3]); |
388 | + |
389 | + // hex("#F00") returns #FF0000 |
390 | + var c = s.split(""); |
391 | + if (s.length === 4) |
392 | + return "#" + c[1] + c[1] + c[2] + c[2] + c[3] + c[3]; |
393 | + |
394 | + // hex("#FF0000") returns #FF0000 |
395 | + return s; |
396 | + |
397 | } |
398 | |
399 | // hidePopups - hides all popups |
400 | @@ -792,9 +823,8 @@ |
401 | |
402 | // imagesPath - returns the path to the images folder |
403 | function imagesPath() { |
404 | - var cssFile = "jquery.cleditor.css", |
405 | - href = $("link[href$='" + cssFile +"']").attr("href"); |
406 | - return href.substr(0, href.length - cssFile.length) + "images/"; |
407 | + var href = $("link[href*=cleditor]").attr("href"); |
408 | + return href.replace(/^(.*\/)[^\/]+$/, '$1') + "images/"; |
409 | } |
410 | |
411 | // imageUrl - Returns the css url string for a filemane |
412 | @@ -813,7 +843,7 @@ |
413 | editor.$frame.remove(); |
414 | |
415 | // Create a new iframe |
416 | - var $frame = editor.$frame = $('<iframe frameborder="0" src="javascript:true;">') |
417 | + var $frame = editor.$frame = $('<iframe frameborder="0" src="javascript:true;" />') |
418 | .hide() |
419 | .appendTo($main); |
420 | |
421 | @@ -833,14 +863,14 @@ |
422 | |
423 | // Work around for bug in IE which causes the editor to lose |
424 | // focus when clicking below the end of the document. |
425 | - if (ie) |
426 | + if (ie || iege11) |
427 | $doc.click(function() {focus(editor);}); |
428 | |
429 | // Load the content |
430 | updateFrame(editor); |
431 | |
432 | // Bind the ie specific iframe event handlers |
433 | - if (ie) { |
434 | + if (ie || iege11) { |
435 | |
436 | // Save the current user selection. This code is needed since IE will |
437 | // reset the selection just after the beforedeactivate event and just |
438 | @@ -848,19 +878,19 @@ |
439 | $doc.bind("beforedeactivate beforeactivate selectionchange keypress", function(e) { |
440 | |
441 | // Flag the editor as inactive |
442 | - if (e.type == "beforedeactivate") |
443 | + if (e.type === "beforedeactivate") |
444 | editor.inactive = true; |
445 | - |
446 | - // Get rid of the bogus selection and flag the editor as active |
447 | - else if (e.type == "beforeactivate") { |
448 | + |
449 | + // Get rid of the bogus selection and flag the editor as active |
450 | + else if (e.type === "beforeactivate") { |
451 | if (!editor.inactive && editor.range && editor.range.length > 1) |
452 | editor.range.shift(); |
453 | delete editor.inactive; |
454 | } |
455 | |
456 | - // Save the selection when the editor is active |
457 | + // Save the selection when the editor is active |
458 | else if (!editor.inactive) { |
459 | - if (!editor.range) |
460 | + if (!editor.range) |
461 | editor.range = []; |
462 | editor.range.unshift(getRange(editor)); |
463 | |
464 | @@ -871,22 +901,31 @@ |
465 | |
466 | }); |
467 | |
468 | - // Restore the text range when the iframe gains focus |
469 | + // Restore the text range and trigger focused event when the iframe gains focus |
470 | $frame.focus(function() { |
471 | restoreRange(editor); |
472 | - }); |
473 | - |
474 | - } |
475 | - |
476 | - // Update the textarea when the iframe loses focus |
477 | - ($.browser.mozilla ? $doc : $(contentWindow)).blur(function() { |
478 | - updateTextArea(editor, true); |
479 | - }); |
480 | - |
481 | - // Enable the toolbar buttons as the user types or clicks |
482 | + $(editor).triggerHandler(FOCUSED); |
483 | + }); |
484 | + |
485 | + // Trigger blurred event when the iframe looses focus |
486 | + $frame.blur(function() { |
487 | + $(editor).triggerHandler(BLURRED); |
488 | + }); |
489 | + |
490 | + } |
491 | + |
492 | + // Trigger focused and blurred events for all other browsers |
493 | + else { |
494 | + $(editor.$frame[0].contentWindow) |
495 | + .focus(function () { $(editor).triggerHandler(FOCUSED); }) |
496 | + .blur(function () { $(editor).triggerHandler(BLURRED); }); |
497 | + } |
498 | + |
499 | + // Enable the toolbar buttons and update the textarea as the user types or clicks |
500 | $doc.click(hidePopups) |
501 | .bind("keyup mouseup", function() { |
502 | refreshButtons(editor); |
503 | + updateTextArea(editor, true); |
504 | }); |
505 | |
506 | // Show the textarea for iPhone/iTouch/iPad or |
507 | @@ -906,7 +945,7 @@ |
508 | $toolbar.height(hgt); |
509 | |
510 | // Resize the iframe |
511 | - hgt = (/%/.test("" + options.height) ? $main.height() : parseInt(options.height)) - hgt; |
512 | + hgt = (/%/.test("" + options.height) ? $main.height() : parseInt(options.height, 10)) - hgt; |
513 | $frame.width(wid).height(hgt); |
514 | |
515 | // Resize the textarea. IE6 textareas have a 1px top |
516 | @@ -927,7 +966,7 @@ |
517 | function refreshButtons(editor) { |
518 | |
519 | // Webkit requires focus before queryCommandEnabled will return anything but false |
520 | - if (!iOS && $.browser.webkit && !editor.focused) { |
521 | + if (!iOS && webkit && !editor.focused) { |
522 | editor.$frame[0].contentWindow.focus(); |
523 | window.focus(); |
524 | editor.focused = true; |
525 | @@ -963,14 +1002,14 @@ |
526 | if (enabled === undefined) |
527 | enabled = true; |
528 | } |
529 | - else if (((inSourceMode || iOS) && button.name != "source") || |
530 | - (ie && (command == "undo" || command == "redo"))) |
531 | + else if (((inSourceMode || iOS) && button.name !== "source") || |
532 | + (ie && (command === "undo" || command === "redo"))) |
533 | enabled = false; |
534 | - else if (command && command != "print") { |
535 | - if (ie && command == "hilitecolor") |
536 | + else if (command && command !== "print") { |
537 | + if (ie && command === "hilitecolor") |
538 | command = "backcolor"; |
539 | // IE does not support inserthtml, so it's always enabled |
540 | - if (!ie || command != "inserthtml") { |
541 | + if (!ie || command !== "inserthtml") { |
542 | try {enabled = queryObj.queryCommandEnabled(command);} |
543 | catch (err) {enabled = false;} |
544 | } |
545 | @@ -991,8 +1030,12 @@ |
546 | |
547 | // restoreRange - restores the current ie selection |
548 | function restoreRange(editor) { |
549 | - if (ie && editor.range) |
550 | - editor.range[0].select(); |
551 | + if (editor.range) { |
552 | + if (ie) |
553 | + editor.range[0].select(); |
554 | + else if (iege11) |
555 | + getSelection(editor).addRange(editor.range[0]); |
556 | + } |
557 | } |
558 | |
559 | // select - selects all the text in either the textarea or iframe |
560 | @@ -1084,7 +1127,7 @@ |
561 | // of potentially heavy updateFrame callbacks. |
562 | if (updateFrameCallback) { |
563 | var sum = checksum(code); |
564 | - if (checkForChange && editor.areaChecksum == sum) |
565 | + if (checkForChange && editor.areaChecksum === sum) |
566 | return; |
567 | editor.areaChecksum = sum; |
568 | } |
569 | @@ -1100,7 +1143,7 @@ |
570 | editor.frameChecksum = checksum(html); |
571 | |
572 | // Update the iframe and trigger the change event |
573 | - if (html != $body.html()) { |
574 | + if (html !== $body.html()) { |
575 | $body.html(html); |
576 | $(editor).triggerHandler(CHANGE); |
577 | } |
578 | @@ -1119,7 +1162,7 @@ |
579 | // of potentially heavy updateTextArea callbacks. |
580 | if (updateTextAreaCallback) { |
581 | var sum = checksum(html); |
582 | - if (checkForChange && editor.frameChecksum == sum) |
583 | + if (checkForChange && editor.frameChecksum === sum) |
584 | return; |
585 | editor.frameChecksum = sum; |
586 | } |
587 | @@ -1132,7 +1175,7 @@ |
588 | editor.areaChecksum = checksum(code); |
589 | |
590 | // Update the textarea and trigger the change event |
591 | - if (code != $area.val()) { |
592 | + if (code !== $area.val()) { |
593 | $area.val(code); |
594 | $(editor).triggerHandler(CHANGE); |
595 | } |
596 | |
597 | === removed file 'addons/web/static/lib/cleditor/jquery.cleditor.min.js' |
598 | --- addons/web/static/lib/cleditor/jquery.cleditor.min.js 2012-06-15 13:32:37 +0000 |
599 | +++ addons/web/static/lib/cleditor/jquery.cleditor.min.js 1970-01-01 00:00:00 +0000 |
600 | @@ -1,31 +0,0 @@ |
601 | -/* |
602 | - CLEditor WYSIWYG HTML Editor v1.3.0 |
603 | - http://premiumsoftware.net/cleditor |
604 | - requires jQuery v1.4.2 or later |
605 | - |
606 | - Copyright 2010, Chris Landowski, Premium Software, LLC |
607 | - Dual licensed under the MIT or GPL Version 2 licenses. |
608 | -*/ |
609 | -(function(e){function aa(a){var b=this,c=a.target,d=e.data(c,x),h=s[d],f=h.popupName,i=p[f];if(!(b.disabled||e(c).attr(n)==n)){var g={editor:b,button:c,buttonName:d,popup:i,popupName:f,command:h.command,useCSS:b.options.useCSS};if(h.buttonClick&&h.buttonClick(a,g)===false)return false;if(d=="source"){if(t(b)){delete b.range;b.$area.hide();b.$frame.show();c.title=h.title}else{b.$frame.hide();b.$area.show();c.title="Show Rich Text"}setTimeout(function(){u(b)},100)}else if(!t(b))if(f){var j=e(i);if(f== |
610 | -"url"){if(d=="link"&&M(b)===""){z(b,"A selection is required when inserting a link.",c);return false}j.children(":button").unbind(q).bind(q,function(){var k=j.find(":text"),o=e.trim(k.val());o!==""&&v(b,g.command,o,null,g.button);k.val("http://");r();w(b)})}else f=="pastetext"&&j.children(":button").unbind(q).bind(q,function(){var k=j.find("textarea"),o=k.val().replace(/\n/g,"<br />");o!==""&&v(b,g.command,o,null,g.button);k.val("");r();w(b)});if(c!==e.data(i,A)){N(b,i,c);return false}return}else if(d== |
611 | -"print")b.$frame[0].contentWindow.print();else if(!v(b,g.command,g.value,g.useCSS,c))return false;w(b)}}function O(a){a=e(a.target).closest("div");a.css(H,a.data(x)?"#FFF":"#FFC")}function P(a){e(a.target).closest("div").css(H,"transparent")}function ba(a){var b=a.data.popup,c=a.target;if(!(b===p.msg||e(b).hasClass(B))){var d=e.data(b,A),h=e.data(d,x),f=s[h],i=f.command,g,j=this.options.useCSS;if(h=="font")g=c.style.fontFamily.replace(/"/g,"");else if(h=="size"){if(c.tagName=="DIV")c=c.children[0]; |
612 | -g=c.innerHTML}else if(h=="style")g="<"+c.tagName+">";else if(h=="color")g=Q(c.style.backgroundColor);else if(h=="highlight"){g=Q(c.style.backgroundColor);if(l)i="backcolor";else j=true}b={editor:this,button:d,buttonName:h,popup:b,popupName:f.popupName,command:i,value:g,useCSS:j};if(!(f.popupClick&&f.popupClick(a,b)===false)){if(b.command&&!v(this,b.command,b.value,b.useCSS,d))return false;r();w(this)}}}function C(a){for(var b=1,c=0,d=0;d<a.length;++d){b=(b+a.charCodeAt(d))%65521;c=(c+b)%65521}return c<< |
613 | -16|b}function R(a,b,c,d,h){if(p[a])return p[a];var f=e(m).hide().addClass(ca).appendTo("body");if(d)f.html(d);else if(a=="color"){b=b.colors.split(" ");b.length<10&&f.width("auto");e.each(b,function(i,g){e(m).appendTo(f).css(H,"#"+g)});c=da}else if(a=="font")e.each(b.fonts.split(","),function(i,g){e(m).appendTo(f).css("fontFamily",g).html(g)});else if(a=="size")e.each(b.sizes.split(","),function(i,g){e(m).appendTo(f).html("<font size="+g+">"+g+"</font>")});else if(a=="style")e.each(b.styles,function(i, |
614 | -g){e(m).appendTo(f).html(g[1]+g[0]+g[1].replace("<","</"))});else if(a=="url"){f.html('Enter URL:<br><input type=text value="http://" size=35><br><input type=button value="Submit">');c=B}else if(a=="pastetext"){f.html("Paste your content here and click submit.<br /><textarea cols=40 rows=3></textarea><br /><input type=button value=Submit>");c=B}if(!c&&!d)c=S;f.addClass(c);l&&f.attr(I,"on").find("div,font,p,h1,h2,h3,h4,h5,h6").attr(I,"on");if(f.hasClass(S)||h===true)f.children().hover(O,P);p[a]=f[0]; |
615 | -return f[0]}function T(a,b){if(b){a.$area.attr(n,n);a.disabled=true}else{a.$area.removeAttr(n);delete a.disabled}try{if(l)a.doc.body.contentEditable=!b;else a.doc.designMode=!b?"on":"off"}catch(c){}u(a)}function v(a,b,c,d,h){D(a);if(!l){if(d===undefined||d===null)d=a.options.useCSS;a.doc.execCommand("styleWithCSS",0,d.toString())}d=true;var f;if(l&&b.toLowerCase()=="inserthtml")y(a).pasteHTML(c);else{try{d=a.doc.execCommand(b,0,c||null)}catch(i){f=i.description;d=false}d||("cutcopypaste".indexOf(b)> |
616 | --1?z(a,"For security reasons, your browser does not support the "+b+" command. Try using the keyboard shortcut or context menu instead.",h):z(a,f?f:"Error executing the "+b+" command.",h))}u(a);return d}function w(a){setTimeout(function(){t(a)?a.$area.focus():a.$frame[0].contentWindow.focus();u(a)},0)}function y(a){if(l)return J(a).createRange();return J(a).getRangeAt(0)}function J(a){if(l)return a.doc.selection;return a.$frame[0].contentWindow.getSelection()}function Q(a){var b=/rgba?\((\d+), (\d+), (\d+)/.exec(a), |
617 | -c=a.split("");if(b)for(a=(b[1]<<16|b[2]<<8|b[3]).toString(16);a.length<6;)a="0"+a;return"#"+(a.length==6?a:c[1]+c[1]+c[2]+c[2]+c[3]+c[3])}function r(){e.each(p,function(a,b){e(b).hide().unbind(q).removeData(A)})}function U(){var a=e("link[href$='jquery.cleditor.css']").attr("href");return a.substr(0,a.length-19)+"images/"}function K(a){var b=a.$main,c=a.options;a.$frame&&a.$frame.remove();var d=a.$frame=e('<iframe frameborder="0" src="javascript:true;">').hide().appendTo(b),h=d[0].contentWindow,f= |
618 | -a.doc=h.document,i=e(f);f.open();f.write(c.docType+"<html>"+(c.docCSSFile===""?"":'<head><link rel="stylesheet" type="text/css" href="'+c.docCSSFile+'" /></head>')+'<body style="'+c.bodyStyle+'"></body></html>');f.close();l&&i.click(function(){w(a)});E(a);if(l){i.bind("beforedeactivate beforeactivate selectionchange keypress",function(g){if(g.type=="beforedeactivate")a.inactive=true;else if(g.type=="beforeactivate"){!a.inactive&&a.range&&a.range.length>1&&a.range.shift();delete a.inactive}else if(!a.inactive){if(!a.range)a.range= |
619 | -[];for(a.range.unshift(y(a));a.range.length>2;)a.range.pop()}});d.focus(function(){D(a)})}(e.browser.mozilla?i:e(h)).blur(function(){V(a,true)});i.click(r).bind("keyup mouseup",function(){u(a)});L?a.$area.show():d.show();e(function(){var g=a.$toolbar,j=g.children("div:last"),k=b.width();j=j.offset().top+j.outerHeight()-g.offset().top+1;g.height(j);j=(/%/.test(""+c.height)?b.height():parseInt(c.height))-j;d.width(k).height(j);a.$area.width(k).height(ea?j-2:j);T(a,a.disabled);u(a)})}function u(a){if(!L&& |
620 | -e.browser.webkit&&!a.focused){a.$frame[0].contentWindow.focus();window.focus();a.focused=true}var b=a.doc;if(l)b=y(a);var c=t(a);e.each(a.$toolbar.find("."+W),function(d,h){var f=e(h),i=e.cleditor.buttons[e.data(h,x)],g=i.command,j=true;if(a.disabled)j=false;else if(i.getEnabled){j=i.getEnabled({editor:a,button:h,buttonName:i.name,popup:p[i.popupName],popupName:i.popupName,command:i.command,useCSS:a.options.useCSS});if(j===undefined)j=true}else if((c||L)&&i.name!="source"||l&&(g=="undo"||g=="redo"))j= |
621 | -false;else if(g&&g!="print"){if(l&&g=="hilitecolor")g="backcolor";if(!l||g!="inserthtml")try{j=b.queryCommandEnabled(g)}catch(k){j=false}}if(j){f.removeClass(X);f.removeAttr(n)}else{f.addClass(X);f.attr(n,n)}})}function D(a){l&&a.range&&a.range[0].select()}function M(a){D(a);if(l)return y(a).text;return J(a).toString()}function z(a,b,c){var d=R("msg",a.options,fa);d.innerHTML=b;N(a,d,c)}function N(a,b,c){var d,h,f=e(b);if(c){var i=e(c);d=i.offset();h=--d.left;d=d.top+i.height()}else{i=a.$toolbar; |
622 | -d=i.offset();h=Math.floor((i.width()-f.width())/2)+d.left;d=d.top+i.height()-2}r();f.css({left:h,top:d}).show();if(c){e.data(b,A,c);f.bind(q,{popup:b},e.proxy(ba,a))}setTimeout(function(){f.find(":text,textarea").eq(0).focus().select()},100)}function t(a){return a.$area.is(":visible")}function E(a,b){var c=a.$area.val(),d=a.options,h=d.updateFrame,f=e(a.doc.body);if(h){var i=C(c);if(b&&a.areaChecksum==i)return;a.areaChecksum=i}c=h?h(c):c;c=c.replace(/<(?=\/?script)/ig,"<");if(d.updateTextArea)a.frameChecksum= |
623 | -C(c);if(c!=f.html()){f.html(c);e(a).triggerHandler(F)}}function V(a,b){var c=e(a.doc.body).html(),d=a.options,h=d.updateTextArea,f=a.$area;if(h){var i=C(c);if(b&&a.frameChecksum==i)return;a.frameChecksum=i}c=h?h(c):c;if(d.updateFrame)a.areaChecksum=C(c);if(c!=f.val()){f.val(c);e(a).triggerHandler(F)}}e.cleditor={defaultOptions:{width:500,height:250,controls:"bold italic underline strikethrough subscript superscript | font size style | color highlight removeformat | bullets numbering | outdent indent | alignleft center alignright justify | undo redo | rule image link unlink | cut copy paste pastetext | print source", |
624 | -colors:"FFF FCC FC9 FF9 FFC 9F9 9FF CFF CCF FCF CCC F66 F96 FF6 FF3 6F9 3FF 6FF 99F F9F BBB F00 F90 FC6 FF0 3F3 6CC 3CF 66C C6C 999 C00 F60 FC3 FC0 3C0 0CC 36F 63F C3C 666 900 C60 C93 990 090 399 33F 60C 939 333 600 930 963 660 060 366 009 339 636 000 300 630 633 330 030 033 006 309 303",fonts:"Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond,Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana",sizes:"1,2,3,4,5,6,7",styles:[["Paragraph","<p>"],["Header 1","<h1>"],["Header 2","<h2>"], |
625 | -["Header 3","<h3>"],["Header 4","<h4>"],["Header 5","<h5>"],["Header 6","<h6>"]],useCSS:false,docType:'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',docCSSFile:"",bodyStyle:"margin:4px; font:10pt Arial,Verdana; cursor:text"},buttons:{init:"bold,,|italic,,|underline,,|strikethrough,,|subscript,,|superscript,,|font,,fontname,|size,Font Size,fontsize,|style,,formatblock,|color,Font Color,forecolor,|highlight,Text Highlight Color,hilitecolor,color|removeformat,Remove Formatting,|bullets,,insertunorderedlist|numbering,,insertorderedlist|outdent,,|indent,,|alignleft,Align Text Left,justifyleft|center,,justifycenter|alignright,Align Text Right,justifyright|justify,,justifyfull|undo,,|redo,,|rule,Insert Horizontal Rule,inserthorizontalrule|image,Insert Image,insertimage,url|link,Insert Hyperlink,createlink,url|unlink,Remove Hyperlink,|cut,,|copy,,|paste,,|pastetext,Paste as Text,inserthtml,|print,,|source,Show Source"}, |
626 | -imagesPath:function(){return U()}};e.fn.cleditor=function(a){var b=e([]);this.each(function(c,d){if(d.tagName=="TEXTAREA"){var h=e.data(d,Y);h||(h=new cleditor(d,a));b=b.add(h)}});return b};var H="backgroundColor",A="button",x="buttonName",F="change",Y="cleditor",q="click",n="disabled",m="<div>",I="unselectable",W="cleditorButton",X="cleditorDisabled",ca="cleditorPopup",S="cleditorList",da="cleditorColor",B="cleditorPrompt",fa="cleditorMsg",l=e.browser.msie,ea=/msie\s6/i.test(navigator.userAgent), |
627 | -L=/iphone|ipad|ipod/i.test(navigator.userAgent),p={},Z,s=e.cleditor.buttons;e.each(s.init.split("|"),function(a,b){var c=b.split(","),d=c[0];s[d]={stripIndex:a,name:d,title:c[1]===""?d.charAt(0).toUpperCase()+d.substr(1):c[1],command:c[2]===""?d:c[2],popupName:c[3]===""?d:c[3]}});delete s.init;cleditor=function(a,b){var c=this;c.options=b=e.extend({},e.cleditor.defaultOptions,b);var d=c.$area=e(a).hide().data(Y,c).blur(function(){E(c,true)}),h=c.$main=e(m).addClass("cleditorMain").width(b.width).height(b.height), |
628 | -f=c.$toolbar=e(m).addClass("cleditorToolbar").appendTo(h),i=e(m).addClass("cleditorGroup").appendTo(f);e.each(b.controls.split(" "),function(g,j){if(j==="")return true;if(j=="|"){e(m).addClass("cleditorDivider").appendTo(i);i=e(m).addClass("cleditorGroup").appendTo(f)}else{var k=s[j],o=e(m).data(x,k.name).addClass(W).attr("title",k.title).bind(q,e.proxy(aa,c)).appendTo(i).hover(O,P),G={};if(k.css)G=k.css;else if(k.image)G.backgroundImage="url("+U()+k.image+")";if(k.stripIndex)G.backgroundPosition= |
629 | -k.stripIndex*-24;o.css(G);l&&o.attr(I,"on");k.popupName&&R(k.popupName,b,k.popupClass,k.popupContent,k.popupHover)}});h.insertBefore(d).append(d);if(!Z){e(document).click(function(g){g=e(g.target);g.add(g.parents()).is("."+B)||r()});Z=true}/auto|%/.test(""+b.width+b.height)&&e(window).resize(function(){K(c)});K(c)};var $=cleditor.prototype;e.each([["clear",function(a){a.$area.val("");E(a)}],["disable",T],["execCommand",v],["focus",w],["hidePopups",r],["sourceMode",t,true],["refresh",K],["select", |
630 | -function(a){setTimeout(function(){t(a)?a.$area.select():v(a,"selectall")},0)}],["selectedHTML",function(a){D(a);a=y(a);if(l)return a.htmlText;var b=e("<layer>")[0];b.appendChild(a.cloneContents());return b.innerHTML},true],["selectedText",M,true],["showMessage",z],["updateFrame",E],["updateTextArea",V]],function(a,b){$[b[0]]=function(){for(var c=[this],d=0;d<arguments.length;d++)c.push(arguments[d]);c=b[1].apply(this,c);if(b[2])return c;return this}});$.change=function(a){var b=e(this);return a?b.bind(F, |
631 | -a):b.trigger(F)}})(jQuery); |
632 | \ No newline at end of file |