[Proto-Scripty] Re: the effect in Effect.toggle does not work

2009-04-27 Thread Ram

At last, a fairly large hint. With the following code, when I put the
Javascript inline, the effect works. Whereas if I put it in an
external JS file, include that in the head and call the function (like
shown below), it doesnt work.

HTML Source

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
script src=http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/
prototype.js type=text/javascript/script
script src=http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/
scriptaculous.js type=text/javascript/script
script src=/javascripts/application.js type=text/javascript/
script
titleComments/title
meta http-equiv=Content-type content=text/html; charset=utf-8 /
style type=text/css media=screen
body { background-color: #000; font: 16px Helvetica, Arial; color:
#fff; }
/style
/head
body
a href=# onclick=toggle_comments();; return false;Comments/a
div style=display:none; background-color: red; id=comments-
section
HI!
a href=# onclick=toggle_comments();; return false;Close/a
/div
/body
/html

application.js

function toggle_comments() {
new Effect.toggle('comments-section', 'slide');
}
... FOLLOWED BY MANY OTHER CUSTOM JS FUNCTIONS ...


What works, is the following

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
script src=http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/
prototype.js type=text/javascript/script
script src=http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/
scriptaculous.js type=text/javascript/script
titleComments/title
meta http-equiv=Content-type content=text/html; charset=utf-8 /
style type=text/css media=screen
body { background-color: #000; font: 16px Helvetica, Arial; color:
#fff; }
/style
/head
body
a href=# onclick=new Effect.toggle('comments-section', 'slide');;
return false;Comments/a
div style=display:none; background-color: red; id=comments-
section
HI!
a href=# onclick=   new Effect.toggle('comments-section',
'slide'); ; return false;Close/a
/div
/body
/html

Think thats boils things down considerably.. Walter, any idea where I
might be breaking this in application.js? Maybe I have bad syntax in
the rest of the functions in it? But all the other functions work
fine..

On Apr 25, 7:44 pm, Walter Lee Davis wa...@wdstudio.com wrote:
 Can you go to the tab where you see it broken, view source, copy and  
 paste it into

 http://validator.w3.org/#validate_by_input

 and see if there's anything up there?

 Prototype is sensitive to standards, and you may eliminate some of  
 your problem by starting with a clear page.

 Walter

 On Apr 25, 2009, at 7:29 AM, Vinay Seshadri wrote:

  What could possibly be the difference?
--~--~-~--~~~---~--~~
You received 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: Robert Penner's easing equations for Scriptaculous 1.8

2009-04-27 Thread Riccardo De Agostini

A corrected version (as well as future versions, if any) can be found
here:
http://snipplr.com/view/14458/robert-penners-actionscript-easing-functions-ported-to-scriptaculous-18/

--~--~-~--~~~---~--~~
You received 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] Calling function every time PeriodicalUpdater makes a request

2009-04-27 Thread BryanG

I'm trying to call a JavaScript function every time PeriodicalUpdater
makes a request (so I can check the response to see if the
PeriodicalUpdater needs to be stopped).

I've tried numerous methods - creating a responder for OnComplete,
passing an OnComplete callback, and having the web page that
PeriodicalUpdater calls return A JS call to the function - nothing has
worked (the first two caused the function to be executed only once,
not every time a PU was performed).

I've tried both prototype 1.6.1_rc2 and 1.6.0.3 and get the same
response.  I've also tried searching through the group, but have not
come across anyone with this same issue.

Here's the web page code I'm using:
var updater = Ajax;

function init() {
  updater = new Ajax.PeriodicalUpdater('', 'get_status2.php', {evalJS:
true, evalScripts: true, method: 'get', frequency: 1, decay: 1 });
}

And here's the output I'm sending from get_status2.php (I've tried
this both with and without the header of the response containing a
Content-type of text/javascript):
script type=text/javascriptalert(null);/script

I do see this response being returned properly in Firebug.  I've tried
this on FF 3.0.9 and IE and get same result.

Was wondering if anyone had any ideas of what I might be doing wrong
(this is my first time using Prototype, so feel free to suggest
stupid mistakes), or had a suggestion of how to solve this problem.
Obviously, I've got a different function that I plan to use to check
the response and stop the PU if needed - I think I'll be OK there, but
I just can't get a function to be called on every update.

