jQuery.fn.fadeToggle = function(speed, easing, callback) { return this.animate({opacity: 'toggle'}, speed, easing, callback); }; function AddFavorite() { var title = 'Free Fonts - Font Reactor'; var url = 'http://en.fontreactor.com'; if (window.sidebar) // Firefox window.sidebar.addPanel(title, url, ''); else if(window.opera && window.print) // Opera { var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); // required to work in opera 7+ elem.click(); } else if(document.all) // IE window.external.AddFavorite(url, title); } $(document).ready(function (){ $("img").lazyload(); $('#tabs div').hide(); $('#tabs div:first').show(); //$('#tabs ul li:first').addClass('active'); // Set the class for active state $('#tabs ul li a').click(function(){ // When link is clicked $('#tabs ul li').addClass('inactive'); // Remove active class from links $(this).parent().removeClass('inactive'); //Set parent of clicked link class to active var currentTab = $(this).attr('href'); // Set currentTab to value of href attribute $('#tabs div').hide(); // Hide all divs $(currentTab).show(); // Show div with id equal to variable currentTab return false; }); $("#language_current").click(function() { $("#language-picker").fadeToggle("fast"); }); $("#close").click(function(){ $.ajax({ url: 'http://en.fontreactor.com/process.php', type: 'POST', data:"saveBrowseCats=false" }); $("#browse_cats").fadeToggle("fast"); $("#button_cats").toggleClass("collapsed").toggleClass("expanded"); return false; }); $('#returntop a').click(function(){ $('html, body').animate({scrollTop:0}, 'slow'); return false; }); $('.preview').click(function(){ var elementid = this.name; var inputs = []; $(':input', $('#previewfontform-'+elementid)).each(function() { inputs.push(this.name + '=' + encodeURIComponent(this.value)); }) $('#fontid-'+elementid).children("a").empty(); $('#loading-'+elementid).show(); var img = new Image(); $(img).load(function () { $(this).hide(); $('#fontid-'+elementid).children("a").append(this); $('#loading-'+elementid).fadeOut(function(){ $(img).fadeIn(); }); }) $(img).attr('style', 'display:inline'); $(img).attr('src', 'http://en.fontreactor.com/thumbs.php?str='+$('#'+elementid+'-preview_text').val()+'&filename='+$('#'+elementid+'-filename').val()+'&filettf='+$('#'+elementid+'-filettf').val()); return false; }) $("#submit_button").click(function(){ $('#loading').show(); var inputs = []; $(':input', $('#submit_form')).each(function() { inputs.push(this.name + '=' + encodeURIComponent(this.value)); }) $.ajax({ url: 'http://en.fontreactor.com/process.php', type:'POST', data:inputs.join('&'), timeout: 2000, error: function() { alert("Could not stablish connection. Try later."); }, success: function(r) { $('#loading').hide(); if(r.substring(0,1)==0){ $(':input', $('#submit_form')).attr("disabled",true); } $('#message_submitted').html(r.substring(2,r.length)); $('#message_submitted').fadeIn(); } }) return false; }) $('.loginbutton').click(function (e) { e.preventDefault(); $.get("http://en.fontreactor.com/process.php?show=login", function(data){ // create a modal dialog with the data $(data).modal({ close: false, position: ["15%",], overlayId: 'login-overlay', containerId: 'login-container', onOpen: login.open, onShow: login.show, onClose: login.close }); }); }); }); var login = { message: null, open: function (dialog) { // dynamically determine height var h = 220; if ($('#login-subject').length) { h += 26; } if ($('#login-cc').length) { h += 22; } var title = $('#login-container .login-title').html(); dialog.overlay.fadeIn(200, function () { dialog.container.fadeIn(200, function () { dialog.data.fadeIn(200, function () { $('#login-container .login-content').animate({ height: h+100 }, function () { $('#login-container .login-title').html(title); $('#login-container form').fadeIn(200, function () { $('#login-container #login-name').focus(); $('#login-container .login-cc').click(function () { var cc = $('#login-container #login-cc'); cc.is(':checked') ? cc.attr('checked', '') : cc.attr('checked', 'checked'); }); }); }).animate({ height: h }, "fast"); }); }); }); }, show: function (dialog) { $('#btnLogin').click(function (e) { e.preventDefault(); // validate form if (login.validate()) { $.ajax({ url: 'http://en.fontreactor.com/process.php', data: $('#login-container form').serialize() + '&sublogin=true', type: 'post', cache: false, dataType: 'html', success: function (r) { if(r.substring(0,1)==1){// errors found $('.login-message').html(r.substring(2,r.length)).fadeIn(200); }else{ window.location=r.substring(2,r.length); } }, error: login.error }); } else { if ($('#login-container .login-message:visible').length > 0) { var msg = $('#login-container .login-message div'); msg.fadeOut(200, function () { msg.empty(); login.showError(); msg.fadeIn(200); }); } else { $('#login-container .login-message').animate({ height: '30px' }, login.showError); } } }); }, close: function (dialog) { $('#login-container .login-message').fadeOut(); $('#login-container form').fadeOut(200); $('#login-container .login-content').animate({ height: 40 }, function () { dialog.data.fadeOut(200, function () { dialog.container.fadeOut(200, function () { dialog.overlay.fadeOut(200, function () { $.modal.close(); }); }); }); }); }, error: function (xhr) { alert(xhr.statusText); }, validate: function () { return true; }, showError: function () { $('#login-container .login-message') .html($('
').append(login.message)) .fadeIn(200); } }; function locale(lang,url){ $.ajax({ url: 'http://en.fontreactor.com/process.php', type: 'POST', data: 'locale='+lang, success: function(r) { window.location=url; } }); } function setMessage(destination, id, number){ var options = new Array('','Download', 'Character Map'); $('#'+destination+'-'+id).html(options[number]); } function setText(destination, id, number){ var options = new Array('Rate this font', 'Poor', 'Nothing Special', 'Acceptable', 'Pretty Cool', 'Excellent'); $('#'+destination+'-'+id).html(options[number]); } /** Color picker*/ $(function() { $('#textcolor').colorPicker(); $('#backgroundcolor').colorPicker(); });