[drupal-devel] [feature] 2 additional hooks to form_textarea to support module writers who are extending it.
Issue status update for http://drupal.org/node/18417 Project: Drupal Version: 4.5.2 Component: base system Category: feature requests Priority: normal Assigned to: Anonymous Reported by: jbond Updated by: gordon Status: patch -1 I do not think that these 2 additional hooks are needed. This will really add alot of additional overhead as it is going to call every textarea hook 4 times for every textarea on a page. Besides these modifiaction can be handled better and cleaner in the javascript. If you take a look at Xinha/HTMLArea or FckEditor they both manipulate the dom once the page has loaded, and not during. This is a much better and cleaner method as it means that you can attach to any textarea with only a few commands. This is what javascript excels at. So I don't think this is needed. gordon Previous comments: ------------------------------------------------------------------------ March 5, 2005 - 19:54 : jbond Attachment: http://drupal.org/files/issues/common.inc_8.patch (1.83 KB) This patch is for common.inc function form_textarea(). It adds two additional hooks for module writers. 1) A new hook "post-title" which works the same as "pre" and "post" but allows html to be inserted between the title of the element and the textarea. This makes it easier to insert a row of buttons (say) that sit just on top of the textarea. 2) A new hook "attributes" which takes an array() from modules that provide it and merges it into the $attributes array for the textarea. Wysywig editors typically need to add javascript handlers for things like onClick and this provides a simple way for the module to add them. ------------------------------------------------------------------------ March 5, 2005 - 20:00 : jbond Attachment: http://drupal.org/files/issues/common.inc_9.patch (1.83 KB) Apologies. the first patch had ms win line endings. This one should be unix line endings.
gordon <drupal-devel@drupal.org> Sun, 6 Mar 2005 10:17:35
I do not think that these 2 additional hooks are needed. This will really add alot of additional overhead as it is going to call every textarea hook 4 times for every textarea on a page. Besides these modifiaction can be handled better and cleaner in the javascript. If you take a look at Xinha/HTMLArea or FckEditor they both manipulate the dom once the page has loaded, and not during. This is a much better and cleaner method as it means that you can attach to any textarea with only a few commands. This is what javascript excels at. So I don't think this is needed.
I'd agree with you, perhaps, about the attributes tag. I don't think I agree about "post-title". I think it's highly likely that a module would use "pre" or "post-title" but not both. And since these are all in memory hooks I hardly see that calling 4 module hooks instead of 2 is going to make any performance difference at all, at all. Following your logic there's no need for "pre" either, because you can implement that in javascript from "post". Better and cleaner? I find php a hell of a lot easier to code and debug in than Javascript. But then that's just me. -- Julian Bond Email&MSM: julian.bond at voidstar.com Webmaster: http://www.ecademy.com/ Personal WebLog: http://www.voidstar.com/ M: +44 (0)77 5907 2173 T: +44 (0)192 0412 433 S: callto://julian.bond/
Hello, Please put this back on the drupal.org, and just so you know, if you have 4 parameters in the textarea, then it multiplies by 4 for each implementation of the hook. 2 modules, 8 function calls, 3 modules, 12 function call and so on. Gordon. On Sun, 2005-03-06 at 10:45 +0000, Julian Bond wrote:
gordon <drupal-devel@drupal.org> Sun, 6 Mar 2005 10:17:35
I do not think that these 2 additional hooks are needed. This will really add alot of additional overhead as it is going to call every textarea hook 4 times for every textarea on a page. Besides these modifiaction can be handled better and cleaner in the javascript. If you take a look at Xinha/HTMLArea or FckEditor they both manipulate the dom once the page has loaded, and not during. This is a much better and cleaner method as it means that you can attach to any textarea with only a few commands. This is what javascript excels at. So I don't think this is needed.
I'd agree with you, perhaps, about the attributes tag. I don't think I agree about "post-title". I think it's highly likely that a module would use "pre" or "post-title" but not both.
And since these are all in memory hooks I hardly see that calling 4 module hooks instead of 2 is going to make any performance difference at all, at all.
Following your logic there's no need for "pre" either, because you can implement that in javascript from "post".
Better and cleaner? I find php a hell of a lot easier to code and debug in than Javascript. But then that's just me.
-- Gordon Heydon <gordon@heydon.com.au>
Gordon Heydon <gordon@heydon.com.au> Sun, 6 Mar 2005 22:30:49
Please put this back on the drupal.org, Done
I'll try another tack more appropriate for the mailing list. I want to add a row of buttons between the title and textarea I want to add 3 javascript handlers to the textarea. onClick, OnSelect and onKeyUp. I can't see how to do this from javascript. Can you point me at an example. I've found a few for DOM modification that point me at a way to post the row of buttons by using getElementById and then insertBefore. That's going to be fairly messy getting from a php function to the javascript in 'post' to modifying the DOM to appearing on the screen. But probably do-able. But I haven't been able to find anything that suggests how to add handlers to an existing node. I suppose I could hide the whole shebang; Title, textarea, description and then recreate it all in 'post'. But the hook doesn't get all the parameters. -- Julian Bond Email&MSM: julian.bond at voidstar.com Webmaster: http://www.ecademy.com/ Personal WebLog: http://www.voidstar.com/ M: +44 (0)77 5907 2173 T: +44 (0)192 0412 433 S: callto://julian.bond/
Hello, Basically you use getElementByID or any of the other locater's, and then do something like this. obj.onclick = function () { alert('onclick'); }; Gordon. On Sun, 2005-03-06 at 12:32 +0000, Julian Bond wrote:
Gordon Heydon <gordon@heydon.com.au> Sun, 6 Mar 2005 22:30:49
Please put this back on the drupal.org, Done
I'll try another tack more appropriate for the mailing list.
I want to add a row of buttons between the title and textarea
I want to add 3 javascript handlers to the textarea. onClick, OnSelect and onKeyUp.
I can't see how to do this from javascript. Can you point me at an example. I've found a few for DOM modification that point me at a way to post the row of buttons by using getElementById and then insertBefore. That's going to be fairly messy getting from a php function to the javascript in 'post' to modifying the DOM to appearing on the screen. But probably do-able.
But I haven't been able to find anything that suggests how to add handlers to an existing node.
I suppose I could hide the whole shebang; Title, textarea, description and then recreate it all in 'post'. But the hook doesn't get all the parameters.
-- Gordon Heydon <gordon@heydon.com.au>
Gordon Heydon <gordon@heydon.com.au> Sun, 6 Mar 2005 23:44:16
Basically you use getElementByID or any of the other locater's, and then do something like this.
obj.onclick = function () { alert('onclick'); };
Hmmm. In Firefox, but not apparently in IE6. -- Julian Bond Email&MSM: julian.bond at voidstar.com Webmaster: http://www.ecademy.com/ Personal WebLog: http://www.voidstar.com/ M: +44 (0)77 5907 2173 T: +44 (0)192 0412 433 S: callto://julian.bond/
participants (3)
-
gordon -
Gordon Heydon -
Julian Bond