Thanks,
Bryan

--~--~-~--~~~---~--~~
You received 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] adding and removing classnames

2009-04-27 Thread Jeff

i'm new to prototype. i was using jQuery and loved it and am a little
confused coming over to prototype. i am trying to add and remove a
class of active to a labels parent div. does anyone know why i can't
do this?

i've tried this

div id=submit-choices'

div
input /labelmy label/label
/div

div
input /labelmy label/label
/div
/div!-- close submit-choices div --

  Event.addBehavior({
'#submit-choices label:click' : function() {
removeClassName($('submit-choices div'), 'active');
this.addClassNAme('active')
  }
}
  })

and also

  Event.addBehavior({
'#submit-choices label:click' : function() {
  var divs = document.getElementById('submit-
choices').getElementsByTagName('div');
  if ( divs.hasClassName('active' )) {
divs.removeClassName('active');
this.addClassNAme('active')
  }
}
  })

it keeps saying divs.hasClassName is not a function. i mean wtf?

--~--~-~--~~~---~--~~
You received 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] equivalent of the onAvailable YUIEvent?

2009-04-27 Thread Mark Mansour

Hey guys,

I'm looking for the earliest point to execute a method when a HTML
element is available.  Currently I can only get my desired usability
by inlining the javascript (you can see the dom change when I use
dom:loaded).  I noticed that YUIEvent has an onAvailable event [http://
developer.yahoo.com/yui/event/#onavailable] and wondered if there was
an equivalent for prototype (or if this is the best solution!)

Mark

--
Mark Mansour
m...@stateofflux.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: Calling function every time PeriodicalUpdater makes a request

2009-04-27 Thread T.J. Crowder

Hi Bryan,

The docs for the PeriodicalUpdater[1] say that it supports all of the
standard Ajax.Options[2], and so I would expect onSuccess, onComplete,
etc. to work.  But there's a note at the bottom of the PU docs saying
specifically to use onSuccess since onComplete is hijacked for
another purpose (it appears to get fired when you stop the PU via the
stop() method).

So use onSuccess:
* * * *
pe = new Ajax.PeriodicalUpdater(target, url, {
onSuccess:  function() {
/* Your code here */
}
});
* * * *

If for some other reason you want to have script code in the retrieved
content get executed, include a script tag in the content and specify
the evalScripts: true option in the PU's options:
* * * *
pe = new Ajax.PeriodicalUpdater(target, url, {
evalScripts: true,
onSuccess:  function() {
/* Your code here */
}
});
* * * *

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Apr 26, 10:27 pm, BryanG bgond...@gmail.com wrote:
 I'm trying to call a JavaScript function every time PeriodicalUpdater
 makes a request (so I can check the response to see if the
 PeriodicalUpdater needs to be stopped).

 I've tried numerous methods - creating a responder for OnComplete,
 passing an OnComplete callback, and having the web page that
 PeriodicalUpdater calls return A JS call to the function - nothing has
 worked (the first two caused the function to be executed only once,
 not every time a PU was performed).

 I've tried both prototype 1.6.1_rc2 and 1.6.0.3 and get the same
 response.  I've also tried searching through the group, but have not
 come across anyone with this same issue.

 Here's the web page code I'm using:
 var updater = Ajax;

 function init() {
   updater = new Ajax.PeriodicalUpdater('', 'get_status2.php', {evalJS:
 true, evalScripts: true, method: 'get', frequency: 1, decay: 1 });

 }

 And here's the output I'm sending from get_status2.php (I've tried
 this both with and without the header of the response containing a
 Content-type of text/javascript):
 script type=text/javascriptalert(null);/script

 I do see this response being returned properly in Firebug.  I've tried
 this on FF 3.0.9 and IE and get same result.

 Was wondering if anyone had any ideas of what I might be doing wrong
 (this is my first time using Prototype, so feel free to suggest
 stupid mistakes), or had a suggestion of how to solve this problem.
 Obviously, I've got a different function that I plan to use to check
 the response and stop the PU if needed - I think I'll be OK there, but
 I just can't get a function to be called on every update.

 Thanks,
 Bryan
--~--~-~--~~~---~--~~
You received 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: adding and removing classnames

2009-04-27 Thread T.J. Crowder

Hi,

Welcome!  You'll find it a bit of an adjustment moving from jQuery to
Prototype, but there's a lot of good stuff to get into.  I'd recommend
having a good, thorough read through the API docs[1] to get started
with, just so you know what's available to you.  Takes about an hour,
but pays you back dramatically in saved time.

One of the biggest things you'll need to get used to is that Prototype
does not conflate the concepts of an Element and an Array or list --
they're clear and distinct concepts.  jQuery does a lot of that kind
of conflation, which some like and others don't.  So the methods that
are available on Element (like addClassName and removeClassName) are
not available on Array, you must explicitly walk through the array --
although Prototype provides a lot of nifty stuff to help you do so.

I can't comment on anything specific to Event.addBehavior since I've
never used that plug-in (that's not Prototype, it's an add-on -- Low
Pro, I think).  But there are some errors in the code I can help with
that I'm reasonably sure don't relate to that part of things:

 div id=submit-choices'

I'm guessing that you typed in the HTML structure, rather than copy-
and-paste?  You're opening with  there, but closing with '.

   Event.addBehavior({
 '#submit-choices label:click' : function() {
 removeClassName($('submit-choices div'), 'active');
 this.addClassNAme('active')
   }
 }

A couple of issues there:

1. You're using removeClassName as an unqualified reference, and so it
will be resolved relative to the scope chain.  In the code you've
quoted, I don't see a containing scope that will have a
removeClassName function.  You probably want Element.removeClassName,
but...

2. ...you're using $() and giving it a selector-like string (submit-
choices div), although without the # at the beginning.  $() is purely
for looking up elements by ID[2].  If you want to find elements by
selector, you want $$()[3] to do it at the document level, or
Element#select[4] to do it within a given element (e.g., searching its
descendants).

   var divs = document.getElementById('submit-
 choices').getElementsByTagName('div');
   if ( divs.hasClassName('active' )) {
 divs.removeClassName('active');
 this.addClassNAme('active')
   }
 }

