views:

647

answers:

2

Hi,

I need help in locating the conflict in my code, below is my ugly code (I'm just starting to write my mootools and my approach i think are ugly). the site can be seen here http://tinyurl.com/y9xvm6b. I think it is conflicting with these lines

  <script type="text/javascript" src="/lotsforsaleroxascity/media/system/js/mootools.js"></script>
  <script type="text/javascript" src="/lotsforsaleroxascity/media/system/js/caption.js"></script>

in my code. that 2 lines are generated by my cms and using it.

  // Global Functions

window.addEvent('domready',function(){


/* ------------------------------------------------------- Menu */

    var Logo = $('logo').getElements('a'),
        LogoPos = Logo.getStyle('backgroundPosition');
    Logo.addEvents({
        mouseenter: function(){
            this.fade(1);
        },
        mouseleave: function(){
            // Morphes back to the original style
            this.fade(0);
        }    
    });   


/* ------------------------------------------------------- Tabs */


        var tabs = new MGFX.Tabs('#foliobotnav .nav','.t1',{

            autoplay: true,

            transitionDuration:500,

            slideInterval:6000,

            hover:true

        });





    var pages = new noobSlide({

        box: $('mcontent_hold'),

        items: $$('#mcontent_hold div'),

        size: 950,

        handles: $$('#logo a').extend($$('#topnav ul li.inpage a')),

        onWalk: function(currentItem,currentHandle){

            <!--$('info4').set('html',currentItem.getFirst().innerHTML);-->

            this.handles.removeClass('active');

            currentHandle.addClass('active');

        }

    });  



/* ------------------------------------------------------- Websites */  

    var dropWEB = $$('#web div.left div.imgwrap')[0];

    $$('#web .right .imgwrap').each(function(item)

    {

        item.addEvent('click', function(e)

        {

            e = new Event(e).stop();

            dropWEB.removeEvents();

            dropWEB.empty()

            var a = item.clone();

            a.inject(dropWEB);

            dropWEB.style.height = "400px";

        });



    });

/* ------------------------------------------------------- Websites End*/



/* ------------------------------------------------------- Identity */  

    var dropID = $$('#artwork div.left div.imgwrap')[0];

    $$('#artwork .right .imgwrap').each(function(item)

    {

        item.addEvent('click', function(e)

        {

            e = new Event(e).stop();

            dropID.removeEvents();

            dropID.empty()

            var a = item.clone();

            a.inject(dropID);

            dropID.style.height = "400px";

        });



    });

/* ------------------------------------------------------- Identity End*/     



/* ------------------------------------------------------- Artworks */  

    var dropART = $$('#identity div.left div.imgwrap')[0];

    $$('#identity .right .imgwrap').each(function(item)

    {

        item.addEvent('click', function(e)

        {

            e = new Event(e).stop();

            dropART.removeEvents();

            dropART.empty()

            var a = item.clone();

            a.inject(dropART);

            dropART.style.height = "400px";

        });



    });

/* ------------------------------------------------------- Artworks End*/   


/* ------------------------------------------------------- Contact */

$("form").submit(function(){

// 'this' refers to the current submitted form
var str = $(this).serialize();

   $.ajax({
   type: "POST",
   url: "contact.php",
   data: str,
   success: function(msg){

$("#msg").ajaxComplete(function(event, request, settings){

if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{
result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
$("#formwrap").hide();
}
else
{
result = msg;
}

$(this).html(result);

});

}

 });

return false;

});



/* ------------------------------------------------------- Contact */



});

Thank You!

---Edited below

Btw, Conflicts I'm experiencing is all my custom function in globals.js are not function. buttons don't work, slider don't work, and also the thumbnail viewer.

Thanks Again.

A: 

You're loading two versions of mootools.js; that can't be good for a start. You have .../media/system/js/mootools.js and .../templates/pennfolio/js/mootools.js.

During development it's probably a good idea to use the uncompressed version of mootools.js, so you can find your way around the source easily if there's a problem (D.prototype is undefined isn't a very useful error message). Then use a compressed version in production.

Richard Turner
Thanks Richard, I tried removing the (templates/pennfolio/js/mootools.js) But didn't fix the conflict. I know it's wrong to load same js library with different version. I just tried to put them both for debugging purposes.Thanks!
Pennf0lio
When you say "conflict", what error message do you see?
Richard Turner
'conflict' i mean problem. What I mean is when i removed the (templates/pennfolio/js/mootools.js) it still doesn't work properly. But when I stop my cms loading this 2 lines, <script type="text/javascript" src="/lotsforsaleroxascity/media/system/js/mootools.js"></script> <script type="text/javascript" src="/lotsforsaleroxascity/media/system/js/caption.js"></script>It worked properly.
Pennf0lio
A: 

I'm with Richard on this - I'd use an uncompressed version, use firebug and load in a few console.log() to determine where the issue is.

I recommend running your code through jslint.com - it shows a few issues:

  1. Line 52: To comment out JavaScript, use // NOT
  2. Problem at line 78 character 28: Missing semicolon.
  3. Problem at line 112 character 27: Missing semicolon.
  4. Problem at line 146 character 28: Missing semicolon.

Fix those, then try again.

keif
Thanks Keif, I found the problem. I'm using slide plugin of mootools, I forgot that I merged it with the core mootools, so whenever I remove my own mootools, my script don't work. (Man, I'm very messy with my code.)Thanks for jslint.com, It's Great Tool. Thanks!
Pennf0lio
Don't thank me, thank Douglas Crockford for JSLint.com It's an invaluable tool.
keif