# HG changeset patch # User olivier # Date 1443693038 -7200 # Thu Oct 01 11:50:38 2015 +0200 # Branch 3.1-stable # Node ID 3eb3b8fb10111e0215ff991ba072fd4f4b07d6bc # Parent afa2be8909ac662ee169d97aaf4580e95d3a6814 Add a Table button to the Textile toolbar to convert tabulated text into textile table syntax. diff -r afa2be8909ac -r 3eb3b8fb1011 public/images/jstoolbar/bt_table.png Binary file public/images/jstoolbar/bt_table.png has changed diff -r afa2be8909ac -r 3eb3b8fb1011 public/javascripts/jstoolbar/jstoolbar-textile.min.js --- a/public/javascripts/jstoolbar/jstoolbar-textile.min.js Sun Sep 20 06:18:15 2015 +0000 +++ b/public/javascripts/jstoolbar/jstoolbar-textile.min.js Thu Oct 01 11:50:38 2015 +0200 @@ -1,2 +1,1 @@ -function jsToolBar(e){if(!document.createElement){return}if(!e){return}if(typeof document["selection"]=="undefined"&&typeof e["setSelectionRange"]=="undefined"){return}this.textarea=e;this.editor=document.createElement("div");this.editor.className="jstEditor";this.textarea.parentNode.insertBefore(this.editor,this.textarea);this.editor.appendChild(this.textarea);this.toolbar=document.createElement("div");this.toolbar.className="jstElements";this.editor.parentNode.insertBefore(this.toolbar,this.editor);if(this.editor.addEventListener&&navigator.appVersion.match(/\bMSIE\b/)){this.handle=document.createElement("div");this.handle.className="jstHandle";var t=this.resizeDragStart;var n=this;this.handle.addEventListener("mousedown",function(e){t.call(n,e)},false);window.addEventListener("unload",function(){var e=n.handle.parentNode.removeChild(n.handle);delete n.handle},false);this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling)}this.context=null;this.toolNodes={}}function jsButton(e,t,n,r){if(typeof jsToolBar.strings=="undefined"){this.title=e||null}else{this.title=jsToolBar.strings[e]||e||null}this.fn=t||function(){};this.scope=n||null;this.className=r||null}function jsSpace(e){this.id=e||null;this.width=null}function jsCombo(e,t,n,r,i){this.title=e||null;this.options=t||null;this.scope=n||null;this.fn=r||function(){};this.className=i||null}jsButton.prototype.draw=function(){if(!this.scope)return null;var e=document.createElement("button");e.setAttribute("type","button");e.tabIndex=200;if(this.className)e.className=this.className;e.title=this.title;var t=document.createElement("span");t.appendChild(document.createTextNode(this.title));e.appendChild(t);if(this.icon!=undefined){e.style.backgroundImage="url("+this.icon+")"}if(typeof this.fn=="function"){var n=this;e.onclick=function(){try{n.fn.apply(n.scope,arguments)}catch(e){}return false}}return e};jsSpace.prototype.draw=function(){var e=document.createElement("span");if(this.id)e.id=this.id;e.appendChild(document.createTextNode(String.fromCharCode(160)));e.className="jstSpacer";if(this.width)e.style.marginRight=this.width+"px";return e};jsCombo.prototype.draw=function(){if(!this.scope||!this.options)return null;var e=document.createElement("select");if(this.className)e.className=className;e.title=this.title;for(var t in this.options){var n=document.createElement("option");n.value=t;n.appendChild(document.createTextNode(this.options[t]));e.appendChild(n)}var r=this;e.onchange=function(){try{r.fn.call(r.scope,this.value)}catch(e){alert(e)}return false};return e};jsToolBar.prototype={base_url:"",mode:"wiki",elements:{},help_link:"",getMode:function(){return this.mode},setMode:function(e){this.mode=e||"wiki"},switchMode:function(e){e=e||"wiki";this.draw(e)},setHelpLink:function(e){this.help_link=e},button:function(e){var t=this.elements[e];if(typeof t.fn[this.mode]!="function")return null;var n=new jsButton(t.title,t.fn[this.mode],this,"jstb_"+e);if(t.icon!=undefined)n.icon=t.icon;return n},space:function(e){var t=new jsSpace(e);if(this.elements[e].width!==undefined)t.width=this.elements[e].width;return t},combo:function(e){var t=this.elements[e];var n=t[this.mode].list.length;if(typeof t[this.mode].fn!="function"||n==0){return null}else{var r={};for(var i=0;i $2")})}}};jsToolBar.prototype.elements.unbq={type:"button",title:"Unquote",fn:{wiki:function(){this.encloseLineSelection("","",function(e){e=e.replace(/\r/g,"");return e.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2")})}}};jsToolBar.prototype.elements.pre={type:"button",title:"Preformatted text",fn:{wiki:function(){this.encloseLineSelection("
\n","\n
")}}};jsToolBar.prototype.elements.space4={type:"space"};jsToolBar.prototype.elements.link={type:"button",title:"Wiki link",fn:{wiki:function(){this.encloseSelection("[[","]]")}}};jsToolBar.prototype.elements.img={type:"button",title:"Image",fn:{wiki:function(){this.encloseSelection("!","!")}}};jsToolBar.prototype.elements.space5={type:"space"};jsToolBar.prototype.elements.help={type:"button",title:"Help",fn:{wiki:function(){window.open(this.help_link,"","resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes")}}} +function jsToolBar(e){if(!document.createElement){return}if(!e){return}if(typeof document["selection"]=="undefined"&&typeof e["setSelectionRange"]=="undefined"){return}this.textarea=e;this.editor=document.createElement("div");this.editor.className="jstEditor";this.textarea.parentNode.insertBefore(this.editor,this.textarea);this.editor.appendChild(this.textarea);this.toolbar=document.createElement("div");this.toolbar.className="jstElements";this.editor.parentNode.insertBefore(this.toolbar,this.editor);if(this.editor.addEventListener&&navigator.appVersion.match(/\bMSIE\b/)){this.handle=document.createElement("div");this.handle.className="jstHandle";var t=this.resizeDragStart;var n=this;this.handle.addEventListener("mousedown",function(e){t.call(n,e)},false);window.addEventListener("unload",function(){var e=n.handle.parentNode.removeChild(n.handle);delete n.handle},false);this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling)}this.context=null;this.toolNodes={}}function jsButton(e,t,n,r){if(typeof jsToolBar.strings=="undefined"){this.title=e||null}else{this.title=jsToolBar.strings[e]||e||null}this.fn=t||function(){};this.scope=n||null;this.className=r||null}function jsSpace(e){this.id=e||null;this.width=null}function jsCombo(e,t,n,r,i){this.title=e||null;this.options=t||null;this.scope=n||null;this.fn=r||function(){};this.className=i||null}jsButton.prototype.draw=function(){if(!this.scope)return null;var e=document.createElement("button");e.setAttribute("type","button");e.tabIndex=200;if(this.className)e.className=this.className;e.title=this.title;var t=document.createElement("span");t.appendChild(document.createTextNode(this.title));e.appendChild(t);if(this.icon!=undefined){e.style.backgroundImage="url("+this.icon+")"}if(typeof this.fn=="function"){var n=this;e.onclick=function(){try{n.fn.apply(n.scope,arguments)}catch(e){}return false}}return e};jsSpace.prototype.draw=function(){var e=document.createElement("span");if(this.id)e.id=this.id;e.appendChild(document.createTextNode(String.fromCharCode(160)));e.className="jstSpacer";if(this.width)e.style.marginRight=this.width+"px";return e};jsCombo.prototype.draw=function(){if(!this.scope||!this.options)return null;var e=document.createElement("select");if(this.className)e.className=className;e.title=this.title;for(var t in this.options){var n=document.createElement("option");n.value=t;n.appendChild(document.createTextNode(this.options[t]));e.appendChild(n)}var r=this;e.onchange=function(){try{r.fn.call(r.scope,this.value)}catch(e){alert(e)}return false};return e};jsToolBar.prototype={base_url:"",mode:"wiki",elements:{},help_link:"",getMode:function(){return this.mode},setMode:function(e){this.mode=e||"wiki"},switchMode:function(e){e=e||"wiki";this.draw(e)},setHelpLink:function(e){this.help_link=e},button:function(e){var t=this.elements[e];if(typeof t.fn[this.mode]!="function")return null;var n=new jsButton(t.title,t.fn[this.mode],this,"jstb_"+e);if(t.icon!=undefined)n.icon=t.icon;return n},space:function(e){var t=new jsSpace(e);if(this.elements[e].width!==undefined)t.width=this.elements[e].width;return t},combo:function(e){var t=this.elements[e];var n=t[this.mode].list.length;if(typeof t[this.mode].fn!="function"||n==0){return null}else{var r={};for(var i=0;i $2")})}}};jsToolBar.prototype.elements.unbq={type:"button",title:"Unquote",fn:{wiki:function(){this.encloseLineSelection("","",function(e){e=e.replace(/\r/g,"");return e.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2")})}}};jsToolBar.prototype.elements.pre={type:"button",title:"Preformatted text",fn:{wiki:function(){this.encloseLineSelection("
\n","\n
")}}};jsToolBar.prototype.elements.space4={type:"space"};jsToolBar.prototype.elements.link={type:"button",title:"Wiki link",fn:{wiki:function(){this.encloseSelection("[[","]]")}}};jsToolBar.prototype.elements.img={type:"button",title:"Image",fn:{wiki:function(){this.encloseSelection("!","!")}}};jsToolBar.prototype.elements.space6={type:"space"};jsToolBar.prototype.elements.table={type:"button",title:"Table",fn:{wiki:function(){this.encloseSelection("","", function(e){e=e.replace(/\r/g,"");e=e.replace(/(\t)/g,"|");e=e.replace(/^(.+)$/gm,"|$1|");return e})}}};jsToolBar.prototype.elements.space5={type:"space"};jsToolBar.prototype.elements.help={type:"button",title:"Help",fn:{wiki:function(){window.open(this.help_link,"","resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes")}}}; diff -r afa2be8909ac -r 3eb3b8fb1011 public/javascripts/jstoolbar/lang/jstoolbar-en.js --- a/public/javascripts/jstoolbar/lang/jstoolbar-en.js Sun Sep 20 06:18:15 2015 +0000 +++ b/public/javascripts/jstoolbar/lang/jstoolbar-en.js Thu Oct 01 11:50:38 2015 +0200 @@ -14,3 +14,4 @@ jsToolBar.strings['Preformatted text'] = 'Preformatted text'; jsToolBar.strings['Wiki link'] = 'Link to a Wiki page'; jsToolBar.strings['Image'] = 'Image'; +jsToolBar.strings['Table'] = 'Table'; diff -r afa2be8909ac -r 3eb3b8fb1011 public/javascripts/jstoolbar/lang/jstoolbar-fr.js --- a/public/javascripts/jstoolbar/lang/jstoolbar-fr.js Sun Sep 20 06:18:15 2015 +0000 +++ b/public/javascripts/jstoolbar/lang/jstoolbar-fr.js Thu Oct 01 11:50:38 2015 +0200 @@ -14,3 +14,4 @@ jsToolBar.strings['Preformatted text'] = 'Texte préformaté'; jsToolBar.strings['Wiki link'] = 'Lien vers une page Wiki'; jsToolBar.strings['Image'] = 'Image'; +jsToolBar.strings['Table'] = 'Tableau'; diff -r afa2be8909ac -r 3eb3b8fb1011 public/javascripts/jstoolbar/textile.js --- a/public/javascripts/jstoolbar/textile.js Sun Sep 20 06:18:15 2015 +0000 +++ b/public/javascripts/jstoolbar/textile.js Thu Oct 01 11:50:38 2015 +0200 @@ -200,6 +200,24 @@ } // spacer +jsToolBar.prototype.elements.space6={type:"space"}; +// table +jsToolBar.prototype.elements.table={ + type: 'button', + title: 'Table', + fn: { + wiki:function() { + this.encloseSelection("","", function(e){ + e=e.replace(/\r/g,""); + e=e.replace(/(\t)/g,"|"); + e=e.replace(/^(.+)$/gm,"|$1|"); + return e; + }) + } + } +} + +// spacer jsToolBar.prototype.elements.space5 = {type: 'space'} // help jsToolBar.prototype.elements.help = { @@ -209,3 +227,4 @@ wiki: function() { window.open(this.help_link, '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes') } } } + diff -r afa2be8909ac -r 3eb3b8fb1011 public/stylesheets/jstoolbar.css --- a/public/stylesheets/jstoolbar.css Sun Sep 20 06:18:15 2015 +0000 +++ b/public/stylesheets/jstoolbar.css Thu Oct 01 11:50:38 2015 +0200 @@ -95,6 +95,9 @@ .jstb_img { background-image: url(../images/jstoolbar/bt_img.png); } +.jstb_table { + background-image: url(../images/jstoolbar/bt_table.png); +} .jstb_help { background-image: url(../images/help.png); }