Sabtu, 17 Agustus 2013

libraries/jqueryplugins/dc-popup

$(function(){
   
    /**
     * Define all variables needed
     *
     * ifrSlctr: Iframe selector
     * styleURI: Link to css file
     * parentURI: The URI of the parent
     * intervalId: Identifier for setInterval defined in $.linkListener() method
     */
    var
        ifrSlctr = 'iframe#box_login_iframe',
styleURI = 'http://detik.net.id/detik/libraries/jqueryplugins/dc-popup/1.0.0/dc.css?1361184094',
parentURI = document.location.href,
        intervalId;
   
    $.createStyle = function() {
$('<link/>', {href:styleURI, rel:'stylesheet', type:'text/css'}).appendTo('head');
    }
   
    $.createStyle();
   
    /**
     * Create iframe and all div needed on the fly
     *
     * @param string src Source or link for the iframe
     * @returns void
     */
    $.createIframe = function(src){
       
        if ( ! $('#bg_page_login').length ) {
            $('<div/>', {id:'bg_page_login'}).appendTo('body');
            $('<div/>', {'class':'box_login'}).appendTo('#bg_page_login');
            $('#bg_page_login').append('<div id="black_close"></div>');
            $('<iframe/>', {id:'box_login_iframe',scrolling:'no', frameborder:'no', src:src}).css('background-color', 'transparent').appendTo('.box_login');
           
            $.linkListener();
        }
    }
   
    /**
     * Faded out the black background, remove it div and clean the intervalId
     *
     * @returns void
     */
    $.closepop = function() {
        $('#bg_page_login').fadeOut(150);
$('#bg_page_login').remove();
        clearInterval(intervalId);
    }
   
    $.loginbox = function(urllink, xwidth, xheight) {
$(ifrSlctr).animate({
  height: xheight,
  width: xwidth,
},200).attr('src',urllink);
    }
   
    $.addUrlParam = function(url, key, value) {
str = ( url.split('?').length > 1 ) ? '&' : '?';
return url + str + key + '=' + value;
    }
   
    $.linkListener = function() {
       
        intervalId = setInterval(function() {
            if(window.location.hash != '') {
               
                if( window.location.hash == '#close' ) {
                    $.closepop();
                }
                else if(window.location.hash == '#main') {
                    return;
                }
                else {
    fragment = location.href.split("#")[1];
                    hash = fragment.split(' ');
   
    if( ! hash[1] )
hash = fragment.split('%20');
                    size = hash[1].split('-');
                    url = $.addUrlParam(hash[0],'parentURI', parentURI);
                    width    = size[0],
                    height   = size[1];
                   
                    $.loginbox(url, width, height);
                }
               
                window.location.hash = 'main';
            }
        }, 200);
    }
   
    $.anim = function(obj, height, width) {
       
        var src = $.addUrlParam($(obj).attr('alt'), 'parentURI', parentURI);
       
        $.createIframe(src);
       
        $('#bg_page_login').fadeIn(200);
        $(ifrSlctr).animate({
          height: height,
          width:width
        },200);
    }
   
    $.doLogin = function() {
        $.anim($('.to_login'), 440, 670);
    }
   
    $('.to_login, .to_reg').click(function() {
       
        if( $(this).attr('class') == 'to_login' ) {
            var height = 440,
                width = 670;
        }
        else {
            var height = 500,
                width = 840;
        }
       
        $.anim(this, height, width);
       
        return false;
    });
   
    $('.userlogin').click(function() {
        $("#drop_user").fadeIn(100);
        $('.userlogin').css("background-color","#ffffff");
    });
   
    $('.userlogin').mouseleave(function() {
        $("#drop_user").delay(500).fadeOut(0);
        $('.userlogin').delay(500).css("background-color","#E6E6E6");
    });
   
    $('#drop_user').mouseover(function() {
        $("#drop_user").fadeIn(0);
        $('.userlogin').css("background-color","#ffffff");
    });
   
});

Tidak ada komentar:

Posting Komentar