Here's that conflation problem.  You're setting 'divs' to a NodeList,
then calling a method from Prototype's Element extensions on it.
NodeLists aren't Elements, they're NodeLists.  You want to operate on
each item in the list.  In Prototype, if the goal is to remove
'active' from all divs within submit-choices and then add active to
the label on which the click occurred (assuming Low Pro hooks up
handlers using Element#observe), this would do it:

$('submit-choices').select('div').invoke('removeClassName',
'active');
this.addClassName('active');

That uses $()[2] to look up the submit-choices div, then Element#select
[4] to get an array of its decendant divs, then Enumerable#invoke[5]
to look through that array calling the 'removeClassName' method on
each element and passing in 'active' (Element#removeClassName is okay
with being called when the class name isn't on the element; it's just
a no-op).

I'd probably approach the whole problem differently, though.  If the
goal is that clicking a label will mark its parent div as active and
clear any other active divs, and that all of this happens within a
container called 'submit-choices', I would probably put one single
handler on submit-choices rather than using Low Pro to hook up every
label within it.  Clicks bubble up, so a click on the label will be
seen by submit-choices barring someone stopping it.  So this would be
all that you needed:

* * * *
document.observe('dom:loaded', function() {
$('submit-choices').observe('click', function(event) {
var label;
var div;

label = event.findElement('div  label');
if (label) {
div = label.up();
this.select('div.active').invoke(
'removeClassName',
'active');
div.addClassName('active');
event.stop();
}
});
});
* * * *
(Also on Pastie: http://pastie.org/459429)

That one handler, on submit-choices, looks to see if the click was on
a label with a div as an immediate parent.  If it was, it will remove
the active class from all active divs within the container, then
add the active class to the parent.  Key bits of the above are
document.observe's dom:loaded event[6], the fact that Element#observe
[7] ensures that this within the event handler refers to the element
on which the event is hooked (so this is submit-choices within th
ehandler), and Event#findElement[8].  I think nowadays findElement
actually accepts a full CSS selector, but the docs for it still just
say tag name so I haven't relied on that above; instead I explicitly
check the parent's tag name.

You can add and remove divs within the submit-choices 

[Proto-Scripty] displaying Server time using Ajax.periodicaUpdater

2009-04-27 Thread Palastina Uber Alles

Hello everyone,
I am new to prototype, and I am trying to implement a simple ajax
request
I wrote the index.html file, and the clock.html file

index.html

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
meta http-equiv=content-type content=text/html; charset=utf-8 /
title Test Page /title
script type=text/javascript src=../prototype.js/script
script
function getClock() {
var url = 'data/clock.html';
var myAjax = new Ajax.PeriodicalUpdater(
'clockArea',
url,
{
method: 'get',
frequency: 2,
onFailure: function(resp) {alert(Failure : +
resp.statusTest,test);},
onException : function(resp, 
exception){alert(exception +
exception,test);}
});
}
/script
/head
body
input type=button value=Test onclick=getClock();/br/ br/
br/
pdiv id=clockArea/div/p
/body
/html

and the clock.html


html
head
script type=text/javascript
function display()
{
var myscriptTime  = new Date();
document.write(myscriptTime)

}
/script
/head
body onload=display()

/body
/html



clock.html displays the date correctly, but when I click the btn in
the first file the time is not displayed
and there is no errors. onSuccess it alerts a msg



any body can help me please.
--~--~-~--~~~---~--~~
You received 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: Is there a way to determine absolute coordinates of an element on the screen?

2009-04-27 Thread ColinFine



On Apr 26, 10:56 pm, buda www...@pochta.ru wrote:
 this gets coordinates in a page but I need to translate them to screen


Does Element.getViewportOffset() not help?

Colin

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



[Proto-Scripty] Re: the effect in Effect.toggle does not work

2009-04-27 Thread Walter Lee Davis

What does Firebug say, specifically, when a function fails to run?  
Does it error at all? Can you put breakpoints in your code (or alert  
statements) and see if it is being called? You say that there are  
other functions which work fine, are they in the same application.js  
file?

Walter

On Apr 27, 2009, at 2:22 AM, Ram wrote:

 Think thats boils things down considerably.. Walter, any idea where I
 might be breaking this in application.js? Maybe I have bad syntax in
 the rest of the functions in it? But all the other functions work
 fine..


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



[Proto-Scripty] Re: the effect in Effect.toggle does not work

2009-04-27 Thread Vinay Seshadri
Hi Walter,
Ive solved the problem!! AWOOHOO!! :)

ok you're probably gonna punch me but I really have no idea why this is
happening.

I use this helper method javascript_include_tag :defaults to include my
default javascripts in my head tag. This method is in-built in Rails and it
generates the following HTML for me.

script src=/javascripts/prototype.js?1240656994
type=text/javascript/script
script src=/javascripts/effects.js?1240656994
type=text/javascript/script
script src=/javascripts/dragdrop.js?1240656994
type=text/javascript/script
script src=/javascripts/controls.js?1240656994
type=text/javascript/script
script src=/javascripts/widgets/tooltip.js?1237809444
type=text/javascript/script
script src=/javascripts/application.js?1240826026
type=text/javascript/script

I've noticed the ?1240656994 before but dint think much of it cos my JS
always worked. Now, if i include the following line instead, it works fine!

script src=/javascripts/prototype.js type=text/javascript/script

Im so sorry to have put you through all that only for it to end up being
something so silly!!
Im going to see if anyone else has discussed such behaviour before anywhere
online. If not, gonna start a thread in a Rails forum to see what others
think about it.

Thanks again for helping me through this Walter. Really appreciate it :)

