From dcc09250250b0985e943986731f8da6c652b5725 Mon Sep 17 00:00:00 2001 From: maslen Date: Tue, 11 Aug 2009 14:15:37 +0100 Subject: [PATCH] widgets.Editor : Added ordered and unordered lists to the editor toolbar --- src/widgets/editor/editor.js | 63 +++++++++++++----- .../images/editor/button-blockquote.png | Bin 3414 -> 546 bytes .../images/editor/button-orderedlist.png | Bin 0 -> 408 bytes .../images/editor/button-unorderedlist.png | Bin 0 -> 399 bytes .../images/editor/dark-button-blockquote.png | Bin 567 -> 544 bytes .../images/editor/dark-button-orderedlist.png | Bin 0 -> 417 bytes .../editor/dark-button-unorderedlist.png | Bin 0 -> 400 bytes src/widgets/widgets.editor.css | 32 ++++++--- test/glow/widgets/editor/editor.js | 12 +++- 9 files changed, 78 insertions(+), 29 deletions(-) create mode 100644 src/widgets/images/editor/button-orderedlist.png create mode 100644 src/widgets/images/editor/button-unorderedlist.png create mode 100644 src/widgets/images/editor/dark-button-orderedlist.png create mode 100644 src/widgets/images/editor/dark-button-unorderedlist.png diff --git a/src/widgets/editor/editor.js b/src/widgets/editor/editor.js index 8221ce0..a0e14e4 100755 --- a/src/widgets/editor/editor.js +++ b/src/widgets/editor/editor.js @@ -26,9 +26,16 @@ ITALICS_LABEL : "I", STRIKE_TITLE : "Strikethrough", - STRIKE_LABEL : "Strike" + STRIKE_LABEL : "Strike", + UNORDERED_TITLE : "Unordered list", + UNORDERED_LABEL : "unordered list", + + ORDERED_TITLE : "Ordered list", + ORDERED_LABEL : "ordered list" + /* + BLOCK_TITLE : "Blockquote", BLOCK_LABEL : "blockquote", @@ -93,7 +100,7 @@ this.toolbar = new glow.widgets.Editor.Toolbar(this); if (this._opts.toolset == "basic") { - this.toolbar._addToolset("italics", "bold", "strike"/*, "blockquote"*/); + this.toolbar._addToolset("italics", "bold", "strike", /*"blockquote",*/ "unorderedlist", "orderedlist"); } else throw new Exception("Unknown toolset name."); @@ -291,7 +298,7 @@ Idler.prototype._stop = function() { this.opts = opts || {}; - this.whitelist = ["em", "strong", "strike", "p", "br", "blockquote"]; // TODO: support tags.attributes + this.whitelist = ["em", "strong", "strike", "p", "br", /*"blockquote",*/ "ul", "ol", "li"]; // TODO: support tags.attributes } // runs before clean @@ -513,7 +520,7 @@ Idler.prototype._stop = function() { myToolbar._addToolset("Bold", "Italics") .addButton("MyCustomButton", opts); // will be chainable */ - glow.widgets.Editor.Toolbar.prototype._addToolset = function() { + glow.widgets.Editor.Toolbar.prototype._addToolset = function(/*arguments*/) { var toolToAdd; for (var i = 0, l = arguments.length; i < l; i++) { if ( (toolToAdd = this.editor._tools[arguments[i]]) ) { @@ -553,14 +560,14 @@ Idler.prototype._stop = function() { H6: true, DIV: true, ADDRESS: true, -// BLOCKQUOTE: true, + BLOCKQUOTE: true, CENTER: true, PRE: true, CODE: true, A: true, - UL: true, - OL: true, - LI: true, +// UL: true, +// OL: true, +// LI: true, DL: true, DT: true, DD: true, @@ -692,8 +699,8 @@ Idler.prototype._stop = function() { */ glow.widgets.Editor.Toolbar.prototype._update = function(domPath) { /*debug*///console.log("glow.widgets.Editor.Toolbar.prototype._update("+domPath+")") var handled = false; - for (var i = 0, l = this._tools.length; i < l; i++) { - if (domPath.indexOf("|"+this._tools[i].tag+"|") > -1) { + for (var i = 0, l = this._tools.length; i < l; i++) { + if (domPath.indexOf("|"+this._tools[i].tag+"|") > -1) { this._tools[i].activate(); handled = true; } @@ -927,19 +934,41 @@ Idler.prototype._stop = function() { command: "strikethrough", action: function() { tag.call(this.editor.editArea, this.command); return false; } } - } - /* tag.call(this.editor.editArea, this.command) - , - blockquote: { + }, +/* + blockquote: { name : "blockquote", opts : { title: localeModule.BLOCK_TITLE, label: localeModule.BLOCK_LABEL, tag: "blockquote", - command: "formatblock", - action: function() { tag.call(this.editor.editArea, this.command, 'blockquote'); return false; } + command: "indent", + action: function() { tag.call(this.editor.editArea, this.command); return false; } } }, +*/ + unorderedlist: { + name : "unorderedlist", + opts : { + title: localeModule.UNORDERED_TITLE, + label: localeModule.UNORDERED_LABEL, + tag: "ul", + command: "insertunorderedlist", + action: function() { tag.call(this.editor.editArea, this.command); return false; } + } + }, + orderedlist: { + name : "orderedlist", + opts : { + title: localeModule.ORDERED_TITLE, + label: localeModule.ORDERED_LABEL, + tag: "ol", + command: "insertorderedlist", + action: function() { tag.call(this.editor.editArea, this.command); return false; } + } + } + /* tag.call(this.editor.editArea, this.command) + , heading1:{ name : "heading1", opts : { @@ -1329,7 +1358,7 @@ Idler.prototype._stop = function() { } else { this._domPath(); - this.contentWindow.document.execCommand(tagName, false, null); + this.contentWindow.document.execCommand(tagName, false, attr); } this.contentWindow.focus(); updateArea.call(this); diff --git a/src/widgets/images/editor/button-blockquote.png b/src/widgets/images/editor/button-blockquote.png index 65fb97f9ad3320bf2de52b681e4c639cf9dd5c16..4f8cfdaca0ff6a1fdbfafaebc1dde06acc3fde01 100755 GIT binary patch delta 496 zcmVzL900044NklQ)Nh848c)UHYcmJA z8cQV5mP#@9@gYgoWBO+_i9#{73dUh>zXgmfb0T2$RpkZV(02BWhD`+H@=x&s#xO7m zyr!QOigxf3-jG#0yeHjIyU}`vK)tPJ=rWeu(^rna?;=s*H&f7hks1%CSzRwud@zZ6 zO#h6nQ7G1ff-#?mPQW-Y8v&!MDkt!UwzFq!xs704E|C*3);R}(*L1T&vCmzEH`J>g m-t*;2IHB6mhc41xfB^uG67qjlay7^R0000Q;V~#$?9CK$qdGaLR_vf#~6N|+P7A*MY&6}b{ zi@tmJu27*uOn&?JjeiA zDORi)T!RQ;hy^vcU>t^Ig~bw{329uUunZUke){z3`Sa(0B!3j`ts#V&_M_UmMvQr!9ncf$B);oTep4tb|xV(J3BikCkO4p3Lp$}kwAnr zh^b7OGB|rAQqCP z6dEzL5hF&x?|=OH^AW;;0Ru{wEcxisBbb2kU|1QEs$X~ng__yAb?fQVr$>z%b^reT z9Xoa$IdWvom@y9?JkVy@o{d?|W)RL#4MW{Vcv5#@DcS&Ug$fn+@85s>_U$H3nn2p! zyLWHhy49*xtI?xJqp{+}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G`Y8xK~3}_En2W-5#mDm>2b!On|ff))a?mXvDJ<#AiXDTL7e~l z6DZB)qS87nt>X|6WoGgg{X0>iNYAC)qw$6U=|^A6xcgsr$};?U&lo=i7ywC&L^@AS RzM=pC002ovPDHLkV1mgAM+N`@ diff --git a/src/widgets/images/editor/button-orderedlist.png b/src/widgets/images/editor/button-orderedlist.png new file mode 100644 index 0000000000000000000000000000000000000000..49795f784d9f5eae99d709de49a3c8b19dc87b8b GIT binary patch literal 408 zcmV;J0cZY+P) z{zRHOC#f6Hs`so&=4a(#F{wbN!ohsKgV213aPaVZJ3@61qiqp~fn2VH&=x8=TMjA+ z-n5U9?87?Pwm7vVJA{LW?|Fp!97fwB z4gSzxw*Hux3#sk$;rvo)YQ?@(Yw35&CSin$H(#U z@yg1|_xJbp_4WDr`M9{a#KgqI!^3bYY4ZR80LV#1K~#9!?3CLIgdh|}E6qz6?P|A~ z`Tx%xDKSVB>7|%)y&Pe|VS{d?=r&4(%2SB|Kym<$w{)%zX`h%jAjvS!P9;uLEJv#G zmd>>y?Gw}f1x*JHx@L3jXGjc&ce_e9Cl+S5N+^#7rNzNQEhzw0j{SS{md>>nJY`6G zIW3=TZsJ=v#bUZesJ`}<`TDB<_lm?tY#?5$NOf$XRz;G>oRIurp_T*yBFBE8-qN|& tf~O2=FQ?`9m!OKoM$?V#rXqa>7yzC@6G!^P`$GT#002ovPDHLkV1lg!zgYkP literal 0 HcmV?d00001 diff --git a/src/widgets/images/editor/dark-button-blockquote.png b/src/widgets/images/editor/dark-button-blockquote.png index d3daea6d6a03f40ca90fa5b6ab8049605d4fd9fd..1982529d107e4924e698f5ce2e5301c3d5cfbcf5 100644 GIT binary patch delta 476 zcmV<20VDpm1fT?vPJeN6afF0~t*xy@L_}R(U3qzVwY9aJoSbTEYE4Z|Q&UqsJUqL* zyQHL~Gcz+~Wo63B%K!iWW@cuQk&(&C$-%+F@$t;e%+}V{SXfx<>gvD0zhh%# z_4V~OHa3h@AyNPU0ai&wK~#9!?3LMWgD?<9y#|aS!3Gkt_J9BXvKGSPKJ2yBP`bqDgk8(!4Oc& zG1LS;(;OKj-DncHA;&!P5&pPznnAL043fHGpuCvojexR=(GgJk``r_-c%ddX2`FQX zo`6zcq9*W}-hVJi`ioEChCK5>w;M^J`l6IzX**YbC&XrQGas@P$bLG4DZ1E(tJVTW)ov(O? z_VQLv-%b9$McUazQC2OBBo3g&vPkKNs+iB}vz!!zWK}maP@b=|AfTK>Pz03n@sI>= zsH`pJ6s81}A4?<&D7$kQ2z;izGDzC9OyGtrv%x)EJPFGpsk(HvdeI`i3ormIGOJnT S{r5fq0000Rz-47+ z|Ns9pGc)O9RdN6T0c}Y{K~#9!?3LY)f-n$93oS~EV8N9iwSV>f-*RmSrAxmhBwk>$ zJIT2^fliy5eC)nZY*X1L1d^&Hkd!F_<+)2U2b8I`tpiHk_u8?=3n{BSP+DuX14?gV@5lHf!Kr-V5lvT|=P;z5(2b97X;n?DZxZxfs&7&#v zY-}#G%480FrhljjBt<1WxFJFO&+U4dsN1|$GD@bJ=%Yq4l0^xASr#O3@W7i0*71YoxSJqtR&@4JAIXK6HjDf{4EIn8U@6<(QnRoQsYgEn#L@oa@o2Gy4cq}mZk4vIkXcqO2` zbl1HD%B!`?0j2DF>G-AF#jCt42RnG6eC&yIKzY2_)`8EI9f2gfNDpp^5$mpUsDP`V pyHeJ%YhJrjMAKJnwJYBO3;>fJTuTCUy=DLa002ovPDHLkV1hY=^J4%2 diff --git a/src/widgets/images/editor/dark-button-orderedlist.png b/src/widgets/images/editor/dark-button-orderedlist.png new file mode 100644 index 0000000000000000000000000000000000000000..494c9350ac1fc9f75a53129e0060be5558b73fb3 GIT binary patch literal 417 zcmV;S0bc%zP)adEb`w!go>K0ZEdY-~qIM|XF3PEJmrpPzDaa&T~Pt*xy?Lqn#f zrlqB&va+(Vv9V^S4rTxV0Om9 ztrpSQQjqfH+x|q#M4=?5W$A6e1;afxd)4{cb(Pta{~M*;>iMszw@MNQ+d>$6a=H?j zwjiRjrJw-Do!RP>T{E-gV}n^U=Jrt3`0cBU?;E5?FH!pEK1h@FWZDO5I|HK1K``*} zJdaR*hQYQFhMt_R1g0&>=xiw{fpKRx`()>Rkd_v+cDZPfUIGjN*53(ys0-w200000 LNkvXXu0mjfT8O=G literal 0 HcmV?d00001 diff --git a/src/widgets/images/editor/dark-button-unorderedlist.png b/src/widgets/images/editor/dark-button-unorderedlist.png new file mode 100644 index 0000000000000000000000000000000000000000..6d108cf2d2cf7c5c0f3a8d685f169b16718e8d50 GIT binary patch literal 400 zcmV;B0dM|^P)sX)mifQkngt6ohvM6HG zA}wcV9qZFxG3_l>rr1zguB?6y<`2WOR$h$IxUo=%;mxrA0*}-Vf#=N;TE|)g`Lw6g ziWbV#3T1iUnXK#cbx~#J?aQkFE7F^WhUjA}(i8%kwj#-8%z6Apv4$KWE^R+DXJ{P@ u$PxOqr_+iBV#`*fW;WT}{HRDD0R{kMpACoYb*tw90000.*hello world.*<\/strike>/.test(content), "The strike button produces a strike tag."); + window.t_editor.editArea._select(); + window.t_editor.toolbar.getTool("unorderedlist").press(); + content = window.t_editor.cleaner.clean(window.t_editor.editArea._getContent()).toLowerCase(); + /*5*/ t.ok(/
  • .*hello world.*<\/li><\/ul>/.test(content), "The unorderedlist button produces a ul and li tag."); + + window.t_editor.editArea._select(); + window.t_editor.toolbar.getTool("orderedlist").press(); + content = window.t_editor.cleaner.clean(window.t_editor.editArea._getContent()).toLowerCase(); + /*6*/ t.ok(/
    1. .*hello world.*<\/li><\/ol>/.test(content), "The orderedlist button produces a ol and li tag."); + t.start(); }, 10); });