[Proto-Scripty] element.observ on classname+id

2010-02-20 Thread Jinsa
Hi everybody!

I'm actually working on a script acting on a UL menu with different LI
classname. The goal is to react onMouseOver and onClick on each LI
click or mouseover differently. The fact is the class is unknown so my
script have to check the UL and then observe each LI as elements.

Here is the html:

ul id=menu
  li class=itema id=current href=First/a
  li class=item23a id=current href=Second/a
  li class=item22a id=current href=Third/a
  li class=item12a id=current href=Vador/a
  li class=item6a id=current href=What the!/a
  li class=item2a id=current href=Hahum!/a
/ul

and then the script:

function bindage()
{
$('menu').down('li').each(function (el)
{
return $(el).observe('click', function(event)
{
event.stop();
alert('hellow bro');
});
});
}

Event.observe(window, 'load', bindage);

But that obviously doesn't work... I really don't have any idea to
make it work... I've tried so far but without any success... maybe you
could help me?

Thanks,

JF.

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



[Proto-Scripty] new Element insert problem

2010-02-20 Thread kstubs
What is wrong with the following, the bad result is the new input
elements are not contained by the new div element:

Javascript:
var div1 = div.insert(new Element('div', { 'class': 'new-section' }));
div1.insert(new Element('input', { 'name': 'newsection-name-' + count,
'class': 'newsection-name item-' + count }));
div1.insert(new Element('input', { 'name': 'newsection-val-' +
count }));


Output - FF:
div class=new-section/divinput name=newsection-name-0
class=newsection-name item-0input name=newsection-val-0

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



Re: [Proto-Scripty] Re: element.observ on classname+id

2010-02-20 Thread agnese camellini
Hi jinsa, i'm not a professional but for what i've been reading yesterday i
can say you where is the problem.
I mean where to begin.
The approach can be pretty different if you are using a framework (Mootools
scriptaculous jQuery) or you are writing javascript by yourself (which i
think in order to have a solution need much more time to be elaborated.

Here is the link to elaborate the problem:

http://www.quirksmode.org/js/events_order.html
http://www.quirksmode.org/js/introevents.html

I'm actually having a problem like yours in writing down the scheme for a
gallery, BUT, i will try a first (temporary) solution with jQuery (which is
largely compatible), in the meanwhile i'll elaborate a more robust one with
the help of the site manual i showed to you.
don't know how much it will take but however i have time.

So if you find some better link. let me know.

;)


2010/2/20 Jinsa jf.wesq...@gmail.com

 The Html given is not good, the one I use is:

 ul id=menu
  li class=itema href=Accueil/a
  li class=item23a href=Programmes/a
  li class=item22a href=A l'affiche/a
  li class=item12a href=Débats/a
  li class=item6a href=Intervenants/a
  li class=item2a href=Infos-Pratiques/a
 /ul

 but it doesn't change the fact that's not wroking ^^.

 If someone can help :)

 Thanks :)

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



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



[Proto-Scripty] Re: element.observ on classname+id

2010-02-20 Thread joe t.
Just as a small nit-pick, LI elements are containers, and so should
have closing /li tags.
-joe t.


On Feb 20, 8:58 am, Jinsa jf.wesq...@gmail.com wrote:
 Hi everybody!

 I'm actually working on a script acting on a UL menu with different LI
 classname. The goal is to react onMouseOver and onClick on each LI
 click or mouseover differently. The fact is the class is unknown so my
 script have to check the UL and then observe each LI as elements.

 Here is the html:

 ul id=menu
   li class=itema id=current href=First/a
   li class=item23a id=current href=Second/a
   li class=item22a id=current href=Third/a
   li class=item12a id=current href=Vador/a
   li class=item6a id=current href=What the!/a
   li class=item2a id=current href=Hahum!/a
 /ul

 and then the script:

 function bindage()
 {
         $('menu').down('li').each(function (el)
         {
                 return $(el).observe('click', function(event)
                 {
                         event.stop();
                         alert('hellow bro');
                 });
         });

 }

 Event.observe(window, 'load', bindage);

 But that obviously doesn't work... I really don't have any idea to
 make it work... I've tried so far but without any success... maybe you
 could help me?

 Thanks,

 JF.

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



