[Proto-Scripty] Re: Adding properties to native objects

2009-05-19 Thread Gabriel Gilini
On Tue, May 19, 2009 at 8:16 PM, RobG rg...@iinet.net.au wrote:

  On May 19, 9:26 pm, ColinFine colin.f...@pace.com wrote:
  This is a case when you really truly want just the facilities that
  Javascript provides (prototypes rather than classes), and using
  (pretend) classes makes it harder not easier.

 Yes, although some may argue that it is better to create a new object
 that has the required methods and leverages the methods of Date,
 rather than modifying a built-in object prototype[snip]

I fully agree on that, but since OP is using prototype.js, who already
extends a lot of built-in objects, it doesn't make a difference.

Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br

--~--~-~--~~~---~--~~
You received 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: toColorPart

2009-05-18 Thread Gabriel Gilini
On Mon, May 18, 2009 at 12:35 PM, Alaa ala...@gmail.com wrote:


 look, it is like:

 Var s= 10;
 alert(s.toColorPart()); // it works and prints 0a

 var a = $('valuesList').value;
 alert (a); //  prints 10 as in the textbox

 alert(a.toColorPart()); // does not work


Try `window.alert(typeof a)' -, I bet you won't get `number'.

Now try window.alert((a + 0).toColorPart());

Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Check element class against array

2009-05-14 Thread Gabriel Gilini
On Wed, May 13, 2009 at 3:34 PM, louis w louiswa...@gmail.com wrote:


 I have an array containing a number of strings. I would like to
 continue exucuting my script only if an item has ANY/ALL of the
 strings assigned as a class name.

 $A(['foo', 'bar', 'foob']);

 Is there an elegant want to do this without having to loop through the
 items?


Supposing you have the aforementioned element stored in the - elm -
variable, and the classes' array in the - classesArr - variable:

var classNamesRegex = new RegExp('\\b(' + classesArr.join('|') + ')\\b'); //
Generates /\b(foo|bar|foob)\b/

if(!classNamesRegex.test(elm.className)){
   window.alert('get me out of here');
}

Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Check element class against array

2009-05-14 Thread Gabriel Gilini
On Fri, May 15, 2009 at 12:05 AM, kangax kan...@gmail.com wrote:


 On May 14, 8:24 pm, Gabriel Gilini gabr...@usosim.com.br wrote:
  var classNamesRegex = new RegExp('\\b(' + classesArr.join('|') + ')\\b');
 //
  Generates /\b(foo|bar|foob)\b/

 Please don't use boundaries to separate class values. I wonder who
 came up with this silly idea and why it keeps circulating around.


 /\bfoo\b/ matches values such as foo-bar which is, of course, wrong.


Hm, I didn't know that. Actually I have never used /b myself, I didn't even
know they existed in JavaScript. I thought they would replace just fine the
(^|\s) thing (which is what I usually use).
Thanks for the advice.

Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br

--~--~-~--~~~---~--~~
You received 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: Overwrite onClick in IE

2009-03-24 Thread Gabriel Gilini
Are they all DOM 0 handlers? If so, just set them all to null.
links.each(function(el){el.onclick=null});

Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br
gabr...@souagil.com.br


On Tue, Mar 24, 2009 at 2:24 AM, tkane2000 tkthomp...@gmail.com wrote:


 ...long story as to why I need to do this, but I have a set of links
 that already have onClick event handlers set and I need to overwrite
 them.  If I could just get them to return false and do nothing else, I
 could use the observe method to the the rest.  Below is an example of
 what I mean:

 The following script works in FF3, but not IE7:

 div id=gallery
div class=thumb
div class=listItem
a href=http://www.cnn.com;
 onClick=location.href='http://www.google.com'
 class=thumbHolderthis is some text/abr /
/div
/div
 /div

 script type=text/javascript
var links = $$('#gallery .thumb .listItem .thumbHolder');
links[0].writeAttribute({onClick:alert('test');return false;}); //
 works in FF, but not IE
 /script

 Any idea why this works in FF but not IE?  Any hacks to get around
 it?  (keep in mind I can't edit the anchor tag directly...must do it
 through js)

 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: Using JSON/AJAX for more than just scalar data.

