/* * A megadott input elemhez képes új stílust adni attól függően, hogy * mi annak a tartalma(üres, nem üres) * ** Máshol felhasználva az inputStyle() függvényt kell módosítani ** és a document ready eseményt (ahol meg kell adni, mely inputokon végezze ezt el) ** searchInpWidth() is dmsV2-es függvényhívás * * v:0.1 */ // Dokumentum betöltéskor meghívja az adott elemekre $j(document).ready(function() { inputFocusStyle($j("#search"), "search"); inputFocusStyle($j("#login .userName"), "login"); inputFocusStyle($j("#login .userPassword"), "login"); }); // Input stílus a DMSv2-ben function inputStyle(item, type) { if( type =="search" ) { item.css("color", "#67ade9"); item.css("font-family", "ptsansBold"); } if( type =="login" ) { item.css("color", "#5b5b5b"); item.css("font-family", "corporate"); } } function removeAtri(item, type) { item.removeAttr( 'style' ); if( type == "search") { searchInpWidth(); } } // Az input value stlíusát módosítja focus és focusout esetén // Illetve billentyűleütés esetén function inputFocusStyle(item, type) { // Ha üres amikor a focus lekerül róla akkor elveszi a stílust item.focusout(function(){ if(itemvaluelength(item) == 0) { removeAtri(item, type); } }); //Betöltéskor megvizsgálja, hogy üres-e ha nem akkor más stílust kap if(itemvaluelength(item) != 0) { inputStyle(item, type); } // Ha megkapja a focust akkor hozzáadja a stílust item.focus(function() { if(itemvaluelength(item) != 0) { inputStyle(item, type); } }); // Ha üres inputban leütünk egy karaktert akkor hozzáadja stílus item.keydown(function() { if(itemvaluelength(item) == 0) { inputStyle(item, type); } }); // Ha a gépelés végére üres akkor elveszi a stílust item.keyup(function() { if(itemvaluelength(item) == 0) { removeAtri(item, type); } }); } function itemvaluelength(item) { if(isset(item)) { x=item.val(); if(isset(x)) return(x.length); } return(0); }