Author: ben Date: 2007-07-25 21:43:14 -0700 (Wed, 25 Jul 2007) New Revision: 5797
Added: sandbox/ben/branches/cuppajoe/demos/calendar/calendardata/vcal_2007-8-01.xml sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/test/linkdialog-driver.lzx sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/test/scrollrichedittext-test.lzx Removed: sandbox/ben/branches/cuppajoe/lps/components/extensions/views/richinputtext.lzl Modified: sandbox/ben/branches/cuppajoe/ sandbox/ben/branches/cuppajoe/WEB-INF/lps/lfc/data/LzReplicationManager.lzs sandbox/ben/branches/cuppajoe/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js sandbox/ben/branches/cuppajoe/lps/components/extensions/views/richinputtext.lzx sandbox/ben/branches/cuppajoe/lps/components/incubator/baseedittext.lzx sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/linkdialog.lzx sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/richtexteditarea.lzx sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/scrollrichedittext.lzx sandbox/ben/branches/cuppajoe/lps/components/incubator/test/baseedittext-test.lzx sandbox/ben/branches/cuppajoe/test/extensions/test-lzunit-richinputtext.lzx sandbox/ben/branches/cuppajoe/test/extensions/test-lzunit-textformat.lzx sandbox/ben/branches/cuppajoe/test/extensions/test-richinputtext-default-format.lzx sandbox/ben/branches/cuppajoe/test/extensions/test-richinputtext.lzx sandbox/ben/branches/cuppajoe/test/extensions/test-small-richinputtext.lzx Log: Merged revisions 5748-5756,5758-5770,5772-5796 via svnmerge from http://svn.openlaszlo.org/openlaszlo/branches/legals ....... r5751 | ben | 2007-07-23 12:23:55 -0700 (Mon, 23 Jul 2007) | 28 lines Change 20070723-ben-W by [EMAIL PROTECTED] on 2007-07-23 12:19:57 PDT in /Users/ben/src/svn/openlaszlo/branches/legals for http://svn.openlaszlo.org/openlaszlo/branches/legals Summary: Repair richinputtext lzunit test for legals New Features: Bugs Fixed: (partial) LPP-3431 Ensure richtext and richtexteditor work in OL4/SWF Technical Reviewer: none QA Reviewer: none Doc Reviewer: none Documentation: Release Notes: Details: This change makes the richinputtext lzunit test pass in swf7 and swf8 in legals. THIS TEST WILL FAIL IN DHTML; that is expected, because richinputtext is not supported in DHTML. Tests: http://localhost:8080/legals/test/extensions/test-lzunit-richinputtext.lzx?lzr=swf7 http://localhost:8080/legals/test/extensions/test-lzunit-richinputtext.lzx?lzr=swf8 ....... r5753 | ben | 2007-07-23 12:46:19 -0700 (Mon, 23 Jul 2007) | 29 lines Change 20070723-ben-L by [EMAIL PROTECTED] on 2007-07-23 12:43:14 PDT in /Users/ben/src/svn/openlaszlo/branches/legals for http://svn.openlaszlo.org/openlaszlo/branches/legals Summary: Repairs richinputtext tests New Features: Bugs Fixed: (partial) LPP-3431 Ensure richtext and richtexteditor work in OL4/SWF Technical Reviewer: none QA Reviewer: none Doc Reviewer: none Documentation: Release Notes: Details: A few more tests pass; they were not passing because of stupid little cruft, like a missing string replace function or a stray character. Tests: http://localhost:8080/legals/test/extensions/test-lzunit-textformat.lzx?lzr=swf7 http://localhost:8080/legals/test/extensions/test-lzunit-textformat.lzx?lzr=swf8 http://localhost:8080/legals/test/extensions/test-small-richinputtext.lzx?debug=false&lzr=swf8 http://localhost:8080/legals/test/extensions/test-small-richinputtext.lzx?debug=false&lzr=swf7 ....... r5755 | ben | 2007-07-23 14:29:25 -0700 (Mon, 23 Jul 2007) | 19 lines Change 20070723-ben-2 by [EMAIL PROTECTED] on 2007-07-23 14:27:05 PDT in /Users/ben/src/svn/openlaszlo/branches/legals for http://svn.openlaszlo.org/openlaszlo/branches/legals Summary: Adding a standalone lzunit test for scrollrichedittext Technical Reviewer: none QA Reviewer: none Doc Reviewer: none Documentation: To isolate problems in scrollrichedittext from other rich text editor problems, I've created this standalone test file. Tests: http://localhost:8080/legals/lps/components/incubator/rich-text/test/scrollrichedittext-test.lzx?debug=true&lzr=swf7 (Currently runs, but with debugger errors that seem to mean that it's not working properly) ....... r5767 | jcrowley | 2007-07-24 09:55:27 -0700 (Tue, 24 Jul 2007) | 26 lines Change 20070724-jcrowley-X by [EMAIL PROTECTED] on 2007-07-24 12:27:56 EDT in /Users/jcrowley/src/svn/openlaszlo/legals-safe for http://svn.openlaszlo.org/openlaszlo/branches/legals Summary: No event data in calendar demo for August 2007 New Features: Bugs Fixed: LPP-4269 Technical Reviewer: pbr QA Reviewer: Doc Reviewer: Documentation: Release Notes: Details: Added a copy of the data for August 2006, with the dates switched to 2007. This must not have gotten added when I fixed the "create data for 2007" bug a while back. Odd. Tests: Ran Calendar and data was there. ....... r5773 | max | 2007-07-24 15:37:23 -0700 (Tue, 24 Jul 2007) | 23 lines Change 20070724-maxcarlson-8 by [EMAIL PROTECTED] on 2007-07-24 13:09:36 PDT in /Users/maxcarlson/openlaszlo/legals-checkin for http://svn.openlaszlo.org/openlaszlo/branches/legals Summary: Fix sprite position caching during early initiialization New Features: Bugs Fixed: LPP-4357 - getMouse returns absolute coordinates in DHTML + FF Technical Reviewer: promanik QA Reviewer: jcrowley Doc Reviewer: (pending) Documentation: Release Notes: Details: LzSprite.js - Only set __poscachedirty if the sprite has a __parent attached. Otherwise, the position will be cached too early - before the sprite is attached to the DOM. This yields a nice speedup and resolves the issue with lpp-4120. Tests: Tested LPP-4120, LPP-4357 testcases in Safari, Firefox 2 and IE 7. ....... r5774 | ben | 2007-07-24 15:56:37 -0700 (Tue, 24 Jul 2007) | 57 lines Change 20070723-ben-y by [EMAIL PROTECTED] on 2007-07-23 15:49:09 PDT in /Users/ben/src/svn/openlaszlo/branches/legals for http://svn.openlaszlo.org/openlaszlo/branches/legals Summary: [UPDATED x2] Make rich text editor work in Legals New Features: Bugs Fixed: LPP-3431 Ensure richtext and richtexteditor work in OL4/SWF LPP-4347 baserichedittext-test.lzx fails LPP-4348 rich-text: formatfontsize test fails LPP-4349 test-baseedittext.lzx fails LPP-4350 linkdialog-test fails LPP-4351 richtexteditarea-test has warnings and errors in debugger, but lzunit test passes LPP-4352 scrollrichedittext can't create scrollbar LPP-4356 link dialog does not make links Technical Reviewer: ptw (pending) QA Reviewer: frisco (pending) Doc Reviewer: none Documentation: This changeset makes the rich text editor and all associated helper classes work in OL4. The changes required to make it work were all just updating to the new class regime. Release Notes: Details: Also note that none of the rich text api's or components work in DHTML; this is a swf-only feature. Tests: These tests all compile and run with no errors or warnings: http://localhost:8080/legals/test/extensions/test_getText_setText.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/test/extensions/test-lzunit-richinputtext.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/test/extensions/test-lzunit-textformat.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/test/extensions/test-richinputtext.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/test/extensions/test-richinputtext-default-format.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/test/extensions/test-small-richinputtext.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/lps/components/incubator/test/baseedittext-test.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/lps/components/incubator/test/scrolledittext-test.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/lps/components/incubator/rich-text/test/baserichedittext-test.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/lps/components/incubator/rich-text/test/richtexteditarea-test.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/lps/components/incubator/rich-text/test/richtexteditor-test.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/lps/components/incubator/rich-text/test/scrollrichedittext-test.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/lps/components/incubator/rich-text/test/linkdialog-test.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/lps/components/incubator/rich-text/test/linkdialog-driver.lzx?debug=true&lzr=swf7 http://localhost:8080/legals/docs/developers/richtext.html Note that all live examples appear and work. All of these tests also work in lzr=swf8. ....... r5776 | max | 2007-07-24 16:41:17 -0700 (Tue, 24 Jul 2007) | 24 lines 20070724-maxcarlson-P by [EMAIL PROTECTED] on 2007-07-24 15:42:47 PDT in /Users/maxcarlson/openlaszlo/legals-checkin/WEB-INF/lps/lfc for http://svn.openlaszlo.org/openlaszlo/branches/legals/WEB-INF/lps/lfc Summary: Lock layouts during replication New Features: Bugs Fixed: LPP-2111 - Horrendously inefficient looping in layout classes!! Technical Reviewer: promanik QA Reviewer: jcrowley Doc Reviewer: (pending) Documentation: Release Notes: Details: Lock layouts before replication, and unlock afterwards. Tests: See testcase attached to LPP-2111. With the patch applied, http://localhost:8080/legals-checkin/my-apps/wrappinglayoutupdate.lzx?lzr=dhtml&lzt=html shows 16733 calls in the profiler when the puttun click is profiled. Without the patch, it shows 80389 calls and takes ~593ms. ....... Property changes on: sandbox/ben/branches/cuppajoe ___________________________________________________________________ Name: svnmerge-integrated - /openlaszlo/branches/legals:1-5746 /openlaszlo/trunk:1-3892,3894-3952,3954-4393,4395-4461,4463-4467,4469-4471,4473-5085,5087-5171,5173-5203,5205-5209,5211-5331,5333-5334 + /openlaszlo/branches/legals:1-5746,5748-5756,5758-5770,5772-5796 /openlaszlo/trunk:1-3892,3894-3952,3954-4393,4395-4461,4463-4467,4469-4471,4473-5085,5087-5171,5173-5203,5205-5209,5211-5331,5333-5334 Modified: sandbox/ben/branches/cuppajoe/WEB-INF/lps/lfc/data/LzReplicationManager.lzs =================================================================== --- sandbox/ben/branches/cuppajoe/WEB-INF/lps/lfc/data/LzReplicationManager.lzs 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/WEB-INF/lps/lfc/data/LzReplicationManager.lzs 2007-07-26 04:43:14 UTC (rev 5797) @@ -289,7 +289,8 @@ */ function getNodeOffset ( p ){ if (this.nodes != null) { - for ( var i = 0; i < this.nodes.length; i++ ){ + var l = this.nodes.length; + for ( var i = 0; i < l; i++ ){ if ( p == this.nodes[ i ] ){ return i; } @@ -366,6 +367,10 @@ * @access private */ function __LZHandleMultiNodes ( n ){ + var layouts = this.parent && this.parent.layouts ? this.parent.layouts : []; + for (var i in layouts) { + layouts[i].lock(); + } this.hasdata = true; var lastnodes = this.nodes; this.nodes = n; @@ -380,7 +385,8 @@ this.__LZadjustVisibleClones( lastnodes , true ); - for ( var i = 0; i < this.clones.length ; i++ ){ + var l = this.clones.length; + for (var i = 0; i < l; i++ ){ var cl = this.clones[ i ] ; var iplusoffset = i + this.__LZdataoffset; cl.clonenumber = iplusoffset ; @@ -389,18 +395,16 @@ } if (cl.onclonenumber.ready) cl.onclonenumber.sendEvent( iplusoffset ); } - - if (this.onclones.ready) this.onclones.sendEvent( this.clones ); - - + for (var i in layouts) { + layouts[i].unlock(); + } } /** * @access private */ -function __LZadjustVisibleClones( lastnodes , - newnodes){ +function __LZadjustVisibleClones( lastnodes , newnodes){ var stpt = this.__LZdiffArrays( lastnodes , this.nodes); if ( ! this.pooling ) { @@ -415,7 +419,7 @@ LzInstantiator.enableDataReplicationQueuing( ); while ( this.nodes.length > this.clones.length ){ - this.clones[ this.clones.length ] = this.getNewClone(); + this.clones.push( this.getNewClone() ); } LzInstantiator.clearDataReplicationQueue( ); @@ -604,7 +608,8 @@ * @return LzView: A clone mapped to the given data. */ function getCloneForNode ( p ){ - for ( var i = 0; i < this.clones.length; i++ ){ + var l = this.clones.length; + for ( var i = 0; i < l; i++ ){ if ( this.clones[ i ].datapath.p == p ){ return this.clones[ i ]; } @@ -624,7 +629,8 @@ */ function setVisible ( vis ){ this.visible = vis; - for ( var i = 0; i < this.clones.length; i++ ){ + var l = this.clones.length; + for ( var i = 0; i < l; i++ ){ this.clones[ i ].setVisible( vis ); } if (this.onvisible.ready) this.onvisible.sendEvent( vis ); @@ -650,7 +656,8 @@ if ( !didrun ){ var who = chgpkg.who; - for ( var i = 0; i < this.clones.length; i++ ){ + var l = this.clones.length; + for ( var i = 0; i < l; i++ ){ var cl = this.clones[ i ]; if ( cl.datapath.__LZneedsOpUpdate( chgpkg ) ){ cl.datapath.__LZsetData(); @@ -733,7 +740,8 @@ * @access private */ function updateData ( a , b ){ - for ( var i = 0; i < this.clones.length; i++ ){ + var l = this.clones.length; + for ( var i = 0; i < l; i++ ){ this.clones[ i ].datapath.updateData( ); } } Modified: sandbox/ben/branches/cuppajoe/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js =================================================================== --- sandbox/ben/branches/cuppajoe/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2007-07-26 04:43:14 UTC (rev 5797) @@ -1230,15 +1230,12 @@ } } - /* This breaks in firefox - see LPP-4120 - // set this and parent's dirty to false + // set this and parents' __poscachedirty to false var p = this; - while (p != this.__rootSprite) { - p.__poscachedirty = false; + while (p && p != this.__rootSprite) { + if (p.__parent) p.__poscachedirty = false; p = p.__parent; } - */ - this.__poscachedirty = false; this.__poscache = pos; return pos; } Copied: sandbox/ben/branches/cuppajoe/demos/calendar/calendardata/vcal_2007-8-01.xml (from rev 5767, openlaszlo/branches/legals/demos/calendar/calendardata/vcal_2007-8-01.xml) Deleted: sandbox/ben/branches/cuppajoe/lps/components/extensions/views/richinputtext.lzl Modified: sandbox/ben/branches/cuppajoe/lps/components/extensions/views/richinputtext.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/lps/components/extensions/views/richinputtext.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/lps/components/extensions/views/richinputtext.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -1,34 +1,304 @@ <library> -<include href="LzTextFormat.lzx" /> +<include href="LzTextFormat.lzx" /> - -<!--- This component deals with displaying, editing, and formatting rich text. +<!--- This component deals with displaying, editing, and formatting rich text. It is a subclass of inputtext, and supports the inputtext API, plus several methods for setting and getting the format of the text. Formats - are specified as textformat. ---> -<class name="richinputtext" extends="inputtext"> - <!--- The text that appears in the component. --> - <attribute name="text" type="html" setter="setText(text)"/> - - <!--- The default format to use for inserted and typed text. - Flash support for default formatting of text is not reliable. - The default format will sometimes but rarely be observed. To ensure - that Flash uses the default format you want when the user types new - text, format the character after the insertion point. - See the example, also in test-richinputtext.lzx, - shows an example of using this trick. - --> - <attribute name="defaultformat" /> + are specified as textformat. +--> +<interface name="richinputtext" extends="inputtext"> + <!--- The default format to use for inserted and typed text. + Flash support for default formatting of text is not reliable. + The default format will sometimes but rarely be observed. To ensure + that Flash uses the default format you want when the user types new + text, format the character after the insertion point. + See the example, also in test-richinputtext.lzx, + shows an example of using this trick. + --> + <attribute name="defaultformat" /> +</interface> -</class> +<script when='immediate'> +<![CDATA[ -<include href="richinputtext.lzl" /> +class richinputtext extends LzInputText { + static var tagname = 'richinputtext'; + var defaultformat = null; + + //----------------------------------------------------------------------------- + // Set the contents of the richinputtext to the string passed in. Pass in + // null or an empty string to clear the component's contents. + // For best results, follow calls to setText with calls to setTextFormat. + // + // @param String t: the string to which to set the text + //----------------------------------------------------------------------------- + function setText ( t ){ + + if (typeof(t) == 'undefined' || t == null) { + t = ""; + } else if (typeof(t) != "string") { + t = t.toString(); + } + + + this.text = t; + + var mc = this.sprite.__LZtextclip; + mc.htmlText = t; + + if (this.resize && (this.multiline == false)) { + // single line resizable fields adjust their width to match the text + this.setWidth(this.getTextWidth()); + } + + //multiline resizable fields adjust their height + if (this.multiline && this.sizeToHeight) { + this.setHeight(mc._height); + } + + if (this.multiline && this.scroll == 0 ) { + var scrolldel = new LzDelegate(this, "__LZforceScrollAttrs"); + _root.LzIdle.callOnIdle(scrolldel); + } + + // @event ontext: Sent whenever the text in the field changes. + if (this['ontext']) this.ontext.sendEvent(); + + } + + //----------------------------------------------------------------------------- + // When using databinding... (I don't understand this) + // + // @return: The string in the text field, with html formatting. + //----------------------------------------------------------------------------- + function updateData (){ + return this.sprite.__LZtextclip.htmlText; + } + + + //----------------------------------------------------------------------------- + // Sets the default format to apply to added text. This roughly corresponds + // to Flash's TextField.setNewTextFormat, although flash only sometimes + // respects that setting. + // For best results, follow calls to setText with calls to setTextFormat + // + // @param textformat fmt: the default format + //----------------------------------------------------------------------------- + function setDefaultFormat ( fmt ){ + + this.defaultformat = fmt; + var flashformat = new TextFormat(); + for (var i in fmt) { + flashformat[i] = fmt[i]; + } + this.sprite.__LZtextclip.setNewTextFormat(flashformat); + } + + //----------------------------------------------------------------------------- + // Push the default format currently set on this object in this.defaultformat + // into the Flash TextField. This is just like setDefaultFormat except that it + // doesn't require a new default format to be passed in. + // + // @keywords private + //----------------------------------------------------------------------------- + function _. WforceResetDefaultFormat ( ){ + var flashformat = new TextFormat(); + for (var i in this.defaultformat) { + flashformat[i] = this.defaultformat[i]; + } + this.sprite.__LZtextclip.setNewTextFormat(flashformat); + } + + + //----------------------------------------------------------------------------- + // Sets the string in the text field to be the html text passed in. + // If there's no formatting information in the html text passed in, + // apply the default text format to it. + // This trick relies on the nestedness of html formatting. Innermost + // formats win over outer formats. + // + // @param t: the new contents of the text field + //----------------------------------------------------------------------------- + function setHTMLText ( t ){ + + if (this['defaultformat']) { + t = this['defaultformat'].toHTML() + t + "</font>"; + } + + this.sprite.__LZtextclip.htmlText = t; + } + + //----------------------------------------------------------------------------- + // Returns the string represented in the text field. + // Substitutes \r's with \n's because otherwise flash loses line breaks on + // setText(getText()). + // + // @return: The string in the text field + //----------------------------------------------------------------------------- + function getText ( ){ + var rawtext = this.sprite.__LZtextclip.text; + return rawtext.split("\r").join("\n"); + } + + //----------------------------------------------------------------------------- + // Returns HTML of the formatted string in the text field + // + // @return: HTML of the formatted string in the text field + //----------------------------------------------------------------------------- + function getHTMLText ( ){ + return this.sprite.__LZtextclip.htmlText; + } + + //------------------------------------------------------------------------------ + // @keywords private + //------------------------------------------------------------------------------ + getText.dependencies = function ( who , self){ + return [ self , "htmlText" ]; + } + + + //------------------------------------------------------------------------------ + // Apply the specified format change to the substring indicated. + // For example: + // foo.applyTextFormat("bold", true, start, end) == makes the text bold no matter what + // foo.applyTextFormat("bold", false, start, end) == makes the text un-bold no matter what + // foo.applyTextFormat("size", 32, start, end); + // foo.applyTextFormat("font", "Euphoria", start, end); + // + // @param String attr: the name of the attribute to change, One of bold, italic, underline, size, + // face, color, url, align, indent, leading, bullet + // @param color|boolean|number|string val: the value to which to set the specified attribute to + // @param integer beginIndex: index of the beginning of the selection + // @param integer endIndex: index of the end of the selection. + //------------------------------------------------------------------------------ + function applyTextAttr (attr, val, beginIndex, endIndex){ + // Start with a TextFormat object with no attributes set + var format = new TextFormat(); + + // Change the text format based on the format passed in. + format[attr] = val; + this.sprite.__LZtextclip.setTextFormat(beginIndex, endIndex, format); + } + + //------------------------------------------------------------------------------ + // Append the specified string to the contents of the field + // @param str the string to append + // @param toHTML whether to put the appended text into the HTMLText or the plaintext? + // if toHTML is not specified, append the text to the plaintext. + //------------------------------------------------------------------------------ + function appendText(str, toHTML) { + if (toHTML) { + this.sprite.__LZtextclip.htmlText = this.sprite.__LZtextclip.htmlText + str; + } else { + this.sprite.__LZtextclip.text = this.sprite.__LZtextclip.text + str; + } + + } + + //------------------------------------------------------------------------------ + // Gets the format of the specified range of characters. Attributes will be + // undefined unless they are common to the entire range of characters. + // + // @param integer beginIndex: index of the beginning character of the range + // @param integer endIndex: index of the last character of the range + //------------------------------------------------------------------------------ + + function getTextFormat(beginindex, endindex) { + var flashformat = this.sprite.__LZtextclip.getTextFormat(beginindex, endindex); + var fmt = new textformat(this); + + for (var i in flashformat) { + fmt[i] = flashformat[i]; + } + + return fmt; + } + + //------------------------------------------------------------------------------ + // Sets the format of the specified range of characters. + // @param textformat fmt: the new format. attributes to leave alone should be undefined. + // + // @param integer beginIndex: index of the beginning character of the range + // @param integer endIndex: index of the last character of the range + //------------------------------------------------------------------------------ + function setTextFormat(fmt, beginindex, endindex) { + var flashformat = new TextFormat(); + + for (var i in fmt) { + flashformat[i] = fmt[i]; + } + if (beginindex || (beginindex == 0)) { + this.sprite.__LZtextclip.setTextFormat(beginindex, endindex, flashformat); + } else { + this.sprite.__LZtextclip.setTextFormat(flashformat); + } + + + } + + //------------------------------------------------------------------------------ + // Bold, italic, and underline make sense to toggle, so here's a special + // toggling API. + // + // @param String attr: One of "bold", "italic", or "underline" + // @param integer beginIndex: index of the beginning character of the range + // @param integer endIndex: index of the last character of the range + //------------------------------------------------------------------------------ + function toggleFormat(attr, beginindex, endindex) { + // Due to what seems to be a bug in flash, we create a new, all-undefined + // TextFormat object, and *only* set the particular attribute we are + // toggling. Otherwise, the font may change unpredictably. + var format = this.sprite.__LZtextclip.getTextFormat(beginindex, endindex); + var newFormat = new TextFormat(); + switch (attr) { + case "bold": + newFormat.bold = !format.bold; + break; + case "italic": + newFormat.italic = !format.italic; + break; + case "underline": + newFormat.underline = !format.underline; + break; + default: + } + + this.sprite.__LZtextclip.setTextFormat(beginindex, endindex, newFormat); + + } + + //------------------------------------------------------------------------------ + // Replace the current selection with the string specified. The current selection + // is the range of characters which Flash thinks is selected. This range is + // (-1, -1) unless this component has the focus. + // + // @keywords deprecated + // @param String: str string to put where the current selection is in the string + //------------------------------------------------------------------------------ + function replaceSel (str) { + this.sprite.__LZtextclip.replaceSel(str); + } + + //------------------------------------------------------------------------------ + // Replace text between start and end, without changing that text's format. + // + // @param Number s: the start of the range to replace + // @param Number e: the end of the range to replace + // @param String txt: the text to put in the string instead of what's currently + // there + //------------------------------------------------------------------------------ + function replaceText (s, e, txt) { + this.sprite.__LZtextclip.replaceText(s,e,txt); + } +} +]]> +</script> + </library> <!-- * X_LZ_COPYRIGHT_BEGIN *************************************************** * Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved. * * Use is subject to license terms. * * X_LZ_COPYRIGHT_END ****************************************************** --> -<!-- @LZX_VERSION@ --> +<!-- @LZX_VERSION@ --> Modified: sandbox/ben/branches/cuppajoe/lps/components/incubator/baseedittext.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/lps/components/incubator/baseedittext.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/lps/components/incubator/baseedittext.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -169,12 +169,14 @@ the middle point for the textbox. @keywords private --> <method name="_placeTextY"> - if (this.multiline) { - this._field.setY(2); - } else { - this._field.setY( - (this.height - this._field.fontsize) / 2 - 3 - ); + if (this._field) { + if (this.multiline) { + this._field.setY(2); + } else { + this._field.setY( + (this.height - this._field.fontsize) / 2 - 3 + ); + } } </method> @@ -197,15 +199,18 @@ this._placeTextY() } - if (this.multiline != this._field.multiline) { - this._field.setMultiline(this.multiline); + if (this._field) { // if you instantiate a baseedittext, + // it will not have an _field + if (this.multiline != this._field.multiline) { + this._field.setMultiline(this.multiline); + } + if (this.maxlength != null) { + this._field.setMaxLength(this.maxlength); + } + if (this.pattern != null) { + this._field.setPattern(this.pattern); + } } - if (this.maxlength != null) { - this._field.setMaxLength(this.maxlength); - } - if (this.pattern != null) { - this._field.setPattern(this.pattern); - } ]]> </method> @@ -232,16 +237,18 @@ if (this._initcomplete) { if (! _ignorecalldown) { - // Have to set internal inputtext's nocallback attr. It - // can't be passed into _field.setText() since it's not an - // laszlo method. Nocallback means that setValue called - // internal inputtext and inputtext should not call setValue - // back. - this._field.ignorecallup = true; + if (this._field) { + // Have to set internal inputtext's nocallback attr. It + // can't be passed into _field.setText() since it's not an + // laszlo method. Nocallback means that setValue called + // internal inputtext and inputtext should not call setValue + // back. + this._field.ignorecallup = true; - // _internalinputtext's ontext will trigger an ontext and - // onvalue event so we don't send those events here. - this._field.setText(value); + // _internalinputtext's ontext will trigger an ontext and + // onvalue event so we don't send those events here. + this._field.setText(value); + } } this.text = value; @@ -310,7 +317,7 @@ @return String: the text string in input box. --> <method name="getValue"> if (this._initcomplete) { - return this._field.getText(); + return (this._field ? this._field.getText() : ""); } else { return this._initialtext; } @@ -321,7 +328,7 @@ @return String: the string displayed. --> <method name="getText"> if (this._initcomplete) { - return this._field.getText(); + return (this._field ? this._field.getText() : ""); } else { return this._initialtext; } Modified: sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/linkdialog.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/linkdialog.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/linkdialog.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -19,6 +19,12 @@ <attribute name="ystart" value="110"/> + <!--- the start index of the text to mark as an url --> + <attribute name="ssel" value="0" /> + <!--- the end index of the text to mark as an url --> + <attribute name="esel" value="0" /> + + <animator name="_animShow" attribute="y" to="0" from="${-parent.height}" @@ -35,6 +41,8 @@ <!--- show slides in the dialog. --> <method name="show"> + this.ssel = this.editor._ssel; + this.esel = this.editor._esel; this.urlfield.setText("http://"); var ntextlength = this.urlfield.getText().length; this.urlfield.setSelection(ntextlength,ntextlength); @@ -51,13 +59,20 @@ <!--- makelink Assigns link and standard link formatting to text selected in the editor. --> <method name="makelink"> + if (this.ssel == this.esel) { + // it doesn't make sense to make a link to an empty selection, so, + // let's see if the editor has a more useful selection. + this.ssel = this.editor._ssel; + this.esel = this.editor._esel; + } + var url = urlfield.getText(); - var fmt = this.editor.currentformat; + var fmt = this.editor.getTextFormat(this.ssel, this.esel); fmt.url = url; fmt.color = blue; fmt.target = "_new"; fmt.underline = true; - this.editor.setCurrentFormat(fmt); + this.editor.setTextFormat(fmt, this.ssel, this.esel); var ncaratinsertpoint = this.editor.getAttribute("_esel"); // make sure that next onfocus, which will be triggered by doing setSelection here, is ignored by editor. Modified: sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/richtexteditarea.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/richtexteditarea.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/richtexteditarea.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -18,7 +18,7 @@ <attribute name="toolbar" value="$once{parent.parent.toolbar}" /> <!--- Reference to the hyperlink creation dialog --> - <attribute name="linkpanel" value="$once{parent.parent.linkpanel}" /> + <attribute name="linkpanel" value="null"/> <!-- The defaultfontsize, defaultfontname, and defaultfontcolor determine the initial configuration of the toolbar, and thus, the @@ -101,24 +101,29 @@ // However, my oncurrentformat event hasn't yet been registered. // So: explicitly push the format to the toolbar this.toolbar.matchformat(this.currentformat); + + // Point my linkpanel attribute at the linkpanel associated with + // this text editor + if ("linkpanel" in this.parent.parent) + this.linkpanel = this.parent.parent.linkpanel; </method> <!-- PUBLIC METHODS .........................................................--> <!--- Reset the values of the richtexteditor. --> - <method name="reset"> + <method name="reset"><![CDATA[ this.clearText(true); this._resetFormatToDefaults(); this.inp.setDefaultFormat(this.currentformat); this.rollback(); - if (this.linkpanel) this.linkpanel.hide(); - if (this.toolbar) this.toolbar.reset(); + if ("linkpanel" in this && this.linkpanel) this.linkpanel.hide(); + if ("toolbar" in this && this.toolbar) this.toolbar.reset(); this.isHTML = false; this._shouldresettoolbar = true; this._ssel = this._esel = 0; - </method> + ]]></method> <!-- EVENT HANDLERS .........................................................--> Modified: sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/scrollrichedittext.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/scrollrichedittext.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/scrollrichedittext.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -36,7 +36,7 @@ classname = "vscrollbar"; } if ($debug) { - if (typeof(global[classname]) == "undefined") { + if (typeof(lz[classname]) == "undefined") { Debug.write("scrollbarclassname undefined", this); } } @@ -50,19 +50,19 @@ // _vs.stepsize="${parent.inp.lineheight}" this.applyConstraint("stepsize", - function() { this.setAttribute("stepsize", parent.inp.lineheight); }, + function() { this.setAttribute("stepsize", this.parent.inp.lineheight); }, [p.inp, "lineheight"]); // _vs.scrollmax="${parent.inp.maxheight}" /> this.applyConstraint("scrollmax", - function() { this.setAttribute("scrollmax", parent.inp.maxheight); }, + function() { this.setAttribute("scrollmax", this.parent.inp.maxheight); }, [p.inp, "maxheight"]); #pragma "methodName=init" super.init(); } - this._vs = new global[classname](this, + this._vs = new (lz[classname])(this, { axis: "y", scrollattr: "pos", scrolltarget: this.inp, Copied: sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/test/linkdialog-driver.lzx (from rev 5776, openlaszlo/branches/legals/lps/components/incubator/rich-text/test/linkdialog-driver.lzx) Copied: sandbox/ben/branches/cuppajoe/lps/components/incubator/rich-text/test/scrollrichedittext-test.lzx (from rev 5755, openlaszlo/branches/legals/lps/components/incubator/rich-text/test/scrollrichedittext-test.lzx) Modified: sandbox/ben/branches/cuppajoe/lps/components/incubator/test/baseedittext-test.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/lps/components/incubator/test/baseedittext-test.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/lps/components/incubator/test/baseedittext-test.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -7,7 +7,7 @@ <class name="TextTestCase" extends="TestCase"> <method name="setUp"> - gbet.reset(); + gbet.clearText(); </method> </class> <TestSuite> @@ -25,7 +25,7 @@ </canvas> <!-- * X_LZ_COPYRIGHT_BEGIN *************************************************** -* Copyright 2006 Laszlo Systems, Inc. All Rights Reserved. * +* Copyright 2007 Laszlo Systems, Inc. All Rights Reserved. * * Use is subject to license terms. * * X_LZ_COPYRIGHT_END ****************************************************** --> <!-- @LZX_VERSION@ --> Modified: sandbox/ben/branches/cuppajoe/test/extensions/test-lzunit-richinputtext.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/test/extensions/test-lzunit-richinputtext.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/test/extensions/test-lzunit-richinputtext.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -2,8 +2,13 @@ <include href="lzunit"/> <include href="/extensions/views/richinputtext.lzx" /> <include href="/extensions/views/LzTextFormat.lzx" /> - <include href="/utils/textutils.lzx" /> +<script> + // a little replace function, just to help with testing and such + function replace(s, f, r) { + return s.split(f).join(r); + } +</script> <class name="RichTextTestBase" extends="TestCase"> <!--- Constant for testing. --> <attribute name="PLAIN_A" type="string" value="aaa." /> @@ -43,7 +48,7 @@ <method name="testFixCRs"> var str = new String(PLAIN_A + "\r" + PLAIN_B); - var foo = textutils.replace(str, "\r", ""); + var foo = replace(str, "\r", ""); assertSame(PLAIN_A + PLAIN_B, foo); </method> @@ -51,27 +56,27 @@ var orig = "I am a little teapot."; var findme = "t"; var replacewith = "!"; - var processed = textutils.replace(orig, findme, replacewith); + var processed = replace(orig, findme, replacewith); assertSame("I am a li!!le !eapo!.", processed) // single replacement at beginning of the string - processed = textutils.replace("twelve", findme, replacewith); + processed = replace("twelve", findme, replacewith); assertSame("!welve", processed) // single replacement in middle of the string - processed = textutils.replace("lite", findme, replacewith); + processed = replace("lite", findme, replacewith); assertSame("li!e", processed) // test single replacement at end of string - processed = textutils.replace("great", findme, replacewith); + processed = replace("great", findme, replacewith); assertSame("grea!", processed) // test two replacements in a row - processed = textutils.replace("utter", findme, replacewith); + processed = replace("utter", findme, replacewith); assertSame("u!!er", processed) // test complete replacement - processed = textutils.replace("tttttt", findme, replacewith); + processed = replace("tttttt", findme, replacewith); assertSame("!!!!!!", processed) @@ -113,7 +118,8 @@ <method name="testAppendHTMLFudge"> rich.appendText(RICH_B, true); var after = rich.getText(); - var munge = textutils.replace(after, "\r", ""); + var munge = replace(after, "\r", ""); + munge = replace(munge, "\n", ""); assertSame(PLAIN_A + PLAIN_RICH_B, munge); </method> @@ -165,7 +171,8 @@ <method name="testAppendHTML"> rich.appendText(RICH_B, true); var after = rich.getText(); - var munge = textutils.replace(after, "\r", ""); + var munge = replace(after, "\r", ""); + munge = replace(munge, "\n", ""); assertSame(PLAIN_RICH_A + PLAIN_RICH_B, munge); </method> @@ -173,7 +180,8 @@ rich.appendText(RICH_B, true); rich.appendText(RICH_C, true); var after = rich.getText(); - var munge = textutils.replace(after, "\r", ""); + var munge = replace(after, "\r", ""); + munge = replace(munge, "\n", ""); assertSame(PLAIN_RICH_A + PLAIN_RICH_B + PLAIN_RICH_C, munge); </method> </class> @@ -360,7 +368,7 @@ rich.setHTMLText(newstr); var f = rich.getTextFormat(LONG_A.length, LONG_A.length + 1); assertEquals("Verdana", f.font); - var pt = textutils.replace(rich.getText(), "\r", ""); + var pt = replace(rich.getText(), "\r", ""); assertEquals(LONG_A + PLAIN_A, pt); </method> </class> @@ -424,7 +432,7 @@ // Make sure that setting the default actually sets the default, // but doesn't change the format of the existing text rich.setDefaultFormat(myformat); - sameFormat(myFormat, rich.defaultformat); + sameFormat(myformat, rich.defaultformat); var afterChangingDefault = rich.getTextFormat(0, rich.getText().length); sameFormat(initialFormat, afterChangingDefault); </method> Modified: sandbox/ben/branches/cuppajoe/test/extensions/test-lzunit-textformat.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/test/extensions/test-lzunit-textformat.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/test/extensions/test-lzunit-textformat.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -2,7 +2,6 @@ <include href="lzunit"/> <include href="/extensions/views/richinputtext.lzx" /> <include href="/extensions/views/LzTextFormat.lzx" /> - <include href="/incubator/textutils.lzx" /> <!--- Constant for testing. --> <attribute name="PLAIN_A" type="string" value="aaa." /> @@ -14,7 +13,14 @@ <attribute name="PLAIN_RICH_A" type="string" value="rich" /> <attribute name="PLAIN_RICH_B" type="string" value="i have spaces" /> <attribute name="PLAIN_RICH_C" type="string" value=" space before and after " /> - + + <script> + // a little replace function, just to help with testing and such + function replace(s, f, r) { + return s.split(f).join(r); + } + </script> + <class name="Creation" extends="TestCase"> <method name="testCreation"> var f = new textformat(); Modified: sandbox/ben/branches/cuppajoe/test/extensions/test-richinputtext-default-format.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/test/extensions/test-richinputtext-default-format.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/test/extensions/test-richinputtext-default-format.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -52,7 +52,7 @@ </method> </button> - <button text="reset" onclick="rte.reset()"/> + <button text="reset" onclick="rte.clearText()"/> </view> <view x="20" y="250" width="200"> <simplelayout axis="x" spacing="5" /> Modified: sandbox/ben/branches/cuppajoe/test/extensions/test-richinputtext.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/test/extensions/test-richinputtext.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/test/extensions/test-richinputtext.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -5,7 +5,7 @@ methods also exist. --> -<!-- auto-included BUT NOT in lps-dev --> +<!-- auto-included BUT NOT in lps-dev --> <include href="/extensions/views/richinputtext.lzx" /> <!-- --> <debug x="300"/> @@ -13,7 +13,7 @@ <window title="toggleFormat"> <simplelayout axis="y" spacing="4" /> - + <!--- These checkboxes use the toggleFormat function to toggle the boldness, italic-ness, or underline-ness of the text. Modified: sandbox/ben/branches/cuppajoe/test/extensions/test-small-richinputtext.lzx =================================================================== --- sandbox/ben/branches/cuppajoe/test/extensions/test-small-richinputtext.lzx 2007-07-26 04:39:54 UTC (rev 5796) +++ sandbox/ben/branches/cuppajoe/test/extensions/test-small-richinputtext.lzx 2007-07-26 04:43:14 UTC (rev 5797) @@ -69,7 +69,7 @@ var tf = new textformat(); tf.color = 0xFF9933; ; - tf.italic = true;s + tf.italic = true; tf.font = 'Times'; _______________________________________________ Laszlo-checkins mailing list [email protected] http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins
