var boozurkScripts; (function($) { boozurkScripts = { init : function( in_modules ) { var modules = in_modules.split(','); for (i in modules) { switch(modules[i]) { case 'postexpander': boozurkScripts.post_expander(); break; case 'thickbox': boozurkScripts.init_thickbox(); break; case 'tooltips': boozurkScripts.tooltips(); boozurkScripts.cooltips(boozurk_l10n.cooltips_selector); break; case 'quotethis': boozurkScripts.init_quote_this(); break; case 'animatemenu': boozurkScripts.animate_menu(); break; case 'scrolltopbottom': boozurkScripts.scroll_top_bottom(); break; case 'commentvariants': boozurkScripts.comment_variants(); break; case 'resizevideo': boozurkScripts.resize_video(); break; case 'tinynav': boozurkScripts.tinynav(); break; case 'tinyscrollbar': boozurkScripts.tinyscrollbar(); break; default : //no default action break; } } }, post_expander : function() { return $('#posts_content').find('a.more-link').each(function() { $(this).unbind().click(function() { var link = $(this); $.ajax({ type: 'POST', url: link.attr("href"), beforeSend: function(XMLHttpRequest) { link.html(boozurk_l10n.post_expander).addClass('ajaxed'); }, data: 'boozurk_post_expander=1', success: function(data) { link.parents(".storycontent").hide().html($(data)).fadeIn(600); } }); return false; }); }); }, animate_menu : function() { return $('#mainmenu').children('.menu-item-parent').each(function() { $this = $(this); var d = $this.children('ul'); //for each main item, get the sub list d.css( {'opacity' : 0 } ); $this.hoverIntent( function(){ //when mouse enters, slide down the sub list d.css( {'display' : 'block' } ).animate( { 'opacity' : 0.95 } ); }, function(){ //when mouse leaves, hide the sub list d.stop().animate( { 'opacity' : 0 }, 200, 'swing', function(){ d.css( {'display' : '' } ); } ); } ); }); }, tooltips : function() { return $('#posts_content').find('.bz-tooltip').each(function() { var p = $(this).parent(); var self = $(this); var timeoutID; self.hide(); p.unbind().hoverIntent( function(){ window.clearTimeout(timeoutID); self.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: 0.9}); }, function(){ timeoutID = window.setTimeout( function(){self.fadeOut()}, 200); } ); }); }, init_thickbox : function() { $('#posts_content').find('.storycontent a img').parent('a[href$=".jpg"],a[href$=".png"],a[href$=".gif"]').addClass('thickbox'); $('#posts_content').find('.storycontent .gallery').each(function() { $('a[href$=".jpg"],a[href$=".png"],a[href$=".gif"]',$(this)).attr('rel', $(this).attr('id')); }); }, scroll_top_bottom : function() { top_but = $('#navbuttons').find('.minib_top a'); bot_but = $('#navbuttons').find('.minib_bottom a'); // smooth scroll top/bottom top_but.click(function() { $("html, body").animate({ scrollTop: 0 }, { duration: 400 }); return false; }); bot_but.click(function() { $("html, body").animate({ scrollTop: $('#footer').offset().top - 80 }, { duration: 400 }); return false; }); }, comment_variants : function() { $('#commentform').find('.comment-variants label').click(function() { $('#comment').removeClass( 'style-default style-blue style-pink style-orange style-yellow style-green style-gray style-white' ); $('#comment').addClass( $('input', this).val() ); $('input', this).attr('checked',true); }); }, init_quote_this : function() { if ( document.getElementById('reply-title') && document.getElementById("comment") ) { bz_qdiv = document.createElement('small'); bz_qdiv.innerHTML = ' - ' + boozurk_l10n.quote + ''; bz_replink = document.getElementById('reply-title'); bz_replink.appendChild(bz_qdiv); } }, quote_this : function() { var posttext = ''; if (window.getSelection){ posttext = window.getSelection(); } else if (document.getSelection){ posttext = document.getSelection(); } else if (document.selection){ posttext = document.selection.createRange().text; } else { return true; } posttext = posttext.toString().replace(/&/g,"&").replace(/"/g,""").replace(//g,">"); if ( posttext.length !== 0 ) { document.getElementById("comment").value = document.getElementById("comment").value + '
' + posttext + '
'; } else { alert( boozurk_l10n.quote_alert ); } }, resize_video : function() { // https://github.com/chriscoyier/Fluid-Width-Video var $fluidEl = $("#posts_content").find(".storycontent"); var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com'], object, embed",$fluidEl); $allVideos.each(function() { $(this) // jQuery .data does not work on object/embed elements .attr('data-aspectRatio', this.height / this.width) .removeAttr('height') .removeAttr('width'); }); $(window).resize(function() { var newWidth = $fluidEl.width(); $allVideos.each(function() { var $el = $(this); $el .width(newWidth) .height(newWidth * $el.attr('data-aspectRatio')); }); }).resize(); }, tinynav : function() { $(".nav-menu").tinyNav({ label: '', // String: Sets the