/** * @name: dd.js * @description: customize dropdown * @author: Marghoob Suleman - http://www.marghoobsuleman.com/ * @version: 1.5 * @date: March 09, 2009 * @released: March 31, 2009 {1.4}, March 30, 2009 {1.3}, March 22, 2009 {1.2}, March 20, 2009 {1.0} * @category: Javascript Custom Component * @copyright (c) 2009 Marghoob Suleman (powered by: http://www.giftlelo.com/) */ $(document).ready(function(e) { var ua = navigator.userAgent; if(ua.indexOf('MSIE 6.0') == -1) { try { MSDropDown.init(); } catch(e) { alert(e); } } }); MSDropDown={settings:{theme:'blue',autoHide:'off',offClass:'aOff',onClass:'aOn',maintainHeight:0,idpostfixmain:'_ms',idpostfixchild:'_child',idpostfixa:'_msa',idposttitlediv:'_divtitle',idposttitle:'_title',idhidden:'_input',showTitle:true,visibleRows:7,iconWithTitle:true},styles:{ddclass:'msDropDown',childclass:'msDropDown_Child',arrow:'/shared/dd_arrow.gif',arrowclass:'msArrow',titleclass:'msDropdownTitle',disabled:'msDisabled',enabled:'msEnabled'},attributes:{action:"onfocus,onblur,onchange,onclick,ondblclick,onmousedown,onmouseup,onmouseover,onmousemove,onmouseout,onkeypress,onkeydown,onkeyup",prop:"size,multiple,disabled,tabindex"},selected:new Object(),zIndex:999,insideWindow:false,dp_array:new Object(),currentDiv:'',init:function(byID){this.storeNmake(byID);},storeNmake:function(byID){var dps=this.getAllDropDown(byID);var total=dps.length;for(var iCount=0;iCount0){this.addNewEvents(currentSelect.id);var prop=new Array();var selectProp=this.getSelectProperties(currentSelect.id);prop["selectAttributes"]=selectProp.attributes;prop["selectAction"]=selectProp.action;var width=(this.dp_array[currentSelect.id]==undefined)?$(currentSelect).width():this.dp_array[currentSelect.id].width;var height=(this.dp_array[currentSelect.id]==undefined)?$(currentSelect).height():this.dp_array[currentSelect.id].height;$(currentSelect).css({width:width+'px'});var oOptions=$("#"+currentSelect.id+"> *");var totalOptions=oOptions.length;for(var optionCount=0;optionCount0){$("#"+dd_id).remove();} var childid=dd_id+idChild;var childtitledivid=dd_id+idtitlediv;var titleid=dd_id+idtitle;var hiddeninput=dd_id+idhidden;var onchange=values.onchange;var childheight='';if(values.length>this.getVisibleRows())childheight='120';var ddhtml="";var zIndex=this.zIndex--;var css=(selectProp["disabled"]==true)?" "+this.styles.disabled:this.styles.enabled;ddhtml+="
";if(id == 'branche-portfolio') { arrow = '/shared/dd_project.gif'; };if(selectProp["disabled"]==true){ddhtml+="
Loading...
";}else{ddhtml+="
Loading...
";};ddhtml+="
";var ahtml="";var sValue="";var sImg="";for(var aCount=0;aCount";};} var isDisabled=curretna.disabled;var img="";var sTitle=(this.getShowTitle()==true)?text:'';var innerStyle=(curretna.style!=undefined)?curretna.style:'';if(curretna.optstart!=undefined){var optLabel=(curretna.optstart.label==undefined)?'':curretna.optstart.label;ahtml+="
"+optLabel+"
";};if(icon!=undefined){img="";};if(isDisabled==undefined||isDisabled==false){ahtml+="";}else{ahtml+="";};ahtml+=img+''+text+"";if(curretna.optend=="end"){ahtml+="
";};};sValue=(sValue=='')?values[0].text:sValue;ddhtml+=ahtml;ddhtml+="
";ddhtml+="
" counter++;$("#"+id).after(ddhtml);if(selectProp["disabled"]==false){}else{$("#"+dd_id).css({opacity:0.4});};this.applyEvents(dd_id,values,id);if(childheight!='')$("#"+childid).css({overflowY:'scroll',overflowX:'hidden',height:childheight+'px'});$("#"+titleid).html(sImg+sValue);this.manageSelection(id,selectedID);}},hasAction:function(prop,action){var sAction=action;var selectAction=prop;for(var i in selectAction){if(i.toString().toLowerCase()==sAction.toString().toLowerCase()&&selectAction[i]==true){return true;};};return false;},applyEvents:function(id,values,parent){var sID=id;var parent_id=parent;var props=values;var selectProp=props["selectAttributes"];var selectAction=props["selectAction"];if(selectProp["disabled"]==false){for(var i in selectAction){if(selectAction[i]==true){switch(i){case'onfocus':$("#"+sID).bind("focus",function(e){$("#"+parent_id).focus();});break;case'onblur':break;case'onchange':break;case'onclick':$("#"+sID).bind("click",function(e){$("#"+parent_id).click();});break;case'ondblclick':$("#"+sID).bind("dblclick",function(e){$("#"+parent_id).dblclick();});break;case'onmousedown':$("#"+sID).bind("mousedown",function(e){$("#"+parent_id).mousedown();});break;case'onmouseup':$("#"+sID).bind("mouseup",function(e){$("#"+parent_id).mouseup();});break;case'onmouseover':$("#"+sID).bind("mouseover",function(e){$("#"+parent_id).mouseover();});break;case'onmousemove':$("#"+sID).bind("mousemove",function(e){$("#"+parent_id).mousemove();});break;case'onmouseout':$("#"+sID).bind("mouseleave",function(e){$("#"+parent_id).mouseout();});break;case'onkeypress':$("#"+sID).bind("keypress",function(e){$("#"+parent_id).keypress();});break;case'onkeydown':$("#"+sID).bind("keydown",function(e){$("#"+parent_id).keydown();});break;case'onkeyup':$("#"+sID).bind("keyup",function(e){$("#"+parent_id).keyup();});break;};};};};},addNewEvents:function(id){document.getElementById(id).refresh=function(e){MSDropDown.refresh(this.id);}},refresh:function(id){MSDropDown.storeNmake("#"+id);},manageSelection:function(id,selected){if(this.selected[id]==undefined){this.selected[id]={selected:selected,previous:selected};};this.selected[id].selected=selected;if(this.selected[id].previous!=this.selected[id].selected){$("#"+this.selected[id].previous).removeClass('selected');};$("#"+this.selected[id].selected).addClass('selected');this.selected[id].previous=this.selected[id].selected;},setSelected:function(id,value,aID,val,imgsrc){var parentID=id.split("_")[0];this.selected[parentID].current=aID;var sID=id;var oPorop=prop;var targetDiv=sID+this.settings.idposttitle;var hiddeninput=sID+this.settings.idhidden;var prop=this.getdps(parentID);$("#"+parentID+" option:selected").text(value.toString());$("#"+parentID+" option:selected").val(val.toString());if($("#"+parentID).attr("onfocus")!=undefined){$("#"+parentID).focus();$("#"+hiddeninput).focus();};if($("#"+parentID).attr("onchange")!=undefined){$("#"+parentID).change();};$("#"+hiddeninput).val(value);var showIcon=this.getSetting("iconWithTitle");if(imgsrc.toString()!='undefined'&&showIcon==true){value=""+value;} $("#"+targetDiv).html(value);this.manageSelection(parentID,aID);this.closeDropDown();},openDropDown:function(id){var prentDiv=id;var childDiv=id+="_child";if($("#"+childDiv).css("display")=="block"){MSDropDown.closeDropDown();return false;};var position=$("#"+prentDiv).position();var childPosTop=$("#"+prentDiv).height()+parseInt($("#"+prentDiv).css("padding-top"))+'px';var parentWidth=parseInt($("#"+prentDiv).width());var childWidth=parseInt($("#"+childDiv).width());if(childWidth0){for(var iCount=0;iCount