preventing an event from running
there are 2 event functions that are used in the script. 1 is to expand all sections and the other expands sections 1 by one. The issue i'm having is that the href link, when pressed closes the section. I was reading up on the stop() function, but can't figure out where to place it without screwing up the other functions. Here is the code I'm using:
- $(function() {
- jQuery('a.popup').live('click', function(){
- newwindow=window.open($(this).attr('href'),'','height=540,width=960, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1, copyhistory=0');
- window.moveTo(screen.width/2,screen.height/2);
- if (window.focus) {newwindow.focus()}
- return false;
-
- });
- });
- chaptitle = $(data).find("chapter").attr("label");
- filenum = $(data).find("file").attr("label");
- $(function() {
- /* be sure data is defined here */
- $( data ).find("chapter").each(function() {
- var $chapter = $('<li class="chaptertitle"/>')
- .append('<img class="img-swap" src="/demo/images/plus.png" class="img-swap" />')
- .append('<p align="left" class="pc-left">' + $(this).attr("label") + '<p align="right" class="pc-right">Duration</p>')
- .append('<ul/>')
- .appendTo( '#screens' );
- $(this).find('screen').each(function() {
- time=$(this).find('mobile').attr('duration')
- $("#screens").append(time)
- $('#screens ul:last')
- .append('<li class="screentitle"/>')
- .find('li:last').append('<p align="left" class="p-left"><a href="http://sandbox.kalliance.com/demo/player.swf?streamer=rtmp://184.172.28.227/'+filenum+'/&file=' + $(this).attr('path') + '&allowscriptaccess=true&autostart=true&stretch=fill&plugins=captions-2&captions.back=true&captions.file=/demo/xml/'+chaptitle+'/captions.xml&allowFullScreen=true" class="popup">' + $(this).attr('label') + '</a></p><p align="right" class="p-right">'+ $(this).attr("duration")+'</p>');
-
- });
- });
- });
- $('.show, .hide').click(function(event){
- // grab the image, its src, and whether the src is currently a plus...
- var $img = $('.img-swap'),
- src = $img.attr('src'),
- canExpand = src.indexOf('plus.png') > -1;
- // test for (ExpandAll AND is a plus) OR (CollapseAll AND is a minus)...
- if($(this).hasClass('show') === canExpand){
- // show (is a plus) or hide (is a minus) the title...
- $(".screentitle")[ canExpand ? 'show' : 'hide' ]('normal');
- // replace plus with minus, or vice versa...
- $img.attr('src', canExpand ? src.replace('plus', 'minus') : src.replace('minus', 'plus'));
- // if you have additional processing : canExpand TRUE means you're expanding
- }
-
- });
-
-
- $(".chaptertitle").click( function(event){
- $(".screentitle", this).slideToggle("normal")
- var $img = $(".img-swap", this);
- if ($img.attr('src').indexOf("plus.png") > -1) {
- $img.attr('src', $img.attr('src').replace('plus', 'minus'));
-
- } else {
- $img.attr('src', $img.attr('src').replace('minus', 'plus'));
-
-
- }
-
- });
- Basically, when the link is clicked for the new popup window, I don't want it to run the slidetoggle function.
a working demo can be found
here