2009-01-28 Thread Gabriel Gilini
Just make sure that your server returns data with one of the following
content-types: application/ecmascript, application/javascript,
application/x-ecmascript, application/x-javascript, text/ecmascript,
text/javascript, text/x-ecmascript, or text/x-javascript
as explained in the API: http://www.prototypejs.org/api/ajax/options

Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br
gabr...@souagil.com.br


On Wed, Jan 28, 2009 at 12:34 PM, Richard Quadling rquadl...@googlemail.com
 wrote:


 Hi.

 Currently I use AJAX to send POST requests and receive JSON encoded
 data which is magically supplied as an object to me by Prototype in
 the onSuccess handler.

 I can then examine the data and process it as I need to.

 So far so good.

 I now need to do something I don't know how to do.

 The processing I mentioned above is essentially a switch statement
 which determines the processing I want. The specific case then
 extracts the parameters from the JSON object and calls the appropriate
 method/function with the extracted params. More functionality means
 more editing of this 1 function.

 What I want to achieve is a way to have my server supply the call that
 is to be made and when the response arrives at the client, it is just
 executed, without me having to decode it first.

 I want to have a shrink wrapped set of classes which are communicated
 with, essentially by the server.

 A simplistic example.

 Client performs some user interface action (clicks a button, drop down,
 etc.).
 This initiates an AJAX call to get some data.
 The server responds with the data using JSON.
 The onSuccess handler decodes the data client side and calls the
 appropriate functions to handle the response.

 I want this to become

 Client performs some user interface action (clicks a button, drop down,
 etc.).
 This initiates an AJAX call to get some data.
 The server responds with the data using JSON and the code required to
 handle the data.
 The onSuccess handler just runs the code.

 This will allow me to incrementally add functionality to the client as
 they move around the site.

 Regards,

 Richard Quadling.





 --
 -
 Richard Quadling
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 Standing on the shoulders of some very clever giants!

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: jQuery or Prototype ?

2009-01-21 Thread Gabriel Gilini
You might like to read Dion's opinion on this:
http://almaer.com/blog/why-i-often-prefer-prototype-too

Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br
gabr...@souagil.com.br