On Mon, Apr 27, 2009 at 5:31 PM, Walter Lee Davis wa...@wdstudio.comwrote:


 What does Firebug say, specifically, when a function fails to run?
 Does it error at all? Can you put breakpoints in your code (or alert
 statements) and see if it is being called? You say that there are
 other functions which work fine, are they in the same application.js
 file?

 Walter

 On Apr 27, 2009, at 2:22 AM, Ram wrote:

  Think thats boils things down considerably.. Walter, any idea where I
  might be breaking this in application.js? Maybe I have bad syntax in
  the rest of the functions in it? But all the other functions work
  fine..


 



-- 
In Sport We Trust !!!

--~--~-~--~~~---~--~~
You received 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] Using this.arrayname to add data to an array not working

2009-04-27 Thread Imbi Rehling

Hello to all, my first post to this group!
I am new to OOP in JavaScript and have written my first Js Class using 
prototype.js..
On the 'Learn pages' at prototypejs.org the example for 
'Classes-Inheritance' shows the following..

var Logger = Class.create({
  initialize: function() {
// this is the right way to do it:
this.log = [];
  },
  write: function(message) {
this.log.push(message);
  }
});

For some reason I can't seem to add to the array using 'this.arrayName'.
I have tried also this.arrayName[i] = value;
I initialize the array using the method shown above
I have had to use the following in my method that updates the array. I have 
several methods that will update arrays, and will probably have to use the 
same in those. It will mean two lines of extra code for each method!!
.

