[Proto-Scripty] Re: Future of Prototyp.js
On Sunday, 23 October 2011 17:43:39 UTC+1, T.J. Crowder wrote: Hi, On Oct 23, 5:35 pm, wwwboy www...@pochta.ru wrote: With the speed of which modern browsers release updates and move toward HTML5 - I think there will be no significant differences between them in a year. IE8 will not be alive in a year in the light of Windows8 with IE10 and canceling support XP - so there will be IE9 and IE10 which a close to other browsers. I think you're being very optimistic there, particularly with regard to how quickly Windows users will upgrade. And here we are, a year later, and guess what? IE8 still has more market share (24%) than IE9 (20%). :-) http://marketshare.hitslink.com/browser-market-share.aspx?qprid=2qpcustomd=0 -- T.J. -- 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/-/mbafvlZ3-egJ. 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] Walter Lee Davis is now a moderator
Hi all, If you've been on the list for any time at all, you'll know Walter Lee Davis. :-) Walter was good enough to step forward to help with moderating the list, and we seem to have him up and running now (he's approved his first held message). So please say welcome and thank you to Walter! Thanks Walter! -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com -- 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/-/06WUrGFe6CYJ. 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] Call for moderators
Hi, I have no idea whether you can moderate via email. But thanks anyway. :-) Anyone else? -- T.J. On Friday, 11 May 2012 16:32:10 UTC+1, Walter Lee Davis wrote: I can do this, but I never read the list through the Web interface. Are there options to ping the moderators by e-mail? If it's web-only, I doubt I would be a good choice. Walter On May 11, 2012, at 11:09 AM, T.J. Crowder wrote: Hi all, I almost never read this group anymore. When I do, there are usually a couple of messages from new members waiting to be allowed through. (I'm a moderator of the group.) Seems like the group could use at least a couple of more moderators. Who's up for being one? It takes virtually no time. If you already come to the list regularly, if you become a moderator you'll just see a notification if any messages are being held for moderation. A couple of clicks and you can either can the spam or allow the real messages. So if you're interested, please just reply to this thread. Ideally, I'd like to see replies from people who've been active on the list for at least a year. Thanks! -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com -- 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/-/PRcXmFT6xFEJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/i0EqMmJ4r3oJ. 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] Call for moderators
Hi all, I almost never read this group anymore. When I do, there are usually a couple of messages from new members waiting to be allowed through. (I'm a moderator of the group.) Seems like the group could use at least a couple of more moderators. Who's up for being one? It takes virtually no time. If you already come to the list regularly, if you become a moderator you'll just see a notification if any messages are being held for moderation. A couple of clicks and you can either can the spam or allow the real messages. So if you're interested, please just reply to this thread. Ideally, I'd like to see replies from people who've been active on the list for at least a year. Thanks! -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com -- 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/-/PRcXmFT6xFEJ. 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] stupid checkbox question
On Friday, 27 April 2012 10:47:51 UTC+1, DaveK wrote: input type='checkbox' id='1' not a legal ID - must start with a letter That's no longer true as of HTML5, which in this case is just documenting what browsers already did: http://www.w3.org/TR/html5/elements.html#the-id-attribute It *was* true for HTML4, but browsers didn't care in terms of document.getElementById and such. Note that it's still true for CSS (#1 is an invalid selector), and browsers *do* care about that (e.g., with querySelectorAll and such): http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier So while HTML5 is very lax, if you're ever going to use CSS selectors to refer to the element, best to stick to the more restrictive CSS rules. FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com -- 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/-/waBN43eCc84J. 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: accessing global objects
From the code you've quoted, it would be accessible, there must be more to it than that. Can you provide a minimalist test case on http://jsbin.com or similar? -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Monday, 2 April 2012 12:21:44 UTC+1, nav indian wrote: even after declaring as global, it is still not accessible . the following code will get an idea. one.js namespace(package1) var oneObject ; package1.tabs=function(app) { this.app = app; this. createTabs(); } createTabs = function(){ oneObject = new thirdpartyObject(); } two.js //Here I have to access oneObject. On Mon, Apr 2, 2012 at 1:28 PM, T.J. Crowder t...@crowdersoftware.comwrote: Here I have to access oneObject. You can't, it's a local variable within the function you assigned to the `createTabs` variable. Unless you export it (make it publicly accessible in some way, for instance by assigning it to your `package1` object as a property), it's completely private to `createTabs`. Side note: Your code is falling prey to The Horror of Implicit Globals[1]. Strongly recommend properly declaring variables to avoid that. 1: http://blog.niftysnippets.org/2008/03/horror-of-implicit-globals.html Best, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Sunday, 1 April 2012 12:41:16 UTC+1, nav indian wrote: Hi I have two javascript files. one.js namespace(package1) var oneObject ; package1.tabs=function(app) { this.app = app; this. createTabs(); } createTabs = function(){ oneObject = new thirdpartyObject(); } two.js //Here I have to access oneObject. -- 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/-/XJ20PmyWnIQJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/hJoyflIZoi8J. 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: Handle an Event or Element in one function (or alias)?
Hi, On Feb 25, 8:26 pm, Walter Lee Davis wa...@wdstudio.com wrote: I have defined a new function on the Element namespace: //common function to switch tabs Element.addMethods({ setTab: function(elm, evt){ //hide all the content bodies.invoke('hide'); tabs.invoke('removeClassName','active'); elm.addClassName('active').bodies.invoke('show'); } }) It works perfectly when it's passed from an element $('sometab').setTab(); But if I want to register a click handler on all the tabs: tabs.invoke('observe','click', setTab); I get an error: TypeError: 'undefined' is not a function (evaluating 'handler.call(element, event)') ...from Prototype 1.7 in Safari 5.1.2. Is there a way to write this so it will work in both contexts, or do I need to add an explicit event handler form of the method somewhere else? If I write the handler like this: tabs.invoke('observe','click', function(evt){ this.setTab(); } ); ...then it works perfectly, but I'm confused why it's not working in the other syntax. I could swear I've used that same construction earlier and had it work just fine. Thanks in advance, Walter Here's how you would hook that up: tabs.invoke('observe','click', Element.Methods.setTab.methodize() ); Live example: http://jsbin.com/opitis Explanation: * `Element.Methods` contains all of the methods that will be applied to elements when augmenting them (including ones you add) http://api.prototypejs.org/dom/Element/Methods/ * `methodize` is what Prototype uses to turn Element.setTab(foo) into $(foo).setTab(); http://api.prototypejs.org/language/Function/prototype/methodize/ Hope this helps - happy coding! -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Problem with jquery+prototype
Hi, On Feb 23, 9:42 pm, Syn vjuliu...@gmail.com wrote: Hey, I'm using a tool which uses prototype. I'm also using my own little jquery which looks like this: $(document).ready(function(){ $('.flip').click(function(){ $('#panel').slideToggle('slow'); }); }); The problem is if I include prototype.js then my (above) script does not work. I'm really in hurry with the project can't dive into prototype's nitty-gritty. Could somebody let me know how to solve this, Thanks, Syn This comes up all the time, just do a search for it and you'll find details. The short version is: Both jQuery and Prototype try to use the `$` symbol. jQuery is kind enough to provide a function to relinguish control of it, called `noConflict`. So just add this after your script tag that includes jQuery: scriptjQuery.noConflict();/script Then `$` belongs to Prototype, and `jQuery` is how you access jQuery. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Problem with jquery+prototype
Hi, On Feb 23, 9:42 pm, Syn vjuliu...@gmail.com wrote: Hey, I'm using a tool which uses prototype. I'm also using my own little jquery which looks like this: $(document).ready(function(){ $('.flip').click(function(){ $('#panel').slideToggle('slow'); }); }); The problem is if I include prototype.js then my (above) script does not work. I'm really in hurry with the project can't dive into prototype's nitty-gritty. Could somebody let me know how to solve this, Thanks, Syn The _slightest effort_ on your part would find the solution: http://api.jquery.com/jQuery.noconflict -- T.J. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: class is a reserved identifier. What is wrong?
Hi, The problem must be in code you haven't quoted. Use your editor to do a case-sensitive search for class (in all lower case), it's a reserved (but currently unused) word in JavaScript. Note that your quoted code uses Class (with an initial capital letter), which is fine. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Feb 20, 8:39 am, Alexey Stepanov sager...@gmail.com wrote: This my script, when event is on exit from onClick i got message class is a reserved identifier class= CheckBoxSlider = Class.create({ initialize: function (checkbox, block) { this.checkbox= $(checkbox); this.block=$(block); this.checkbox.observe(click, this.onClick.bind(this)); }, onClick: function (event) { if (this.checkbox.checked) { this.block.show(); }else { this.block.hide(); } } }); window.onload= function() { tmp = new CheckBoxSlider(register-new-user,regiser-new-user- fields); }; -- 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: Order of Event Handler
Hi, The fundamental answer here is: Relying on the order in which event handlers are triggered is usually not a good design decision. Rather than spending time trying to get it working, I'd spend time finding a completely different way to solve the problem if at all possible. Unlike jQuery, Prototype doesn't guarantee the order in which event handlers are fired. When you attach an event handler with Prototype, it really calls addEventListener/attachEvent for your specific handler (after putting a wrapper around it), and so the order in which the handlers are called is determined by the browser implementation. Unfortunately, different browsers do different things. *Most* browsers (Chrome, Firefox, Safari, Opera, IE9+ [if in standards mode]) fire handlers in the order in which they were attached (FIFO); some browsers (IE6, IE7, IE8) fire them in reverse order (LIFO). jQuery addresses that by only attaching a single handler for each event to each element; if you attach further handlers, jQuery chains them *itself* rather than relying on the browser to do it. Prototype doesn't do that. ...when i'm running the scripts my handler comes first but doesn't prevent the other handlers to run. Do i misinterpret the event.stop() method. No, `event.stop` is meant to both stop propagation and prevent the default action -- and it does, in the normal case. Weirdly, subsequent handler don't get the event when i call event.stopImmediatePropagation(); from within my first prototype handler. I'm writing weirdly cause i couldn't find any documentation about stopImmediatePropagation() except in jQuery, any explanation to this? stopImmediatePropagation is a jQuery-only thing. If you're calling it from within a Prototype handler, you're presumably causing an exception by trying to call a function that doesn't exist. I can't see why that would prevent other handlers from running. So trying to address this with order-of-handlers is going to be a mess and I don't recommend it. There has to be another solution. However, if you're going to go down the order-of-handlers route, one option would be to use a modified version of Prototype that actually uses jQuery to hook up the handlers. This would be non-trivial, but possible. The event object jQuery passes into handlers has access to the raw event object as `event.originalEvent`, so it would be possible for you to modify Prototype so that it inserts a wrapper handler that receives the jQuery event object, uses Prototype to extend the `event.originalEvent` object, and then fires the handler using that. But it will get complicated fast (not least around `stopObserving`). Good luck, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Feb 7, 6:48 am, Mem12 memcac...@gmail.com wrote: Hello, we're working on a big web application and using prototype as well as jQuery, both are needed due to dependencies on plugins, frameworks and so on. One specific framework, Tapestry to name it, uses prototype and registers a click handler on each element, when clicked the event is stopped and a custom event is thrown which then gets processed and does the communication with the server. We show parts of an entity on a page in different sections and use optimistic locking. To prevent concurrent modification exceptions we'd like to set one section in edit mode and prevent all outside elements from being clicked. My problem is now that there're already click handler on each element and there's no way i can run a JS before that handler are registered. My first attempt was to resort the handler as i already did something similar in jQuery and it worked just fine by reading and manipulating the results of data('events'). In prototype i found this to read the handler: {{code}} var registry = Element.retrieve($(element), 'prototype_event_registry'); if(registry) { var responders = registry.get('click'); //insert new handler here responders = responders.reverse(); {{/code}} Even that's not the clean solution i'd want (preferably i'd like to insert a new handler up front) i could live with that, regrettably prototype isn't impressed by this solution and just ignores the order. So my second approach was to still read the responders but instead of inserting my new handler i first call stopObserving('click') to unregister them all, then i register my new handler and subsequent the earlier registered ones. Any suggestions how to solve this kind of problem cleaner/faster/the right way would be highly appreciated. IMHO this problem shouldn't be new or unique as i'd guess it's quite common that a later handler needs to prevent earlier registered ones from running without removing them. So the resorting at least kinda works as described above (copy responders, unregister all, register new, register old, still hopefully someone can come up with a better solution), when i'm running
[Proto-Scripty] Re: Problem with IE8 throwing Object doesn't support this property or method error
Hi, Expanding on Walter's reply, this details the problem and solution: http://www.prototypejs.org/learn/extensions Basically, Prototype can't extend DOM prototypes in IE, so any time you get a DOM element via another means (for instance, .parentNode, .firstChild, whatever), you have to be sure to run it through $() so Prototype can extend it. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jan 26, 6:46 pm, MrBaseball34 mrbasebal...@gmail.com wrote: Prototype version: 1.6.0.3 Line 4081 4061: fire: function(element, eventName, memo) { . . 4081: element.fireEvent(event.eventType, event); Yes, we are also using jQuery but this has just recently cropped up. The prototype units are the ones included with Magento v1.4.0.1. This is causing some tremendous issues with Magento logins in IE8. Any ideas how to fix 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: RegExp.match
On Jan 22, 8:54 am, Dmitry Trunikov dmitry.truni...@gmail.com wrote: ... Thank you very match. ^ ... LOL No worries! -- T.J. :-) -- 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: RegExp.match
Hi, On Jan 20, 1:06 pm, Dmitry Trunikov dmitry.truni...@gmail.com wrote: Hi ALL! how can i obtain of matched substrings in RegExp object? the prototypejs masks original RegExp.match method. the original method returns array of matched strings. the new method just returns true/false only. thanks. The JavaScript RegExp object doesn't have a `match` method at all (neither on `RegExp` nor on its prototype[1]). You're thinking of either `RegExp#exec`[2] or `String#match`[3]. [1]: http://es5.github.com/#x15.10 [2]: http://es5.github.com/#x15.10.6.2 [3]: http://es5.github.com/#x15.5.4.10 HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Questions about Function#methodize()
Hi, On Jan 15, 12:17 am, BeiMingyu cwen1...@gmail.com wrote: I‘am reading the source code of Function#methodize() (version1.7). But I can't quite understand it. 1. How can a function apply to null? code: return __method.apply(null, a); If you pass `null` or `undefined` in as the `thisArg` argument of `call` or `apply`, the global object is used as `thisArg`. (The global object is `window` on browsers.) See http://es5.github.com/#x15.3.4.3 2. want does it mean return this._methodized = function(){}? Does it meanthis._methodized = function(){}; return this._methodized? Effectively, yes. The form x = y is called an assignment expression. Like most (all?) expressions, the expression has a value: The value being assigned. And so w = x = y; means w = (x = y); Note that it's the value, not the code, that gets reused. So in x = y = foo();, the call to `foo` only happens once; the return value of `foo` is the value used in x = y = value. See http://es5.github.com/#x11.13.1 HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Select range of array items
On Jan 12, 7:14 pm, Walter Lee Davis wa...@wdstudio.com wrote: Just to point out, the $A( ) wrapper around the slice product was there because you can't guarantee an extended array in IE without it. Every other browser would be fine. No, IE allows Prototype to automagically extend arrays just fine. It's only the DOM element extensions that are not automatic in IE. This works in IE6, for instance: http://jsbin.com/afocoy All that `$A()` does in that code is needlessly duplicate the array. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Ajax.Updater insertion not working in IE
Hi, On Jan 9, 11:08 pm, Jason C jtchand...@gmail.com wrote: ...but does not work in IE9. What error(s), if any, do you see in the JavaScript console / developer tools? -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Status of prototype
Hi, On Jan 6, 12:49 pm, James Hargreaves james.hargrea...@gmail.com wrote: Hello, I note that the prototype libraries (available on prototypejs.org) have not been updated since November 2010. Indeed, nothing much seems to have been updated on the site since around then. Is prototype still an active project? Thanks Jay (Caveat: I'm not a member of the Prototype team and don't speak for them. My view of the project is from the outside, and so may be flawed. I was a bit involved with the project briefly, doing a fair bit of missing documentation with an eye toward contributing on the code front as well, but stepped away from it for various reasons a couple of years ago.) Is prototype still an active project? It depends on your perspective. Unlike some other libraries, Prototype has no corporate sponsor; no one is paid to work on it. There's been no visible activity on the project since November 2010 (the last release, and last blog entry). The previous version was 14 months earlier (September 2009). There are 105 outstanding bug reports, including some that are quite straightforward to fix (such as Prototype overwriting any native implementation of `Array#filter` and such; issue #317). Most of the people who contributed to the project in the past are not currently doing so; as far as I'm aware, only Andrew Dupont (the project lead) is even nominally on the Prototype team at this point, and he's busy with other things. Here's what Andrew had to say the last time this came up, about three months ago: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/7d434e109c23c306/547c3ed0303b4c78#547c3ed0303b4c78 My take-away here is that the project is essentially inactive -- after all, Andrew can't be expected to do all the work himself! He has a job and a mortgage and a life like the rest of us. But it could be reactivated quite quickly, really, if someone with some significant time available, and the necessary credentials to make Andrew think it made sense, stepped up and offered to take the reins alongside him. Ideally, someone or ones working for a company or companies with a significant Prototype investment that want to see the library continue and are happy to pay their engineers to work on it a bit rather than paying them to replace it with something else -- e.g., companies giving back to the project with actual paid developer time. It wouldn't take much. The project needs one person with a reasonable time commitment per week (say, 4-8 hours/week) to co-chair with Andrew, and then if (say) five of the companies that use Prototype could offer two hours of a developer's time per week triaging bug reports, fixing bugs, etc., that would make a _massive_ difference to the project. Hopefully that new co-chair could also look at some of the longer-term stuff (like using element wrappers rather than DOM element augmentation, which I know was high on Andrew's to do list). Best, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: I've a problem with my code.
Hi, First off, there's a problem with this line: element.parentNode.update(TEST); It will frequently fail in IE. You have to ensure that the element has been extended before you can use Prototype extensions like `update`: $(element.parentNode).update(TEST); This isn't a problem in other browsers, just IE. Details: http://www.prototypejs.org/learn/extensions Regarding the Uncaught TypeError: Cannot call method 'update' of null, that makes perfect sense: In this code, you ensure that all elements with class addcomment have no descendant elements at all (only a text node saying TEST2): $$('.addcomment').each(function(elementz){ elementz.update(TEST2); }); **After** which, you try to refer to the parent node of an element that *used* to be a descendant (specifically a child) of one of those addcomment elements, but which is now (as of the update above) an orphan. You took away its parent node by clearing all of the elements out of it. Minimal fix: document.observe('dom:loaded', function() { $$('.single .addcomment .comment').each(function(element){ element.observe('click', function(event){ var thisAddComment = event.findElement('.addcomment'); $$('.addcomment').each(function(elementz){ if (elementz !== thisAddComment) { elementz.update(TEST2); } }); element.parentNode.update(TEST); }); }); }); There we explicitly avoid clearing out the descendant elements of the addcomment element that contains this comment element. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jan 6, 4:45 pm, Matthew Goszcz matthew.gos...@gmail.com wrote: I'm a newcomer to prototype but every time I try to run the following... document.observe('dom:loaded', function() { $$('.single .addcomment .comment').each(function(element){ element.observe('click', function(event){ $$('.addcomment').each(function(elementz){ elementz.update(TEST2); }); element.parentNode.update(TEST); }); }); }); I get an error Uncaught TypeError: Cannot call method 'update' of null. Can you please help I'm trying to reset every .addcomment element to say TEST2 except for clicked element to say TEST, but only one element at the time can say TEST. -- 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've a problem with my code.
On Jan 6, 7:08 pm, Walter Lee Davis wa...@wdstudio.com wrote: You're probably getting something other than what you expect with the parentNode attribute there. Prototype has a lot of dom-walking methods that get around the problem of whitespace nodes and the like. You may *think* that the parentNode is an element, but it's just a space. No. By definition, a parent node is an element, document, or document fragment. Text nodes (like a space) cannot have children. What you've said can be true of a child node, a sibling, etc., but not `parentNode`. (Also note that `parentNode` is a *property*, not an *attribute*.) -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Using `element.update()` on td elements
Hi, On Dec 27, 2:35 pm, Aaron J Spetner aaron.spet...@spetnik.com wrote: Is the `update()` method intended to work on td elements? Every time I try I get an 'INVALID_STATE_ERR'. Thanks AJS Yes, Element#update works just fine on `td` elements. Example: http://jsbin.com/aqehax It even works when you use it to add/remove table cells, because Prototype does some under-the-covers stuff to make that work even on browsers which are a bit difficult about manipulating tables in that way. (But if you do things like replacing multiple table cells in a row with just one table cell without using `colspan`, results will still vary across browsers -- ex http://jsbin.com/aqehax/3 -- but that's no great surprise, and using colspan -- ex http://jsbin.com/aqehax/4 -- works.) HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: about source code Class.create()
On Dec 5, 12:53 am, BeiMingyu cwen1...@gmail.com wrote: I have a problem about the source code (version 1.7): var Class = (function() { function create() { var parent = null, properties = $A(arguments); if (Object.isFunction(properties[0])) parent = properties.shift(); function klass() { * this.initialize.apply(this, arguments); // Where has the method initialize been defined?? * }} *Where has the method initialize been defined??* It can be defined by the specification object passed into Class.create. If it isn't, a default is defined about 15 lines further down: if (!klass.prototype.initialize) klass.prototype.initialize = Prototype.emptyFunction; HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Scriptaculous page hacked?
On Dec 5, 3:27 am, Jill Elaine jillelain...@gmail.com wrote: On this page:http://madrobby.github.com/scriptaculous/draggable/ there is some hack that appears to be a link to porn? åÂÉÔÅ ÐÒÏÓÔÉÔÕÔÏË ËÁË ÈÏÔÉÔÅ. etc Who to alert to this issue? At the bottom of the page it says script.aculo.us was created by Thomas Fuchs where the name is a link to Thomas' blog. His blog has his email address. I'm not seeing the porn link (double-check me though), so I'm guessing someone already corrected it. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Where is ver. 2.0 is coming?
Other than the unnecessary assignment to `child`, doesn't look that bad to me... How would you improve it? -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Nov 30, 6:38 am, Victor vkhomyac...@gmail.com wrote: Also CoffeeScript sometimes generates very ugly code. Example: CoffeeScript: SelectParser.select_to_array = (select) - parser = new SelectParser() parser.add_node( child ) for child in select.childNodes parser.parsed Generated JavaScript: SelectParser.select_to_array = function(select) { var child, parser, _i, _len, _ref; parser = new SelectParser(); _ref = select.childNodes; for (_i = 0, _len = _ref.length; _i _len; _i++) { child = _ref[_i]; parser.add_node(child); } return parser.parsed; }; -- 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 BUG: IE8: Object::stringify
Hi, On Nov 21, 3:01 pm, tom tomsen tom.tom...@inbox.com wrote: On Windows XP with Internet Explorer 8, I came across the following situation. (http://jsfiddle.net/tCKrt/) var data = {name: 'öäöä'}; Object.toJSON(data); Every Browser returns öäöa except IE8 returns (something like) \u080\u898. (Specifically, \u00f6\u00e4\u00f6\u00e4.) It comes to the same thing, öäöä and \u00f6\u00e4\u00f6\u00e4 are *exactly* the same string. The latter is written with Unicode escape sequences, the former with literal Unicode characters. Check this out: http://jsbin.com/ecojun On Chrome, you see this: * * * * d1.name: öäöä {name:öäöä} d2.name: öäöä d1.name === d2.name? true * * * * On IE8, you see this: * * * * d1.name: öäöä {name:\u00f6\u00e4\u00f6\u00e4} d2.name: öäöä d1.name === d2.name? true * * * * Note the last line. To fix that Problem I had to modify Object::stringify(): function stringify(object) { var string = JSON.stringify(object); return unescape(string.replace(/\\u/g, '%u')); } Well first, there is no problem, and thus no need for a fix. :-) IE8 just uses escape sequences rather than literal characters. But secondly, your fix will tend to mess up anything in your string that starts with a '%' and is followed by 2-4 hex digits. Separately, `escape` and `unescape` were deprecated years ago and shouldn't be used. If you really, really want to use Unicode literals, you'd want: function stringify(object) { var string = JSON.stringify(object); return string.replace(/\\u([0-9A-Za-z]{2,4})/g, function(m, c0) { return String.fromCharCode(parseInt(c0, 16)); }); } ...or similar. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Prototype AJAX call IE6 - not working
Hi, It would have been really helpful if you'd pointed out which line was line 37, since things tend to get re-wrapped. :-) But the problem is here: onException: function(response) { alert(Failed + response.responseText); }, ---^ That dangling comma at the end of the object literal you're passing into Ajax.Request. Most JavaScript engines are fine with it, and it's now even officially supported (there was some ambiguity before the ECMAScript 5th ed. spec came out a couple of years ago), but older versions of IE choke on it. Remove the dangling comma and it should stop complaining. There's a similar problem with dangling commas at the ends of array literals (e.g., given `var a = [1, 2, 3, ];`, what's the length of `a`?). More: http://blog.niftysnippets.org/2010/09/literal-improvement.html HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Nov 8, 8:36 pm, Jessica Smith jazz...@gmail.com wrote: Hi, I'm a total n00b when it comes to AJAX and Prototype. I do have an example that works in IE7+, FF and Chrome, but not IE6. I'm getting the following JS error when I include the function in my test page. I tried including the XMLHttpRequest section thinking that might be part of my problem, but it doesn't make a difference. Any suggestions are welcome. [error] Line: 37 Char: 5 Error: Expected identifier, string or number Code: 0 [/error] [code] html head titlef1/title script type=text/javascript if (!window.XMLHttpRequest) { window.XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP'); }} /script script type=text/javascript src=prototype.js/script script type=text/javascript var cdInterval=0; var cdTime=cdInterval+1; function changeCart(cartname) { alert(cartname); document.getElementById(cartname).innerHTML = cartname; //setTimeout(ajaxlastcall(),500); } function ajaxlastcall() { url = http://devmachineurl/sid.htm? sid=6680prg=menuframe=lastcall; new Ajax.Request(url, { onSuccess: function(response) { var data = response.responseXML.getElementsByTagName( 'LastCallData' ); for( var i = 0; i data.length; i++ ) { var interval = data[i].getAttribute( 'interval' ) - 0; var lastcall = data[i].getAttribute( 'lastcall' ); } if (interval == 0) document.getElementById(lct).innerHTML=lastcall; else startit(interval,lastcall); }, onException: function(response) { alert(Failed + response.responseText); }, }); } /script /head body div id=cartnamePlease select a cart./div input type=hidden id=toggleval name=toggleval value=yes /body /html [/code] -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Element.replace get top node of replaced content
On Nov 4, 5:30 pm, vhochstein vhochst...@googlemail.com wrote: Hi, if I call old_element = Element.replace(element, 'html code for new element') I get the old_element in response. How may I get the new_element node if it does nt have an id attribute? Thanks a lot in advance. -- Volker Well, you could find it through the hierarchy or some such, but probably the easiest thing is to get a reference to it *before* you replace it: var new_element = new Element('tagName').update('contents'); Element.replace(old_element, new_element); Live example: http://jsbin.com/uwibuh HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Done but with errors on when page loads.
On Oct 28, 2:31 pm, DeveloperDavid d.smith38h...@gmail.com wrote: Message: Object doesn't support this property or method Have a read through this tutorial from the prototypejs.org site: http://prototypejs.org/learn/extensions Elements can be automagically extended on other browsers, but not IE. You have to make sure you're dealing with an extended one. All elements you get via Prototype are pre-extended for you, but if you create or retrieve them via other means, they won't be. See the article for details. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Rant - IE7 Sucks
On Oct 27, 3:46 pm, Victor vkhomyac...@gmail.com wrote: I think there is some problem in your code... I suspect so as well, which is why a couple of days ago I asked him to post a self-contained example to http://jsbin.com. -- T.J. ;-) -- 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.Serialize returning nada
On Oct 25, 2:18 pm, ColinFine colin.f...@pace.com wrote: Your 'serialize()' is called when you _define_ dofill. No, it'll get called each time he _calls_ `dofill`. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Rant - IE7 Sucks
Can you post a self-contained example to http://jsbin.com? -- T.J. On Oct 25, 6:10 pm, kstubs kst...@gmail.com wrote: I may have to repost, but I'll state what I think the issue may be here first. OK, so IE7. I have a class and I mixin an object called SimpleForms. These methods are not available in the intialize method for the class. So, var myClass = Class.create(SimpleForms, { initialize: function() { this.SimpleForms_Method('xyz');' } }); Code errors on the call to: this.SimpleForms_Method in IE7 only. Is this an IE7 issue? Is this a Prototype bug, or know IE7 limitation? Karl.. -- 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: Future of Prototyp.js
On Oct 23, 6:01 am, buda www...@pochta.ru wrote: IE6 is already innonexistence. Whether IE6 remains relevant depends a great deal on where you look and whom you're targeting. If you look at the figures on http://ie6countdown.com, you see that if you're targeting east asia, you'd be an idiot not to support IE6. Similarly, that 2.2% in the UK is a misleading figure, because although small in itself, it consists of very large government departments -- so if your site/application is targeted at those departments, you're still stuck with IE6 support. You get the idea. :-) The rapid development of browser features they caught up and there are fewer and fewer differences between them. A year later, they practically do not remain. Where are you getting that information? There still remain significant and problematic differences between browsers from different vendors. Heck, IE8 (nearly 30% of the desktop market[1]) and below don't even support `addEventListener`, making Prototype's handling of that difference very important indeed. Yes, in a year I'd expect IE9 to be much higher on that list than it is currently because even Microsoft users are getting the idea of updating more often, but I suspect IE8 will still be above it. Separately, I think the premise that most of Prototype is about working around outdated browser differences is (respectfully) incorrect. Most of Prototype is around adding useful utility functionality. Some of it is about smoothing out differences (such as how opacity is specified in various browsers), but mostly it's about simplifying and expanding on what's common across browsers (for instance, the DOM navigation stuff). My two cents. :-) [1] http://marketshare.hitslink.com/browser-market-share.aspx?qprid=2qpcustomd=0 -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Object.isArray should be changed
On Oct 23, 6:25 am, buda www...@pochta.ru wrote: I've noticed that library's isArray not worked properly sometimes. When? A statement like that really requires data. I suspect where you haven't seen it work, the object genuinely isn't an array. Prototype's `Object.isArray` function relies on the JavaScript engine correctly implementing the specification for `Object.prototype.toString` (Section 15.2.4.2[1]). I've never met an engine that didn't implement that correctly. In contrast, your implementation gives false negatives on any browser that hasn't yet implemented the new `forEach` array prototype method from ECMAScript5 (so, IE8 and downward), and gives false positives on any object that just happens to have a property called `forEach`. Respectfully, the Prototype implementation is much more robust. [1] http://es5.github.com/#x15.2.4.2 -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Object.isArray should be changed
Hi again, Sorry, I was talking about Prototype 1.7's version of `isArray`. I suddenly had a thought just now, so I checked and found that Prototype 1.6 used a different (and naive) definition which has known issues; presumably those issues are why 1.7's version has been updated. So if you're using 1.6, you may well see a false negative on a real array instance. (Specifically, any array received from another window will result in a false negative.) I'm surprised that 1.6 had that problem, but it's good to see that 1.7 fixes it. If you want to apply the fix to your projects without upgrading from 1.6 to 1.7, here's a cheap and easy way: (function() { var toString = Object.prototype.toString; Object.isArray = function(obj) { return toString.call(obj) === [object Array]; // Capitalization matters }; })(); HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Oct 23, 12:54 pm, T.J. Crowder t...@crowdersoftware.com wrote: On Oct 23, 6:25 am, buda www...@pochta.ru wrote: I've noticed that library's isArray not worked properly sometimes. When? A statement like that really requires data. I suspect where you haven't seen it work, the object genuinely isn't an array. Prototype's `Object.isArray` function relies on the JavaScript engine correctly implementing the specification for `Object.prototype.toString` (Section 15.2.4.2[1]). I've never met an engine that didn't implement that correctly. In contrast, your implementation gives false negatives on any browser that hasn't yet implemented the new `forEach` array prototype method from ECMAScript5 (so, IE8 and downward), and gives false positives on any object that just happens to have a property called `forEach`. Respectfully, the Prototype implementation is much more robust. [1]http://es5.github.com/#x15.2.4.2 -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Future of Prototyp.js
Hi, On Oct 23, 5:35 pm, wwwboy www...@pochta.ru wrote: With the speed of which modern browsers release updates and move toward HTML5 - I think there will be no significant differences between them in a year. IE8 will not be alive in a year in the light of Windows8 with IE10 and canceling support XP - so there will be IE9 and IE10 which a close to other browsers. I think you're being very optimistic there, particularly with regard to how quickly Windows users will upgrade. An optional ability to build library without of support of old browsers will be the big advance for most developers - small size, fast execution! Again, what makes you think that legacy support is a significant fraction of the library? I suggest reading through the source, the vast majority of it is utility functionality, not cross-browser workarounds. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: strange problem with detect method and cloning data
Hi, On Oct 20, 3:33 am, buda www...@pochta.ru wrote: T.J. here is the example of using instance private vaiables store in use -http://jsfiddle.net/QW8vM/17/ FWIW, that code refers to an undefined symbol `_items` in the property getter function. Also note that it has a memory leak: `destroy` releases the `items` on the private variables object you create for every instance, but doesn't actually release the private variables object itself or the array entry associated with it. So every instance creation/destruction will leak a small amount of memory and as time goes by, the array will get more and more bogged down in abandoned entries. Here's a version without those issues (note that `_privates` is now just an object, not an array, and see also changes in `destroy`): http://jsbin.com/ewoniq Unless you're going to have lots and lots of these objects in memory at the same time (like, thousands), I'd *strongly recommend* you avoid this pattern. Instead, just define `add` and `indexOf` within `initialize` and have them use `_items` (the local var in `initialize`) directly. This increases the overhead per instance (because each and every instance gets its own `add` and `indexOf` functions), but avoids requiring the `destroy` call. Example: http://jsbin.com/ewoniq/2 FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: strange problem with detect method and cloning data
On Oct 21, 2:03 pm, buda www...@pochta.ru wrote: About not using such pattern - I agree if only few methods need to access _privates, but what if an object has about 10 or more methods that manipulate _privates!? make them all per instance? It depends entirely on how many instances you expect to have. If thousands, enable function reuse (I just tend to use a naming convention rather than true private variables); if dozens, probably just go ahead and duplicate the methods. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: strange problem with detect method and cloning data
On Oct 18, 6:01 am, buda www...@pochta.ru wrote: here the code http://jsfiddle.net/QW8vM/10/ `Object.clone` returns a raw object with a shallow copy of the properties of the object you give it. It is not a perfect copy of the object down to the prototype level: var a, b; a = [1, 2, 3]; b = Object.clone(a); display(Object.isArray(a): + Object.isArray(a)); // true display(Object.isArray(b): + Object.isArray(b)); // false === If you want to copy an array, use Array#slice (but note that it only copies numeric properties, so if you've added non-numeric properties to the array, you'll have to handle them): var a, b; a = [1, 2, 3]; b = a.slice(0); // Copy the array display(Object.isArray(a): + Object.isArray(a)); // true display(a = + a.join(, )); // 1, 2, 3 display(Object.isArray(b): + Object.isArray(b)); // true display(b = + b.join(, )); // 1, 2, 3 Here's a working version of your fiddle: http://jsfiddle.net/QW8vM/11/ Somewhat off-topic, but I find that `a` constructor very odd. `add` always adds to a central array shared by all instances created by the `a` constructor, but *every access* to the `items` property *copies* that central array. Making a copy of an array on property access is very surprising behavior, that's normally the sort of thing a function is for. Consider: var foo = new a(); var x = foo.items; var y = foo.items; Anyone reading that could would expect that `x` and `y` referred to the same array, but of course they don't in the case of your `a` constructor. Very surprising. Similarly: var one = new a(); var two = new a(); one.add(foo); one.add(bar); alert(two.items.length); // 2?!?! I haven't added anything to `two`! I'm curious what the use-case is... HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: strange problem with detect method and cloning data
On Oct 18, 10:29 am, buda www...@pochta.ru wrote: that sample was to demonstarte Object.clone bug :) It's not a bug, though I'd say detecting that it's being fed an array wouldn't be a bad feature to add. Usually I us to var a = Class.create((function() { var _privates = []; function initialize() { _privates.push({}); this.internalId = _privates.length-1; _privates[this.internalId].items = []; -- here the instances items ... How do you ever clean up the private data for instances that have been released and reclaimed by the GC? Some kind of destroy contract and hope you don't miss out a destroy call? -- T.J. -- 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 created object is not extended with Object methods?
On Oct 18, 8:30 am, buda www...@pochta.ru wrote: I try var o = {}; o.name = 'propertyName'; alert(o.keys); -- undefined why? but in debugger I see that Object has all methods, but o - not! `keys` is not an instance method, it's a method of the `Object` function: alert(Object.keys(o)); // name You're confusing `Object` with `Object.prototype`. The properties of `Object` are not inherited by object instances; the properties of `Object.prototype` are. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Why created object is not extended with Object methods?
On Oct 18, 3:08 pm, buda www...@pochta.ru wrote: T.J. what the reasons not to make them Object.prtototype methods? If you add something to `Object.prototype`, it shows up on *every* object. So for instance: Object.prototype.foo = function() { return bar; }; var a = {}; console.log(typeof a.foo); // - function for (var name in a) { console.log(name); } // - foo To put it mildly, this causes a problem because people expect a blank object to be, um, blank. And in fact, you see people repeatedly running into problems with Prototype's additions to `Array.prototype` because they're using `for..in` incorrectly[1][2]. Compare the output of this page: http://jsbin.com/ajiyal with this one: http://jsbin.com/ajiyal/2 The code is identical in the two pages, it's just that the second one includes Prototype and the first one doesn't. Since Prototype adds a bunch of `Array.prototype` properties, they show up on that naive (broken) `for..in` loop. As of ECMAScript5 it's possible to put properties on `Object.prototype` (and `Array.prototype`) that *won't* break naive `for..in` loops by using `Object.defineProperty` and setting `enumerable` to `false`, but there's still the problem that people expect a blank object to be blank. And so if (for instance) you put a `keys` property on `Object.prototype` that refers to a function that returns the object's keys, but I have code where I use a `keys` property on an object to mean something else entirely (very likely, and in fact I *have* done it), there's a problem. For that reason, the list of properties defined for `Object.prototype` in the spec[3] is very short and likely to stay that way, in favor of properties defined on `Object` that you pass an instance into (like `Object.keys`). [1] http://blog.niftysnippets.org/2010/11/myths-and-realities-of-forin.html [2] http://api.prototypejs.org/language/Array/ [3] http://es5.github.com/#x15.2.4 HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: err fred.loginfo is not function.
Hi, You haven't given your `player` object a method called `loginfo` at all, which is why you're getting that error (the property `fred.loginfo` will come back `undefined`, which naturally fails when you try to execute it via `()`). Also, you have a typo where you're creating your `promote` function, it's a `promte` instead, so if you got past the `loginfo` call you'd run into the same problem with `promote`. And note that in your test code at the end, you create `bob` and `alice` instances but you continue to call the methods on the `fred` instance. You said you're a new programmer. One thing to take away from this is that computers are incredibly picky about small details. :-) FYI, if a function is a constructor function (intended to be used with `new`, like your `player` function), the convention is to use initial caps on the name, e.g. `Player` with a capital `P`. Other functions are written in camelCase. This helps differentiate functions that aren't constructor functions from ones that are. It's only a convention, but it's very widely-used. If you're new to JavaScript, I did a series of blog posts/articles on the language you may find helpful (or not, of course). If you start here[1] and then work your way forward through the posts chronologically, it may be helpful. [1] http://blog.niftysnippets.org/2008/02/javascripts-curiously-powerful-or.html HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Oct 16, 6:55 pm, Yossi rness...@gmail.com wrote: HI, I am new programmer. I looking to work with OOP in javascript. I heard about prototypejs, and I try to run my first CODE in firefox7.0.1 And Prototype JavaScript framework, version 1.7 . The err that I got is fred.loginfo is not function below the code: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head script type=text/javascript src=/prototype_js/prototype.js/ script title/title /head body script language=javascript type=text/javascript function player(n,s,r){ this.name=n; this.score=s; this.rank=r; } player.prototype.promte=function(){ this.rank++; console.log(my new rank is: ,this.rank); } var fred=new player(fred,1,5); fred.loginfo(); fred.promote(); var bob=new player(bob,50,1); fred.loginfo(); fred.promote(); var alise=new player(alise,233,33); fred.loginfo(); fred.promote(); /script /body /html -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-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: method ON vs OBSERVE
On Oct 16, 2:45 pm, clockworkgeek nonproffessio...@clockworkgeek.com wrote: I find IE doesn't bubble it's field-related events properly so you still need to use `observe` for those cases. As a fix I suppose 'on' could search it's children for fields and manually apply `observe` on those but it wouldn't be ideal, dynamically added fields would be exempt. IE doesn't bubble `focus` or `blur`, but it does bubble the IE- specific `focusin` and `focusout` events. jQuery maps `focus` to `focusin` (and similarly for `blur`/`focusout`) in its event delegation stuff. I think that would be a better way to go. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: strange problem with detect method and cloning data
Hi, The code you've quoted has a variety of syntax errors and typos, such as using `function initialize()` within an object literal (which results in an Unexpected identifier error) and using `Class.Create` rather than `Class.create`. It's very hard to help when the code presented is fundamentally broken and yet reported as working. I recommend going back to first principles, building a minimal failing test case, and if you don't solve the problem in the course of doing that (which frequently happens), putting it on jsbin.com or jsfiddle.net or similar and then linking to it so people can help you. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Oct 17, 3:37 am, buda www...@pochta.ru wrote: I have a class var a = Class.Create({ function initialize() { var _items = []; Object.defineProperties(this, { 'items': { get: function () { return Object.clone(_items); }, enumerable: true } }); ...} function indexOf(item) { return -1; } }); then I create an instance of the class var b = new a(); then I fill the _items with the data [ { name: 'Joe', last: 'Celko' }, { name: 'Ivan', last: 'Susanin' } ] and ovewrite the indexOf method with thw new one b.indexOf = function(item) { var index = -1; var items = this.items; items.detect(function(el, idx) { var b = (el.name === item.name) (el.last === item.last); b (index = idx); return b; }); return index; }; then i try to seach b.indexOf({ name: 'Joe', last: 'Celko' }); and always get -1 !!! I try to debug and detect the this._each in Enumerable.each never goes into, but if I chnge return Object.clone(_items); --- return _items; everything goes ok and returns 0! Why? Help me please. I cannot expose original items because changes on it maybe damaged -- 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 problem with detect method and cloning data
On Oct 17, 10:17 am, T.J. Crowder t...@crowdersoftware.com wrote: It's very hard to help when the code presented is fundamentally broken and yet reported as working. Sorry, in print that comes across much more harshly than it was intended to. I only mean that it's easier to help debug code that's a bit more cleaned up, wasn't meant as a dig. -- T.J. -- 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: method ON vs OBSERVE
Hi, On Oct 11, 3:13 pm, Miguel Beltran R. yourpa...@gmail.com wrote: Using prototype 1.7 I try to figure what is better, the new ON method or OBSERVE method but the only thing I found is that ON is better if you wish use an CSS selector and/or stopObserve am I correct? or observe is going to be deprecated? `on` is just like `observe` if you don't pass it a filtering selector (except that it's more indirect; it eventually ends up calling `observe` under the covers), but I can't imagine `observe` is going to be deprecated. Both have mechanisms for stopping event handlers. With `on` you stop it by calling `stop` on the `EventHandler` object it returns to you; with `observe` you call `stopObserving` with the same arguments you gave `observe` (or fewer, if you want to have a broader effect). The claim is that `on` is useful because you don't have to remember the event handler function if you need to stop it later, but since you have to remember the `EventHandler` instance `on` returns to you, I'm not seeing any net benefit in that sense. `on`'s real use is event delegation IMHO. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Silly Question
On Oct 11, 12:04 am, nelian i...@myskills.co.za wrote: I am somewhat new to AJAX, but one thing that I have not touch upon is the following - When my App is making an AJAX call, from the users perspective it seems to be doing nothing, how does one go about freezing the page (Not sure what else to call it) and indicate to the user that something is happening? (I have seen it on a couple of sites, but cannot seem to find an example at the moment) Thanks in advance for the help Ian Not a silly question at all. When you want to show something modal on the page, what you need to do is mask the page so that nothing reacts to clicks and such, and then put your modal thing above the mask (so the user can interact with it, and so it's not greyed-out if you use opacity on the mask to make everything a bit dimmer). Because things like Flash and Java applets and (on some browsers) form controls disobey the usual z-index CSS stuff, putting the mask on the page requires that you play a bit of a game: You put another entire _window_ in the way. This is called the iframe shim trick. An iframe creates a different window, but participates in the z-index ordering of your page. Here's[1] an answer I gave on Stack Overflow to a similar question using jQuery which goes into the details a bit, and here's[2] a Prototype translation of the example. As I say in the answer on SO, this example isn't perfect by any means, that's what the various libraries that do this for you are for, but it should get you started. HTH, [1] http://stackoverflow.com/questions/4868412/show-modal-dialog-with-x-without-using-jqueryui/4868514#4868514 [2] http://jsbin.com/ocobu4/4 -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Pimp my code!
Hi, On Oct 8, 6:30 pm, Walter Lee Davis wa...@wdstudio.com wrote: What's a more idiomatic way to write this: Element.addMethods({ toggleClassName: function(element, className){ var element = $(element); (element.hasClassName(className)) ? element.removeClassName(className) : element.addClassName(className); return element; } }); This works, but it's got that really long line in the middle. How do you do what PHP calls a variable variable in JavaScript to execute the correct method (add/remove) based on the input without writing it all out long-hand? Walter You are aware that Prototype *has* `toggleClassName` already[1], right? And in fact, I think the current implementation of it answers your question about variable variables: toggleClassName: function(element, className) { if (!(element = $(element))) return; return Element[Element.hasClassName(element, className) ? 'removeClassName' : 'addClassName'](element, className); }, That works because as you probably know, you can refer to an object property using a literal with dotted syntax: x = obj.foo; ...or with a string using bracketed syntax: x = obj['foo']; The latter opens up the possibility of using an expression for the string: x = obj[flag ? 'foo' : 'bar']; And of course, what we think of as methods aren't really methods at all[2], they're just functions assigned to properties, and so: obj[flag ? 'foo' : 'bar'](); ...will call `obj.foo()` or `obj.bar()` depending on the value of `flag`. That's what the Prototype version of `toggleClassName` does, it calls `removeClassName` or `addClassName` based on the result of calling `hasClassName`. This form of variable variables only works with object properties, but I find that it applies in 99% of the situations I'd want it. [1] http://api.prototypejs.org/dom/Element/toggleClassName/ [2] http://blog.niftysnippets.org/2008/03/mythical-methods.html HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: The order of iteration with Hash objects.
On Oct 5, 2:39 pm, Shane McCarron halindr...@gmail.com wrote: If the sorted order of the hash keys isn't what you want, you might also consider assigning ordinals as part of the hash key. Assuming you have less than 1 hash keys, I would do something like _myKey as a key, where is a number that you increase each time you put an item into the hash. You'd still have to sort the keys after retrieving them, they won't be guaranteed to be iterated in order. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: The order of iteration with Hash objects.
On Oct 4, 5:38 pm, surge gera...@gmail.com wrote: I have this nasty problem with hashes. IE 8 disregards the order of hash element declarations and when I do hash_name.each(), the result is out of order so to speak -- although I know that the order is not guaranteed. What's the best solution if I want to stay with hashes? You said it yourself: The order is not guaranteed. It could change from one dot release of the browser to the next. If you need a specific order, you need to get the keys (Hash#keys[1]) and sort them (Array#sort[2]), then loop through them in their (now) sorted order. [1] http://api.prototypejs.org/language/Hash/prototype/keys/ [2] http://es5.github.com/#x15.4.4.11 -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Instance methods and stopObserve
Hi, Two things: 1. It's `stopObserving`[1], not `stopObserve`. So that's kind of going to be an issue right there. ;-) The error should be showing up in the error console. 2. If you pass a function reference into `stopObserving` in order to tell it to stop using that particular function, it has to be the *same* function you gave `observe`. But that's not what you're doing. `bindAsEventListener` returns a *new* function that will, when called, call your original function with the `this` value and arguments you give (and the event argument). So you have to give that same function reference to `stopObserving`: a_function: function() { // my instance method var some_bound_function = (function() { // only need to do this once Event.stopObserve(document, 'some:custom_dom_event', some_bound_function); // here we do something ... }).bindAsEventListener(this); Event.observe(document, 'some:custom_dom_event', some_bound_function); SomeComponent.CallSomeFunction(); // in turn will fire the event 'some:custom_dom_event' } Or what I'd more likely do, because I don't like anonymous functions[2]: a_function: function() { // my instance method var some_bound_function = some_function.bindAsEventListener(this); Event.observe(document, 'some:custom_dom_event', some_bound_function); SomeComponent.CallSomeFunction(); // in turn will fire the event 'some:custom_dom_event' function some_function() { // only need to do this once Event.stopObserve(document, 'some:custom_dom_event', some_bound_function); // here we do something ... } } (Actually I'd take it a step further so that the function you're assigning to `a_function` isn't anonymous either, but that's off- topic.) [1] http://api.prototypejs.org/dom/Event/stopObserving/ [2] http://blog.niftysnippets.org/2010/03/anonymouses-anonymous.html -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Oct 2, 12:44 pm, kstubs kst...@gmail.com wrote: Subject line correction: Instance methods and stopObserve Consider correction: Event.bindAsEventListener(document, 'some:custom_dom_event', this); Should be: Event.observe(document, 'some:custom_dom_event', some_function.bindAsEventListener(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: Future of Prototype.js
On Sep 30, 3:58 am, Marty Amberg mar...@edenstreet.com wrote: Might have been asleep during my previous google searches but I found tj's sitehttp://proto-scripty.wikidot.comtoday which seems like answers questions of what I would want and think prototype needs to grow. No sense in reinventing something that is there which is what I ahd posted before. A place for solid examples and other useful things. Yeah, http://proto-scripty.wikidot.com is something people can use. Not really my site, it's meant to be the community's. Before he disappeared, Tobie was talking about migrating that content into the new prototypejs.org site hosted on GitHub (where it's easy for anyone to contribute via pull-request), which I think was and is a great idea. WikiDot has gotten very aggressive with ads and most programmers know enough markdown that it's familiar to them. On Sep 30, 2:43 am, ncubica ncub...@gmail.com wrote: ok ... So T.J. I know you not have the ultimate decision for designate a candidate for any position at Prototype community but certanly you are the most near with the core team. So I would like to know if you could email one of them and try to start designate person for revitalize this community... Andrew reads the list and of course anyone can send him an email directly, but sure, I'll drop him a note calling his attention to this thread. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Future of Prototype.js
On Sep 27, 5:00 am, Marty Amberg mar...@edenstreet.com wrote: I was thinking today that besides better documentation, It be nice having a site where one can go and download actual rl examples. Yeah, I'd probably like to see either hosted examples on the documentation pages themselves, or callouts to jsbin.com or jsfiddle.net. One more thing. Chevy and Ford and Honda, make lots of cars but that does not mean they produce the best vehicles. Absolutely. But when a business is making a decision about a fleet purchase, you can bet they're looking closely not only at the fuel economy and reliability of the actual vehicles, but at the stability and forecast longevity of the company behind them. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Snap for scriptaculous sortable
On Sep 26, 10:18 am, Vaji vajiram...@gmail.com wrote: Any timely help would be much more appreciated. Strongly recommend dropping the word timely from messages like this in future. It's downright rude. You're asking for _help_, the timeframe on which someone takes their precious time to help you is completely and totally up to them. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Snap for scriptaculous sortable
On Sep 26, 10:18 am, Vaji vajiram...@gmail.com wrote: Any timely help would be much more appreciated. Recommend dropping the word timely from messages like this in future. You're asking for _help_, the timeframe on which someone takes their precious time to help you is completely and totally up to them. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Future of Prototype.js
Hi Nahum, On Sep 24, 2:49 am, ncubica ncub...@gmail.com wrote: Hi TJ, I would like to help in the implementation of the UI interface for prototype, who do you think can lead this feature? It would be Andrew or some volunteer he nominates. I can't volunteer for it, I'm over-committed and would just end up wasting people's time. Specifically with regard to UI, the first question will be whether you're going to help Thomas with Script.aculo.us[1] (e.g., the official UI-related stuff for Prototype), and/or help Sébastien, Samuel, Yurij, and Vincent with Prototype UI[2], or help Ryan with LivePipe[3], or (radical approach) port jQuery UI[4] to Prototype, etc. (I'm sure the latter is a big project, but you get the benefit of the fact jQuery UI is fairly broad and well-established, and the jQuery UI team is a good size and has some funding.[5]) Prototype also really needs a skilled, engaged webmaster. Before his other commitments required his time elsewhere, Tobie was working on moving prototypejs.org to Github Pages[6], which would make updates to it basically a matter of pushing a commit (or sending a pull request for one). But probably more than anything else, Prototype needs an engaged leader again. The project lagged for a long time after Sam (Stephenson, not Samuel Lebeau) went on to other things, and then he finally officially handed the baton to Andrew and Tobie, but Tobie got a new job and life changes, etc., and I don't know what (if any) time he has for this, and Andrew's commented on his other demands. Is there someone with sufficient knowledge, skill, and time to join them and actively lead the project? I'd say doing it properly would require a minimum of eight hours/week, every week: Fixing bugs, coordinating fixes from other contributors, dealing with the website, determining and actioning Prototype 2, etc., etc. It's a big commitment. FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com [1] http://madrobby.github.com/scriptaculous/contribute/ [2] http://prototype-ui.com/ [3] http://livepipe.net/ [4] http://jqueryui.com [5] http://jqueryui.com/about [6] http://pages.github.com/ On Sep 24, 2:49 am, ncubica ncub...@gmail.com wrote: Hi TJ, I would like to help in the implementation of the UI interface for prototype, who do you think can lead this feature? I'm think I'm best using prototype than working on the core, I could help in this stage, and also I would love a renaissance of protoype. I think in the same way of you... we have to do something in a way of help Andrew... Best Nahum On Sep 23, 11:19 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, This was _JUST_ gone into, in depth:http://groups.google.com/group/prototype-scriptaculous/browse_thread/... I think this is a fair-ish (but incomplete) summary: 1. Prototype is a spare-time activity for a very small number of people. In fact, at the moment I think it's mostly just Andrew, and he has other things he does (like, you know, hold down a full-time job). Just recently the project largely lost another major contributor to his job and family commitments. 2. Andrew has no plans to stop working on Prototype on any time soon. 3. Prototype work is done in fits and spurts, long periods of inactivity followed by a period (couple of weeks) of feverish activity. 4. jQuery has multiple corporate sponsors, not least Microsoft, and there are people paid to work on it full time. Thus it's able to be much more up-to-date and proactive than Prototype. A quote from Andrew in the thread linked above: On Aug 23, 1:07 am, Andrew Dupont googlegro...@andrewdupont.net wrote: I will say, though, that if we're crowning winners and losers, then jQuery won a long time ago. It is certainly the _de facto_ JavaScript library for web development. The good news is that the losers of the war aren't looking so bad; libraries like Prototype, MooTools, and Dojo still have loyal user bases, and I doubt they're going away. My personal perspective, for what it's worth (e.g., possibly exactly what you're paying for it, nothing :-) ) is based on some data points: 1. The last blog post on the Prototype blog was 10 months ago. 2. The library has had basically no activity since v1.7 was released November 2010. 3. The most recent three releases were: v1.7 - November 2010 v1.6.1 - September 2009 v1.6.0.3 - September 2008 Three releases, in total, including dot releases, in the last three years. Compare with 16 releases (four major ones) of jQuery in that time period (v1.3 through v1.6.4). 4. Absolute use and trends: Absolute use:http://trends.builtwith.com/javascript Prototype trend:http://trends.builtwith.com/javascript/Prototype jQuery trend:http://trends.builtwith.com/javascript/JQuery 5. Questions tagged on StackOverflow: jQuery: 114,842 Prototype: 2,152 ...which could
[Proto-Scripty] Re: Future of Prototype.js
, then it will have a different kind of future. I hope all these recent questions about Prototype's future mark the beginning of a renaissance for the library, a turning point of talent looking to help out. I wish I could be part of it. Best, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Sep 23, 12:34 pm, buda www...@pochta.ru wrote: It has long heard nothing about plans for the future. Browsers are evolving, and many library functions are duplicate the functions of JavaScript. Already implemented in all browsers support ECMAScript 5, but the library is not reflected. I would like to be able to not pull in hundreds of kilobytes to support older browsers and have only the functionality you need - as it is implemented in other libraries like JQuery. What is the future of Prototype.js? Is it live or dead? Should I start to learn JQuery? -- 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: Future of Prototype.js
Hi, I should have said: If you do decide to switch, beware that jQuery only covers about 3/4ths of the ground Prototype covers. It does all the DOM stuff, but doesn't do much of anything in terms of language enhancement. So no equivalent to `Class`, for example, nor any of the added methods on `Array`, `String`, or `Function`. (It does have a subset of those on offer, just not as extensions to the built-ins -- for instance, `jQuery.trim` rather than `String#strip`, `jQuery.proxy` rather than `Function#bind`). If you need a `Class`-like thing, I did one you might look at: http://blog.niftysnippets.org/2009/09/simple-efficient-supercalls-in.html My main point being: jQuery is great, but its scope isn't as broad. In some ways that may be what you want with this ECMAScript5 stuff coming in -- or not. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Sep 23, 5:19 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, This was _JUST_ gone into, in depth:http://groups.google.com/group/prototype-scriptaculous/browse_thread/... I think this is a fair-ish (but incomplete) summary: 1. Prototype is a spare-time activity for a very small number of people. In fact, at the moment I think it's mostly just Andrew, and he has other things he does (like, you know, hold down a full-time job). Just recently the project largely lost another major contributor to his job and family commitments. 2. Andrew has no plans to stop working on Prototype on any time soon. 3. Prototype work is done in fits and spurts, long periods of inactivity followed by a period (couple of weeks) of feverish activity. 4. jQuery has multiple corporate sponsors, not least Microsoft, and there are people paid to work on it full time. Thus it's able to be much more up-to-date and proactive than Prototype. A quote from Andrew in the thread linked above: On Aug 23, 1:07 am, Andrew Dupont googlegro...@andrewdupont.net wrote: I will say, though, that if we're crowning winners and losers, then jQuery won a long time ago. It is certainly the _de facto_ JavaScript library for web development. The good news is that the losers of the war aren't looking so bad; libraries like Prototype, MooTools, and Dojo still have loyal user bases, and I doubt they're going away. My personal perspective, for what it's worth (e.g., possibly exactly what you're paying for it, nothing :-) ) is based on some data points: 1. The last blog post on the Prototype blog was 10 months ago. 2. The library has had basically no activity since v1.7 was released November 2010. 3. The most recent three releases were: v1.7 - November 2010 v1.6.1 - September 2009 v1.6.0.3 - September 2008 Three releases, in total, including dot releases, in the last three years. Compare with 16 releases (four major ones) of jQuery in that time period (v1.3 through v1.6.4). 4. Absolute use and trends: Absolute use:http://trends.builtwith.com/javascript Prototype trend:http://trends.builtwith.com/javascript/Prototype jQuery trend:http://trends.builtwith.com/javascript/JQuery 5. Questions tagged on StackOverflow: jQuery: 114,842 Prototype: 2,152 ...which could, of course, just mean that Prototype is so much better it generates fewer questions, or that people using Prototype don't use StackOverflow, or that people are mis-tagging JavaScript questions jquery (I see that a fair bit), or some combination of those. Does all this mean Prototype is dead? No, not a bit of it. But it has a very small staff with other major demands on their time, and has no funding. Andrew's quite clear that it's not dead, and also that it will continue in much the way it has these last three years. I made the business, not technical, decision years ago to use jQuery rather than Prototype. In many ways I prefer Prototype, although there are some good ideas in jQuery (also some phenomenally bad ones, such as how overloaded the API is). I still pitch in and moderate this mailing list, and still answer questions, but for me the business case is: Which library amongst the large number out there is kept up-to- date; jumps on testing new browser versions for compatibility; has a large ecosystem of code I can use; has a large pool of talent I can hire or contract; has well-maintained, frequently updated and extended, reliable, and documented UI helpers (jQueryUI vs. Script.aculo.us); and is likely to be around long-term without heroic effort from a single individual, or a small set of individuals. So I went with jQuery, despite preferring Prototype in many ways. [I also looked at Dojo, ExtJS, (more recently) Closure, and a few others.] It could have gone another way. People like me could have done more to contribute to the project; leadership could have focussed on core functionality, community-building, and developer (um) development rather than side-issues; corporate sponsorship
[Proto-Scripty] Re: Can a Template Escape HTML entities in Fields?
Hi, No, the Template class has nothing built-in to do that. I suggested adding something to do it years ago[1] (and even created a patch, link in the ticket), but it never went anywhere. You might grab the patch and look at it, I don't think the Template code's changed and it was trivially easy. I eventually went further and just made it possible for the template to call string methods if they didn't take args, but I don't have a linkable patch for that. [1] https://prototype.lighthouseapp.com/projects/8886/tickets/773-template-option-to-escape-html HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Sep 22, 10:07 pm, Chazza charles.gebh...@gmail.com wrote: Greetings All, Can a Template escape the HTML of an object's properties when it evaluates? E.g. var tpl = new Template('pNo HTML #{prop}./p'); tpl.evaluate({prop: '2 3'}); // BAD! displays pNo HTML 2 3/p can this display: pNo HTML 2 lt; 3/p ? Thanks for any pointers. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Prototype and jQuery
Clarifying Marc's post, after doing jQuery.noConflict(), the jQuery shop folks can continue to use $ for jQuery stuff if they shadow the global symbol with a local one. The most common way to do that is to use a function argument: jQuery.noConflict(); (function($) { // Here, $ = jQuery because $ resolves to the argument, so $(div).css(color, blue); // Turns text in all divs blue })(jQuery); // Here, $ = Prototype because noConflict() was called, so $$(div).invoke('setStyle', {color: green}); // Turns text in all divs green FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Sep 21, 9:05 am, Marc marc.heilig...@gmail.com wrote: It's easy enough for the jQuery shop guys to use this pattern: (function($) { // jQuery stuff here })(jQuery); -- Marc On Sep 20, 8:14 pm, kstubs kst...@gmail.com wrote: I've read through the post, but need clarification on the no-conflict steps. I have written an API using prototype. I am now handing the code over to a jquery shop. They do not want to change their use of $ symbol for jquery. How can this be accomplished? Thanks, Karl.. -- 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: $('som_div') $('som_div div.child_of_some_div')
Hi, $('som_div') $('som_div div.child_of_some_div') I find myself frequently referencing child divs so use .down() a lot. It would be convenient at times to get to that child div directly with the $ shortcut as I've exampled above. If it's just syntactic sugar you're looking for, you can readily create your own function for that: function $X(id_like_thing) { var index, childSelector, element; index = id_like_thing.indexOf( ); if (index = 0) { childSelector = id_like_thing.substring(index+1).strip(); id_like_thing = id_like_thing.substring(0, index - 1); } element = $(id_like_thing); if (element childSelector) { element = element.down(childSelector); } return element; } (Untested off-the-cuff code.) Is there another convenient means to accomplish this in the class or am I stuck doing this: var _myClass = new myClass($('my_div').down('div.child')) If you're trying to avoid `down` for some reason, you can do this: var _myClass = new myClass($$('#my_div div.child')[0]) The more specific you can be on the right-hand side of that, the better, because the way most selector engines work is right-to-left: First find matches for `div.child` and then work up the ancestor chain of each match to see if the rest of the selector matches. Of course, you'd have to profile that to see whether it's slower or faster (if you care) than `down`. Be sure to profile on your target browsers, as the answer will vary markedly depending on whether the browser supports `querySelectorAll`. FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Sep 20, 3:54 pm, kstubs kst...@gmail.com wrote: $('som_div') $('som_div div.child_of_some_div') I find myself frequently referencing child divs so use .down() a lot. It would be convenient at times to get to that child div directly with the $ shortcut as I've exampled above. Has anyone else considered this or something similar? Would this be a costly addition to the core, or perhaps a mistake for the core? 1 good justifying reason for this, and perhaps there is an easy fix here as well. I frequently will write a class and the class itself will expect a layer object; that layer object being the primary container for content the class interacts with. So my constructor usually looks like: var myClass = Class.create({ initialize:function(layer) { this.container = $(layer); // here is the } }); I'm finding that I do not have a convenient way to initialize myClass when layer is not a defined object, so when it is a child object of a defined object this is not convenient. I'd like for the following to be suitable means to instantiate myClass: var _myClass = new myClass('my_div'); // where my_div is a defined object var _myClass = new myClass('my_div div.child') // where we intend the child div of my_div to be the classes container The latter does not work with the $ approach in the initializer for the class. Is there another convenient means to accomplish this in the class or am I stuck doing this: var _myClass = new myClass($('my_div').down('div.child')) Karl.. -- 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: $('person-example').serialize(true)
Hi, On Sep 12, 6:53 am, tani naveedja...@gmail.com wrote: $('person-example').serialize(true) this code doesn't work, how I would implement this The more effort you put into your question, the more likely people are to be able -- and willing -- to help you. The examples in the documentation are (and I think this is unfortunate) written in a form you might use when working with an interactive console like the ones in Chrome, Firebug, Safari, Opera... In actual code, you want to use the result, e.g.: var data = $('person-example').serialize(true); `data` will receive an object with the serialized form data. Note that person-example must be the **id** (not name) of a form. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Event fire bubbling
Hi, On Sep 8, 4:33 pm, kstubs kst...@gmail.com wrote: Shouldn't the following fire all the way up to the document element, so: document.on('anychart:onEventMarkerClick', ...) is valid? Assuming this.container is some HTML element within the document. onEventMarkerClick: function(e) { var obj = {'index': this.index, 'event': e}; Event.fire(this.container, 'anychart:onEventMarkerClick', obj, true); }, WFM: http://jsbin.com/ovudod Perhaps you can post some code that doesn't work? -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Possible bug with arrays and classes
Hi, My Test Code: var base = Class.create({ collection: [], itterations:0, initialize: function() { this.itterations++; this.collection.push(this.itterations); console.log('Itterations: %s, Number items in Collection: %s', this.itterations, this.collection.size()); } }); What that does is create a constructor function where `collection` is shared by all instances created by the function, because `collection` is part of the constructor's prototype. This is correct behavior. It happens because you never assign to `collection` via one of your instances, so the instances (including the ones that are the prototypes for `foo` and `bar`) continue to use the prototype's copy. It's the same mechanism that allows function objects to be shared. (It would happen if collection were some other kind of object reference, too.) In class-based OOP you'd think of it as being a class member. var foo = Class.create(base, {}); var bar = Class.create(base, {}); Your derived constructor functions also share `collection` because they're using it from the base constructor's prototype, too. There is only one `collection` array in total, no matter how many derived constructors or new instances you create. (There's no real analogue in class-based OOP here, I don't think. Prototypical OOP is just different sometimes.) Victor's solution moves `collection` to the `foo` and `bar` constructor function prototypes instead, and so all `foo` instances will share the `foo` constructor's collection, and all `bar` instances will share the `bar` constructor's collection. If that's what you meant, great. But if you want each *instance* to have its own collection, which is the normal use-case, initialize `collection` in the `initialize` function: var base = Class.create({ itterations:0, initialize: function() { this.collection = []; this.itterations++; this.collection.push(this.itterations); console.log('Itterations: %s, Number items in Collection: %s', this.itterations, this.collection.size()); } }); Now you may be thinking: But why did he move `collection` but not `itterations`? (BTW, just the two ts in that, rather than three. ;-) ) We don't assign to `itterations` either, do we? Actually we do: this.itterations++; It doesn't look like an assignment, but it basically means: this.itterations = this.itterations + 1; ...and so it creates an own copy of the property on the instance, rather than incrementing the one on the prototype. (Subtle, that one, and I had to go check to be sure.) Happy coding, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Prototype itself throws errors in IE7
Hi, On Aug 26, 5:30 pm, Walter Lee Davis wa...@wdstudio.com wrote: Rough example: [1,2,3].each(function(n){ $('someDiv').insert(n + 2); }); will output 345 in your DIV in any browser other than IE. $A([1,2,3]).each ... etc. will do it everywhere. Actually, no. The extensions to arrays, functions, and strings are all automatic (at the Array.prototype, etc., level) even on IE. It's only DOM elements that can't be extended prototypically on IE and so have to be passed through `$` (or Element.extend`) before you use Prototype's extensions to them. So this would add a class name on any browser other than IE: var p = document.createElement('p'); p.addClassName(foo); ...but on IE that would cause the error Lukas is seeing. You have to do this: var p = $(document.createElement('p')); p.addClassName(foo); ...to be compatible with IE (see also below). Prototype has to extend each element individually, because IE doesn't allow you to extend the prototype of DOM elements like other browsers do. Lukas, all element instances you retrieve or create via Prototype methods will automatically be extended for you, so for instance this works without an explicit `$`: var p = new Element('p'); p.addClassName(foo); ...because Prototype's `Element` constructor makes sure the element is extended before it gives it back to you. It's only when you've gotten an element reference directly from the DOM that you have to make sure to pass it through `$`. Note that passing an element through `$` more than once is a harmless no-op. Details: http://www.prototypejs.org/learn/extensions HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Remove class
Hi, Well, avoiding unnecessary object creation and deletion is frequently best provided it doesn't complicate the code too much. But objects are *constantly* created and destroyed in JavaScript (every time you call a function, you're creating an object -- a very real one -- to hold the parameters and variables for that function call). The DOM element is the bigger thing. I'd say you're on the right track reusing just the one element, either via show/hide or by actually detaching it from the DOM when not in use. Best, -- T.J. :-) On Aug 25, 5:32 pm, chapster emurra...@gmail.com wrote: Thank you T.J for the detailed answer, really helps. In regards to what I'm trying to remove from memory I was referring to the instance of the class. I can't imagine trying dynamically to get rid of the class dynamically, when I could just remove it from my js file if I don't need it. This leads to another question. I have seen popups being implemented where every time you rollover a link it creates a new instance of the class. This just seems like a huge overhead to me. One implementation was each time you rollover an anchor tag it creates a div below it with the popup ( I think in their case it was a tooltip, similar ). Then when you rollout of the anchor tag it removes the div and I would imagine removes the reference in the js file to the newly created popup. For example in a seperate js file you might have rollover code on a bunch of FAQ questions that every time the user rollsover the element it creates a new popup in a name space of say //pseudo-code app.popups = appFunctionality { this.popup; Rollover : function{ this.popup = new Popup(); } Rollout :function{ this.popup.remove(); } destroy: function{} this.popup = undefined; } So the above namespace keeps my methods and variables in the appFunctionality object from polluting the global space This all seems fine to me as the element in the html markup only lasts the duration of the rollover event. When rollout happens it gets removed. Then on the js side the instance also gets removed. Sorry for the long approach to this question but would it not be better to create one instance of the popup at the start of your js application and have that in it's own namespace. This way when you do a rollover on an anchor it calls a show or hide method inside the Popup class instead of constantly re-creating instances of the popup. In the html you just dynamically add a div on the body that's display hidden and then show on the rollover and hide on the rollout. Content inside the popup can be changed based on what anchor tag you are over. This way your not creating instances everytime and having to worry about garbage collection. Am I correct in thinking the above approach is less taxing on everything. Thanks again for the help in understanding GB collection. On Aug 24, 3:36 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, It's unclear whether you're talking about removing the `namespace.Popup` *class* (well, constructor function -- JavaScript doesn't have classes), or removing the `popup` *instance* (object) that you've created for a specific popover. The short version: If you want to remove the instance you created in `rollever`, what you're doing is mostly fine although there's probably a bug in the quoted code. (You have an extra `var` in the line `var popup = new Popup()` which makes it shadow the variable you declare in the containing scope; as a result, it's eligible for GC as soon as `rollever` returns. Probably just a typo in the quick pseudo-code.) The long version: To release the memory associated with an object (or a primitive, for that matter), all you do is make sure nothing is referring to it anymore. JavaScript is a garbage-collected language, you don't release memory explicitly. You just make sure that nothing refers to the thing you want to get rid of, and eventually the garbage collector will notice that it's unreferenced and will remove it from memory. (When and how it does this is entirely up to the JavaScript implementation, some implementations are quite lazy, others are more pro-active.) You do that in one of four ways: 1. If the thing is referenced from a `var` (`var popup = new Popup();`), assign `undefined` to the `var` (`null` is also fine as you've done in `rollout`). I use `undefined` because it's symmetrical: `undefined` is the value a `var` has before you assign anything to it, so it makes sense to me that to clear it I put it back in that same state). But you see `null` used a lot, probably because it's short and easy to type and similar to the null concept in other languages, and there's nothing wrong with it if you don't obsess about symmetry like I do. 2. If the thing is a property on an object and you're done with the property, either A) assign `undefined` (or `null`) to the property
[Proto-Scripty] Re: Remove class
Hi, It's unclear whether you're talking about removing the `namespace.Popup` *class* (well, constructor function -- JavaScript doesn't have classes), or removing the `popup` *instance* (object) that you've created for a specific popover. The short version: If you want to remove the instance you created in `rollever`, what you're doing is mostly fine although there's probably a bug in the quoted code. (You have an extra `var` in the line `var popup = new Popup()` which makes it shadow the variable you declare in the containing scope; as a result, it's eligible for GC as soon as `rollever` returns. Probably just a typo in the quick pseudo-code.) The long version: To release the memory associated with an object (or a primitive, for that matter), all you do is make sure nothing is referring to it anymore. JavaScript is a garbage-collected language, you don't release memory explicitly. You just make sure that nothing refers to the thing you want to get rid of, and eventually the garbage collector will notice that it's unreferenced and will remove it from memory. (When and how it does this is entirely up to the JavaScript implementation, some implementations are quite lazy, others are more pro-active.) You do that in one of four ways: 1. If the thing is referenced from a `var` (`var popup = new Popup();`), assign `undefined` to the `var` (`null` is also fine as you've done in `rollout`). I use `undefined` because it's symmetrical: `undefined` is the value a `var` has before you assign anything to it, so it makes sense to me that to clear it I put it back in that same state). But you see `null` used a lot, probably because it's short and easy to type and similar to the null concept in other languages, and there's nothing wrong with it if you don't obsess about symmetry like I do. 2. If the thing is a property on an object and you're done with the property, either A) assign `undefined` (or `null`) to the property (the object will still have the property but the property's value will be `undefined` [or `null`]), or B) completely remove the property from the object via `delete` (the object will no longer have the property at all). `delete` looks like this: delete foo.bar; // or delete foo[bar]; // the string can be a literal, or any expression resulting in a string (Important: `delete` removes a property from an object. It has *nothing* to do with memory management, except as a side-effect -- if the property being removed was the last thing to reference something. It is nothing whatsoever like `delete` in C++ or some other languages.) 3. If the thing is a property on an object (like your `Popup` property on your `namespace` object), if you're done with the object as a whole, just release the object as a whole. Anything the object's properties referred to will get cleaned up if those are the only remaining references. E.g., when releasing `namespace`, you don't have to go through releasing all of its properties first. 4. If it's referenced from a `var` within a function, and you don't create any closures[1] (functions) within the function, just let the function return. If that `var` is the only thing referring to the thing you're trying to release, the reference will get cleaned up when the `var` is. (JavaScript nerds like me will point out that this is the same as #3 above, because behind the scenes, `var`s in functions are actually properties of an object that gets cleaned up when the function returns unless a closure has a reference to it.) Mind you, depending on what `Popup` does, you may not need to keep a copy of the instance at all. If it hooks up handlers to events or something, those references will keep it in memory until you unhook it. [1] http://blog.niftysnippets.org/2008/02/closures-are-not-complicated.html FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Aug 23, 6:56 pm, chapster emurra...@gmail.com wrote: When I create a class like example below. How would I remove a class so its not in memory. namespace.Popup = Class.create( { initialize: function(params){ ... }, show:function(){ // create or show } }); I was thinking of creating this at the start of my application and just hiding and showing the popup which will be a div that will be passed into the popup class as a container. In other languages I have called the class everytime a user rolls over an element like below. //pseudo code var popup; function rollever(){ var popup = new Popup(); popup.show(); } function rollout(){ if (popup) popup = null; } How would you remove a class like above in prototype. -- 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
[Proto-Scripty] Re: Prototype's evolution
Hi, On Aug 19, 8:08 am, ncubica ncub...@gmail.com wrote: btw... google groups is closing... does anyone knows what is gonna happen with this email group?? Where did you hear that? I don't see anything about it on the Groups main page[1] or help[2], or the Wikipedia page[3]. They recently rolled out a new UI update[4]. I don't think Groups is closing. It's clearly not a flagship Google product, it's slow as all get-out, administering groups can only be called byzantine, but... They have removed some features[5] (the about box on the group's Home page, group pages, and group files -- most of which are redundant with other, better, Google products) quite a long time back and they're finally deleting the files related to them at the end of the month (until then zips are still available for download), but Groups itself doesn't seem to be closing. [1] http://groups.google.com/ [2] http://groups.google.com/support [3] http://en.wikipedia.org/wiki/Google_Groups [4] http://www.groups.google.com/support/bin/topic.py?topic=1046505 [5] http://groups.google.com/support/bin/answer.py?answer=1046705 You know, when I started out, I didn't expect or intend this note to be so long or to have so many references. It just kept...growing... :-) Sorry about that. Best, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: Bind order args
Hi, In your example, `x` is in scope and will not be undefined within the iterator, because the iterator function is a closure[1] over the context containing `x`. The only reason `x` would be undefined would be if you shadowed[2] it with a local declaration within your function (either a var or a named function argument). In that example, since your function is *already* a closure, there's no particular need for `bind` anyway, just use a var pointing to `this`: var x = 1; var array = [1,2,3,4]; var self = this; // or me is another popular name array.each(function(num) { if (num == x) { // do something, involving self } }); Or, of course, just use the fact that `each` accepts a second argument[3] defining what `this` should be: var x = 1; var array = [1,2,3,4]; array.each(function(num) { if (num == x) { // do something, involving this } }, this ); `bind` is mostly useful when you're passing a function reference into something that doesn't provide that second argument feature (like `observe`) when you don't want to create a closure in the current context. There are, of course, many ways and it's down to the coder which they prefer. :-) [1] Closures are not complicated http://blog.niftysnippets.org/2008/02/closures-are-not-complicated.html [2] Variable shadowing http://en.wikipedia.org/wiki/Variable_shadowing [3] Enumerable#each http://api.prototypejs.org/language/Enumerable/prototype/each/ HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Aug 11, 4:33 pm, kstubs kst...@gmail.com wrote: Well, and agreeably what I wrote seems a bit odd, however there are many cases when making this available to the anonomyous function is handy. What I have found, is when I bind this, then you lose scope of the containing context. Take for example: var x = 1; vary array = [1,2,3,4]; array.each(function(num) { if (num == x) { // x is out of scope, x is undefined // do something, involving this }.bind(this)); So, to bind this, and pass the value of x, the argument order seems to be backwards. -- 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: Bind order args
Can you explain your question a bit more clearly? Yes, it's true that the `thisArg` argument to `Enumerable#find` is the second argument, and it's also true that the `thisArg` argument to `Function#bind` is the first argument, but it's unclear what you're really asking. Also note that you don't need `bind` in your sample code at all, because your iterator function is already a closure. So just var mtedit = this.MeetEdits.find(function(item) { return item.meetid == formid; }); ...because the function can use the `formid` variable from the containing scope (I know it's there because you were passing it into `bind`). (I used `item` rather than `mtedit` as the function argument name to avoid confusion with the `mtedit` variable in the containing scope.) FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Aug 9, 7:43 pm, kstubs kst...@gmail.com wrote: Why, when I bind like this is this the 2nd argument (expecting it to be first argument) in the find function? var mtedit = this.MeetEdits.find(function(mtedit,formid) { return mtedit.meetid == formid; }.bind(this, formid)); -- 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: Triggering an effect on 2 completely different HTMLdivElements simultaneously with 1 single click, how to ?
Hi, Just trigger them at the same time, the effects will run in parallel: Effect.BlindDown(div1); Effect.BlindDown(div2); Alternately, you might look at Effect.Parallel[1], which runs effects in parallel in an organized way and allows you to specify options to apply to all of them. Example[2] [1] http://madrobby.github.com/scriptaculous/effect-parallel/ [2] http://jsbin.com/ozifoy -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Aug 6, 12:34 pm, donalduck g...@kiloge.fr wrote: Greetings How can I trigger the blind effect on 2 completely different HTMLdivElements simultaneously with 1 single click ? Thanks -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Eliminate POST vars before submit
Hi, Sounds like some refactoring is in order. If you're doing an Ajax call, then I'm with Miguel, you can just grab the fields you really need and send them directly. If you want it to be a real form post (refreshes the page, etc.), you could create a new form on-the-fly with the relevant fields and submit that instead. Alternately, remember that browsers (and Prototype) don't send disabled form fields. So if you know, when submitting, which fields are relevant and don't want to refactor, just ensure that by the time the form is submitted, the irrelevant fields are disabled. Then they won't be sent. But 1,300 fields in a single form...that screams divide and conquer to me. Best, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Aug 1, 3:14 pm, Martín Marqués martin.marq...@gmail.com wrote: I have a large form with quite a bunch of pull downs to select. Then a submit button. The thing is that there can be up to 1300 vars, and maybe more in the future, but in every post only 10 or 15 are valid for the program. How can I eliminate them from the list of variables that are finally submitted? -- Martín Marqués select 'martin.marques' || '@' || 'gmail.com' DBA, Programador, Administrador -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Eliminate POST vars before submit
You can make it just selects like this: if(selects[i].tagName.toUpperCase() === SELECT selects[i].getValue() == 0){ -- T.J. On Aug 1, 5:42 pm, Martín Marqués martin.marq...@gmail.com wrote: OK, got it done in another way (I'm not sure if I was clear about what I wanted). Form id is formEntrega. Event.observe(window, 'load', function() { Event.observe('formEntrega', 'submit', function(event){ var selects = this.getElements(); for(var i=0; i selects.length; i++){ if(selects[i].getValue() == 0){ selects[i].disable(); } } this.submit(); } ); }); This works like a charm. The only thing missing is some validation for a select element (getElements() brings everything in the form, not only the selects), but havent found how to do that. 2011/8/1 T.J. Crowder t...@crowdersoftware.com: Hi, Sounds like some refactoring is in order. If you're doing an Ajax call, then I'm with Miguel, you can just grab the fields you really need and send them directly. If you want it to be a real form post (refreshes the page, etc.), you could create a new form on-the-fly with the relevant fields and submit that instead. Alternately, remember that browsers (and Prototype) don't send disabled form fields. So if you know, when submitting, which fields are relevant and don't want to refactor, just ensure that by the time the form is submitted, the irrelevant fields are disabled. Then they won't be sent. But 1,300 fields in a single form...that screams divide and conquer to me. Best, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Aug 1, 3:14 pm, Martín Marqués martin.marq...@gmail.com wrote: I have a large form with quite a bunch of pull downs to select. Then a submit button. The thing is that there can be up to 1300 vars, and maybe more in the future, but in every post only 10 or 15 are valid for the program. How can I eliminate them from the list of variables that are finally submitted? -- Martín Marqués select 'martin.marques' || '@' || 'gmail.com' DBA, Programador, Administrador -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- Martín Marqués select 'martin.marques' || '@' || 'gmail.com' DBA, Programador, Administrador -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: semi-colon complaint and other 1-7
Hi, Yes, in whitespace only mode the Closure compiler also deletes any semicolons that will be inserted by (the horror that is) automatic semicolon insertion[1]. Eclipse should have an option to disable the warning if the semicolon would be added by ASI. I would leave it enabled, though, so you don't rely on ASI in your own code. [1] http://es5.github.com/#x7.9 -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 28, 9:49 pm, kstubs kst...@gmail.com wrote: Thanks. I started out reporting an issue on a semi-colon, but thought this was more of an obvious problem (that isn't a problem). So the semi-colon issue is still there, and I think I can resolve them, but seems they occur after things like: Here's an example from event.js function(value) { object[method] = value }; Missing semi after value. Turns out that the additional semi-colon issues I am seeing with prototype 1-7 is a problem after running through Google's compiler. I only strip white space, but seems that Google compiler is also removing semi-colons... -- 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 serializing and ignoring disabled fields
Hi What is the thinking behind ignoring those fields items in a form that have been disabled? Is this an HTML recommended standard? Browsers don't submit disabled fields, so Prototype doesn't serialize them. This has been true pretty much forever, but here's the latest HTML spec's description of this: http://www.w3.org/TR/html5/association-of-controls-and-forms.html#constructing-form-data-set So not just recommended, but dictated by the standard. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 29, 5:03 pm, kstubs kst...@gmail.com wrote: What is the thinking behind ignoring those fields items in a form that have been disabled? Is this an HTML recommended standard? Here is what I do, perhaps there is a much better solution. I often need to show a client a field value, like a primary key ID, but they shouldn't change it, so I disable this input. I do like the look of the disabled input, and this is why I default to this view - but - the item is ignored on serialization. Karl.. -- 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: Combo box?
Chosen looks really cool. The problem with Chosen is (quoting from the website): What browsers are supported? All modern browsers are support (Firefox, Chrome, Safari and IE9). Legacy support for IE8 is also enabled. So, legacy support for the 30% of the general populace using IE8 (and I've tried it, it's pretty slow), and no support at all for the 17% using IE6 and IE7 (and I've tried it, it doesn't work correctly). [1] Ouch, that's half of your average site's users who won't get the enhanced version or get it but have it run slowly. Of course, every site's audience is different, for some sites -- web programming sites and such -- you'd be on pretty safe ground. Still, it's early days, hopefully they'll be able to improve the IE8 support and add support for IE6 and IE7 (until those finally actually die -- and wouldn't that be nice!). [1] http://marketshare.hitslink.com/browser-market-share.aspx?qprid=2 -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 27, 4:18 am, Tom Gregory tagreg...@gmail.com wrote: I should add, it comes in both Prototype and jQuery flavors, with forks for moo tools and others. (Sorry for the second post.) TAG On Jul 26, 11:17 pm, Tom Gregory tagreg...@gmail.com wrote: By chance, your question comes a day or so after one appeared on hacker news: Project:http://harvesthq.github.com/chosen/ Insightful HN Comments:http://news.ycombinator.com/item?id=2793086 It looks like it could be trivially tweaked to handle new entries. TAG On Jul 26, 4:38 pm, Shane McCarron halindr...@gmail.com wrote: Does anyone know of a *stable* combobox implementation that uses Prototype? -- Shane McCarron halindr...@gmail.com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-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: Combo box?
Chosen looks really cool. The problem with Chosen is (quoting from the website): What browsers are supported? All modern browsers are support (Firefox, Chrome, Safari and IE9). Legacy support for IE8 is also enabled. So, legacy support for the 30% of the general populace using IE8 (and I've tried it, it's pretty slow), and no support at all for the 17% using IE6 and IE7 (and I've tried it, it doesn't work correctly). [1] Ouch, that's half of your average site's users who won't get the enhanced version or get it but have it run slowly. Of course, every site's audience is different, for some sites -- web programming sites and such -- you'd be on pretty safe ground. Still, it's early days, hopefully they'll be able to improve the IE8 support and add support for IE6 and IE7 (until those finally actually die -- and wouldn't that be nice!). [1] http://marketshare.hitslink.com/browser-market-share.aspx?qprid=2 -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 27, 4:18 am, Tom Gregory tagreg...@gmail.com wrote: I should add, it comes in both Prototype and jQuery flavors, with forks for moo tools and others. (Sorry for the second post.) TAG On Jul 26, 11:17 pm, Tom Gregory tagreg...@gmail.com wrote: By chance, your question comes a day or so after one appeared on hacker news: Project:http://harvesthq.github.com/chosen/ Insightful HN Comments:http://news.ycombinator.com/item?id=2793086 It looks like it could be trivially tweaked to handle new entries. TAG On Jul 26, 4:38 pm, Shane McCarron halindr...@gmail.com wrote: Does anyone know of a *stable* combobox implementation that uses Prototype? -- Shane McCarron halindr...@gmail.com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-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: semi-colon complaint and other 1-7
Your title was semi-colon complaint but your example was that Eclipse complains about a comma. If Eclipse is really saying it thinks that comma should be a dot, then yes, it's an Eclipse issue. The comma operator[1] is perfectly valid there. [1] http://es5.github.com/#x11.14 HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 28, 8:09 pm, kstubs kst...@gmail.com wrote: I'm using eclipse editor and getting some syntax complaints, for example the following: From appx. line: 4000 while ( (chunker.exec(), m = chunker.exec(soFar)) !== null ) { soFar = m[3]; parts.push( m[1] ); if ( m[2] ) { extra = m[3]; break; } } Complains that the comma after chunker.exec(), should be a . Make sense? Is the eclipse issue? Karl.. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: IE 9 issues with Insertion
What do you figure the odds are that people are going to need to know more about your code than that? Like, you know, what your page's HTML looks like, what those strings are you're inserting. Trivial points, really... ;-) -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 28, 9:19 pm, S L june.st...@gmail.com wrote: I have no problem displaying the page in IE7 and 8. But in IE9, these menus are missing. Here's the code: new Insertion.Bottom($(secondaryNav), MyShop.Extranet.MyChart.secondaryMenuHtml); new Insertion.Bottom($(primaryNav), MyShop.Extranet.MyChart.primaryMenuHtml); new Insertion.Bottom($(breadcrumbNav), MyShop.Extranet.MyChart.breadcrumbMenuHtml); new Insertion.Top($(footer), MyShop.Extranet.MyChart.footerMenuHtml); var menu = $(menu); var userTitle = (menu != null ? menu.down(h2) : null); if(menu userTitle) { new Insertion.Bottom(userTitle, 'a href=./bye.asp(Log Out)/ a'); } Please help. Thanks. Steve -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: ajax.updater oncomplete anonymous function variable argument
Hi, This is a common error, you're not alone. The problem is that the function you're creating in the loop (the anonymous function assigned to `onComplete`) has an *enduring reference* to the `qnum` variable, not a *copy* of its value when the function was created. All copies of your `onComplete` callback use the same variable, which by the time they use it will have the value as of the *end* of the loop. This is how closures (functions that close over) data work, they have an enduring reference to the variables. Closures are not complicated[1], there are just a couple of basics that people tend to misunderstand if they haven't had them explained to them. First I'll tell you how it's usually solved, then how you can solve it with useful features Prototype providers, and then recommend a completely different approach: The usual way to solve it is to create a factory function that creates functions for you that close over a variable they each have a private copy of, assigning the value of `qnum` at a point in time to those variables as we create them, like this: function fillQuiz() { var qnum = 0; var tget = 'q' + qnum; while ($(tget)) { new Ajax.Updater($(tget), 'qblock.php', { method: 'get', parameters: {qnum: $(tget).readAttribute('qnum')}, // Here we *call* a function that returns a function onComplete: createCallback(qnum) }); qnum++; tget = 'q' + qnum; } function createCallback(q) { // This closure closes over `q`, which is private // to the closure and never changes. return function() { qListen(q); }; } } function qListen(_me) { window.alert(_me); } There, we use `createCallback` to create and return a function for us that closes over the `q` argument, which is created for each call. That way, the returned function closes over something that doesn't change. The good news is you don't have to write `createCallback`, because Prototype already has one: `Function#curry`[2]. `Function#curry` does exactly what we want, it accepts arguments and returns a function that will call the original function with those arguments. So with Prototype, that code gets a bit simpler: function fillQuiz() { var qnum = 0; var tget = 'q' + qnum; while ($(tget)) { new Ajax.Updater($(tget), 'qblock.php', { method: 'get', parameters: {qnum: $(tget).readAttribute('qnum')}, onComplete: qListen.curry(qnum) }); qnum++; tget = 'q' + qnum; } } function qListen(_me) { window.alert(_me); } So that's the general solution, and how Prototype helps with it. What's the completely different approach? Ajax calls are expensive, and you can only have so many of them going at a time. Rather than firing off separate ajax requests for *every question*, I'd strongly recommend firing off one request with a list of questions, and having the request reply with all of the results in one go. That eliminates the loop, solving the problem related to the loop, and reduces server load. [1] http://blog.niftysnippets.org/2008/02/closures-are-not-complicated.html [2] http://api.prototypejs.org/language/Function/prototype/curry/ HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 15, 5:26 pm, Heath Jordan hjor...@cascadeauto.com wrote: I am using an anonymous function so I c an pass args. I need the arguments to be variable and when they actually get called they are the final state of the variable not the state at which I 'think' I am setting them. function fillQuiz() { var qnum = 0; var tget = 'q' + qnum; while($(tget)!= null) { new Ajax.Updater($(tget), 'qblock.php', { method: 'get', parameters: {qnum: $(tget).readAttribute('qnum')}, onComplete:function(){qListen(qnum)} }); qnum++; tget = 'q' + qnum; } } function qListen(_me) { window.alert(_me); } -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Modal windows
Hi, There are several on http://scripteka.com/. Click the window or modal tags in the tag cloud at the bottom to filter the list on the left. Best, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 12, 8:53 am, vasileVas radupacur...@gmail.com wrote: Hi ,I'm new to prototype I need to add a modal window on an already build up site that's using prototype. I don't want to add jquery and another plugin just for this, because this modal window will be used only for terms of service so I don't want to have a lot of downloding on page just for that. So, if you know a simple modal window, I need it just for some simple html text, please let me know. I only founded some pretty fancy modal windows on prototype, but I want to keep the download size down. Thanks. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Object from string
On Jul 9, 6:15 pm, kstubs kst...@gmail.com wrote: Wow, you just have to love Javascript, so flexible sometimes! What an amazing language, I tell ya. Thanks for that shortcut ilandril! You can even use an expression within the square brackets: var idx = itt + 1; var h = {}; h['p_Value' + idx.toString()] = names[itt]; ...but you probably want that `name` variable for something else anyway. This is all a consequence of the fact that object property names are strings, and so these all set the same property of `a` to `bar`: a.foo = bar; a['foo'] = bar; x = 'f'; a[x + 'o' + 'o'] = bar; These are also identical: a[0] = bar; a['0'] = bar; ...and in fact, we all use the fact that a number within the brackets is converted to a string property name all the time, whenever we use an array -- because JavaScript arrays aren't really arrays at all: http://blog.niftysnippets.org/2011/01/myth-of-arrays.html FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: li problem in IE8
On Jul 7, 7:22 am, KingKong99 k0818069...@gmail.com wrote: very simple code li_date = lihello/li; $('log').innerHTML = li_date; it works very fine in all browsers but not in IE8 Unknow runtime error You'll have to give people a bit more to go on than that. What kind of element is log, for instance? Unknown runtime error is usually IE's way of saying you're trying to do something odd with the DOM. For instance, what you're doing there is setting the *entire content* of the log element (whatever that is) to be an `li` element; the end result is that any content in log is removed and it will have a single child, the `li` element. You can only do that if log is an `ol` or a `ul`, since those are the only things that can directly contain `li`. I was surprised to find that IE was okay with it if log was a `div` (it's invalid, but IE and other browsers apparently work around it), but I was able to get IE to throw the error if I tried to do that when log was an `li` or `p` element (and I'm sure it would with many others). It works fine if log is a `ul`. Here's the test case: http://jsbin.com/ijelah/3 So basically, I think the problem is that you're trying to put an `li` inside something that can't have an `li` inside it. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: What's your favorite error status code?
On Jul 7, 12:42 pm, Walter Lee Davis wa...@wdstudio.com wrote: I've used 409 (Conflict) a lot to signal back to my application that an Ajax request went wrong at the server level (409 and Ajax are both powerful household cleaner brands, so it's my private-joke-over-HTTP status). But if I want to be semantic at the error code level, what code best signals you, the user, did something incomplete or wrong, so you are not getting a 200 for your effort? Thanks, Walter To my mind, HTTP response codes aren't for application logic signalling. They're for signalling between the browser and server. The correct response to bum data from the user is a 200 with an application-logic-level success/error flag. I wouldn't conflate the transport and business logic layer errors. (The 409 / Ajax thing *is* funny.) FWIW... -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: What's your favorite error status code?
On Jul 7, 1:27 pm, Walter Lee Davis wa...@wdstudio.com wrote: On Jul 7, 2011, at 8:21 AM, T.J. Crowder wrote: To my mind, HTTP response codes aren't for application logic signalling. They're for signalling between the browser and server. The correct response to bum data from the user is a 200 with an application-logic-level success/error flag. Fair enough, but since the onFailure callback only runs if the response code sent back is something other than the 200 range, how would you recommend I send back that failure other than with the status code? Walter Let's just say I never use Ajax.Request directly. :-) I put in application-level plumbing and take care of things like providing a `context` parameter for callbacks and handling both transport and application logic errors. -- T.J. -- 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: managing zindex
Hi, I was playing with something a couple of years back that was going to have a bunch of little boxes, any of which needed to be brought in front of the others on click. I played with keeping track of the most- recently-brought-forward box and then lowering its z-index again when another one was brought forward -- basically, having a background (statically-positioned content), a mid-ground (absolutely positioned content with z-index of one value), and foreground (absolutely- positioned content with a slightly higher z-index). But it didn't work well, not least because there was no history to it -- I'd drag a box over somewhere, then start dragging another and the box I'd dropped previously would (of course) go underneath other boxes depending on which boxes came first in the document order. I got distracted and never finished fiddling with that (it was just something I was playing with), but your question reminded me of the awkwardness and as I know a good deal more now about JavaScript and CSS than I did then, my first thought was: How 'bout an ever- increasing value? Browsers seem to store z-index in 32-bit signed integers, meaning that the range in front of the statically-positioned content is 0 to 2,147,483,647 (more than 2.1 billion). So in my lots of small boxes situation, I could probably have just had a variable, `nextZIndex`, seeded it with the value 1, and then each time one of my boxes was clicked and needed to be brought in front of the others, I'd just assign that next z-index to it and increment `nextZIndex`. The boxes will maintain themselves in most-recently-clicked order...for 2.1 billion clicks, which I think is a reasonable limit. :-) Here's a live copy of the sort of thing: http://jsbin.com/uzokad It feels a bit...open-ended, but has the advantage of being wonderfully simple. And you could always put in a check for when you find your `nextZIndex` value is at about 2,147,483,000 or so and do the expensive (not really at that point, in the scheme of things) operation of redoing the numbering on all of your relevant elements. FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 4, 4:27 pm, kstubs kst...@gmail.com wrote: Those are some good ideas. In an effort to just write something quickly I decided to: 1) keep track of context object z-index 2) set z-index of this object to some absurd big z-index value 3) on lost focus (or when the object should resume the not expanded state) return z-index to original size This seems to be working fine.. I was fishing for if anyone else had ran into similar implementation problems. You know its fantastic to finally be able to write all of this great Javascript code using Prototype, but you still have to write it intelligently. -- 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: managing zindex
I should have mentioned that unless you're okay with things wigging out after 2.1 billion clicks (and it would be perfectly reasonable to be okay with that), you will want to do that readjustment. If you try this copy (http://jsbin.com/uzokad/2) which starts just a few numbers shy of the limit, the results vary from browser to browser as to what happens when the value exceeds a signed 32-bit int -- they differ, but are nearly-universally undesirable. (Chrome just happily keeps going; I guess they either use a JavaScript number [a 64-bit format IEEE 754 floating-point value -- this is my suspicion] or a 64-bit int.) But IE, Firefox, and Opera all became unhappy in varying ways. -- T.J. :-) On Jul 4, 10:41 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I was playing with something a couple of years back that was going to have a bunch of little boxes, any of which needed to be brought in front of the others on click. I played with keeping track of the most- recently-brought-forward box and then lowering its z-index again when another one was brought forward -- basically, having a background (statically-positioned content), a mid-ground (absolutely positioned content with z-index of one value), and foreground (absolutely- positioned content with a slightly higher z-index). But it didn't work well, not least because there was no history to it -- I'd drag a box over somewhere, then start dragging another and the box I'd dropped previously would (of course) go underneath other boxes depending on which boxes came first in the document order. I got distracted and never finished fiddling with that (it was just something I was playing with), but your question reminded me of the awkwardness and as I know a good deal more now about JavaScript and CSS than I did then, my first thought was: How 'bout an ever- increasing value? Browsers seem to store z-index in 32-bit signed integers, meaning that the range in front of the statically-positioned content is 0 to 2,147,483,647 (more than 2.1 billion). So in my lots of small boxes situation, I could probably have just had a variable, `nextZIndex`, seeded it with the value 1, and then each time one of my boxes was clicked and needed to be brought in front of the others, I'd just assign that next z-index to it and increment `nextZIndex`. The boxes will maintain themselves in most-recently-clicked order...for 2.1 billion clicks, which I think is a reasonable limit. :-) Here's a live copy of the sort of thing:http://jsbin.com/uzokad It feels a bit...open-ended, but has the advantage of being wonderfully simple. And you could always put in a check for when you find your `nextZIndex` value is at about 2,147,483,000 or so and do the expensive (not really at that point, in the scheme of things) operation of redoing the numbering on all of your relevant elements. FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 4, 4:27 pm, kstubs kst...@gmail.com wrote: Those are some good ideas. In an effort to just write something quickly I decided to: 1) keep track of context object z-index 2) set z-index of this object to some absurd big z-index value 3) on lost focus (or when the object should resume the not expanded state) return z-index to original size This seems to be working fine.. I was fishing for if anyone else had ran into similar implementation problems. You know its fantastic to finally be able to write all of this great Javascript code using Prototype, but you still have to write it intelligently. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Prototype DOM-traversal methods failing on HTML5 elements in IE 9 using html5shiv
Hi, On Jul 1, 1:52 am, Jonny Nott jonn...@gmail.com wrote: Aha, Mr Crowder, you always have the answers! Thanks. So, any news on Prototype v 1.7.0.1, 1.7.1 or 1.8? Will the next version have the latest Sizzle in? If the question is directed at me: I have no idea, I'm not involved with Prototype's development. I'd _assume_ that any release of Prototype would include the latest Sizzle unless there was a breaking API change in Sizzle making grabbing the latest difficult, which could cause a delay. The primary Sizzle API[1] consists of just three functions, but who knows, maybe Prototype had to go under the covers in order to provide some of Prototype's features. The Sizzle in jQuery 1.4.2, released 19 Feb 2010, doesn't have this `article` problem; the Sizzle in Prototype 1.7, released nine months later (16 Nov 2010), does (http://jsbin.com/osufay/4). On the face of it, given Sizzle is meant to be self-contained and Prototype supports pluggable selector engines, it should be trivial. And in about 15 minutes I was able to copy my local prototype-1.7.js file and swap in the Sizzle from the uncompressed jQuery 1.6.1[2]. The result worked in our `up` test case. But I tend to assume it can't be quite that easy and other things would be broken. I don't have the time to go any further with it, but if anyone wants to follow the recipe and run it through a test suite, here it is: Copy prototype-1.7.js and replace lines 3,966-4,937 (inclusive) with lines 3,700-5,106 (inclusive) from jQuery 1.6.1 uncompressed release[2]. For visual reference: prototype-1.7.js: Start and end lines starred: 3964 })(); 3965 Prototype._original_property = window.Sizzle; * 3966 /*! 3967 * Sizzle CSS Selector Engine - v1.0 3968 * Copyright 2009, The Dojo Foundation ... 4936 return Sizzle.filter( later, tmpSet ); * 4937 }; 4938 4939 4940 window.Sizzle = Sizzle; jquery-1.6.1.js: Start and end lines starred: 3696 }); 3697 3698 3699 * 3700 /*! 3700 * Sizzle CSS Selector Engine ... 5105 return Sizzle.filter( later, tmpSet ); * 5106 }; 5107 5108 // EXPOSE 5109 jQuery.find = Sizzle; But again: I have no idea if that's all that's required, just that the result worked in our `up` case finding `article`. It probably isn't that easy. Perhaps post a new thread asking about an update with just the latest Sizzle. Best, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com [1] https://github.com/jquery/sizzle/wiki/Sizzle-Home [2] http://code.jquery.com/jquery-1.6.1.js -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Element.extend returning null after in a form (in chrome)
Hi, It would help to quote some code, otherwise people are just guessing at what might be going wrong. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jul 1, 8:17 am, Thexder jpree...@gmail.com wrote: I pass in a form id, it has the form element up until the Element.extend call, then it returns null. I've traced the code up to the Element.extend, then the Chrome debugger goes into the function 'K', but the parameter is null. Obviously the debugger doesn't know how to trace the code, and I don't know enough about the prototype library to know where it might be going wrong. Any ideas? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Prototype DOM-traversal methods failing on HTML5 elements in IE 9 using html5shiv
On Jun 30, 5:44 pm, Jonny Nott jonn...@gmail.com wrote: [snip] Is this a gaping hole/bug? I'm sure the core folks have thick skins, but was gaping _really_ necessary? On Jun 30, 6:57 pm, Jonny Nott jonn...@gmail.com wrote: I *think* this is exactly what html5shiv is doing. Could try adding your suggestion into the test HTML on pastebin, but I'm not at my computer right now :( Correct, that's exactly what html5shiv does: Creates elements using the new tags so that IE understands that those tags are elements. It looks like a bug in the old version of Sizzle that Prototype incorporates. You can see it vs. the current version of Sizzle (in jQuery) here: http://jsbin.com/osufay In contrast, if I go back to an earlier version of jQuery with an older Sizzle, it fails in the same sort of way: http://jsbin.com/osufay/2 And if I go back to Prototype 1.6.0 (which didn't use Sizzle, it had its own selector engine), it works: http://jsbin.com/osufay/3 So it was a bug in Sizzle that's been fixed. The fix would be to upgrade the Sizzle bundled in Prototype to the latest version. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: event observe for image problem on IE
Hi, On IE, Prototype can't extend elements at the prototype level and so you have to extend them individually if you get/create them without going through Prototype. To do that, just pass the element through the `$` function: var newImg = $(document.createElement(img)); The reason you don't have to do that on Firefox or other browsers is that on those browsers, Prototype can add its enhancements to the *prototypes* of elements rather than individually to each element. But not on IE. More here: http://prototypejs.org/learn/extensions You have to do this whenever you use raw DOM methods (like document.createElement, or document.getElementById, or document.getElementsByTagName, etc.) rather than Prototype equivalents. Alternately, of course, you can just go through Prototype whenever creating or retrieving elements; then Prototype will ensure they've been extended before giving them to you. E.g.: function addImage(src, div) { var newImg = new Element(img); newImg.id=Image+div; $(img+div).appendChild(newImg); papa=$(img-upload); $(img+div).style.display=block; hijo=$(upload+div).style.display=none; newImg.src = src; newImg.observe('load', loadcrop); } There I've just replaced `document.createElement` with `new Element` and replaced `document.getElementById` with `$`. Separately, I would recommend reversing the order of your last two lines to: newImg.observe('load', loadcrop); newImg.src = src; ...just in case the image is already in cache. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jun 28, 4:06 pm, edwingt edwin.al...@gmail.com wrote: Hello I'm trying to do an event observe work on IE, it works good on FF and Chrome, this is the script. When the newImg.observe() is reached I catch an exception with this msg 'src' is undefined function addImage(src, div) { var newImg = document.createElement(img); newImg.id=Image+div; document.getElementById(img+div).appendChild(newImg); papa=document.getElementById(img-upload); document.getElementById(img+div).style.display=block; hijo=document.getElementById(upload+div).style.display=none; newImg.src = src; newImg.observe('load', loadcrop); } function loadcrop(evt) { img = evt.findElement(); var txt = new String(img.id); addCrop(txt.slice(5,6)); } Thanks if you can help me solve this problem. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: event observe for image problem on IE
On Jun 29, 9:33 am, Johan Arensman johanm...@gmail.com wrote: TJ! How on earth can you do that so fast!? Do you have this reply as a template or something?? LOL I took typing in high school. Some of the best advice my mother ever gave me. :-) -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: IE8 problem
Hi, Anyone please help. What am I do wrong?!! You're using the same `id` value on more than one element. That is invalid markup[1] and will not work correctly. `id` values *MUST* be unique on the page.[2][3] You may have wanted to use a `class`[4][5] instead: div class=num1/div div class=num2/div div class=num3/div div class=num4/div div class=num5/div alert($$(.num).length); // 5 [1] http://validator.w3.org/ [2] http://www.w3.org/TR/html5/elements.html#the-id-attribute [3] http://www.w3.org/TR/html401/struct/global.html#adef-id [4] http://www.w3.org/TR/html5/elements.html#classes [5] http://www.w3.org/TR/html401/struct/global.html#adef-class HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jun 22, 2:33 pm, KingKong99 k0818069...@gmail.com wrote: I have very simple code as below: html head script src=prototype.js/script script document.observe('dom:loaded',function(){ var nums = $$('#num'); alert(nums.length); }); /script /head body div id=bb div id=num_container div id=num1/div div id=num2/div div id=num3/div div id=num4/div div id=num5/div /div /div /body /html There is no problem in Chrome or Firefox but IE8. It should alert number 5 not 1. Anyone please help. What am I do wrong?!! Thank you King -- 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: Registered events and removed DOM objects
Hi, On Jun 16, 9:11 am, Acu woj...@studioatrium.pl wrote: I am curious what happens with references to Events registered through Event.Observe when object bound with those evenst is removed with Element.remove function. Are they automatically freed (like with Event.unloadCache)? Or maybe one should unregister those events with Event.stopObserving before removing object? Prototype doesn't do anything to remove the handlers on `remove`, they'll stay in memory. If you know you've only set handlers on that element and none of its children, yes, use `stopObserving`: $(theElement).stopObserving().remove(); If there may be handlers on the element's children as well, use `purge`[1]: $(theElement).purge().remove(); It's not clear from the documentation, but `purge` does remove handlers from the element's descendants. [1] http://api.prototypejs.org/dom/Element/purge/ HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: form.serialize not working in IE8
Hi, On Jun 14, 5:40 pm, Don donlope...@gmail.com wrote: form.serialize in IE8 is returning a blank string, even though there are elements. Should this be working in IE8? That seems really unlikely. What does your form look like? And in particular, do the form fields have `name` values (rather than `id`s)? -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / 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: form.serialize not working in IE8
I figured it out. I was wiping out the form by setting the innerHTML property of a parent div before calling form.serialize. Interestingly though, this worked in previous versions of IE and still does in virtually every other browser, if you have a reference to the form before wiping it out. If you have a reference to the form's DOM element prior to setting `innerHTML`, it should remain valid. I found it so surprising that IE8 would get this wrong that (with apologies) I had to test it for myself. But I can easily replicate your result on IE6 - IE9: http://jsbin.com/elihi5 It only happens if you remove the form by setting `innerHTML` on its parent, though. If you remove it via DOM `removeChild`, it works correctly: http://jsbin.com/elihi5/2 So it's down to how IE handles setting `innerHTML`. Apparently, doing so destroys the parent/child relationship of the elements therein, as we can see here: http://jsbin.com/elihi5/5 If I use `innerHTML` to clear it, although my reference to the form remains valid, the form no longer has any children. If I already have a reference to one of its children, my reference remains valid, but the form still loses that child. Very surprising behavior. I suppose since `innerHTML` is a Microsoft invention and hasn't until recently[1] been subject to any standardization, calling this wrong (as I did above) is harsh. But really, really surprising. Thanks for letting us know about it! [1] http://www.w3.org/TR/html5/apis-in-html-documents.html#dom-innerhtml -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jun 16, 12:07 am, Don donlope...@gmail.com wrote: On Jun 15, 2:25 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, On Jun 14, 5:40 pm, Don donlope...@gmail.com wrote: form.serialize in IE8 is returning a blank string, even though there are elements. Should this be working in IE8? That seems really unlikely. What does your form look like? And in particular, do the form fields have `name` values (rather than `id`s)? I figured it out. I was wiping out the form by setting the innerHTML property of a parent div before calling form.serialize. Interestingly though, this worked in previous versions of IE and still does in virtually every other browser, if you have a reference to the form before wiping it out. -- 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.serialize not working in IE8
And just because so many things about forms are special in IE, just a quick note that this is not specific to forms, the same thing happens to other content within the area being cleared: http://jsbin.com/elihi5/6 -- T.J. :-) On Jun 16, 4:16 am, T.J. Crowder t...@crowdersoftware.com wrote: I figured it out. I was wiping out the form by setting the innerHTML property of a parent div before calling form.serialize. Interestingly though, this worked in previous versions of IE and still does in virtually every other browser, if you have a reference to the form before wiping it out. If you have a reference to the form's DOM element prior to setting `innerHTML`, it should remain valid. I found it so surprising that IE8 would get this wrong that (with apologies) I had to test it for myself. But I can easily replicate your result on IE6 - IE9: http://jsbin.com/elihi5 It only happens if you remove the form by setting `innerHTML` on its parent, though. If you remove it via DOM `removeChild`, it works correctly: http://jsbin.com/elihi5/2 So it's down to how IE handles setting `innerHTML`. Apparently, doing so destroys the parent/child relationship of the elements therein, as we can see here: http://jsbin.com/elihi5/5 If I use `innerHTML` to clear it, although my reference to the form remains valid, the form no longer has any children. If I already have a reference to one of its children, my reference remains valid, but the form still loses that child. Very surprising behavior. I suppose since `innerHTML` is a Microsoft invention and hasn't until recently[1] been subject to any standardization, calling this wrong (as I did above) is harsh. But really, really surprising. Thanks for letting us know about it! [1]http://www.w3.org/TR/html5/apis-in-html-documents.html#dom-innerhtml -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jun 16, 12:07 am, Don donlope...@gmail.com wrote: On Jun 15, 2:25 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, On Jun 14, 5:40 pm, Don donlope...@gmail.com wrote: form.serialize in IE8 is returning a blank string, even though there are elements. Should this be working in IE8? That seems really unlikely. What does your form look like? And in particular, do the form fields have `name` values (rather than `id`s)? I figured it out. I was wiping out the form by setting the innerHTML property of a parent div before calling form.serialize. Interestingly though, this worked in previous versions of IE and still does in virtually every other browser, if you have a reference to the form before wiping it out. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request not working with HTTPS and self signed certificates
Hi, I don't think it has anything to do with the certificate being self- signed, just that it's https. Are you trying to use https in an ajax call when the page has been loaded via http? If so, you're running into the Same Origin Policy[1], which forbids doing that. Ajax requests, by default, can only go to the same origin as the document in which the script is running, and the concept of an origin includes the protocol (http://example.com and https://example.com are _different_ origins). More in the link. If you're in control of the server, you have a couple of options: 1. Use JSON-P[2] instead of Ajax. JSON-P doesn't have an origin restriction, but it can only use the GET method, not POST. 2. If you can rely on using a modern browser, you can use the new CORS[3] standard. You can see a list of browsers and their support (or lack thereof) for CORS here[4]. Unfortunately, CORS is only supported by IE in IE8 and above, and that support requires extra work (whereas every other browser vendor who supported it did so in a backward- compatible way). Specifically, instead of using XMLHttpRequest (which is what Ajax.Request uses), you have to use a completely new XDomainRequest object instead. But again, only on IE. Note that using CORS requires that you add support for it to the server, because you have to handle a request from the browser asking if it's okay to send the cross-origin request. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com [1] http://en.wikipedia.org/wiki/Same_origin_policy [2] http://en.wikipedia.org/wiki/JSONP#JSONP [3] http://www.w3.org/TR/access-control/ [4] http://caniuse.com/#search=cors On Jun 12, 9:00 am, Rick Avner rickav...@gmail.com wrote: Hi, I have a HTML Application (HTA) using Ajax.Request to get information from one of my LAMP based server. The requests were working fine using HTTP. However, the requests are failing (responseText is blank) when I use HTTPS. Server SSL is enabled using self signed certificates. Is there any way to ignore certificate warnings while using Ajax.Request? I know I should use CA certified certificates on my server. However just wondering if there is any way for Ajax.Request to work with self signed certificates. I am using prototype.js version 1.5. Thanks in advance. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request not working with HTTPS and self signed certificates
Hi, As I said in my post, the Ajax.Request call are in a HTML Application (HTA). Which is not a server page. It run on client machine using mshta.exe and request data from server using ajax. Ah, sorry. Probably not safe to assume everyone knows what you mean by HTA. I've seen any number of acronyms people have created ad hoc to make their web apps sound cool, I have to assume I put your use of HTA in that category, not being familiar with that specific Microsoft-centric technology. And I don't think the issue is due to Same Origin Policy, as the requests are working fine when server SSL is enabled using trusted certificate. In that case, it's a question for Microsoft. Prototype isn't involved in the certificate chain process at all. It just does the request and reads the response via XMLHttpRequest. The certificate stuff is handled by the user agent (e.g., mshta.exe). -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jun 12, 7:17 pm, Rick Avner rickav...@gmail.com wrote: Hi Crowder, Thanks for the information. As I said in my post, the Ajax.Request call are in a HTML Application (HTA). Which is not a server page. It run on client machine using mshta.exe and request data from server using ajax. And I don't think the issue is due to Same Origin Policy, as the requests are working fine when server SSL is enabled using trusted certificate. The response is blank when server SSL is enabled using self signed certificate. Any idea? And yes, I should try with latest version of prototype.js. Thanks On Jun 12, 3:05 pm, T.J. Crowder t...@crowdersoftware.com wrote: Addendum: I am using prototype.js version 1.5. Why? It's been out of date for more than three and a half years (assuming you're talking about v1.5.1.2, which was superceded by v1.6.0 in November 2007). That's a _long_ time in the browser-based world. -- T.J. On Jun 12, 10:36 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I don't think it has anything to do with the certificate being self- signed, just that it's https. Are you trying to use https in an ajax call when the page has been loaded via http? If so, you're running into the Same Origin Policy[1], which forbids doing that. Ajax requests, by default, can only go to the same origin as the document in which the script is running, and the concept of an origin includes the protocol (http://example.comandhttps://example.comare_different_origins). More in the link. If you're in control of the server, you have a couple of options: 1. Use JSON-P[2] instead of Ajax. JSON-P doesn't have an origin restriction, but it can only use the GET method, not POST. 2. If you can rely on using a modern browser, you can use the new CORS[3] standard. You can see a list of browsers and their support (or lack thereof) for CORS here[4]. Unfortunately, CORS is only supported by IE in IE8 and above, and that support requires extra work (whereas every other browser vendor who supported it did so in a backward- compatible way). Specifically, instead of using XMLHttpRequest (which is what Ajax.Request uses), you have to use a completely new XDomainRequest object instead. But again, only on IE. Note that using CORS requires that you add support for it to the server, because you have to handle a request from the browser asking if it's okay to send the cross-origin request. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com [1]http://en.wikipedia.org/wiki/Same_origin_policy [2]http://en.wikipedia.org/wiki/JSONP#JSONP [3]http://www.w3.org/TR/access-control/ [4]http://caniuse.com/#search=cors On Jun 12, 9:00 am, Rick Avner rickav...@gmail.com wrote: Hi, I have a HTML Application (HTA) using Ajax.Request to get information from one of my LAMP based server. The requests were working fine using HTTP. However, the requests are failing (responseText is blank) when I use HTTPS. Server SSL is enabled using self signed certificates. Is there any way to ignore certificate warnings while using Ajax.Request? I know I should use CA certified certificates on my server. However just wondering if there is any way for Ajax.Request to work with self signed certificates. I am using prototype.js version 1.5. Thanks in advance. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: problem in Event.observe()
Hi, This group works in English, so please translate any other languages when quoting. According to Google, that translates as: * * * * Error details page User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.2; .NET4.0C) Timestamp: Fri, 3 Jun 2011 09:17:26 UTC Message: Missing Objects Line: 3863 Character: 5 Code: 0 * * * * Event.observe(window,'load',test()); every thing is ok in firefox or chrome ,but in ie8 ,an error occured like this It seems unlikely that it works in Firefox or Chrome, because your #observe call is incorrect. You're *calling* the `test` function and passing its return value into `observe`. Since your `test` function doesn't return anything, the result of calling it is `undefined`. Instead, just pass a reference to your `test` function into `observe`, without calling `test`: Event.observe(window,'load',test); // ^--- No () here 我希望这有助于 ;-) -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jun 3, 10:22 am, 坤 操 madfro...@gmail.com wrote: function test(){ alert('adfsasdfdsaf');} Event.observe(window,'load',test()); every thing is ok in firefox or chrome ,but in ie8 ,an error occured like this 网页错误详细信息 用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.2; .NET4.0C) 时间戳: Fri, 3 Jun 2011 09:17:26 UTC 消息: 缺少对象 行: 3863 字符: 5 代码: 0 URI:http://vmck.com.cn/Windchill/netmarkets/javascript/util/prototype.js -- 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.