[jQuery] plugin: fieldSelection

2006-12-16 Thread Alex Brem
Hey jQuery lovers,

I coded a small plugin to retrieve the caret position and the current
selection index of input fields and textareas.
Special treatment for such an simple thing is needed because MSIE
doesn't support the easy DOM 3.0 methods (yes, this also applies to IE7
*sigh*).

So here's the plugin and a small test case:

http://lab.0xab.cd/jquery/fieldselection/

Please note that the plugin is a little rough and not very jQuerish at
the moment - mainly because I don't know if this is useful for anyone
else. If so, please gimme some feedback. Oh, and there's also a lack of
documentation. :)

Greets,

Alex

--
http://www.kwick.de - KWICK! Community

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] plugin: fieldSelection

2007-02-08 Thread [-Stash-]

Does anyone know if this is still being worked on?  I'd be very interested to
use this with a few more features in it.

Luke


Alex Brem wrote:
> 
> Hey jQuery lovers,
> 
> I coded a small plugin to retrieve the caret position and the current
> selection index of input fields and textareas.
> Special treatment for such an simple thing is needed because MSIE
> doesn't support the easy DOM 3.0 methods (yes, this also applies to IE7
> *sigh*).
> 
> So here's the plugin and a small test case:
> 
> http://lab.0xab.cd/jquery/fieldselection/
> 
> Please note that the plugin is a little rough and not very jQuerish at
> the moment - mainly because I don't know if this is useful for anyone
> else. If so, please gimme some feedback. Oh, and there's also a lack of
> documentation. :)
> 
> Greets,
> 
> Alex
> 
> --
> http://www.kwick.de - KWICK! Community
> 
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/plugin%3A-fieldSelection-tf2833491.html#a8878627
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] plugin: fieldSelection

2006-12-16 Thread Yehuda Katz

The first thing I notice is the beginning of your plugin:

var e = (typeof this.id == 'function') ? this.get(0) : this;

could be replaced with

var e = this.jquery ? this[0] : this



On 12/16/06, Alex Brem <[EMAIL PROTECTED]> wrote:


Hey jQuery lovers,

I coded a small plugin to retrieve the caret position and the current
selection index of input fields and textareas.
Special treatment for such an simple thing is needed because MSIE
doesn't support the easy DOM 3.0 methods (yes, this also applies to IE7
*sigh*).

So here's the plugin and a small test case:

http://lab.0xab.cd/jquery/fieldselection/

Please note that the plugin is a little rough and not very jQuerish at
the moment - mainly because I don't know if this is useful for anyone
else. If so, please gimme some feedback. Oh, and there's also a lack of
documentation. :)

Greets,

Alex

--
http://www.kwick.de - KWICK! Community

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/





--
Yehuda Katz
Web Developer | Wycats Designs
(ph)  718.877.1325
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] plugin: fieldSelection

2006-12-16 Thread David
I think it can be useful as a part of the to be jqueryised WYMeditor 
(http://www.wymeditor.org). Maybe it's not so bad to modularize a 
WYSIWYG editor. Certain fields could  use specific parts of  an editor. 
I'm thinking in the line of a user added title that can have different 
css styles or a link.

David


Alex Brem schreef:
> Hey jQuery lovers,
>
> I coded a small plugin to retrieve the caret position and the current
> selection index of input fields and textareas.
> Special treatment for such an simple thing is needed because MSIE
> doesn't support the easy DOM 3.0 methods (yes, this also applies to IE7
> *sigh*).
>
> So here's the plugin and a small test case:
>
> http://lab.0xab.cd/jquery/fieldselection/
>
> Please note that the plugin is a little rough and not very jQuerish at
> the moment - mainly because I don't know if this is useful for anyone
> else. If so, please gimme some feedback. Oh, and there's also a lack of
> documentation. :)
>
> Greets,
>
> Alex
>
> --
> http://www.kwick.de - KWICK! Community
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>
>
>   



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] plugin: fieldSelection

