[Proto-Scripty] Re: Avoiding bubbleling
Yeah I had that problem also (http://www.partygek.nl .. see the carousel). What I did was something like this div id='container1' div id='logo'/div /div I put a mouseover and mouseout on container1. on mouseover and mouseout I check the fire element is a decended of container1 OR is container 1 ... if not, it's outside container1 ;-) On Jan 25, 6:34 pm, Geoffroy Gomet geoffroy.go...@gmail.com wrote: Thanks a lot TJ, I was beginning to think in that direction. This should solve my problem. Once more, thank you for the quick response. Geoffroy On Jan 25, 6:14 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, On the mouseover bit, the problem isn't really the bubbling, since you'd also get that same behavior if the mouse were hovering over any part of the logo div -- over some padding, for instance -- since mouseover fires over and over again at the slightest change in mouse position. Really what you want to do is track whether the logo is already dimmed and only trigger the effect if not. Just set the flag when you first dim the logo, then don't dim it again. (You can't use Element#visible because if you ask when the effect is still running, that will come back true.) The flag could even be whether the mouseover handler is attached -- detach it when you dim the logo, reattach it when you un-dim it. I haven't used mouseout enough to be able to help, really, but some thoughts/observations: * Will mouseout reliably fire on logo when logo is invisible, on all of your target browsers? * To know whether you're getting a mouseout from 'logo' itself as opposed to the image within it, you can use Event#findElement: var src; src = event.findElement(); if (src src.id == 'logo') { // It's the logo itself, undim it } * You'll want to Test This Like Crazy on a wide variety of browsers. * If you search around, you may find implementations that emulate the mouseenter and mouseleave events on browsers that don't natively support them. I'm pretty sure that mouseenter and mouseleave are what you want for the above, but browser support for them varies. HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jan 25, 3:15 pm, Geoffroy Gomet geoffroy.go...@gmail.com wrote: Here is an example of what I want to do: ... div class='center_part' div id='logo'%=image_tag '/images/logo.png'%/div div id='description'lorem ipsum/div /div ... $('logo').observe('mouseover', function(event){ new Effect.Opacity('logo', { from: 1.0, to: 0.0, duration: 0.3 }); }); $('logo').observe('mouseout', function(event){ new Effect.Opacity('logo', { from: 0.0, to: 1.0, duration: 0.3 }); }); So, I would like to avoid that hovering (mouseover) the img inside the div#logo bubble up and trigger the event once more and ruin the effect of hiding the logo. Already thanks for the quick answer. Geoffroy Gomet --~--~-~--~~~---~--~~ 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: Draggable and Droppable - Update Database (Very Close!)
On Jan 25, 5:41 pm, KaR kylere...@gmail.com wrote: Hi, I actually figured it out, there were a couple of errors in my syntax. However, I do have one question regarding adding multiple Droppables. Is there any easy way to just declare all the droppables in one line of code? For example, I have five DIVs that are my droppables. They all have an ID, eg., 1, 2, 3, 4, 5. Right now, I have: Droppables.add( '1', {hoverclass: 'hoverActive', onDrop: moveItem}); $ ('1').cleared = true;} How would I declare all of the droppables (1, 2, 3, 4, and 5)? ['1', '2', '3', '4', '5'].each(function (id) {Droppables.add(id, { ... })}); But note that '1' etc. are not valid IDs in HTML: ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (-), underscores (_), colons (:), and periods (.). [http:// www.w3.org/TR/html401/types.html#h-6.2] Colin Fine --~--~-~--~~~---~--~~ 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: Form.request() ... Which submit button did the user press?
On the presumption that you're submitting from a button's click observer, you can use Event#element() to determine which element was clicked. Also, rather than using input type=submit .../ i typically use input type=button .../ to prevent the form from trying to unload the page as a form submission. -joe t. On Jan 25, 5:32 pm, Matt mattal...@gmail.com wrote: Is there any way of knowing which submit button was pressed from the post passed by Form.request()? I'm just getting the first submit button in the form, no matter which one I press. --~--~-~--~~~---~--~~ 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: document.viewport.getDimensions
JFYI - Upgrade from 1.6.0.1 to 1.6.0.3 solved the issue. On Jan 24, 10:28 pm, Alex K klizhen...@gmail.com wrote: Ok, here you are: //inside some class... this.on_resize_ = this.on_resize.bindAsEventListener(this); Event.observe(window,'resize',this.on_resize_); on_resize: function(e){ var d = document.viewport.getDimensions(); $('header').innerHTML = ' width: '+d.width+' height: '+d.height; } //FF 3.0.5 gives me width: 1024 height: 542 //Seamonkey 1.1.2 width: 1022 height: 555 //Opera 9.63 gives me width: 1007 height: 372 and does not react on resizes properly. 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: Possible incompatibility with JSON library?
Jerod, On Jan 25, 8:34 pm, Jerod Venema jven...@gmail.com wrote: Not sure about the bug, but is there a reason you can't use the prototype JSON methods? I've got a workaround in place, but I'm working on an app that doesn't normally depend on Prototype.js, but breaks when it's there. There are other components that do depend on Prototype, so it needs to be there. Aside from that, I've lost count of all of the libraries and browsers that include a copy of json2.js. It's pretty common, so I thought if this actually could be a problem it would be worth looking at. Thanks, Nathan --~--~-~--~~~---~--~~ 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: Possible incompatibility with JSON library?
2009/1/26 nlloyds nllo...@gmail.com: Jerod, On Jan 25, 8:34 pm, Jerod Venema jven...@gmail.com wrote: Not sure about the bug, but is there a reason you can't use the prototype JSON methods? I've got a workaround in place, but I'm working on an app that doesn't normally depend on Prototype.js, but breaks when it's there. There are other components that do depend on Prototype, so it needs to be there. Aside from that, I've lost count of all of the libraries and browsers that include a copy of json2.js. It's pretty common, so I thought if this actually could be a problem it would be worth looking at. Thanks, Nathan What happens if you load prototype first? -- - 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] Problems with XML in IE 7
I am loading some XML: new Ajax.Request(this.options.url, { method: 'post', parameters: 'r=hlf=' + $F(this.textbox), onSuccess:function(transport) { thisObject.data = transport.responseXML; alert(thisObject.data.getElementsByTagName ('Locations')[0].childNodes.length); } }); In Firefox I am getting a good result on the alert, in IE it returns zero. When I am loading the responseText from transport into Xmldoc it retruns a good result: // testing result for IE xmlDoc = new ActiveXObject(Microsoft.XMLDOM); xmlDoc.loadXML(transport.responseText); alert(xmlDoc.getElementsByTagName('Locations')[0].childNodes.length); Any suggestions? --~--~-~--~~~---~--~~ 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: Problems with XML in IE 7
sounds like an encoding problem ... for me IE often stops working if everyting is utf-8 and i also declare the reponse to be utf-8 encoded. if i remove the encoding on the response it works fine in IE, too On Mon, Jan 26, 2009 at 4:08 PM, Patrick patr...@clickfactor.nl wrote: I am loading some XML: new Ajax.Request(this.options.url, { method: 'post', parameters: 'r=hlf=' + $F(this.textbox), onSuccess:function(transport) { thisObject.data = transport.responseXML; alert(thisObject.data.getElementsByTagName ('Locations')[0].childNodes.length); } }); In Firefox I am getting a good result on the alert, in IE it returns zero. When I am loading the responseText from transport into Xmldoc it retruns a good result: // testing result for IE xmlDoc = new ActiveXObject(Microsoft.XMLDOM); xmlDoc.loadXML(transport.responseText); alert(xmlDoc.getElementsByTagName('Locations')[0].childNodes.length); Any suggestions? -- Lars Schwarz Heiligengeiststr. 26 26121 Oldenburg T 0441 36110338 M 0151 1727 8127 W www.bitrocker.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: How to read draggables position?
Just add a new JavaScript block to your current page and paste it in. On Jan 23, 4:45 pm, antonio.grazi...@gmail.com antonio.grazi...@gmail.com wrote: I have declared a New Draggable called 'module_left' in a script in my HTML page should I add your code in the HTML page or in the .js file ? --~--~-~--~~~---~--~~ 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: Possible incompatibility with JSON library?
Richard, What happens if you load prototype first? I think it does the same thing no matter which order the scripts are loaded. Thanks, Nathan --~--~-~--~~~---~--~~ 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: Possible incompatibility with JSON library?
On Jan 25, 7:30 pm, nlloyds nllo...@gmail.com wrote: I'm using this code: script src=http://www.json.org/json2.js;/script script runat=server src=https://ajax.googleapis.com/ajax/libs/ prototype/1.6.0.3/prototype.js/script script runat=server document.write(JSON.stringify([])); /script Which will output null with the Prototype script tag. If that tag is removed, the output is [], as I had expected. I believe the JSON library checks for at toJSON property on objects, which doesn't normally exist for Array, but does after Prototype.js augments them. Any ideas? I get [] with both prototype.js (1.6.0.3) and json2.js included: html head title/title /head body script src=http://www.json.org/json2.js;/script script src=https://ajax.googleapis.com/ajax/libs/prototype/ 1.6.0.3/prototype.js/script script type=text/javascript document.write(JSON.stringify([1,2,3])); /script /body /html -- kangax --~--~-~--~~~---~--~~ 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] Dragged and Confused
This is some working code that makes a Draggable: this.draggable = new Draggable(ts.up(div.rsrcRow), { revert: true, ghosting: true, onStart: function(draggable, event) { var G = window.grid; var dzs = G.gridElt.select(div.rsrcRow); G.dropZoneElts = dzs; // But why doesn't this store window.grid ? G.shouldBeGridObj = this; // ? But IS draggable.options. }.bind(window.grid), ... }); I would think the value of 'onStart' here would be the wrapper that bind puts around the function object, but it clearly is not. window.grid is a prototypejs-style object, and when onStart is called, 'this' is bound not to that object, but to draggable.options. And looking at it after the drag+drop (as window.grid.shouldBeGridObj) I can see that the 'onStart' member is the original function body with no indication of a bind-wrapper. What am I missing here? TIA, Mike --~--~-~--~~~---~--~~ 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] Theoretical Question
I am a web developer that is well versed in PHP and MySQL development environments. Lately, I have been picking up Prototype and script.aculo.us on a piece by piece basis. I have found myself using (or relying) heavily on event observers and calls to Ajax.Update() functions which pass serialized form variables. This can partially be explained by the fact that my sites are normally entirely DB driven and partially by the fact that I have not been doing anything too fancy. In general practice, I use various script.aculou.us visual effects and only a smattering of the Prototype helpers, the majority of the work on my pages is then passed to a php script and the content is in turn updated via an Ajax.Update. My question is, how sloppy is this? Or is it a viable implementation? Thanks, Ryan --~--~-~--~~~---~--~~ 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: New use case for Sortable tree?
Eric, I'm interested in seeing your solution. I have the same problem of trying to prevent the nested sortables from accepting groups. Stephen On Jan 7, 3:35 pm, Eric eylin2...@gmail.com wrote: I ended up extending Scriptaculous to allow for this behavior. The changes in the new API are: 1. Added a groupAccept option toSortable. It takes the same argument as Droppables' accept, but is used to limit whatgroupsin aSortabletreewill accept. (Group is defined as any element in theSortablelist that contains a nested list). For the example in my previous post, I gave all Items a class name like item, and set groupAccept to item. This ensures only Items can be dropped intoGroups,Groupscannot be dropped intoGroups. 2. To support the implementation of #1, I added an option to Droppables called acceptIf. acceptIf takes a function that takes two arguments: the dragged element and the Droppable object. acceptIf should return true if the drop should occur and false otherwise. This is meant to be a more general and dynamic way of specifying what can be dropped than the existing accept and containment options. If some of you are interested in these enhancements, I can post the code here. How do I go about adding these enhancements to the Scriptaculous trunk? Eric On Jan 6, 10:31 pm, Eric eylin2...@gmail.com wrote: I am usingSortablewithtreeenabled on a list like below: Group 1 Item 1 Item 2 Item 3 Group 2 Item 4 Here, bothGroupsand Items can be dragged. Additionally, Items can be dragged intoGroups(each Group contain an UL). However, I want to preventGroupsfrom being dragged intoGroups, but there doesn't seem to be an option inSortableto achieve that. The solution would be something like being able to specify accept class names for theSortabletree'snested ULs, so only Items would be allowed insideGroups. But that doesn't seem to be possible. Is there something that I am missing, or would doing this require me to extendSortable'simplementation myself? Thanks, Eric By the way, in the course of implementing my drag-and-droptree, I found thetree-dump output ofSortabletreeto be clumsy to use on the server side, because it would require me to recreate thetreein the database each time. Instead, I added a Draggables observer for the onEnd event to capture each sorting action, and send to the server only the change that was made: what element was dragged, which container it was dragged to and at what position. This required a bit of additional coding to determine the location and position of dragged element, but made the server side code simpler and faster. I am just curious, have other people done the same? --~--~-~--~~~---~--~~ 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] Ajax.Request delay
Hello, I'm having a weird issue when trying to use Ajax.Request in a function within a function. I'm using LiveValidation from http://www.livevalidation.com/ which uses prototype.js. It has a custom attribute that allows you to pass in a custom function to validate against. I call this custom function so that I can check a username against a database using the Ajax.Request method. The way it should work is, if the username is not found, it returns true, otherwise false. I haven't been able to get that exact result so I've created some workarounds. True or False is passed to the custom function of LiveValidation and validates based on true or false. However, for some reason, there is a delay in passing the value from the LiveValidation custom function. So let's say the username bee is taken. As I type the word 'bee' and the LiveValidation is being passed to the Ajax.Method, it is returning false. If I continue to type, let's say to the word 'beer,' it finally comes back true, even though 'beer' is not taken. Once I leave that field for the next one, it validates again and comes back false for the word 'beer.' Thus the delay. Here is the code I am using for the Ajax.Request function: * function validateEntry(c,f) { var url = ajaxProcessor.php?f= + f + c= + c; new Ajax.Request(url, { method: 'post', onComplete: function(transport) { if (transport.responseText == YES){ return entryResponse = 1; }else{ return entryResponse = 0; } } }); if (entryResponse == 0) { return false; }else{ return true; } } I'm using entryResponse because I haven't figured out how to return true or false. Here is the custom function for LiveValidation: script type=text/javascript var f1 = new LiveValidation('f1', { validMessage: Ok! } ); f1.add( Validate.Custom, { against: function(value){ return validateEntry(value,3) }, failureMessage: Username already taken! } ); /script *** Now I tested to see if it was the LiveValidation that was causing the delay in sending the correct value to the Ajax.Request function and it's not. Somewhere within the Ajax.Request method, the return values are being delayed. Can anyone help? --~--~-~--~~~---~--~~ 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: Theoretical Question
The pattern you've described doesn't sound too awful in practice, but if you start updating large chunks of your page at once, consider making the server share some of the work with the client. If you've already got the whole page there, and all the script, it doesn't make sense to (for example) update an entire table or grid when you've just deleted a row or re-sorted the contents. If you can get away with posting only the new sort order or the delete request to the server, and updating the page in the browser when you get a 200 header back from the update script, then you can improve your performance quite a lot, both for the client and the server. Walter On Jan 26, 2009, at 9:48 PM, ph...@ryangibbons.net wrote: My question is, how sloppy is this? Or is it a viable implementation? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---