[Proto-Scripty] Re: Finding the position of a scroll bar for an element with overflow:auto
yeah, try $(myContainer).scrollTop On Nov 7, 5:10 pm, Shane McCarron halindr...@gmail.com wrote: I have an element that has overflow:auto. The contents of the element are updated from time to time via ajax calls. I want to ensure that when this happens, if the user has scrolled down into the content, their scroll position stays the same even through the content is effectively regenerated. Is there a way to get the scrollTop for an element? -- 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] Re: Variables in $$() ?????
Thanks for that but like most things in the prototype documentation, it lacks the type of clarity that I can understand. Nice way to get help... Your docs suck so just spoon feed me the answer The answer to your initial approach is an issue with basic javascript string behavior and was nailed on the head by both Johnathon and David var myVariableValue = 3; var mySelector = input[type=radio][name='type'] [value='myVariableValue']; In the above expression the value of myVariableValue isn't evaluated, its literally written into the string as is, hence its not the value 3 its the string value myVariableValue Hope you like puree'd corn template var myTemplate = new Template(input[type=#{type}][name='#{name}'] [value='#{value}']); var dto = { type : 'radio', name : 'type', value : '3' }; var selector = myTemplate.evaluate(dto); On Sep 25, 6:28 pm, T.J. Crowder t...@crowdersoftware.com wrote: The fundamental thing you need to do is _simplify_, divide and conquer. Is it the XML stuff that isn't working, or is it the radio button stuff that isn't working? Walk through with a debugger, etc. The `$$` of this is not the problem barring some strange thing, you'll need to look elsewhere. -- T.J. On Sep 25, 4:16 pm, Phil Petree phil.pet...@gmail.com wrote: Morning TJ! I know it SHOULD work... I'm just saying it didnt. works: // set radio button for type selectThis = {selectID: 'type', selectValue: transport.responseXML.getElementsByTagName('type')[0].firstChild.nodeValue} ; $$(radioTemplate.evaluate(selectThis))[0].writeAttribute(checked, checked); didn't work: var selectThis = transport.responseXML.getElementsByTagName('type')[0].firstChild.nodeValue; $$(input[type=radio][name='type'][value=' + selectThis + ']).writeAttribute(checked, checked); ALSO: This works: selectThis = {matchString: transport.responseXML.getElementsByTagName('state')[0].firstChild.nodeValue }; $$('select#ajstate option').each(function(o){ if(o.value == selectTemplate.evaluate(selectThis)){o.selected = true;$break;} }); But moving it into a function doesn't: setSelect('ajState', transport.responseXML.getElementsByTagName('state')[0].firstChild.nodeValue ); function setSelect(strID, strValue) { var selectIDTemplate = new Template('#{matchID}'); var selectTemplate = new Template('#{matchString}'); var selectThis; var selectID; selectID = {matchID: strID}; selectThis = {matchString: strValue }; $$('select#selectIDTemplate.evaluate(selectID) option').each(function(o){ if(o.value == selectTemplate.evaluate(selectThis)){o.selected = true;$break;} });} I think I am either daft or extremely tired! LOL On Sat, Sep 25, 2010 at 10:34 AM, T.J. Crowder t...@crowdersoftware.comwrote: Hi, David, although your suggestion doesn't throw any errors, it doesnt work either... kinda wierd as I thought it would... It does work, barring there being something wrong somewhere else: http://jsbin.com/elota3 The problem with your original code was as as Jonathan said, you were passing the string input[type=radio][name='type'][value=selectThis] into $$ as the selector. David's suggestion fixes that by using the *value* of selectThis rather the actual text selectThis. As the live example above shows, that works. FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Sep 25, 2:21 pm, Phil Petree phil.pet...@gmail.com wrote: David, although your suggestion doesn't throw any errors, it doesnt work either... kinda wierd as I thought it would... and it would have been MUCH simpler to implement too! On Sat, Sep 25, 2010 at 8:57 AM, David Behler d.beh...@gmail.com wrote: What about this: $$(input[type=radio][name='type'][value=' + selectThis + ']) ? Am 25.09.2010 14:41, schrieb Phil Petree: Jonathan, Thanks for that but like most things in the prototype documentation, it lacks the type of clarity that I can understand. IOW, I can read the documentation, scratch my head and say huh? I leave that documentation thinking this might be what I need but have no clue as to how to implement that to solve my problem. Which is exactly what happened here... OK, I need to use templates to somehow sprintf the string constant into a direct value but huh? On Sat, Sep 25, 2010 at 7:59 AM, Jonathan Rosenberg j...@tabbysplace.orgwrote: You're passing a string constant to $$ input[type=radio][name='type'][value=selectThis]) 'selectThis' will not be evaluated, as you seem to be expecting. Have a loook at Tenplate to do what you want: http://www.prototypejs.org/api/template -- Jonathan Rosenberg Founder Executive Director
[Proto-Scripty] Re: Passing Variables to Functions in addEventListener Within a Class
You can just add parameters to the bind call and they will show up in execution. $(id).observe('mousedown', this.myFunction.bind(this, otherParam); Then I believe it shows up after the event. function myFunction(event, param){... but in your case, simply binding to this will allow you to reference the instance's ID and all other properties associated with the class instance and you shouldn't have to basically curry extra parameters to the event listener. -- http://positionabsolute.net On Jul 23, 2:48 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Since you're creating the event handler inside your `initialize` function, you can take advantage of the fact it's already a closure by assigning `this` to a local variable (`self` is a common name for it) and then using `self` within the closure (the event handler), since it will inherit it. Here's an example (with a few other things cleaned up as well, I've included comments): initialize: function(id,name,top,left){ var self = this; // Keep a reference to the instance for use below try{ this.id = id; this.name = name; this.currentTop = top; this.currentLeft = left; // Use `observe`, not `addEventListener`, for IE support $(id).observe(mousedown, function(event) { // `event` not `this.id` // Throughout, use `self` to refer to the instance alert(self.id); self.myFunction(self.id); }); // No `false` needed with `observe` } catch(error){alert(error);} }, Alternately, if you don't like using `self`, or if the function you want to use is already defined somewhere, you can use Prototype's Function#bind. #bind creates a closure for you behind the scenes that will turn around and call the original function such that `this` is set correctly: initialize: function(id,name,top,left){ try{ this.id = id; this.name = name; this.currentTop = top; this.currentLeft = left; // Use `observe`, not `addEventListener`, for IE support $(id).observe(mousedown, (function(event) { // `event` not `this.id` alert(this.id); this.myFunction(this.id); }).bind(this)); // Note the `bind` (and as above, no `false` needed with `observe`) } catch(error){alert(error);} }, More on closures here:http://blog.niftysnippets.org/2008/02/closures-are-not-complicated.html More on `this` and how it's not the same in JavaScript as in some other languages:http://blog.niftysnippets.org/2008/04/you-must-remember-this.html More on binding here:http://api.prototypejs.org/language/function/prototype/bind/http://proto-scripty.wikidot.com/prototype:tip-using-an-instance-meth... HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Jul 23, 6:16 pm, Doc Torbin mtor...@gmail.com wrote: I am working on a class now and part of the initialization is adding event listeners to an object. I'd like to pass some value through to the functions that are attributes of the class but I can't seem to figure it out. Here's a sample piece of the code: var MyClass= new Class.create(); MyClass.prototype = { initialize: function(id,name,top,left){ try{ this.id = id; this.name = name; this.currentTop = top; this.currentLeft = left; $(id).addEventListener(mousedown,function(this.id){ alert(this.id); this.myFunction(this.id); },false); } catch(error){alert(error);} }, myFunction:function(event){ this.mouseState++; $('status').innerHTML = The object has been picked up. || mouseState is + this.mouseState; } }; Any suggestions would be much appreciated. - MT -- 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: Ajax abort method
I did something similar in that I just patched Ajax.Request with some extra functionality to allow timeouts, I never fussed with it further than fundamental tests but it certainly worked. Take a peak and maybe you can learn how to write something to meet your own needs http://positionabsolute.net/blog/2008/07/prototype-ajax-request-timeout.php On Jul 22, 5:29 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, There's a ticket for it:https://prototype.lighthouseapp.com/projects/8886/tickets/302 and it's mentioned in this one:https://prototype.lighthouseapp.com/projects/8886/tickets/308 Looks like #302 is waiting for someone to write some tests, but: I know that separate from Mark's stuff in #308, there's going to be an Ajax API rewrite (and possibly implementation rewrite as well) for 2.0. -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Jul 22, 8:09 am, Ran Berenfeld berenfeld...@gmail.com wrote: I'm sure this was asked before. I'm running a web site with continuous ajax calls to the same server page. Now I want that if the Ajax is not completed in (say) 5 seconds, the call will be aborted and a new call s made. I've seen pages in the web that suggests an implementation for an abort method. Will there be one in the upcoming release ? And should this method be used ? Thanks Ran Site Admin -http://www.ichess.co.il -- 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: How do I remove and stash an observer?
just store the reference to the listener and re-attach it to the element after the user has successfully purchased more comment tokens or whatnot. var myListener = function(){}; $(button).stopObserving(); //.. user buys tokens... $(button).observe('click', myListener); -- http://positionabsolute.net On Jul 21, 4:26 pm, Walter Lee Davis wa...@wdstudio.com wrote: I have a video editing app that I'm working on where you can add captions to your movie up to a total number of purchased captions. When you reach that limit, I disable the buttons that add more captions by using Element.stopObserving and changing the button image to reflect this disabled nature. Now the client would like me to add purchase more to the same screen, so I would like to know if I can memoize the listener from an element, disable it, and then re-enable it from memory later in the same session. I know that this page will work the way it is if I reload the page after a successful purchase of new captions, but it's a big page, and I'd like to avoid that if I can. Any ideas? Thanks, Walter -- 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: How would I get a closer set of siblings?
This would be an ideal use case for XPath. On Mar 5, 10:35 am, Walter Lee Davis wa...@wdstudio.com wrote: Thanks, yes that might work. But I am trying to write something which is structure-agnostic, since it goes in a plug-in for a Web design application, and I have no idea how people will want to use it. Alex's suggestion allows me to do the very least (and therefore resist the urge to screw up) while still offering an unsurprising result in a wide range of layout situations. Walter On Mar 5, 2010, at 8:08 AM, Eric wrote: Hi, All the proposed solutions are very nice example of coding, but however you may ask yourself this question: If there is no easy way to do the processing I want with my data structure, am I sure I am using the right data structure? In other words, instead of coding heavy processing functions couldn't you just change your DOM structure to optimize whatever processing you need to do with them. In your case, adding a DIV around each H3-P-P-P... sequence would do the trick. Alex: Very nice implementation! Eric On Feb 23, 6:20 pm, Walter Lee Davis wa...@wdstudio.com wrote: Wow, thanks very much Alex! Walter On Feb 23, 2010, at 11:28 AM, Alex Wallace wrote: Here's a slightly better version, as it crawls the tree itself instead of grabbing and filtering all of the element's nextSiblings(). Since it avoids the call to recursivelyCollect() it's a bit faster (with 10 siblings after the requested node, it's about 20% faster - when I upped it to about 40 elements after the node, it ran well over 250% faster). If you have a lot of nodes to filter for the accordion, I'd definitely use this version. function fasterSameTagSiblings(element) { element = $(element); var results = [], node = element.nextSibling, tag; while (node = node.nextSibling) { if (node.nodeType === 1) { tag = tag || node.tagName.toLowerCase(); if (node.tagName.toLowerCase() === tag) results.push(node) else break; } } return results; } Cheers, Alex Micro-optimization for sure, but it was bugging me. :) function fasterSameTagSiblings(element) { element = $(element); var results = [], node = element.nextSibling, tag; while (node = node.nextSibling) { if (node.nodeType === 1) { tag = tag || node.tagName.toLowerCase(); if (node.tagName.toLowerCase() === tag) results.push(node) else break; } } return results; } On Mon, Feb 22, 2010 at 8:24 PM, Walter Lee Davis wa...@wdstudio.com wrote: The heads and the paragraphs are all at the same level, and I don't want all the paragraphs, just the ones between this head and the next head. (It's for an accordion effect.) So while up('div').select('p') would do exactly what you say, it would leave me where I started. Thanks, Walter On Feb 22, 2010, at 5:46 PM, Matt Foster wrote: This is probably too obvious to be right but if you're simply looking for all of the paragraph tags at that level could you simply go up to the parent and select down from there? On Feb 22, 12:57 pm, Paul Kim kimba...@gmail.com wrote: Hi Alex, thanks for the tip. I've modified the function based on your tip and your example function: function consecutiveSameTagSiblings(element) { var element = $(element); var nextSiblings = element.nextSiblings(); var similarElements = []; similarElements.push(element); for (var i=0; i nextSiblings.length; i++) { if (element.tagName == nextSiblings[i].tagName) { similarElements.push(nextSiblings[i]); } else { break; } } return similarElements; } On Mon, Feb 22, 2010 at 9:50 AM, Alex Wallace alexmlwall...@gmail.comwrote: Paul, one recommendation: store the results of element.nextSiblings() in a local variable outside of the loop. DOM traversals are pretty slow. Best, Alex On Mon, Feb 22, 2010 at 12:28 PM, Paul Kim kimba...@gmail.com wrote: Hi Walter, if you want to get all similar elements up to but not including the next head, I would use Prototype's Element.nextSiblings() to loop through all elements with the same tagName and break when the tagName is different. Here is a function I created just now that would hopefully do what you want: function getSimilarElements(element) { var element = $(element); var similarElements = new Array(); for (var i=0; i element.nextSiblings().length; i
[Proto-Scripty] Re: AsyncExecutioner
Feel free to post questions or comments here as I disabled them on the actual article. I think this is a valuable plugin for Prototype, it certainly isn't a common use case but there are instances where data gets too big to handle in one shot. On Jan 11, 9:51 am, Matt Foster mattfoste...@gmail.com wrote: Hey Everyone, I've completed work on a new Prototype plugin to handle massive datasets elegantly and avoid the dreaded Stop Script dialog. It uses a chunking algorithm to split up the dataset into small pieces, and then loop over those using chained setTimeout executions to allow a break in execution in order for regular UI processing to be handled, such as scrolling or selecting text. It can be extremely useful for less than pertinent processing that can be carried on in the background. http://positionabsolute.net/blog/2010/01/asynchronous-execution.php Regards, Matt -- 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] AsyncExecutioner
Hey Everyone, I've completed work on a new Prototype plugin to handle massive datasets elegantly and avoid the dreaded Stop Script dialog. It uses a chunking algorithm to split up the dataset into small pieces, and then loop over those using chained setTimeout executions to allow a break in execution in order for regular UI processing to be handled, such as scrolling or selecting text. It can be extremely useful for less than pertinent processing that can be carried on in the background. http://positionabsolute.net/blog/2010/01/asynchronous-execution.php Regards, Matt -- 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: self-or-ancestor in one whack?
You could use a closure to ensure you're dealing with the right element. $$('.my_table td').each(function(cell){ cell.observe('mouseover', listener.curry(cell)); }); function listener(cell, evt){ if(evt.element() != cell) return false; } Are you trying to have a clean way to avoid flickering? -- http://positionabsolute.net On Dec 19, 7:00 pm, Tobie Langel tobie.lan...@gmail.com wrote: var elm = evt.findElement('td'); is exactly the same as doing: var elm = evt.element(); if(elm.tagName.toString().toLowerCase() != 'td') elm = elm.up ('td'); Only it'll accept any kind of CSS selector. On Dec 19, 3:38 pm, Walter Lee Davis wa...@wdstudio.com wrote: I'll give that a try. I'm not sure (from the API docs) if that's going to do exactly what I want or not. Thanks, Walter On Dec 19, 2009, at 9:23 AM, ColinFine wrote: On Dec 18, 5:51 pm, Walter Lee Davis wa...@wdstudio.com wrote: I use this construction quite a lot: var elm = evt.element(); if(elm.tagName.toString().toLowerCase() != 'td') elm = elm.up('td'); whenever I am constructing a rollover listener, since it works around the whole issue with mouseover / out events firing whenever you move over a child of the element you're trying to observe. Is there a simpler way to do this, a more Prototype-y way, that is? I've had a look around the API, and I also had a Google, but the former didn't turn up anything useful and the latter turned up every commit message from every project that includes Prototype. I belive that is what Element.findElement is for. Colin -- 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 athttp://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: Complete graphical toolkit in js
Ext.js has a ton of UI stuff prebaked http://extjs.com -- http://positionabsolute.net On Dec 18, 4:40 am, Frédéric f...@gbiloba.org wrote: Hi, I'm wondering: does it exist a complete graphical toolkit in javascript? Something like Qt or Gtk, which allows to build complex GUI? I found several nice little projects, but they all use their own design... Thanks, -- Frédéric -- 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: Multi-dimensional JSON passed in an Ajax request?
I'd just put it in a variable. parameters : '?method=saveDatadata='+data.toJSON(); -- http://positionabsolute.net On Dec 17, 6:48 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Ajax.Updater (and the rest) don't claim to post object graphs to the server, and in fact they don't. They only pass name-value pairs, because they're doing normal HTTP GETs or POSTs, which are based on name-value pairs. HTTP doesn't know anything about JSON. If you want to pass an object graph, you could pass a single parameter with your JSON-formatted data as the value: new Ajax.Updater(this.msg, '/inc/Calendar/Validate.php', { 'parameters': {json: this.toJSON()} } ); ...and then decode the JSON-formatted data (the value of the 'json' parameter) on the server. There are JSON libraries for most server- side languages (and if there isn't one that suits your environment, well, the point of JSON is that it is easily parsed -- see json.org for details). HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Dec 17, 10:14 pm, Ian R i...@fairmountfair.com wrote: So ok, I have this JSON string I'm trying to pass as a post. From my object's toJSON() method, I get this string: { anonymous_element_1: { class: required, msg: }, anonymous_element_2: { class: required, msg: }, public_phone: { class: phone, value: 706-201-1149, msg: }, private_phone: { class: phone, value: 315-487-9176, msg: } } Which is valid JSON according tohttp://www.jsonlint.com/... However, when I try to pass this to a PHP script: new Ajax.Updater(this.msg, '/inc/Calendar/Validate.php', { 'parameters': this.toJSON() } ); I get nothing passed. However, I've noticed that if I take the multidimensional aspect out of it and just use the format {'key':'value,'key':'value'}, it passes just fine. Also, if I specifically set the method to get, I this passed in $_GET Array ( [{anonymous_element_1:_ {class:_required,_msg:_},_anonymous_element_2:_ {class:_required,_msg:_},_public_phone:_ {class:_phone,_value:_706-201-1149,_msg:_},_private_phone:_ {class:_phone,_value:_315-487-9176,_msg:_}}] = ) Basically a crazy URL-encoded version of my JSON, as the key in a valueless array. Hm. What am I doing wrong here? I just don't get it. Thanks in advance! Ian -- 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: Sychronize many asynchronous Ajax.Request
I'd recommend taking a look at my Ajax Service Queue approach, such that all requests go through the service object, and in the subclass for the queue's case won't send the next request until its predecessor has returned. It needs to be updated for 1.6 but the idea is on the wall for you to look at... Most pertinently is the onFinish event which would work perfectly for your circumstance. http://positionabsolute.net/blog/2007/04/ajax-request-queue.php On Nov 24, 8:30 am, Alex McAuley webmas...@thecarmarketplace.com wrote: Yes... Objects and thier properties are built and stored in memory (how else would they get built) - the CPU does the calculations and outputs the opcode to the browser (which reads from memory) what it needs to do with the object (In very simple terms)... So it stands to reason that if you dont remove the Object from memory it will just add to the memory bracket. To test... Build a test page with a periodical ajax request and (on winblows) watch the RAM that for instance firefox uses in the task manager go up and up and up. Then close the whole browser (so it starts clean again) and assign the periodical updater to a variable var request=new Ajax.Periodical...({}); request=null; And watch the difference between what happend in the first test and the second... In the second test the browser frees up 60-80% of the memory that it used to make/process the request by nulling the object back to a null byte If you look on TJ's proto scripty wikidot my results are there and the code that accompanies it. I assumed it was common knowledge that people garbage collected ajax requests... Its not just prototypejs but every ajax style library that does not garbage collect these requests Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: david david.brill...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, November 24, 2009 11:54 AM Subject: [Proto-Scripty] Re: Sychronize many asynchronous Ajax.Request Yes your right Alex, but the case of maalek did not mention such numbers of request. I think in his case using one array is better than using a lot (~14 differents variables). btw, I'm interrest in In fact the actal request stays in memory unless you null the object and after reflexion, that is logical, but is it normal ?? -- david On 24 nov, 09:37, Alex McAuley webmas...@thecarmarketplace.com wrote: Arrays are stored in memory, they are not a cookie so they do not get stored on the client machine .. (and you yourself say that even if it was its not cross browser) To test .. Do 100 requests with large responses and save them all into an array and see how much memory the web browser is eating each time you do one... In fact the actal request stays in memory unless you null the object - i wrote a post on this in TJ's proto scripty wiki which has test cases to prove it. I dont see any reason ever to save the response of multiple requests in an object that is saved in memory of the client's browser what happens if they are on an iPhone or somehting with not alot of memory ? Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: david david.brill...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, November 24, 2009 7:24 AM Subject: [Proto-Scripty] Re: Sychronize many asynchronous Ajax.Request I'm sorry Alex, but I definitely not agree with you ! First because there is existing method to cache the Ajax request and they use local object to save the result (we have now some new way to save locally a variable but it's not cross-browser). And next, because an array is much more flexible than variables. you could access each element independantly and have the length method (In our exemple, to know how much elements have been saved). And if each request should have a specific position in the array, length is no more working, but Prototype have sugaristic method that help you playing with Array the way you need. But there is I think plenty way to do this. -- david On 23 nov, 23:44, Alex McAuley webmas...@thecarmarketplace.com wrote: It would polute the variable and seriously eat RAM to save every result response in an array, i would highly recommend staying away from it.. Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: david david.brill...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 23, 2009 8:00 PM Subject: [Proto-Scripty] Re: Sychronize many asynchronous Ajax.Request Hi all, if you need to save all returned value, just save each request result in an array. Check the length of the result list to know when all request are finished. But we still turn around the same
[Proto-Scripty] Re: Stopping an enumeration
I'd like to use enumeration functions to select from a sorted list where I know that if the select function has passed and then starts failing (returns false) This isn't a prime situation for Enumerable but certainly nothing it can't handle. Never mind - I just discovered $break in the docs Really, what documentation covered the $break variable? I've always considered this as Prototype property and although you can get away with it in most cases, I'd strongly advise against manipulating that variable yourself. I'm not sure what use case you're going for, are you collecting the items in the array that match or just getting to the max index of matches and then exiting? Here is some quick and dirty code of how to work out a situation like yours with Enumerable methods... var vocab = [ apples, apricot, airplane, bass, banana, bounce, card, carry, cart, ceasar ]; var myFlag = false; var myRegex = /^b.*/; var myFilter = function(val, itr){ if(val.search(myRegex) -1 myFlag == false){ myFlag = true; } else if(val.search(myRegex) == -1 myFlag == true){ myFlag = false; } return (myFlag val.search(myRegex) -1); } var newVocab = vocab.collect(myFilter); console.log(newVocab); On Nov 9, 6:47 am, andy.kri...@gmail.com andy.kri...@gmail.com wrote: Never mind - I just discovered $break in the docs - that should do what I want. On Nov 9, 6:41 am, andy.kri...@gmail.com andy.kri...@gmail.com wrote: I'd like to use enumeration functions to select from a sorted list where I know that if the select function has passed and then starts failing (returns false), I can stop enumerating (because every additional item will also fail). For example, scanning a sorted array of strings for strings that start with a regexp - once the regexp has found matches and then stops matching again, there's no need to continue. Is that possible with the built-in functions or should I be looping over the array myself in this case? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Effect.Morph to enlarge images
You could use a fisheye... http://positionabsolute.net/blog/2007/08/prototype-fisheye.php On Nov 3, 12:55 pm, ph...@ryangibbons.net ph...@ryangibbons.net wrote: Richard, Thanks for the response. Question though, I am not quit sure what you mean. I would like the image the enlarge upon mouse over and go back original size on mouse out...hopefully as a smooth transition. I have seen some very heavy JS scripts that do this but I was looking for a lighter alternative using script.aculo.us Thanks, RG On Nov 3, 9:45 am, Richard Quadling rquadl...@googlemail.com wrote: 2009/11/3 ph...@ryangibbons.net ph...@ryangibbons.net: Hey all, I was trying to come up with a simple way to enlarge images on mouse over and set them back to their normal size on mouse out. I figured why not try Effect.Morph with two sets of css for the images. Implementation can be seen here: http://rgvisuals.com/ie/(Clickon Stories link) Problem I am running into is that it seems to be quite jittery. I know that this is doable in Flash but I am just not much of a Flash fan. I am taking it by my simple exploration that Effect.Morph may not be the most stable or correct ways of going about this. Can anyone point me in the right direction? Thanks, Ryan I think you have to know if you are scaling an image and if so, not perform any other scaling on that image. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE :http://www.experts-exchange.com/M_248814.html 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-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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Insert , Defer and Is there a better way?
Hey Kiran, Function.defer is simply delegating the functions execution to Function.delay which in the end delegates it to a wrapper of window.setTimeout. By using defer it enforces the timeout to be a value of 0.01 which is just enough to hiccup the browser's procedural processing. If your application relies on this element to be inserted, avoid the defer and you'll be sure the content is loaded after execution of insert. -- http://positionabsolute.net On Nov 2, 7:41 pm, phegaro pheg...@gmail.com wrote: HI T.J, I'm sorry but are you asking for more than what is above? I can write a simple page that puts together the HTML and JS listed above. Is that what you want? Kiran On Oct 30, 2:22 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Kiran, It sounds like you've already put together a minimalist test case, would you post it (e.g., to Pastie[1] or similar)? I haven't run into a situation where a single defer wasn't sufficient, but I also haven't tested extensively on Mac OS. Cheers, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Oct 30, 7:19 am, phegaro pheg...@gmail.com wrote: Hi all, This might be a more generic browser/javascript questions than a prototype specific quesiton but i thought it would better to ask here because you all tend to really understand javascript and browsers in a ton of detail. So here goes. If i execute the following code: HTML: div id=area/div Javascript: $('area').insert({bottom: div id=inserted/div}); var count = 0; var f = function() { if ($('inserted') == null) { console.log(not there); count++; if (count 50) { $('area'.insert({bottom: div id=inserted/ div}); count = 0; } f.defer(); } else { console.log(there); } }; f(); Result: Most of the time it just shows: there but some of the time it does this not there not there not there there I am assuming because the insert is something that is queued and the browser then inserts the nodes into the DOM in its next event loop. I know that webkit is a single threaded so this makes sense that sometimes its not there and then it gets there, so really i guess i have to wait till its there before i can do the next thing on that inserted node. What about firefox and IE? Are they all single threaded in the same way? What happens in Chrome? Sometimes i see the following happen also which is really concerning to me: not there not there ... 50 times not there there It happens every so often on webkit (mac os) and on iPhone webkit and i can reproduce it pretty easily. I have built something simple that will do this but all this seems a little crazy to me because when i look at others code they dont even take this into account. They never way for DOM elements to show up when inserting HTML text into a DOM element. Any answers/suggestions would be super helpful. Kiran --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Insert , Defer and Is there a better way?
In taking a second look at your code... Are you using the F function recursively to wait for the DOM to be loaded and your area element to be available? you can use many other approaches... Prototype $(document).observe(dom:loaded, function()...); Traditional window.onload = function()... By executing your code in those methods, you can be sure that DOM elements are loaded and ready for manipulation via Javascript. -- http://positionabsolute.net On Nov 5, 3:22 pm, Matt Foster mattfoste...@gmail.com wrote: Hey Kiran, Function.defer is simply delegating the functions execution to Function.delay which in the end delegates it to a wrapper of window.setTimeout. By using defer it enforces the timeout to be a value of 0.01 which is just enough to hiccup the browser's procedural processing. If your application relies on this element to be inserted, avoid the defer and you'll be sure the content is loaded after execution of insert. -- http://positionabsolute.net On Nov 2, 7:41 pm, phegaro pheg...@gmail.com wrote: HI T.J, I'm sorry but are you asking for more than what is above? I can write a simple page that puts together the HTML and JS listed above. Is that what you want? Kiran On Oct 30, 2:22 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Kiran, It sounds like you've already put together a minimalist test case, would you post it (e.g., to Pastie[1] or similar)? I haven't run into a situation where a single defer wasn't sufficient, but I also haven't tested extensively on Mac OS. Cheers, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Oct 30, 7:19 am, phegaro pheg...@gmail.com wrote: Hi all, This might be a more generic browser/javascript questions than a prototype specific quesiton but i thought it would better to ask here because you all tend to really understand javascript and browsers in a ton of detail. So here goes. If i execute the following code: HTML: div id=area/div Javascript: $('area').insert({bottom: div id=inserted/div}); var count = 0; var f = function() { if ($('inserted') == null) { console.log(not there); count++; if (count 50) { $('area'.insert({bottom: div id=inserted/ div}); count = 0; } f.defer(); } else { console.log(there); } }; f(); Result: Most of the time it just shows: there but some of the time it does this not there not there not there there I am assuming because the insert is something that is queued and the browser then inserts the nodes into the DOM in its next event loop. I know that webkit is a single threaded so this makes sense that sometimes its not there and then it gets there, so really i guess i have to wait till its there before i can do the next thing on that inserted node. What about firefox and IE? Are they all single threaded in the same way? What happens in Chrome? Sometimes i see the following happen also which is really concerning to me: not there not there ... 50 times not there there It happens every so often on webkit (mac os) and on iPhone webkit and i can reproduce it pretty easily. I have built something simple that will do this but all this seems a little crazy to me because when i look at others code they dont even take this into account. They never way for DOM elements to show up when inserting HTML text into a DOM element. Any answers/suggestions would be super helpful. Kiran --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Prototype gadget for client side translation
Hey Everyone, I've put the finishing touches on a JS based gadget to handle site translation. It uses Prototype for class structure and element collection etc and the Google Translate API to handle the actual text translations. It handles all of the requests async style and never reloads the page. Nor does it destructively handle node collection, so all of your event handlers remain intact... Check it out http://positionabsolute.net/blog/2009/10/google-translate-gadget-site-translation.php Cheers, Matt --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: onChange in Dynamic Element not working in IE6
This one was a SOB and as always, IE is at fault... Here is what I found on researching this... now this is for IE only of course.. var cell = new Element(td); This is all well and good w/o any attributes, the Element constructor delegates the attributes object, the second parameter to Element.writeAttribute... cell.writeAttribute(class, text); fails to work due to the attribute translations, found in the Element._attributeTranslations.write object. IE8 is now expecting to write to the literal class attribute, not the className that it gets translated to. cell.setAttribute(class, text); //this works fine in IE8 cell.addClassName(text); //this also works but its not using element attributes but the JS DOM reference itself, ie cell.className = ... -- http://positionabsolute.net On Oct 26, 4:04 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Just as a side measure that you are probably not aware of... IE8 has a bug that when you do your new Element(td..,'class':'text'... It will not add the class to IE8 browsers ... you need to use addClassName('text'); after you insert it... I found this out the hard way ! Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: molo maurice_lowent...@ssga.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, October 26, 2009 7:27 PM Subject: [Proto-Scripty] onChange in Dynamic Element not working in IE6 The following code works in Firefox but the onChange/onBlur events do not get triggered from the browser in IE6 Does anyone know 1) How to fix this 2) If I should use a different approach for dynamically building the form elements I dynamically build elements on the screen base on a button being entered to call a function var newSecurityTdInput = new Element('td' , {'class':'text'}); var newSecurityInput = new Element('input', {'type':'text', 'class':'text newid', 'name':'newid', 'onChange': validateNewSecurityChange(this); ,'onBlur': getSecurityName (this);}); newSecurityTdInput.appendChild(newSecurityInput); newSecurityTr.appendChild(newSecurityTdInput); Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Depreciation of Array#reduce
What is ES5? On Oct 23, 1:31 pm, Tobie Langel tobie.lan...@gmail.com wrote: We removed it because it conflicted with an identically named method specified in ES5. If you really need to use it, I strongly sugest you find another name for it. Best, Tobie --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Tying an Element and a custom class together
Yeah that'd be great functionality to allow for a much simpler proxy On Oct 19, 9:48 am, Eric lefauv...@gmail.com wrote: Matt, I like your way of doing it, but my concern is that the documented toElement() method seems to be only half implemented. A minor change to the $() function could make it work completely (see it here:http://pastie.org/660553). What do you guys think about this change? Eric On Oct 17, 12:11 am, Matt Foster mattfoste...@gmail.com wrote: Quick and dirty, im sure there are errors but conceptually this would be my approach... var ElementProxy = Class.create({ initialize : function(ele){ this.element = $(ele); this.nodeType = this.element.nodeType; this.tagName = this.element.tagName; this.delegateMethods(); }, delegateMethods : function(){ var methods = Element.Methods; for(var method in methods){ var __method = methods[method]; if (Object.isFunction(__method) !(__method in this)) this.assignMethod(method, __method); } }, assignMethod : function(method, __method){ this[method] = function(){ return __method.apply(this.element, [this.element].concat($A(arguments))); }; } }); -- http://positionabsolute.net On Oct 16, 3:01 pm, Matt Foster mattfoste...@gmail.com wrote: The has a relationship is the only way to go for sure. You could create an ElementProxy class that inherits all the Element methods but just keeps a reference to the actual DOM reference internally. All of the Element.Methods are parameterized so I'm sure there'd be an easy way to delegate the reference. As long as the ElementProxy class implements all the regular methods then core prototype processes wouldn't know the difference between the two. -- http://positionabsolute.net On Oct 16, 12:02 pm, Eric lefauv...@gmail.com wrote: Hi, While I agree with T.J. arguments, there are cases when it is nice to have this behavior (DOM element and Plain object in the same object). On of those case is, for example when you're creating a new control class. The way I do it is: - building the DOM element in the class's constructor (and keeping it in an attribute) (*) - implement the toElement() method in the class (to return this DOM element) (*) The second step allows you to provide your class instance to any prototype method instead of a DOM element. A small example:http://jsbin.com/omaza Ops: Previous sentence was wrong... After trying to write the example, and checking in the source, it seems that you can only use this kind of object as a DOM element in a handfull of prototype's methods (insert, update and replace)... Is it any reason why this behavior is not implemented in $() (this would actually allow to use a custom class everywhere where a DOM element is needed, and just add one line of code). Eric (*) This was the simplest way to explain the process, but you may prefer dynamically create the DOM element on the first call of toElement() for better efficiency. On Sep 10, 10:56 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Andrea, FWIW, I'd say the best practice is: Don't do that, it conflates the model with the view *and* the controller. :-) (MVC is not by any means the only game in town, but the terminology is useful for questions like this.) If you ever want to present the business object in two different ways in two different panels (in a list, for instance, and in a details pane that shows the details of the highlighted object in the list), you can't, or rather the code gets ugly fast. Instead, I'd suggest keeping the business object separate from the element and using a has a rather than an is a relationship. You can do that by storing the business object ID on the element in some way (data-key is the attribute I usually use for this, and fits with the proposed HTML5 data attributes standard), either directly or via a small controller. The business object should never update the element directly, and so it doesn't need to know about it. Instead, it should raise events that controllers can respond to by updating the elements they control. When I say fire event, I'm not necessarily talking browserspeak (I wouldn't use browser events for this), just a minimal
[Proto-Scripty] Re: Tying an Element and a custom class together
The has a relationship is the only way to go for sure. You could create an ElementProxy class that inherits all the Element methods but just keeps a reference to the actual DOM reference internally. All of the Element.Methods are parameterized so I'm sure there'd be an easy way to delegate the reference. As long as the ElementProxy class implements all the regular methods then core prototype processes wouldn't know the difference between the two. -- http://positionabsolute.net On Oct 16, 12:02 pm, Eric lefauv...@gmail.com wrote: Hi, While I agree with T.J. arguments, there are cases when it is nice to have this behavior (DOM element and Plain object in the same object). On of those case is, for example when you're creating a new control class. The way I do it is: - building the DOM element in the class's constructor (and keeping it in an attribute) (*) - implement the toElement() method in the class (to return this DOM element) (*) The second step allows you to provide your class instance to any prototype method instead of a DOM element. A small example:http://jsbin.com/omaza Ops: Previous sentence was wrong... After trying to write the example, and checking in the source, it seems that you can only use this kind of object as a DOM element in a handfull of prototype's methods (insert, update and replace)... Is it any reason why this behavior is not implemented in $() (this would actually allow to use a custom class everywhere where a DOM element is needed, and just add one line of code). Eric (*) This was the simplest way to explain the process, but you may prefer dynamically create the DOM element on the first call of toElement() for better efficiency. On Sep 10, 10:56 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Andrea, FWIW, I'd say the best practice is: Don't do that, it conflates the model with the view *and* the controller. :-) (MVC is not by any means the only game in town, but the terminology is useful for questions like this.) If you ever want to present the business object in two different ways in two different panels (in a list, for instance, and in a details pane that shows the details of the highlighted object in the list), you can't, or rather the code gets ugly fast. Instead, I'd suggest keeping the business object separate from the element and using a has a rather than an is a relationship. You can do that by storing the business object ID on the element in some way (data-key is the attribute I usually use for this, and fits with the proposed HTML5 data attributes standard), either directly or via a small controller. The business object should never update the element directly, and so it doesn't need to know about it. Instead, it should raise events that controllers can respond to by updating the elements they control. When I say fire event, I'm not necessarily talking browserspeak (I wouldn't use browser events for this), just a minimal implementation of the Observer pattern (as a mixin or similar you can use for lots of different objects). FWIW, and apologies if I went OT, but I hope I didn't, -- T.J. Crowder tj / crowder software / comwww.crowdersoftware.com On Sep 9, 3:02 pm, Andrea Campi andrea.ca...@gmail.com wrote: Hi, in my application I need JS objects to represent some business objects, which are represented on the page by an Element. I would like to be able to tie the two together in such a way that I can use them interchangeably. This sounds like it should be a common pattern, so I was wondering what the best practices are. Example: var Foo = Class.create({ initialize: function(parent) { var element = Object.extend(new Element(div, { 'class': 'foo', 'id': 'myFoo' }), this); parent.insert(element); }, bar: function() { } // more methods }; Thanks to Object.extend I can easily call: $('myFoo').bar() But I cannot do the opposite, for instance: var foo = new Foo(); foo.childElements(); Note that it would just work if I could return 'element' (which now behaves like Foo). However, I've readhttp://dev.rubyonrails.org/ticket/11481andithas reasonable objections to letting the constructor return a value. So, what gives? Any suggestion? TIA, Andrea --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Tying an Element and a custom class together
Quick and dirty, im sure there are errors but conceptually this would be my approach... var ElementProxy = Class.create({ initialize : function(ele){ this.element = $(ele); this.nodeType = this.element.nodeType; this.tagName = this.element.tagName; this.delegateMethods(); }, delegateMethods : function(){ var methods = Element.Methods; for(var method in methods){ var __method = methods[method]; if (Object.isFunction(__method) !(__method in this)) this.assignMethod(method, __method); } }, assignMethod : function(method, __method){ this[method] = function(){ return __method.apply(this.element, [this.element].concat($A(arguments))); }; } }); -- http://positionabsolute.net On Oct 16, 3:01 pm, Matt Foster mattfoste...@gmail.com wrote: The has a relationship is the only way to go for sure. You could create an ElementProxy class that inherits all the Element methods but just keeps a reference to the actual DOM reference internally. All of the Element.Methods are parameterized so I'm sure there'd be an easy way to delegate the reference. As long as the ElementProxy class implements all the regular methods then core prototype processes wouldn't know the difference between the two. -- http://positionabsolute.net On Oct 16, 12:02 pm, Eric lefauv...@gmail.com wrote: Hi, While I agree with T.J. arguments, there are cases when it is nice to have this behavior (DOM element and Plain object in the same object). On of those case is, for example when you're creating a new control class. The way I do it is: - building the DOM element in the class's constructor (and keeping it in an attribute) (*) - implement the toElement() method in the class (to return this DOM element) (*) The second step allows you to provide your class instance to any prototype method instead of a DOM element. A small example:http://jsbin.com/omaza Ops: Previous sentence was wrong... After trying to write the example, and checking in the source, it seems that you can only use this kind of object as a DOM element in a handfull of prototype's methods (insert, update and replace)... Is it any reason why this behavior is not implemented in $() (this would actually allow to use a custom class everywhere where a DOM element is needed, and just add one line of code). Eric (*) This was the simplest way to explain the process, but you may prefer dynamically create the DOM element on the first call of toElement() for better efficiency. On Sep 10, 10:56 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Andrea, FWIW, I'd say the best practice is: Don't do that, it conflates the model with the view *and* the controller. :-) (MVC is not by any means the only game in town, but the terminology is useful for questions like this.) If you ever want to present the business object in two different ways in two different panels (in a list, for instance, and in a details pane that shows the details of the highlighted object in the list), you can't, or rather the code gets ugly fast. Instead, I'd suggest keeping the business object separate from the element and using a has a rather than an is a relationship. You can do that by storing the business object ID on the element in some way (data-key is the attribute I usually use for this, and fits with the proposed HTML5 data attributes standard), either directly or via a small controller. The business object should never update the element directly, and so it doesn't need to know about it. Instead, it should raise events that controllers can respond to by updating the elements they control. When I say fire event, I'm not necessarily talking browserspeak (I wouldn't use browser events for this), just a minimal implementation of the Observer pattern (as a mixin or similar you can use for lots of different objects). FWIW, and apologies if I went OT, but I hope I didn't, -- T.J. Crowder tj / crowder software / comwww.crowdersoftware.com On Sep 9, 3:02 pm, Andrea Campi andrea.ca...@gmail.com wrote: Hi, in my application I need JS objects to represent some business objects, which are represented on the page by an Element. I would like to be able to tie the two together in such a way that I can use them interchangeably. This sounds like it should be a common pattern, so I was wondering what
[Proto-Scripty] Re: how to select all elements by class after a certain point?
var nextElements=$(element).descendants();// returns everythign that This would return all children of the element, not siblings. On Oct 10, 4:26 am, Alex McAuley webmas...@thecarmarketplace.com wrote: If you use Event with element you can find the element that was clicked $$('.blah').each(function(e) { $(e).observe('click',function(event){ var element=Event.element(event); // this is the element var nextElements=$(element).descendants();// returns everythign that is a }); }); This is untested. Your list is a straight list of divs so it may not work - but try it and see!.. HTH Alex Mcauley http://www.thevacancymarket.com - Original Message - From: patrick patrick99...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Saturday, October 10, 2009 8:41 AM Subject: [Proto-Scripty] how to select all elements by class after a certain point? Hi everyone, I am a bit stuck on this.. So, I have a layout with something like this: div class=blahblah/div div class=blahblah/div div class=other_class/div div class=blahblah/div div class=blahblah/div div class=blahblah/div div class=other_class/div div class=blahblah/div ... I have a function that is called when one of my '.blah' divs is clicked, and so in that function 'this' refers the particular div.. I am trying to figure out how I can get all of the divs that are '.blah' after 'this'... Thank you. -patrick --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Submit form on select for autosuggest
You've defined your function after you reference it... It needs to be created first then it can be referenced. function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); -- http://positionabsolute.net On Oct 8, 10:45 pm, Yogesh Agashe yogesh.aga...@gmail.com wrote: Hello, Thanks for the reply. I tried doing that but it didn't work for me.If you point out the mistake in following code, it will be great.Thanks again.script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /scriptThanks, Yogesh Matt Foster wrote:http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleterafterUpdateElement function... you receive an input object and some element that was representing the field. At this point you could execute form.submit.. --http://positionabsolute.netOn Oct 7, 11:19 am, Yogeshyogesh.aga...@gmail.comwrote:Hello, I am using Ajax.autocompleter in one of my forms. I am calling a custom function getSelectedId after update element to get an ID of the selected list item. I need a functionality such that form should get submitted whenever : 1) a user clicks a item using mouse from the autosuggest list. 2) Whenever user presses enter key while a list item is selected. (This I have achieved through a hack as shown in code below. I call .submit() after getSelectedId function) I don't know how to submit the form on mouse click. Any help on this issue will be really helpful to me. script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /script Thank you. Sincerely, Yogesh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: how to select all elements by class after a certain point?
Hence the note on it This might not work as its divs. The name of the elements have no weight on the issue. The structure of the elements are all that matters. Siblings != Children You should have added the disclaimer... This does not work... On Oct 12, 3:04 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Hence the note on it This might not work as its divs. Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Matt Foster mattfoste...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, October 12, 2009 7:12 PM Subject: [Proto-Scripty] Re: how to select all elements by class after a certain point? var nextElements=$(element).descendants();// returns everythign that This would return all children of the element, not siblings. On Oct 10, 4:26 am, Alex McAuley webmas...@thecarmarketplace.com wrote: If you use Event with element you can find the element that was clicked $$('.blah').each(function(e) { $(e).observe('click',function(event){ var element=Event.element(event); // this is the element var nextElements=$(element).descendants();// returns everythign that is a }); }); This is untested. Your list is a straight list of divs so it may not work - but try it and see!.. HTH Alex Mcauley http://www.thevacancymarket.com - Original Message - From: patrick patrick99...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Saturday, October 10, 2009 8:41 AM Subject: [Proto-Scripty] how to select all elements by class after a certain point? Hi everyone, I am a bit stuck on this.. So, I have a layout with something like this: div class=blahblah/div div class=blahblah/div div class=other_class/div div class=blahblah/div div class=blahblah/div div class=blahblah/div div class=other_class/div div class=blahblah/div ... I have a function that is called when one of my '.blah' divs is clicked, and so in that function 'this' refers the particular div.. I am trying to figure out how I can get all of the divs that are '.blah' after 'this'... Thank you. -patrick --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Submit form on select for autosuggest
Hey Yogesh, You may want to also look at how you're referencing the form. Usually document.forms is a numerical array, not an associative. I'd recommend using an ID on the form object and then grab it via $(form_id)... document.forms['searchcustomerform'].submit(); vs $(searchcustomerform).submit(); Cheers, Matt On Oct 12, 3:02 pm, Yogesh Agashe yogesh.aga...@gmail.com wrote: Hello, I am glad to say that I found the root of the problem. I had a button named submit and this was causing the problem. Thanks so much Matt for pointing out the function definition error. As Christo notes here: (http://www.spiration.co.uk/post/1232/Submit%20is%20not%20a%20function) This means you have a function trying to call the form's submit() method, but you also have a button which is called submit(). This causes a conflict in javascript, because the submit method is already bound to that button. To solve the problem, simply change the name of the button so that name=moo (or something). Your submit() call in your javascript function/method will now work. Sincerely, Yogesh Yogesh Agashe wrote:Thanks for pointing out this error Matt. I should have noticed this. But even after defining the function earlier, form submit doesn't work :( Sorry. Sincerely, Yogesh Matt Foster wrote:You've defined your function after you reference it... It needs to be created first then it can be referenced. function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); --http://positionabsolute.netOn Oct 8, 10:45 pm, Yogesh Agasheyogesh.aga...@gmail.comwrote:Hello, Thanks for the reply. I tried doing that but it didn't work for me.If you point out the mistake in following code, it will be great.Thanks again.script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /scriptThanks, Yogesh Matt Foster wrote:http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleterafterUpdateElementfunction... you receive an input object and some element that was representing the field. At this point you could execute form.submit.. --http://positionabsolute.netOn Oct 7, 11:19 am, Yogeshyogesh.aga...@gmail.comwrote:Hello, I am using Ajax.autocompleter in one of my forms. I am calling a custom function getSelectedId after update element to get an ID of the selected list item. I need a functionality such that form should get submitted whenever : 1) a user clicks a item using mouse from the autosuggest list. 2) Whenever user presses enter key while a list item is selected. (This I have achieved through a hack as shown in code below. I call .submit() after getSele ctedId function) I don't know how to submit the form on mouse click. Any help on this issue will be really helpful to me. script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /script Thank you. Sincerely, Yogesh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: How to fire a custom/synthetic Control key + mouse scroll wheel movement event?
Hey Alex, You failed to see his point. You failed to see mine Ctrl + mouse wheel scales the page not the text - it scales images, elements, text and everything If said images and elements widths and font-size properties were given using the em unit, they'd be scaled just the same. LOL glad to see you think your own misperceptions are so comical. Implement the pastie to see how my example works before you jump to these grand slanderous conclusions. -- http://positionabsolute.net On Oct 8, 2:32 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: You failed to see his point. Ctrl + mouse wheel scales the page not the text - it scales images, elements, text and everything LOL Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Matt Foster mattfoste...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, October 08, 2009 6:58 PM Subject: [Proto-Scripty] Re: How to fire a custom/synthetic Control key + mouse scroll wheel movement event? So just as a recap, you're looking to simulate the ctrl + mouse wheel event such that the native processing for zoom magnification applies? This is a highly useful feature, I would love to add some widgets type icons (magnifier glasses with a + and -) on my site that allows people to rescale the document image using it. It would very intuitive (just click the +magnifier icon to make it bigger and visa versa). So really you want a control on your page that increases font size? My approach would be to design everything I want to be scalable using the em unit so that everything is relative. Set a modest em level at the body level such that everything else is relative to this value. Then the control simply modifies the value for this to propagate the zoom in/out effect. http://pastie.org/647201 -- http://positionabsolute.net On Oct 8, 12:16 pm, tcupolo tcup...@afsincorporated.biz wrote: @Radoslav, I took some time today to look through your patch. It would make this function very easy to implement. It would take the form of a keypress event with ctrlkey=true and the necessary keyCode and charCode values. What is it's status? Will it make it into a future version of Prototype anytime soon? If not, what is the recommended way of using a patch like this? (I assume including it as a seperate js file on each page override the original function definition of fire, but that's not completely clear.) It took a little time for me to realize but I think it's the best way to go for a cross-browser compatible ZOOM solution. Thanks for the reply. On Oct 1, 7:47 am, Radoslav Stankov rstan...@gmail.com wrote: A time ago I have created ticket and a patch for making Event.fire to fire event (https://prototype.lighthouseapp.com/projects/8886/tickets/697-eventfi... ) Here is a git forhttp://gist.github.com/121011 I hope it's useful --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: How to fire a custom/synthetic Control key + mouse scroll wheel movement event?
So just as a recap, you're looking to simulate the ctrl + mouse wheel event such that the native processing for zoom magnification applies? This is a highly useful feature, I would love to add some widgets type icons (magnifier glasses with a + and -) on my site that allows people to rescale the document image using it. It would very intuitive (just click the +magnifier icon to make it bigger and visa versa). So really you want a control on your page that increases font size? My approach would be to design everything I want to be scalable using the em unit so that everything is relative. Set a modest em level at the body level such that everything else is relative to this value. Then the control simply modifies the value for this to propagate the zoom in/out effect. http://pastie.org/647201 -- http://positionabsolute.net On Oct 8, 12:16 pm, tcupolo tcup...@afsincorporated.biz wrote: @Radoslav, I took some time today to look through your patch. It would make this function very easy to implement. It would take the form of a keypress event with ctrlkey=true and the necessary keyCode and charCode values. What is it's status? Will it make it into a future version of Prototype anytime soon? If not, what is the recommended way of using a patch like this? (I assume including it as a seperate js file on each page override the original function definition of fire, but that's not completely clear.) It took a little time for me to realize but I think it's the best way to go for a cross-browser compatible ZOOM solution. Thanks for the reply. On Oct 1, 7:47 am, Radoslav Stankov rstan...@gmail.com wrote: A time ago I have created ticket and a patch for making Event.fire to fire event (https://prototype.lighthouseapp.com/projects/8886/tickets/697-eventfi... ) Here is a git forhttp://gist.github.com/121011 I hope it's useful --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Event#observe on elements
Yeah don't worry about it. Your use case works fine, its the way IE handles event observers that has the memory leak. Other browsers its fine and as noted, prototype handles this IE anomaly under the covers for you so you're good. On Oct 6, 1:57 pm, Ngan Pham nganp...@gmail.com wrote: Thanks for the reply. I do understand that Just because an element has been detached from the visible DOM doesn't mean that the reference can be maintained elsewhere. I just assumed that once it is detached, and the object isn't referenced anywhere else in the code that it would be collected by garbage collection, just like any other variable: function test() { var i = 0; var j = $('some-element').remove(); } it's my thinking that after test() has finished running, that both i and j would be picked up by garbage collection. is this not true? So, what you're saying, to answer my question, is that I don't have to worry about using Event#stopObserving? On Tue, Oct 6, 2009 at 10:22 AM, Matt Foster mattfoste...@gmail.com wrote: The removed element? Just because an element has been detached from the visible DOM doesn't mean that the reference can be maintained elsewhere. It would be no edge case to detach and re-attach a particular element, so to think that an element should be trashed just because it has no parent node is a bad perception. Prototype has accomodations for IE's poor garbage collection tactics and has a cleanup method for this that gets handled transparently to you. -- http://positionabsolute.net On Oct 6, 12:05 pm, Ngan Pham nganp...@gmail.com wrote: Hey everyone, I have a quick question. If put some Event#observe on an element...and then later remove the element with Element#remove, do I have to do Event#stopObserving? Or do the event detach themselves once garbage collection picks up the removed element? Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Submit form on select for autosuggest
http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleter afterUpdateElement function... you receive an input object and some element that was representing the field. At this point you could execute form.submit.. -- http://positionabsolute.net On Oct 7, 11:19 am, Yogesh yogesh.aga...@gmail.com wrote: Hello, I am using Ajax.autocompleter in one of my forms. I am calling a custom function getSelectedId after update element to get an ID of the selected list item. I need a functionality such that form should get submitted whenever : 1) a user clicks a item using mouse from the autosuggest list. 2) Whenever user presses enter key while a list item is selected. (This I have achieved through a hack as shown in code below. I call .submit() after getSelectedId function) I don't know how to submit the form on mouse click. Any help on this issue will be really helpful to me. script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /script Thank you. Sincerely, Yogesh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Variabalized containment
http://prototypejs.org On Oct 6, 7:45 am, WLQ maybe...@gmail.com wrote: Sounds plausible, I would like to have more information on that please. On 5 Okt., 08:14, Alex McAuley webmas...@thecarmarketplace.com wrote: Why not give your list a class name thats specific to the list and select with $$ Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: WLQ maybe...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Sunday, October 04, 2009 3:05 PM Subject: [Proto-Scripty] Variabalized containment The question is, how can I tell containment to include all lists with Id's of someid_somenumber. Somenumber being any number, let's say I've got 20 lists with the Id of someid_{ID}. So I don't really know the full ID of the list. I want to be able to receive items from the lists id of which includes someid_ regardless of what number goes after. Thanks, Yan- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Event#observe on elements
The removed element? Just because an element has been detached from the visible DOM doesn't mean that the reference can be maintained elsewhere. It would be no edge case to detach and re-attach a particular element, so to think that an element should be trashed just because it has no parent node is a bad perception. Prototype has accomodations for IE's poor garbage collection tactics and has a cleanup method for this that gets handled transparently to you. -- http://positionabsolute.net On Oct 6, 12:05 pm, Ngan Pham nganp...@gmail.com wrote: Hey everyone, I have a quick question. If put some Event#observe on an element...and then later remove the element with Element#remove, do I have to do Event#stopObserving? Or do the event detach themselves once garbage collection picks up the removed element? Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Range utility increment
I hadn't thought of that and a good point. So if you create a NumberRange of even numbers from 2 to 6 and ask it if 3 is included, unless you override that behavior in your NumberRange class, `include` will return true. The range object itself will certainly return true in this scenario. as it does fall within the beginning and end. Although in most cases, and certainly in my example I've wrapped the instance within an Enumerable ($A) which also has an include method (actually ObjectRange inherits and overrides this method).. but the Enumerable.include method is..quoting the API docs based on the == comparison operator (equality with implicit type conversion) such that, 3 is simply not a number created by the range, hence not a value in the enumerable. http://api.prototypejs.org/language/enumerable.html#include-instance_method -- http://positionabsolute.net On Sep 28, 7:27 pm, T.J. Crowder t...@crowdersoftware.com wrote: Matt, The ObjectRange `include` method looks like this: function include(value) { if (value this.start) return false; if (this.exclusive) return value this.end; return value = this.end; } So if you create a NumberRange of even numbers from 2 to 6 and ask it if 3 is included, unless you override that behavior in your NumberRange class, `include` will return true. -- T.J. On Sep 28, 9:20 pm, Matt Foster mattfoste...@gmail.com wrote: Hey TJ, I don't understand, if a NumberRange was given an instance of EvenNumber as its start and end parameters, how would it come up with the number 3? On Sep 26, 7:10 am, T.J. Crowder t...@crowdersoftware.com wrote: All right, lads, let's move along... Each approach has its benefits and costs, it all depends on what problem you're solving. Matt, FWIW, I think you'd want to override the `include` method as well, as others a NumberRange with even numbers would include 3. At that point you're overriding most of ObjectRange, so I'd probably just start from Enumerable. This is not intended as a dig. -- T.J. On Sep 25, 9:51 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Omg get over yourself you have taken what i said completely the wrong way.. What arrogant plug was that?... Lets take your code and look at it shall we... 30+ lines for no reason other than Hey look at me, i can write a function/class in 30 lines that only needs to be 5. Chill out dude, i wasn't knocking your code, it was just OTT. You can continue to think you are right which is arrogance in itself... there is more than one way to skin a cat. TJ's/My loop that took all of 30 seconds to create is faster no doubt, has less weight and does the job. I personaly have better things to do than write some amazing class to achieve what can be done in 30 seconds - evidently you do not so good luck with that. Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Matt Foster mattfoste...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, September 25, 2009 9:16 PM Subject: [Proto-Scripty] Re: Range utility increment That only gives you even or odd increments to the top number... Incorrect, notice the constructor method? It ensures that the number given is even such that you'll never get a range of odd numbers. Granted the last line of the Jojo's question was Let's say count up by 2's: [2,4,6,8,10]. How do you do this? Hence why I went with this specific implementation, to demonstrate how you can create classes that the ObjectRange class can use to create proper ranges. I didn't feel it was necessary to abstract out the class such that it covers all bases but demonstrate how to do it one way and then Jojo could modify for their own purposes. Better to go with my/TJ's loop What an arrogant plug of your own spaghetti code and hasty discredit to my contribution. Exposing your shortfalls isn't difficult, you aren't creating a range object, completely bypassing the ObjectRange's functionality and just simply creating a hacked out array. So to put the nail in the coffin, here is the classes abstracted out var IncrementNumber = Class.create({ initialize : function(num, increment){ this.num = num; this.increment = increment;}, succ : function(){ return this.clone(this.num + this.increment, this.increment);}, clone : function(num, increment){ return new IncrementNumber(num, increment);}, toString : function(){ return this.num;} }); var EvenNumber = Class.create(IncrementNumber, { initialize : function($super, num){ $super(num, 2); this.num = (num % 2 == 1) ? num - 1 : num;}, clone : function(num, increment){ return new EvenNumber(num);} }); var NumberRange = Class.create
[Proto-Scripty] Re: Range utility increment
I'd just use an 'iterator' class to do this... var EvenNumber = Class.create( { initialize : function(num){ this.num = (num % 2 == 1) ? num - 1 : num; }, succ : function(){ return new EvenNumber(this.num + 2); }, toString : function(){ return this.num; } }); var bottom = new EvenNumber(1); var top = new EvenNumber(21); var range = $A($R(bottom, top)); console.log(range); I had done this to a much greater extent in my date range selector gadget. Where it became the master range, held a range of calendar objects, which were in themselves ranges of date objects... fun stuff. https://positionabsolute.net/blog/2008/01/google-calendar-date-range-selection.php ps just looking over that, should rename that class to PositiveEvenNumber, only going to work one way, but you get the idea On Sep 25, 4:15 am, Alex McAuley webmas...@thecarmarketplace.com wrote: function everyOther(start, end, increment) { var n; var rv = []; for (n = start; n = end; n += increment) { rv[rv.length] = n; } return rv; } Just a mod to make it better to be able to change it to 3's, 4's, 5's ;) Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: T.J. Crowder t...@crowdersoftware.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, September 25, 2009 8:29 AM Subject: [Proto-Scripty] Re: Range utility increment Hi, I'm looking for a way to specify that I want to increment by any value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this? ObjectRange itself is for ranges of consecutive values, but you can get an array of such values by applying Enumerable#collect to a range: var twos; twos = $R(1, 5).collect(function(x) { return x * 2; }); ...although frankly I'd probably go with a straight loop like Alex did (although a slightly different one): function everyOther(start, end) { var n; var rv = []; for (n = start; n = end; n += 2) { rv[rv.length] = n; } return rv; } FWIW, -- T.J. Crowder tj / crowder software / comwww.crowdersoftware.com On Sep 24, 11:15 pm, JoJo tokyot...@gmail.com wrote: http://www.prototypejs.org/api/utility/dollar-r From the documentation of the Range utility, it seems like it can only increment by 1's. For example, $A($R(1,10,true)) gives you: [1,2,3,4,5,6,7,8,9,10]. I'm looking for a way to specify that I want to increment by any value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Range utility increment
That only gives you even or odd increments to the top number... Incorrect, notice the constructor method? It ensures that the number given is even such that you'll never get a range of odd numbers. Granted the last line of the Jojo's question was Let's say count up by 2's: [2,4,6,8,10]. How do you do this? Hence why I went with this specific implementation, to demonstrate how you can create classes that the ObjectRange class can use to create proper ranges. I didn't feel it was necessary to abstract out the class such that it covers all bases but demonstrate how to do it one way and then Jojo could modify for their own purposes. Better to go with my/TJ's loop What an arrogant plug of your own spaghetti code and hasty discredit to my contribution. Exposing your shortfalls isn't difficult, you aren't creating a range object, completely bypassing the ObjectRange's functionality and just simply creating a hacked out array. So to put the nail in the coffin, here is the classes abstracted out var IncrementNumber = Class.create({ initialize : function(num, increment){ this.num = num; this.increment = increment; }, succ : function(){ return this.clone(this.num + this.increment, this.increment); }, clone : function(num, increment){ return new IncrementNumber(num, increment); }, toString : function(){ return this.num; } }); var EvenNumber = Class.create(IncrementNumber, { initialize : function($super, num){ $super(num, 2); this.num = (num % 2 == 1) ? num - 1 : num; }, clone : function(num, increment){ return new EvenNumber(num); } }); var NumberRange = Class.create(ObjectRange, { _each: function(iterator) { var value = this.start; while (this.include(value.num)) { iterator(value.num); value = value.succ(); } }, }); var bottom = new IncrementNumber(-10, 2); //var bottom = new EvenNumber(-20); var top = new EvenNumber(25); var range = $A(new NumberRange(bottom, top)); console.log(range); nothing gets me fired up like a flame... On Sep 25, 2:25 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: That only gives you even or odd increments to the top number... WHat if you wanted every 5th number ... Better to go with my/TJ's loop Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Matt Foster mattfoste...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, September 25, 2009 5:57 PM Subject: [Proto-Scripty] Re: Range utility increment I'd just use an 'iterator' class to do this... var EvenNumber = Class.create( { initialize : function(num){ this.num = (num % 2 == 1) ? num - 1 : num; }, succ : function(){ return new EvenNumber(this.num + 2); }, toString : function(){ return this.num; } }); var bottom = new EvenNumber(1); var top = new EvenNumber(21); var range = $A($R(bottom, top)); console.log(range); I had done this to a much greater extent in my date range selector gadget. Where it became the master range, held a range of calendar objects, which were in themselves ranges of date objects... fun stuff. https://positionabsolute.net/blog/2008/01/google-calendar-date-range-... ps just looking over that, should rename that class to PositiveEvenNumber, only going to work one way, but you get the idea On Sep 25, 4:15 am, Alex McAuley webmas...@thecarmarketplace.com wrote: function everyOther(start, end, increment) { var n; var rv = []; for (n = start; n = end; n += increment) { rv[rv.length] = n; } return rv; } Just a mod to make it better to be able to change it to 3's, 4's, 5's ;) Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: T.J. Crowder t...@crowdersoftware.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, September 25, 2009 8:29 AM Subject: [Proto-Scripty] Re: Range utility increment Hi, I'm looking for a way to specify that I want to increment by any value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this? ObjectRange itself is for ranges of consecutive values, but you can get an array of such values by applying Enumerable#collect to a range: var twos; twos = $R(1, 5).collect(function(x) { return x * 2; }); ...although frankly I'd probably go with a straight loop like Alex did (although a slightly different one): function everyOther(start, end) { var n; var rv = []; for (n = start; n = end; n += 2) { rv
[Proto-Scripty] Prototype ajax history
Hey Everyone, I've finished a project that handles the problems of browser history when implementing ajax solutions. It's built to integrate with prototype perfectly and borrows a lot of the same concepts. The idea is an event driven system where all XHRs go through a single 'service' object which deals with server communications. This way we can register each request with the browser's history module and be able to accommodate the user as he/she traverses the history array. Take a look when you have a minute, its surely worth the time. http://positionabsolute.net/blog/2009/09/ajax-history-wars.php#number=6 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prototype ajax history
You asked for it Mona, I've set you up as a contributor for the project http://code.google.com/p/agileajax/ On Sep 21, 1:39 pm, Mona Remlawi mona.reml...@gmail.com wrote: thanks for sharing this! i would love to contribute to this project if any help is needed .. let me know cheers -- mona On Mon, Sep 21, 2009 at 7:00 PM, Matt Foster mattfoste...@gmail.com wrote: Hey Everyone, I've finished a project that handles the problems of browser history when implementing ajax solutions. It's built to integrate with prototype perfectly and borrows a lot of the same concepts. The idea is an event driven system where all XHRs go through a single 'service' object which deals with server communications. This way we can register each request with the browser's history module and be able to accommodate the user as he/she traverses the history array. Take a look when you have a minute, its surely worth the time. http://positionabsolute.net/blog/2009/09/ajax-history-wars.php#number=6 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Element#Storage
I agree with Jim, If I remove an element from the DOM for whatever reason, perhaps its a control widget that only gets inserted for inline editing or something. I don't want to re-apply listeners and proprietary data each time I reinsert the control back into the document. And this leads to another point that was made in another discussion about deep cloning, So lets say we implement the functionality to Element.remove and when you invoke this, it takes all the steps to properly dispose of that element, fantastic, but what about child elements, does it also walk through all children/grand children to detect and remove storage data for these as well? -- http://positionabsolute.net On Sep 9, 3:44 pm, david david.brill...@gmail.com wrote: Hi Jim, I could have both opinion: - As it is attach on an element what is the interrest of having data staying inline and element disapear ? - But as you say, if you want to keep data when the element is removed from the DOM, because we know that it will be recreate. When reading the prototype blog post {1], one purpose of this class is used to avoid memory leak in IE, which seems to go in the direction of removing data. In the post, there is a link to $.fn.data and there, nothing is said in API documentation of this function. I think that this type of question is for should ask to our team athttp://groups.google.fr/group/prototype-core [1]http://prototypejs.org/2009/2/16/pimp-my-code-1-element-storage -- david On 9 sep, 16:26, Jim Higson j...@wikizzle.org wrote: On Tuesday 08 September 2009 12:09:38 david wrote: Hi Yaffle, There is nothing in the code that seems to automatically delete the Storage object when an element is deleted. Even in the Element .remove, But removing an element doesn't mean I'll never use it again. I might remove it from the document and add it in somewhere else and I wouldn't want the data associated with it to have gone in the meantime. -- Jim my wiki ajaxification thing:http://wikizzle.org my blog:http://jimhigson.blogspot.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-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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: More useful clone method
Scenario for you... What if I have a parent object that I use deepClone on and it has child elements that have event handlers, is this functionality preserved with the method? On Aug 26, 1:18 pm, watermark86 watermar...@gmail.com wrote: Well, I have x-mas presents. I give it it works for me status. I've tested this bit of code with firefox and it seems to work with every scenario I can throw at it. I'm sure there is room for speed improvements and I know it doesn't conform to coding style, but it works. It would be great if prototype officially extended Element.clone with this functionality. deepClone: function(element) { var newElement = element.clone(true); //clone the node //stop observing all events on the newElement (IE (and some others?) copies them) newElement.stopObserving(); //copy storage Element.getStorage(newElement); (Element.Storage[newElement._prototypeUID[0]]=new Hash (Element.getStorage(element))).unset('prototype_event_registry'); //copy the events on the parent if (!Object.isUndefined(registry = Element.retrieve(element, 'prototype_event_registry'))) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(newElement, eventName, r.handler); }); }); } //get all of the descendants var srcdecend = element.descendants(); var dstdecend = newElement.descendants(); var numdecend = srcdecend.length; //foreach of the descendants for(var i = 0; i numdecend; ++i) { //stop observing all events on the newElement (IE (and some others?) copies them) dstdecend[i].stopObserving(); //copy storage Element.getStorage(dstdecend[i]); (Element.Storage[dstdecend[i]._prototypeUID[0]]=Element.getStorage (srcdecend[i]).clone()).unset('prototype_event_registry'); //copy the events on each child to it's new corrisponding child var registry = Element.retrieve(srcdecend[i], 'prototype_event_registry'); if (!Object.isUndefined(registry)) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(dstdecend[i], eventName, r.handler); }); }); } } return newElement; } On Aug 26, 9:43 am, watermark86 watermar...@gmail.com wrote: 1.6.1rc3 added Element.clone (which calls cloneNode). On Aug 25, 5:46 pm, Matt Foster mattfoste...@gmail.com wrote: Good luck with this, let us know if it works out. Quick glance at your code I can see an obvious error... var newElement = element.clone(true); //clone the node Element doesn't have a clone method. The native DOM element does have a cloneNode method though. -- http://positionabsolute.net On Aug 25, 2:15 pm, watermark86 watermar...@gmail.com wrote: I'm using 1.6.1rc3 to have access to Element.storage. I need to write a function that deep clones an element and copies the Element.observe events as well as the Element.Storage items with it. I've managed to write the code that can copy one or the other. The problem comes in when I try to do both (copy the storage items and the events.) I suppose due to Event.observe using the Element.storage item, I can't seem to have the items that I've stored with Element.store to copy while maintaining the Event.observe events that I've copied. I can copy the observe events or the element.store events, but not both. Below is some terrible code for review. Thanks for any help or insults. deepClone: function(element) { //deep clone node var newElement = element.clone(true); //clone the node //stop observing because of IE BS newElement.stopObserving(); //copy the item var registry = Element.retrieve(element, 'prototype_event_registry'); if (!Object.isUndefined(registry)) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(newElement, eventName, r.handler); }); }); } //for all of the descendants, copy the event handlers var srcdecend = element.descendants(); var dstdecend = newElement.descendants(); var numdecend = srcdecend.length
[Proto-Scripty] Re: KEY_DOWN event
The down arrow. Perhaps the preceding key up, key left and key right options could have given you a clue... On Aug 25, 8:07 am, Ooypunk ooyp...@gmail.com wrote: OK, then I'll go with that. Thanks! Only thing left for me to complain is that I still don't know what names like KEY_DOWN are for, or how they should be used, and that there's nothing in the manual (hint). On Aug 25, 11:37 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, If you want to know whether the control key was down when the mouse was clicked, then yes, the ctrlKey property of the mouse click event object is what you want. element.observe('click', function(event) { if (event.ctrlKey) { // Something cool here } } https://developer.mozilla.org/en/DOM/event.ctrlKey If you're looking to receive an event (separate from the click) when the control key is pressed, that varies quite a bit by browser:http://unixpapa.com/js/key.html But my impression is that you're just looking for it when the mouse is clicked, which is much more reliable. HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 25, 12:09 am, Ooypunk ooyp...@gmail.com wrote: Hi, I was looking for a way to capture a mouse-click plus ctrl-button. As I am using Prototype now for some time (it's great!), I thought Prototype could help me with this too. Sure, the manual is clear enough of how to capture a mouse-click event (that works fine here), but how about the ctrl-button? According to the manual, there's a list of key codes to be used (KEY_DOWN, for example), but there is no KEY_CTRL and there is nowhere to be found how they should be used. It says it's self explanatory, but for me it isn't. :( I think I can get it to work with event.ctrlKey, but I have a feeling, this is not the way. Thanks in advance. Ooypunk PS. I hope I made my problem clear enough, I know I'm not very good at explaining, especially because english is not my mother tongue. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: More useful clone method
Good luck with this, let us know if it works out. Quick glance at your code I can see an obvious error... var newElement = element.clone(true); //clone the node Element doesn't have a clone method. The native DOM element does have a cloneNode method though. -- http://positionabsolute.net On Aug 25, 2:15 pm, watermark86 watermar...@gmail.com wrote: I'm using 1.6.1rc3 to have access to Element.storage. I need to write a function that deep clones an element and copies the Element.observe events as well as the Element.Storage items with it. I've managed to write the code that can copy one or the other. The problem comes in when I try to do both (copy the storage items and the events.) I suppose due to Event.observe using the Element.storage item, I can't seem to have the items that I've stored with Element.store to copy while maintaining the Event.observe events that I've copied. I can copy the observe events or the element.store events, but not both. Below is some terrible code for review. Thanks for any help or insults. deepClone: function(element) { //deep clone node var newElement = element.clone(true); //clone the node //stop observing because of IE BS newElement.stopObserving(); //copy the item var registry = Element.retrieve(element, 'prototype_event_registry'); if (!Object.isUndefined(registry)) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(newElement, eventName, r.handler); }); }); } //for all of the descendants, copy the event handlers var srcdecend = element.descendants(); var dstdecend = newElement.descendants(); var numdecend = srcdecend.length; for(var i = 0; i numdecend; ++i) { //stop observing because of IE BS dstdecend[i].stopObserving(); //copy the registry var registry = Element.retrieve(srcdecend[i], 'prototype_event_registry'); if (!Object.isUndefined(registry)) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(dstdecend[i], eventName, r.handler); }); }); } } return newElement; } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Reuse 'Effect' code for looping
http://prototypejs.org/api/function/delay var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var delayConstant = 1; arr.each(function(value, index){ (function(val){ $(myInput).value = val; }).delay(delayConstant * index, value); }); -- http://positionabsolute.net On Aug 14, 5:53 am, Benj ben...@gmail.com wrote: Hey, I want to create a new effect that changes a numerical value in a text input box from one value to another by cycling through each number inbetween the two values. i.e. if the original value is 199.99 and I want to update it to 259.99 (normally with ajax) I would like the input value to be changed as below: 199.99 209.99 219.99 229.99 239.99 249.99 259.99 This should create a sped-up digital clock effect. I will play about with which numbers to include depending on the distance between the values. How do I harness the looping used for core effects to perform this operation? This will also provide me with the transitions and timing. Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Casting a json object into an instance of a class
You could just have the server return code that instantiates the object to begin with. You aren't limited to JSON its just convienent because the structure is simple and there are plenty of processors that understand it. But you can evaluate any JS code just as is. -- http://positionabsolute.net On Aug 12, 8:36 am, T.J. Crowder t...@crowdersoftware.com wrote: At least, I now know what is the state of the art way of getting a class instance through Ajax ;o) Well, I don't know if it's state of the art, but provided you're in control of both ends (so, for instance, the raw data object doesn't get fields that end up overwriting your methods), it seems fine. Thanks again! Happy to help, -- T.J. On Aug 12, 12:06 pm, Eric lefauv...@gmail.com wrote: Thanks for your reply T.J.! I did used Class instead of class. This was a typo when I posted :o) You're right, it should have work the way I did it... and it actually did work this way... ...except that due to a mistake in my events handling, my new thing value was overridden by some obsolete part of code just after being converted into a class instance :o( And since it was overridden by the raw JSON object value, I stupidly assumed that the casting didn't work. At least, I now know what is the state of the art way of getting a class instance through Ajax ;o) Thanks again! Eric On Aug 12, 10:49 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, That should work. I notice that you have class.Create rather than Class.create; I assume that's just an error in the note and that the actual code uses Class.create? Because if not, that's your problem. if(myInstance.isB())... = isB is undefined That indicates there's a different problem. isB should be defined regardless, you defined it in your class definition. If the Object.extend thing weren't working, it should *return* undefined, but not *be* undefined. FWIW, this works: * * * * (also athttp://pastie.org/581050) // Defining var Thing = Class.create({ initialize: function(src) { if (src) { Object.extend(this, src); } }, isB: function() { return this.b; } }); // Using: var t; t = new Thing({b: true}); alert(t.isB() ? + t.isB()); * * * * HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: image flickering with Effect.Morph
I am trying to code an OS X-style menu bar with prototype Are you talking about the dock? http://positionabsolute.net/blog/2007/08/prototype-fisheye.php On Jul 13, 4:05 pm, Mario Colombo mario.colo...@yetnet.ch wrote: Hi everybody, I am trying to code an OS X-style menu bar with prototype and scriptaculous 1.8.2. I have two problems which I hope to solve with your feedback. I myself am stuck after failing with all the ideas I had. Please find the example here:http://aldebaran.mine.nu/menu/menu.htmlhttp://aldebaran.mine.nu/menu/menu.jshttp://aldebaran.mine.nu/menu/menu.css 1st problem: image flickering: changing mouseover over the different divs produces a flash or flickering. Reading this group and other sources suggest that it is a problem with different Effects active at the same time. I tried to solve this over Effect.Queues and cancel the whole queue with my scope: 'menu' but unfortunately cancelling queues results in no effects at all: ---[code]-- // menuelement is the current menu div from $$('.level_one').each (function(menuelement) { elDimensions = menuelement.getDimensions(); // to set style manually to where the effect was cancelled var queue = Effect.Queues.get('menu'); // cancelling the whole scope: 'menu' queue queue.each(function(effect) { effect.cancel(); }); menuelement.setStyle('height:'+ elDimensions.height + 'px; ' + 'width:' + elDimensions.width + 'px;') // set dimensions to where effect stops var myEffect = new Effect.Morph(menuelement, {style: {width:'100px', height:'100px'}, queue: {position: 'end', scope: 'menu'}}); //new effect takes place ---[/code]-- I also tried to save all effects to the same variable myEffect, trying to have them overwrite themselves, which brought a partial improvement. 2nd problem: On 'mouseout' I would like the menu to return to its original state 'width:100px; height:100px;' I tried the following code: ---[code]-- Event.observe($('menu'), 'mouseout', function(event) { // 'menu' is the id of the containing div $$('.level_one').each(function(menuelement) { var myEffect = new Effect.Morph(menuelement, {style: {width:'100px', height:'100px'}}); });}); ---[/code]-- This resulted in erratic behaviour. Help would be greatly appreciated. Help for better OO programming is always welcome. Thank you in advance. Mario --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Getting keys from a JSON object returned from transport.responseText.evalJSON(); or for that matter any JSON object
var keys = $H(obj).keys(); http://prototypejs.org/api/hash/keys -- http://positionabsolute.net On Aug 10, 10:46 am, Alex McAuley webmas...@thecarmarketplace.com wrote: You can prolly sort the order if you wanted it in some kind of order but its not needed in my opinion! Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: T.J. Crowder t...@crowdersoftware.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, August 10, 2009 3:37 PM Subject: [Proto-Scripty] Re: Getting keys from a JSON object returned from transport.responseText.evalJSON(); or for that matter any JSON object Hi, Regardless of where the object came from (having evaluated it from a JSON string or something else), that's what for..in is for: var name, obj = {'a': 1, 'b': 2}.evalJSON(); for (name in obj) { alert(name + = + obj[name]); } ...alerts a=1 then b=2. The order is not guaranteed. Cool, eh? Speaking generally, for..in iterates through the names of the properties in the object. Note that depending on the object in question, some of those properties may refer to functions: var obj = { foo: function() { alert(Foo!); }, bar: 42 }; var name; for (name in obj) { alert(typeof obj[ + name + ] = + typeof obj[name]); } ...alerts obj[foo] = function and obj[bar] = number. for..in includes properties an object has inherited from its prototype: var a = ['one', 'two']; var name; for (name in a) { alert(typeof a[ + name + ] = + typeof a[name]); } ...will not only alert a[0] =one and a[1] = 2 but also any other enumerable properties on arrays. In most implementations, there aren't any other *enumerable* properties (some properties can be marked dontEnum, but only by the implementation, not our code), but when you're using Prototype, there are lots -- because Prototype adds lots of properties to the Array prototype referencing additional nifty Array functions. Which is why you don't use for..in to loop through array elements, there could be more than just the array elements.[1] You can filter out the properties that are inherited from the prototype by using hasOwnProperty: var a = ['one', 'two']; var name; for (name in a) { if (a.hasOwnProperty(name)) { alert(typeof a[ + name + ] = + typeof a[name]); } } ...will only alert the two you expect. All of the above is JavaScript, not Prototype; details in the spec[2]. [1]http://proto-scripty.wikidot.com/prototype:tip-looping-through-arrays [2]http://www.ecma-international.org/publications/standards/Ecma-262.htm HTH, have fun! -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 10, 2:54 pm, krishna81m krishna...@gmail.com wrote: I tried to google and search prototype API for a method that will give me just the keys in a JSON object. Is there none in Prototype and no way to know the keys? Regards Krishna --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: autosuggest feature enter button hack in new Ajax.Autocompleter
I've never actually used this component but in researching the docs, could you use the callback for afterUpdateElement and then programatically execute the form's submit method? http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleter -- http://positionabsolute.net On Aug 7, 10:11 am, Yogesh yogesh.aga...@gmail.com wrote: Hello All, I have just joined this group and it's my first post. I will like to thank the community for coming up with such a powerful library. I am using new Ajax.Autocompleter in one of script and it works fine. I am using it in a input text box, in which, user types in the search term and back end script queries the database to get a result set and suggested items get shown as a list in input text box. When the suggested items show up as list in my input text box, when I press enter/tab key, a single list item gets selected. However, to submit this item, I have to press enter key again. In short, I need to hit enter twice in order to submit the list item. I will like if this action is done in a single hit of enter key. I tried using some JavaScript hacks to submit the form on enter key but I think scriptaculus is over riding it. Is this the case? Is there any way to make this work with just single enter key? Thanks. Regards, Yogesh --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Class with Ajax and onclick event
Depending on when you wanted to pass the additional argument you could just attach it to the argument chain on bind this.changeContent = this.changeContent.bindAsEventListener(this, extraArgument); Since we're already looking at that line of code, be careful, reassigning the function to a bound version of itself could get tricky if you decide to create a subclass of Dynamic. -- http://positionabsolute.net On Aug 4, 9:24 am, Liviu Timar mailti...@gmail.com wrote: Hello, This is my first post here. Thus, I'll like to say hello to everybody in this community and I want to appologize if this question was asked before. I am a web developer for a site that has 1mil+ visitors/month: www [dot] ziare [dot] ro, and I want to use the Prototype Framework to make an element refresh itself (with an scriptaculous Effect) periodically. This is my class: var Dynamic = Class.create({ initialize: function(selector, container, script) { this.selector = selector; this.script = script; this.container = container; this.changeContent = this.changeContent.bindAsEventListener(this); this.getContent(); }, getContent: function() { new Ajax.Request(this.script, { onSuccess: function(req) { this.content = req.responseJSON; //document.fire('content:retrieved', req.responseJSON); } }); $$(this.selector).invoke('observe', 'click', this.changeContent.bind (this)); }, changeContent: function(event) { event.preventDefault(); console.log(this.content); console.log(this.container); /*new Effect.Fade($(this.container), { afterFinish: function() { new Effect.Appear($(this.container)); } }); $(this.container).update('cucu');*/ }}); document.observe('dom:loaded', function() { var dyn = new Dynamic(.tzNavLink a, tzContent, titlurileZilei.php); }); 'tzContent' is the div whose content changes by clicking on of the links with the 'tzNavLink' css class (the 1 2 3 4 5 6 links onwww.ziare.ro). The problem is that this.content is undefined in changeContent (a function that listens for the click event), although this.container works well in the same function. Why is that? It has something to do with the Ajax.Request? Also, I want to ask how can I 'tzContent' to change periodically using such and object (I want everything to be encapsulated so I can use this object in other projects)? Thank you for your response. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Class.create and this keyword
In an effort to keep the code clean I'd delegate this functionality to a dedicated method other than the constructor. On Aug 4, 2:16 pm, Matt Foster mattfoste...@gmail.com wrote: If you really wanted to avoid bind you could just use closures within the initialize method var Sub4 = Class.create(Super4, { baz: bat, initialize: function () { var self = this; var f = function () { alert(Class:+self.fu+self.baz); }; document.observe(click,f); } }); On Aug 4, 3:35 am, Cédric bertolini.ced...@gmail.com wrote: On 3 août, 22:38, Matt Foster mattfoste...@gmail.com wrote: Regardless of the JS framework. A closure is necessary for attaching class methods to a particular instance and preserve the instance reference via the this keyword. This is automatic with the regular Constructor syntax. Defining a function as an object method inside a constructor creates a closure, so we can use #bind at the same time as the definition. The point is, Class.create acts like a prototype more than as a constructor. I never really thought of that. So I can't bind to my object instance inside Class.create. And I guess that what acts as a constructor in Class is the initialize method... So, maybe, I should define f inside initialize, something like: var Sub4 = Class.create(Super4, { baz: bat, initialize: function () { this.f = function () { alert(Class:+this.fu+this.baz); }.bind(this); document.observe(click, this.f); } }); Is there a cost to operating that way? I guess I won't be able to use Class.addMethods... I thought Function.bind was pretty clean myself, but I guess you've got the sweet tooth for the syntax. I think #bind is awesome :) It's the bind the function in the initializer that bothers me, when I compare it to the standard syntax bind the function at its definition. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Masked Input in Prototype
The plugin's code is compliant with not conflicting with the $ function. But in your implementation of this plugin, you'll have to be sure to use jQuery(#maskInput).mask(...); instead of the demo's example code which uses the $ method. -- http://positionabsolute.net On Jul 30, 9:23 am, Celso cels...@gmail.com wrote: Unfortunately I am no expert in prototype. I can not believe that someone has developed a prototype mask! I try to use prototype and jquery together, Works:http://docs.jquery.com/Using_jQuery_with_Other_Libraries But .. the plugin does not works. On 29 jul, 18:27, Alex McAuley webmas...@thecarmarketplace.com wrote: why not just port the jquery one... wont take long ! Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Celso cels...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, July 29, 2009 10:22 PM Subject: [Proto-Scripty] Re: Masked Input in Prototype something like this:http://digitalbush.com/projects/masked-input-plugin On 24 jul, 06:48, Richard Quadling rquadl...@googlemail.com wrote: 2009/7/23 Matt Foster mattfoste...@gmail.com: You must further define your idea of masked input http://www.google.com/search?q=define%3A+masked+inputie=utf-8oe=utf... On Jul 23, 3:58 pm, Celso cels...@gmail.com wrote: Anyone know a masked input in prototype? Thanks, Celso. An inputmask[1] is where you can say enter text in a form like ... AA nn nn nn A You would be able to type 2 letters, 6 numbers and then 1 letter. The case would be forced to upper case and the spacing would be automatic. BO 52 91 91 V for example OR Are you talking about hiding the input? Like input type=password ? Regards, Richard. [1]http://www.google.co.uk/search?q=define:+input+mask -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! 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-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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Class.create and this keyword
Regardless of the JS framework. A closure is necessary for attaching class methods to a particular instance and preserve the instance reference via the this keyword. http://www.javascriptkit.com/javatutors/closures.shtml I thought Function.bind was pretty clean myself, but I guess you've got the sweet tooth for the syntax. -- http://positionabsolute.net On Aug 3, 1:16 pm, Cédric bertolini.ced...@gmail.com wrote: Thanks. I'll use #bind instead of #bindAsEventListener from now on. Regarding the binding inelegancy, I'm a bit disappointed, but at least it's a good working solution to the problem. I guess Class#addMethods won't be of any help here? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: get controls array
Hey Diego, I'd suggest learning CSS, in particular CSS Selectors. Second read up on prototype, you were a dollar sign away from almost having it. In your case, the name is too inconsistent, you could have almost gotten away with $$(input[name~=opt) but alas there is no space after it so it fails. As an alternative, looking at your code you just do... $$(input [type=text]) or if your collection requisites are more specific, add a class to the elements you want to collect and then simply $ (.myClass) -- http://positionabsolute.net On Jul 23, 5:50 pm, diegoturriaga diegoturri...@gmail.com wrote: I have something like that: tr tdPEPE/td tdinput ... name=opt[0][]input ... name=opt[0][] ... input ... name=opt[0][]/td tdselect ... name=selA[].../select/td tdselect ... name=selB[].../select/td /tr tr tdJUAN/td tdinput ... name=opt[1][]input ... name=opt[1] []...input ... name=opt[1][]/td tdselect ... name=selA[].../select/td tdselect ... name=selB[].../select/td /tr ... tr tdTITO/td tdinput ... name=opt[n-1][]input ... name=opt[n-1][] ... input ... name=opt[n-1][]/td tdselect ... name=selA[].../select/td tdselect ... name=selB[].../select/td /tr I want to get the array opt[x] using prototype but $('opt[x]') give me only the first instance. I need something like getElementsByName but using prototype :) Sorry for my english... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Masked Input in Prototype
You must further define your idea of masked input http://www.google.com/search?q=define%3A+masked+inputie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-a On Jul 23, 3:58 pm, Celso cels...@gmail.com wrote: Anyone know a masked input in prototype? Thanks, Celso. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Need help for performantly creating tooltips
I think one of the easiest ways to handle tooltips is just let the native browser deal with it, using the title attribute with imgs and anchor elements will pop a 100 word tip on what the action will take. So just create the tool with a title attribute and then you're good to go. --- http://positionabsolute.net On Jul 22, 10:53 pm, Trevan Richins develo...@ckiweb.com wrote: On 7/22/2009 11:05 AM, Chris wrote: moverListener: function(e) { elm = Event.findElement(e, '.' + this.classes); if(elm !== undefined) { this.showToolTip(elm) } else return; }, moutListener: function(e) { elm = Event.findElement(e, '.' + this.classes); if(elm !== undefined) { this.hideTooltip(elm); } }, . I've found Event.findElement to be really slow in IE6. I've always rewritten it to just loop through the parents and do a quick check for each item. The reason findElement was been slow for me is that it asks the selector class for all items in the page that matches the selector, and then compares that list against the list of parents to see which ones it should return. And since IE6 can't use xpath, it is very slow. But this is definitely better than binding to each individual item, especially if you have a bunch of them. Eats up memory and bogs down the browser. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: DataGrid
That is nice, you should submit it to http://scipteka.com -- http://positionabsolute.net On Jul 17, 4:14 am, Alex McAuley webmas...@thecarmarketplace.com wrote: Nice data grid! ... what about inline editing of the cells ? .. i cant get it to work on firefox in your demo - Original Message - From: nirbhab nirbhabba...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, July 16, 2009 7:32 AM Subject: [Proto-Scripty] DataGrid http://is.gd/1zDvChave a flexible datagrid...but sorting issue is there. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Objects that return zero length
Hmm, well you'd have to do a little extra filtering but no reason this isn't possible. assuming obj is your main structure you just posted do something like this... var edgeArr = $H(obj.nodes).keys().findAll(function(itr){ return ! (obj.nodes[itr].edges instanceof Array);}).collect(function(key) { return obj.nodes[key]; }); edgeArr is now an array of all objects that have a valid edges structure. ps. You owe me one pint of beer. On Jul 14, 10:47 pm, ronman ron.new...@gmail.com wrote: Yes, that's pretty close. attr is an object with properties, and one of those, attr.edges, is a nested object with its own nested sub- objects. All these properties and objects are constructed by evalJson () and then put in a $H() in a manner very similar to what you just described. I've copied a sample of the structure below. I was assuming that putting this whole thing within $A() would make the individual members (properties and objects) iterable, but perhaps I'm misunderstanding and instead every property and sub-object must be iterable (that is, understand the [] operator and have a length() method). Unfortunately, when the sub-object edges is empty, then running each () on the hash that contains it fails. arr.each(function(edgeProperty){ // fails if arr is an empty Hash. works if arr is an empty Array. fails if arr is a filled Array. Notice that the first edges is empty and the second one has one member: Brainwriting. from json: { nodes: { Brain Writing : { label: BRAIN\\nWRITING , height: 0.50, width: 0.83, fontsize: 10.00, fontcolor: white, pos: [ 570, 213 ], id: 1695, onmousedown: startdrag('1695'), length: 1, edges: [ ] }, A Perfect Brainstorm : { label: A PERFECT\\nBRAINSTORM\\n, height: 0.50, width: 1.11, fontsize: 10.00, fontcolor: white, pos: [ 326, 167 ], class: node, onmousedown: startdrag('1701'), length: 1, edges: { Brainwriting : { color: black, penwidth: 0.5, fontname: Arial, URL: javascript:void(predwin(2179)), label: bull; , } Ron blog.ideatree.us On Jul 14, 4:47 pm, Matt Foster mattfoste...@gmail.com wrote: Oh I get it now, attr.edges isn't an array of edge objects, its just an object with a series of properties that define an edge to your shape? If that is the case and you wish to iterate over the properties and execute set on them explicitly, you could do something like... var arr = $H(attr.edges).keys(); arr.each(function(edgeProperty){ this[edgeProperty].set(...); }, attr.edges); On Jul 14, 3:09 pm, ronman ron.new...@gmail.com wrote: Here's what I'm doing now: $A(attr.edges).each(function(edge) { edge.set(id, new GraphEdge(cv, id, edge)); }, this); Same result. The iterator.length shows zero and the inside of the loop never executes. But the iterator is (correctly, I think) 'Object Brainwriting =Object' Just casting around, I also tried taking off the binding to 'this' at the end, doesn't help. As before, I'm not getting why anything whatsoever that's in an array shouldn't automatically return length 0. On Jul 14, 1:47 pm, Matt Foster mattfoste...@gmail.com wrote: $A(attr.edges).each(function(edge) { this.edge.set(id, new GraphEdge(cv, id, edge)); }, this); edge is your variable, why bother trying to set function ownership? The function is sent the parameter it needs to act upon. Just remove this from your this.edge... line and you should be good. -- http://positionabsolute.net On Jul 14, 2:28 pm, ronman ron.new...@gmail.com wrote: This is a newbie question, but I learn a lot every time I ask. Why do some objects return a zero length? I'm doing Array.each. In the array at this particular time is a single object. Firebug describes that object as Object Brainwriting color=black penwidth=0.5 fontname=Arial and I iterate through the array this way: $A(attr.edges).each(function(edge) { this.edge.set(id, new GraphEdge(cv, id, edge)); }, this); But in Prototype's each method the 'edge' iterator (the Brainwriting Object), returns zero length: function $A(iterable) { if (!iterable) return []; if (iterable.toArray) return iterable.toArray(); var length = iterable.length || 0, results = new Array(length); // LENGTH NOW IS ZERO while (length--) results[length] = iterable[length]; return results; } Maybe the Brainwriting Object is not iterable, but I would expect $A (attr.edges) to have made it so before my call to each(). Surely I'm not expected to assign a length attribute to objects myself - just
[Proto-Scripty] Re: mixin of function not found
Factory pattern in a nutshell is using the same source for all creation of a particular class, such that all instances can be prepared identically. The source being a method, probably a member of a class, you always reference this method to create a new instance instead of calling new Class directly in your implementation. The advantage of this is that when your implementation wants all instances to have a particular property set you can set it in this central method before it gets returned instead of having to run around your code and find everytime you instantiated it. Or even better, the factory method returns a subclass that has this property/function already built in. http://en.wikipedia.org/wiki/Factory_method_pattern Element is not an instance nor does it a extend from Class/ Class.create so you can't swap this sort of functionality. The following will not work as you're anticipating. var CanvasElement = Class.create(Element, { myMethod : function(){ // } }); var myCanvas = new CanvasElement(); myCanvas.myMethod(); //fail -- http://positionabsolute.net On Jul 14, 12:26 pm, ronman ron.new...@gmail.com wrote: OK on using addMethods. Makes sense, and it's working for me. Very nice. Thanks. About not assigning functions after creation without a good factory method, I'm confused. Isn't that what the example is doing on the Prototype example at: http://prototypejs.org/learn/class-inheritance ? // define a module var Vulnerable = { wound: function(hp) { this.health -= hp; if (this.health 0) this.kill(); }, kill: function() { this.dead = true; } }; // the first argument isn't a class object, so there is no inheritance ... // simply mix in all the arguments as methods: var Person = Class.create(Vulnerable, { initialize: function() { this.health = 100; this.dead = false; } }); var bruce = new Person; bruce.wound(55); bruce.health; //- 45 On Jul 13, 4:22 pm, Matt Foster mattfoste...@gmail.com wrote: The second argument is accepting attributes of the HTML element. It isn't just assigning values to the object like Object.extend style. I'd recommend using Element.addMethods, and scope it to only canvas elements, that way each time you create a canvas you'll have this method available, but it won't pollute other elements with this special functionality. Element.addMethods('canvas', ...); http://prototypejs.org/api/element/addMethods You could also assign the function value after creation, but unless you're using a good factory pattern, you could easily get instances of canvas without your specialized method. You can't send methods to the constructor like that, just won't work. The declaration for Element is a bit bizarre so it can be hard to find, so here it is... (function() { var element = this.Element; this.Element = function(tagName, attributes) { attributes = attributes || { }; tagName = tagName.toLowerCase(); var cache = Element.cache; if (Prototype.Browser.IE attributes.name) { tagName = '' + tagName + ' name=' + attributes.name + ''; delete attributes.name; return Element.writeAttribute(document.createElement(tagName), attributes); } if (!cache[tagName]) cache[tagName] = Element.extend (document.createElement(tagName)); return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); }; Object.extend(this.Element, element || { }); if (element) this.Element.prototype = element.prototype; }).call(window); -- http://positionabsolute.net On Jul 13, 2:40 pm, ronman ron.new...@gmail.com wrote: Why doesn't 'getCoordinates' show up in the following code? canvas.getCoordinates() throws an error of getCoordinates is not a function I'm making a newbie error somewhere. var canvas = new Element('canvas', { width: this.xform(data.size[0]) + 16 + 'px', height: this.xform(data.size[1]) + 16 + 'px', // mixin to Element for canvases getCoordinates: function(element){ var position = this.getPosition(element), size = this.getSize (); var obj = {left: position.x, top: position.y, width: size.x, height: size.y}; obj.right = obj.left + obj.width; obj.bottom = obj.top + obj.height; return obj; }, } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax Request Timeout
Hey Rick, My proposed idea in that article requires you to actually redefine the Ajax.Request. If we can solidify the idea we could submit the code as a patch to core but as of now you've gotta either replace it in the source library itself or just redefine it after the library but before any implementation. Review that demo page to see how I had done it and you could probably get it working. On Jul 14, 1:57 pm, Rick dun...@googlemail.com wrote: hi But leaving aside status 0, just a logical point. The third condition in your updated code: return (status = 200 status 300 status != 0); ...is irrelevant and will never be evaluated. If 200 = x 300, x cannot be zero. i can't believe what piece rubbish of code i have written, my brain must have bin offline :'( i think the zero comes from that part: --- line: 1499-- getStatus: function() { try { return this.transport.status || 0; } catch (e) { return 0 } } --- so Firefox must leave the status undefined. @ Matt Foster : i tried your patch but it didn't work for me, but maybe its my fault ... maybe it was a bad day of coding for me :) i will try it again yes the Ajax part off prototype is a bit uncomfortable by the way sorry I am not a native English speaker, so don't be mad with me ;) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Objects that return zero length
Oh I get it now, attr.edges isn't an array of edge objects, its just an object with a series of properties that define an edge to your shape? If that is the case and you wish to iterate over the properties and execute set on them explicitly, you could do something like... var arr = $H(attr.edges).keys(); arr.each(function(edgeProperty){ this[edgeProperty].set(...); }, attr.edges); On Jul 14, 3:09 pm, ronman ron.new...@gmail.com wrote: Here's what I'm doing now: $A(attr.edges).each(function(edge) { edge.set(id, new GraphEdge(cv, id, edge)); }, this); Same result. The iterator.length shows zero and the inside of the loop never executes. But the iterator is (correctly, I think) 'Object Brainwriting =Object' Just casting around, I also tried taking off the binding to 'this' at the end, doesn't help. As before, I'm not getting why anything whatsoever that's in an array shouldn't automatically return length 0. On Jul 14, 1:47 pm, Matt Foster mattfoste...@gmail.com wrote: $A(attr.edges).each(function(edge) { this.edge.set(id, new GraphEdge(cv, id, edge)); }, this); edge is your variable, why bother trying to set function ownership? The function is sent the parameter it needs to act upon. Just remove this from your this.edge... line and you should be good. -- http://positionabsolute.net On Jul 14, 2:28 pm, ronman ron.new...@gmail.com wrote: This is a newbie question, but I learn a lot every time I ask. Why do some objects return a zero length? I'm doing Array.each. In the array at this particular time is a single object. Firebug describes that object as Object Brainwriting color=black penwidth=0.5 fontname=Arial and I iterate through the array this way: $A(attr.edges).each(function(edge) { this.edge.set(id, new GraphEdge(cv, id, edge)); }, this); But in Prototype's each method the 'edge' iterator (the Brainwriting Object), returns zero length: function $A(iterable) { if (!iterable) return []; if (iterable.toArray) return iterable.toArray(); var length = iterable.length || 0, results = new Array(length); // LENGTH NOW IS ZERO while (length--) results[length] = iterable[length]; return results; } Maybe the Brainwriting Object is not iterable, but I would expect $A (attr.edges) to have made it so before my call to each(). Surely I'm not expected to assign a length attribute to objects myself - just lilke 'penwidth' and 'color' were assigned - in order to make Array.each() work on objects. Why doesn't the Object.length return non-zero when any kind of Object is instantiated? I'm using Firefox 3.0.10. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax Request Timeout
Yeah I discuss the idea of having its own event for timing out in my article. The argument is a timeout is a failure, its failed to retrieve a response in the given time. So a timeout is basically like an inherited event from onFailure. Question remains do you seperate the event or just add a flag to the XHR to indicate the reason for failure is its timed out. Obviously you side with the latter as did Tobie so perhaps it would be best to dispatch both events for ease of implementation. Also that success method looks exactly like what TJ suggested and I posted, so good going on that. On Jul 14, 3:56 pm, Rick dun...@googlemail.com wrote: currently i just fixed the success function success: function() { var status = this.getStatus(); return (status = 200 status 300); }, and just watch the onFailure and onException event. But i would like to have an onTimeout event, so if we get an solution for a crossbrowser working onTimeout event, we can submit it. I have read about an solution but this one was rejected because it didn't worked in safari, etc. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: select option by value
You could use many of the enumerable methods, this seems a bit verbose but gets the job done. Enumerable.find will iterate over the collection until the iteration function returns a value of true. I could have used each, but potentially would have iterated more than necessary, as we'd really want to halt search after a successful find. http://prototypejs.org/api/enumerable/find $A(select.options).find(function(option, index){ if(option.value == someValue){ select.selectedIndex = index; return true; } return false; }); -- http://positionabsolute.net On Jul 7, 4:58 pm, Martín Marqués martin.marq...@gmail.com wrote: I'm trying to select an option from a select, but by value, and not by index. I'm trying like this: function selectOptionByValue(selectID,valor){ var found = false; var i = 0; while(!found iselectID[0].options.length){ if(selectID[0].options[i].value == valor) { selectID[0].options[i].selected=true; found = true; } i++; } } I would call this function passing as argument the DOM object of the select and the option value that should be selected. Is there an easier way of doing this? BTW, it's not working for me. -- 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Events in own Class
This will work, but remember that the instance isn't going to actually fire an event, its just really acting as liaison to the document object to fire off events via document. You've somewhat namespaced the event with your reference ID which is going to make things difficult for anything attempting to observe an event from an instance. document.observe(observable_ + myInstance._refID + :onFoo); Prototype's custom events are events that can fire from a DOM instance, which will bubble to parents and can be caught at the top or wherever along the propagation chain. What I believe you are looking for is events fired from a function/class instance. You can get the function instance to throw an event by using the scripts i posted above. -- http://positionabsolute.net On Jun 29, 5:07 pm, Sven stuebe...@googlemail.com wrote: ok i tryed something... var Observable = Class.create({ initialize : function(){ this._refID = Observable.prototype.refCount++; }, observe : function(name, handler){ document.observe('observable_' + this._refID + ':' + name, handler); }, fire : function(name){ document.fire('observable_' + this._refID + ':' + name); } }); Object.extend(Observable.prototype, {refCount : 0}); var Test = Class.create(Observable, { initialize : function($super){ $super(); }, foo : function(){ this.fire('onFoo'); } }); is only a prototype for testing. Is it the right way or not? thanks, rgds sven On 29 Jun., 20:17, Matt Foster mattfoste...@gmail.com wrote: I ran into this same issue and made a class to extend others from to inherit this sort of functionality. This is the article but the JS itself is a bit outdatedhttp://positionabsolute.net/blog/2007/06/event-dispatcher.php To get the freshest JS...http://positionabsolute.net/includes/javascripts/EventDispatcher.js On Jun 29, 12:56 pm, Sven stuebe...@googlemail.com wrote: hmm but wait this is a global event... i want a instance-based event. xyz.foo(); //alert(barbarbar); abc.foo(); // alert(1234); and second $('bla').hide(); rgds sven On 29 Jun., 18:41, Sven stuebe...@googlemail.com wrote: wow thank you ;) On 29 Jun., 18:38, Rick Waldron waldron.r...@gmail.com wrote: Dig it: http://jsbin.com/uhogi (view the source) Rick On Mon, Jun 29, 2009 at 12:19 PM, Sven stuebe...@googlemail.com wrote: Hi, is it possible to add Events to own classes? something like this: var myClass = Class.create({ foo : function(){ this.fire('bar'); } }); var xyz = new MyClass(); xyz.observe('bar', function(){alert(barbarbar);}); rgds sven --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Events in own Class
I ran into this same issue and made a class to extend others from to inherit this sort of functionality. This is the article but the JS itself is a bit outdated http://positionabsolute.net/blog/2007/06/event-dispatcher.php To get the freshest JS... http://positionabsolute.net/includes/javascripts/EventDispatcher.js On Jun 29, 12:56 pm, Sven stuebe...@googlemail.com wrote: hmm but wait this is a global event... i want a instance-based event. xyz.foo(); //alert(barbarbar); abc.foo(); // alert(1234); and second $('bla').hide(); rgds sven On 29 Jun., 18:41, Sven stuebe...@googlemail.com wrote: wow thank you ;) On 29 Jun., 18:38, Rick Waldron waldron.r...@gmail.com wrote: Dig it: http://jsbin.com/uhogi (view the source) Rick On Mon, Jun 29, 2009 at 12:19 PM, Sven stuebe...@googlemail.com wrote: Hi, is it possible to add Events to own classes? something like this: var myClass = Class.create({ foo : function(){ this.fire('bar'); } }); var xyz = new MyClass(); xyz.observe('bar', function(){alert(barbarbar);}); rgds sven --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Working out where a user is on the page
When your event fires just get the scroll properties from the window, Prototype has a convenient method just for this purpose. http://prototypejs.org/api/document/viewport/getscrolloffsets -- http://positionabsolute.net On Jun 11, 9:30 am, Jeztah webmas...@thecarmarketplace.com wrote: At the time of a function call is it possible to work out where the user is on the page (scroll wise) without something being clicked or moved. I have an error function i built and it scrolls down to the center of the whle page (including anything past the scrollbar) - example of the viewport is 600px high and the whole page is 1000px high it will scroll so 500px is the middle of the screen as the use sees it But, this is annoying if the error was generated from an action at the top of the page as it scrolls down 500px to show the error - making the user effectvely scroll back up!... It would be great if my function was aware of the user's position on the page - the only problem is ... the function is only passed a string to disply in the error at present so i have no reference to see its offsets on the page to work this stuff out.. so i was wondering if it can be done without passing an element into the funciton to work it out!.. Regards Alex --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: HTML breaks JSON
You guys are crazy...you send json_encode an object, not a string!! http://us3.php.net/manual/en/function.json-encode.php -- http://positionabsolute.net On Jun 5, 6:16 am, Alex McAuley webmas...@thecarmarketplace.com wrote: very strange .. works for me with anything all the time - Original Message - From: Matt guitarroman...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, June 05, 2009 10:05 AM Subject: [Proto-Scripty] Re: HTML breaks JSON Hi Alex, Still didn't work for me :( Just produced broken HTML output again. On Jun 4, 5:24 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: You need to do it a bit differently with php json_encode/decode ... i had this problem when i first started using it where you send post data (JSON) as p $post=str_replace('\', '', $_POST['p']); $json=$post; $d=json_decode($json,true); foreach($d as $key=$val) { .. do what you will with it after this unless you know the key names !! This should do the trick for you HTH ALex - Original Message - From: Matt i...@leedsguide.co.uk To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, June 04, 2009 4:30 PM Subject: [Proto-Scripty] Re: HTML breaks JSON Hi again, I've been running addslashes() on the input before running json_encode () and it still creates problems when I pass it through AJAX - breaks HTML tags etc. If I turn addslashes() off, any occurence of in the body text (eg quotes from speakers etc) breaks the code again. Does anyone have a foolproof method? Cheers Matt On Apr 24, 9:54 pm, Matt Foster mattfoste...@gmail.com wrote: What are you sending to PHP's json_encode? It is expecting a structure to serialize into a JSON syntax string. $struct = array(message = h1Hello World/h1Who says we can't have any kind of \quotes\ we want?); echo json_encode($struct); If you try to run json_encode on your already JSONified string, yeah its going to cause problems... -- http://positionabsolute.net On Apr 24, 12:26 pm, T.J. Crowder t...@crowdersoftware.com wrote: @Ananth: Converting to Base64 would be massive overkill, surely. @OP: There's no reason you can't include strings containing HTML in JSON data. You just have to make sure your strings are valid string literals, like this: { message: pThis is HTML./p } There's nothing special other than making sure the HTML is correctly escaped -- e.g., if you're putting the JSON string in double quotes, naturally any double quotes in the HTML will need a backslash in front of them -- as, for that matter, will any backslashes! HTH, -- T.J. Crowder tj / crowder software / com On Apr 24, 5:05 pm, Ananth Raghuraman araghuram...@gmail.com wrote: JSON should not contain HTML for tactical/ease of programming purposes unless the HTML is there as part of a larger design, but there may or may not be implementation restrictions. If you are facing problems, can you try encoding the HTML string (Base64) and decoding back (using Javascript Base64 code ) before display on the browser? On Fri, Apr 24, 2009 at 11:30 AM, Matt guitarroman...@gmail.com wrote: Hi there, I'm using PHP to output some JSON through AJAX to my page. It breaks whenever I use a backslash or quote mark. I've tried using php's json_encode function which doesn't seem to help, just breaks it further. I've also tried php's addslashes() to the output, again, same problem. Am I approaching this correctly, fundamentally? Is JSON supposed to contain HTML? Thanks, Matt --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Event.toggle
Is there a way to initially load the page with the map open and then close it after a timed period? Better yet, is there some way to load it with it hidden but not chopped up? Yeah, having it display:none or visibility:hidden can muck up the calculations of the containers dimensions. I'd suggest the good ole trick of hiding IFrames, which is just set the container as { position:absolute; left: -4000px; } This way the map is off the view port hence invisible to the user and yet fully accessible via the DOM for dimension calculations. Thinking more about it, you may not want to instantiate the map until you're ready, nothing says it has to be done on page load, I had done some work with Ext.js and Google maps, where Ext does the DOM element creation all via JS execution, i loaded the map only when it was necessary. http://positionabsolute.net/projects/javascript/ext/googleservice/ -- http://positionabsolute.net On Jun 5, 5:09 am, MIGhunter ad...@botdls.com wrote: I'm trying to use a script to hide and show user information. Right now I am just playing with it and here is what I have:http://migcfdesign.com/joani/index.html The problem is the map. I can't load the page with the map hidden. If I do chops off 1/2 of the map. Is there a way to initially load the page with the map open and then close it after a timed period? Better yet, is there some way to load it with it hidden but not chopped up? I'm not sure what's the conflict is between google's js and prototype.js. The url to a copy of the map messing up is:http://migcfdesign.com/joani/index2.html Here is the code I am using: html head titleToggle Test/title meta http-equiv=Content-Type content=text/html; charset=utf-8 / meta name=viewport content=initial-scale=1.0, user-scalable=no / script src=/javascripts/lib/prototype.js type=text/javascript/ script script src=/javascripts/src/scriptaculous.js type=text/ javascript/script script type=text/javascript src=http://maps.google.com/maps/api/ js?sensor=true/script script type=text/javascript Event.observe(window, 'load', function() { Event.observe('featurebox-3-listen', 'click', function(){ $('featurebox-3').toggle(); }); }); Event.observe(window, 'load', function() { Event.observe('featurebox-4-listen', 'click', function(){ $('featurebox-4').toggle(); if($('featurebox-4').hide()){ $('featurebox-4-listen').update('(812)555-'); } else { //do nothing. } }); }); Event.observe(window, 'load', function() { Event.observe('featurebox-5-listen', 'click', function(){ $('featurebox-5').toggle(); if($('featurebox-5').hide()){ $('featurebox-5-listen').update(' Street Bloomington, IN 47401'); } else { //do nothing. } }); }); function initialize() { var latlng = new google.maps.LatLng(39.1485520, -86.5857814); var myOptions = { zoom: 13, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById (map_canvas), myOptions); } /script /head body onload=initialize() table tr tdimg src=images/map_symbol.jpg alt=Map title=Map/td tdpspan id=featurebox-3-listena href=#strongMap (Hide) /strong/a/span | span onclick=$('featurebox-3').toggle();a href=#strongMap (Show)/strong/a/span/p/td div class=featurebox id=featurebox-3div class=featurebox id=featurebox-2 pdiv id=map_canvas style=width:50%; height:50%/div/p /div /tr tr tdimg src=images/phone_symbol.jpg alt=Phone title=Phone Number/td tdspan id=featurebox-4-listena href=#strongPhone Number/ strong/a/span/td
[Proto-Scripty] Re: How can I get a list of events fired by an object?
The iframe element doesn't support any events[1]. You can indeed listen to the load event directly from the IFrame element. http://pastie.org/493154 The document that it contains may support various events (such as load, click, etc.). Why would a document inside an iframe not support these events? -- http://positionabsolute.net On May 21, 8:46 pm, RobG rg...@iinet.net.au wrote: On May 22, 12:11 am, Walter Lee Davis wa...@wdstudio.com wrote: I'd like to see what events are there for the observing, particularly on an iframe. The iframe element doesn't support any events[1]. The document that it contains may support various events (such as load, click, etc.). Is there a general-purpose way (or even some tab of Firebug I haven't seen before) that I can see what events are being fired? Some sort of Event.observe('foo','*'... kind of thing? Try Firebug's Profile option. 1. URL:http://www.w3.org/TR/html401/present/frames.html#edef-IFRAME -- Rob --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: How can I get a list of events fired by an object?
I'm pretty sure you can listen to the iframe's load event for that... I don't think it bubbles so you'll have to listen to it on the iframe itself and not on a parent. I use that event extensively in my ajax history solution, http://positionabsolute.net/blog/2007/07/javascript-history-service.php -- http://positionabsolute.net On May 21, 5:39 pm, Walter Lee Davis wa...@wdstudio.com wrote: Thanks, it appears that the only way that I'll be able to work around this is with a timed observer pattern, there doesn't seem to be an event fired by an iframe into the page context when its src changes. The underlying problem was how to keep an iframe sized to match its contents. While you get one onload event when the frame finishes loading, no others are ever fired, even when you navigate to a different page within the iframe. Walter On May 21, 2009, at 5:05 PM, Matt Foster wrote: You could find a list of all events and listen to them each, there isn't an all operator to listen to any event that is fired as far as I know... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: How can I get a list of events fired by an object?
You could find a list of all events and listen to them each, there isn't an all operator to listen to any event that is fired as far as I know... function allYourEventAreBelongToUs(e){ console.log(You hit an event %o, e); } $w(load unload click dblclick ...).each(function(evenType){ $(ele).observe(eventType, allYourEventAreBelongToUs); }) Here is a list I found of most events in JS, just remove the on obviously for your purposes... http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.3 -- http://positionabsolute.net On May 21, 10:11 am, Walter Lee Davis wa...@wdstudio.com wrote: I'd like to see what events are there for the observing, particularly on an iframe. Is there a general-purpose way (or even some tab of Firebug I haven't seen before) that I can see what events are being fired? Some sort of Event.observe('foo','*'... kind of thing? Thanks in advance, Walter --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Observe onmouseover and onmouseout with IE6
What is surprising to me is that the this scope ever actually worked inside the event handlers. Had you left the handle alone I know that Proto would have bound the element to the handler such that this would assume the value of the element, but since you explicitly set this via bind in the iterable function, it should have overwritten that. The value of this in the iterable function is window, so you're really binding window to the event handler's owner scope, not the element at large. If this worked though, then somewhere in this idea I'm mistaken but I cannot see where. -- http://positionabsolute.net On May 20, 1:54 am, Dravis plu...@gmail.com wrote: I have this bit of code in my webpage's header. It simply pulls all the li elements from the mainmenu and attaches onmouseover and onmouseout event observers to them to toggle the drop down effects of the menu. It works perfectly in IE7 and Firefox but when I mouse over the menu in IE6 I get nothing. Anyone have any ideas? document.observe(dom:loaded, function() { $$('#mainmenu li').each(function(item) { $(item).observe(onmouseover, function() { $(this).addClassName(sfhover); }.bind(this)); $(item).observe(onmouseout, function() { $(this).removeClassName(sfhover); }.bind(this)); }); }); --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Check element class against array
var test = ['foo', 'bar', 'foob']; if (test.any(element.hasClassName.bind(element))) { I believe using the non-methodized version of this method would be better Element.hasClassName.curry(element); -- http://positionabsolute.net On May 14, 12:30 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I can think of two approaches off-hand: 1. Use Enumerable#include on the array of classes you want to test against, using Element#hasClassName as the iterator function (bound to the instance), e.g.: var test = ['foo', 'bar', 'foob']; if (test.any(element.hasClassName.bind(element))) { // ... } or if (['foo', 'bar', 'foob'].any(element.hasClassName.bind (element))) { // ... } (You don't need to use $A() around array literals.) 2. Use $w on the class name to get an array of the individual class names, then use Enumerable#any on that, passing in Enumerable#include on the array you want to test against as the #any iterator. Something like this: var test = ['foo', 'bar', 'foob']; if ($w(element.className).any(test.include.bind(test))) { log(true); } (Both of those bits of code are untested.) But if this is going to be happening a lot (a tight loop, or a mouseover handler, etc.), check the runtime cost of each of these by going under the covers. FWIW, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 13, 7:34 pm, louis w louiswa...@gmail.com wrote: I have an array containing a number of strings. I would like to continue exucuting my script only if an item has ANY/ALL of the strings assigned as a class name. $A(['foo', 'bar', 'foob']); Is there an elegant want to do this without having to loop through the items? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Check element class against array
I think you misinterpreted what I was saying. Simply swapping bind for curry will certainly generate errors. I don't really feel like explaining it and its of potentially trivial performance results but, savor some of this syntax... var ele = $(container); var arr = $w(foo bar derka); var bool = arr.any(Element.hasClassName.curry(ele)); console.log(bool);//if this throws an error, get firebug!! ... div id=container class='foo'/div -- http://positionabsolute.net On May 14, 5:04 pm, louis w louiswa...@gmail.com wrote: Thanks guys. I am going to compare the difference in processing time of TJ's suggestions. It will be called often (from a Form Observer). For now I am using this one: if (_validate_field_classes.any(element.hasClassName.bind (element))) { Wasn't aware of the any function. Matt. I tried swapping bind for curry and it gave an error. On May 14, 3:32 pm, Matt Foster mattfoste...@gmail.com wrote: var test = ['foo', 'bar', 'foob']; if (test.any(element.hasClassName.bind(element))) { I believe using the non-methodized version of this method would be better Element.hasClassName.curry(element); -- http://positionabsolute.net On May 14, 12:30 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I can think of two approaches off-hand: 1. Use Enumerable#include on the array of classes you want to test against, using Element#hasClassName as the iterator function (bound to the instance), e.g.: var test = ['foo', 'bar', 'foob']; if (test.any(element.hasClassName.bind(element))) { // ... } or if (['foo', 'bar', 'foob'].any(element.hasClassName.bind (element))) { // ... } (You don't need to use $A() around array literals.) 2. Use $w on the class name to get an array of the individual class names, then use Enumerable#any on that, passing in Enumerable#include on the array you want to test against as the #any iterator. Something like this: var test = ['foo', 'bar', 'foob']; if ($w(element.className).any(test.include.bind(test))) { log(true); } (Both of those bits of code are untested.) But if this is going to be happening a lot (a tight loop, or a mouseover handler, etc.), check the runtime cost of each of these by going under the covers. FWIW, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 13, 7:34 pm, louis w louiswa...@gmail.com wrote: I have an array containing a number of strings. I would like to continue exucuting my script only if an item has ANY/ALL of the strings assigned as a class name. $A(['foo', 'bar', 'foob']); Is there an elegant want to do this without having to loop through the items? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Please Help With Code
I think he's looking for a snippet handout, by the looks of the spaghetti that he's pasted he's trying to highlight a single item in a menu. var activeElement = false; $$(ul.menu li).invoke(observe, click, function(e){ var element = e.element(); if(activeElement) activeElement.removeClassName(active); element.addClassName(active); activeElement = element; }); }); -- http://positionabsolute.net On May 8, 5:50 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, There are lots of code examples in the resource I pointed you to, particularly the unofficial wiki. For instance, one aspect of what you're trying to do is hook events. That's very thoroughly covered with lots of examples in the API docs[1] and on the wiki[2][3]. So again, have a read through and you'll be well on your way. [1]http://prototypejs.org/api/element/observe [2]http://proto-scripty.wikidot.com/prototype:tip-hooking-events [3]http://proto-scripty.wikidot.com/prototype:how-to-hooking-events Enjoy! -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 8, 9:22 am, z...@zanepaul.com.au z...@zanepaul.com.au wrote: Thanks for your reply, Im very new at this and was hoping more for some code to as a starting point? On May 8, 3:39 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Prototype can definitely help you with that. Off the top of my head, the Prototype methods you want are Element#observe[1] (which is a convenience wrapper for Event.observe[2]) and probably Element#addClassName[3] and Element#removeClassName[4]. [OT (e.g., not Prototype-related) you might want to use === and !== in your comparisons of object instances, rather than == and != (see the ECMAScript spec[5] for more on identity comparisons).] If you're just getting started with Prototype, it's _well_ worth your time having a read through the API[6] from beginning to end. It takes about an hour, and saves you hours and hours in return. The learn[7] page and the unofficial wiki[8] may also be useful. [1]http://prototypejs.org/api/element/observe [2]http://prototypejs.org/api/event/observe [3]http://prototypejs.org/api/element/addClassName [4]http://prototypejs.org/api/element/removeClassName [5]http://www.ecma-international.org/publications/standards/Ecma-262.htm [6]http://prototypejs.org/api [7]http://prototypejs.org/learn [8]http://proto-scripty.wikidot.com HTH! -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 8, 5:53 am, z...@zanepaul.com.au z...@zanepaul.com.au wrote: Im trying to get this code working in FireFox and Sarfari var changeStyleColour = function () { var active = null, newclass = colourActive; if (this.Event.addEventListener) this.Event.addEventListener ('onUnload', function () {active = null;}); return function (element) { if ((active != element) element.className) { if (active) active.className = colourNormal; element.className = newclass; active = element; } }; }(); Can someone please help- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajaxio next step?
Another good one is www.mindmeister.com, I doubt they've got an API for you to work with but maybe you can get some ideas. Its built with Proto/scripty, but they use a canvas object instead of SVG so it could be a bonus for your IE requirement. -- http://positionabsolute.net On May 5, 11:21 am, Gecko sneakyliz...@gmail.com wrote: Thanks James, I had done some research on your demo (I even tried the newest versions of the library scripts) and was hoping you still monitored this group. Ryan thank you for the suggestion. Wireit does seem promising (although it’s current version fails in IE7, they seem to be working on a fix and I will attempt to us their dev version). Amazingly fast response from both of you, thank you very much. On May 5, 9:01 am, Diodeus diod...@gmail.com wrote: I wrote Ajaxio as an exercise to learn how to use Prototype Scriptaulous several years ago. I had it to the point where I could have the drawing as an XML file and reload it from XML data, but I lost the source code. I've had many enquiries from people who have taken it for their own purposes, but I haven't really heard anything back from anyone. I was reworking parts of Walter Zorn's library in order to make the connector lines clickable, but never got that part finished. It was intended more as a demonstration than a step towards a workable product. To tell you the truth, it's kinda crappy and I've learned a lot about JavaScript since then, as I did just building it. I'm glad it gave you some inspiration, but unfortunately Ajaxio is a non-entity. - James. On May 4, 6:30 pm, Gecko sneakyliz...@gmail.com wrote: Anyone ever do anything with or similar to James MacFarlane'shttp://jameslab.moveable.com/ajaxio/demo. It is exactly what I need to work with inside a browser based application using soap web services. The problem is that is it fails in IE7 8 (which are my target users). And yes I am extremely new to javascript so it may be a very simple fix that I am not seeing. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Effect.Appear doesn't work when in queue
In looking at your code, there were a few HTML mistakes. First your try me element doesn't have a proper closing div tag its just /div no greater than to close the tag. You've also does this on your input buttons, input objects are considered simple, meaning they have no children, so having a separate closing tag is bad practice. You have... input type=button onclick=return gotoNewAccount (document.getElementById('newUserTextbox').value); id=newUserSubmitFromHome value=create account/input it should be input type=button onclick=return gotoNewAccount (document.getElementById('newUserTextbox').value); id=newUserSubmitFromHome value=create account/ -- http://positioanbsolute.net On Apr 30, 10:55 pm, alpineedge3 gmarzl...@gmail.com wrote: thanks for the reply. i removed the quotes from the duration but it still does not work. On Apr 26, 12:38 pm, Diodeus diod...@gmail.com wrote: function barcodeFlyToSimLeft(){ new Effect.Move('barcodeLeft',{x: -350, y: 200, mode: 'relative'}); new Effect.Shrink('barcodeLeft',{direction: 'center', queue: 'end', afterFinish: function(){Barcode('043396097742');}}); new Effect.Appear('barcodeLeft',{x: 0, y:0, duration: '1.0', queue: 'end'}); return false; } Duration should be numeric, not a string. On Apr 24, 5:26 pm,alpineedge3gmarzl...@gmail.com wrote: Hi, I'm running an effect chain: move, shrink, then appear. The appear effect doesn't fade in. rather, it just becomes visible with 100% opacity. The scripts are controlling the barcode boxes on the homepage ofwww.fastpricecheck.com. Any help would be appreciated. Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Event.observe
Hey Brent, Do you have a demo page that displays this issue? My only thoughts are that the elements are getting reloaded in the DOM yet not getting the events attached. -- http://positionabsolute.net On Apr 29, 2:59 pm, BrentNicholas brentnicho...@gmail.com wrote: Hi all, So I posted about this before but am still having troubles with Event.observe flaking out on me after a period of time. Here's the situation: The page runs and init's the app with: document.observe(dom:loaded, init); init() fires off: getSelectsForm() As you can see (below) it loads a page and attaches some observers, the page loaded only has three buttons on it (as seen in the Event.observe code). They are not of the same names or id's, but do share the same css class names. Nothing else is loaded. Now if I click any button right away things work just fine (List Page, Add Page). If I wait about 5 minutes (not pressing any buttons first after load) the 'buttonGetProjectsList' will not seem to fire the 'getProjectsList' function as registered through the observer. However the button 'buttonAddProjectForm' will fire off the 'addProject' function. Even if you start using the page right away (everything works), then wait 5 minutes, the list button will not work but the others will. The pages loaded by these button do not have any elements of the same name or id on them that the ''dsp_ProjSelects.cfm' file had. So there should not be any naming conflicts. Any thoughts on this? I've taken the application and stripped in down to just what's needed in a test area and I'm still getting the trouble. function getSelectsForm() { new Ajax.Request('dsp_ProjSelects.cfm?'+cfSession, { method: 'get', onSuccess: loadSelectsForm, onComplete: attachSelectsFormObservers, onFailure: function(r) { throw new Error( r.statusText ); } } ); } function loadSelectsForm(transport) { var htmlBlock = transport.responseText; Element.update(idSelectsDIV,htmlBlock); Form.focusFirstElement('SELECT_FORM'); } function attachSelectsFormObservers() { Event.observe('buttonGetProjectsList','click', getProjectsList, false); Event.observe('buttonAddProjectForm','click', addProject, false); Event.observe('buttonClearForm','click', clearSelectsForm, false); } Also, environment: Win XP (all patches) IE 6.0.2900.2180.xpsp.080413-2111 Thanks for your time and effort. Brent --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: pimp my snippet?
Just to have fun with it... var val = $F(file); if(val.lastIndexOf( ) val.lastIndexOf(/)) On Apr 29, 2:52 pm, Walter Lee Davis wa...@wdstudio.com wrote: Aha, but what about spaces in folders leading up to that filename? I don't mind those, since I only end up with the file, not the entire local path. Which was why I did the split + last() trick. A file field reports its value to JavaScript as the entire root-relative path to the file on the user's computer in some browsers (Safari for sure). Walter On Apr 29, 2009, at 1:53 PM, Diodeus wrote: if($F(file).indexOf( )) { alert('darnammit, no spaces Wilbur!') } On Apr 29, 1:29 pm, Walter Lee Davis wa...@wdstudio.com wrote: Trying to keep people from uploading files with spaces in their filenames: //inside a change event observer on the field if($F(file) $F(file).split(/(\/|\\ \)/).last().include( )) ... //warning here Can anyone suggest a more elegant route? Thanks, Walter --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Extracting methods from codebase
I'd set up each class or major structure, such as Element, Enumerable, etc etc as its own file, then define packages such as minimal, efficient, advanced, ajax...etc. Then in a server side script it will bundle these files together depending on the package so you could make a request something like prototype-package.php?package=advanced and it will pull only files that you have set up as the advanced package. I find that lazy loading either leads to lost dependencies or in most cases leads to more overhead than if you had just loaded it all in one request. When using the packaging server side script you can also use tactics of minify and gzipping to reduce the payload. -- http://positionabsolute.net On Apr 29, 12:46 pm, Bertrand bertrand.char...@gmail.com wrote: Hi, My code makes use of Element's update method. It handles modification of an element's contents gracefully and isn't as risky as innerHTML. My problem is that I don't know how to extract it from the code (I wish I could link to Google's Prototype, but I work in an environment where filesize is critical). The issue at hand is that the method makes use of other bits (bind, defer, stripScripts, $A, etc.) from the library that would in turn pull other bits and so forth. My question is : Is there a way to smartly cherry-pick the bits I need from the source code without breaking anything. My previous attempts at doing just that were utter failures and reverting back to innerHTML is ground for disaster as well. Any help appreciated. Thanks, Bertrand. PS: A solution would be to have some sort of preprocessor directives like //@dependsOn: defer, bind, $A... for each method so that a script could create custom builds of the library that would fit the user's needs perfectly (one could even imagine a web interface where the user would indicate the functions he wants to use, hit generate to obtain a custom version of Prototype). Sprockets seems to be a step in that direction but it's not fine- grained enough in my opinion. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: HTML breaks JSON
What are you sending to PHP's json_encode? It is expecting a structure to serialize into a JSON syntax string. $struct = array(message = h1Hello World/h1Who says we can't have any kind of \quotes\ we want?); echo json_encode($struct); If you try to run json_encode on your already JSONified string, yeah its going to cause problems... -- http://positionabsolute.net On Apr 24, 12:26 pm, T.J. Crowder t...@crowdersoftware.com wrote: @Ananth: Converting to Base64 would be massive overkill, surely. @OP: There's no reason you can't include strings containing HTML in JSON data. You just have to make sure your strings are valid string literals, like this: { message: pThis is HTML./p } There's nothing special other than making sure the HTML is correctly escaped -- e.g., if you're putting the JSON string in double quotes, naturally any double quotes in the HTML will need a backslash in front of them -- as, for that matter, will any backslashes! HTH, -- T.J. Crowder tj / crowder software / com On Apr 24, 5:05 pm, Ananth Raghuraman araghuram...@gmail.com wrote: JSON should not contain HTML for tactical/ease of programming purposes unless the HTML is there as part of a larger design, but there may or may not be implementation restrictions. If you are facing problems, can you try encoding the HTML string (Base64) and decoding back (using Javascript Base64 code ) before display on the browser? On Fri, Apr 24, 2009 at 11:30 AM, Matt guitarroman...@gmail.com wrote: Hi there, I'm using PHP to output some JSON through AJAX to my page. It breaks whenever I use a backslash or quote mark. I've tried using php's json_encode function which doesn't seem to help, just breaks it further. I've also tried php's addslashes() to the output, again, same problem. Am I approaching this correctly, fundamentally? Is JSON supposed to contain HTML? Thanks, Matt --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Observe div content change?
Anath's idea would be ideal but I am not sure how supported that event actually is. Alternatively, it'd be a bit more work but still would satisfy your event requisite of just firing off you own event when you update. var oldHTML = ele.innerHTML; ele.update(text); ele.fire(x:update, { oldHTML : oldHTML }); http://prototypejs.org/api/element/fire -- http://positionabsolute.net On Apr 22, 10:33 am, Ananth Raghuraman araghuram...@gmail.com wrote: $(your element id).observe(DOMCharacterDataChanged,function(evt){ //your code here }); Try above Check the Event.Observe documentation on prototype api documentation website. This website gives you a link to DOM 2 Events list. Check the Mutation Events section. On Wed, Apr 22, 2009 at 7:02 AM, Yozefff yoze...@gmail.com wrote: Is it possible to observe when the content of a DIV is changed? So for example, I update the innerHTML (ajax perhaps?) and some JS class is listening when the content is changed. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: I am not getting value from backend page
Ooo to be honest, that is quite ugly Amlan... Having a ton of code written to an inline handler is just bad form, it would be much better to just delegate to an event handler, and even better yet, hook into this event via Event.observe... $(category).observe(change, handleChange); You'll have a much easier time debugging via this approach. -- http://positionabsolute.net On Apr 20, 9:16 am, Amlanam...@enduetechnologies.com amlan.h...@gmail.com wrote: I am using prototype.js for category and subcategy dropdown. On selecting category corrsesponding subcategories will be shown in another dropdown. script type=text/javascript src=js/prototype.js/script select name=category style=width:180px; onchange=new Ajax.Updater('subcc', 'subCat.php?id=' + this [this.selectedIndex].value, {asynchronous:true, evalScripts:true}); option value=/option option value=/option -- /select span id=subcc select name=subCategory id=subCategory style=width: 180px; option value=Select Category/option /select/span --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Internet Explorer 8 and new Element
class and super are reserved words that we actually never use, but think of them as words like _if_ or _case_ Use className as the appropriate property for setting the HTML attribute of class, a bit hoaky but that is just the way it is, with or w/o prototype... http://www.webreference.com/javascript/reference/core_ref/keywords.html --- http://positionabsolute.net On Apr 20, 7:29 am, butz adrian.chris...@halbehalbe.ch wrote: I can confirm this also, using : IE 8.0.6001.*, 128-Bit As a workaround I used: var myDiv = new Element('div'); myDiv.addClassName('myCssClass'); On 23 Feb., 11:20, Cyrus arianglan...@googlemail.com wrote: Hi, I am testing the latest IE8 version and found an error in prototype. Creating anelementwithnewElementand assigning inline a class, it is not working. ?xml version=1.0 encoding=UTF-8? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/ TR/xhtml11/DTD/xhtml11.dtd html xmlns=http://www.w3.org/1999/xhtml; dir=ltr xml:lang=de head meta http-equiv=content-type content=text/html; charset=UTF-8 / titleTest/title style type=text/css .red { background: red; } .green { background: green; } } /style script src=http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/ prototype.js/script script src=http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/ scriptaculous.js/script script //![CDATA[ document.observe(dom:loaded, function() { var red =newElement('div', { 'id' : 'red' }).update('red').addClassName('red'); $$('body')[0].insert(red); var green =newElement('div', { 'id' : 'green', 'class' : 'green' }).update('green'); $$('body')[0].insert(green); }); //]] /script /head body /body /html There should be two lines a red and a green one. The green class is not taken. Checking the html output with the IE8 dev tool it gets me: div id=red class=.redred/div div id=green className=.greengreen/div Can someone confirm this? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Aborting an ajax request
I don't really understand the logic, You have multiple forms on a particular state in your ajax application. If the user takes action to change this state you want to prompt them with the confirm window of Changes have been made, are you sure you want to discard? If they click yes- i want to discard, then simply don't send the ajax request in the first place. Otherwise, if you send it, then ask them if you'd rather discard you're just making things more difficult. -- http://positionabsolute.net On Apr 16, 9:18 am, Andrea Raimondi andrea.raimo...@gmail.com wrote: On Apr 16, 2:27 pm, Justin justin.gir...@gmail.com wrote: Can you not just turn off the submission of ajax requests when the confirm dialog appears? I'm not sure I understand what you mean. Plus, there's a problem I thought of only after having posted this: when I show a form, I also have the inherent data save AJAX.Request/ Updater. This poses a constraint i.e. I have to abort all except the one I need and this is not achievable using global responders(because I can't tell beforehand which is the correct one to except for). function showDialog() { if no active requests { show dialog() turn off ajax requests() return true } return false } Maybe I wasn't clear enough, it should be the other way around: function showDialog() { if not confirm { abort ajax request() return true } return false } Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: async ajax requests and timeouts delimma
Yeah I'd say thats a pretty good approach, if you've got 8 active requests then the timeout duration of the 9th should be affected by the number of currently active predecessors. I'd do something in the onCreate method to just set the instance's timeout universally instead of trying to micromanage each. onCreate : function(request){ request.options.requestTimeout = Ajax.activeRequestCount * SOME_CONSTANT; } I've also done some work with enhancing prototype's Ajax.Request to accommodate for timeout functionality, have a peak at your convenience. http://positionabsolute.net/blog/2008/07/prototype-ajax-request-timeout.php On Apr 15, 3:13 pm, Maarten maartenwie...@gmail.com wrote: Hi mona, I don't mean this in a negative way, but what exactly are you doing? Just out of curiousity. Other than that, have you tried passing the Ajax requests into different objects? Maarten --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: script requires much resources : ´-(
After reviewing the behavior of the control I'd say it reinforces the idea that you should just set it up in a scrolling div and modify the scroll property, this would approach would alleviate much of the intense processing. You could leverage the Effect.Tween[1] method to handle most of the animation processing. [1] http://wiki.github.com/madrobby/scriptaculous/effecttween Oh and a +1 on the content of that film strip, wish my work was half that interesting... --- http://positionabsolute.net On Mar 19, 11:26 am, eulerss eulers...@hotmail.com wrote: i was checking your page, and in FF works great, but in IE it doesnt work, very slow like you said, the page freezes the browser, i checked your page on 03-19-09 at 9:25 am XD On 19 mar, 03:58, XyXEL derblaueor...@googlemail.com wrote: well, that is the website i madehttp://pp-media-shop.com/joomla/index.php?option=com_contenttask=blo... it works quite fine in firefox, but in IE6 and IE7 it causes heavy lags and freezes the browser for short time.- Ocultar texto de la cita - - Mostrar texto de la cita - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Stopping events ..
Very strange but I'll take your word on it. Although I can't say I understand why the object wouldn't throw its submit event after executing the submit method. If another method, one that isn't handling the event called the submit method, would it be caught by the submit listener? -- http://positionabsolute.net On Mar 19, 12:03 pm, Marko Zabcic gm.ma...@gmail.com wrote: You can also do this: $('foo').observe('submit',function(evt){ evt.stop(); //shorter way console.log('bar'); this.submit(); }); On Mar 18, 11:45 pm, Alex Mcauley webmas...@thecarmarketplace.com wrote: There is no exception or error thrown in firebug !! I went round it with an inline call instead ! Thanks for help guys Alex - Original Message - From: Matt Foster mattfoste...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, March 18, 2009 8:26 PM Subject: [Proto-Scripty] Re: Stopping events .. Event.stop(e) does indeed prevent event propagation. I would assume that your code is hitting an exception before Event.stop is being executed. Try calling Event.stop() at the very beginning of the script, before anything else, then if there are no errors, call event.form.submit() to carry on with the original submit event. @Walter: If you have a submit handler that executes the object's submit event wouldn't this lead to an infinite loop? Wouldn't the idea be, catch the submit event, validate the fields, if all is valid, allow the event to proceed, if its not then stop the event. function handleLoad(){ $(myForm).observe(submit, function(e){ var invalidArr = $(myForm).select(input.req, textarea.req, select.req).findAll(function(element){ return element.value != }); if(invalidArr.length 0){ e.stop(); //prototype 1.6 code to event stop. handleInvalids(invalidArr ) } }); } Event.observe(window, load, handleLoad); -- http://positionabsolute.net On Mar 18, 11:59 am, Walter Lee Davis wa...@wdstudio.com wrote: Try calling Event.stop() at the very beginning of the script, before anything else, then if there are no errors, call event.form.submit() to carry on with the original submit event. Walter On Mar 18, 2009, at 11:45 AM, Alex Mcauley wrote: It still does not work with Event.stop(event); for some reason i even tried changing the code to . var error=''; $$('.req').each(function(e) { if($(e).value=='') { error+='Required'; } }); if(error.length=1) { alert(error) Event.stop(event); // does not work } - Original Message - From: Alex Mcauley webmas...@thecarmarketplace.com To: prototype-scriptaculous@googlegroups.com Sent: Wednesday, March 18, 2009 3:42 PM Subject: [Proto-Scripty] Re: Stopping events .. Doh !! i knew it was something simple !! Thanks Alex - Original Message - From: Walter Lee Davis wa...@wdstudio.com To: prototype-scriptaculous@googlegroups.com Sent: Wednesday, March 18, 2009 3:11 PM Subject: [Proto-Scripty] Re: Stopping events .. Has to be capital E event: Event.stop(event) Walter On Mar 18, 2009, at 10:40 AM, Jeztah wrote: event.stop(event); // doesnt stop the request from firing --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Updater home-brew autocompletion timing issue
I've got to add my two cents as well, For addressing the issue of attaching parameters to the Ajax.Request object, they're actually available in the callbacks. Each callback gets sent an Ajax.Response instance which contains the request property which in turn has the parameters property, http://prototypejs.org/api/ajax/response To address the wrong order issue, you could create a queue of requests such that each request is asynchronous but stacked such that it will not be sent until the previous request has returned. I've written something for this for prototype 1.5 as Ajax.RequestQueue and formalized this idea in my AgileAjax package in the class AjaxService. http://positionabsolute.net/blog/2007/04/ajax-request-queue.php http://positionabsolute.net/blog/2009/03/agile-ajax.php On Mar 19, 2:34 pm, Jonny Nott jonn...@gmail.com wrote: I've now found a solution to this problem, as follows: var inputControlCapturedValue = inputControl.getValue(); new Ajax.Request(xhrRequestUrl, { method: 'get', parameters: { table: s_table, column_name: s_columnName, category: categorySelect.getValue(), match: inputControl.getValue(), action: 'selectgenericforeign' }, onCreate: targetSelect.disable.bind(targetSelect), onSuccess: (function(transport){ if (inputControlCapturedValue == inputControl.getValue()) { targetSelect.update(transport.responseText); targetSelect.enable(); } }).bind(targetSelect) }); The solution arrived at is seperating the Ajax.Request and Element.update calls rather than using Ajax.Updater. The onSuccess callback function then checks that the input box's value hasn't changed since the request was initiated. If it has changed, it won't bother updating the select box with its response HTML. Thanks all for help and pointers. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Stylesheet issue with inserted elements
Were the injected stylesheets being loaded, did you check it with firebug? Also with firebug you should inspect the control's elements and see if they're inheriting these properties and or if any of them are being overridden by another selector. IE and FF have major differences with links/hrefs such that I am guessing there in lies your issue. Its nice to have stylesheets loaded seperately b/c of modularity and relative paths from the sheet itself, but you could look into packaging them via server side and outputting them as one, this approach does save downloading time and could in your instance solve the issue of the sheets not presenting themselves. -- http://positionabsolute.net On Mar 19, 3:25 pm, Walter Lee Davis wa...@wdstudio.com wrote: I am using Ryan Johnson's excellent Control.Textarea toolbar widget on a site. Since this site is quite dynamic, automatically assembling forms around the database columns and their types, I am using $$ ('textarea') to find any textareas, then Element.wrap to wrap them in a div (for layout reasons with the Control) and then attaching the Control to the textarea. My basic code looks like this: $$('textarea').each(function(elm){ var wrap = Element.wrap(elm,'div',{'class':'wrap'}); wrap.clonePosition(elm,{setHeight:false}); wrap.setStyle({border:'none',padding:0}); elm.setStyle({width:'100%'}); new Control.TextArea.ToolBar.Markdown(elm); }); This works perfectly, except when it comes to the styles. In a further bid to modularity, I put all of the Control-specific stuff in a separate sheet, and included that in the head of the page. But it didn't seem to work in either Safari or Firefox. Xyle scope went a little further, and actually showed the elements as having the properties they were supposed to have, but they just didn't look like they should. (The toolbar is a styled UL, with background images to make the buttons look nice.) It showed on screen in all three browsers as a plain unstyled UL would. On a whim, I put all of the styles from the Control stylesheet into my main stylesheet and removed the link to the Control stylesheet. With just that change -- going from two stylesheets to one -- everything started working. Both stylesheets were valid CSS, the page was valid XHTML Strict. Has anyone seen anything like this before? Thanks, Walter --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: script requires much resources : ´-(
You should rely more on the Effect.Morph to handle the animations and less on your own setTimeout calls, I think its compounding multiple timeout calls and morph effects which run their own intervals to manage the effect. Try getting the effect to run with one call to Effect.Morph. -- http://positionabsolute.net On Mar 18, 12:01 pm, XyXEL derblaueor...@googlemail.com wrote: Hello, i made a script, that slides pictures threw a div-element. well, the performance just sucks, but i dont have any flash-knowledge, so i had to code it in javascript. it works quite fine in FF, but in IE6 and IE7 it freezes the browser often. can anyone help me please :-) ? i pasted the code herehttp://pastie.org/419852 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Stopping events ..
Event.stop(e) does indeed prevent event propagation. I would assume that your code is hitting an exception before Event.stop is being executed. Try calling Event.stop() at the very beginning of the script, before anything else, then if there are no errors, call event.form.submit() to carry on with the original submit event. @Walter: If you have a submit handler that executes the object's submit event wouldn't this lead to an infinite loop? Wouldn't the idea be, catch the submit event, validate the fields, if all is valid, allow the event to proceed, if its not then stop the event. function handleLoad(){ $(myForm).observe(submit, function(e){ var invalidArr = $(myForm).select(input.req, textarea.req, select.req).findAll(function(element){ return element.value != }); if(invalidArr.length 0){ e.stop(); //prototype 1.6 code to event stop. handleInvalids(invalidArr ) } }); } Event.observe(window, load, handleLoad); -- http://positionabsolute.net On Mar 18, 11:59 am, Walter Lee Davis wa...@wdstudio.com wrote: Try calling Event.stop() at the very beginning of the script, before anything else, then if there are no errors, call event.form.submit() to carry on with the original submit event. Walter On Mar 18, 2009, at 11:45 AM, Alex Mcauley wrote: It still does not work with Event.stop(event); for some reason i even tried changing the code to . var error=''; $$('.req').each(function(e) { if($(e).value=='') { error+='Required'; } }); if(error.length=1) { alert(error) Event.stop(event); // does not work } - Original Message - From: Alex Mcauley webmas...@thecarmarketplace.com To: prototype-scriptaculous@googlegroups.com Sent: Wednesday, March 18, 2009 3:42 PM Subject: [Proto-Scripty] Re: Stopping events .. Doh !! i knew it was something simple !! Thanks Alex - Original Message - From: Walter Lee Davis wa...@wdstudio.com To: prototype-scriptaculous@googlegroups.com Sent: Wednesday, March 18, 2009 3:11 PM Subject: [Proto-Scripty] Re: Stopping events .. Has to be capital E event: Event.stop(event) Walter On Mar 18, 2009, at 10:40 AM, Jeztah wrote: event.stop(event); // doesnt stop the request from firing --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: script requires much resources : ´-(
Hmm maybe I am not understanding what you're interface is trying to accomplish... If you've got a strip of images that you want to scroll across based on mouse movements, why don't you just wrap them in a div with an overflow and modify the scrollLeft property of the div to modify the display. You can hide the scroll bar with a sibling that sits below with a negative margin. A link to a working example would be great. On Mar 18, 4:08 pm, XyXEL derblaueor...@googlemail.com wrote: well, with effekt.morph calling only once i may move all pictures in one call, but i can not stop it. if some1 moves the mouse on the div it should stop running, so that he can watch the picture as long as he want to. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prevent iframe / break-away
$(ifr).observe(beforeunload, Event.stop); Give it a whirl, I have no idea if that will work; --- http://positionabsolute.net On Mar 18, 5:27 am, Vladimir Tkach tea...@gmail.com wrote: try to use beforeunload event 2009/3/18 Karlson azagnio...@gmail.com Hi, I am trying to prevent iframe breakout. This is how i attempted to do it in head section of my HTML document: function windowUnload(evt) { evt.stop(); } Event.observe(window, 'unload', windowUnload); $('ifr').observe('unload', windowUnload); //Event.observe(window, 'unload', function(event) { // Event.stop(event); //}); 'ifr - the id of my iframe. My code does not work. Is it possible at all with prototype? What am i doing wrong, can some one give me some feedback? Regards, Karlson -- Best Regards, Vladimir Tkach +972-54-7574166 tea...@gmail.com http://teamco-anthill.blogspot.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-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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prevent iframe / break-away
Looking further into this issue has revealed, that you can't actually stop a page from unloading, as this would allow malicious sites to trap a user indefinitely. Listening for the beforeunload event on the top window prompts a confirmation window saying you're about to navigate away, continue or cancel. You can also do some extra processing in the event handler but the handler can't prevent the unload. If the user clicks cancel then you're able to keep these framebuster pages in their frames. Otherwise the user is redirected. --- http://positionabsolute.net On Mar 18, 4:58 pm, Matt Foster mattfoste...@gmail.com wrote: $(ifr).observe(beforeunload, Event.stop); Give it a whirl, I have no idea if that will work; --- http://positionabsolute.net On Mar 18, 5:27 am, Vladimir Tkach tea...@gmail.com wrote: try to use beforeunload event 2009/3/18 Karlson azagnio...@gmail.com Hi, I am trying to prevent iframe breakout. This is how i attempted to do it in head section of my HTML document: function windowUnload(evt) { evt.stop(); } Event.observe(window, 'unload', windowUnload); $('ifr').observe('unload', windowUnload); //Event.observe(window, 'unload', function(event) { // Event.stop(event); //}); 'ifr - the id of my iframe. My code does not work. Is it possible at all with prototype? What am i doing wrong, can some one give me some feedback? Regards, Karlson -- Best Regards, Vladimir Tkach +972-54-7574166 tea...@gmail.com http://teamco-anthill.blogspot.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-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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prototype.js / jQuery conflict
This is completely theoretical, and probably even more ludicrous as I think of it being plausible cross-browser... But in theory if you did something like this var A = function(){ alert(First definition);} A(); var A = function(){ alert(Second definition); }; A(); Would behave as such, so that you could load jquery and all dependent scripts first, then load prototype and all of its dependent scripts subsequent to that and get away with it? Give it a shot and let us know... On Feb 6, 2:22 pm, david david.brill...@gmail.com wrote: Hi dizzyjay, the noConflict function works great, but the problem I think is that you rename the jquery object, so all other developper will have to change there scripts to no use anymore the $ function (by defaul $==jquery). some times ago, a protosafe library was developped, but it has stopped so I'm not sure there is a way to resolve your problem. -- david On 6 fév, 00:48, dizzyjay dizzy...@gmail.com wrote: Is there a way to resolve this conflict within prototype? My portal uses jQuery and I'm the only developer with a preference of prototype.js. I've tried the jQuery.noConflict() with no luck. I don't want to abandon my prototype.js skillset for jQuery but it's looking like I'm the one that needs to find the workaround if I want to continue with prototype.js (NOTE: I've also tried the find/replace '$' with '_$' method didn't work- broke a good amount of functionality) thanks in advance dj --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Having trouble with .without().
It appears as though without accepts its values in individual parameters. Looking at the documentation it does illustrate that each value is set in as its own parameter. http://prototypejs.org/api/array/without Looking into the source it becomes clear that it uses the function's arguments as array to purge values from, not the first argument as an array. A snippet from proto 1.6... without: function() { var values = $A(arguments); return this.select(function(value) { return !values.include(value); }); }, I'm pretty sure proto's CSS parser can handle the not pseudo selector, so you can do something like this... $$(s_CSS + :not(.nonSpacing)); http://www.w3.org/TR/css3-selectors/#negation -- http://positionabsolute.net On Jan 22, 12:27 pm, Richard Quadling rquadl...@googlemail.com wrote: Hi. s_CSS = '.scrollBox label'; console.info($$(s_CSS)); console.info($$(s_CSS + '.nonSpacing')); console.info($$(s_CSS).without($$(s_CSS + '.nonSpacing'))); [label.nonSpacing, label, label.nonSpacing, label, label, label, label, label.nonSpacing, label, label, label, label, label.nonSpacing, label, label, label, label, label.nonSpacing, label, label, label, label, label.nonSpacing, label, label, label, label, label.short, label, label, label] [label.nonSpacing, label.nonSpacing, label.nonSpacing, label.nonSpacing, label.nonSpacing, label.nonSpacing, label.short] [label.nonSpacing, label, label.nonSpacing, label, label, label, label, label.nonSpacing, label, label, label, label, label.nonSpacing, label, label, label, label, label.nonSpacing, label, label, label, label, label.nonSpacing, label, label, label, label, label.short, label, label, label] The first info shows me all the labels in the .scrollBox. The second info shows me all the labels in the scrollBox which are nonSpacing. The third info shows me the same as the first. The .without is NOT working as I would expect. Any ideas? Richard. -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Problem with double click
If you're traversing a collection of elements, then the first parameter in your findAll method is going to be an element. Bind is a property of a Function, not an Element, so that it would be failing on this attempt of execution. http://prototypejs.org/api/function/bind -- http://positionabsolute.net On Jan 9, 8:40 am, Walter Lee Davis wa...@wdstudio.com wrote: On Jan 9, 2009, at 6:56 AM, Othon Reyes wrote: Object doesn't support this property or method in line 651 of prototype.js This particular error usually means that the object in question has not yet been extended by Prototype. Try wrapping the reference to it in the dollar function before you attack it with any of the Prototype functions. If you're referring to it as foo in your script, do this in the first line or so: var foo = $(foo); Walter --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Updated DIV seems to still have the same innerHTML...
You can pass it an element reference, however your reference of this isn't an element. It may have assumed element methods via Object.extend in your constructor but the reference is still to a function, not a DOM reference. -- http://positionabsolute.net On Jan 8, 12:04 pm, Ian R i...@fairmountfair.com wrote: On Jan 8, 4:09 am, SGD danny.g...@googlemail.com wrote: Try new Ajax.Updater(this.id, as you have to pass the id of an element, not the element itself. Oh! I thought you could pass either the ID or an element reference... in fact, the code seems to work either way, so maybe that's true. You can optimize your code by just having: $$('[contenteditable=true]').each(function(el) { new Ajax.Updater(el.id,'loader.php',{parameters: {field: el.id}, onComplete: function(){ alert('check #2: ' + el.innerHTML); } }); }); This works really well, and thank you, but I have a need to call this function in multiple places (like, both on page load and on a button click, and maybe some other places)... which is not a problem, I've taken the meat of it out and placed it in a function called load(el), and I'm calling that function in this loop and I can call it elsewhere, and I can continue from here in this realm. However, what I *thought* I was trying to do was develop my editfield as an object, add the appropriate properties and methods and things, and then call these functions as el.load() rather than load (el). I suppose there is not a ton of benefit from this, other than to increase my fluency with OOP and to allow for subclassing and method overriding. I would really like to know more about this, though, and in particular how one can take existing HTML (like my DIVs) and apply such an object to it... the example that I keep coming back to is how one can take an existing UL and say: Sortable.create(el); And then that UL has methods and properties of a Sortable. HOWEVER: I would like to have an instance which I can call in events. Once again, I have talked myself dizzy and I'm not quite sure what I'm saying anymore. If any of this makes sense, I would love to be directed to some sort of document that I could read on the subject, or if anyone could advise me on a decent search string, I have been looking this up but I am not 100% sure I'm using the correct terms. Thanks so much! I am very excited about Prototype! I didn't realize how much I liked it until I started messing around with Dojo. Prototype makes a lot more sense to me, personally. Ian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Custom Property on TextNode
Hey Everyone, I'm working on a project that swaps out text nodes. I need to save a reference to the new text node with the existing node. In FF I am able to set custom properties no problem, IE however throws an error of Object does not support this property or method. I was thinking I could use a hash object and the text nodes node value property as the key, and the new node as the value but this seems incredibly sloppy, especially as its a hack for IE only. Anyone know how I can get around it this error? Here is a snippet http://pastie.org/353010 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: IE and Element#up
Its because FF allows for native prototype extension and IE does not, such that any referenced element won't have proto's element extension methods until its been explicitly extended. a href=# onclick=$(this).up('.bla').remove()Back/a But to be honest I wouldn't use that style of event listener, try something like this... $$(.bla a).invoke(observe, click, function(e){ e.element().up(.bla).remove(); }); -- http://positionabsolute.net On Jan 1, 5:43 pm, joris77 joriswijl...@gmail.com wrote: Hi, This works in firefox but it doesn't in internet explorer 7 is this an issue or am I missing something? html head script src=prototype.js type=text/javascript/script /head body div class=bla a href=# onclick=this.up('.bla').remove()Back/a /div /body /html Thanks anyway --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: How to change contentType.
Browser is opening save dialog and saveing the response into an .xls file. So your scripts are writing to the clients machine? Is the data being received over an XHR request? It wouldn't be the most fluid progress bar, but if it was an XHR you could increment a progress bar each time it moves to the next ready state.\ If you need something really smooth and if the download times are in excess of 15 seconds or more I'd highly recommend looking into a flash solution. Flash has much better capabilities to monitor HTTP progress. -- http://positionabsolute.net On Jan 2, 4:23 am, Naganirangen Ravilla moonon...@gmail.com wrote: Thanks for your response. No issues at serverside contentType.Response contenttype is application/xls. Browser is opening save dialog and saveing the response into an .xls file. My requirement is while downloading data ,browser showd show loading or downloading message till download will get finished. any idea to show this message using prototype. Thanks, Naga. On Wed, Dec 31, 2008 at 10:35 PM, T.J. Crowder t...@crowdersoftware.comwrote: Hi, I don't quite understand, from your subject line How to change contentType, it sounds like you want to know how to set the content type of the response, but your message talks about doing something with a Loading... message. Can you clarify? (OT: To set the content type of the returned data, in your JSP you want to use the setContentType method of the ServletResponse.[1] So if that was the question, that's the answer, but it's a Java EE thing serverside rather than a Prototype thing client-side.) [1] http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletResponse.h...) Sorry if I'm being dense, I just got up. :-) HTH, -- T.J. Crowder tj / crowder software / com On Dec 31, 2:36 pm, Naganirangen moonon...@gmail.com wrote: Hi, I'm new user to use this prototype API.Below is my requirement. I'm exporting content from jsp to excel,using setcontentType application/xls of httpresponse. When it is downloading ,browser should show Loading message. I don't know how to handle this using prototype. Can any one suggest me how to do it ? Your help is highly appreciated. Thanks, Naga. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Build an organization chart with prototype scriptaculous
You could use a canvas element or SVG elements. https://developer.mozilla.org/en/Drawing_Graphics_with_Canvas https://developer.mozilla.org/en/SVG Prototype doesn't have much support for either of these options but they're viable and you could use event listener/dom traversal with the SVG solution. If you don't mind spending the cash on a license, you could go for Flex, they have a very nice Chart API. -- http://positionabsolute.net On Dec 31 2008, 12:02 pm, E. Nadir elasri.na...@gmail.com wrote: Hello, Is there a script to draw organization chart in prototype scriptaculous ? thanks :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---