/* utywidgets.js - utillyty Copyright (C) 2010 Attilio Pavone GNU General Public License version 3 */ // tilly 24/12/2009 // v1.0 var UTY_HTFLAGS_READONLY=1; var UTY_HTFLAGS_DISABLED=2; var UTY_HTFLAGS_NOWRAP=4; var UTY_HTFLAGS_SELECTED=8; function utyWidget(){} utyWidget.prototype.__init=function(id){ this._id=id; this._element=null; } utyWidget.prototype.id=function(){ return this._id; } utyWidget.prototype.element=function(){ if(!this._element)this._element=document.getElementById(this._id); return this._element; } utyWidget.prototype.text=function(text){ return uty_text(this.element(),text); } utyWidget.prototype.disabled=function(value){ if(value===true)this.element().disabled='disabled'; if(value===false)this.element().disabled=''; return this.element().disabled==='disabled' || this.element().disabled===true; // tilly 10/02/2011 } utyWidget.prototype.toString=function(){return "utyWidget";} function utyButtonBase(id,onclick){ this.__init(id,onclick); } utyButtonBase.prototype=new utyWidget(); utyButtonBase.prototype.__init=function(id,onclick){ utyWidget.prototype.__init.call(this,id); this.onclick=onclick; } utyButtonBase.prototype.click=function(element,event){ if(this.onclick)return eval(this.onclick); } utyButtonBase.prototype.toString=function(){return "utyButtonBase";} function utyButton(id,onclick){ this.__init(id,onclick); } utyButton.prototype=new utyButtonBase(); utyButton.prototype.text=function(text){ var td_text=document.getElementById(this.id()+"_text"); if(!td_text)return ""; return uty_text(td_text,text); } utyButton.prototype.toString=function(){return "utyButton";} function utyStatusbarPanel(id){ this.__init(id); } utyStatusbarPanel.prototype=new utyWidget(); utyStatusbarPanel.prototype.toString=function(){return "utyStatusbarPanel";} function utyListviewColumn(lvwId,id,onclick,sizable){ this.__init(id,onclick); this.formatInfo={"date-format:":"",'dec-point':'.','thousands-sep':''}; this._lvwId=lvwId; this.listview=function(){ return eval('window.'+this._lvwId); } this._sizable=sizable; this.sizable=function(){ return this._sizable; } this.onresize=""; this.resize=function(){ if(this.onresize)eval(this.onresize); } this._dispSort=undefined; this.dispSort=function(order){ if(order!==undefined){ this._dispSort=order; var img_sort_asc=document.getElementById(this.id()+"_sort_asc"); var img_sort_desc=document.getElementById(this.id()+"_sort_desc"); img_sort_asc.style.display='none'; img_sort_desc.style.display='none'; switch(order){ case UTY_SORT_ASC:img_sort_asc.style.display='block';break; case UTY_SORT_DESC:img_sort_desc.style.display='block';break; } } return this._dispSort; } this.sort=function(type){ var revsort=this.dispSort(); switch(revsort){ case UTY_SORT_ASC:revsort=UTY_SORT_DESC;break; case UTY_SORT_DESC:revsort=UTY_SORT_ASC;break; default:revsort=UTY_SORT_ASC;break; } this.listview().sort(this,type,revsort); } this.index=function(){return this.element().cellIndex;} } utyListviewColumn.prototype=new utyButtonBase(); utyListviewColumn.prototype.click=function(element,event){ var pageX=uty_page_x(event); var clientX=uty_page_x(element); if ((pageXclientX+element.offsetWidth-utyListviewColumn.CAPTURE_MARGIN) )return; return utyButtonBase.prototype.click.call(this,element,event); } utyListviewColumn.prototype.toString=function(){return "utyListviewColumn";} utyListviewColumn.CAPTURE_MARGIN=10; function utyListviewHead(lvwId,id){ this.__init(id); var m_hotCell=null,m_dragCell=null,m_restoreCursor=null,m_dragX=0,m_captureOffset=0; this._lvwId=lvwId; this.listview=function(){ return eval('window.'+this._lvwId); } this._columns=null; this.columns=function(index){ if(this._columns==null){ this._columns=new Array(); var row=this.rowElement(); for (var i=0;ihotCellX)&&(eventX0){ this.setHotCell(row.cells[m_hotCell.cellIndex-1]); } } else if(!((eventX>hotCellX+m_hotCell.offsetWidth-utyListviewColumn.CAPTURE_MARGIN)&&(eventXcellX){ if(eventX0)this.setHotCell(row.cells[cell.cellIndex-1]); }else if(((eventX>cellX+cell.offsetWidth-utyListviewColumn.CAPTURE_MARGIN)&&(eventX=0){ newwidth+="px"; this.setCellWidth(m_dragCell, newwidth); } } this.setDragCell(); this.listview().bodyElement().onscroll();//opera adjust. NB:after reset hotCell! uty_document_disable_onselectstart(false); } this.setHotCell=function(cell){ if(cell){ var column=eval('window.'+cell.id); if(!column||!column.sizable())return; this.element().style.cursor="e-resize"; m_hotCell=cell; }else{ this.element().style.cursor = m_restoreCursor; m_hotCell = null; } } this.setDragCell=function(cell,eventX,eventY){ if(cell){ var sizer=this.colSizerElement(); m_captureOffset=uty_page_x(cell)+cell.offsetWidth-eventX;//CAPTURE_MARGIN eventX+=m_captureOffset; sizer.style.left=(eventX-uty_window_scroll_x())+"px";//position:fixed sizer.style.top=(uty_page_y(this.element())-uty_window_scroll_y())+"px"; sizer.style.height=this.listview().element().clientHeight+"px"; sizer.style.display="block"; m_dragX=eventX; m_dragCell=cell; }else{ this.colSizerElement().style.display="none"; m_dragCell=null; } } } utyListviewHead.prototype=new utyWidget(); utyListviewHead.prototype.toString=function(){return "utyListviewHead";} function utyListview(id,selectionMode,onselchange,onconfirm){ this.__init(id); var m_object=this;//sort callback this._sortIndex=-1; this._sortFormatInfo=null; this._selectionMode=selectionMode; this.selectionMode=function(mode){ if (mode0)return this.selectedIndexes(0); return -1; } this.onselchange=onselchange; this.onconfirm=onconfirm; this._bodyElement=null; this.bodyElement=function(){ if(this._bodyElement==null)this._bodyElement=document.getElementById(this.id()+"_body"); return this._bodyElement; } this._bodyTableElement=null; this.bodyTableElement=function(){ if(this._bodyTableElement==null)this._bodyTableElement=this.bodyElement().childNodes[0]; return this._bodyTableElement; } this._listHead=null; this.listHead=function(){ if(this._listHead==null)this._listHead=eval('window.'+this.id()+"_head"); return this._listHead; } this.columns=function(index){ return this.listHead().columns(index); } this.getColumnById=function(id){ return this.listHead().getColumnById(id); } this.loadBody=function(html){ this._currentRow=null; this._selectedIndexes=new Array(); this._bodyTableElement=null; this.bodyElement().innerHTML=html; this.listHead().refresh();//ie7 crash } this.text=function(row,col,text){ var cellIdx=isNaN(col)?this.getColumnById(col).index():col; var cell=this.bodyTableElement().rows[row].cells[cellIdx].childNodes[0]; return uty_text(cell,text); } this.mousedown=function(row,event){ //var row=cell.parentNode; if(this._selectionMode>0){ this.execSelect(row,event.ctrlKey,event.shiftKey);//NB: set currentRow before onselchange }else{ this.setCurrentRow(row); } if(event.ctrlKey||event.shiftKey){ uty_document_disable_onselectstart(true);//ie return false;//w3c } } this.mouseup=function(row,event){ uty_document_disable_onselectstart(false); } this.dblclick=function(row, event){ if(this.onconfirm){ uty_selection_clear(); eval(this.onconfirm); } } this.rows=function(index){ var tbodies=this.bodyTableElement().getElementsByTagName('tbody'); var tbody=null; if(tbodies && tbodies.length>0) tbody=tbodies[0]; if(tbody){ if(index!==undefined)return tbody.rows[index]; return tbody.rows; }else{ return new Array(); } } this.setCurrentRow=function(row){ if(this._currentRow){ this._currentRow.className=this._currentRow.restoreclass; if(this._currentRow.selected)this._currentRow.className+="_select"; } if(!row.selected)row.restoreclass=row.className; row.className=row.restoreclass+"_current"; if (row.selected)row.className+="_select"; this._currentRow=row; } this.selectingRows=function(row, range){ var rows=new Array(); if(range&&this._selectionMode>1){ var start=this._currentRow?this._currentRow.rowIndex:0; var end=row.rowIndex; if(end0){ this.unselectRow(this.bodyTableElement().rows[this._selectedIndexes[0]]); } } this.execSelect=function(row,append,range){ if(!(append&&(this._selectionMode>1)))this.unselectAll(); var rows=this.selectingRows(row,range); for(var i=0;ithis.bodyElement().clientHeight) if(this.element().offsetParent && (this.element().offsetParent.style.position=='absolute' || this.element().offsetParent.style.position=='fixed')) this.scrollIntoView(row); else if(row.scrollIntoView) row.scrollIntoView(); } return i; }else{ if(select)this.unselectAll(); return -1; } } this.keypress=function(event){ var i=this.currentIndex(); var l=this.rows().length-1; switch(uty_key_code(event)){ case UTY_KEY_CODE_RETURN: if((this.selectedIndex()>=0)&&(this.onconfirm))eval(this.onconfirm);return false; case UTY_KEY_CODE_DOWN: if(++i>l)i=0; break; case UTY_KEY_CODE_UP: if(--i<0)i=l; break; case UTY_KEY_CODE_PAGE_DOWN: if((i+=this.pageRowsCount())>l)i=l; break; case UTY_KEY_CODE_PAGE_UP: if((i-=this.pageRowsCount())<0)i=0; break; default: i=-1; } if(i>=0 && i<=l){ var row=this.rows(i); if(this._selectionMode>0){ this.execSelect(row,event.ctrlKey,event.shiftKey);//NB: set currentRow before onselchange }else{ this.setCurrentRow(row); } this.scrollIntoView(row); return false; } } this.scrollIntoView=function(row){ if(row.offsetTop+row.offsetHeight>this.bodyElement().scrollTop+this.bodyElement().clientHeight) this.bodyElement().scrollTop=row.offsetTop+row.offsetHeight-this.bodyElement().clientHeight; if(row.offsetTop0)return this.bodyElement().clientHeight/this.rows(0).offsetHeight; //return 0; TODO! return 10; } } utyListview.prototype=new utyWidget(); utyListview.prototype.toString=function(){return "utyListview";} function utyTreeview(id,onselchange,onconfirm,ondispchange){ this.__init(id); this.onselchange=onselchange; this.onconfirm=onconfirm; this.ondispchange=ondispchange; this._currentNode=null; this.currentNode=function(){ return this._currentNode; } this.click=function(node){ this.setCurrentNode(node); } this.dblclick=function(node){ if(this.firstChildIndex(node)>=0){ uty_selection_clear(); this.dispchange(node); } this.setCurrentNode(node); if(this.onconfirm)return eval(this.onconfirm); } this.dispchange=function(node){ if(this.ondispchange)if(eval(this.ondispchange)===false)return; if(!this.expanded(node))this.expand(node); else this.collapse(node); } this.expanded=function(node){ if(!node)return true;//root var img=this.treeImgElement(node); if(img.alt=='+')return false; else return true; } this.setCurrentNode=function(node){ if(this._currentNode)this.labelElement(this._currentNode).className=""; if(this.isChild(node)&&(node!=this.element())){ var labelElement=this.labelElement(node); labelElement.className="current"; this._currentNode=node; }else{ this._currentNode = null; } if(this.onselchange)return eval(this.onselchange); } this.expand=function(node){ if(!this.isChild(node)||(node==this.element()))return; var img=this.treeImgElement(node); img.alt='-'; img.src=img.src.replace("tree_plus.png","tree_minus.png"); var firstChild=this.firstChildIndex(node); if (firstChild<0)return; for (var i=firstChild;ifirstChild){ if(this.currentNode()==node.childNodes[firstChild])this.setCurrentNode(null); node.removeChild(node.childNodes[firstChild]); } } this.appendChildren=function(node,html){ if(!node)node=this.element(); node.innerHTML+=html; } this.text=function(node,text){ return uty_text(this.labelElement(node),text); } this.insertChild=function(node,html){ if(!node)node=this.element(); var frag=document.createElement('div'); frag.innerHTML=html; var newNode=frag.childNodes[0]; var text=this.text(newNode).toLowerCase(); var refNode=null; if(this.firstChildIndex(node)>=0){ for(var i=this.firstChildIndex(node);itext){ refNode=node.childNodes[i]; break; } } } if(refNode){ node.insertBefore(newNode,refNode); newNode.style.background=this._treelinebg; } else{ if(this.lastChild(node))this.lastChild(node).style.background=this._treelinebg; node.appendChild(newNode); newNode.style.background=""; } //if(newNode.scrollIntoView)newNode.scrollIntoView(); return newNode; } this.lastChild=function(node){ if(!node)node=this.element(); if(node.childNodes[node.childNodes.length-1].nodeName.toLowerCase()=='div')return node.childNodes[node.childNodes.length-1]; return null; } this.replace=function(node,html){ var current=(node==this.currentNode()); //var last=(node==this.lastChild(node.parentNode)); //var frag=document.createElement('div'); //frag.innerHTML=html; //var newNode=frag.childNodes[0]; //node.parentNode.replaceChild(newNode,node); //if(last)newNode.style.background=""; //else newNode.style.background=this._treelinebg; var parent=this.parent(node); this.remove(node); node=this.insertChild(parent,html); if(current)this.setCurrentNode(node); } this.isChild=function(node,parent){ if(!node)return false; var hparent=parent?parent:this.element(); var hnode=node; do{ if(hnode==hparent)return true; if(hnode==this.element())break; }while(hnode=this.parent(hnode)); return false; } } utyTreeview.prototype=new utyWidget(); utyTreeview.prototype.toString=function(){return "utyTreeview";} utyTreeview.getNode=function(td){ var node=td; while(node.nodeName.toLowerCase()!='div'){ node=node.parentNode; } return node; } /** * dialog widget base */ function utyDialog(id,onconfirm,oncancel){ this.__init(id,onconfirm,oncancel); var m_object=this; this.visible=function(){ return this.element().style.display=='block'; } /** * show the dialog */ this.show=function(modal,position){ if(modal)this.plexiglas(); if(this.oncancel)this.cancelElement().style.display='inline'; else this.cancelElement().style.display='none'; this.element().style.display='block'; if(position=='center-window')uty_center_in_window(this.element());//after display this._onmousedown=window.onmousedown; window.onmousedown=this.mousedown; this.focus(); //uty_window_add_event('mousedown', this.mousedown); } this.focus=function(){ document.getElementById(m_object._id+"_ok").focus(); } this.plexiglas=function(){ var pg=document.createElement('div'); pg.className='utyplexyglas'; pg.onclick=this.focus; document.body.appendChild(pg); this._pg=pg; } this.confirm=function(){ this.hide(); if(this.onconfirm)eval(this.onconfirm); } this.cancel=function(){ this.hide(); if(this.oncancel)eval(this.oncancel); } /** * INTERNAL window mousedown */ this.mousedown=function(event){ var titlebar=m_object.titlebarElement(); if(!event)event=window.event;//ie m_object._x=uty_window_x(event); m_object._y=uty_window_y(event); m_object._left=m_object.element().offsetLeft; m_object._top=m_object.element().offsetTop; if(m_object._xm_object._left+titlebar.offsetWidth|| m_object._ym_object._top+titlebar.offsetHeight)return; uty_document_disable_onselectstart(true); uty_window_add_event('mousemove', m_object.mousemove); uty_window_add_event('mouseup', m_object.mouseup); titlebar.style.cursor='move'; return false; } /** * INTERNAL window mouseup */ this.mouseup=function(){ uty_window_remove_event('mousemove', m_object.mousemove); m_object.titlebarElement().style.cursor=''; uty_document_disable_onselectstart(false); } /** * INTERNAL window mouse move if dragging */ this.mousemove=function(event){ if(!event)event=window.event;//ie var x=uty_window_x(event); var y=uty_window_y(event); if(x<0||x>uty_window_width()||y<0||y>uty_window_height())return; var dx=x-m_object._x; var dy=y-m_object._y; m_object.element().style.left=(m_object._left+dx)+"px"; m_object.element().style.top=(m_object._top+dy)+"px"; } this.titlebarElement=function(){ return this.element().childNodes[0]; } this.titleElement=function(){ return document.getElementById(this.id()+'_title'); } this.cancelElement=function(){ return document.getElementById(this.id()+'_cancel'); } } utyDialog.prototype=new utyWidget(); utyDialog.prototype.__init=function(id,onconfirm,oncancel){ utyWidget.prototype.__init(id); this.onconfirm=onconfirm; this.oncancel=oncancel; } /** * hide the dialog */ //overridable utyDialog.prototype.hide=function(){ this.element().style.display='none'; window.onmousedown=this._onmousedown; document.body.removeChild(this._pg); } utyDialog.prototype.toString=function(){return "utyDialog";} function utyMsgbox(id){ this.__init(id); this.queue=new Array(); this.messageElement=function(){ return document.getElementById(this.id()+'_message'); } this.iconElement=function(){ return document.getElementById(this.id()+'_icon'); } this.setLevel=function(level){ var img = "/err_none_big.png"; switch(level*1) { case UTY_ERR_WARN: img = "/err_warn_big.png"; break; case UTY_ERR_USR: img = "/err_usr_big.png"; break; case UTY_ERR_APP: img = "/err_app_big.png"; break; case UTY_ERR_SYS: img = "/err_sys_big.png"; break; } this.iconElement().src=utyMsgbox.res+img; } this.hide=function(){ utyDialog.prototype.hide.call(this); utyMsgbox.dequeue(); } } utyMsgbox.prototype=new utyDialog(); utyMsgbox.show=function(level,title,message,onconfirm,oncancel){ var msgbox=eval(utyMsgbox.id); if(!msgbox.visible()){ msgbox.onconfirm=onconfirm; msgbox.oncancel=oncancel; msgbox.setLevel(level); uty_text(msgbox.titleElement(),title); uty_text(msgbox.messageElement(),message); msgbox.show(true,'center-window'); }else{ msgbox.queue.push({'level':level,'title':title,'message':message,'onconfirm':onconfirm,'oncancel':oncancel}); } } utyMsgbox.dequeue=function(){ var msgbox=eval(utyMsgbox.id); if(msgbox.queue.length>0){ var data=msgbox.queue.shift(); utyMsgbox.show(data.level,data.title,data.message,data.onconfirm,data.oncancel); } } utyMsgbox.prototype.toString=function(){return "utyMgbox";} function utyDropdown(id, buddyId){ this.__init(id); this._buddyId = buddyId; this._buddyElement=null; this.buddyElement=function(){ if (this._buddyElement==null) this._buddyElement=document.getElementById(this._buddyId); return this._buddyElement; } this.setPosition=function(){ var buddyElem=this.buddyElement(); var element=this.element(); var bleft=uty_window_x(buddyElem); var btop=uty_window_y(buddyElem); if((uty_window_height()-(btop+buddyElem.offsetHeight+2)0)) element.style.top=(uty_page_y(buddyElem)-element.offsetHeight-2)+"px"; else element.style.top=(uty_page_y(buddyElem)+buddyElem.offsetHeight+2)+"px"; if((uty_window_width()-bleft0)) element.style.left = (uty_page_x(buddyElem) + buddyElem.offsetWidth - element.offsetWidth)+"px"; else element.style.left = uty_page_x(buddyElem)+"px"; } this.show=function(){ this.element().style.left=uty_window_scroll_x()+"px"; this.element().style.top=uty_window_scroll_y()+"px"; this.element().style.display="block"; this.setPosition();//after display! } this.hide=function(){ this.element().style.display="none"; } this.visible=function(){ return this.element().style.display=='block'; } } utyDropdown.prototype=new utyWidget(); utyDropdown.prototype.toString=function(){return "utyDropdown";} function utyCombobox(id, listMode, listColValue, listColText, htFlags, onchange){ this.__init(id); this.listMode=listMode; this.listColValue=listColValue; this.listColText=listColText; this.onchange=onchange; this._htFlags=htFlags; this.htFlags=function(flags){ if(flags!==undefined)this._htFlags=flags; if(this._htFlags & UTY_HTFLAGS_DISABLED)this.disabled(true);else this.disabled(false); if(this._htFlags & UTY_HTFLAGS_READONLY)this.readonly(true);else this.readonly(false); return htFlags; } this.readOnly=function(value){ if(value!==undefined){ if(value){ this.button.disabled=true; this.textElement.readonly=true; this._htFlags |= UTY_HTFLAGS_READONLY; }else{ if(this.listMode<2)this.textElement.readonly=false; if(!(this._htFlags&UTY_HTFLAGS_DISABLED))this.button.disabled=false; this._htFlags &= ~UTY_HTFLAGS_READONLY; } } return this._htFlags&UTY_HTFLAGS_READONLY; } this._dropdownObj=null; this.dropdownObj=function(){ if (this._dropdownObj==null) this._dropdownObj=eval("window."+this._id+"_dropdown"); return this._dropdownObj; } this._textElement=null; this.textElement=function(){ if (this._textElement==null) this._textElement=document.getElementById(this._id+"_text"); return this._textElement; } this._valueElement=null; this.valueElement=function(){ if (this._valueElement==null) this._valueElement=document.getElementById(this._id+"_value"); return this._valueElement; } this._buttonElement=null; this.buttonElement=function(){ if (this._buttonElement==null) this._buttonElement=document.getElementById(this._id+"_button"); return this._buttonElement; } this._list=null; this.list=function(){ if (this._list==null) this._list=eval("window."+this._id+"_listview"); return this._list; } this.dropdownShow=function(){ if(!this.list().element().style.width){ this.list().element().style.width = this.element().offsetWidth+"px"; } this.dropdownObj().show(); this.find(); this.buttonElement().normalClassName=this.buttonElement().className; this.buttonElement().className+="_pressed"; } this.dropdownHide=function(){ this.dropdownObj().hide(); this.buttonElement().className=this.buttonElement().normalClassName; } this.text_onchange=function(){ var list = this.list(); var i=list.find(this.textElement().value,this.listColText,true,false); if(this.listMode>0){ if(i>=0)this.value(list.text(i,this.listColValue)); else this.value(null); } else { if(i>=0)this.value(list.text(i,this.listColValue)); else this.value(this.textElement().value); } if(this.onchange)eval(this.onchange); } this.text_onkeydown=function(event){ if(this.readOnly())return; var list = this.list(); if (list.keypress(event)===false) { if (list.selectedIndex()>=0) { var oldText = this.textElement().value; this.textElement().value = list.text(list.selectedIndex(), this.listColText); if(oldText!=this.textElement().value)this.text_onchange(); } uty_select(this.textElement(), 0); uty_stop_propagation(event); return; } switch(uty_key_code(event)){ case UTY_KEY_CODE_F1+3:return this.button_onclick(); } } this.text_onkeyup=function(event){ if(this.readOnly())return; this.find(); } this.find=function(){ this.list().find(this.textElement().value,this.listColText,false,true); } this.text_onblur=function(){ //if(this.textElement().value != this.textElement().defaultValue)this.text_onchange(); } this.list_onconfirm=function(){ //this._isActive=true; var list = this.list(); if (list.selectedIndex()>=0) { var oldText = this.textElement().value; this.textElement().value = list.text(list.selectedIndex(), this.listColText); if(oldText!=this.textElement().value)this.text_onchange(); } this.dropdownHide(); uty_select(this.textElement(), 0); //this._isActive=false; } this.button_onclick=function(){ //this._isActive=true; if(this.dropdownObj().visible()){ this.dropdownHide(); }else{ this.dropdownShow(); } uty_select(this.textElement(), 0); //this._isActive=false; } this.value=function(newValue){ if(newValue!==undefined){ this.valueElement().value=newValue; if (this.listColValue == this.listColText) { this.textElement().value=newValue; } else { var i=this.list().find(newValue, this.listColValue, true, false); if (i>=0) { this.textElement().value=this.list().text(i,this.listColText); } } } return this.valueElement().value; } this.listText=function(col){ var list = this.list(); if(!col)col=this.listColValue; var i=list.find(this.textElement().value, this.listColText, true, false); if(i>=0) return list.text(i, col); return null; } this.listValue=function(){ if(this.list().find(this.valueElement().value, this.listColValue, true, false)>=0) return this.valueElement().value; return null; } } utyCombobox.prototype=new utyWidget(); utyCombobox.prototype.disabled=function(value){ if(value!==undefined){ if(value){ this.textElement().disabled=this.valueElement().disabled=this.buttonElement.disabled='disabled'; this._htFlags |= UTY_HTFLAGS_DISABLED; }else{ this.textElement().disabled=this.valueElement().disabled=''; if(!this.readOnly())this.buttonElement().disabled=''; this._htFlags &= ~UTY_HTFLAGS_DISABLED; } } return this._htFlags&UTY_HTFLAGS_DISABLED; } utyCombobox.prototype.toString=function(){return "utyCombobox";} function utyDatebox(id,format,dropdownMode,onchange){ this.__init(id); this.format=format; this.comboMode=dropdownMode; this.onchange=onchange; this._dropdownObj=null; this.dropdownObj=function(){ if (this._dropdownObj==null) this._dropdownObj=eval("window."+this._id+"_dropdown"); return this._dropdownObj; } this._textElement=null; this.textElement=function(){ if (this._textElement==null) this._textElement=document.getElementById(this._id+"_text"); return this._textElement; } this._buttonElement=null; this.buttonElement=function(){ if (this._buttonElement==null) this._buttonElement=document.getElementById(this._id+"_button"); return this._buttonElement; } this._calendar=null; this.calendar=function(){ if (this._calendar==null) this._calendar=eval("window."+this._id+"_calendar"); return this._calendar; } this.dropdownShow=function(){ this.dropdownObj().show(); this.text_onkeyup(); this.buttonElement().normalClassName=this.buttonElement().className; this.buttonElement().className+="_pressed"; } this.dropdownHide=function(){ this.dropdownObj().hide(); this.buttonElement().className=this.buttonElement().normalClassName; } this.text_onchange=function(){ this.value(uty_parse_date(this.textElement().value,this.format)); if (this.onchange) eval(this.onchange); } this.text_onkeydown=function(event){ switch(uty_key_code(event)){ case UTY_KEY_CODE_F1+3:return this.button_onclick(); } } this.text_onkeyup=function(event){ } this.text_onblur=function(){ } this.button_onclick=function(){ if(this.dropdownObj().visible()){ this.dropdownHide(); }else{ this.dropdownShow(); } uty_select(this.textElement(), 0); } this.value=function(newValue){ if(newValue!=null){ if(!isNaN(newValue.getTime())) this.textElement().value=uty_format_date(newValue, this.format); else this.textElement().value=""; } return this.textElement().value; } } utyDatebox.prototype=new utyWidget(); utyDatebox.prototype.toString=function(){return "utyDatebox";} function utyNumberbox(id, decimals, decPoint, thousandsSep, onchange){ this.__init(id); this.decimals=decimals; this.decPoint=decPoint; this.thousandsSep=thousandsSep; this.onchange=onchange; this._textElement=null; this.textElement=function(){ if (this._textElement==null) this._textElement=document.getElementById(this._id+"_text"); return this._textElement; } this.value=function(newValue){ if(newValue!==undefined){ if(!isNaN(newValue)){ this.textElement().value=uty_format_number(newValue, this.decimals,this.decPoint,this.thousandsSep); }else{ this.textElement().value=""; } } return uty_parse_float(this.textElement().value, this.decPoint,this.thousandsSep); } this.text_onchange=function(){ this.value(uty_parse_float(this.textElement().value, this.decPoint,this.thousandsSep)); if (this.onchange) eval(this.onchange); } this.text_onkeydown=function(event){ /*var keyCode=uty_key_code(event); if (keyCode>=48 && keyCode<=57) return true; if (keyCode<32 || keyCode>=127) return true; var chr = String.fromCharCode(keyCode); switch(chr){ case this.decPoint:return this.textElement().value.indexOf(this.decPoint)==0; case '+': case '-': case '\t': case '\n':return true; }*/ //if (String.fromCharCode(keyCode)==this.thousandsSep return false; return true; } } utyNumberbox.prototype=new utyWidget(); utyNumberbox.prototype.toString=function(){return "utyNumberbox";}