var qArr = this.cap_questions;// create a var as the array //
for(blah blah){
var q = // set-up the value //
qArr.push(q);
}
this.cap_questions = qArr; // restore the classes array value with 
updated var //

Does anyone have an explanation for this, or is it a bug??
If its a bug, should it be reported at the site??
Thanks in advance..  Gilbert 


--~--~-~--~~~---~--~~
You received 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: Calling function every time PeriodicalUpdater makes a request

2009-04-27 Thread BryanG

Thanks for the reply.  Your first suggestion worked great, although I
don't understand why.  When I tried implementing the onSuccess, I
called the function directly - something like:

onSuccess: alert(onSuccess);

This apparently just gets called once the first time through.  If I
used the formatting you specified (with the function() definition), it
works exactly like I wanted, although I'm not sure what the difference
is.

Also, I did try returning script tags when using evalScripts:true (as
in the example I posted), so am not sure why that didn't work (or is
it the same issue - I've got to make it a function definition rather
than just calling the function)?

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



[Proto-Scripty] Re: Using this.arrayname to add data to an array not working

2009-04-27 Thread T.J. Crowder

Hi,

Your Logger class, as given, will work fine:

var l = new Logger();
l.write(Testing);
l.write(One);
l.write(Two);
l.write(Three);

The result of the above would be that the 'log' array would be:

[Testing, One, Two, Three]

 I have had to use the following in my method that updates the array.

That workaround is not necessary.  If this code works:

var qArr = this.cap_questions;// create a var as the array //
for(blah blah){
var q = // set-up the value //
qArr.push(q);
}
this.cap_questions = qArr; // restore the classes array value with

...then this code works:

for(blah blah){
var q = // set-up the value //
this.cap_questions.push(q);
}

I suspect if you give us a more complete example -- including direct
quotes of where you're using your class (the above are clearly edited
examples) -- we'll be able to tell you what you're doing wrong.  My
guess would be that it relates to how you're calling your class's
instance methods.

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Apr 27, 2:05 pm, Imbi Rehling imbil...@tpg.com.au wrote:
 Hello to all, my first post to this group!
 I am new to OOP in JavaScript and have written my first Js Class using
 prototype.js..
 On the 'Learn pages' at prototypejs.org the example for
 'Classes-Inheritance' shows the following..

 var Logger = Class.create({
   initialize: function() {
     // this is the right way to do it:
 this.log = [];
   },
   write: function(message) {
     this.log.push(message);
   }

 });

 For some reason I can't seem to add to the array using 'this.arrayName'.
 I have tried also this.arrayName[i] = value;
 I initialize the array using the method shown above
 I have had to use the following in my method that updates the array. I have
 several methods that will update arrays, and will probably have to use the
 same in those. It will mean two lines of extra code for each method!!
 .

     var qArr = this.cap_questions;    // create a var as the array //
     for(blah blah){
         var q = // set-up the value //
         qArr.push(q);
     }
     this.cap_questions = qArr; // restore the classes array value with
 updated var //

 Does anyone have an explanation for this, or is it a bug??
 If its a bug, should it be reported at the site??
 Thanks in advance..  Gilbert
--~--~-~--~~~---~--~~
You received 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: equivalent of the onAvailable YUIEvent?

2009-04-27 Thread Ananth Raghuraman
Look at YUILoader's onSuccess method; it is the same as dom:loaded event

