[web2py] Re: JQuery plugin

2010-09-25 Thread Rick
Thanks for the suggestions. Now I consider this plugin:
http://www.happyworm.com/jquery/jplayer/

On Sep 25, 3:33 am, Magnitus  wrote:
> Assuming that you know how to create sound effects in regular
> Javascript, making your own pluggin for it doesn't seem that
> difficult.
>
> Lets assume that you want a pluggin that affect only div elements in a
> wrapped set and you want to be able to specify the sound...
>
> It'd look something like this (note that this is a quick-and-dirty
> piece of code... totally untested):
>
> {function($){
> $.fn.AddSoundOnClick = function(SoundEffect) {
>   return this.filter('div').bind('click',function(event){
>     //Stick the logic to emit the sound effect here
>     }).end();
>   };
>
> })(jQuery);
>
> Afterwards, lets say that you have a sound effect stored in the
> variable CowSound and a div with class "SoundDiv", you could add the
> cow sound like this:
>
> jQuery('div.SoundDiv').AddSoundOnClick(CowSound);
>
> Here's terrific book for jQuery:
>
> http://www.amazon.ca/jQuery-Action-Second-Bear-Bibeault/dp/1935182323...
>
> If you're serious about using jQuery properly, it'll be the best 30$
> you ever spent. Sure learned a lot from it.
>
> On Sep 24, 4:13 pm, Rick  wrote:
>
>
>
> > Hi,
>
> > I'd like to make a button that generates a sound when clicking on it.
> > This JQuery plugin was the best way I could 
> > found:http://plugins.jquery.com/project/sound
> > and I wrote this code:
>
> > views/default/index.html:
> >         {{extend 'layout.html'}}
> >         
> >                 onClick="jQuery(this).sound.play(/static/success.wav)"
> >         
>
> > views/layout.html:
> >         
>
> > {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}}
> >         
>
> > Since I'm totally new to JQuery I understand that this is completely
> > wrong. Could anyone tell me how it should look like, please?


[web2py] Re: JQuery plugin

2010-09-24 Thread Magnitus
Assuming that you know how to create sound effects in regular
Javascript, making your own pluggin for it doesn't seem that
difficult.

Lets assume that you want a pluggin that affect only div elements in a
wrapped set and you want to be able to specify the sound...

It'd look something like this (note that this is a quick-and-dirty
piece of code... totally untested):

{function($){
$.fn.AddSoundOnClick = function(SoundEffect) {
  return this.filter('div').bind('click',function(event){
//Stick the logic to emit the sound effect here
}).end();
  };
})(jQuery);

Afterwards, lets say that you have a sound effect stored in the
variable CowSound and a div with class "SoundDiv", you could add the
cow sound like this:

jQuery('div.SoundDiv').AddSoundOnClick(CowSound);

Here's terrific book for jQuery:

http://www.amazon.ca/jQuery-Action-Second-Bear-Bibeault/dp/1935182323/ref=sr_1_1?ie=UTF8&s=books&qid=1285384287&sr=8-1

If you're serious about using jQuery properly, it'll be the best 30$
you ever spent. Sure learned a lot from it.

On Sep 24, 4:13 pm, Rick  wrote:
> Hi,
>
> I'd like to make a button that generates a sound when clicking on it.
> This JQuery plugin was the best way I could 
> found:http://plugins.jquery.com/project/sound
> and I wrote this code:
>
> views/default/index.html:
>         {{extend 'layout.html'}}
>         
>                 onClick="jQuery(this).sound.play(/static/success.wav)"
>         
>
> views/layout.html:
>         
>
> {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}}
>         
>
> Since I'm totally new to JQuery I understand that this is completely
> wrong. Could anyone tell me how it should look like, please?


[web2py] Re: JQuery plugin

2010-09-24 Thread mdmcginn
Or you could use unobtrusive Javascript ,
where onClick isn't necessary in the HTML because it's inserted by
jQuery.

