From c7a5e4e0074d51c2368d26bf31ef659286c7f7c2 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Fri, 7 Feb 2014 10:34:26 +0200 Subject: [PATCH] Update 90-custom.js --- js/90-custom.js | 60 +++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/js/90-custom.js b/js/90-custom.js index bff6ab1..3759c1b 100644 --- a/js/90-custom.js +++ b/js/90-custom.js @@ -1,44 +1,34 @@ -function set_style(name){ - $('#stylesheet').attr("href", "/css/" + name); - localStorage.setItem("theme", name); +(function(){ + 'use strict'; + function set_style(name){ + $('#stylesheet').attr("href", "/css/" + name); + localStorage.setItem("theme", name); + } - $('#yardi').attr('src', name == "slate" || name == "cyborg" ? "/img/yardi-white.png" : "/img/yardi-blue.png"); -} + $( document ).ready(function() { + var hiddenDiv = $(document.createElement('div')); -$( document ).ready(function() { - var txt = $('#comments'); - hiddenDiv = $(document.createElement('div')), - content = null; + hiddenDiv.addClass('hiddendiv common'); - txt.addClass('txtstuff'); - hiddenDiv.addClass('hiddendiv common'); + $('body').append(hiddenDiv); - $('body').append(hiddenDiv); + $("textarea.autoresize").on('keyup', function () { + var content = $(this).val(); - $("textarea.autoresize").on('keyup', function () { - content = $(this).val(); + content = content.replace(/\n/g, '
'); + hiddenDiv.html(content + '
'); - content = content.replace(/\n/g, '
'); - hiddenDiv.html(content + '
'); + $(this).css('height', hiddenDiv.height()+23); + }); - $(this).css('height', hiddenDiv.height()+23); + $('#theme_slate' ).on('click', function () { set_style("slate"); }); + $('#theme_cerulean').on('click', function () { set_style("cerulean"); }); + $('#theme_cyborg' ).on('click', function () { set_style("cyborg"); }); + $('#theme_cosmo' ).on('click', function () { set_style("cosmo"); }); }); - $('#theme_slate' ).on('click', function () { set_style("slate"); }); - $('#theme_cerulean').on('click', function () { set_style("cerulean"); }); - $('#theme_cyborg' ).on('click', function () { set_style("cyborg"); }); - $('#theme_cosmo' ).on('click', function () { set_style("cosmo"); }); -}); - -var theme = localStorage.getItem("theme"); -if(theme) { - set_style(theme); - $(document).ready(function(){ - $('#yardi').attr('src', theme == "slate" || theme == "cyborg" ? "/img/yardi-white.png" : "/img/yardi-blue.png"); - }) -} - -$( document ).ready(function() { - var sb=$('#sidebar').detach(); - sb.appendTo($('#sponsors')); -}); + var theme = localStorage.getItem("theme"); + if(theme) { + set_style(theme); + } +})(); -- 2.39.2