Index: branches/1.0.x/inc/js/jquery.scripts.js =================================================================== diff -u -N -r14600 -r14754 --- branches/1.0.x/inc/js/jquery.scripts.js (.../jquery.scripts.js) (revision 14600) +++ branches/1.0.x/inc/js/jquery.scripts.js (.../jquery.scripts.js) (revision 14754) @@ -1,71 +1,86 @@ -$(document).ready(function() -{ - $('#change-password').bind('click', function() { - $("#password-show").hide(); - $("#password-block").fadeIn(); - return false; - }); +function DBlocks() { + var $me = this; + this.selectors = ['#lang', '#currency', '#login', '#login-alt']; - $('#password').keyup(function(){ - $('#result-password').html(passwordStrength($('#password').val())).show() ; - }) + $(document).ready( + function () { + $me.init(); + } + ); +} - $("#lang").click(function() { - if ( $(this).parent().is(".plashka-sel") ) { - $(this).parent().removeClass("plashka-sel"); - $("#lang-sel").fadeOut(); +DBlocks.prototype.init = function () { + var $manager = this; + + $( this.selectors.join(', ') ).click( + function($e, $now) { + var $me = $(this), + $parent = $me.parent(); + + if ( $parent.is('.plashka-sel') ) { + $parent.removeClass('plashka-sel'); + + if ( $now === undefined || $now === false ) { + $('#' + $me.attr('id') + '-sel').fadeOut(); + } + else { + $('#' + $me.attr('id') + '-sel').hide(); + } + } + else { + $manager.hideOthers($me); + + $parent.addClass('plashka-sel'); + $('#' + $me.attr('id') + '-sel').fadeIn(); + } + + return false; } - else - { - $(this).parent().addClass("plashka-sel"); - $("#lang-sel").fadeIn(); - } - return false; - }); + ); - $("#currency").click(function() { - if ( $(this).parent().is(".plashka-sel") ) { - $(this).parent().removeClass("plashka-sel"); - $("#currency-sel").fadeOut(); + $('.icon-close').click( + function() { + $('#login,#login-alt').parent().removeClass('plashka-sel'); + $('#login-sel, #login-alt-sel').fadeOut(); + + return false; } - else - { - $(this).parent().addClass("plashka-sel"); - $("#currency-sel").fadeIn(); - } - return false; - }); + ); +} - $("#login").click(function() { - if ( $(this).parent().is(".plashka-sel") ) { - $(this).parent().removeClass("plashka-sel"); - $("#login-sel").fadeOut(); +DBlocks.prototype.hideOthers = function ($current) { + $( this.selectors.join(', ') ).not($current).each( + function () { + var $me = $(this), + $parent = $me.parent(); + + if ( $parent.is('.plashka-sel') ) { + $me.trigger('click', [true]); + } } - else - { - $(this).parent().addClass("plashka-sel"); - $("#login-sel").fadeIn(); - } - return false; - }); + ); +} - $("#login-alt").click(function() { - if ( $(this).parent().is(".plashka-sel") ) { - $(this).parent().removeClass("plashka-sel"); - $("#login-alt-sel").fadeOut(); +$(document).ready(function() +{ + $('#change-password').click( + function($e) { + $('#password-show').hide(); + $('#password-block').fadeIn(); + + return false; } - else - { - $(this).parent().addClass("plashka-sel"); - $("#login-alt-sel").fadeIn(); - } - return false; - }); + ); - $(".icon-close").click(function() { - $("#login,#login-alt").parent().removeClass("plashka-sel"); - $("#login-sel,#login-alt-sel").fadeOut(); - return false; - }); + $('#password').keyup( + function($e) { + var $password = $('#password').val(); -}); \ No newline at end of file + $('#result-password') + .html( passwordStrength($password) ) + .show(); + } + ); +}); + +new DBlocks(); \ No newline at end of file