2006-12-16 Thread John Resig
Ok, this is really really impressive. Every time that I have to deal
with text-field selection, I'm constantly banging my head against the
keyboard. This is a fantastic plugin to have on hand.

Some quick suggestions:
- When you replace a snippet, the cursor loses focus. It would be
fantastic if the new replaced snippet was selected too.  Like so: foo
[bar] baz becomes: foo [zoo] baz (where [] is the selection)
- In the object that you return, including two other properties:
before (The text before the current selection) and after (the text
after the current selection)
- Make it so that you can bind a .selection() event (or some such) so
that you can have a method be called back every time the selection
changes, for example:
$(...).selection(function(e,s){
alert( s.text );
});
(This would only have to fire whenever the selection is complete)

This is a great plugin - I can't wait to use it! (Especially
considering that it works great in IE, Safari and Firefox!)

--John

On 12/16/06, Alex Brem <[EMAIL PROTECTED]> wrote:
> Hey jQuery lovers,
>
> I coded a small plugin to retrieve the caret position and the current
> selection index of input fields and textareas.
> Special treatment for such an simple thing is needed because MSIE
> doesn't support the easy DOM 3.0 methods (yes, this also applies to IE7
> *sigh*).
>
> So here's the plugin and a small test case:
>
> http://lab.0xab.cd/jquery/fieldselection/
>
> Please note that the plugin is a little rough and not very jQuerish at
> the moment - mainly because I don't know if this is useful for anyone
> else. If so, please gimme some feedback. Oh, and there's also a lack of
> documentation. :)
>
> Greets,
>
> Alex
>
> --
> http://www.kwick.de - KWICK! Community
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] plugin: fieldSelection

2006-12-18 Thread Alex Brem
Hi John,

many, many thanks for your ideas!
So maybe you are interested in the latest version where I implemented
the "cursor to new text" suggestion. Just pass true to
replaceSelection() as a second parameter. Or maybe it should be the default?

The latest testing version is is 0.2.1, but please note, it is not very
well tested in Opera and Safari. Also there are known IE quirks!

http://laboratorium.0xab.cd/jquery/fieldselection/

Also new is setSelection() which.. let's you set a field selection. :)
But please note: although it basically works, I for sure have to rewrite
the arguments stuff which is way too hackish. But what I wanted to
implement is stuff like this:

setSelection([2, 5])
setSelection({start: 5, end: 'current'})
setSelection({pos: 5})
setSelection('$') // cursor to end

I also want to implement things like "select word under cursor" and
similar things.

And I thought about optionally passing a function e.g. to intercept
replaceSelection(). This way you could easily implement stuff like
additionally wrap spaces around the inserted text, but only if there are
non surrounding, if you know what I mean.

So.. am I moving it into the right direction? :)

Alex


John Resig wrote:
> Ok, this is really really impressive. Every time that I have to deal
> with text-field selection, I'm constantly banging my head against the
> keyboard. This is a fantastic plugin to have on hand.
> 
> Some quick suggestions:
> - When you replace a snippet, the cursor loses focus. It would be
> fantastic if the new replaced snippet was selected too.  Like so: foo
> [bar] baz becomes: foo [zoo] baz (where [] is the selection)
> - In the object that you return, including two other properties:
> before (The text before the current selection) and after (the text
> after the current selection)
> - Make it so that you can bind a .selection() event (or some such) so
> that you can have a method be called back every time the selection
> changes, for example:
> $(...).selection(function(e,s){
>alert( s.text );
> });
> (This would only have to fire whenever the selection is complete)
> 
> This is a great plugin - I can't wait to use it! (Especially
> considering that it works great in IE, Safari and Firefox!)
> 
> --John


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] plugin: fieldSelection

2006-12-19 Thread Brice Burgess
Alex Brem wrote:
> So.. am I moving it into the right direction? :)
>   
Certainly! You're laying the framework for a lot of things here -- I can 
see live spelling checks with suggested words on right click, WYSIWYG|M 
developer friendly API, pruning/filtering of textarea data && so on. 
Keep it up :)

~ Brice



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/