On Mon, Apr 27, 2009 at 2:48 AM, Mark Mansour markmans...@gmail.com wrote:


 Hey guys,

 I'm looking for the earliest point to execute a method when a HTML
 element is available.  Currently I can only get my desired usability
 by inlining the javascript (you can see the dom change when I use
 dom:loaded).  I noticed that YUIEvent has an onAvailable event [http://
 developer.yahoo.com/yui/event/#onavailable] and wondered if there was
 an equivalent for prototype (or if this is the best solution!)

 Mark

 --
 Mark Mansour
 m...@stateofflux.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: Is there a way to determine absolute coordinates of an element on the screen?

2009-04-27 Thread Diodeus

You need the famous Kangax Prototype cheat sheet. There is a very
handy diagram on the PDF that will help you with this positioning
issue:

http://thinkweb2.com/projects/prototype/prototype-1602-cheat-sheet/


On Apr 26, 5:56 pm, buda www...@pochta.ru wrote:
 this gets coordinates in a page but I need to translate them to screen

 On 26 апр, 19:35, Diodeus diod...@gmail.com wrote:

  I use this: ( fromhttp://www.quirksmode.org/js/findpos.html)

  function findPos(obj) {
          //find coordinates of a DIV
          var curleft = curtop = 0;
          if (obj.offsetParent) {
                  curleft = obj.offsetLeft
                  curtop = obj.offsetTop
                  while (obj = obj.offsetParent) {
                          curleft += obj.offsetLeft
                          curtop += obj.offsetTop
                  }
          }
          return [curleft,curtop];

  }

  myPos = findPos($('someDIV'))
  alert(myPos[0] + ,  myPos[1])

  On Apr 25, 7:02 am, buda www...@pochta.ru wrote:

   I have a problem with keydown event - event.screenY in the handler
   show coordinates inside a form instead of screen so I need to have
   absolute coordinates of an element to show popup element under an
   element or beneath of it

   Help me please- Скрыть цитируемый текст -

  - Показать цитируемый текст -
--~--~-~--~~~---~--~~
You received 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 effect in Effect.toggle does not work

2009-04-27 Thread Walter Lee Davis

Hmmm. Well, that's odd, but chalk one up to Rails and its development/ 
test/production environments. The querystring at the end of the  
filename is there to force the browser to get a newer version of the  
script. That number is the current time in Unix time() mode, I think,  
or it may be keyed to the migration timestamp, I can't recall. In  
production mode, I don't think you see that -- so the browser is  
encouraged to cache the script for better performance. Maybe your code  
was stuck on a cached version with an error in it -- an error you  
subsequently fixed.

Walter

On Apr 27, 2009, at 9:38 AM, Vinay Seshadri wrote:

 Im so sorry to have put you through all that only for it to end up  
 being something so silly!!
 Im going to see if anyone else has discussed such behaviour before  
 anywhere online. If not, gonna start a thread in a Rails forum to  
 see what others think about it.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-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: Calling function every time PeriodicalUpdater makes a request

2009-04-27 Thread T.J. Crowder

Hi,

 If I
 used the formatting you specified (with the function() definition), it
 works exactly like I wanted, although I'm not sure what the difference
 is.

All the difference in the world! :-)  This code:

x = alert(Hi there);

...calls the alert function and stores the result of calling that
function in the variable 'x'.  This code:

x = function() { alert(Hi there); };

...*creates* a function but does *not* call it, and stores a reference
to that function in the variable 'x'.  If/when the function is called,
it will call the alert function.

So if you were doing something like this:

pe = new Ajax.PeriodicalUpdater(target, url, {
onSuccess:  alert('Hi there')  // == Wrong
});

...quick, what were you doing?  That's right:  Calling the alert
function and storing the *result* of that call (the return value) in
the onSuccess member of the options object, and then passing that
object and the other parameters into the Ajax.PeriodicalUpdater
constructor.  I don't think alert has a return value, which means it
would be undefined, which is effectively the same as not having the
onSuccess option present at all.  (Pardon the wrong comment, it's
there for people skimming, something I picked up from a 70's book on
programming -- was it KR? -- where they were careful to clearly label
examples of incorrect code.)  Whereas this:

pe = new Ajax.PeriodicalUpdater(target, url, {
onSuccess:  function() {
alert('Hi there');
}
});

...*creates* a function and puts a reference to that function on the
options object; PeriodicalUpdater will see the function reference in
the options and call that function for each successful update.

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Apr 27, 3:00 pm, BryanG bgond...@gmail.com wrote:
 Thanks for the reply.  Your first suggestion worked great, although I
 don't understand why.  When I tried implementing the onSuccess, I
 called the function directly - something like:

 onSuccess: alert(onSuccess);

 This apparently just gets called once the first time through.  If I
 used the formatting you specified (with the function() definition), it
 works exactly like I wanted, although I'm not sure what the difference
 is.

 Also, I did try returning script tags when using evalScripts:true (as
 in the example I posted), so am not sure why that didn't work (or is
 it the same issue - I've got to make it a function definition rather
 than just calling the function)?

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



