Re: [Proto-Scripty] Re: Adding CSS-Rules to a styletag in Prototype
Thanks, Joe T. Walter: The problem is, that on my page the user can add/remove contents and also change the styles of those contents dynamically using JS. Now if you set a Style to certain elements, either via changing the style-tag or adding a class-name and *afterwards* add content, that content won't be styled. Of course, I save the applied style-settings in my backend and so I could apply the style-definitions when I generate the added content, but that maybe that might not be the case anymore in the future and also it's easier to set a style-definition in a style tag, rather than doing the backend-thing. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/jwbn35nC444J. 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 using Prototype 1.6.1 in IE9 / how compatible is Prototype 1.7 with 1.6.1?
Thanks Andrew. I tried upgrading. So far I don't see any problems, Good job! :) -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/Rvq6OvyfS50J. 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: What performs better? 30 observers on specific elements or 1 Observer observing every click?
Do I understand this right that you suggest adding one special class or attribute to all clickable elements, so that in my observer I can check for that class/attribute in the very first line minimizing the amount of if statements PLUS you suggest to delegate the triggered event to the [clicked] element so that I don't have one big eventhandler and can keep a good software structure? If I understand this right this would be THE answer. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/HR4SX-ts9ZoJ. 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] Adding CSS-Rules to a styletag in Prototype
Hi there, I wanna add CSS-Definitions to a style-tag using Prototype. In all good browsers (ALL^IE) this works by simplay appending a CSS-String to the desired style-tag. IE doesn't like this though. I found [1] that in IE you can update the entire contents of the style-tag using an attribute named * cssText* but that doesn't append but replace the all definitions. So I was wondering, does Prototype JS already have a method to append style-definitions to a styletags for all browsers? Thanks, Lukas [1] http://acidmartin.wordpress.com/2009/05/06/creating-style-tag-with-javascript-and-adding-rules-to-it/ -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/4fQMnC0XkpIJ. 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] Stopping events using Prototype 1.6.1 in IE9 / how compatible is Prototype 1.7 with 1.6.1?
Hi, I'm currently trying to make my site compatible with IE9 and there's already a major problem. I'm using Prototype 1.6.1 and it seems events won't be stopped with Event.stop anymore in IE9. I've read on Stackoverflow [1] Prototype 1.7 fixes that problem but I'm not sure if I should update. Deadline's coming soon and I don't know how much of a problem updating Prototype will be. So here's my question: Is there a way to stop events in IE9 with Prototype 1.6.1 or would you recommend upgrading to Prototype 1.7? Would you say there are some things that could be problematic? Thank you, Lukas [1] http://stackoverflow.com/questions/3919250/disable-a-link-in-ie9-prototype-stop-not-working -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/invHmqRjrzEJ. 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] Using only one draghandle in a sortable List
Hi there, I have a list where, when I hover its items, an overlay with an edit-link (and some other stuff) is shown. Now I'm trying to make that list sortable with Scriptaculous' Sortable. The problem is that I overlay the listitems with the mentioned edit-link-stuff and therefore cannot click and drag the list-items. For performance (and convenience) reasons I only have 1 overlay, not an overlay for each list-item, so I cannot define an overlay for each item as draghandle. So, is there any way I can dynamically bind a drag-handle for the list-items, so i can make the overlay the drag-handle for each list-item I'm hovering? -- Lukas -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/XM-bkELAdIwJ. 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: Using only one draghandle in a sortable List
Nevermind, I refactored the code, this isnt nexxessary anymore. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/Gjf9O2Fh5bYJ. 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] onDrop in Sortable
Hi, it seems there's no callback for 'onDrop' (like in Droppable) in Scriptaculous' Sortable. Is there any way to call a function whenever an element's dropped in Sortable? Thanks Lukas -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/DlJnb2kjbuQJ. 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] Aw: Re: Prototype itself throws errors in IE7
Ok, thank you guys but the problem was something different. It's almost emberassing ^^. I simply included prototype.js twice. While every normal Browser doesn't care, IE7 throws the above mentioned errors. Thanks though for your responses and sorry for having wasted your time ;) Lukas -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/9PGVg6luyqMJ. 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 itself throws errors in IE7
Hi I'm trying to get a project I'm working on IE7-proof and I'm running into errors right from the start. The project is almost finished so I'm already including a lot of scripts and already have a lot of markup. When I load my page I get the error Object doesn't support this property or method. prototype.js line 291 character 7 ...and lot's of others, but this one occurs in prototype.js pretty much is the basis for everything else. All scripts depend on one call in a dom:loaded-observer to be exectuted. I commented that line out so nothing get's executed but I still get the error in prototype.js. And I have no idea where to start. Fermion in the IRC-channel told my prototype doesn't work in quirksmode in IE7. I'm using XHTML 1.0 Transitional and I get validation-errors because I use custom attributes in some tags. But I created a file that uses Prototype and has custom attributes for testing pruposes and that page works well. If someone has an idea or a tip it's very appreciated. Thanks and have a nice weekend, Lukas -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/dxQftnqYLjoJ. 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: Why is there a $super-Parameter?
It's late, but I have to ask something though that it still don't understand. Why *doesn't* prototype just add a reference to the parent-class in subclasses? Like klass.prototype.superclass = superclass ...in Class.Create. Is it because the *this*-reference would go out of scope? -- 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] Why is there a $super-Parameter?
Hi, I'm working on my bachelor-thesis and I'm trying to understand a few things. I'm wondering: Why is there the construct of the $super-parameter in Prototype's class-implementation? Is anything wrong with calling this.parent.myfunction()? Why did they implement that? This is more of a theoretical question.. I just think there must be a reason for the $super thing.. Does anyone have an idea? Thanks Lukas -- 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.
Re: [Proto-Scripty] Why is there a $super-Parameter?
Sounds logical ;) No really, thx :) -- 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: Why is there a $super-Parameter?
Thanks a lot TJ that helps! -- 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] What do you think of this software-architecture?
Hi again, I'm working on a little project that lets users create (very) simple websites. On his site the user can add sections (like a text or a big image or a video) one below the other. Each section can be edited by clicking a link underneath the section. So to structure my code, and give me some convenience for later work, I copied and modified prototype's class-implementation so that a class created with my implementation can [optionally] be passed a DOM-object as parameter, which will be extended with a set of methods and properties of the class. That means I can create a class for a section and instantiate it passing it a section-DOM-Object. That section-object has all functions it needs to have to be edited right attached to it. That allows me to structure my code in a very OOP-like manner, seeing DOM-Objects as instances of my classes. Also I can still query the DOM-Tree the Prototype way and perform actions on it (like $$('.section').first.edit()). One trap I of course had to work around is name-conflicts, because I'm extending with up to 10 methods and properties. I just prefixed my names with rb (like $$('.section').first.rbEdit()). It's ugly, but it works. What do you think of such a structure? Sounds ok? Sounds problematic? All feedback is very appreciated :) Lukas -- 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] How to handle non-'px' values if you want to get an element's line-height
Hi, I need to calculate the line-height of an element. Unfortunately I cannot predict in which unit it will be set*** but I need to find out its px-value. If it is set in em or percent I can calculate it from the font-size, but that again could also be set in em or percent too. So I'm wondering what's the right way to deal with this; Do I need to recursively traverse the DOM tree upwards until I find a line-height/font-size I can work with? What if none is set? I read the default font-size for IE/FF/Safari is 16px, but I'm actually not sure if that's true. Or is there another way I can't think of? Thanks, Lukas * if there's no other way I could base the calculation on px-, em- (and maybe percent)-values, but if I can avoid this that would be a bonus -- 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 always visible in overflow:hidden parent div
Hi there, you can do this with the snap-paramter. It 'normally' takes a value, but you can also pass it a function that sets the boundaries for your draggable element: new Draggable('element', { snap: function(x, y) { return[ (x 200) ? (x 0 ? x : 0 ) : 200, (y 100) ? (y 0 ? y : 0) : 100 ]; } }); The values 200 should be the width of your container MINUS the draggable's width and instead of 100 you should insert the container's height minus the height of the element. Lukas -- 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: Strange ajax behaviour with effect.morph
Hi Rey, you shouldn't use timers for this - you canot be sure when an ajaxrequest has finished loading. There are parameters both in the ajax-methods and in morph that take functions that will be called on a specific event like when the ajax-call has been loaded (these are called callbacks). Check http://www.prototypejs.org/api/ajax/options section Common callbacks and http://madrobby.github.com/scriptaculous/core-effects/ for the part callbacks. A simple usage would be new Effect.Morph( myDiv, { style:height:0px;, afterFinish: function({ new Ajax.Request(url, { onSuccess: function(transport) { new Effect.Morph( myDiv, { style:height: 222px;overflow:hidden; } ); } }); })} ); There might be syntax-errors in 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: number sign (#) in a select option - gets truncated
Is the hash mark part of the request URL? If so it probably strips it because it's interpreted as an anchor and not part of a http-request to a file. If not so: We can haz (relevant) codez? -- 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.
Re: [Proto-Scripty] Re: How to show the full resolution image at clicking on thumnail
Why don't you ask in the jQuery-Group? https://groups.google.com/forum/?fromgroups#!forum/jquery-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-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.
Re: [Proto-Scripty] Re: How to show the full resolution image at clicking on thumnail
Also, posting a hell lot of code without structure or documentation probably won't get you anywhere. Try to strip everything down to there very relevant parts, comment your code and post again (here: https://groups.google.com/forum/?fromgroups#!forum/jquery-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-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 wrote a dropdown multiselect also
nice! -- 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: Prototype 1.7 EvalJSON Error Sintax on Date Eval
Afaik a JSON-Object (or string) must be wrapped in {}. What you have is an array (your string's wrapped with [ ]). Try: { [ {Aspirante_id:37, AspirantesComentarios_id: 6, Comentario:asdfadsf, Who:nahum, When: new Date(1294268679000) } ] } or {[{Aspirante_id:37,AspirantesComentarios_id: 6,Comentario:asdfadsf,Who:nahum,When:new Date(1294268679000)}]} Also, please, format your code when you paste it. -- 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: Can I change what new [someClass] will return?
Hi Richard, thanks for your reply. With The return is something I've been using since May 2008 with all the releases and updates since then. Do you mean you have used the native prototype-return, or did you alter it, and it still worked? On Dec 16, 6:04 pm, Richard Quadling rquadl...@gmail.com wrote: On 16 December 2010 16:36, Luke kickingje...@gmail.com wrote: Hi, if you define a Class like -- var TestClass = Class.create({ initialize: function(element) { element = $(element); this.doFunkyStuffWithElement(element) return element; }, doFunkyStuffWithElement: function(element) { log(funky stuff here) } }); -- and you instantiate that Class var myObject = new TestClass(); is there a way I can change it so (while namespacing my Class-Code so Prototype's Class will remain untouched) that instantiation of that class will return something different than what Prototype returns (in my case a DOM-Object that has been extended with custom Methods)? --- Why I want to do this: I'm working on a site where you can create really simple webpages by adding, editing, and removing elements on your page. To structure my code I make use of prototype's dom- extending nature and its way of class-inheritance: There is a base class for elements on the page which has methods for editing and removing that object and so on. I subclass this base-class for specific elements where I implement the specific editing/removing/ whatever-code. Now to map my functionality to the elements on the page, I extend the DOM-Elements which you can edit/etc with the methods and properties of the class, leaving out unnecessary constructors etc. But it is always a little annoying to extend an object with a class, and then fetch that object again to work with it: -- new EditablePicture($('the_element_I_extend')); var my_element = $('the_element_I_extend'); my_element.do_something(); -- it would be nice to be able to do something like this: -- var my_element = new EditablePicture($('the_element_I_extend')); my_element.do_something(); -- Is that kind of stuff even possible? Thank you Lukas -- 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 athttp://groups.google.com/group/prototype-scriptaculous?hl=en. Yep - I think so. Look at around line 80 of prototype.js function klass() { return this.initialize.apply(this, arguments); } The return is something I've been using since May 2008 with all the releases and updates since then. I've not had any issues with my code or with scripty with it. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- 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: Is there a way to get the name of a class from within the class?
I take that as a no? On Dec 16, 6:02 pm, bernard bernard.christophe...@gmail.com wrote: I truly wish some people would take the trouble to buy a javascript book instead of off-topic-posting in this group... meh. b. Intellectual honesty consists in taking ideas seriously. To take ideas seriously means that you intend to live by, to practice, any idea you accept as true. [Ayn Rand] -- 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: Can I change what new [someClass] will return?
Sounds good. Can you post a link to your source (if you want to share it and have it on github or something)? On Dec 17, 11:08 am, Richard Quadling rquadl...@gmail.com wrote: On 17 December 2010 08:32, Luke kickingje...@gmail.com wrote: Hi Richard, thanks for your reply. With The return is something I've been using since May 2008 with all the releases and updates since then. Do you mean you have used the native prototype-return, or did you alter it, and it still worked? On Dec 16, 6:04 pm, Richard Quadling rquadl...@gmail.com wrote: On 16 December 2010 16:36, Luke kickingje...@gmail.com wrote: Hi, if you define a Class like -- var TestClass = Class.create({ initialize: function(element) { element = $(element); this.doFunkyStuffWithElement(element) return element; }, doFunkyStuffWithElement: function(element) { log(funky stuff here) } }); -- and you instantiate that Class var myObject = new TestClass(); is there a way I can change it so (while namespacing my Class-Code so Prototype's Class will remain untouched) that instantiation of that class will return something different than what Prototype returns (in my case a DOM-Object that has been extended with custom Methods)? --- Why I want to do this: I'm working on a site where you can create really simple webpages by adding, editing, and removing elements on your page. To structure my code I make use of prototype's dom- extending nature and its way of class-inheritance: There is a base class for elements on the page which has methods for editing and removing that object and so on. I subclass this base-class for specific elements where I implement the specific editing/removing/ whatever-code. Now to map my functionality to the elements on the page, I extend the DOM-Elements which you can edit/etc with the methods and properties of the class, leaving out unnecessary constructors etc. But it is always a little annoying to extend an object with a class, and then fetch that object again to work with it: -- new EditablePicture($('the_element_I_extend')); var my_element = $('the_element_I_extend'); my_element.do_something(); -- it would be nice to be able to do something like this: -- var my_element = new EditablePicture($('the_element_I_extend')); my_element.do_something(); -- Is that kind of stuff even possible? Thank you Lukas -- 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 athttp://groups.google.com/group/prototype-scriptaculous?hl=en. Yep - I think so. Look at around line 80 of prototype.js function klass() { return this.initialize.apply(this, arguments); } The return is something I've been using since May 2008 with all the releases and updates since then. I've not had any issues with my code or with scripty with it. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- 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 athttp://groups.google.com/group/prototype-scriptaculous?hl=en. I build my own prototype. I have a patch which is applied to after the compiled from source. So, any class I create, I can return something from the initializer. I'm trying to find the original request for this feature, but I can't. It makes my classes work like a Factory if the initializer returns something other than this. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- 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: Can I change what new [someClass] will return?
Ok, that works great. Thank you Richard! On Dec 17, 11:17 am, Richard Quadling rquadl...@gmail.com wrote: On 17 December 2010 10:14, Luke kickingje...@gmail.com wrote: Sounds good. Can you post a link to your source (if you want to share it and have it on github or something)? I don't use github. I simply build prototype and then add my patch. I don't have any unit tests for this either, but my users are using it all day every day (24 hour call centre) for several years. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- 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: Is there a way to get the name of a class from within the class?
Ok, thanks T.J., I really wanted to get the name of the Class as a string. The reason is this: I'm working on a project that lets you create really simple webpages by adding, editing and removing objects (images, text, ..) to your page. To structure my code I do 2 things: 1.) I create classes for all objects on the page (for instance a general object-class, that holds general functions for editing, removing, etc and subclasses that inherit from the general class and implement their specific editing etc-functions (like for editing images, texts, etc)). Then I take the editable dom-elements of the page and extend them with the methods of the classes (I extend an editable image with the image-class etc) excluding methods like initilize or constructor. That way I can make use of class- inheritance and still have that sweet syntactic sugar like $ ('myImage').edit() (actually it's $('myImage').rbEdit() because of possible name-conflicts). Now what I want to prevent is that a DOM-Object get's extended by same class twice, because that would overwrite existing values, so I thought I might save what classes an object has already been extended with, and stop before it gets extended twice. But I'll think I'll define the classname as a property in the class itself then, and maybe throw an error if the classname has not been set. On Dec 17, 3:08 pm, T.J. Crowder t...@crowdersoftware.com wrote: Bernard, 1. No need to be offensive. If you think a question is beneath you, by all means ignore it rather than moaning into everyone's mailbox. 2. This question is almost certainly about Prototype's `Class` feature, not JavaScript. Yes, if you know JavaScript well you automatically know the answer to certain aspects of the question, but we were all new once, we all have limited time to read things, and we don't all learn perfectly reading general texts; sometimes we need our specific question answered in order to understand a broader concept. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Dec 16, 5:02 pm, bernard bernard.christophe...@gmail.com wrote: I truly wish some people would take the trouble to buy a javascript book instead of off-topic-posting in this group... meh. b. Intellectual honesty consists in taking ideas seriously. To take ideas seriously means that you intend to live by, to practice, any idea you accept as true. [Ayn Rand] -- 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: Is there a way to get the name of a class from within the class?
Hmm, that actually is a really good Idea. I already use my own Class.create-method as discussed here http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/b7f516a73fb4113a , so adding a unique id to this wouldn't be much of an effort. Thanks again! :) On Dec 17, 6:43 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Another option is to give the classes that you're using in this way a unique ID: * * * * (function() { var uniqueClassIDAllocator = 0; Class.createSpecial = Class_createSpecial; function Class_createSpecial() { var clz = Class.create.apply(Class, arguments); clz.classID = ++uniqueClassIDAllocator; return clz; } })(); var MyCoolClass = Class.createSpecial(...); * * * * If you don't want to have a `createSpecial` function, you could always assign these IDs if/when a class is used to extend elements (e.g., in a lazy way), but I prefer the explicit `createSpecial` because it happens at the time the class is created, as an explicit action of the author. FWIW, -- T.J. :-) On Dec 17, 2:46 pm, Luke kickingje...@gmail.com wrote: Ok, thanks T.J., I really wanted to get the name of the Class as a string. The reason is this: I'm working on a project that lets you create really simple webpages by adding, editing and removing objects (images, text, ..) to your page. To structure my code I do 2 things: 1.) I create classes for all objects on the page (for instance a general object-class, that holds general functions for editing, removing, etc and subclasses that inherit from the general class and implement their specific editing etc-functions (like for editing images, texts, etc)). Then I take the editable dom-elements of the page and extend them with the methods of the classes (I extend an editable image with the image-class etc) excluding methods like initilize or constructor. That way I can make use of class- inheritance and still have that sweet syntactic sugar like $ ('myImage').edit() (actually it's $('myImage').rbEdit() because of possible name-conflicts). Now what I want to prevent is that a DOM-Object get's extended by same class twice, because that would overwrite existing values, so I thought I might save what classes an object has already been extended with, and stop before it gets extended twice. But I'll think I'll define the classname as a property in the class itself then, and maybe throw an error if the classname has not been set. On Dec 17, 3:08 pm, T.J. Crowder t...@crowdersoftware.com wrote: Bernard, 1. No need to be offensive. If you think a question is beneath you, by all means ignore it rather than moaning into everyone's mailbox. 2. This question is almost certainly about Prototype's `Class` feature, not JavaScript. Yes, if you know JavaScript well you automatically know the answer to certain aspects of the question, but we were all new once, we all have limited time to read things, and we don't all learn perfectly reading general texts; sometimes we need our specific question answered in order to understand a broader concept. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Dec 16, 5:02 pm, bernard bernard.christophe...@gmail.com wrote: I truly wish some people would take the trouble to buy a javascript book instead of off-topic-posting in this group... meh. b. Intellectual honesty consists in taking ideas seriously. To take ideas seriously means that you intend to live by, to practice, any idea you accept as true. [Ayn Rand] -- 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] Can I change what new [someClass] will return?
Hi, if you define a Class like -- var TestClass = Class.create({ initialize: function(element) { element = $(element); this.doFunkyStuffWithElement(element) return element; }, doFunkyStuffWithElement: function(element) { log(funky stuff here) } }); -- and you instantiate that Class var myObject = new TestClass(); is there a way I can change it so (while namespacing my Class-Code so Prototype's Class will remain untouched) that instantiation of that class will return something different than what Prototype returns (in my case a DOM-Object that has been extended with custom Methods)? --- Why I want to do this: I'm working on a site where you can create really simple webpages by adding, editing, and removing elements on your page. To structure my code I make use of prototype's dom- extending nature and its way of class-inheritance: There is a base class for elements on the page which has methods for editing and removing that object and so on. I subclass this base-class for specific elements where I implement the specific editing/removing/ whatever-code. Now to map my functionality to the elements on the page, I extend the DOM-Elements which you can edit/etc with the methods and properties of the class, leaving out unnecessary constructors etc. But it is always a little annoying to extend an object with a class, and then fetch that object again to work with it: -- new EditablePicture($('the_element_I_extend')); var my_element = $('the_element_I_extend'); my_element.do_something(); -- it would be nice to be able to do something like this: -- var my_element = new EditablePicture($('the_element_I_extend')); my_element.do_something(); -- Is that kind of stuff even possible? Thank you Lukas -- 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] Is there a way to get the name of a class from within the class?
Hi, If you define a class like var MyCoolClass = Class.create({ initialize: function() { // find out classname here } }); can you get the name of the class from within itself? After all it's just a variable-name, but is it somehow accessible? Thank you Lukas -- 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: Extending the Object-Class
Ok, thank you again, TJ On Dec 11, 1:50 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, `Object` is deep in the core of JavaScript, not just Prototype. You can add static functions to `Object` fairly safely provided you use obscure names: Object.myReallyObscureMethodName = function() { // }; ...but as you mentioned, you will be susceptible to naming conflicts. What you must **never** do is add to `Object.prototype`: // DON'T DO THIS Object.prototype.myReallyObscureMethodName = function() { // }; If you do that (the way it's shown above), then just about every `for..in` loop in code running alongside yours will fail, because the above adds an enumerable `myReallyObscureMethodName` property to *all objects*: var name; for (name in {}) { alert(name); // This gets reached, and alerts myReallyObscureMethodName } ...and that's just a Bad Thing(tm). (As of ECMAScript 5th edition, it's *possible* to add non-enumerable properties to `Object.prototype` using special syntax, but I still wouldn't do it.) HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Dec 11, 12:07 am, Luke kickingje...@gmail.com wrote: Hi, is it ok to extend Object (http://api.prototypejs.org/language/Object/ ) with a custom function (I mean regarding name-conflicts, I want to name my function extendWrapped)? Or is it a Class that should better not be touched for some reason? It seems to be pretty deep in the core of Prototype, so I'm kinda cautious.. Thanks Lukas -- 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] Extending the Object-Class
Hi, is it ok to extend Object ( http://api.prototypejs.org/language/Object/ ) with a custom function (I mean regarding name-conflicts, I want to name my function extendWrapped)? Or is it a Class that should better not be touched for some reason? It seems to be pretty deep in the core of Prototype, so I'm kinda cautious.. Thanks Lukas -- 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 to create a new DOM-element from a string?
Hi Walter, yes the string comes from an ajax call and is not guaranteed to always follow the same pattern. However, by now I'm using prototype's BlindDown-effect when inserting and that even requires me to have a div wrapping what I want to insert (because of padding/margin), so it's ok that it's there. But still thanks a lot for your help, now I know that creating DOM just from a string needs a little workaround. It will surely not be the last time I need this. Thanks Lukas On Dec 7, 7:42 pm, Walter Lee Davis wa...@wdstudio.com wrote: Is mystring what you get back from your Ajax request? Do you control the server that sends it? If you want to end up with the Element div.something inserted somewhere on your page, you could do this pretty simply: var mystring = 'ptext a href=#link/a/ppMore text/pimg src=asd /'; //mystring could also be the output from your Ajax request var myDomObject = new Element('div',{ someProperty: someValue, someFunction: function() {}, ...}).update(mystring); myDomObject.addClassName('something'); //no need to extend, 'new Element' is already extended $('myDiv').insert({top: myDomObject}); So you create the outermost level of the DOM object using new Element, and that gets you everything you need. You could also pass back from your server a JSON graph of the desired element, and pass that to new Element directly, and you could skip some of this. By the way, I do the addClassName thing separately to humor IE, which doesn't seem to work when you define the classname in the new Element parameters level. I haven't tracked this issue to see if it's been fixed in newer versions of the library, I've just been doing it out of habit. If anyone can confirm that this is now no longer needed, I'd be happy to remove it and put it back in the parameters hash where I believe it belongs. Walter On Dec 7, 2010, at 12:53 PM, Luke wrote: Ok, what I wanna do is this: - var mystring = 'div class=somethingptext a href=#link/a/ ppMore text/pimg src=asd //div'; var myDomObject = createDomFromString(mystring); var methodsAndProperties = {someProperty: someValue, someFunction: function() {}, ... }; Object.extend(myDomObject, methodsAndProperties); $('myDiv').insert({top: myDomObject}); - In normal words, what I want to do is create a DOM-Object BEFORE I insert it, so I can perform some extensions on it, and dont't have to do: - var mystring = 'div class=somethingptext a href=#link/a/ ppMore text/pimg src=asd //div'; var foo = new Element('div', {}).update(mystring); var myDomObject = foo.select('.something').first(); Object.extend(myDomObject, methodsAndProperties); $('myDiv').insert({top: myDomObject}); - or even insert it, and then search for it. On Dec 7, 5:10 pm, Rick.Wellman rick.well...@kiewit.com wrote: Is it just me,... I don't understand what you're even asking/trying to accomplish? What kind of DOM object are you hoping to create? Call it a potayto, or a potahto but any element you insert the HTML into is a wrapper. Apologies if this seems terse but I truly do not understand your question/goal. -Original Message- From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptaculous@googlegroups.com ] On Behalf Of Luke Sent: Tuesday, December 07, 2010 9:59 AM To: Prototype script.aculo.us Subject: [Proto-Scripty] Re: How to create a new DOM-element from a string? Hm ok, hoped there would be a way I could generate a DOM object that consists of just the HTML (without wrapper) and before I insert it. On Dec 7, 4:52 pm, Walter Lee Davis wa...@wdstudio.com wrote: That's because I called innerHTML on it at the end, and that returns a string. If you then want to create a new element out of that, you could try inserting it into your page somewhere with $('someElementOnYourPage').insert({after: foo}); Of you could just leave the innerHTML part off the end, which would leave foo populated with the outer wrapper object created by new Element... Walter On Dec 7, 2010, at 3:20 AM, Luke wrote: Hmm, damn. the returned value is still a string :( On Dec 7, 9:16 am, Luke kickingje...@gmail.com wrote: Thanks Walter! On Dec 6, 6:28 pm, Walter Lee Davis wa...@wdstudio.com wrote: On Dec 6, 2010, at 12:12 PM, Walter Lee Davis wrote: It's OT for this list, but have a look at Prototype.js. You can create a new DOM element in memory, and do all the things you want to it without ever showing it to the user. Sorry, this was completely bone-headed of me -- I thought I was on another list. 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
[Proto-Scripty] Re: Anything wrong with adding a function called 'click' to the global Element-namespace?
By now I just changed the name of the function to 'rbClick'. It's ugly, but it shouldn't be problematic, should it? On Dec 6, 10:39 pm, T.J. Crowder t...@crowdersoftware.com wrote: some form controls (radio, checkbox, maybe others...) have a native click() method that toggles them, so that would be in conflict... Nice one, *exactly* why this sort of thing is not generally a good idea. Create a utility class to do it, etc., but putting them on the actual elements is asking for trouble. Re the `click` event on form controls (which are Elements, of course):http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-... -- T.J. :-) On Dec 3, 6:16 am, Gappa pavel.linh...@gmail.com wrote: Hi, some form controls (radio, checkbox, maybe others...) have a native click() method that toggles them, so that would be in conflict I suppose. Pavel On 2 pro, 10:36, Luke kickingje...@gmail.com wrote: Hi, I think it's pretty annoying to write myelement.observe('click', function(event){ // do stuff event.stop() }); for every link etc for which you want to replace the click- functionality. So I added a Method to Element that does the observer- invoking and event-stopping for me and simply named it click. Like with jQuery, the event only keeps bubbling if the given eventHandler returns true. Element.addMethods({ click: function(element, eventHandler) { if (!(element = $(element))) return; element.observe('click', function(event){ if(!eventHandler(event)) event.stop() }); return element; } }); But I'm wondering. 'click' sounds like a name to me that could easily cause conflicts. It works in Safari and FF though. Does anyone know if there could be sideeffects or nameconflicts? Thanks Lukas -- 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 to create a new DOM-element from a string?
Thanks Walter! On Dec 6, 6:28 pm, Walter Lee Davis wa...@wdstudio.com wrote: On Dec 6, 2010, at 12:12 PM, Walter Lee Davis wrote: It's OT for this list, but have a look at Prototype.js. You can create a new DOM element in memory, and do all the things you want to it without ever showing it to the user. Sorry, this was completely bone-headed of me -- I thought I was on another list. 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 to create a new DOM-element from a string?
Hmm, damn. the returned value is still a string :( On Dec 7, 9:16 am, Luke kickingje...@gmail.com wrote: Thanks Walter! On Dec 6, 6:28 pm, Walter Lee Davis wa...@wdstudio.com wrote: On Dec 6, 2010, at 12:12 PM, Walter Lee Davis wrote: It's OT for this list, but have a look at Prototype.js. You can create a new DOM element in memory, and do all the things you want to it without ever showing it to the user. Sorry, this was completely bone-headed of me -- I thought I was on another list. 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: Prototype class-instances sharing properties
Will try that, thank you yuval On Dec 4, 8:44 pm, yuval dagan dag...@gmail.com wrote: Hi currently the rdBuff is shared between all instatces try to create the instance variable (here rdBuff) inside the initialize function and with the this keyword its not default like in C++ etc... var SomeClass = Class.create({ initialize: function(name) { this.rbBuffer = {}; }, setBuffer: function(val) { this.rbBuffer.test = val; }, . . . hope it helped cheers yuval On Sat, Dec 4, 2010 at 5:01 PM, Luke kickingje...@gmail.com wrote: Hi, I've got a weird behavior here, or rather a behavior I don't understand. If you take the following Class: --- var SomeClass = Class.create({ rbBuffer: nulll, setBuffer: function(val) { this.rbBuffer = val; }, getBuffer: function() { return this.rbBuffer; } }); --- and play around a little bit: --- var c1 = new SomeClass(); var c2 = new SomeClass(); c1.setBuffer(true); c2.setBuffer(false); log(c1.getBuffer()); // PRINTS TRUE log(c2.getBuffer()); // PRINTS FALSE --- everything works as expected. But if you alter that class and make rbBuffer a JSON-object and try to set/get properties of that object, it kinda gets shared: --- var SomeClass = Class.create({ rbBuffer: {}, setBuffer: function(val) { this.rbBuffer.test = val; }, getBuffer: function() { return this.rbBuffer.test; } }); var c1 = new SomeClass(); var c2 = new SomeClass(); c1.setBuffer(true); c2.setBuffer(false); log(c1.getBuffer()); // PRINTS FALSE log(c2.getBuffer()); // PRINTS FALSE --- rbBuffer.test of the first object is overwritten with the value you set on the second object, as if the use the same variable. Does anyone know why this is, and how to work with it? Thanks Lukas -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculou s%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Observe once
Hi, I'm doing an internship in a company where they bought a script for modals called 'Lightview' ( http://www.nickstakenburg.com/projects/lightview/ ), so I'm kinda stuck with using it. The problem is that instead of many other libraries, you cannot pass lightview any callbackfunctions as parameters. That means the only way to react on, lets say, when lightview is done opening or closing is to observe global events that will be fired in such cases. So if I want to do something when lightview closes I need to observe 'lightview:hidden', but I do not -always- react on this event with a given behaviour since there are many cases for which lightview is shown. I just want to react to the close even just this one time. So I thought, maybe I could write an observer, that kills its self after it has been executed. I tried this: var discardAll = function(event) { // Do stuff document.stopObserving('lightview:hidden', discardAll); } document.observe('lightview:hidden', discardAll); But this doesn't work. I must say I don't really have much clue of stoping specific observers in the first place, so I'm wondering if this is even the right way to stop an observer Thanks, Lukas -- 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 to create a new DOM-element from a string?
Hm ok, hoped there would be a way I could generate a DOM object that consists of just the HTML (without wrapper) and before I insert it. On Dec 7, 4:52 pm, Walter Lee Davis wa...@wdstudio.com wrote: That's because I called innerHTML on it at the end, and that returns a string. If you then want to create a new element out of that, you could try inserting it into your page somewhere with $('someElementOnYourPage').insert({after: foo}); Of you could just leave the innerHTML part off the end, which would leave foo populated with the outer wrapper object created by new Element... Walter On Dec 7, 2010, at 3:20 AM, Luke wrote: Hmm, damn. the returned value is still a string :( On Dec 7, 9:16 am, Luke kickingje...@gmail.com wrote: Thanks Walter! On Dec 6, 6:28 pm, Walter Lee Davis wa...@wdstudio.com wrote: On Dec 6, 2010, at 12:12 PM, Walter Lee Davis wrote: It's OT for this list, but have a look at Prototype.js. You can create a new DOM element in memory, and do all the things you want to it without ever showing it to the user. Sorry, this was completely bone-headed of me -- I thought I was on another list. 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 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: How to create a new DOM-element from a string?
Ok, what I wanna do is this: - var mystring = 'div class=somethingptext a href=#link/a/ ppMore text/pimg src=asd //div'; var myDomObject = createDomFromString(mystring); var methodsAndProperties = {someProperty: someValue, someFunction: function() {}, ... }; Object.extend(myDomObject, methodsAndProperties); $('myDiv').insert({top: myDomObject}); - In normal words, what I want to do is create a DOM-Object BEFORE I insert it, so I can perform some extensions on it, and dont't have to do: - var mystring = 'div class=somethingptext a href=#link/a/ ppMore text/pimg src=asd //div'; var foo = new Element('div', {}).update(mystring); var myDomObject = foo.select('.something').first(); Object.extend(myDomObject, methodsAndProperties); $('myDiv').insert({top: myDomObject}); - or even insert it, and then search for it. On Dec 7, 5:10 pm, Rick.Wellman rick.well...@kiewit.com wrote: Is it just me,... I don't understand what you're even asking/trying to accomplish? What kind of DOM object are you hoping to create? Call it a potayto, or a potahto but any element you insert the HTML into is a wrapper. Apologies if this seems terse but I truly do not understand your question/goal. -Original Message- From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Luke Sent: Tuesday, December 07, 2010 9:59 AM To: Prototype script.aculo.us Subject: [Proto-Scripty] Re: How to create a new DOM-element from a string? Hm ok, hoped there would be a way I could generate a DOM object that consists of just the HTML (without wrapper) and before I insert it. On Dec 7, 4:52 pm, Walter Lee Davis wa...@wdstudio.com wrote: That's because I called innerHTML on it at the end, and that returns a string. If you then want to create a new element out of that, you could try inserting it into your page somewhere with $('someElementOnYourPage').insert({after: foo}); Of you could just leave the innerHTML part off the end, which would leave foo populated with the outer wrapper object created by new Element... Walter On Dec 7, 2010, at 3:20 AM, Luke wrote: Hmm, damn. the returned value is still a string :( On Dec 7, 9:16 am, Luke kickingje...@gmail.com wrote: Thanks Walter! On Dec 6, 6:28 pm, Walter Lee Davis wa...@wdstudio.com wrote: On Dec 6, 2010, at 12:12 PM, Walter Lee Davis wrote: It's OT for this list, but have a look at Prototype.js. You can create a new DOM element in memory, and do all the things you want to it without ever showing it to the user. Sorry, this was completely bone-headed of me -- I thought I was on another list. 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 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 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] How to create a new DOM-element from a string?
Hi, I'm loading some plain HTML via Ajax.Request and insert it in a DIV. I need to perform some extensions on the HTML I load though, which brought me to the idea to create DOM from the loaded markup, extend it and insert it. So my question is: Is there a convenient way to create DOM from a string of HTML-markup? The only way I found, or have been told, is to create a DIV with new Element, insert the markup in it, and remove the DIV again. But I find that kinda hacky. Isn't there a good way for this? Thanks Lukas -- 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] Prototype class-instances sharing properties
Hi, I've got a weird behavior here, or rather a behavior I don't understand. If you take the following Class: --- var SomeClass = Class.create({ rbBuffer: nulll, setBuffer: function(val) { this.rbBuffer = val; }, getBuffer: function() { return this.rbBuffer; } }); --- and play around a little bit: --- var c1 = new SomeClass(); var c2 = new SomeClass(); c1.setBuffer(true); c2.setBuffer(false); log(c1.getBuffer()); // PRINTS TRUE log(c2.getBuffer()); // PRINTS FALSE --- everything works as expected. But if you alter that class and make rbBuffer a JSON-object and try to set/get properties of that object, it kinda gets shared: --- var SomeClass = Class.create({ rbBuffer: {}, setBuffer: function(val) { this.rbBuffer.test = val; }, getBuffer: function() { return this.rbBuffer.test; } }); var c1 = new SomeClass(); var c2 = new SomeClass(); c1.setBuffer(true); c2.setBuffer(false); log(c1.getBuffer()); // PRINTS FALSE log(c2.getBuffer()); // PRINTS FALSE --- rbBuffer.test of the first object is overwritten with the value you set on the second object, as if the use the same variable. Does anyone know why this is, and how to work with it? Thanks Lukas -- 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] Anything wrong with adding a function called 'click' to the global Element-namespace?
Hi, I think it's pretty annoying to write myelement.observe('click', function(event){ // do stuff event.stop() }); for every link etc for which you want to replace the click- functionality. So I added a Method to Element that does the observer- invoking and event-stopping for me and simply named it click. Like with jQuery, the event only keeps bubbling if the given eventHandler returns true. Element.addMethods({ click: function(element, eventHandler) { if (!(element = $(element))) return; element.observe('click', function(event){ if(!eventHandler(event)) event.stop() }); return element; } }); But I'm wondering. 'click' sounds like a name to me that could easily cause conflicts. It works in Safari and FF though. Does anyone know if there could be sideeffects or nameconflicts? Thanks Lukas -- 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] Class Inheritance Properties
Hi there! Is there a way you can inherit from a class and extend a property from the parent class with the same property of the subclass? Like if I have the following 2 classes: === === var Section = Class.create({ attach: function(element) { Object.extend(element, this.extension); } extension: { // Methods and properties here } } === and === var SectionText = Class.create(Section, { extension: { // More methods and properties here } }); === === is somehow possible to extend the extension-property of the parent class with the extension-property of the subclass rather than replacing it? Can I maybe somehow access the parent's property from the subclass to manually extend it? Thanks, Luke -- 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: Class Inheritance Properties
Thanks. Fermion in the Prototype-IRC also told me the same thing. But he said you cannot access the parent's property. It will be overwritten by the child. Is that true or do you know any way to access it from the child? $super just seems to contain the parent's method that has the same name like the child's method it is passed to... . On Nov 29, 1:23 pm, Johan Arensman johanm...@gmail.com wrote: You can use the $super parameter name to access the property of the parent class. See:http://api.prototypejs.org/language/Class/create/ On Mon, Nov 29, 2010 at 12:15 PM, Luke kickingje...@gmail.com wrote: Hi there! Is there a way you can inherit from a class and extend a property from the parent class with the same property of the subclass? Like if I have the following 2 classes: === === var Section = Class.create({ attach: function(element) { Object.extend(element, this.extension); } extension: { // Methods and properties here } } === and === var SectionText = Class.create(Section, { extension: { // More methods and properties here } }); === === is somehow possible to extend the extension-property of the parent class with the extension-property of the subclass rather than replacing it? Can I maybe somehow access the parent's property from the subclass to manually extend it? Thanks, Luke -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculou s%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Is it possible to add multiple funtions to an Ajax-callback like onSuccess?
Hi the topic says it all. Can you somehow call multiple functions for a callback of Ajax.Request? Like new Ajax.Request(url, { onSuccess: [function(){}, function(){}] }); I know emthat/em doesn't work. But is there maybe another way? I've seen there are Ajax.Responders ( http://www.prototypejs.org/api/ajax/responders ) but I couldn't figure out how that works. Thank you Lukas -- 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: Is it possible to add multiple funtions to an Ajax-callback like onSuccess?
On Nov 29, 7:19 pm, Walter Lee Davis wa...@wdstudio.com wrote: Will that work for you? Indeed! Thought things were more complicated ;). 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-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: Extending a DOM-Object
Thank you Mr Crowder, that was quite informative. Still I'm a little unsure how to proceed. If I got this right, it is common sense now that extending the DOM is the wrong thing to do. One of the main reasons is the possibility of name-conflicts. So I thought I might extend Objects with a JSON-Object (called 'builder' in my case) which contains all my methods and properties to (sort of) have my own namespace. But that would require a circular reference in my builder-object to the DOM-Element it is attached to (so the methods in my builder-object can work on the DOM they are attached to). I'm wondering if there's any way to keep that nice programming- paradigm prototype introduced with it's $-function, that you can simply write $('myelement').myfunction() while avoiding the above- mentioned problems. I could write my own wrapper-method, like jQuery's $-function, but that would miss the whole point of working with prototype. How do other people work with this? Luke On Nov 22, 7:37 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Luke, What you're talking about doing is called an expando property. They're not covered by a standard AFAIK, although interestingly Microsoft has an `expando` property on objects[1] (this is where the name came from) which is a boolean saying whether you can do this. If you do a web search on expando you'll find a lot more information (and a studio album by Timothy B. Schmit, but leave that aside...). (Ignore the statement on GreaseSpot that expandos relate to custom attributes; they don't, the article is just wrong.) Prototype uses expando properties like mad (the whole concept of extending an element[2] relies on expandos, and Prototype uses them elsewhere as well), so if you're using Prototype, you're already relying on the environment allowing expandos. But it's probably worth noting that Prototype is moving away from expandos at some point in favor of doing a jQuery-like wrapper thing instead. I'd avoid having your expando property value (directly or indirectly) reference another DOM element, as that sets up the possibility of circular references, and circular references that dip between the DOM and JavaScript layers can cause memory leaks on IE. [1]http://msdn.microsoft.com/en-us/library/ms533747(VS.85).aspx [2]http://prototypejs.org/learn/extensions Happy coding, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Nov 21, 8:28 pm, Luke kickingje...@gmail.com wrote: Thanks Walter. If that's the only reason I'm willing to take that risk. In my whole application I will only attach one variable, kind of like my namespace and this will give me some convenience when accessing that namespace. If it's conform to W3C standards and works in all browsers, I think it's ok. But is it? Can't find any documentation or specification on this Luke On Nov 21, 8:50 pm, Walter Lee Davis wa...@wdstudio.com wrote: I think that the basic reason for the separate store is to provide insulation from any current, past, or future browsers tramping on a key name you may choose today and test in some subset of all browsers. Browser scripting is fun enough in IE with its amusing conflation of Name and ID properties without getting into the weeds with a perfectly- safe-seeming data element being confused for some completely other property or method. Walter On Nov 21, 2010, at 2:15 PM, Luke wrote: Hi, is there anyting wrong with extending a DOM-Object with $('myelement').myvariable = something; or why is there the prototype-method store, which saves values in a seperate hash? Thank you, Lukas -- 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] Extending a DOM-Object
Hi, is there anyting wrong with extending a DOM-Object with $('myelement').myvariable = something; or why is there the prototype-method store, which saves values in a seperate hash? Thank you, Lukas -- 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: Extending a DOM-Object
Thanks Walter. If that's the only reason I'm willing to take that risk. In my whole application I will only attach one variable, kind of like my namespace and this will give me some convenience when accessing that namespace. If it's conform to W3C standards and works in all browsers, I think it's ok. But is it? Can't find any documentation or specification on this Luke On Nov 21, 8:50 pm, Walter Lee Davis wa...@wdstudio.com wrote: I think that the basic reason for the separate store is to provide insulation from any current, past, or future browsers tramping on a key name you may choose today and test in some subset of all browsers. Browser scripting is fun enough in IE with its amusing conflation of Name and ID properties without getting into the weeds with a perfectly- safe-seeming data element being confused for some completely other property or method. Walter On Nov 21, 2010, at 2:15 PM, Luke wrote: Hi, is there anyting wrong with extending a DOM-Object with $('myelement').myvariable = something; or why is there the prototype-method store, which saves values in a seperate hash? Thank you, Lukas -- 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: How should I model this if extending the DOM is bad?
Sorry, I don't understand. How would you store a reference to the Object in the paragraph? Or would you keep a list (or an array) of paragraph-objects that have a reference to the paragraph-DOM-Element? On Nov 6, 7:33 pm, buda www...@pochta.ru wrote: Keep reference to the object in storage of a paragraph, video and etc On 4 ноя, 23:09, Luke kickingje...@gmail.com wrote: Hi, sorry for the non-descriptive topic, I couldn't think of anything better. However, I'm currently working on a project where you can create simple webpages by adding different types of paragraphs, (eg. Text, Image, Video) one below the other, and edit their contents, move or delete them. Basically like this: http://blogage.de/files/60901/image Im rewriting the JS and I have a little problem here; I recently read that extending the DOM is basically a bad idea and that in Prototype 2 they will even stop that practice. Now my idea (actually) was, for a project like this, to create classes for each paragraph-type with methods and properties that I would extend the paragraph-DOM with. I mean that if I had, like in the above image, three paragraphs, each would be represented by a DIV with the class=paragraph text or class=paragraph video etc. On the JS-side there would be classes like Text or Video which would have a method that would extend those DIVs with functions and properties necessary to edit, move or delete that paragraph. When, for example, the user clicks on an editlink, it simply would call its paragraph's edit-method. Everything would be nice and clean. But now I know, extending is bad. So I'm kinda stuck here, I don't know how to write unobtrusive JS without writing terrible spaghetti- esque code with lots of observers. I mean I could still organize parts of the code in classes, but there would be a long list of observers (eg. for clicking an edit-link) with switch-cases for the types of paragraphs. Actually even with extending the DOM I'm not totally sure how I would catch the edit-clicking event. As I said, I'm kind of stuck :). Can you help me with ideas? How would you do this? Thanks a lot, Luke -- 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] How should I model this if extending the DOM is bad?
Hi, sorry for the non-descriptive topic, I couldn't think of anything better. However, I'm currently working on a project where you can create simple webpages by adding different types of paragraphs, (eg. Text, Image, Video) one below the other, and edit their contents, move or delete them. Basically like this: http://blogage.de/files/60901/image Im rewriting the JS and I have a little problem here; I recently read that extending the DOM is basically a bad idea and that in Prototype 2 they will even stop that practice. Now my idea (actually) was, for a project like this, to create classes for each paragraph-type with methods and properties that I would extend the paragraph-DOM with. I mean that if I had, like in the above image, three paragraphs, each would be represented by a DIV with the class=paragraph text or class=paragraph video etc. On the JS-side there would be classes like Text or Video which would have a method that would extend those DIVs with functions and properties necessary to edit, move or delete that paragraph. When, for example, the user clicks on an editlink, it simply would call its paragraph's edit-method. Everything would be nice and clean. But now I know, extending is bad. So I'm kinda stuck here, I don't know how to write unobtrusive JS without writing terrible spaghetti- esque code with lots of observers. I mean I could still organize parts of the code in classes, but there would be a long list of observers (eg. for clicking an edit-link) with switch-cases for the types of paragraphs. Actually even with extending the DOM I'm not totally sure how I would catch the edit-clicking event. As I said, I'm kind of stuck :). Can you help me with ideas? How would you do this? Thanks a lot, Luke -- 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.