Revision: 8041 http://languagetool.svn.sourceforge.net/languagetool/?rev=8041&view=rev Author: dnaber Date: 2012-09-14 21:54:50 +0000 (Fri, 14 Sep 2012) Log Message: ----------- wrap lines for long messages
Modified Paths: -------------- trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/atd.core.js Modified: trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js =================================================================== --- trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js 2012-09-14 19:42:55 UTC (rev 8040) +++ trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js 2012-09-14 21:54:50 UTC (rev 8041) @@ -169,7 +169,8 @@ var errors = responseXML.getElementsByTagName('error'); for (var i = 0; i < errors.length; i++) { var suggestion = {}; - suggestion["description"] = errors[i].getAttribute("msg"); + // I didn't manage to make the CSS break the text, so we add breaks with Javascript: + suggestion["description"] = this._wordwrap(errors[i].getAttribute("msg"), 50, "<br/>"); suggestion["suggestions"] = []; var suggestionsStr = errors[i].getAttribute("replacements"); if (suggestionsStr) { @@ -188,7 +189,10 @@ suggestion["string"] = errorString; suggestion["context"] = ""; suggestion["type"] = errors[i].getAttribute("category"); - // TODO: suggestion["moreinfo"] + var url = errors[i].getAttribute("url"); + if (url) { + suggestion["moreinfo"] = url; + } this.suggestions.push(suggestion); var ruleId = errors[i].getAttribute("ruleId"); if (ruleId == "HUNSPELL_NO_SUGGEST_RULE" || ruleId == "HUNSPELL_RULE" || ruleId.indexOf("MORFOLOGIK_RULE") == 0) { @@ -211,6 +215,23 @@ return { errors: errorStruct, count: ecount, suggestions: this.suggestions }; } +// Wrapper code by James Padolsey +// Source: http://james.padolsey.com/javascript/wordwrap-for-javascript/ +// License: "This is free and unencumbered software released into the public domain.", +// see http://james.padolsey.com/terms-conditions/ +AtDCore.prototype._wordwrap = function(str, width, brk, cut) { + brk = brk || '\n'; + width = width || 75; + cut = cut || false; + + if (!str) { return str; } + + var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' : '|\\S+?(\\s|$)'); + + return str.match( RegExp(regex, 'g') ).join( brk ); +} +// End of wrapper code by James Padolsey + // TODO: remove once processXML works fine: AtDCore.prototype.processXMLOriginal = function(responseXML) { Modified: trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/atd.core.js =================================================================== --- trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/atd.core.js 2012-09-14 19:42:55 UTC (rev 8040) +++ trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/atd.core.js 2012-09-14 21:54:50 UTC (rev 8041) @@ -169,7 +169,8 @@ var errors = responseXML.getElementsByTagName('error'); for (var i = 0; i < errors.length; i++) { var suggestion = {}; - suggestion["description"] = errors[i].getAttribute("msg"); + // I didn't manage to make the CSS break the text, so we add breaks with Javascript: + suggestion["description"] = this._wordwrap(errors[i].getAttribute("msg"), 50, "<br/>"); suggestion["suggestions"] = []; var suggestionsStr = errors[i].getAttribute("replacements"); if (suggestionsStr) { @@ -214,6 +215,23 @@ return { errors: errorStruct, count: ecount, suggestions: this.suggestions }; } +// Wrapper code by James Padolsey +// Source: http://james.padolsey.com/javascript/wordwrap-for-javascript/ +// License: "This is free and unencumbered software released into the public domain.", +// see http://james.padolsey.com/terms-conditions/ +AtDCore.prototype._wordwrap = function(str, width, brk, cut) { + brk = brk || '\n'; + width = width || 75; + cut = cut || false; + + if (!str) { return str; } + + var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' : '|\\S+?(\\s|$)'); + + return str.match( RegExp(regex, 'g') ).join( brk ); +} +// End of wrapper code by James Padolsey + // TODO: remove once processXML works fine: AtDCore.prototype.processXMLOriginal = function(responseXML) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Got visibility? Most devs has no idea what their production app looks like. Find out how fast your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219671;13503038;y? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ Languagetool-cvs mailing list Languagetool-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/languagetool-cvs