On Wed, Jan 21, 2009 at 9:41 AM, Jan Hansen j...@nhl-data.dk wrote:

  Thanks!

 Yes, tools are tools - and one should use the one that fits the task at
 hand best. However, it is difficult to actually know which tool to use if
 you dont know the tools well enuogh. I guess this is the reason developers
 tend to have a tendency of falling into the habit of once you've learned
 how to use a hammer, everything starts looking like a nail... Ah well...

 I'm not looking for arguments _not_ to use jQuery, but the current
 situation is that it is getting increasingly harder to convince co-workers
 that prototype is a valid choice. jQuery seem to have many more followers
 along with a more united community, whereas the prototype api pages are
 relatively short in larger examples. There is the unofficial wiki you set
 up which tries to help in several areas, which it does - and no, I haven't
 found time to contribute myself (yet.. argh...). Plugins/tools/whatever is
 found on scripteka and finally we have the scriptaculous website as well. I
 know that the prototype team now focuses on more scheduled releases, better
 documentation and the community as a general - which is good. I really hope
 it will help the ecosystem around prototype evolve. Im just looking for all
 you clever guys comments on what the differences between prototype and
 jQuery are, and how this could help me persuade others that just because MS
 decides to support a tool, doesnt mean that the others should be
 abandoned. But I believe that we have to do something now. Sigh... more
 work, and still no time...

 But thanks a lot for you insightfull answers!

 Best regards,

 /Jan





 On 21-01-2009 10:56, T.J. Crowder wrote:

 Hi,

 Tools are tools, use the one that does what you need and that you find
 comfortable.

 One thing I don't like about jQuery is all of the (in effect) function
 overloading.  I don't have a problem with overloaded functions
 provided they do essentially the same thing (in Java, for instance,
 it's how you do optional parameters).  But for example, the jQuery
 function (usually aka $) is just way too overloaded.  If you see:

 $(x);

 ...or

 jQuery(x);

 ...in someone's code, you have to look very carefully at 'x' to know
 what that's going to do.  It might

 1. Extend a raw element

 or maybe

 2. Search for elements matching a CSS selector

 or it could

 3. Register a function to be called when the DOM is ready

 but don't forget that instead it might

 4. Create DOM elements from an HTML string.

 Yikes.  That's asking for maintenance problems IMHO, even if you don't
 have junior staff -- and especially if you do.

 In a similar vein, I don't like the fact that a number of jQuery's
 functions are dual-mode:  They do one thing if you pass in a
 parameter, something else if you don't.  If you write:

 x = $('#frog').html('ribbit');

 ...you're setting the inner content of the 'frog' element to the text
 'ribbit'.  But if you write:

 x = $('#frog').html();

 ...you're *retrieving* the content of 'frog'.  So the html() function
 has to check arguments.length every time you call it (except it
 doesn't, see note about subtle bugs below) to figure out whether it's
 a set or get operation, even though you've ALREADY done that
 differentiation in your code.  Now, I know branch-on-test is very fast
 these days, but I still don't see any excuse for requiring the library
 to do that runtime check on every call.  Just use different names,
 f'chrissake. :-)  And there's that maintenance aspect again -- it's
 unusual for functions to change meaning in that way.  Granted, this
 isn't *totally* dissimilar to using a property (where what happens
 depends on whether it's on the left- or right-hand side of the
 assignment operator), but it's different enough to cause hassles.

 Oh!  And quick:  What does 'x' refer to in the above two statements?
 You guessed it, it depends on whether you passed a parameter into html
 () or not.  If you did, html() returns a jQuery object (for chaining
 purposes); if you didn't, it returns a string (the content of the
 element).  Say what?

 These dual-mode functions make some bugs in your code even more subtle
 than they need to be.  Consider:

 function buggyFunction(count) {
 var display;
 if (count  minThreshold) {
 display = 'Need more thingies';
 } else if (count  maxThreshold) {
 display = 'Too many thingies!';
 }
 $('#levelmessage').html(display);
 }

 The author of the function messed up and forgot to set 'display' to
 anything if minThreshold = count = maxThreshold (they probably
 wanted ''), and so 'display' is undefined when passed into html() in
 that case.  Now, does that show the text 'undefined'?  No.  It doesn't

[Proto-Scripty] Re: event.observe document

2008-12-14 Thread Gabriel Gilini
Use the Event.element method to find out who triggered the event, then check
if you want to do your stuff or not.
Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br
gabr...@souagil.com.br


On Sun, Dec 14, 2008 at 3:37 PM, Stucture_Ulf 
maximilian.moulet...@gmail.com wrote:


 I'm using keyboard short cuts with Event.observe document. I do not
 want these to be activated when using certain input fields on the
 site. So my question is how I temporarily disable these document
 shortcuts when these input fields are in focus.grateful for tips.
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Extracting the name from a JSON object