[Proto-Scripty] Re: displaying Server time using Ajax.periodicaUpdater

2009-04-27 Thread T.J. Crowder

Hi,

There are a couple of problems there.  The first and biggest problem
is that your clock.html file *isn't* getting the server's time, it's
getting the client's time.  You're running client-side code to output
the time to the document as it's being rendered in the browser.  The
second problem is that you can't use document.write in script tags in
content you're going to retrieve and put on the page via
PeriodicalUpdater (or Element#update or anything like them).  But see
the first point, you don't want to anyway.

You need to create something that runs *on the server* and outputs the
time, and then plop that into the appropriate location on your page.

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Apr 27, 11:07 am, Palastina Uber Alles ala...@gmail.com wrote:
 Hello everyone,
 I am new to prototype, and I am trying to implement a simple ajax
 request
 I wrote the index.html file, and the clock.html file

 index.html

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
 head
 meta http-equiv=content-type content=text/html; charset=utf-8 /
 title Test Page /title
 script type=text/javascript src=../prototype.js/script
 script
         function getClock() {
                 var url = 'data/clock.html';
                 var myAjax = new Ajax.PeriodicalUpdater(
                         'clockArea',
                         url,
                         {
                                 method: 'get',
                                 frequency: 2,
                                 onFailure: function(resp) {alert(Failure : +
 resp.statusTest,test);},
                                 onException : function(resp, 
 exception){alert(exception +
 exception,test);}
                         });
                 }
 /script
 /head
 body
         input type=button value=Test onclick=getClock();/br/ br/
 br/
         pdiv id=clockArea/div/p
 /body
 /html

 and the clock.html

 html
 head
 script type=text/javascript
 function display()
 {
         var myscriptTime  = new Date();
         document.write(myscriptTime)

 }

 /script
 /head
 body onload=display()

 /body
 /html

 clock.html displays the date correctly, but when I click the btn in
 the first file the time is not displayed
 and there is no errors. onSuccess it alerts a msg

 any body can help me please.
--~--~-~--~~~---~--~~
You received 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] Web Desktop Showcase

2009-04-27 Thread Jeztah

After a bit of time playing and alot of people asking about Web
Desktops i decided to pull my old code out of retirement and fix some
bugs !!

http://showcase.bazookawally.co.uk/

Above is a link to the Desktop Demo ...

Please any browser but INTERNET EXPLORER !!! .. there is a couple of
bugs i have yet to iron out with jQuery and IEx 

It works fine in Safari (windows at least), Firefox, Chrome, Opera
(iirc)

If anyone would like the code or would like to help me iron out the
last couple of bugs please let me know !!

The code weighs in (packed) at 7.3kb and unpacked at 14.6kb... it
relies on prototypejs  Scriptaculous for the windowing system and i
use jQuery for a few internal bits and bobs - but it will run without
jquery if one desires

Page load is fast and quick, the ajax unloads itself from memory to
stop the page lagging at all...

There are many of these types of applications out there, but most if
not all in my opinion are slow, laggy, and not very configurable.
My offering combats this with a modular design, easy hooks into the
window API and one load for alll CSS/Javascript, The backend is
running php5 but any serverside langauge will run, or just plain html

Any (Constructive) comments are welcome, and questions (if any)!!

Enjoy

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



[Proto-Scripty] Re: Using this.arrayname to add data to an array not working

2009-04-27 Thread IMBI-Indie-Portal

Thanks T.J.

I probably should have been more specific.

I'm actually building a Q and A Captcha, not a Logger. I used that as
an example.

The issue is, I am using proto's Ajax.Request and I'm running that
code within the 'onComplete: function(transport){ callback }' and this
is executing within a method which get an array of questions from a
database.
Another method then creates a select list and renders it to the page.

I have found that if I declare a var using the 'this.arrayName' before
running the Ajax.Request I can load the array OK.

What is strange, is that I can then do 'this.ArrayName  = var;' and
populate the objects array whilst I'm still in the  'onComplete
callback'.

