[spip-dev] Un cas de compactage des js du header privé qui plante FF

Je testais le plugin PortePlume avec le squelette SoyezCréateurs.
Et sur la page de cfg des couleurs du squelette, j'ai une page blanche avec une erreur dans la console de FireBug (oui l'erreur est énorme) :

function (container, callback) {var fb = this;$(container).html("<div class=\"farbtastic\"><div class=\"color\"></div><div class=\"wheel\"></div><div class=\"overlay\"></div><div class=\"h-marker marker\"></div><div class=\"sl-marker marker\"></div></div>");var e = $(".farbtastic", container);fb.wheel = $(".wheel", container).get(0);fb.radius = 84;fb.square = 100;fb.width = 194;if (navigator.appVersion.match(/MSIE [0-6]\./)) {$("*", e).each(function () {if (this.currentStyle.backgroundImage != "none") {var image = this.currentStyle.backgroundImage;image = this.currentStyle.backgroundImage.substring(5, image.length - 2);$(this).css({backgroundImage: "none", filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"});}});}fb.linkTo = function (callback) {if (typeof fb.callback == "object") {$(fb.callback).unbind("keyup", fb.updateValue);}fb.color = null;if (typeof callback == "function") {fb.callback = callback;} else if (typeof callback == "object" || typeof callback == "string") {fb.callback = $(callback);fb.callback.bind("keyup", fb.updateValue);if (fb.callback.get(0).value) {fb.setColor(fb.callback.get(0).value);}}return this;};fb.updateValue = function (event) {if (this.value && this.value != fb.color) {fb.setColor(this.value);}};fb.setColor = function (color) {var unpack = fb.unpack(color);if (fb.color != color && unpack) {fb.color = color;fb.rgb = unpack;fb.hsl = fb.RGBToHSL(fb.rgb);fb.updateDisplay();}return this;};fb.setHSL = function (hsl) {fb.hsl = hsl;fb.rgb = fb.HSLToRGB(hsl);fb.color = fb.pack(fb.rgb);fb.updateDisplay();return this;};fb.widgetCoords = function (event) {var x, y;var el = event.target || event.srcElement;var reference = fb.wheel;if (typeof event.offsetX != "undefined") {var pos = {x: event.offsetX, y: event.offsetY};var e = el;while (e) {e.mouseX = pos.x;e.mouseY = pos.y;pos.x += e.offsetLeft;pos.y += e.offsetTop;e = e.offsetParent;}var e = reference;var offset = {x: 0, y: 0};while (e) {if (typeof e.mouseX != "undefined") {x = e.mouseX - offset.x;y = e.mouseY - offset.y;break;}offset.x += e.offsetLeft;offset.y += e.offsetTop;e = e.offsetParent;}e = el;while (e) {e.mouseX = undefined;e.mouseY = undefined;e = e.offsetParent;}} else {var pos = fb.absolutePosition(reference);x = (event.pageX || 0 * (event.clientX + $("html").get(0).scrollLeft)) - pos.x;y = (event.pageY || 0 * (event.clientY + $("html").get(0).scrollTop)) - pos.y;}return {x: x - fb.width / 2, y: y - fb.width / 2};};fb.mousedown = function (event) {if (!document.dragging) {$(document).bind("mousemove", fb.mousemove).bind("mouseup", fb.mouseup);document.dragging = true;}var pos = fb.widgetCoords(event);fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;fb.mousemove(event);return false;};fb.mousemove = function (event) {var pos = fb.widgetCoords(event);if (fb.circleDrag) {var hue = Math.atan2(pos.x, - pos.y) / 6.28;if (hue < 0) {hue += 1;}fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);} else {var sat = Math.max(0, Math.min(1, - (pos.x / fb.square) + 0.5));var lum = Math.max(0, Math.min(1, - (pos.y / fb.square) + 0.5));fb.setHSL([fb.hsl[0], sat, lum]);}return false;};fb.mouseup = function () {$(document).unbind("mousemove", fb.mousemove);$(document).unbind("mouseup", fb.mouseup);document.dragging = false;};fb.updateDisplay = function () {var angle = fb.hsl[0] * 6.28;$(".h-marker", e).css({left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + "px", top: Math.round(- Math.cos(angle) * fb.radius + fb.width / 2) + "px"});$(".sl-marker", e).css({left: Math.round(fb.square * (0.5 - fb.hsl[1]) + fb.width / 2) + "px", top: Math.round(fb.square * (0.5 - fb.hsl[2]) + fb.width / 2) + "px"});$(".color", e).css("backgroundColor", fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));if (typeof fb.callback == "object") {$(fb.callback).css({backgroundColor: fb.color, color: fb.hsl[2] > 0.5 ? "#000" : "#fff"});$(fb.callback).each(function () {if (this.value && this.value != fb.color) {this.value = fb.color;}});} else if (typeof fb.callback == "function") {fb.callback.call(fb, fb.color);}};fb.absolutePosition = function (el) {var r = {x: el.offsetLeft, y: el.offsetTop};if (el.offsetParent) {var tmp = fb.absolutePosition(el.offsetParent);r.x += tmp.x;r.y += tmp.y;}return r;};fb.pack = function (rgb) {var r = Math.round(rgb[0] * 255);var g = Math.round(rgb[1] * 255);var b = Math.round(rgb[2] * 255);return "#" + (r < 16 ? "0" : "") + r.toString(16) + (g < 16 ? "0" : "") + g.toString(16) + (b < 16 ? "0" : "") + b.toString(16);};fb.unpack = function (color) {if (color.length == 7) {return [parseInt("0x" + color.substring(1, 3)) / 255, parseInt("0x" + color.substring(3, 5)) / 255, parseInt("0x" + color.substring(5, 7)) / 255];} else if (color.length == 4) {return [parseInt("0x" + color.substring(1, 2)) / 15, parseInt("0x" + color.substring(2, 3)) / 15, parseInt("0x" + color.substring(3, 4)) / 15];}};fb.HSLToRGB = function (hsl) {var m1, m2, r, g, b;var h = hsl[0], s = hsl[1], l = hsl[2];m2 = (l <= 0.5) ? l * (s + 1) : l + s - l * s;m1 = l * 2 - m2;return [this.hueToRGB(m1, m2, h + 0.33333), this.hueToRGB(m1, m2, h), this.hueToRGB(m1, m2, h - 0.33333)];};fb.hueToRGB = function (m1, m2, h) {h = (h < 0) ? h + 1 : (h > 1) ? h - 1 : h;if (h * 6 < 1) {return m1 + (m2 - m1) * h * 6;}if (h * 2 < 1) {return m2;}if (h * 3 < 2) {return m1 + (m2 - m1) * (0.66666 - h) * 6;}return m1;};fb.RGBToHSL = function (rgb) {var min, max, delta, h, s, l;var r = rgb[0], g = rgb[1], b = rgb[2];min = Math.min(r, Math.min(g, b));max = Math.max(r, Math.max(g, b));delta = max - min;l = (min + max) / 2;s = 0;if (l > 0 && l < 1) {s = delta / (l < 0.5 ? 2 * l : 2 - 2 * l);}h = 0;if (delta > 0) {if (max == r && max != g) {h += (g - b) / delta;}if (max == g && max != b) {h += (2 + (b - r) / delta);}if (max == b && max != r) {h += (4 + (r - g) / delta);}h /= 6;}return [h, s, l];};$("*", e).mousedown(fb.mousedown);fb.setColor("#000000");if (callback) {fb.linkTo(callback);}}(function ($) {$.fn.markItUp = function (settings, extraSettings) {var options, ctrlKey, shiftKey, altKey, enterKey;ctrlKey = shiftKey = altKey = enterKey = false;options = {id: "", nameSpace: "", root: "", lang: "", previewInWindow: "", previewAutoRefresh: true, previewPosition: "after", previewTemplatePath: "~/templates/preview.html", previewParserPath: "", previewParserVar: "data", resizeHandle: true, beforeInsert: "", afterInsert: "", onEnter: {}, onShiftEnter: {}, onCtrlEnter: {}, onTab: {}, markupSet: [{}]};$.extend(options, settings, extraSettings);if (!options.root) {$("script").each(function (a, tag) {miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);if (miuScript !== null) {options.root = miuScript[1];}});}return this.each(function () {var $$, textarea, levels, scrollPosition, caretPosition, caretEffectivePosition, clicked, hash, header, footer, previewWindow, template, iFrame, abort, before, after;$$ = $(this);textarea = this;levels = ;abort = false;scrollPosition = caretPosition = 0;options.previewParserPath = localize(options.previewParserPath);options.previewTemplatePath = localize(options.previewTemplatePath);
function localize(data, inText) {if (inText) {return data.replace(/("|')~\//g, "$1" + options.root);}return data.replace(/^~\//, options.root);}

function init() {id = "";nameSpace = "";if (options.id) {id = "id=\"" + options.id + "\"";} else if ($$.attr("id")) {id = "id=\"markItUp" + $$.attr("id").substr(0, 1).toUpperCase() + $$.attr("id").substr(1) + "\"";}if (options.nameSpace) {nameSpace = "class=\"" + options.nameSpace + "\"";}$$.wrap("<div " + nameSpace + "></div>");$$.wrap("<div " + id + " class=\"markItUp\"></div>");$$.wrap("<div class=\"markItUpContainer\"></div>");$$.addClass("markItUpEditor");header = $("<div class=\"markItUpHeader\"></div>").insertBefore($$);$(dropMenus(options.markupSet)).appendTo(header);$(header).find("li.markItUpDropMenu ul:empty").parent().remove();footer = $("<div class=\"markItUpFooter\"></div>").insertAfter($$);if (options.resizeHandle === true && $.browser.safari !== true) {resizeHandle = $("<div class=\"markItUpResizeHandle\"></div>").insertAfter($$).bind("mousedown", function (e) {var h = $$.height(), y = e.clientY, mouseMove, mouseUp;mouseMove = function (e) {$$.css("height", Math.max(20, e.clientY + h - y) + "px");return false;};mouseUp = function (e) {$("html").unbind("mousemove", mouseMove).unbind("mouseup", mouseUp);return false;};$("html").bind("mousemove", mouseMove).bind("mouseup", mouseUp);});footer.append(resizeHandle);}$$.keydown(keyPressed).keyup(keyPressed);$$.bind("insertion", function (e, settings) {if (settings.target !== false) {get();}if (textarea === $.markItUp.focused) {markup(settings);}});$$.focus(function () {$.markItUp.focused = this;});}

function dropMenus(markupSet) {var ul = $("<ul></ul>"), i = 0;var lang = $$.attr("lang") || options.lang;$("li:hover > ul", ul).css("display", "block");$.each(markupSet, function () {var button = this, t = "", title, li, j;if ((!lang || !button.lang || $.inArray(lang, button.lang) != -1) && (!button.lang_not || $.inArray(lang, button.lang_not) == -1)) {title = button.key ? (button.name || "") + " [Ctrl+" + button.key + "]" : button.name || "";key = button.key ? "accesskey=\"" + button.key + "\"" : "";if (button.separator) {li = $("<li class=\"markItUpSeparator\">" + (button.separator || "") + "</li>").appendTo(ul);} else {i++;for (j = levels.length - 1; j >= 0; j--) {t += levels[j] + "-";}li = $("<li class=\"markItUpButton markItUpButton" + t + i + " " + (button.className || "") + "\"><a href=\"\" " + key + " title=\"" + title + "\">" + (button.name || "") + "</a></li>").bind("contextmenu", function () {return false;}).click(function () {return false;}).mouseup(function () {if (button.call) {eval(button.call)();}markup(button);return false;}).hover(function () {$("> ul", this).show();$(document).one("click", function () {$("ul ul", header).hide();});}, function () {$("> ul", this).hide();}).appendTo(ul);if (button.dropMenu) {levels.push(i);$(li).addClass("markItUpDropMenu").append(dropMenus(button.dropMenu));}}}});levels.pop();return ul;}

function magicMarkups(string) {if (string) {string = string.toString();string = string.replace(/\(\!\(([\s\S]*?)\)\!\)/g, function (x, a) {var b = a.split("|!|");if (altKey === true) {return (b[1] !== undefined) ? b[1] : b[0];} else {return (b[1] === undefined) ? "" : b[0];}});string = string.replace(/\[\!\[([\s\S]*?)\]\!\]/g, function (x, a) {var b = a.split(":!:");if (abort === true) {return false;}value = prompt(b[0], b[1] ? b[1] : "");if (value === null) {abort = true;}return value;});return string;}return "";}

function prepare(action) {if ($.isFunction(action)) {action = action(hash);}return magicMarkups(action);}

function build(string) {openWith = prepare(clicked.openWith);placeHolder = prepare(clicked.placeHolder);replaceWith = prepare(clicked.replaceWith);closeWith = prepare(clicked.closeWith);if (replaceWith !== "") {block = openWith + replaceWith + closeWith;} else if (selection === "" && placeHolder !== "") {block = openWith + placeHolder + closeWith;} else {block = openWith + (string || selection) + closeWith;}return {block: block, openWith: openWith, replaceWith: replaceWith, placeHolder: placeHolder, closeWith: closeWith};}

function selectWord() {selectionBeforeAfter(/\s|[.,;:!¡?¿()]/);selectionSave();}

function selectLine() {selectionBeforeAfter(/\r?\n/);selectionSave();}

function selectionRemoveLast(pattern) {if (!pattern) {pattern = /\s/;}last = selection[selection.length - 1];if (last && last.match(pattern)) {set(caretPosition, selection.length - 1);get();$.extend(hash, {caretPosition: caretPosition, scrollPosition: scrollPosition});}}

function selectionBeforeAfter(pattern) {if (!pattern) {pattern = /\s/;}before = $$.val().substring(0, caretEffectivePosition);after = $$.val().substring(caretEffectivePosition + selection.length - fixOperaBug(selection) - fixIeBug(selection));before = before.xSplit(pattern);after = after.xSplit(pattern);}

function selectionSave() {nb_before = before ? before[before.length - 1].length : 0;nb_after = after ? after[0].length : 0;nb = nb_before + selection.length + nb_after - fixIeBug(selection);caretPosition = caretPosition - nb_before;set(caretPosition, nb);get();$.extend(hash, {caretPosition: caretPosition, scrollPosition: scrollPosition});}

function markup(button) {var len, j, n, i;hash = clicked = button;get();$.extend(hash, {line: "", root: options.root, textarea: textarea, selection: selection || "", caretPosition: caretPosition, ctrlKey: ctrlKey, shiftKey: shiftKey, altKey: altKey, enterKey: enterKey});if (button.selectionType) {if (button.selectionType == "word") {if (!selection) {selectWord();} else {selectionRemoveLast(/\s/);}}if (button.selectionType == "line") {selectLine();}if (button.selectionType == "return") {selectionBeforeAfter(/\r?\n/);before_last = before[before.length - 1];after = "";if (r = before_last.match(/^-([*#]+) ?(.*)$/)) {if (r[2]) {button.replaceWith = "\n-" + r[1] + " ";before_last = "";} else {button.replaceWith = "\n";}} else {before_last = "";button.replaceWith = "\n";}before[before.length - 1] = before_last;selectionSave();}}prepare(options.beforeInsert);prepare(clicked.beforeInsert);if (ctrlKey === true && shiftKey === true) {prepare(clicked.beforeMultiInsert);}$.extend(hash, {line: 1});if (button.forceMultiline === true && selection.length || (ctrlKey === true && shiftKey === true)) {lines = selection.xSplit(/\r?\n/);for (j = 0, n = lines.length, i = 0; i < n; i++) {if ($.trim(lines[i]) !== "") {$.extend(hash, {line: ++j, selection: lines[i]});lines[i] = build(lines[i]).block;} else {lines[i] = "";}}string = {block: lines.join("\n")};start = caretPosition;len = string.block.length + ($.browser.opera ? n : 0);} else if (ctrlKey === true) {string = build(selection);start = caretPosition + string.openWith.length;len = string.block.length - string.openWith.length - string.closeWith.length;len -= fixIeBug(string.block);} else if (shiftKey === true) {string = build(selection);start = caretPosition;len = string.block.length;len -= fixIeBug(string.block);} else {string = build(selection);start = caretPosition + string.block.length;len = 0;start -= fixIeBug(string.block);}if (selection === "") {start += fixOperaBug(string.replaceWith);}if (string.block !== selection && abort === false) {insert(string.block);set(start, len);}get();$.extend(hash, {line: "", selection: selection});if (button.forceMultiline === true || (ctrlKey === true && shiftKey === true)) {prepare(clicked.afterMultiInsert);}prepare(clicked.afterInsert);prepare(options.afterInsert);if (previewWindow && options.previewAutoRefresh) {refreshPreview();}shiftKey = altKey = ctrlKey = enterKey = abort = false;}

function fixOperaBug(string) {if ($.browser.opera) {return string.length - string.replace(/\n*/g, "").length;}return 0;}

function fixIeBug(string) {if ($.browser.msie) {return string.length - string.replace(/\r*/g, "").length;}return 0;}

function insert(block) {if (document.selection) {var newSelection = document.selection.createRange();newSelection.text = block;} else {$$.val($$.val().substring(0, caretEffectivePosition) + block + $$.val().substring(caretEffectivePosition + selection.length));}}

function set(start, len) {if (textarea.createTextRange) {range = textarea.createTextRange();range.collapse(true);range.moveStart("character", start);range.moveEnd("character", len);range.select();} else if (textarea.setSelectionRange) {textarea.setSelectionRange(start, start + len);}textarea.scrollTop = scrollPosition;textarea.focus();}

function get() {textarea.focus();scrollPosition = textarea.scrollTop;if (document.selection) {selection = document.selection.createRange().text;if ($.browser.msie) {var range = document.selection.createRange(), rangeCopy = range.duplicate();rangeCopy.moveToElementText(textarea);caretPosition = -1;while (rangeCopy.inRange(range)) {rangeCopy.moveStart("character");caretPosition++;}caretEffectivePosition = caretPosition;} else {caretPosition = textarea.selectionStart;lenSelection = selection.length;set(0, caretPosition);opBefore = document.selection.createRange().text;caretEffectivePosition = opBefore.length - fixOperaBug(opBefore);set(caretPosition, lenSelection);selection = document.selection.createRange().text;}} else {caretPosition = textarea.selectionStart;caretEffectivePosition = caretPosition;selection = $$.val().substring(caretPosition, textarea.selectionEnd);}return selection;}

function preview() {if (!previewWindow || previewWindow.closed) {if (options.previewInWindow) {previewWindow = window.open("", "preview", options.previewInWindow);} else {iFrame = $("<iframe class=\"markItUpPreviewFrame\"></iframe>");if (options.previewPosition == "after") {iFrame.insertAfter(footer);} else {iFrame.insertBefore(header);}previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1];}} else if (altKey === true) {if (iFrame) {iFrame.remove();}previewWindow.close();previewWindow = iFrame = false;}if (!options.previewAutoRefresh) {refreshPreview();}}

function refreshPreview() {if (previewWindow.document) {try {sp = previewWindow.document.documentElement.scrollTop;} catch (e) {sp = 0;}previewWindow.document.open();previewWindow.document.write(renderPreview());previewWindow.document.close();previewWindow.document.documentElement.scrollTop = sp;}if (options.previewInWindow) {previewWindow.focus();}}

function renderPreview() {if (options.previewParserPath !== "") {$.ajax({type: "POST", async: false, url: options.previewParserPath, data: options.previewParserVar + "=" + encodeURIComponent($$.val()), success: function (data) {phtml = localize(data, 1);}});} else {if (!template) {$.ajax({async: false, url: options.previewTemplatePath, success: function (data) {template = localize(data, 1);}});}phtml = template.replace(/<!-- content -->/g, $$.val());}return phtml;}

function keyPressed(e) {if (e.type === "keydown") {if (e.keyCode === 18) {e.altKey = true;}if (e.keyCode === 17) {e.ctrlKey = true;}if (e.keyCode === 16) {e.shiftKey = true;}}shiftKey = e.shiftKey;altKey = e.altKey;ctrlKey = (!(e.altKey && e.ctrlKey)) ? e.ctrlKey : false;if (e.type === "keydown") {if (ctrlKey === true) {li = $("a[accesskey=" + String.fromCharCode(e.keyCode) + "]", header).parent("li");if (li.length !== 0) {ctrlKey = false;li.triggerHandler("mouseup");return false;}}if (!$.browser.opera) {if (e.keyCode === 13 || e.keyCode === 10) {enterKey = true;if (ctrlKey === true) {ctrlKey = false;markup(options.onCtrlEnter);return options.onCtrlEnter.keepDefault;} else if (shiftKey === true) {shiftKey = false;markup(options.onShiftEnter);return options.onShiftEnter.keepDefault;} else {markup(options.onEnter);return options.onEnter.keepDefault;}}if (e.keyCode === 9) {if (shiftKey == true

ctrlKey == true || altKey == true) {return

false;}markup(options.onTab);return options.onTab.keepDefault;}}}}

init();});};$.fn.markItUpRemove = function () {return this.each(function () {$$ = $(this).unbind().removeClass("markItUpEditor");$$.parent("div").parent("div.markItUp").parent("div").replaceWith($$);});};$.markItUp = function (settings) {var options = {target: false};$.extend(options, settings);if (options.target) {return $(options.target).each(function () {$(this).focus();$(this).trigger("insertion", [options]);});} else {$("textarea").trigger("insertion", [options]);}};}) is not a function
http://dev.sc/sites/dev.sc/local/cache-js/5726b45a5341dcf15cb402f9527773fe.js
Line 3427

En désactivant la compression ça passe (avec define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true):wink:

* RealET tapuscrivait, le 25/02/2009 17:37:

Je testais le plugin PortePlume avec le squelette SoyezCréateurs.
Et sur la page de cfg des couleurs du squelette, j'ai une page blanche avec une erreur dans la console de FireBug (oui l'erreur est énorme) :

SNIP

En désactivant la compression ça passe (avec define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true):wink:

En prenant la version 1.3 de farbtastic de kent1, ça plante pareil.

* RealET tapuscrivait, le 26/02/2009 08:50:

* RealET tapuscrivait, le 25/02/2009 17:37:

Je testais le plugin PortePlume avec le squelette SoyezCréateurs.
Et sur la page de cfg des couleurs du squelette, j'ai une page blanche avec une erreur dans la console de FireBug (oui l'erreur est énorme) :

SNIP

En désactivant la compression ça passe (avec define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true):wink:

En prenant la version 1.3 de farbtastic de kent1, ça plante pareil.

Oups, j'avais pas vidé le cache de SPIP : ça plante plus, merci kent1 !