2008-12-05 Thread Gabriel Gilini
I forgot to say that apparently Safari = 2.0 and IE5.2 on mac doesn't
implement the hasOwnProperty method.

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Fri, Dec 5, 2008 at 8:01 PM, Gabriel Gilini [EMAIL PROTECTED]wrote:

 If you want to iterate through an array with the constructor object's
 prototype extended use Object.prototype.hasOwnProperty().

 var arr = [0,1,2,'foo','bar'];

 for(var i in arr){
if(arr.hasOwnProperty){
   if(arr.hasOwnProperty(i))
  alert(arr[i]);
}
 }

 Gabriel Gilini

 www.usosim.com.br
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]



 On Fri, Dec 5, 2008 at 11:37 AM, T.J. Crowder [EMAIL PROTECTED]wrote:


 Hi George,

 (It's a JavaScript rather than Prototype/script.aculo.us question,
 yes.)

 This object literal / JSON data:

 [{bookingref:'A6D98FGR', canceled:0}]

 ...defines an array with a single element, which is an object instance
 with two properties:  bookingref (value 'A6D98FGR') and canceled
 (value 0).

 You can get the values just by referring to the properties of the
 object, so:

 var x = RS[0].bookingref;
 alert(x); // Alerts 'A6D98FGR'

 JavaScript allows you to use property names both literally with dot
 notation (as above), and _also_ via string names using bracket
 notation; we could write the above like this instead:

 var x = RS[0]['bookingref'];
 alert(x); // Alerts 'A6D98FGR'

 Note the quotes, the square brackets, and the absense of the dot.

 If you don't know the names of the properties in advance, you can use
 the for..in loop to iterate over the names of the object's properties:

 var name;
 for (name in RS[0]) {
alert(name + '=' + RS[0][name]);
 }

 In the loop, the variable 'name' is set on each iteration to the name
 of a property on the object, as a string.  This is powerful when
 combined with bracket notation.  On the object defined in your JSON
 above, that will show bookingref=A6D98FGR and canceled=0; the
 order is not defined and almost certainly will vary from
 implementation to implementation.

 Note that for..in is for iterating over the properties of an object,
 *not* the elements of an array.  Many JavaScript programmers think
 it's for the latter, and they get into trouble as a result because
 Prototype adds some properties to arrays that they're not expecting to
 see.  Details:
 http://proto-scripty.wikidot.com/prototype:tip-looping-through-arrays

 But again, it's totally fine for looping through the properties on an
 object, like your RS[0].

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com

 On Dec 5, 12:18 pm, George [EMAIL PROTECTED] wrote:
  Hi Folks,
 
  This may be more of a pure JavaScript question than Prototype, but
  here goes:
 
  If I have a JSON array called RS for example containing this:
[{bookingref:'A6D98FGR', canceled:0}]
  is there a way for me to programatically get the names and values?
 
  I'd like to be able to do something like
   RS[0].[0].name ((would be 'bookingref'))
   RS[0].[0].value ((would be 'A6D98FGR'))
 
  I hope that makes sense.
 
  Many thanks
 
  George
 



--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: update two container by one ajax call

2008-11-25 Thread Gabriel Gilini
Sorry, forgot the thread URL.

