(function($) { /** * BDS jQuery Slider Plugin */ $.fn.jSlider = function(event,options) { var defaults = { backgroundElement : false, backgroundPosition : '0 0', className : false, slideElement : false }; var o = $.extend(defaults, options); var origPos = $("" + o.backgroundElement +"").css("background-position"); if (o.slideElement) { var slideObj = $("" + o.slideElement +""); if (event == 'over') { slideObj.slideDown(); if (o.backgroundElement) { $("" + o.backgroundElement +"").css("background-position", o.backgroundPosition); } if (o.className) { $(this).toggleClass(o.className); } } else if (event == 'out') { slideObj.slideUp(); if (o.backgroundElement) { $("" + o.backgroundElement +"").css("background-position", o.backgroundPosition); } if (o.className) { $(this).toggleClass(o.className); } } } }; /** * BDS jQuery Delay Plugin */ $.fn.delay = function(time, callback){ jQuery.fx.step.delay = function(){}; return this.animate({delay:1}, time, callback); }; /** * BDS jQuery InputAdvise Plugin */ $.fn.inputAdvise = function(overClass) { return this.each(function(){ var input = jQuery(this); var title = input.attr('title'); if (title) { this.hide = function() { if (input.val() == '' || input.val() == title) input.val(''); } this.show = function() { if (input.val() == '') input.val(title); } // handlers input.focus(this.hide); input.blur(this.show); if (input.val() == '') input.val(title); } }) }; /** * BDS jQuery to enable links opening in popup * just call openInPopup on Link-Selector */ $.fn.openInPopup = function(options) { var defaults = { type: 'GET', data: null }; var o = $.extend(defaults, options); var fetchContent = function(link) { $.ajax({ type: o['type'], url: $(link).attr('href'), data: o['data'], async: false, success: function(data) { $.modal(data, { //TODO just till styling is enabled closeHTML: 'Schliessen' }); }, error: function() { // nothing } }); } return this.each(function(){ $(this).bind('click', function() { fetchContent($(this)); return false; }); }); }; $.fn.helpable = function (helpClass) { return this.each(function() { $(this).focus(function() { if ($(this).siblings(helpClass).length > 0) { $(this).siblings(helpClass).show(); } }); $(this).blur(function () { if ($(this).siblings(helpClass).length > 0) { $(this).siblings(helpClass).hide(); } }); }); }; $.fn.globalLoadIndicator = function (options) { var defaults = { text_load: 'Bitte warten ...' }; var o = $.extend(defaults, options); return this.each(function(){ var indicator = new loadIndicator(o.text_load, true); $(this).bind("ajaxSend", function(){ indicator.show(this); }).bind("ajaxComplete", function(){ indicator.hide(); }); }); }; $.fn.passwordStrength = function (passwordField, usernameField, messages) { return this.each(function() { var container = $(this); this.update = function() { var perc = passwordStrengthPercent(passwordField.val(),usernameField.val()); var equal = (passwordField.val().toLowerCase() == usernameField.val().toLowerCase()); var bpos = "0px -" + perc + "px"; container.find(".colorbar").css("backgroundPosition", bpos); var width = Math.floor(perc * 1.4) + "px"; container.find(".colorbar").css("width", width); if (equal) { container.find(".result").html(messages[0]); } else if (perc < 1) { container.find(".result").html(messages[1]); } else if (perc < 34) { container.find(".result").html(messages[2]); } else if (perc < 68) { container.find(".result").html(messages[3]); } else { container.find(".result").html(messages[4]); } }; usernameField.keyup(this.update); passwordField.keyup(this.update); }); }; function passwordStrengthPercent(password,username) { score = 0; //password < 4 if (password.length < 4 ) { return 0; } //password == username if (password.toLowerCase()==username.toLowerCase()) { return 0; } //password length score += password.length * 4; score += ( checkRepetition(1,password).length - password.length ) * 1; score += ( checkRepetition(2,password).length - password.length ) * 1; score += ( checkRepetition(3,password).length - password.length ) * 1; score += ( checkRepetition(4,password).length - password.length ) * 1; //password has 3 numbers if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) { score += 5; } //password has 2 sybols if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) { score += 5; } //password has Upper and Lower chars if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) { score += 10; } //password has number and chars if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) { score += 15; } //password has number and symbol if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) { score += 15 } //password has char and symbol if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) { score += 15; } //password is just a nubers or chars if (password.match(/^\w+$/) || password.match(/^\d+$/)) { score -= 10; } if (score > 100) { return 100; } return score; } function checkRepetition(pLen,str) { res = ""; for ( i=0; i"; } indicator.hide(); displayHint(errors); } else { document.location = data.location; } }, error: function () { indicator.hide(); displayOutput(o.text_error); messageDiv.addClass('error'); }, complete: function() { // don't hide load indicator cause of clientside redirect; } }); } loginForm.bind('submit', processLogin); $(this).bind('click', function(e) { loginForm.trigger('submit'); e.preventDefault(); }); }); }; })(jQuery); /** * common load indicator; append static html span after given element * * @param message i18n message to display while loading * @return void */ function loadIndicator(message, global) { var globalClass = typeof(global) != 'undefined' && global == true ? ' globalIndicator' : ''; var loadIndicatorHtml = '+message+ '+message+''; var is_visible = false; this.show = function(element) { if(!is_visible) { $(element).prepend(loadIndicatorHtml); is_visible = true; } }; this.showAfter = function(afterElement) { if(!is_visible) { $(afterElement).after(loadIndicatorHtml); is_visible = true; } }; this.hide = function() { $('.indicator').remove(); is_visible = false; }; }