[Proto-Scripty] Re: new Element insert problem

2010-02-20 Thread T.J. Crowder
Hi,

Element#insert returns a reference to the same element you called it
on, not the new content. Just change your first line to

var div1 = new Element('div', { 'class': 'new-section' });
div.insert(div1);

...and the rest should work.

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com

On Feb 20, 6:24 pm, kstubs kst...@gmail.com wrote:
 What is wrong with the following, the bad result is the new input
 elements are not contained by the new div element:

 Javascript:
 var div1 = div.insert(new Element('div', { 'class': 'new-section' }));
 div1.insert(new Element('input', { 'name': 'newsection-name-' + count,
 'class': 'newsection-name item-' + count }));
 div1.insert(new Element('input', { 'name': 'newsection-val-' +
 count }));

 Output - FF:
 div class=new-section/divinput name=newsection-name-0
 class=newsection-name item-0input name=newsection-val-0

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



[Proto-Scripty] Re: element.observ on classname+id

2010-02-20 Thread T.J. Crowder
Hi Jinsa,

Your `bindage` method nearly works, you just have to change `$
('menu').down('li').each` to `$('menu').select('li').each`.
Element#down (with no index argument) finds the first matching
descendant element and returns it; Element#select finds all matching
descendant elements and returns them as an array. My use of
Element#select here assumes that you *know* there won't be any nested
lists, as it will match all descendant LIs, even those in nested lists
within the list you're searching.

But `bindage` can be improved. You're creating a new function for each
LI, which is inefficient and unnecessary. You could do this:

function bindage()
{
$('menu').select('li').invoke('observe', 'click', function(event)
{
event.stop();
alert('hellow bro');
});
}

or this, which has the advantage of using a named function (which
makes it possible for your tools to help you -- showing function names
in stack traces, etc.):

function bindage()
{
$('menu').select('li').invoke('observe', 'click',
bindage_liClick);

function bindage_liClick(event)
{
event.stop();
alert('hellow bro');
}
}

Both of those use a single function to watch all of LIs.

But wait, there's more: Why watch the individual LIs at all? The click
event bubbles up the DOM, so you could just watch the UL -- unnamed
example:

function bindage()
{
$('menu').observe('click', function(event) {
var li;

li = event.findElement('li');
if (li)
{
event.stop();
alert('hellow bro');
}
});
}

or (named):

function bindage()
{
$('menu').observe('click', bindage_ulClick);

function bindage_ulClick(event)
{
var li;

li = event.findElement('li');
if (li)
{
event.stop();
alert('hellow bro');
}
}
}

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Feb 20, 1:58 pm, Jinsa jf.wesq...@gmail.com wrote:
 Hi everybody!

 I'm actually working on a script acting on a UL menu with different LI
 classname. The goal is to react onMouseOver and onClick on each LI
 click or mouseover differently. The fact is the class is unknown so my
 script have to check the UL and then observe each LI as elements.

 Here is the html:

 ul id=menu
   li class=itema id=current href=First/a
   li class=item23a id=current href=Second/a
   li class=item22a id=current href=Third/a
   li class=item12a id=current href=Vador/a
   li class=item6a id=current href=What the!/a
   li class=item2a id=current href=Hahum!/a
 /ul

 and then the script:

 function bindage()
 {
         $('menu').down('li').each(function (el)
         {
                 return $(el).observe('click', function(event)
                 {
                         event.stop();
                         alert('hellow bro');
                 });
         });

 }

 Event.observe(window, 'load', bindage);

 But that obviously doesn't work... I really don't have any idea to
 make it work... I've tried so far but without any success... maybe you
 could help me?

 Thanks,

 JF.

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



[Proto-Scripty] Re: element.observ on classname+id

2010-02-20 Thread T.J. Crowder
Hi Joe,

 Just as a small nit-pick, LI elements are containers, and so should
 have closing /li tags.

Browser behavior for years has made doing what he did functional, and
the HTML5 spec will actually formalize it:
http://dev.w3.org/html5/spec/syntax.html#optional-tags

I only realized that the other day, when I was looking up something
about the TH element and the example flagrantly omitted end tags all
over the place.