Why is it that I cant load the this,arrayName as shown, but it lets be
're-value it'??

Here is a sample of the code: some var declarations are Not show for
simplicity...

var qArr = this.cap_questions; // I CREATE THE USABLE VAR WORKAROUND
HERE 
var url = path-to-php-script-sid=+Math.random();
var req = new Ajax.Request( url, {  // I USE THE var = req TO MAKE
JSLINT HAPPY ??
method: 'get', contentType: 'application/xml', onComplete: function
(transport) {
res = transport.responseXML; cap_nodes = 
res.getElementsByTagName
('group');
for(i=0; i  cap_nodes.length; i++){
qArr.push(cap_nodes[i].childNodes[0].nodeValue);
}
this.cap_questions = qArr; // HERE IT LETS ME RE-DECLARE THIS
OBJECTS VALUE?
}
});

If I try to declare the VAR within the callback it won't work either,
Has to be before the new Ajax.Request.
I checked with 'typeof' and it returns 'undefined'

I have another problem as well.

How can I call a method within another method, like in PHP.

Using 'this.methodName() does not seem to work.
After completion of one methods db retrieval, I do a check for state,
and would like to call a method within the working method.
The idea worked (as functions) before I re-wrote the whole idea into
a  single class.
I want the class to be as dynamic as possible, and dont want to have
to add more intelect to the pages code.
This will be a publicly available App, so I'm trying to make it as
simple as possible to setup.

Thanks again for the Quick HELP. Its much appreciated!
Cheers, Gilbert R..
--~--~-~--~~~---~--~~
You received 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: Calling function every time PeriodicalUpdater makes a request

2009-04-27 Thread BryanG

Wow - thanks for the detailed explanation.  Makes perfect sense now!

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



[Proto-Scripty] Re: Extending Prototype.BrowserFeatures the right way?

2009-04-27 Thread Tim Snadden



 You shouldn't need try/catch for merely testing types of certain
 properties.  I would check `borderRadius` first, since it's a standard
 CSS3 property. `el` also needs to be `null`ed. I think a more
 descriptive name for the test would be `hasBorderRadius` (instead of
 `borderRadius`) - to denote that it is of a boolean value.

 ...
 hasBorderRadius: (function(){
  var el = document.createElement('div');
  var s = el.style;
  var result = typeof s.borderRadius == 'string' ||
   typeof s.MozBorderRadius == 'string' ||
   typeof s.WebkitBorderRadius == 'string';
  el = null;
  return result;
 })()
 ...

 --
 kangax

Hey - I didn't want to clog up the list with noise, but just wanted to  
say thanks very much. Your input on this list is awesome. Cheers, Tim




--~--~-~--~~~---~--~~
You received 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 effect in Effect.toggle does not work

2009-04-27 Thread Vinay Seshadri
Hmmm. Im not sure. This wasnt working for me in dev or production. And the
timestamps are there in both environments.You are right about what theyre
meant for though. I read about it here http://ahref.in/79887

Its explained a bit more in detail in the API under the Using Asset
Timestamps section
http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html

This allows you to set a cache-expiration date for the asset far into the
future, but still be able to instantly invalidate it by simply updating the
file

I updated my JS files in my project in dev but it dint work. Everything
following that line in the API, goes right over my head. He's talking about
setting a future cache expiration time.. dont quite grasp that.

On Mon, Apr 27, 2009 at 7:41 PM, Walter Lee Davis wa...@wdstudio.comwrote:


 Hmmm. Well, that's odd, but chalk one up to Rails and its development/
 test/production environments. The querystring at the end of the
 filename is there to force the browser to get a newer version of the
 script. That number is the current time in Unix time() mode, I think,
 or it may be keyed to the migration timestamp, I can't recall. In
 production mode, I don't think you see that -- so the browser is
 encouraged to cache the script for better performance. Maybe your code
 was stuck on a cached version with an error in it -- an error you
 subsequently fixed.

 Walter

 On Apr 27, 2009, at 9:38 AM, Vinay Seshadri wrote:

  Im so sorry to have put you through all that only for it to end up
  being something so silly!!
  Im going to see if anyone else has discussed such behaviour before
  anywhere online. If not, gonna start a thread in a Rails forum to
  see what others think about it.


 



-- 
In Sport We Trust !!!

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