On Sep 24, 4:42 pm, Bruno Rocha  wrote:
> You can use the new audio tag from HTML5, but this should not work on every
> browser
>
> 
> Your browser does not support the audio element.
> 
>
> 2010/9/24 Rick 
>
>
>
>
>
>
>
>
>
> > Thanks!
>
> > I think there are better plugins for this purpose than this sound-
> > plugin. But now I know how to install it into my application.
>
> > On Sep 24, 8:26 pm, Bruno Rocha  wrote:
> > > You should append JS files before the {{include 'web2py_ajax.html'}}
>
> > > views/layout.html:
> > >        
>
> > > {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}}
> > > 
> > > {{include 'web2py_ajax.html'}}
> > >        
>
> > > and in your div the OnClick event is used in the wrong way, it is not
> > > recommended to use onclick event in a div,  you should use , or
> > > another element, and the file URL should be build with URL helper:
>
> > > views/default/index.html:
> > >        {{extend 'layout.html'}}
> > >        
> > >            
> >  onclick="jQuery(this).sound.play({{=URL('static',args='success.wav')}})">
> > >                          Click here to listen the sound
> > >             
> > >        
>
> > > 2010/9/24 Rick 
>
> > > > Hi,
>
> > > > I'd like to make a button that generates a sound when clicking on it.
> > > > This JQuery plugin was the best way I could found:
> > > >http://plugins.jquery.com/project/sound
> > > > and I wrote this code:
>
> > > > views/default/index.html:
> > > >        {{extend 'layout.html'}}
> > > >        
> > > >                onClick="jQuery(this).sound.play(/static/success.wav)"
> > > >        
>
> > > > views/layout.html:
> > > >        
>
> > {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}}
> > > >        
>
> > > > Since I'm totally new to JQuery I understand that this is completely
> > > > wrong. Could anyone tell me how it should look like, please?
>
> > > --
>
> > >http://rochacbruno.com.br
>
> --
>
> http://rochacbruno.com.br


Re: [web2py] Re: JQuery plugin

2010-09-24 Thread Bruno Rocha
You can use the new audio tag from HTML5, but this should not work on every
browser


Your browser does not support the audio element.




2010/9/24 Rick 

> Thanks!
>
> I think there are better plugins for this purpose than this sound-
> plugin. But now I know how to install it into my application.
>
> On Sep 24, 8:26 pm, Bruno Rocha  wrote:
> > You should append JS files before the {{include 'web2py_ajax.html'}}
> >
> > views/layout.html:
> >
> >
> > {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}}
> > 
> > {{include 'web2py_ajax.html'}}
> >
> >
> > and in your div the OnClick event is used in the wrong way, it is not
> > recommended to use onclick event in a div,  you should use , or
> > another element, and the file URL should be build with URL helper:
> >
> > views/default/index.html:
> >{{extend 'layout.html'}}
> >
> > >
> >
>  onclick="jQuery(this).sound.play({{=URL('static',args='success.wav')}})">
> >  Click here to listen the sound
> > 
> >
> >
> > 2010/9/24 Rick 
> >
> >
> >
> >
> >
> > > Hi,
> >
> > > I'd like to make a button that generates a sound when clicking on it.
> > > This JQuery plugin was the best way I could found:
> > >http://plugins.jquery.com/project/sound
> > > and I wrote this code:
> >
> > > views/default/index.html:
> > >{{extend 'layout.html'}}
> > >
> > >onClick="jQuery(this).sound.play(/static/success.wav)"
> > >
> >
> > > views/layout.html:
> > >
> >
> > >
> {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}}
> > >
> >
> > > Since I'm totally new to JQuery I understand that this is completely
> > > wrong. Could anyone tell me how it should look like, please?
> >
> > --
> >
> > http://rochacbruno.com.br
>



-- 

http://rochacbruno.com.br


[web2py] Re: JQuery plugin

2010-09-24 Thread Rick
Thanks!

I think there are better plugins for this purpose than this sound-
plugin. But now I know how to install it into my application.

On Sep 24, 8:26 pm, Bruno Rocha  wrote:
> You should append JS files before the {{include 'web2py_ajax.html'}}
>
> views/layout.html:
>        
>
> {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}}
> 
> {{include 'web2py_ajax.html'}}
>        
>
> and in your div the OnClick event is used in the wrong way, it is not
> recommended to use onclick event in a div,  you should use , or
> another element, and the file URL should be build with URL helper:
>
> views/default/index.html:
>        {{extend 'layout.html'}}
>        
>            
>  onclick="jQuery(this).sound.play({{=URL('static',args='success.wav')}})">
>                          Click here to listen the sound
>             
>        
>
> 2010/9/24 Rick 
>
>
>
>
>
> > Hi,
>
> > I'd like to make a button that generates a sound when clicking on it.
> > This JQuery plugin was the best way I could found:
> >http://plugins.jquery.com/project/sound
> > and I wrote this code:
>
> > views/default/index.html:
> >        {{extend 'layout.html'}}
> >        
> >                onClick="jQuery(this).sound.play(/static/success.wav)"
> >        
>
> > views/layout.html:
> >        
>
> > {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}}
> >        
>
> > Since I'm totally new to JQuery I understand that this is completely
> > wrong. Could anyone tell me how it should look like, please?
>
> --
>
> http://rochacbruno.com.br