[1]
http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/9dbd642d6e625cff?hl=en

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Tue, Nov 25, 2008 at 2:34 PM, Gabriel Gilini [EMAIL PROTECTED]wrote:

 On Tue, Nov 25, 2008 at 2:17 PM, Miguel Beltran R. [EMAIL PROTECTED]wrote:
 [snip]

 script type=text/javascript


 window.observe('dom:loaded', function (){


 Just change this to document.observe('dom:loaded', function(){
 As seen in a thread[1] a few days back, dom:loaded is a document event.

 [snip]

 Gabriel Gilini

 www.usosim.com.br
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]



--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: update two container by one ajax call

2008-11-25 Thread Gabriel Gilini
On Tue, Nov 25, 2008 at 2:17 PM, Miguel Beltran R. [EMAIL PROTECTED]wrote:
[snip]

 script type=text/javascript


 window.observe('dom:loaded', function (){


Just change this to document.observe('dom:loaded', function(){
As seen in a thread[1] a few days back, dom:loaded is a document event.

[snip]

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: The Hop Effect

2008-11-25 Thread Gabriel Gilini
On Tue, Nov 25, 2008 at 4:02 PM, Walter Lee Davis [EMAIL PROTECTED]wrote:

 To support IE6, may it rest in pieces.

That's no excuse, you could easily support IE6 with a little conditional
commenting.
But you obviously wouldn't achieve the smooth scrolling effect.

[snip]

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: The Hop Effect

2008-11-25 Thread Gabriel Gilini
On Tue, Nov 25, 2008 at 4:20 PM, Walter Lee Davis [EMAIL PROTECTED]wrote:

 If you looked at the script I posted, you'd see that I only attach the
 behavior if the browser doesn't work correctly. Naturally, if the browser is
 non-broken, we don't want to punish it in any way.


Yes, I did look at it, but my statement is still valid.

!--[if lte IE 6]
style
   body{
   height: 100%;
   overflow: auto;
   }

   #menu{
   position: absolute;
   }
/style
![endif]--

And there you have it. No UA-sniffing, no JavaScript at all.

The downside? Everything positioned as absolute will act like fixed in IE6
and lower. But that should be no problem.

And again, with this or yours solutions you can *not* achieve the smooth
scrolling effect. Get it now?

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: select only text (i.e. textnodes, probably) using $$

2008-11-19 Thread Gabriel Gilini
You could check if the firstChild of the element in question is a textNode.

i.e.:

var c = el.firstChild;
if(c.nodeType == 3){ //text node
   el.update(...);
}

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Wed, Nov 19, 2008 at 9:22 PM, lskatz [EMAIL PROTECTED] wrote:


 Hi,
 I want to automatically set up abbreviation tags everywhere in my
 document, and it works great, except I am altering the innerHTML to do
 so and sometimes some crazy results happen.  For instance, an input's
 value should be untouched because the value should not be value=abbr
 title='united states of america'USA/abbr

 I believe the way to go would be to select for textnodes but I cannot
 figure out why that wouldn't work.  Anyway, any help to fix my code
 would be appreciated (I hope the indentation is preserved when I post
 this).

 // find and add in abbr all over the place!
 var replacing={
'TSV':'Tab-Separated Values',
'CSV':'Comma-Separated Values',
   'STs?':'Sequence Type',
   'CCs?':'Clonal Complex',
   'MGIP':'Meningococcus Genome Informatics Platform',
   'MLST':'Multilocus Sequence Typing',
   'GIT':'Georgia Institute of Technology',
   'CDC':'Centers for Disease Control and Prevention',
   'OMP':'Outer Membrane Protein'
};
 $$('.systemMessage, .body p,.body
 div,label,h1,h2,h3,h4,.menu.firefox').each(function(el){
  if(el.hasClassName('doNotDisturb')){
return; // equivalent to a continue inside of an each loop
  }
  el.select('text').each(function(s){
debug('textNode: '+s);
  });
  for(var k in replacing){
var v=replacing[k];
var find=new RegExp('\\b('+k+')\\b','g');
// I should use something like innerContext or innerText
 instead of innerHTML
el.update(el.innerHTML.replace(find,acronym title='+v+'
 $1/acronym,''));
   }
 });

 


--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Attaching onload event while creating new img tag

2008-11-13 Thread Gabriel Gilini
On Thu, Nov 13, 2008 at 6:43 PM, Diodeus [EMAIL PROTECTED] wrote:

 So how do I do this? I know I could create the element with the
 onload, then set the src separately later in the code, but I would
 prefer to do it all inside the new Element constructor.


I honestly can't see the harm in doing

var foo = new Element(img, {
   id: 'something'
});
foo.observe('load', function() {
   // onload code here
});
foo.src = myImage;
$('placeholder').insert(foo);

I can understand that one can find chaining the coolest thing and all,
but what's with this fixation of writing everything in one line?

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: node.select in IE7

2008-11-13 Thread Gabriel Gilini
On Thu, Nov 13, 2008 at 4:17 PM, AlannY [EMAIL PROTECTED] wrote:


 Hi there. I'm working on simple script that must work on all browsers,
 which prototype supports.

 There are code:
 var edit = node.select('a#edit')[0];
 if( edit ) {
 ...
 }


What's node?

How to fix it?


$(node).select(...) should probably fix it for you

Cheers

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: testing whether all elements in a div have a certain class

2008-10-31 Thread Gabriel Gilini
Indeed, I don't know why I said that lol.I guess I was thinking of var or
function name.

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Fri, Oct 31, 2008 at 6:20 PM, Jarkko Laine [EMAIL PROTECTED] wrote:


 On 31.10.2008, at 21.25, Gabriel Gilini wrote:

  I'm thinking $$(eval('#container_'+boxID+' span'));
  Don't know if it's the right thing to do though.

 Why would you want to eval that string?

 Matt, could you elaborate a bit more?

  $$('#container_'+boxID+' span');

 actually looks to be fine. What are you getting with it and what are
 you expecting?

 //jarkko

 --
 Jarkko Laine
 http://jlaine.net
 http://dotherightthing.com
 http://odesign.fi

 Check out my latest book, Unobtrusive Prototype, fresh off the
 Peepcode oven:
 http://peepcode.com/products/unobtrusive-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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Element.update()

2008-10-30 Thread Gabriel Gilini
Well, first of all, try quoting your hash keys like this:
list.each(function(item){
   var newOption = new Element('option',
{'innerHTML':item.nm,'value':item.id});
   selectList.insert({bottom:newOption});
   });

If it still doesn't work, try using firebug's[1] console and debug to see
any exception the script might be throwing.

[1] www.getfirebug.com

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Thu, Oct 30, 2008 at 5:30 PM, cyiam [EMAIL PROTECTED] wrote:


 HELP! This is the first time I have my script working for IE but not
 for Firefox.
 I have a 3 drop downs. The first dropdown dictates what will be shown
 on the second. And second drop down dictates the third. I use
 Ajax.Request() to get the drop down values from database. onSuccess, I
 call the function below:

 function updateList2(list){
var selectList = $('list2');
selectList.update();

var newOption = new Element('option',{innerHTML:'-- Select One
 --',value:''});
selectList.insert({bottom:newOption});
if (list){
list.each(function(item){
var newOption = new Element('option',
 {innerHTML:item.nm,value:item.id});
selectList.insert({bottom:newOption});
});
}
 }

 Works fine in IE, but when Firefox will not insert the new options
 into the list!

 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Simple, unobtrusive way to open all links marked external

2008-10-30 Thread Gabriel Gilini
What's the error that the script's throwing?
Also, are the elements in the result enum already extended[1]? If not,
switch element.observ to $(element).observe.

[1] http://prototypejs.org/learn/extensions

Cheers

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Thu, Oct 30, 2008 at 5:07 PM, [EMAIL PROTECTED]
[EMAIL PROTECTED]wrote:


 Hi guys,

 I'm learning the prototype library after coming from jQuery, and I'm
 trying to write a simple snippet that opens external links in a new
 window.

 This doesn't seem to work in Firefox, or Safari, and I'm not sure what
 I'm doing wrong here,

 I'm sure it's something really obvious, but I've been staring at this
 code for so long now that I've effecitvely gone snow blind.

 Can anyone help?

 I'm using prototype 1.6.0.1, and I'm on a mac.

 // goal - select all external links and onclick, open that link in a
 new window, in an unobtrusive manner

 var openNewWindow = function(element) {
element.observe('click', function() {window.open(element.href);} );
 };

 // begin constructing regexp that makes any url with the host domain
 in it, and with the optional www prefix
 var internalUrl = / + (www)? + document.location.hostname + /;

 // turn string into regexp to match against
 var pattern = eval(internalUrl);

 // reject all links whose href matches the host domain regexp defined
 above
 filteredResult = result.reject(function(e) {
return e.href.match(pattern);
});

 add onclick handler each member of the array of remaining links
 filteredResult.invoke('openNewWindow');






 


--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Strange .update Error?

2008-10-30 Thread Gabriel Gilini
Well, that's weird. It could be a bug, you should probably fill a ticket
with some sample code and a copy of the error message at Lighthouse[1].
[1] http://prototype.lighthouseapp.com/projects/8886-prototype

Cheers

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Thu, Oct 30, 2008 at 8:24 PM, cyiam [EMAIL PROTECTED] wrote:



 I couldn't get update to work correctly, so I ended up clearing the
 element out, then do an Element.insert.

 On Oct 30, 4:20 pm, Jonathan Rosenberg [EMAIL PROTECTED] wrote:
  I'm having what I think is a weird problem with .update on IE.
 
  This statement fails:
 
  this._question.update(divYou/div)
 
  but this works
 
  this._question.update(spanYou/span)
 
  It fails in the prototype.js code, but only on IE.
 
  Any thoughts?
 
  --
  Jonathan Rosenberg
  Founder  Executive Director, Tabby's Placehttp://www.tabbysplace.org/

 


--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Iframe issue with IE7 (probably 6)

2008-10-29 Thread Gabriel Gilini
Thomas,
Some sample code and HTML would help immensely.

Cheers
Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Wed, Oct 29, 2008 at 5:37 PM, Matt Foster [EMAIL PROTECTED] wrote:


 Very strange, not sure if i understand completely. So there is an
 internal iFrame object that is getting references from its containing
 document object.  When the iframe reloads it no longer has these
 references? Wouldn't a reload of the iframe force it to retrieve fresh
 references as everything internal is lost?  Does the parent page take
 an action on the IFrame on its initial load that isn't being taken on
 the iframe refresh?



 On Oct 29, 10:43 am, Thomas A [EMAIL PROTECTED] wrote:
  The reference is the other way round. The Iframe content references
  for example buttons or divs of the surrounding html page. And if the
  iframe reloads or changes the page, it tries to rereference these
  elements but fails on IE.
 


--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Stopping page from moving back to top

2008-10-27 Thread Gabriel Gilini
Place this inside anFunction:
evt.stop();

it stops the default behavior of the current event, which in your case is
following a link.

ps: shouldn't it be called aFunction? :)

Cheers,

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Mon, Oct 27, 2008 at 2:47 PM, jason maina [EMAIL PROTECTED] wrote:

 That one is not working also producing error...

 On Mon, Oct 27, 2008 at 7:42 PM, Brian Williams [EMAIL PROTECTED]wrote:

 try javascript:void(); in place of javascript:return false;




 On Mon, Oct 27, 2008 at 12:22 PM, jason maina [EMAIL PROTECTED]wrote:

 Hi all,

 Im having this page with tabs in another page but added through php.
 Thing is when I click on a tab and the page was like halfway it scrolls
 to the top I know it is connected to the hashes in the href bit but dont
 know how to tweak it to stop from this behaviour. Tried remedying with
 replacing it(#) with javascript:return false; but it generates an error
 though it doesnt scroll.

 Here is my code:

 http://pastie.org/301494

 on the page the code is like :
 ul id=tablist
   lia href=# id=tb1 class=Race 1/a/li
   lia href=# id=tb2 class=Race 2/a/li
   lia href=# id=tb3 class=Race 3/a/li
 /ul


 Kind regards
 Jason







 


--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: login popup window

2008-10-27 Thread Gabriel Gilini
What you're looking for is probably Basic Access Authentication[1], if
you're using Apache with Phusion Passenger (aka mod_rails) this[2] will
probably help you.

Also, rails should provide a very easy way to do it, but I just don't know.

[1] http://en.wikipedia.org/wiki/Basic_access_authentication
[2] http://httpd.apache.org/docs/1.3/howto/auth.html

Cheers,
Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Mon, Oct 27, 2008 at 4:23 PM, Bob O [EMAIL PROTECTED] wrote:


 Im not sure if i need to post this here, or in the rails group, but
 maybe someone can help me out.

 I have a current rails app with a typical user login page blah
 blah...what im trying to accomplish is to have a popup window open
 with a login and password field to log a user in from the current
 secure page. The main reason for this is for branding purposes..

 i.e.

 www.mysite.com/branded_client_page - I want to be able to distribute
 this url for the client, and then have the user login right from that
 page (and not be redirected to the mysite/login page) so im trying to
 create a login popup that will appear over that page if the user is
 not logged in.

 any direction would be great

 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: unescape HTML tags

2008-10-15 Thread Gabriel Gilini
 a = 'trtdlt;bgt;Note from 14.10.2008 23:02:59lt;bgt;lt;br
/gt;/td/tr'
trtdlt;bgt;Note from 14.10.2008 23:02:59lt;bgt;lt;br
/gt;/td/tr
 a.unescapeHTML()
bNote from 14.10.2008 23:02:59bbr /

because of this, I guess

@buda
I think that you will have to use some regex on those

Gabriel Gilini

www.usosim.com.br
[EMAIL PROTECTED]
[EMAIL PROTECTED]


On Wed, Oct 15, 2008 at 1:35 PM, kangax [EMAIL PROTECTED] wrote:


 On Oct 15, 6:23 am, buda [EMAIL PROTECTED] wrote:
  How to unescape HTML tags if they are as part of valid HTML string?

 I'm not sure I understand. Why can't you apply `unescapeHTML`? Do you
 need to strip certain tags?

 --
 kangax

 [snip]
 


--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---