/** * Zazar Presentation Framework * * Library: jquery.zazar.js * * Version: 2.0.0 * (C) 2011-2012 Zazar Ltd * * Description: Framework function and effect library * * History: * 2.0.0 - First commercial release * **/ (function($){ $.zazar = { all: function() { // Initialise all functions with default values $.zazar.accordion(); $.zazar.bookmark(); $.zazar.dialog(); $.zazar.navigation(); $.zazar.random(); $.zazar.reveal(); $.zazar.rotate(); $.zazar.scrollto(); $.zazar.slider(); $.zazar.tabs(); $.zazar.ticker(); $.zazar.tooltip(); $.zazar.tree(); }, accordion: function(options) { // Set defaults var defaults = { selector: '.accordion', titletag: 'h4', contenttag: 'p', oneclick: true, speed: 400 }; var options = $.extend(defaults, options); return $(options.selector).each(function() { var obj = $(this); if (!$(obj).hasClass('accordion')) $(obj).addClass('accordion'); // Get each child item $(this).children().each(function() { // Get content element var content = $(options.contenttag,this); // Hide content $(content).hide(); // Style title with link pointer $(options.titletag,this).css({ cursor: 'pointer' }).click(function() { // If oneclick option then hide any visible content if (options.oneclick) { $(options.contenttag,obj).slideUp(); } // Show or hide content if (!$(content).is(':visible')) { $(content).slideDown(options.speed); } else { $(content).slideUp(options.speed); } }); }); }); }, bookmark: function(options) { // Set defaults var defaults = { selector: 'a.bookmark' }; var options = $.extend(defaults, options); return $(options.selector).each(function() { // Attach click event to anchor $(this).bind('click',function() { var url = window.location; var title = document.title; // Add bookmark on supported browsers if (window.sidebar) { window.sidebar.addPanel(title, url,""); } else if( window.external || document.all) { window.external.AddFavorite( url, title); } else { alert('Your browser does not support this bookmark action'); } // Override default anchor handling return false; }); }); }, dialog: function(options) { // Set defaults var defaults = { selector: '.dialog', id: 'dialog', modal: true, opacity: 0.8, fade: 'fast', width: 800, height: 500, errormsg: 'The content could not be loaded' }; var options = $.extend(defaults, options); return $(options.selector).each(function(i,e) { var obj = $(this); // Set up variables var cX, cY, cI, cJ; cX = cY = cI = cJ = 0; var dlg, dlgm, dlgt, dlgc; var el; var id = ''; // Function to show dialog var dialogOpen = function() { // Get window width and full height var x = $(window).width(); var y = $(document).height(); // Calculate center cX = $(window).width() / 2; cY = $(window).height() / 2; // Show background mask for modal option if (options.modal) { dlgm = $('
').appendTo('body').css({ display: 'none', position: 'absolute', width: x, height: y, top: '0', left: '0', zIndex: '10000', opacity: options.opacity }).fadeIn(options.fade).click(function() { dialogClose(); }); } // Create dialog window dlg = $('
').appendTo('body'); x = cX - $(dlg).width() / 2; y = cY - $(dlg).height() / 2; $(dlg).css({ display: 'none', position: 'fixed', left: x, top: y, zIndex: '10001' }); // Support for IE6 if ($.browser.msie && parseInt($.browser.version) <= 7) { cI = $(window).scrollTop(); $(dlg).css({ position: 'absolute', top: (y + cI) + 'px', paddingTop: '2em' }); $('select, object, embed').css({ visibility: 'hidden' }); } $(dlg).fadeIn(options.fade); // Create title & close button dlgt = $('').appendTo($(dlg)); $('').appendTo($(dlg)).click(function(e) { e.preventDefault(); dialogClose(); }); $('.dialogTitle, .dialogClose').css({ display: 'none', position: 'absolute' }); cJ = $('.dialogClose').width(); // Create content container dlgc = $('
').appendTo($(dlg)).css({ display: 'none' }); // Load content from anchor dialogContent(obj); }; // Function to close dialog var dialogClose = function() { // Reapply id for elements if (id) $(el).attr('id',id); // Remove dialog $('.dlgContent img').remove(); $(dlg).remove(); // Remove background mask if (options.modal) { $(dlgm).fadeOut(options.fade,function() { if ($.browser.msie && parseInt($.browser.version) <= 7) { $('select, object, embed').css({ visibility: 'visible' }); } $(this).remove(); }); } }; // Function to change content var dialogContent = function(obj) { var x = 0, y = 0; var err = false; // Remove any existing content $('.dialogTitle, .dialogClose, .dialogContent').fadeOut(options.fade); $(dlgc).html(''); // Show loader $(dlg).addClass('loader'); // Set new title $(dlgt).html($(obj).attr('title')); // Get content link and type var href = $(obj).attr('href'); var type = href.substr(href.lastIndexOf('.')).toLowerCase(); if (type == '.gif' || type == '.jpg' || type == '.jpeg' || type == '.png' || type == '.bmp') { // Display image var img = new Image(); $(img).load(function() { $(dlgc).css({textAlign: 'center'}).append(img); dialogAnimate(img.width, img.height); }).error(function() { dialogError(); }).attr('src', href + '?' + (new Date()).getTime()); } else if (href.charAt(0) == '#') { // Get element and ID el = $(href).get(0); if (el) { id = $(el).attr('id'); // Create clone and clear original ID var el2 = $(el).clone(); $(el).attr('id',''); // Append to content $(dlgc).html($(el2).html()); x = $(dlgc).width(); y = $(dlgc).height(); dialogAnimate(x,y); } else { dialogError(); } } else { if (type == '.swf' || $(obj).hasClass('flash')) { // Display flash var html = '' + '' + '' + '' + '' + ''; // Get flash size or set default x = 560; y = 315; } else { // Display in iFrame with default size var html = '