diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-30 08:56:02 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-30 08:56:02 +0000 |
commit | 0ef82b3dcf7f39ae1ff10cfa2e367c30987549fb (patch) | |
tree | a839890287a91e0b71bbb397725d1178316b4cf2 | |
parent | a1d156d79448c41bdb8dd52439556ffb7f2d6dab (diff) | |
download | redmine-0ef82b3dcf7f39ae1ff10cfa2e367c30987549fb.tar.gz redmine-0ef82b3dcf7f39ae1ff10cfa2e367c30987549fb.zip |
Removes textarea resizer in favour of built-in browser support.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10894 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | public/javascripts/jstoolbar/jstoolbar-textile.min.js | 2 | ||||
-rw-r--r-- | public/javascripts/jstoolbar/jstoolbar.js | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/public/javascripts/jstoolbar/jstoolbar-textile.min.js b/public/javascripts/jstoolbar/jstoolbar-textile.min.js index 5d2c9a46e..50804429e 100644 --- a/public/javascripts/jstoolbar/jstoolbar-textile.min.js +++ b/public/javascripts/jstoolbar/jstoolbar-textile.min.js @@ -1 +1 @@ -function jsToolBar(a){if(!document.createElement){return}if(!a){return}if(typeof document["selection"]=="undefined"&&typeof a["setSelectionRange"]=="undefined"){return}this.textarea=a;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){this.handle=document.createElement("div");this.handle.className="jstHandle";var b=this.resizeDragStart;var c=this;this.handle.addEventListener("mousedown",function(a){b.call(c,a)},false);window.addEventListener("unload",function(){var a=c.handle.parentNode.removeChild(c.handle);delete c.handle},false);this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling)}this.context=null;this.toolNodes={}}function jsButton(a,b,c,d){if(typeof jsToolBar.strings=="undefined"){this.title=a||null}else{this.title=jsToolBar.strings[a]||a||null}this.fn=b||function(){};this.scope=c||null;this.className=d||null}function jsSpace(a){this.id=a||null;this.width=null}function jsCombo(a,b,c,d,e){this.title=a||null;this.options=b||null;this.scope=c||null;this.fn=d||function(){};this.className=e||null}jsButton.prototype.draw=function(){if(!this.scope)return null;var a=document.createElement("button");a.setAttribute("type","button");a.tabIndex=200;if(this.className)a.className=this.className;a.title=this.title;var b=document.createElement("span");b.appendChild(document.createTextNode(this.title));a.appendChild(b);if(this.icon!=undefined){a.style.backgroundImage="url("+this.icon+")"}if(typeof this.fn=="function"){var c=this;a.onclick=function(){try{c.fn.apply(c.scope,arguments)}catch(a){}return false}}return a};jsSpace.prototype.draw=function(){var a=document.createElement("span");if(this.id)a.id=this.id;a.appendChild(document.createTextNode(String.fromCharCode(160)));a.className="jstSpacer";if(this.width)a.style.marginRight=this.width+"px";return a};jsCombo.prototype.draw=function(){if(!this.scope||!this.options)return null;var a=document.createElement("select");if(this.className)a.className=className;a.title=this.title;for(var b in this.options){var c=document.createElement("option");c.value=b;c.appendChild(document.createTextNode(this.options[b]));a.appendChild(c)}var d=this;a.onchange=function(){try{d.fn.call(d.scope,this.value)}catch(a){alert(a)}return false};return a};jsToolBar.prototype={base_url:"",mode:"wiki",elements:{},help_link:"",getMode:function(){return this.mode},setMode:function(a){this.mode=a||"wiki"},switchMode:function(a){a=a||"wiki";this.draw(a)},setHelpLink:function(a){this.help_link=a},button:function(a){var b=this.elements[a];if(typeof b.fn[this.mode]!="function")return null;var c=new jsButton(b.title,b.fn[this.mode],this,"jstb_"+a);if(b.icon!=undefined)c.icon=b.icon;return c},space:function(a){var b=new jsSpace(a);if(this.elements[a].width!==undefined)b.width=this.elements[a].width;return b},combo:function(a){var b=this.elements[a];var c=b[this.mode].list.length;if(typeof b[this.mode].fn!="function"||c==0){return null}else{var d={};for(var e=0;e<c;e++){var f=b[this.mode].list[e];d[f]=b.options[f]}return new jsCombo(b.title,d,this,b[this.mode].fn)}},draw:function(a){this.setMode(a);while(this.toolbar.hasChildNodes()){this.toolbar.removeChild(this.toolbar.firstChild)}this.toolNodes={};var b=document.createElement("div");b.className="help";b.innerHTML=this.help_link;"<a href=\"/help/wiki_syntax.html\" onclick=\"window.open('/help/wiki_syntax.html', '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes'); return false;\">Aide</a>";this.toolbar.appendChild(b);var c,d,e;for(var f in this.elements){c=this.elements[f];var g=c.type==undefined||c.type==""||c.disabled!=undefined&&c.disabled||c.context!=undefined&&c.context!=null&&c.context!=this.context;if(!g&&typeof this[c.type]=="function"){d=this[c.type](f);if(d)e=d.draw();if(e){this.toolNodes[f]=e;this.toolbar.appendChild(e)}}}},singleTag:function(a,b){a=a||null;b=b||a;if(!a||!b){return}this.encloseSelection(a,b)},encloseLineSelection:function(a,b,c){this.textarea.focus();a=a||"";b=b||"";var d,e,f,g,h,i;if(typeof document["selection"]!="undefined"){f=document.selection.createRange().text}else if(typeof this.textarea["setSelectionRange"]!="undefined"){d=this.textarea.selectionStart;e=this.textarea.selectionEnd;g=this.textarea.scrollTop;d=this.textarea.value.substring(0,d).replace(/[^\r\n]*$/g,"").length;e=this.textarea.value.length-this.textarea.value.substring(e,this.textarea.value.length).replace(/^[^\r\n]*/,"").length;f=this.textarea.value.substring(d,e)}if(f.match(/ $/)){f=f.substring(0,f.length-1);b=b+" "}if(typeof c=="function"){i=f?c.call(this,f):c("")}else{i=f?f:""}h=a+i+b;if(typeof document["selection"]!="undefined"){document.selection.createRange().text=h;var j=this.textarea.createTextRange();j.collapse(false);j.move("character",-b.length);j.select()}else if(typeof this.textarea["setSelectionRange"]!="undefined"){this.textarea.value=this.textarea.value.substring(0,d)+h+this.textarea.value.substring(e);if(f){this.textarea.setSelectionRange(d+h.length,d+h.length)}else{this.textarea.setSelectionRange(d+a.length,d+a.length)}this.textarea.scrollTop=g}},encloseSelection:function(a,b,c){this.textarea.focus();a=a||"";b=b||"";var d,e,f,g,h,i;if(typeof document["selection"]!="undefined"){f=document.selection.createRange().text}else if(typeof this.textarea["setSelectionRange"]!="undefined"){d=this.textarea.selectionStart;e=this.textarea.selectionEnd;g=this.textarea.scrollTop;f=this.textarea.value.substring(d,e)}if(f.match(/ $/)){f=f.substring(0,f.length-1);b=b+" "}if(typeof c=="function"){i=f?c.call(this,f):c("")}else{i=f?f:""}h=a+i+b;if(typeof document["selection"]!="undefined"){document.selection.createRange().text=h;var j=this.textarea.createTextRange();j.collapse(false);j.move("character",-b.length);j.select()}else if(typeof this.textarea["setSelectionRange"]!="undefined"){this.textarea.value=this.textarea.value.substring(0,d)+h+this.textarea.value.substring(e);if(f){this.textarea.setSelectionRange(d+h.length,d+h.length)}else{this.textarea.setSelectionRange(d+a.length,d+a.length)}this.textarea.scrollTop=g}},stripBaseURL:function(a){if(this.base_url!=""){var b=a.indexOf(this.base_url);if(b==0){a=a.substr(this.base_url.length)}}return a}};jsToolBar.prototype.resizeSetStartH=function(){this.dragStartH=this.textarea.offsetHeight+0};jsToolBar.prototype.resizeDragStart=function(a){var b=this;this.dragStartY=a.clientY;this.resizeSetStartH();document.addEventListener("mousemove",this.dragMoveHdlr=function(a){b.resizeDragMove(a)},false);document.addEventListener("mouseup",this.dragStopHdlr=function(a){b.resizeDragStop(a)},false)};jsToolBar.prototype.resizeDragMove=function(a){this.textarea.style.height=this.dragStartH+a.clientY-this.dragStartY+"px"};jsToolBar.prototype.resizeDragStop=function(a){document.removeEventListener("mousemove",this.dragMoveHdlr,false);document.removeEventListener("mouseup",this.dragStopHdlr,false)};jsToolBar.prototype.elements.strong={type:"button",title:"Strong",fn:{wiki:function(){this.singleTag("*")}}};jsToolBar.prototype.elements.em={type:"button",title:"Italic",fn:{wiki:function(){this.singleTag("_")}}};jsToolBar.prototype.elements.ins={type:"button",title:"Underline",fn:{wiki:function(){this.singleTag("+")}}};jsToolBar.prototype.elements.del={type:"button",title:"Deleted",fn:{wiki:function(){this.singleTag("-")}}};jsToolBar.prototype.elements.code={type:"button",title:"Code",fn:{wiki:function(){this.singleTag("@")}}};jsToolBar.prototype.elements.space1={type:"space"};jsToolBar.prototype.elements.h1={type:"button",title:"Heading 1",fn:{wiki:function(){this.encloseLineSelection("h1. ","",function(a){a=a.replace(/^h\d+\.\s+/,"");return a})}}};jsToolBar.prototype.elements.h2={type:"button",title:"Heading 2",fn:{wiki:function(){this.encloseLineSelection("h2. ","",function(a){a=a.replace(/^h\d+\.\s+/,"");return a})}}};jsToolBar.prototype.elements.h3={type:"button",title:"Heading 3",fn:{wiki:function(){this.encloseLineSelection("h3. ","",function(a){a=a.replace(/^h\d+\.\s+/,"");return a})}}};jsToolBar.prototype.elements.space2={type:"space"};jsToolBar.prototype.elements.ul={type:"button",title:"Unordered list",fn:{wiki:function(){this.encloseLineSelection("","",function(a){a=a.replace(/\r/g,"");return a.replace(/(\n|^)[#-]?\s*/g,"$1* ")})}}};jsToolBar.prototype.elements.ol={type:"button",title:"Ordered list",fn:{wiki:function(){this.encloseLineSelection("","",function(a){a=a.replace(/\r/g,"");return a.replace(/(\n|^)[*-]?\s*/g,"$1# ")})}}};jsToolBar.prototype.elements.space3={type:"space"};jsToolBar.prototype.elements.bq={type:"button",title:"Quote",fn:{wiki:function(){this.encloseLineSelection("","",function(a){a=a.replace(/\r/g,"");return a.replace(/(\n|^) *([^\n]*)/g,"$1> $2")})}}};jsToolBar.prototype.elements.unbq={type:"button",title:"Unquote",fn:{wiki:function(){this.encloseLineSelection("","",function(a){a=a.replace(/\r/g,"");return a.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2")})}}};jsToolBar.prototype.elements.pre={type:"button",title:"Preformatted text",fn:{wiki:function(){this.encloseLineSelection("<pre>\n","\n</pre>")}}};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("!","!")}}} +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<n;i++){var s=t[this.mode].list[i];r[s]=t.options[s]}return new jsCombo(t.title,r,this,t[this.mode].fn)}},draw:function(e){this.setMode(e);while(this.toolbar.hasChildNodes()){this.toolbar.removeChild(this.toolbar.firstChild)}this.toolNodes={};var t=document.createElement("div");t.className="help";t.innerHTML=this.help_link;"<a href=\"/help/wiki_syntax.html\" onclick=\"window.open('/help/wiki_syntax.html', '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes'); return false;\">Aide</a>";this.toolbar.appendChild(t);var n,r,i;for(var s in this.elements){n=this.elements[s];var o=n.type==undefined||n.type==""||n.disabled!=undefined&&n.disabled||n.context!=undefined&&n.context!=null&&n.context!=this.context;if(!o&&typeof this[n.type]=="function"){r=this[n.type](s);if(r)i=r.draw();if(i){this.toolNodes[s]=i;this.toolbar.appendChild(i)}}}},singleTag:function(e,t){e=e||null;t=t||e;if(!e||!t){return}this.encloseSelection(e,t)},encloseLineSelection:function(e,t,n){this.textarea.focus();e=e||"";t=t||"";var r,i,s,o,u,a;if(typeof document["selection"]!="undefined"){s=document.selection.createRange().text}else if(typeof this.textarea["setSelectionRange"]!="undefined"){r=this.textarea.selectionStart;i=this.textarea.selectionEnd;o=this.textarea.scrollTop;r=this.textarea.value.substring(0,r).replace(/[^\r\n]*$/g,"").length;i=this.textarea.value.length-this.textarea.value.substring(i,this.textarea.value.length).replace(/^[^\r\n]*/,"").length;s=this.textarea.value.substring(r,i)}if(s.match(/ $/)){s=s.substring(0,s.length-1);t=t+" "}if(typeof n=="function"){a=s?n.call(this,s):n("")}else{a=s?s:""}u=e+a+t;if(typeof document["selection"]!="undefined"){document.selection.createRange().text=u;var f=this.textarea.createTextRange();f.collapse(false);f.move("character",-t.length);f.select()}else if(typeof this.textarea["setSelectionRange"]!="undefined"){this.textarea.value=this.textarea.value.substring(0,r)+u+this.textarea.value.substring(i);if(s){this.textarea.setSelectionRange(r+u.length,r+u.length)}else{this.textarea.setSelectionRange(r+e.length,r+e.length)}this.textarea.scrollTop=o}},encloseSelection:function(e,t,n){this.textarea.focus();e=e||"";t=t||"";var r,i,s,o,u,a;if(typeof document["selection"]!="undefined"){s=document.selection.createRange().text}else if(typeof this.textarea["setSelectionRange"]!="undefined"){r=this.textarea.selectionStart;i=this.textarea.selectionEnd;o=this.textarea.scrollTop;s=this.textarea.value.substring(r,i)}if(s.match(/ $/)){s=s.substring(0,s.length-1);t=t+" "}if(typeof n=="function"){a=s?n.call(this,s):n("")}else{a=s?s:""}u=e+a+t;if(typeof document["selection"]!="undefined"){document.selection.createRange().text=u;var f=this.textarea.createTextRange();f.collapse(false);f.move("character",-t.length);f.select()}else if(typeof this.textarea["setSelectionRange"]!="undefined"){this.textarea.value=this.textarea.value.substring(0,r)+u+this.textarea.value.substring(i);if(s){this.textarea.setSelectionRange(r+u.length,r+u.length)}else{this.textarea.setSelectionRange(r+e.length,r+e.length)}this.textarea.scrollTop=o}},stripBaseURL:function(e){if(this.base_url!=""){var t=e.indexOf(this.base_url);if(t==0){e=e.substr(this.base_url.length)}}return e}};jsToolBar.prototype.resizeSetStartH=function(){this.dragStartH=this.textarea.offsetHeight+0};jsToolBar.prototype.resizeDragStart=function(e){var t=this;this.dragStartY=e.clientY;this.resizeSetStartH();document.addEventListener("mousemove",this.dragMoveHdlr=function(e){t.resizeDragMove(e)},false);document.addEventListener("mouseup",this.dragStopHdlr=function(e){t.resizeDragStop(e)},false)};jsToolBar.prototype.resizeDragMove=function(e){this.textarea.style.height=this.dragStartH+e.clientY-this.dragStartY+"px"};jsToolBar.prototype.resizeDragStop=function(e){document.removeEventListener("mousemove",this.dragMoveHdlr,false);document.removeEventListener("mouseup",this.dragStopHdlr,false)};jsToolBar.prototype.elements.strong={type:"button",title:"Strong",fn:{wiki:function(){this.singleTag("*")}}};jsToolBar.prototype.elements.em={type:"button",title:"Italic",fn:{wiki:function(){this.singleTag("_")}}};jsToolBar.prototype.elements.ins={type:"button",title:"Underline",fn:{wiki:function(){this.singleTag("+")}}};jsToolBar.prototype.elements.del={type:"button",title:"Deleted",fn:{wiki:function(){this.singleTag("-")}}};jsToolBar.prototype.elements.code={type:"button",title:"Code",fn:{wiki:function(){this.singleTag("@")}}};jsToolBar.prototype.elements.space1={type:"space"};jsToolBar.prototype.elements.h1={type:"button",title:"Heading 1",fn:{wiki:function(){this.encloseLineSelection("h1. ","",function(e){e=e.replace(/^h\d+\.\s+/,"");return e})}}};jsToolBar.prototype.elements.h2={type:"button",title:"Heading 2",fn:{wiki:function(){this.encloseLineSelection("h2. ","",function(e){e=e.replace(/^h\d+\.\s+/,"");return e})}}};jsToolBar.prototype.elements.h3={type:"button",title:"Heading 3",fn:{wiki:function(){this.encloseLineSelection("h3. ","",function(e){e=e.replace(/^h\d+\.\s+/,"");return e})}}};jsToolBar.prototype.elements.space2={type:"space"};jsToolBar.prototype.elements.ul={type:"button",title:"Unordered list",fn:{wiki:function(){this.encloseLineSelection("","",function(e){e=e.replace(/\r/g,"");return e.replace(/(\n|^)[#-]?\s*/g,"$1* ")})}}};jsToolBar.prototype.elements.ol={type:"button",title:"Ordered list",fn:{wiki:function(){this.encloseLineSelection("","",function(e){e=e.replace(/\r/g,"");return e.replace(/(\n|^)[*-]?\s*/g,"$1# ")})}}};jsToolBar.prototype.elements.space3={type:"space"};jsToolBar.prototype.elements.bq={type:"button",title:"Quote",fn:{wiki:function(){this.encloseLineSelection("","",function(e){e=e.replace(/\r/g,"");return e.replace(/(\n|^) *([^\n]*)/g,"$1> $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("<pre>\n","\n</pre>")}}};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("!","!")}}}
\ No newline at end of file diff --git a/public/javascripts/jstoolbar/jstoolbar.js b/public/javascripts/jstoolbar/jstoolbar.js index 66669ceee..3fcbd8848 100644 --- a/public/javascripts/jstoolbar/jstoolbar.js +++ b/public/javascripts/jstoolbar/jstoolbar.js @@ -44,8 +44,8 @@ function jsToolBar(textarea) { this.toolbar.className = 'jstElements'; this.editor.parentNode.insertBefore(this.toolbar,this.editor); - // Dragable resizing (only for gecko) - if (this.editor.addEventListener) + // Dragable resizing + if (this.editor.addEventListener && navigator.appVersion.match(/\bMSIE\b/)) { this.handle = document.createElement('div'); this.handle.className = 'jstHandle'; |