Fortunately, the end tag is still *allowed*, it's just optional in
certain defined situations.

-- T.J.

On Feb 21, 12:27 am, joe t. thooke...@gmail.com wrote:
 Just as a small nit-pick, LI elements are containers, and so should
 have closing /li tags.
 -joe t.

 On Feb 20, 8:58 am, Jinsa jf.wesq...@gmail.com wrote:



  Hi everybody!

  I'm actually working on a script acting on a UL menu with different LI
  classname. The goal is to react onMouseOver and onClick on each LI
  click or mouseover differently. The fact is the class is unknown so my
  script have to check the UL and then observe each LI as elements.

  Here is the html:

  ul id=menu
    li class=itema id=current href=First/a
    li class=item23a id=current href=Second/a
    li class=item22a id=current href=Third/a
    li class=item12a id=current href=Vador/a
    li class=item6a id=current href=What the!/a
    li class=item2a id=current href=Hahum!/a
  /ul

  and then the script:

  function bindage()
  {
          $('menu').down('li').each(function (el)
          {
                  return $(el).observe('click', function(event)
                  {
                          event.stop();
                          alert('hellow bro');
                  });
          });

  }

  Event.observe(window, 'load', bindage);

  But that obviously doesn't work... I really don't have any idea to
  make it work... I've tried so far but without any success... maybe you
  could help me?

  Thanks,

  JF.

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



[Proto-Scripty] Re: evalScripts problem

2010-02-20 Thread T.J. Crowder
Hi Dan,

 NOW, every-time I do a AJAX.UPDATER...it doesn't do what it's suppose
 to. IN OTHER WORDS: It's acting like those declarations are not declared
 in the header.

It's actually doing what it's documented[1] to do: script blocks
referencing external files will be treated as though they were
empty...external files are not loaded and processed by evalScripts.
I'm not saying they shouldn't be, just that they aren't and the
behavior is documented.

This came up just a few days ago[2]. As I mentioned in that thread, at
the moment you have to find the script tags yourself and load them;
this page[3] on the unofficial wiki talks about the process of
dynamically loading scripts.

[1] http://api.prototypejs.org/language/string.html#evalscripts-instance_method
[2] 
http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/ee2049df172bc05b/1cefd81578083963
[3] http://proto-scripty.wikidot.com/prototype:how-to-load-scripts-dynamically

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com

On Feb 21, 6:39 am, Dan recoursereco...@gmail.com wrote:
 I have some script tags in my header tags that's used all throughout
 my site. In particular, they are script tags to a pop-up box:

 script type=text/javascript src=GreyBox_v5_5_3/greybox/AJS.js/
 script
 script type=text/javascript src=GreyBox_v5_5_3/greybox/
 AJS_fx.js/script

 script type=text/javascript src=GreyBox_v5_5_3/greybox/
 gb_scripts.js/script
 link href=GreyBox_v5_5_3/greybox/gb_styles.css rel=stylesheet
 type=text/css media=all /

 The way to have the popup box show up is to write out a link like so
 a href=URL title=CAPTION rel=gb_image[]HTML/a

 NOW, every-time I do a AJAX.UPDATER and I update the container with a
 link like the one above, it doesn't do what it's suppose to. IN OTHER
 WORDS: It's acting like those declarations are not declared in the
 header.

 How can I make this work? I know it has something to do with
 EvalScripts. Please help I am lost.

 Thanks,
 Dan

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



[Proto-Scripty] Re: change frequency in running periodical executer?

2010-02-20 Thread Радослав Станков
There isn't PeriodicalExecuter#start method its
PeriodicalExecuter#registerCallback

You can do:

code
x.stop();
x.frequency = 1;
x.registerCallback();
/code

You can also do:

code
PeriodicalExecuter.addMethods({
  changeFrequency: function(frequency){
this.stop();
this.frequency = 1;
this.registerCallback();
  }
});
/code

an then just call:

code
x.changeFrequency(1);
x.changeFrequency(whatever);
/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-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: element.observ on classname+id

2010-02-20 Thread Радослав Станков
You can also use Event.delegate / http://gist.github.com/66568 / And
make it event simpler

$('menu').deleage('li', 'click', function(event){
  event.stop();
  alert('hellow bro');
}

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