Your IP : 216.73.216.11


Current Path : /home/digilove/public_html/components/com_marketplace/js/
Upload File :
Current File : /home/digilove/public_html/components/com_marketplace/js/script.js

var $ = jQuery.noConflict();
jQuery(document).ready(function() {
    var camera = jQuery('#camera'),
        photos = jQuery('#photos'),
        screen = jQuery('#screen');
    var template = '<a href="components/com_marketplace/uploads/original/{src}" rel="cam" ' +
        'style="background-image:url(components/com_marketplace/uploads/thumbs/{src})"></a>';
    webcam.set_swf_url('components/com_marketplace/assets/webcam/webcam.swf');

    webcam.set_api_url('components/com_marketplace/views/profile/tmpl/upload.php?seller_id=' + seller_id + ''); // The upload script
    webcam.set_quality(80); // JPEG Photo Quality
    webcam.set_shutter_sound(true, 'components/com_marketplace/assets/webcam/shutter.mp3');
    if (typeof(screen.width() != "undefined")) {
        screen.html(
            webcam.get_html(screen.width(), screen.height())
        );
    }
    var shootEnabled = false;
    jQuery('#shootButton').click(function() {
        if (!shootEnabled) {
            return false;
        }
        webcam.freeze();
        togglePane();
        return false;
    });
    jQuery('#cancelButton').click(function() {
        webcam.reset();
        togglePane();
        return false;
    });

    jQuery('#uploadButton').click(function() {
        webcam.upload();
        webcam.reset();
        togglePane();
        return false;
    });

    camera.find('.settings').click(function() {
        if (!shootEnabled) {
            return false;
        }

        webcam.configure('camera');
    });
    var shown = false;
    jQuery('.camTop').click(function() {

        jQuery('.tooltip').fadeOut('fast');

        if (shown) {
            camera.animate({
                bottom: -466
            });
        } else {
            camera.animate({
                bottom: -5
            }, { easing: 'easeOutExpo', duration: 'slow' });
        }

        shown = !shown;
    });

    jQuery('.tooltip').mouseenter(function() {
        jQuery(this).fadeOut('fast');
    });
    webcam.set_hook('onLoad', function() {

        shootEnabled = true;
    });

    webcam.set_hook('onComplete', function(msg) {

        msg = jQuery.parseJSON(msg);

        if (msg.error) {
            alert(msg.message);
        } else {
            // Adding it to the page;
            photos.prepend(templateReplace(template, { src: msg.filename }));
            // initFancyBox();
        }
    });

    webcam.set_hook('onError', function(e) {
        screen.html(e);
    });
    var start = '';

    function loadPics() {
        if (this != window) {
            if (jQuery(this).html() == 'Loading..') {
                // Preventing more than one click
                return false;
            }
            jQuery(this).html('Loading..');
        }
        return false;
    }
    loadPics();
    /*function initFancyBox(filename){
    	photos.find('a:visible').fancybox({
    		'transitionIn'	: 'elastic',
    		'transitionOut'	: 'elastic',
    		'overlayColor'	: '#111'
    	});
    }*/


    // This function toggles the two
    // .buttonPane divs into visibility:

    function togglePane() {
        var visible = jQuery('#camera .buttonPane:visible:first');
        var hidden = jQuery('#camera .buttonPane:hidden:first');

        visible.fadeOut('fast', function() {
            hidden.show();
        });
    }


    // Helper function for replacing "{KEYWORD}" with
    // the respectful values of an object:

    function templateReplace(template, data) {
        return template.replace(/{([^}]+)}/g, function(match, group) {
            return data[group.toLowerCase()];
        });
    }
});