[Proto-Scripty] Re: Class Inheritance from Element
On Mar 25, 12:02 am, Glen a...@usa.com wrote: I would like to use Prototype's class inheritance to derive a class from Element as below: The current structure of Element and Class does not support such. I was wondering if anyone had anything more elegant. I have the same issue - I want to create my own classes that inherit from standard DOM elements, so I can do something like: var Button = Class.create(Element, { initialize: function($super, content) { $super('button'); this.update(content); } }); document.body.appendChild(new Button(submit)); But as you noted, Element in prototype is not a prototype Class that can be extended using Class.create. I decided not to muck about with that and instead write something else. So I create Class.createElement() that works like as you would expect, with the very serious caveat that you can't override most native methods (not sure why - I can override some, but not others). The implementation looks like this (and is mostly copied from Class.create): Class.createElement = function(tagname, impl) { var IS_DONTENUM_BUGGY = (function() { for ( var p in { toString : 1 }) { // check actual property name, so that it works with augmented // Object.prototype if (p === 'toString') return false; } return true; })(); return function() { var elm = new Element(tagname); properties = Object.keys(impl); // IE6 doesn't enumerate `toString` and `valueOf` (among other built- in // `Object.prototype`) properties, // Force copy if they're not Object.prototype ones. // Do not copy other Object.prototype.* for performance reasons if (IS_DONTENUM_BUGGY) { if (impl.toString != Object.prototype.toString) properties.push(toString); if (impl.valueOf != Object.prototype.valueOf) properties.push(valueOf); } for ( var i = 0, length = properties.length; i length; i++) { var property = properties[i], value = impl[property]; if (Object.isFunction(value) value.argumentNames()[0] == $super) { var method = value; value = (function(m) { return function() { return elm[m].apply(this, arguments); }; })(property).wrap(method); value.valueOf = method.valueOf.bind(method); value.toString = method.toString.bind(method); } impl[property] = value; } Object.extend(elm,impl); elm.initialize.apply(elm,arguments); return elm; }; }; -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Checkbox toggle fails while preventing a row onclick
Hello, I've got a table in which each row has an onclick to launch a pop up using ajax. The onclick for the row is set with in the tr tag. When I attempt to prevent this row onclick while toggling the check box within the row, it fails to toggle the check box. I'm using Event.stop(event) to prevent the row onclick from running when the check box is toggled. However, doing this appears to negate the click of the check box too. I need to allow the check box to be used normally, with out launching the row onclick and to have the rest of the row use the onclick. Any help / insight on this would be much appreciated. Thanks, Benjamin FYI: As a test, I've added an alert prior to the Event.stop(). When present, this alert displays the checkbox as being toggled when the alert is given and then changes back to the original state when the alert is confirmed. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] script.aculo.us autocomplete on dynamically added form field?
Hi, I have a form where I dynamically add extra fields. Here's my example code: http://pastie.org/908497 While I can use autocomplete on my first input field, I am unable to get it to work on any fields that I add after the page loads. Don't suppose anyone can offer any suggestions as to how I might achieve this? Thanks, Russell. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Optimize table content filtering.
I used the Scriptaculous autocompleter with a set of custom extend functions to filter table rows, tr tags, by a class name with some custom attributes. There is quite a bit of code below, so contact me if you need a more detailed walk-through. I can be reached in evenings, by usually calling your mother, who i may or may not have been banging. I love her stories.. or, probably more often by Gchat!! Javascript looks like this: Searcher = { selector : function ( instance ) { try { var ret = []; var partial = []; var entry = instance.getToken (); var count = 0; for (var i = 0; i instance.options.array.length ret.length instance.options.choices; i++) { var itemLabel = instance.options.array [ i ].label; var itemValue = instance.options.array [ i ].val; var itemId = instance.options.array [ i ].itemId; var foundPos = instance.options.ignoreCase ? itemLabel.toLowerCase().indexOf(entry.toLowerCase()) : itemLabel.indexOf(entry); while (foundPos != -1) { if (foundPos == 0 itemLabel.length != entry.length) { var li = 'li item-id=' + itemId + ' item-value=' + itemValue + ''; li += 'strong' + itemLabel.substr(0, entry.length) + '/ strong'; li += itemLabel.substr(entry.length); li += '/li'; ret.push(li); break; } else if (entry.length = instance.options.partialChars instance.options.partialSearch foundPos != -1) { if (instance.options.fullSearch || / \s/.test(itemLabel.substr(foundPos-1,1))) { var li = 'li item-id=' + itemId + ' item-value=' + itemValue + ''; li += itemLabel.substr(0, foundPos) + 'strong' + itemLabel.substr(foundPos, entry.length) + '/strong' + itemLabel.substr( foundPos + entry.length); li += '/li'; partial.push(li); break; } } foundPos = instance.options.ignoreCase ? itemLabel.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : itemLabel.indexOf(entry, foundPos + 1); } } if ( partial.length ) { ret = ret.concat ( partial.slice ( 0, instance.options.choices - ret.length ) ); } else { Searcher.hideItems ( '' ); } if ( ret.length == 0 ) { Searcher.hideItems ( '' ); } return ul + ret.join ( '' ) + /ul; } catch ( e ) { alert ( e ); } }, render: function () { try { if ( this.entryCount 0 ) { for ( var i = 0; i this.entryCount; i++ ) { this.index == i ? Element.addClassName ( this.getEntry ( i ), 'selected' ) : Element.removeClassName ( this.getEntry ( i ), 'selected' ); } if( this.hasFocus ) { this.show (); this.active = true; Searcher.showList ( this ); } } else { this.active = false; this.hide ( '' ); Searcher.hideItems ( '' ); } } catch ( e ) { alert ( 'Error in render: ' + e ); } }, showList : function ( instance ) { try { Searcher.hideItems ( '.open' ); var listItems = $$ ( '#item-searcher-list li' ); listItems.each ( function ( listItem ) { var variationId = listItem.readAttribute ( 'item-value' ); listItem.addClassName('open'); listItem.show (); $ ( 'list-item-' + variationId ).show (); }); }
[Proto-Scripty] Dragging between fixed and non-fixed Sortables (position offset bugs)
Hi Hariz, You seem to have replied in the thread Dragging between fixed and non- fixed Sortables (position offset bugs) but with a completely new topic (and new title). My guess is that you're writing via an email client and hit reply on a message from the other thread and just cleared out the message area of the new email and changed the title; that doesn't work, because there's a thread ID in the email headers. (Easy mistake to make! :-) ) Please be sure when mailing the list (or creating a message in GGroups) on a completely new topic *not* to reply within an existing thread (by using new email rather than reply or whatever); it mixes the two topics together. I've changed the thread title back. Thanks, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Apr 7, 8:42 pm, Hariz Soleminio harriz_solemi...@rocketmail.com wrote: Hi Guys, I'll ask a stupid question of newbies like me. I have a prototype and I use firebug for the development. I keep having prototype [Break on this error] Error in parsing value for 'top'. in my console. what seems to be the problem? is it my scripting? but I think i don't have any problem in my scripting. Since I'm just using a $(anyid) in my development. Thanks in advance guys. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] floating div
You have to learn about position:absolute css style. It will solve your issue. Le 7 avr. 2010 à 20:37, Martín Marqués martin.marq...@gmail.com a écrit : OK, I know this isn't strictly prototype, but I'll through it here. I have a div with id divsubmit which has an animated gif used when prototype is waiting for a response. So I use $('divsubmit').show() in onLoading: and $('divsubmit').hide in onComplete. The thing is that I have this div on the top of the page and everytime I .show() it, all the objects below it go down to make the div fit. I want the div to show up on top of the other objects. How do I do this? -- Martín Marqués select 'martin.marques' || '@' || 'gmail.com' DBA, Programador, Administrador -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com . To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en . -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Checkbox toggle fails while preventing a row onclick
Hi, Without code it's kind of hard to tell what's going wrong, but it *sounds* like you have handlers on both the checkbox's click event and the row's click event, and that you're calling Event.stop from within the checkbox's click event to (try to) prevent the row click from firing. But of course that cancels the event, including the checking of the checkbox. This is one of the places where you don't want to *stop* the event, you just want to prevent it from propagating (bubbling) up the DOM to ancestors of the element on which it occurred. So instead of calling #stop, call #stopPropagation[1], which does exactly that. (Prototype nicely provides this for you on browsers that don't support it natively.) So that's the minimal-impact way to fix it (I think, inferring from your question). There's another way which may have other benefits for you, but it's a larger change to what I infer is your current structure: Event delegation. Rather than watching every row and every checkbox in the table for clicks, just watch for clicks on the table, since clicks bubble. In your table click handler, if you're only interested in clicks on rows or checkboxes, do this: var element; element = event.findElement('tr, input[type=checkbox]'); if (!element) { /* ...click wasn't in a tr or checkbox; perhaps in the table margin... */ else if (element.tagName == 'INPUT') { /* ...handle click on checkbox; perhaps you just ignore it... */ } else { /* ...handle click on row... */ } Event#findElement takes a CSS selector and sees if it matches the element on which the click actually occurred; if not, it goes and check the element's parent element for a match, etc. The upshot is that you get the lowest matching element (the one closest to the actual click). One of the big advantages of event delegation is that you can happily add rows to the table and remove rows without worrying about handlers; you have just the one handler on the table. That's very useful for dynamic stuff. The cost is a small bit of extra complexity in the actual handler. [1] http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event-stopPropagation HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Apr 7, 11:23 pm, Benjamin xixbenjamin...@gmail.com wrote: Hello, I've got a table in which each row has an onclick to launch a pop up using ajax. The onclick for the row is set with in the tr tag. When I attempt to prevent this row onclick while toggling the check box within the row, it fails to toggle the check box. I'm using Event.stop(event) to prevent the row onclick from running when the check box is toggled. However, doing this appears to negate the click of the check box too. I need to allow the check box to be used normally, with out launching the row onclick and to have the rest of the row use the onclick. Any help / insight on this would be much appreciated. Thanks, Benjamin FYI: As a test, I've added an alert prior to the Event.stop(). When present, this alert displays the checkbox as being toggled when the alert is given and then changes back to the original state when the alert is confirmed. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Effect.Morph applied to background image
Hi all! Actually I'm working on a background auto-morph in order to make a moving background using effect.morph. So, basically I set up one bg and each x-time it will change to another bg. So what I have coded: // first, my init function in order to set the background, I make it in JS because I do not want to have a CSS conflict ;) function init() { $('top_frame').setStyle( { background:'transparent url(top_frame.jpg) no-repeat center top', width: '1000px', height: '275px' }); } // then the change it functionality :) function change() { $('top_frame').morph('background: url(images/top_frame2.jpg) no- repeat center top; width:1600px;'); alert('change done'); } // execute it after the DOM loaded function bindage() { init(); alert('init done, lets change it once!'); change(); } Event.observe(window, 'load', bindage); And I have one div named top_frame in my HTML. You can see the example here: http://jinsa.fr/morphbg/test.html Ok ok, so that worked in my head but don't make it in the real world (as real that can be the Internet ^^). The effect.morph is launched because we can see the width change but it do not switch to the other bgimage :/ Do you have an idea how to make it work? Thanks, JF. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] script.aculo.us autocomplete on dynamically added form field?
Hi, You should use full dom creation for your new inputs instead of innerHTML, and use prototype for manipulating Events and DOM On Thu, Apr 8, 2010 at 2:04 AM, Albanach alban...@gmail.com wrote: Hi, I have a form where I dynamically add extra fields. Here's my example code: http://pastie.org/908497 While I can use autocomplete on my first input field, I am unable to get it to work on any fields that I add after the page loads. Don't suppose anyone can offer any suggestions as to how I might achieve this? Thanks, Russell. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Firing a click event.
Hi. Brain has gone to sleep. I've got a form where I'd like to be able to allow some controls to be disabled by a checkbox. Working code ... script type=text/javascript function handleHideClick(ev) { hideClick(ev.element()); } function hideClick(el) { el.up('tr').select('input[type=text]') .each ( function(el2) { el2.disabled = el.checked; } ); } document.observe('dom:loaded', function(ev_dom_loaded) { $$('.dtl_Blank input[type=checkbox]').each(function (el) { hideClick($(el).observe('click', handleHideClick)); }); }); /script Is there a way to simplify this? I initially thought that Element.fire() would help, but that is for custom events only. Essentially, whilst setting the click handler, I want to be able to call the handler also. Regards, Richard. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Firing a click event.
On 8 April 2010 12:20, Richard Quadling rquadl...@googlemail.com wrote: Hi. Brain has gone to sleep. I've got a form where I'd like to be able to allow some controls to be disabled by a checkbox. Working code ... script type=text/javascript function handleHideClick(ev) { hideClick(ev.element()); } function hideClick(el) { el.up('tr').select('input[type=text]') .each ( function(el2) { el2.disabled = el.checked; } ); } document.observe('dom:loaded', function(ev_dom_loaded) { $$('.dtl_Blank input[type=checkbox]').each(function (el) { hideClick($(el).observe('click', handleHideClick)); }); }); /script Is there a way to simplify this? I initially thought that Element.fire() would help, but that is for custom events only. Essentially, whilst setting the click handler, I want to be able to call the handler also. Regards, Richard. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling Ha! Seems that [1] and [2] have it covered. OOI, the fireEvent code at the bottom of [1] (Post #9 by Rick), (cleaned up the quotes) ... function fireEvent(element,event){ if(document.createEvent){ // dispatch for firefox + others var evt = document.createEvent('HTMLEvents'); evt.initEvent(event, true, true ); // event type,bubbling,cancelable return !element.dispatchEvent(evt); } else { // dispatch for IE var evt = document.createEventObject(); return element.fireEvent('on' + event,evt) } } looks good and useful. Is there a way to get this tested across a wide range of browsers/os/etc.? Does Prototype have a test farm? Richard. [1] http://jehiah.cz/archive/firing-javascript-events-properly [2] http://lifescaler.com/2008/04/simulating-mouse-clicks-in-javascript/ -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] The Unofficial Wiki
Hi folks, As many of you know, we've had an unofficial Prototype script.aculo.us wiki for about 18 months: http://proto-scripty.wikidot.com/ I have a question for the community, but first a preamble. Preamble: In the last year (more, actually), there's been precisely one edit by someone other than me. :-) (Doug Reeder added an on0 handler to the bulletproof ajax page.) I wrote the vast majority of the articles and have been very nearly the only person maintaining them, not that there's been a lot to do on that front. (Don't get the impression I mind; I don't.) This suggests to me that - 1. We don't need a wiki or 2. We do, but it's too hard to contribute to that one because you have to request access and wait for it to be granted As a side note: Tobie and the core team are working on moving the main Prototype website to GitHub (don't worry, the URL doesn't change) from the current CMS it's on (Mephisto), and Tobie says that it will be a lot easier for people to contribute official content to the website once that's done. Question: Do we need a wiki with user-generated content? Or should we just move all of the relevant content to the Prototype website and make sure the process for contributing to the website is well-publicized, easy, and efficient? Thanks, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] The Unofficial Wiki
If it becomes easy to contribute to the official page then yes, that's the ideal answer as it's easier to find. If it wasn't for this group, I wouldn't have known about your wiki. On Apr 8, 2010, at 6:23 AM, T.J. Crowder t...@crowdersoftware.com wrote: Hi folks, As many of you know, we've had an unofficial Prototype script.aculo.us wiki for about 18 months: http://proto-scripty.wikidot.com/ I have a question for the community, but first a preamble. Preamble: In the last year (more, actually), there's been precisely one edit by someone other than me. :-) (Doug Reeder added an on0 handler to the bulletproof ajax page.) I wrote the vast majority of the articles and have been very nearly the only person maintaining them, not that there's been a lot to do on that front. (Don't get the impression I mind; I don't.) This suggests to me that - 1. We don't need a wiki or 2. We do, but it's too hard to contribute to that one because you have to request access and wait for it to be granted As a side note: Tobie and the core team are working on moving the main Prototype website to GitHub (don't worry, the URL doesn't change) from the current CMS it's on (Mephisto), and Tobie says that it will be a lot easier for people to contribute official content to the website once that's done. Question: Do we need a wiki with user-generated content? Or should we just move all of the relevant content to the Prototype website and make sure the process for contributing to the website is well-publicized, easy, and efficient? Thanks, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: The Unofficial Wiki
And my answer: I really like having something owned by the community, but I don't see much point if there's no itch to scratch. People are more likely to find content on the main site than in an unofficial wiki somewhere. As long as contributing to the site is _easy_, well- publicized, and not a long drawn-out process, I think we're all (core team, community, new adopters of Prototype) better served migrating the content to the main site and going that route. -- T.J. :-) On Apr 8, 2:23 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi folks, As many of you know, we've had an unofficial Prototype script.aculo.us wiki for about 18 months:http://proto-scripty.wikidot.com/ I have a question for the community, but first a preamble. Preamble: In the last year (more, actually), there's been precisely one edit by someone other than me. :-) (Doug Reeder added an on0 handler to the bulletproof ajax page.) I wrote the vast majority of the articles and have been very nearly the only person maintaining them, not that there's been a lot to do on that front. (Don't get the impression I mind; I don't.) This suggests to me that - 1. We don't need a wiki or 2. We do, but it's too hard to contribute to that one because you have to request access and wait for it to be granted As a side note: Tobie and the core team are working on moving the main Prototype website to GitHub (don't worry, the URL doesn't change) from the current CMS it's on (Mephisto), and Tobie says that it will be a lot easier for people to contribute official content to the website once that's done. Question: Do we need a wiki with user-generated content? Or should we just move all of the relevant content to the Prototype website and make sure the process for contributing to the website is well-publicized, easy, and efficient? Thanks, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: The Unofficial Wiki
I agree - a central site that is easy to contribute to seems the best path. On Thu, Apr 8, 2010 at 8:29 AM, T.J. Crowder t...@crowdersoftware.com wrote: And my answer: I really like having something owned by the community, but I don't see much point if there's no itch to scratch. People are more likely to find content on the main site than in an unofficial wiki somewhere. As long as contributing to the site is _easy_, well- publicized, and not a long drawn-out process, I think we're all (core team, community, new adopters of Prototype) better served migrating the content to the main site and going that route. -- T.J. :-) On Apr 8, 2:23 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi folks, As many of you know, we've had an unofficial Prototype script.aculo.us wiki for about 18 months: http://proto-scripty.wikidot.com/ I have a question for the community, but first a preamble. Preamble: In the last year (more, actually), there's been precisely one edit by someone other than me. :-) (Doug Reeder added an on0 handler to the bulletproof ajax page.) I wrote the vast majority of the articles and have been very nearly the only person maintaining them, not that there's been a lot to do on that front. (Don't get the impression I mind; I don't.) This suggests to me that - 1. We don't need a wiki or 2. We do, but it's too hard to contribute to that one because you have to request access and wait for it to be granted As a side note: Tobie and the core team are working on moving the main Prototype website to GitHub (don't worry, the URL doesn't change) from the current CMS it's on (Mephisto), and Tobie says that it will be a lot easier for people to contribute official content to the website once that's done. Question: Do we need a wiki with user-generated content? Or should we just move all of the relevant content to the Prototype website and make sure the process for contributing to the website is well-publicized, easy, and efficient? Thanks, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- Shane McCarron halindr...@gmail.com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Checkbox toggle fails while preventing a row onclick
Thanks TJ, That worked perfectly. Many thanks! Ben On Thu, Apr 8, 2010 at 2:41 AM, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Without code it's kind of hard to tell what's going wrong, but it *sounds* like you have handlers on both the checkbox's click event and the row's click event, and that you're calling Event.stop from within the checkbox's click event to (try to) prevent the row click from firing. But of course that cancels the event, including the checking of the checkbox. This is one of the places where you don't want to *stop* the event, you just want to prevent it from propagating (bubbling) up the DOM to ancestors of the element on which it occurred. So instead of calling #stop, call #stopPropagation[1], which does exactly that. (Prototype nicely provides this for you on browsers that don't support it natively.) So that's the minimal-impact way to fix it (I think, inferring from your question). There's another way which may have other benefits for you, but it's a larger change to what I infer is your current structure: Event delegation. Rather than watching every row and every checkbox in the table for clicks, just watch for clicks on the table, since clicks bubble. In your table click handler, if you're only interested in clicks on rows or checkboxes, do this: var element; element = event.findElement('tr, input[type=checkbox]'); if (!element) { /* ...click wasn't in a tr or checkbox; perhaps in the table margin... */ else if (element.tagName == 'INPUT') { /* ...handle click on checkbox; perhaps you just ignore it... */ } else { /* ...handle click on row... */ } Event#findElement takes a CSS selector and sees if it matches the element on which the click actually occurred; if not, it goes and check the element's parent element for a match, etc. The upshot is that you get the lowest matching element (the one closest to the actual click). One of the big advantages of event delegation is that you can happily add rows to the table and remove rows without worrying about handlers; you have just the one handler on the table. That's very useful for dynamic stuff. The cost is a small bit of extra complexity in the actual handler. [1] http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event-stopPropagation HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Apr 7, 11:23 pm, Benjamin xixbenjamin...@gmail.com wrote: Hello, I've got a table in which each row has an onclick to launch a pop up using ajax. The onclick for the row is set with in the tr tag. When I attempt to prevent this row onclick while toggling the check box within the row, it fails to toggle the check box. I'm using Event.stop(event) to prevent the row onclick from running when the check box is toggled. However, doing this appears to negate the click of the check box too. I need to allow the check box to be used normally, with out launching the row onclick and to have the rest of the row use the onclick. Any help / insight on this would be much appreciated. Thanks, Benjamin FYI: As a test, I've added an alert prior to the Event.stop(). When present, this alert displays the checkbox as being toggled when the alert is given and then changes back to the original state when the alert is confirmed. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] enumerate hash
Hello I am having a difficult time trying to enumerate a hash to determine if a give key is in the hash and if so delete it and its value. If I could approach it index it would be function remove(valueToTest, hashToBeTested){ -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] enumerate hash
Your message was truncated, but the method you are looking for is `unset`. http://api.prototypejs.org/language/hash/prototype/unset/ Since the function is using `delete this._object[key]` nothing will occur if you feed it a value that actually does not exist in the hash object. Best, Alex On Thu, Apr 8, 2010 at 3:06 PM, chrysanthe m chrysant...@gmail.com wrote: Hello I am having a difficult time trying to enumerate a hash to determine if a give key is in the hash and if so delete it and its value. If I could approach it index it would be function remove(valueToTest, hashToBeTested){ -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: enumerate hash
Sorry sudden send resume in this reply Hello I am having a difficult time trying to enumerate a hash to determine if a give key is in the hash and if so delete it and its value. If I could approach it index it would be function remove(valueToTest, hashToBeTested){ for(i=0;ihashToBeTested.length;i++){ if(valueToTest==hashToBeTested[i]) hashToBeTested.unset(valueToTest); } Would I do it like hashToBeTested.each(function(valueToTest){ if(valueToTest==this)hashToBeTested.unset(valueToTest); },hashToBeTested); return hashToBeTested; which I am sure is wrong syntactically if not semantically. Can someone guide the proper way and more deeply the use of this? On Thu, Apr 8, 2010 at 3:06 PM, chrysanthe m chrysant...@gmail.com wrote: -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: enumerate hash
Ah, I see. You can handle this using Enumerable's invoke. This code should make it clear: a = new Hash({ x : foo, y : bar }); b = new Hash({ x : zam, y : moof }); a.get(x); foo b.get(x); zam [a,b].invoke(get,x); [foo, zam] [a,b].invoke(unset,x) [foo, zam] a.get(x) (undefined) Cheers, Alex On Thu, Apr 8, 2010 at 3:24 PM, chrysanthe m chrysant...@gmail.com wrote: Sorry sudden send resume in this reply Hello I am having a difficult time trying to enumerate a hash to determine if a give key is in the hash and if so delete it and its value. If I could approach it index it would be function remove(valueToTest, hashToBeTested){ for(i=0;ihashToBeTested.length;i++){ if(valueToTest==hashToBeTested[i]) hashToBeTested.unset(valueToTest); } Would I do it like hashToBeTested.each(function(valueToTest){ if(valueToTest==this)hashToBeTested.unset(valueToTest); },hashToBeTested); return hashToBeTested; which I am sure is wrong syntactically if not semantically. Can someone guide the proper way and more deeply the use of this? On Thu, Apr 8, 2010 at 3:06 PM, chrysanthe m chrysant...@gmail.comwrote: -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: enumerate hash
Hi Alex Thanks, but a newbie here so that was drinking at a firehose. Let me parse it to better understand. First can you really invoke on two separate enumerable objects with that [n,n1,n2] syntax? That is tremendous. My problem is I need to first check the presence of a key before I unset it b/c I found out unset-ing a non-existent key seems to zero the struct; also it is more courteous, grin. So how would I construct the and parameterize the annonymous function to do the check and if present do it to itself. Ideally I would like to pass in the enumerable, call the function and return the modified(or not) enumerable in the function's return. On Thu, Apr 8, 2010 at 4:41 PM, Alex Wallace alexmlwall...@gmail.comwrote: Ah, I see. You can handle this using Enumerable's invoke. This code should make it clear: a = new Hash({ x : foo, y : bar }); b = new Hash({ x : zam, y : moof }); a.get(x); foo b.get(x); zam [a,b].invoke(get,x); [foo, zam] [a,b].invoke(unset,x) [foo, zam] a.get(x) (undefined) Cheers, Alex On Thu, Apr 8, 2010 at 3:24 PM, chrysanthe m chrysant...@gmail.comwrote: Sorry sudden send resume in this reply Hello I am having a difficult time trying to enumerate a hash to determine if a give key is in the hash and if so delete it and its value. If I could approach it index it would be function remove(valueToTest, hashToBeTested){ for(i=0;ihashToBeTested.length;i++){ if(valueToTest==hashToBeTested[i]) hashToBeTested.unset(valueToTest); } Would I do it like hashToBeTested.each(function(valueToTest){ if(valueToTest==this)hashToBeTested.unset(valueToTest); },hashToBeTested); return hashToBeTested; which I am sure is wrong syntactically if not semantically. Can someone guide the proper way and more deeply the use of this? On Thu, Apr 8, 2010 at 3:06 PM, chrysanthe m chrysant...@gmail.comwrote: -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: The Unofficial Wiki
T.J. Crowder: Question: Do we need a wiki with user-generated content? We should: just move all of the relevant content to the Prototype website and make sure the process for contributing to the website is well-publicized, easy, and efficient I think the site needs an integrated contribution system for Prototype Extensions, better than jQuery's(http://plugins.jquery.com/). It would be great if the extensions and the patch submission system shared a contribution system. Some want something easier than learning git, rake, lighthouse, etc., in order to contribute; maybe a web front-end to whichever code is in place, to lower the barrier to contributing. User generated code and examples could be posted maintained right on the site with (Prototype Friendly) syntax highlighting. Rico 2.0 has lots of goodies[1], so does Scriptaculous, it would be awesome to sync all these projects up, make the components modular with clear a dependance scheme, especially when considering the future of the library. [1] http://openrico.sourceforge.net/examples/index.html -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.