bolist.js 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761
  1. // <script>
  2. /*
  3. =============================================================
  4. WebIntelligence(r) Report Panel
  5. Copyright(c) 2001-2003 Business Objects S.A.
  6. All rights reserved
  7. Use and support of this software is governed by the terms
  8. and conditions of the software license agreement and support
  9. policy of Business Objects S.A. and/or its subsidiaries.
  10. The Business Objects products and technology are protected
  11. by the US patent number 5,555,403 and 6,247,008
  12. File: list.js
  13. Custom BusObj List control
  14. =============================================================
  15. */
  16. _horiBOList=0
  17. _vertBOList=1
  18. _wrapBOList=2
  19. _andOrBOList=3
  20. _lstNobord="3px solid #FFFFFF"
  21. _lstBord="3px solid #C00000"
  22. _lstNullbord="0px solid #FFFFFF"
  23. _dropFeebackWidget=null
  24. _dropParentWidget=null
  25. _dropPosition=-1
  26. // ================================================================================
  27. // ================================================================================
  28. //
  29. // OBJECT newBOListContainerWidget (Constructor)
  30. //
  31. // Base class for a nested filter list (with OR or AND branches)
  32. //
  33. // ================================================================================
  34. // ================================================================================
  35. function newBOListContainerWidget(id,w,h,image,layout,changeCB,dblClickCB,moveCB,deleteCB,noText,focusCB,addQuickFilterCB,help)
  36. // CONSTRUCTOR
  37. // id [String] the id for DHTML processing
  38. // w [int] widget width, including borders
  39. // h [int] widget height, including borders
  40. // changeCB [function] callback when selecting items
  41. // dblClickCB [function] callback when double clicking on items
  42. // moveCB [function] callback a node is moved from the container buttons up & down
  43. // parameters elem,node,idx. return false if all move performed by function
  44. // noText [boolean] display buttons with no text if true
  45. // deleteCB [function] callback when delete key pressed
  46. // focusCB [function] callback when key pressed on the widget
  47. // Return [AndOrBOListWidget] the instance
  48. {
  49. var o=newWidget(id),v=layout==_vertBOList,l=null
  50. o.w=w
  51. o.h=h
  52. o.andOrList=newBOListWidget("andOrList_"+id,Math.max(0,w-18),h,image,layout,changeCB,dblClickCB,moveCB,deleteCB,focusCB,help)
  53. o.noText=noText?noText:false
  54. l=(v?_lstMoveUpLab:_lstMoveLeftLab)
  55. o.up=newButtonWidget("andOrList_up_"+id,noText?null:l,AndOrContainerWidget_upDownCb,null,null,noText?l:null,null,null,_skin+'buttonIcons.gif',16,16,0,v?64:32,null,16,v?64:32)
  56. l=(v?_lstMoveDownLab:_lstMoveRightLab)
  57. o.down=newButtonWidget("andOrList_down_"+id,noText?null:l,AndOrContainerWidget_upDownCb,null,null,noText?l:null,null,null,_skin+'buttonIcons.gif',16,16,0,v?80:48,null,16,v?80:48)
  58. o.up.lst=o
  59. o.up.isUp=true
  60. o.down.lst=o
  61. o.down.isUp=false
  62. o.down.extraStyle=o.up.extraStyle="margin-top:2px;"
  63. if(addQuickFilterCB)
  64. {
  65. l=_lstQuickFilterLab
  66. o.quickFilter=newButtonWidget("andOrList_quickFilter_"+id,noText?null:l,addQuickFilterCB,null,null,noText?l:null,null,null,_skin+'buttonIcons.gif',16,16,0,160,null,16,160)
  67. o.quickFilter.lst=o
  68. o.quickFilter.extraStyle="margin-top:2px;"
  69. }
  70. o.getList=AndOrContainerWidget_getList
  71. o.getHTML=AndOrContainerWidget_getHTML
  72. o.oldResize=o.resize
  73. o.resize=AndOrContainerWidget_resize
  74. o.moveElem=AndOrContainerWidget_moveElem
  75. o.prvInit=o.init
  76. o.init=AndOrContainerWidget_init
  77. o.chgLayout=BOListContainerWidget_chgLayout
  78. return o
  79. }
  80. //
  81. // we can change the layout of a container even after the HTML is written
  82. //
  83. function BOListContainerWidget_chgLayout(layout)
  84. {
  85. var o=this, v=(layout==_vertBOList),noTxt=o.noText
  86. if (o.layer==null) return
  87. l=(v?_lstMoveUpLab:_lstMoveLeftLab)
  88. if (!noTxt) o.up.setText(l)
  89. o.up.changeImg(0,v?64:32,16,v?64:32,null,l)
  90. l=(v?_lstMoveDownLab:_lstMoveRightLab)
  91. if (!noTxt) o.down.setText(l)
  92. o.down.changeImg(0,v?80:48,16,v?80:48,null,l)
  93. }
  94. // ================================================================================
  95. // ================================================================================
  96. //
  97. // OBJECT newBOListWidget (Constructor)
  98. //
  99. // Base class for a nested filter list (with OR or AND branches)
  100. //
  101. // ================================================================================
  102. // ================================================================================
  103. function newBOListWidget(id,w,h,image,layout,changeCB,dblClickCB,moveCB,deleteCB,focusCB,help)
  104. // CONSTRUCTOR
  105. // id [String] the id for DHTML processing
  106. // w [int] widget width, including borders
  107. // h [int] widget height, including borders
  108. // image [String] the combined image URL
  109. // layout [_horiBOList | _vertBOList | _wrapBOList] the list layout
  110. // changeCB [function] callback when selecting items
  111. // dblClickCB [function] callback when double clicking on items
  112. // moveCB [function] callback a node is moved from the container buttons up & down
  113. // deleteCB [function] callback when delete key pressed
  114. // focusCB [function] callback when key pressed on the widget
  115. // Return [BOListWidget] the instance
  116. {
  117. var o=newScrolledZoneWidget(id,2,4,w,h)
  118. o.image=image
  119. o.layout=layout
  120. o.autofit=true
  121. o.items=new Array
  122. o.counter=0
  123. o.list=o
  124. o.help=help
  125. o.helpZone=newWidget('boListCont_help_'+o.id)
  126. o.changeCB=changeCB
  127. o.dblClickCB=dblClickCB
  128. o.moveCB=moveCB
  129. o.deleteCB=deleteCB
  130. o.focusCB=focusCB
  131. o.getHTML=BOListWidget_getHTML
  132. o.add=BOListWidget_add
  133. o.genericAdd=BOListWidget_genericAdd
  134. o.setDragDrop=AndOrBOListWidget_setDragDrop
  135. o.unselect=AndOrBOListWidget_unselect
  136. o.getSelection=BOListWidget_getSelection
  137. o.getChildIndex=AndOrNodeWidget_getChildIndex
  138. o.select=BOListWidget_select
  139. o.selectByVal=BOListWidget_selectByVal
  140. o.remove=BOListWidget_remove
  141. o.getElement=BOListWidget_getElement
  142. o.getElementByValue=BOListWidget_getElementByValue
  143. o.oldAONodeInit=o.init
  144. o.init=BOListWidget_init
  145. o.removeChild=BOListWidget_removeChild
  146. o.getLastItem=AndOrNodeWidget_getLastItem
  147. o.getLength=AndOrNodeWidget_getLength
  148. o.getItem=AndOrNodeWidget_getItem
  149. o.selection=null
  150. o.htmlWritten=false
  151. o.move=BOListWidget_move
  152. o.getContentTag=BOListWidget_getContentTag
  153. o.showOrhideHelp=BOListWidget_showOrhideHelp
  154. o.oldresize=o.resize
  155. o.resize=BOListWidget_resize
  156. switch(layout)
  157. {
  158. case _vertBOList:
  159. o.lBegin='<tr><td>'
  160. o.lEnd='</td></tr>'
  161. o.iBegin=''
  162. o.iEnd=''
  163. o.createCell=false
  164. break
  165. default:
  166. o.lBegin='<tr>'
  167. o.lEnd='</tr>'
  168. o.iBegin='<td>'
  169. o.iEnd='</td>'
  170. o.createCell=true
  171. break
  172. }
  173. return o
  174. }
  175. // ================================================================================
  176. function BOListWidget_focusCB()
  177. {
  178. var o=getWidget(this)
  179. if (o.focusCB)
  180. o.focusCB()
  181. }
  182. // ================================================================================
  183. function BOListWidget_getHTML(noWriteParent)
  184. // Returns : [String] the HTML
  185. {
  186. var o=this,items=o.items,len=items.length,a=new Array(len+3),j=0
  187. o.htmlWritten=true
  188. a[j++]=(noWriteParent?'':o.beginHTML())+'<table id="boListCont_'+o.id+'" cellpadding="0" cellspacing="0" border="0"><tbody>'+o.lBegin
  189. //a[j++]=o.iBegin+'<div id="boListCont_help_'+o.id+'" class="bgzone" style="overflow:visible" ><i>'+(o.help?o.help:'')+'</i></div>'+o.iEnd
  190. for (var i in items) a[j++]=o.iBegin+items[i].getHTML()+o.iEnd
  191. a[j++]=o.lEnd+'</tbody></table>'//+(noWriteParent?'':o.endHTML())
  192. //regression: do not put the help in the table because we use insertBefore(idx)
  193. a[j++]='<div id="boListCont_help_'+o.id+'" class="bgzone" style="overflow:visible" ><i>'+(o.help?o.help:'')+'</i></div>'
  194. a[j++]=(noWriteParent?'':o.endHTML())
  195. return a.join("")
  196. }
  197. // ================================================================================
  198. function BOListWidget_init()
  199. // Init the widget layers
  200. // Return [void]
  201. {
  202. var o=this,items=o.items
  203. o.oldAONodeInit()
  204. if (!o.htmlWritten)
  205. {
  206. o.layer.innerHTML=o.getHTML(true)
  207. o.oldAONodeInit()
  208. }
  209. if (o.layer._counter !=null)
  210. o.counter=o.layer._counter
  211. else
  212. o.layer._counter=o.counter
  213. o.layer.onmousedown=BOListWidget_focusCB
  214. for (var i in items)
  215. items[i].init()
  216. var dd=o.dragDrop
  217. if (_ie&&dd)
  218. {
  219. dd.attachCallbacks(o.layer)
  220. o.layer.BODDType="list"
  221. }
  222. o.helpZone.init();
  223. o.showOrhideHelp();
  224. }
  225. function BOListWidget_showOrhideHelp()
  226. {
  227. var o=this
  228. if(o.help)
  229. {
  230. var len = o.items.length
  231. if(len == 0)
  232. o.helpZone.setDisplay(true)
  233. else
  234. o.helpZone.setDisplay(false)
  235. //resize if necessary
  236. BOListWidget_resizeHelp(o,o.getWidth())
  237. }
  238. }
  239. function BOListWidget_resizeHelp(list,w)
  240. {
  241. if(list.help && list.helpZone.isDisplayed())
  242. {
  243. list.helpZone.resize(Math.max(0,w-20),null)
  244. }
  245. }
  246. // ================================================================================
  247. function BOListWidget_getSelection()
  248. // Get the current delected node or item
  249. // Return and object with index & value, or null if no selection
  250. {
  251. var o=this,sel=o.selection
  252. if (sel)
  253. {
  254. var id=sel.id,index=-1,items=o.items;len=items.length
  255. for (var i=0;i<len;i++)
  256. {
  257. if (items[i].id==id)
  258. {
  259. index=i
  260. break
  261. }
  262. }
  263. ret=new Object;
  264. ret.index=i
  265. ret.value=sel.value
  266. return ret
  267. }
  268. else
  269. return null
  270. }
  271. function BOListWidget_getContentTag()
  272. {
  273. var o=this
  274. var parNode=o.layer.childNodes[0].childNodes[0].childNodes[0]
  275. if (!o.createCell)
  276. parNode=parNode.childNodes[0]
  277. return parNode
  278. }
  279. // ================================================================================
  280. function BOListWidget_genericAdd(nodeOrItem,idx)
  281. // PRIVATE Adds a node or an item
  282. // nodeOrItem [AndOrNodeWidget or AndOrItemWidget]
  283. // Return [AndOrNodeWidget or AndOrItemWidget]
  284. {
  285. nodeOrItem.fullW=true
  286. var o=this, list=o.list
  287. idx=arrayAdd(o,"items",nodeOrItem,idx)
  288. var items=o.items
  289. nodeOrItem.par=o
  290. nodeOrItem.list=o.list
  291. if (o.layer)
  292. {
  293. var parNode=o.getContentTag()
  294. var s=nodeOrItem.getHTML()
  295. if (o.createCell)
  296. {
  297. var theCell=_curDoc.createElement('td')
  298. theCell.innerHTML=s
  299. if (idx==(items.length-1))
  300. parNode.appendChild(theCell)
  301. else
  302. parNode.insertBefore(theCell,parNode.childNodes[idx])
  303. }
  304. else
  305. {
  306. if ((idx==-1)||(idx==(items.length-1)))
  307. append(parNode,s)
  308. else
  309. insBefore(parNode.childNodes[idx],s)
  310. }
  311. nodeOrItem.init()
  312. }
  313. o.showOrhideHelp();
  314. return nodeOrItem
  315. }
  316. // ================================================================================
  317. function BOListWidget_add(text,imgIndex,value,tooltip,idx)
  318. // Adds an item
  319. // text [String] item text
  320. // imgIndex [int] image index in the combined image
  321. // value [String] item value - must be unique in the list
  322. // tooltip [String] tooltip
  323. // Returns : [void]
  324. {
  325. var o=this,last=o.getLastItem()
  326. var ret=o.genericAdd(newAndOrNodeItem(o.id+'_item-'+(o.counter++),text,imgIndex,value,tooltip),idx)
  327. var last2=o.getLastItem()
  328. if (o.layer)
  329. {
  330. if (last&&(last2.id!=last.id))
  331. {
  332. if (o.layout==_vertBOList)
  333. last.css.borderBottom=_lstNullbord
  334. else
  335. last.css.borderRight=_lstNullbord
  336. }
  337. o.layer._counter=o.counter
  338. }
  339. return ret
  340. }
  341. // ================================================================================
  342. function BOListWidget_select(index)
  343. // Selects and item from its index
  344. // index [int] : the index
  345. // Returns : [void]
  346. {
  347. var items=this.items,len=items.length
  348. index=index==-1?len-1:index
  349. if ((index>=0)&&(index<len))
  350. items[index].select(true)
  351. }
  352. // ================================================================================
  353. function BOListWidget_getElementByValue(value)
  354. // Get an item from its value
  355. // value [String] : the value
  356. // Return [AndOrNodeItem] the item (null if not found)
  357. {
  358. var o=this,items=o.items,len=items.length
  359. for (var i=0;i<len;i++)
  360. {
  361. if (items[i].value==value)
  362. return items[i]
  363. }
  364. return null
  365. }
  366. // ================================================================================
  367. function BOListWidget_getElement(idx)
  368. // Get an item from its index
  369. // idx [int] : the index
  370. // Return [AndOrNodeItem] the item (null if not found)
  371. {
  372. var it=this.items,len=it.length
  373. return ((idx>=0)&&(idx<len))?it[idx]:null
  374. }
  375. // ================================================================================
  376. function BOListWidget_remove(idx)
  377. // Remove an element from its index
  378. // idx [int] element index. if null, remove ALL elements
  379. // Returns : [void]
  380. {
  381. var o=this
  382. if (idx==null)
  383. {
  384. while(o.items.length>0)
  385. o.remove(0)
  386. }
  387. else
  388. {
  389. var it=o.getElement(idx)
  390. if (it)
  391. it.remove()
  392. }
  393. }
  394. // ================================================================================
  395. function BOListWidget_selectByVal(value)
  396. // Selects an item from its value
  397. // value [String] : the value
  398. // Return [void]
  399. {
  400. var item=this.getElementByValue(value)
  401. if (item)
  402. item.select(true)
  403. }
  404. // ================================================================================
  405. function BOListWidget_removeChild(nodeOrItem)
  406. // Removes a child
  407. // nodeOrItem [AndOrNodeItem] : the item to remove
  408. // Return [void]
  409. {
  410. var o=this,items=o.items,len=items.length,list=o.list
  411. for (var i=0;i<len;i++)
  412. {
  413. var item=items[i]
  414. if (item.id==nodeOrItem.id)
  415. {
  416. var l=item.layer
  417. if (item.selected)
  418. item.select(false)
  419. if (l)
  420. {
  421. var p=l.parentNode
  422. if (o.createCell)
  423. {
  424. l=p
  425. p=p.parentNode
  426. }
  427. p.removeChild(l)
  428. }
  429. arrayRemove(o,"items",i)
  430. items=o.items
  431. var newSel=Math.min(i,items.length-1)
  432. if (newSel>=0)
  433. {
  434. items[newSel].select(true)
  435. var last=o.getLastItem()
  436. if (o.layer)
  437. {
  438. if (last&&!last.isNode())
  439. {
  440. var ly=o.list.layout
  441. if (ly==_vertBOList)
  442. {
  443. last.css.borderBottom=_lstNobord
  444. }
  445. else
  446. last.css.borderRight=_lstNobord
  447. }
  448. }
  449. }
  450. else o.select(true)
  451. break
  452. }
  453. }
  454. o.showOrhideHelp();
  455. }
  456. // ================================================================================
  457. function BOListWidget_move(e,node,destIdx)
  458. {
  459. var o=this
  460. e.select(false)
  461. var n=o.add(e.text,e.imgIndex,e.value,e.tooltip,destIdx)
  462. e.remove()
  463. n.select(true)
  464. }
  465. // ================================================================================
  466. function BOListWidget_resize(w,h)
  467. {
  468. var o=this
  469. BOListWidget_resizeHelp(o,w)
  470. o.oldresize(w,h)
  471. }
  472. // ================================================================================
  473. // ================================================================================
  474. //
  475. // OBJECT newAndOrContainerWidget (Constructor)
  476. //
  477. // Base class for a nested filter list (with OR or AND branches)
  478. //
  479. // ================================================================================
  480. // ================================================================================
  481. function newAndOrContainerWidget(id,w,h,image,changeCB,dblClickCB,andOrCB,moveCB,newNodeCB,deleteCB,noText,help)
  482. // CONSTRUCTOR
  483. // id [String] the id for DHTML processing
  484. // w [int] widget width, including borders
  485. // h [int] widget height, including borders
  486. // changeCB [function] callback when selecting items
  487. // dblClickCB [function] callback when double clicking on items
  488. // andOrCB [function] callback a node type is changed
  489. // moveCB [function] callback a node is moved from the container buttons up & down
  490. // newNodeCB [function] callback a new node is created from the container button
  491. // deleteCB [function] callback when delete key pressed
  492. // noText [boolean] display buttons with no text if true
  493. // Return [AndOrBOListWidget] the instance
  494. {
  495. var o=newWidget(id),l
  496. o.w=w
  497. o.h=h
  498. o.andOrList=newAndOrBOListWidget("andOrList_"+id,10,h,image,changeCB,dblClickCB,andOrCB,moveCB,newNodeCB,deleteCB,help)
  499. l=_lstMoveUpLab
  500. o.up=newButtonWidget("andOrList_up_"+id,noText?null:l,AndOrContainerWidget_upDownCb,null,null,noText?l:null,null,null,_skin+'buttonIcons.gif',16,16,0,64,null,16,64)
  501. l=_lstMoveDownLab
  502. o.down=newButtonWidget("andOrList_down_"+id,noText?null:l,AndOrContainerWidget_upDownCb,null,null,noText?l:null,null,null,_skin+'buttonIcons.gif',16,16,0,80,null,16,80)
  503. l=_lstNewNodeLab
  504. o.newNode=newButtonWidget("andOrList_newNode_"+id,noText?null:l,AndOrContainerWidget_nodeCb,null,null,noText?l:null,null,null,_skin+'buttonIcons.gif',16,16,0,96,null,16,96)
  505. o.down.extraStyle="margin-top:2px;"
  506. o.newNode.extraStyle="margin-top:2px;"
  507. o.up.lst=o
  508. o.up.isUp=true
  509. o.down.lst=o
  510. o.down.isUp=false
  511. o.newNode.lst=o
  512. o.getList=AndOrContainerWidget_getList
  513. o.getHTML=AndOrContainerWidget_getHTML
  514. o.oldResize=o.resize
  515. o.resize=AndOrContainerWidget_resize
  516. o.moveElem=AndOrContainerWidget_moveElem
  517. o.canBeMoved=AndOrContainerWidget_canBeMoved
  518. o.prvInit=o.init
  519. o.init=AndOrContainerWidget_init
  520. return o
  521. }
  522. // ================================================================================
  523. function AndOrContainerWidget_init()
  524. {
  525. var o=this
  526. o.rightZone=getLayer('rightZone_'+o.id)
  527. o.prvInit()
  528. o.up.init()
  529. o.down.init()
  530. if(o.quickFilter)
  531. o.quickFilter.init()
  532. if (o.newNode)
  533. o.newNode.init()
  534. o.andOrList.init()
  535. o.resize(o.w,o.h)
  536. }
  537. // ================================================================================
  538. function AndOrContainerWidget_getHTML()
  539. // Returns the widget HTML
  540. {
  541. var o=this,list=o.andOrList
  542. return '<table id="'+o.id+'" style="overflow:hidden;width:'+o.w+'px;height='+o.h+'px" cellpadding="0" cellspacing="0" border="0"><tbody><tr>'+
  543. '<td style="padding-right:5px" width="100%">'+list.getHTML()+'</td>'+
  544. '<td id="rightZone_'+o.id+'" align="center" valign="top">'+o.up.getHTML()+o.down.getHTML()+(o.newNode?o.newNode.getHTML():'')+(o.quickFilter?o.quickFilter.getHTML():'')+'</td>'+
  545. '</tr></tbody></table>'
  546. }
  547. // ================================================================================
  548. function AndOrContainerWidget_getList()
  549. // get the included AndOrBOListWidget
  550. // return [AndOrBOListWidget]
  551. {
  552. return this.andOrList
  553. }
  554. // ================================================================================
  555. function AndOrContainerWidget_resize(w,h)
  556. // resize the container widget
  557. // w [int] : width
  558. // h [int] : height
  559. // return [void]
  560. {
  561. var o=this
  562. o.oldResize(w,h)
  563. var butnW=o.rightZone.offsetWidth
  564. o.andOrList.resize(w!=null?Math.max(0,w-butnW-5):null,h)
  565. o.up.resize(butnW)
  566. o.down.resize(butnW)
  567. if(o.quickFilter)
  568. o.quickFilter.resize(butnW)
  569. if (o.newNode)
  570. o.newNode.resize(butnW)
  571. var d=o.layer.display!="none"
  572. if (d&_moz&&!_saf)
  573. o.setDisplay(false)
  574. o.oldResize(w,h)
  575. if (d&_moz&&!_saf)
  576. o.setDisplay(true)
  577. }
  578. // ================================================================================
  579. function AndOrContainerWidget_upDownCb()
  580. // DHTML Callback. Called when up or down arrow is pressed
  581. // elem [DHTML Element] : the element
  582. // up [boolean] : if true move up; else move down
  583. // return [void]
  584. {
  585. var o=this.lst,list=o.andOrList,sel=list.selection
  586. if (sel)
  587. o.moveElem(sel,this.isUp)
  588. }
  589. // ================================================================================
  590. function AndOrContainerWidget_nodeCb()
  591. // DHTML Callback. Called when node button is pressed
  592. // elem [DHTML Element] : the element
  593. // return [void]
  594. {
  595. var o=this.lst.andOrList,sel=o.getSelection()
  596. if (sel)
  597. {
  598. var n=null
  599. if (sel.isNode())
  600. n=sel.addNode(!sel.isAnd,"")
  601. else
  602. n=sel.par.addNode(!sel.par.isAnd,"",sel.getIndexInParent()+1)
  603. n.select(true)
  604. if (o.newNodeCB)
  605. o.newNodeCB()
  606. }
  607. }
  608. // ================================================================================
  609. function AndOrContainerWidget_canBeMoved(elem,up)
  610. {
  611. var o=this,node=elem.par
  612. if (node)
  613. {
  614. var idx=node.getChildIndex(elem),itemIdx=idx
  615. if (idx!=-1)
  616. {
  617. if (up&&(idx>0))
  618. return true;
  619. else if (!up&&(idx<(node.items.length-1)))
  620. return true;
  621. else
  622. {
  623. idx+=(up?-1:2)
  624. if ((idx<0)||(idx>node.items.length))
  625. {
  626. if (node.par)
  627. return true;
  628. }
  629. }
  630. }
  631. }
  632. return false;
  633. }
  634. // ================================================================================
  635. function AndOrContainerWidget_moveElem(elem,up)
  636. // Move down or up an item, in depth before
  637. // elem [AndOrNodeWidget] or [AndOrItemWidget] : the item to move
  638. // up [boolean] : if true move up; else move down
  639. {
  640. var o=this,node=elem.par
  641. if (node)
  642. {
  643. var idx=node.getChildIndex(elem),itemIdx=idx
  644. if (idx!=-1)
  645. {
  646. if (up&&(idx>0)&&(node.items[idx-1].isNode()))
  647. {
  648. node=node.items[idx-1]
  649. idx=node.items.length
  650. }
  651. else if (!up&&(idx<(node.items.length-1))&&(node.items[idx+1].isNode()))
  652. {
  653. node=node.items[idx+1]
  654. idx=0
  655. }
  656. else
  657. {
  658. idx+=(up?-1:2)
  659. if ((idx<0)||(idx>node.items.length))
  660. {
  661. var oldNode=node
  662. node=node.par
  663. if (node)
  664. idx=node.getChildIndex(oldNode)+(up?0:1)
  665. }
  666. }
  667. if (node)
  668. {
  669. var list=o.getList(),doMove=true
  670. if (list.moveCB)
  671. doMove=list.moveCB(elem,node,idx)
  672. if ((doMove==null)||doMove)
  673. list.move(elem,node,idx)
  674. }
  675. }
  676. }
  677. }
  678. // ================================================================================
  679. // ================================================================================
  680. //
  681. // OBJECT newAndOrBOListWidget (Constructor)
  682. //
  683. // Base class for a nested filter list (with OR or AND branches)
  684. //
  685. // ================================================================================
  686. // ================================================================================
  687. function newAndOrBOListWidget(id,w,h,image,changeCB,dblClickCB,andOrCB,moveCB,newNodeCB,deleteCB,help)
  688. // CONSTRUCTOR
  689. // id [String] the id for DHTML processing
  690. // w [int] widget width, including borders
  691. // h [int] widget height, including borders
  692. // changeCB [function] callback when selecting items
  693. // dblClickCB [function] callback when double clicking on items
  694. // andOrCB [function] callback a node type is changed
  695. // moveCB [function] callback a node is moved from the container buttons up & down
  696. // newNodeCB [function] callback a new node is created from the container button
  697. // deleteCB [function] callback when delete key pressed
  698. // Return [AndOrBOListWidget] the instance
  699. {
  700. var o=newScrolledZoneWidget(id,2,4,w,h)
  701. o.image=image
  702. o.changeCB=changeCB
  703. o.dblClickCB=dblClickCB
  704. o.andOrCB=andOrCB
  705. o.moveCB=moveCB
  706. o.newNodeCB=newNodeCB
  707. o.deleteCB=deleteCB
  708. o.layout=_andOrBOList
  709. o.root=newAndOrNodeWidget(id+"_rootOperator",true,"")
  710. //o.root.isDisplayed=true
  711. o.root.list=o
  712. o.selection=o.root
  713. o.root.selected=true
  714. o.help=help
  715. o.helpZone=newWidget("andOrCont_help_"+id)
  716. o.getHTML=AndOrBOListWidget_getHTML
  717. o.getRoot=AndOrBOListWidget_getRoot
  718. o.setDragDrop=AndOrBOListWidget_setDragDrop
  719. o.unselect=AndOrBOListWidget_unselect
  720. o.getSelection=AndOrBOListWidget_getSelection
  721. o.select=AndOrBOListWidget_select
  722. o.getElementByValue=AndOrBOListWidget_getElementByValue
  723. o.showOrhideRoot=AndOrBOListWidget_showOrhideRoot
  724. o.oldAOListInit=o.init
  725. o.init=AndOrBOListWidget_init
  726. o.move=AndOrBOListWidget_move
  727. o.htmlWritten=false
  728. o.oldresize=o.resize
  729. o.resize=AndOrBOListWidget_resize
  730. return o
  731. }
  732. // ================================================================================
  733. function AndOrBOListWidget_move(e,destNode,destIdx)
  734. // move an item
  735. // e [AndOrNodeWidget] or [AndOrItemWidget] : the item to move
  736. // destNode [AndOrNodeWidget] the destination node
  737. // destIdx [int] the index into the destination node
  738. // Return [void]
  739. {
  740. if (destNode)
  741. {
  742. var n=null
  743. e.select(false)
  744. if (e.isNode())
  745. n=destNode.addCopyNode(e,destIdx)
  746. else
  747. {
  748. if(e.isAdvFilter)
  749. n=destNode.addAdvFilterItem(e.text,e.imgIndex,e.value,e.tooltip,destIdx)
  750. else
  751. n=destNode.addItem(e.text,e.imgIndex,e.value,e.tooltip,destIdx)
  752. }
  753. e.remove()
  754. n.select(true)
  755. }
  756. }
  757. // ================================================================================
  758. function AndOrBOListWidget_getSelection()
  759. // Get the current selected node or item
  760. // Return [AndOrNodeWidget] or [AndOrItemWidget] or null if no selection
  761. {
  762. return this.selection
  763. }
  764. // ================================================================================
  765. function AndOrBOListWidget_select(itemOrNode)
  766. // Select an item or a node
  767. // itemOrNode [AndOrNodeWidget] or [AndOrItemWidget]
  768. {
  769. itemOrNode.select(true)
  770. }
  771. // ================================================================================
  772. function AndOrBOListWidget_getElementByValue(value)
  773. // Get an element from its value
  774. // Return [AndOrNodeWidget or [AndOrItemWidget] or null if not found
  775. {
  776. return this.root.getElementByValue(value)
  777. }
  778. // ================================================================================
  779. function AndOrBOListWidget_init()
  780. // Init the widget
  781. {
  782. var o=this
  783. o.oldAOListInit()
  784. if (!o.htmlWritten)
  785. {
  786. o.layer.innerHTML=o.getHTML(true)
  787. o.oldAOListInit()
  788. }
  789. o.root.init()
  790. o.helpZone.init();
  791. o.showOrhideRoot()
  792. var dd=o.dragDrop
  793. if (_ie&&dd)
  794. {
  795. dd.attachCallbacks(o.layer)
  796. o.layer.BODDType="andorlist"
  797. }
  798. }
  799. // ================================================================================
  800. function AndOrBOListWidget_unselect()
  801. // Unselect
  802. {
  803. var o=this
  804. if (o.selection)
  805. o.selection.select(false)
  806. }
  807. // ================================================================================
  808. function AndOrBOListWidget_getHTML(noWriteParent)
  809. // Returns : [String] the HTML
  810. {
  811. var o=this
  812. o.htmlWritten=true
  813. var a=new Array(3), j=0, len = o.root.items.length
  814. a[j++]=(noWriteParent?'':o.beginHTML())
  815. a[j++]='<div id="andOrCont_'+o.id+'">'+'<div id="andOrCont_help_'+o.id+'" class="bgzone" style="overflow:visible"><i>'+(o.help?o.help:'')+'</i></div>'+o.root.getHTML()+'</div>'
  816. a[j++]=(noWriteParent?'':o.endHTML())
  817. return a.join("")
  818. //return (noWriteParent?'':o.beginHTML())+'<div id="andOrCont_'+o.id+'">'+o.root.getHTML()+'</div>'+(noWriteParent?'':o.endHTML())
  819. }
  820. // ================================================================================
  821. function AndOrBOListWidget_getRoot()
  822. // Return [AndOrBOOperatorWidget] the root widget
  823. {
  824. return this.root
  825. }
  826. // ================================================================================
  827. function AndOrBOListWidget_showOrhideHelp(list)
  828. {
  829. if(list.help)
  830. {
  831. var len = list.root.items.length
  832. if(len == 0)
  833. list.helpZone.setDisplay(true)
  834. else
  835. list.helpZone.setDisplay(false)
  836. //resize
  837. AndOrBOListWidget_resizeHelp(list,list.getWidth())
  838. }
  839. }
  840. function AndOrBOListWidget_resizeHelp(list,w)
  841. {
  842. if(list.help && list.helpZone.isDisplayed())
  843. {
  844. list.helpZone.resize(Math.max(0,w-20),null)
  845. }
  846. }
  847. // ================================================================================
  848. function AndOrBOListWidget_showOrhideRoot()
  849. // hide/show the root widget
  850. {
  851. var o=this, root= o.root, len = root.items.length, show = true
  852. if (o.layer)
  853. {
  854. if((len == 0) || ((len==1) && (!root.items[0].isNode()) )) show=false
  855. root.operLayer.parentNode.style.display=show?"":"none"
  856. //show or hide the help zone
  857. AndOrBOListWidget_showOrhideHelp(o)
  858. }
  859. }
  860. // ================================================================================
  861. function AndOrBOListWidget_resize(w,h)
  862. {
  863. var o=this
  864. AndOrBOListWidget_resizeHelp(o,w)
  865. o.oldresize(w,h);
  866. }
  867. // ================================================================================
  868. function AndOrBOListWidget_setDragDrop(dragCB,acceptDropCB,dropCB)
  869. // Add drag & drop handlers to the widget
  870. // dragCB (source) : triggered when beginning D&D
  871. // acceptDropCB (source, target, ctrl, shift) : return boolean if D&D is accepted
  872. // dropCB (source, target, ctrl, shift) : triggered when ending D&D
  873. //
  874. // when acceptDropCB & dropCB is called, target has some additional fields
  875. //
  876. // * target.dropWidget : the container (list or node) where inserting
  877. // * target.dropIndex : the index to insert (-1 is at the end)
  878. {
  879. var o=this
  880. o.dragCB=dragCB
  881. o.acceptDropCB=acceptDropCB
  882. o.dropCB=dropCB
  883. o.dragDrop=newDragDropData(o,EBLWidget_dragStartCB,EBLWidget_dragCB,EBLWidget_dragEndCB,EBLWidget_acceptDropCB,EBLWidget_leaveDropCB,EBLWidget_dropCB)
  884. }
  885. // ================================================================================
  886. function EBLWidget_getDropInfo(layer)
  887. // Get the widget that must display drop feedback
  888. // Fill the global _dropFeebackWidget
  889. // and _dropPosition
  890. {
  891. var o=getWidget(layer)
  892. switch (layer.BODDType)
  893. {
  894. case "root":
  895. case "nodebg":
  896. case "list":
  897. case "andorlist":
  898. _dropParentWidget=o.items?o:o.root
  899. _dropFeebackWidget=_dropParentWidget.getLastItem()
  900. if ((layer.BODDType=="nodebg")&&(_dropFeebackWidget==null))
  901. _dropFeebackWidget=_dropParentWidget
  902. _dropPosition=-1
  903. break
  904. case "node":
  905. case "item":
  906. _dropParentWidget=o.par
  907. _dropFeebackWidget=o
  908. _dropPosition=o.getIndexInParent()
  909. break
  910. }
  911. return _dropFeebackWidget
  912. }
  913. // ================================================================================
  914. function EBLWidget_dragStartCB(source,layer)
  915. // Triggered when starting drag
  916. {
  917. var o=getWidget(layer)
  918. _curWin.event.cancelBubble=true
  919. if (o)
  920. {
  921. var list=o.list
  922. source.dragCB(source)
  923. newTooltipWidget().show(true,o.text?o.text:(o.isAnd?_lstAndLabel:_lstOrLabel),o.text?list.image:null,16,16,0,o.imgIndex*16)
  924. }
  925. }
  926. // ================================================================================
  927. function EBLWidget_dragCB(source,layer,shift)
  928. // Triggered while dragging
  929. {
  930. newTooltipWidget().setPos(shift);
  931. }
  932. // ================================================================================
  933. function EBLWidget_dragEndCB(source)
  934. // Triggered when ending drag & drop
  935. {
  936. newTooltipWidget().show(false)
  937. }
  938. // ================================================================================
  939. function EBLWidget_acceptDropCB(source,target,ctrl,shift,layer,enter)
  940. {
  941. var o=EBLWidget_getDropInfo(layer)
  942. target.dropWidget=_dropParentWidget
  943. target.dropIndex=_dropPosition
  944. var accepted=target.acceptDropCB(source,target,ctrl,shift)
  945. if (accepted&&o)
  946. {
  947. if (source&&(source.id==target.id))
  948. {
  949. var s=source.selection
  950. if ((s&&s.isNode()&&(o.isChildOf(s)))||
  951. (shift&&s&&o.isNode()&&(s.isChildOf(o)))||
  952. (!ctrl&&s&&(s.id==o.id)))
  953. {
  954. o.setInsertFeedback(false,shift)
  955. return false
  956. }
  957. if (!shift&&!ctrl&&o.par&&(o.par==s.par))
  958. {
  959. var srcIdx=s.getIndexInParent()
  960. if (srcIdx==(_dropPosition-1))
  961. {
  962. o.setInsertFeedback(false,shift)
  963. return false
  964. }
  965. }
  966. }
  967. o.setInsertFeedback(true,shift)
  968. }
  969. else if(o)
  970. o.setInsertFeedback(false,shift)
  971. return accepted;
  972. }
  973. // ================================================================================
  974. function EBLWidget_leaveDropCB(source,target,ctrl,shift,layer)
  975. {
  976. var o=EBLWidget_getDropInfo(layer)
  977. if (o)
  978. o.setInsertFeedback(false)
  979. }
  980. // ================================================================================
  981. function EBLWidget_dropCB(source,target,ctrl,shift,layer)
  982. // Drop function
  983. {
  984. newTooltipWidget().show(false);
  985. var o=EBLWidget_getDropInfo(layer)
  986. if (o)
  987. o.setInsertFeedback(false)
  988. EBLWidget_leaveDropCB(source,target,ctrl,shift,layer)
  989. target.dropWidget=_dropParentWidget
  990. target.dropIndex=_dropPosition
  991. target.dropCB(source,target,ctrl,shift)
  992. }
  993. // ================================================================================
  994. // ================================================================================
  995. //
  996. // OBJECT newAndOrNodeWidget (Constructor)
  997. //
  998. // Base class for a filter list OR or AND node
  999. //
  1000. // ================================================================================
  1001. // ================================================================================
  1002. function newAndOrNodeWidget(id,isAnd,value)
  1003. // CONSTRUCTOR
  1004. // id [String] the id for DHTML processing
  1005. // isAnd [boolean] if true, is a AND node; else is a OR node
  1006. // Return [AndOrNodeWidget] the instance
  1007. {
  1008. var o=newWidget(id)
  1009. o.isAnd=isAnd
  1010. o.items=new Array
  1011. o.value=value
  1012. o.par=null
  1013. o.list=null
  1014. o.counter=0
  1015. o.operLayer=null
  1016. o.getHTML=AndOrNodeWidget_getHTML
  1017. o.getInnerHTML=AndOrNodeWidget_getInnerHTML
  1018. o.getDynamicHTML=AndOrNodeWidget_getDynamicHTML
  1019. o.addNode=AndOrNodeWidget_addNode
  1020. o.addCopyNode=AndOrNodeWidget_addCopyNode
  1021. o.addItem=AndOrNodeWidget_addItem
  1022. o.addAdvFilterItem=AndOrNodeWidget_AdvFilterItem
  1023. o.select=AndOrNodeWidget_select
  1024. o.removeChild=AndOrNodeWidget_removeChild
  1025. o.remove=AndOrNodeWidget_remove
  1026. o.isNode=AndOrNodeWidget_isNode
  1027. o.getElementByValue=AndOrNodeWidget_getElementByValue
  1028. o.setIsAnd=AndOrNodeWidget_setIsAnd
  1029. o.setInsertFeedback=AndOrNodeItem_setInsertFeedback
  1030. o.getLastItem=AndOrNodeWidget_getLastItem
  1031. o.getLength=AndOrNodeWidget_getLength
  1032. o.getParentNode=AndOrNodeWidget_getParentNode
  1033. o.getChildIndex=AndOrNodeWidget_getChildIndex
  1034. o.getIndexInParent=AndOrNodeWidget_getIndexInParent
  1035. o.getItem=AndOrNodeWidget_getItem
  1036. o.genericAdd=AndOrNodeWidget_genericAdd
  1037. o.oldAONodeInit=o.init
  1038. o.init=AndOrNodeWidget_init
  1039. o.isChildOf=AndOrNodeItem_isChildOf
  1040. o.andLabel=_lstAndLabel
  1041. o.orLabel=_lstOrLabel
  1042. return o
  1043. }
  1044. // ================================================================================
  1045. function AndOrNodeWidget_getParentNode()
  1046. // Return [AndOrNodeWidget] the parent node (null if root)
  1047. {
  1048. return this.par
  1049. }
  1050. // ================================================================================
  1051. function AndOrNodeWidget_getLastItem()
  1052. // Return [AndOrNodeWidget] the last node (null if not)
  1053. {
  1054. var it=this.items,len=it.length
  1055. return len>0?it[len-1]:null
  1056. }
  1057. // ================================================================================
  1058. function AndOrNodeWidget_getChildIndex(child)
  1059. // Return [int] the child index (position between 0 and length-1).
  1060. // if child is not in the node, return -1
  1061. {
  1062. var items=this.items,len=items.length
  1063. for (var i=0;i<len;i++)
  1064. if (items[i].id==child.id)
  1065. return i
  1066. return -1
  1067. }
  1068. // ================================================================================
  1069. function AndOrNodeWidget_getIndexInParent()
  1070. // return [int] index in parent node
  1071. {
  1072. var o=this,par=o.par
  1073. return par?par.getChildIndex(o):-1
  1074. }
  1075. // ================================================================================
  1076. function AndOrNodeWidget_getElementByValue(value)
  1077. {
  1078. var o=this,items=o.items
  1079. if (o.value==value)
  1080. return o
  1081. for (var i in items)
  1082. {
  1083. var item=items[i]
  1084. if (item.isNode())
  1085. {
  1086. var elem=item.getElementByValue(value)
  1087. if (elem!=null)
  1088. return elem
  1089. }
  1090. else if (item.value==value)
  1091. return item
  1092. }
  1093. return null
  1094. }
  1095. // ================================================================================
  1096. function AndOrNodeWidget_isNode()
  1097. // Test if it's a node
  1098. {
  1099. return true
  1100. }
  1101. // ================================================================================
  1102. function AndOrNodeWidget_getItem(idx)
  1103. // Test if it's a node
  1104. {
  1105. var it=this.items,len=it.length
  1106. if (idx==-1) idx=len-1
  1107. return ((idx>=0)&&(idx<len))?it[idx]:null
  1108. }
  1109. // ================================================================================
  1110. function AndOrNodeWidget_getLength()
  1111. {
  1112. return this.items.length
  1113. }
  1114. // ================================================================================
  1115. function AndOrNodeWidget_getHTML()
  1116. // Get the widget HTML
  1117. // Returns : [String] the HTML
  1118. {
  1119. var o=this
  1120. return '<table id="'+o.id+'" style="border-top:'+_lstNobord+';" cellpadding="0" cellspacing="0" border="0">' +
  1121. o.getInnerHTML() +
  1122. '</table>'
  1123. }
  1124. // ================================================================================
  1125. function AndOrNodeWidget_getInnerHTML()
  1126. // Get the widget HTML
  1127. // Returns : [String] the HTML
  1128. {
  1129. var o=this,items=o.items,len=items.length,a=new Array(len+2),j=0
  1130. var lab=o.isAnd?o.andLabel:o.orLabel
  1131. //lab=elasticZone(lab,_skin+'bolist.gif',3,26,o.selected?234:156,'oper_'+o.id,'treeNormal',null,0,0,'width="30" align="center"','operTxt_'+o.id)+getSpace(40,1)
  1132. lab=elasticZone(lab,_skin+'bolist.gif',3,28,o.selected?252:168,'oper_'+o.id,'treeNormal',null,0,0,'width="30" align="center"','operTxt_'+o.id)+getSpace(40,1)
  1133. a[j++]='<tbody><tr>'+
  1134. '<td class="treeNormal" style="border-right:1px solid #A0A0A0;" align="center" valign="middle">'+lab+'</td><td style="width:70px;padding-bottom:2px;padding-left:4px">'
  1135. for (var i in items) a[j++]=items[i].getHTML()
  1136. a[j++]='</td></tr></tbody>'
  1137. return a.join("")
  1138. }
  1139. // ================================================================================
  1140. function AndOrNodeWidget_getDynamicHTML()
  1141. // Get the widget HTML
  1142. // Returns : [String] the HTML
  1143. {
  1144. var o=this
  1145. var theTable=_curDoc.createElement('table')
  1146. theTable.id = o.id
  1147. theTable.style.borderTop = _lstNobord
  1148. theTable.cellPadding = 0
  1149. theTable.cellSpacing = 0
  1150. theTable.border = 0
  1151. theTable.innerHTML= o.getInnerHTML()
  1152. return theTable
  1153. }
  1154. // ================================================================================
  1155. function AndOrNodeWidget_init()
  1156. // Init the widget layers
  1157. // Return [void]
  1158. {
  1159. var o=this,items=o.items
  1160. o.oldAONodeInit()
  1161. if (o.layer._counter !=null)
  1162. o.counter=o.layer._counter
  1163. else
  1164. o.layer._counter=o.counter
  1165. var l=o.operLayer=getLayer('oper_'+o.id)
  1166. o.operLayerTxt=getLayer('operTxt_'+o.id)
  1167. l.onmousedown=AndOrNodeWidget_clickCB
  1168. l.onmouseup=AndOrNodeWidget_mouseUp
  1169. if (_ie)
  1170. l.onmousemove=AndOrNodeWidget_triggerDD
  1171. l.onkeydown=AndOrNodeWidget_keyDownCB
  1172. addDblClickCB(l,AndOrNodeWidget_dblClickCB)
  1173. if (o.isDisplayed!=null)
  1174. o.setDisplay(o.isDisplayed)
  1175. var dd=o.list.dragDrop
  1176. if (_ie&&dd)
  1177. {
  1178. var rl=o.layer.childNodes[0].childNodes[0].childNodes[1]
  1179. dd.attachCallbacks(rl)
  1180. dd.attachCallbacks(o.layer)
  1181. o.layer.BODDType=o.par?"node":"root"
  1182. rl.BODDType="nodebg"
  1183. }
  1184. for (var i in items)
  1185. items[i].init()
  1186. }
  1187. // ================================================================================
  1188. function AndOrNodeWidget_clickCB(e)
  1189. {
  1190. var o=getWidget(this),list=o.list
  1191. o.clicked=true
  1192. o.initialX=eventGetX(e)
  1193. o.initialY=eventGetY(e)
  1194. o.select(true)
  1195. if (list.changeCB)
  1196. list.changeCB()
  1197. return false
  1198. }
  1199. // ================================================================================
  1200. function AndOrNodeWidget_mouseUp()
  1201. {
  1202. var o=getWidget(this)
  1203. o.clicked=false
  1204. }
  1205. // ================================================================================
  1206. function AndOrNodeWidget_triggerDD(e)
  1207. {
  1208. var o=getWidget(this)
  1209. if ((o.clicked)&&(_curWin.event.button==_leftBtn))
  1210. {
  1211. if (o.initialX!=null)
  1212. {
  1213. var x=eventGetX(e),y=eventGetY(e),threshold=3
  1214. if ((x<(o.initialX-threshold))||(x>(o.initialX+threshold))||(y<(o.initialY-threshold))||(y>(o.initialY+threshold)))
  1215. {
  1216. this.dragDrop()
  1217. o.clicked=false
  1218. }
  1219. }
  1220. }
  1221. }
  1222. // ================================================================================
  1223. function AndOrNodeWidget_keyDownCB(e)
  1224. {
  1225. var o=getWidget(this),list=o.list
  1226. var key=eventGetKey(e);
  1227. if (key==46)
  1228. {
  1229. if (list.deleteCB)
  1230. list.deleteCB()
  1231. }
  1232. if(key==13)
  1233. {
  1234. eventCancelBubble(e);
  1235. if(o.selected)//already selected
  1236. {
  1237. // Change operator
  1238. o.setIsAnd(!o.isAnd)
  1239. if (o.list.andOrCB)
  1240. o.list.andOrCB()
  1241. }
  1242. else
  1243. {
  1244. o.select(true)
  1245. }
  1246. if (list.changeCB)
  1247. list.changeCB()
  1248. }
  1249. }
  1250. // ================================================================================
  1251. function AndOrNodeWidget_dblClickCB()
  1252. {
  1253. var o=getWidget(this),list=o.list
  1254. // Change operator
  1255. o.setIsAnd(!o.isAnd)
  1256. if (o.list.andOrCB)
  1257. o.list.andOrCB()
  1258. return false
  1259. }
  1260. // ================================================================================
  1261. function AndOrNodeWidget_setIsAnd(isAndNode)
  1262. {
  1263. var o=this
  1264. // Change operator
  1265. o.isAnd=isAndNode
  1266. o.operLayerTxt.innerHTML=convStr(o.isAnd?o.andLabel:o.orLabel)
  1267. }
  1268. // ================================================================================
  1269. function AndOrNodeWidget_select(sel)
  1270. // Select the current item
  1271. // sel [boolean]
  1272. // Return [void]
  1273. {
  1274. var o=this,list=o.list
  1275. if (sel)
  1276. list.unselect()
  1277. list.selection=sel?o:null
  1278. o.selected=sel
  1279. if (o.layer)
  1280. {
  1281. var dy=6+(sel?3:0)
  1282. elasticZoneSetImg(o.operLayer,28,dy,dy+1,dy+2)
  1283. if(sel&&o.operLayer.focus&&(!isHidden(o.operLayer)))
  1284. o.operLayer.focus()
  1285. }
  1286. }
  1287. // ================================================================================
  1288. function AndOrNodeWidget_genericAdd(nodeOrItem,idx)
  1289. // PRIVATE Adds a node or an item
  1290. // nodeOrItem [AndOrNodeWidget or AndOrItemWidget]
  1291. // Return [AndOrNodeWidget or AndOrItemWidget]
  1292. {
  1293. var o=this, list=o.list
  1294. idx=arrayAdd(o,"items",nodeOrItem,idx)
  1295. var items=o.items
  1296. nodeOrItem.par=o
  1297. nodeOrItem.list=o.list
  1298. if (o.layer)
  1299. {
  1300. var parNode=o.layer.childNodes[0].childNodes[0].childNodes[1]
  1301. if ((idx==-1)||(idx==(items.length-1)))
  1302. append(parNode,nodeOrItem.getHTML())
  1303. else
  1304. {
  1305. if (_saf)
  1306. parNode.insertBefore(nodeOrItem.getDynamicHTML(),parNode.childNodes[idx])
  1307. else
  1308. insBefore(parNode.childNodes[idx],nodeOrItem.getHTML())
  1309. }
  1310. nodeOrItem.init()
  1311. }
  1312. list.showOrhideRoot()
  1313. return nodeOrItem
  1314. }
  1315. // ================================================================================
  1316. function AndOrNodeWidget_addNode(isAnd,value,idx)
  1317. // Adds a node
  1318. // Returns : [AndOrNodeWidget] the new node
  1319. {
  1320. var o=this
  1321. var ret= o.genericAdd(newAndOrNodeWidget(o.id+'_item-'+(o.counter++), isAnd, value),idx)
  1322. if (o.layer)
  1323. o.layer._counter=o.counter
  1324. return ret
  1325. }
  1326. // ================================================================================
  1327. function AndOrNodeWidget_addCopyNode(src,idx)
  1328. {
  1329. var o=this,n=o.addNode(src.isAnd,src.value,idx),srcItems=src.items
  1330. for (var i in srcItems)
  1331. {
  1332. var item=srcItems[i]
  1333. if (item.isNode())
  1334. n.addCopyNode(item,-1)
  1335. else
  1336. {
  1337. if(item.isAdvFilter)
  1338. n.addAdvFilterItem(item.text,item.imgIndex,item.value,item.tooltip,-1)
  1339. else
  1340. n.addItem(item.text,item.imgIndex,item.value,item.tooltip,-1)
  1341. }
  1342. }
  1343. return n
  1344. }
  1345. // ================================================================================
  1346. function AndOrNodeWidget_addItem(text,imgIndex,value,tooltip,idx)
  1347. // Adds a node
  1348. // Returns : [void]
  1349. {
  1350. var o=this,last=o.getLastItem()
  1351. var ret=o.genericAdd(newAndOrNodeItem(o.id+'_item-'+(o.counter++),text,imgIndex,value,tooltip),idx)
  1352. var last2=o.getLastItem()
  1353. if (o.layer)
  1354. {
  1355. if (last&&(last2.id!=last.id))
  1356. last.css.borderBottom=_lstNullbord
  1357. o.layer._counter=o.counter
  1358. }
  1359. return ret
  1360. }
  1361. function AndOrNodeWidget_AdvFilterItem(text,imgIndex,value,tooltip,idx)
  1362. // Adds a node
  1363. // Returns : [void]
  1364. {
  1365. var o=this,last=o.getLastItem()
  1366. var ret=o.genericAdd(newAndOrFilter(o.id+'_item-'+(o.counter++),text,imgIndex,value,tooltip),idx)
  1367. var last2=o.getLastItem()
  1368. if (o.layer)
  1369. {
  1370. if (last&&(last2.id!=last.id))
  1371. last.css.borderBottom=_lstNullbord
  1372. o.layer._counter=o.counter
  1373. }
  1374. return ret
  1375. }
  1376. // ================================================================================
  1377. function AndOrNodeWidget_removeChild(nodeOrItem)
  1378. // Removes a direct child
  1379. {
  1380. var o=this,items=o.items,len=items.length,list=o.list
  1381. for (var i=0;i<len;i++)
  1382. {
  1383. var item=items[i]
  1384. if (item.id==nodeOrItem.id)
  1385. {
  1386. var l=item.layer
  1387. if (item.selected)
  1388. item.select(false)
  1389. if (l)
  1390. l.parentNode.removeChild(l)
  1391. arrayRemove(o,"items",i)
  1392. items=o.items
  1393. var newSel=Math.min(i,items.length-1)
  1394. if (newSel>=0)
  1395. {
  1396. items[newSel].select(true)
  1397. var last=o.getLastItem()
  1398. if (o.layer&&last)
  1399. last.css.borderBottom=_lstNobord
  1400. }
  1401. else o.select(true)
  1402. list.showOrhideRoot()
  1403. return true;
  1404. }
  1405. if (item.isNode())
  1406. {
  1407. if (item.removeChild(nodeOrItem))
  1408. return true
  1409. }
  1410. }
  1411. return false
  1412. }
  1413. // ================================================================================
  1414. function AndOrNodeWidget_remove()
  1415. // Remove itself or all the tree except the root
  1416. {
  1417. var o=this
  1418. if (o.par)
  1419. o.par.removeChild(o)
  1420. else
  1421. {
  1422. //delete all child of root
  1423. var items=o.items,len=items.length
  1424. for (var i=len-1;i>=0;i--)
  1425. {
  1426. o.removeChild(items[i])
  1427. }
  1428. }
  1429. }
  1430. // ================================================================================
  1431. // ================================================================================
  1432. //
  1433. // OBJECT newAndOrNodeItem (Constructor)
  1434. //
  1435. // Base class for a filter list OR or AND item (leaf)
  1436. //
  1437. // ================================================================================
  1438. // ================================================================================
  1439. function newAndOrNodeItem(id,text,imgIndex,value,tooltip)
  1440. // CONSTRUCTOR
  1441. // id [String] the id for DHTML processing
  1442. // text [String] item text
  1443. // imgIndex [int] image index in the combined image
  1444. // value [String] item value - must be unique in the list
  1445. // tooltip [String] tooltip
  1446. // Return [AndOrNodeWidget] the instance
  1447. {
  1448. var o=newWidget(id)
  1449. o.text=text
  1450. o.value=value
  1451. o.tooltip=tooltip?tooltip:''
  1452. o.imgIndex=imgIndex?imgIndex:0
  1453. o.par=null
  1454. o.txtLayer=null
  1455. o.getHTML=AndOrNodeItem_getHTML
  1456. o.getDynamicHTML=AndOrNodeItem_getDynamicHTML
  1457. o.oldAOItemInit=o.init
  1458. o.init=AndOrNodeItem_init
  1459. o.select=AndOrNodeItem_select
  1460. o.isNode=AndOrNodeItem_isNode
  1461. o.getParentNode=AndOrNodeItem_getParentNode
  1462. o.getIndexInParent=AndOrNodeItem_getIndexInParent
  1463. o.remove=AndOrNodeItem_remove
  1464. o.setText=AndOrNodeItem_setText
  1465. o.setInsertFeedback=AndOrNodeItem_setInsertFeedback
  1466. o.isChildOf=AndOrNodeItem_isChildOf
  1467. o.fullW=false
  1468. return o
  1469. }
  1470. // ================================================================================
  1471. function AndOrNodeItem_setInsertFeedback(show,isAll)
  1472. {
  1473. var o=this,isLeft=(_dropPosition!=-1),st=o.css,b=show?"#C00000":"#FFFFFF"
  1474. var node=o.isNode()
  1475. if (isAll)
  1476. {
  1477. st.borderTopColor=st.borderLeftColor=st.borderBottomColor=st.borderRightColor="#FFFFFF"
  1478. if (node)
  1479. {
  1480. var dy=show?15:(6+(o.selected?3:0))
  1481. elasticZoneSetImg(o.operLayer,28,dy,dy+1,dy+2)
  1482. }
  1483. else
  1484. {
  1485. var dy=show?12:(o.selected?3:0)
  1486. elasticZoneSetImg(o.layer,28,dy,dy+1,dy+1,dy+2)
  1487. }
  1488. }
  1489. else
  1490. {
  1491. var isVert=((o.list.layout==_vertBOList)||(o.list.layout==_andOrBOList))
  1492. // Case of insersion into an empty node
  1493. if (_dropParentWidget&&(_dropFeebackWidget.id==_dropParentWidget.id))
  1494. {
  1495. var feedLayer=o.layer.childNodes[0].childNodes[0].childNodes[1],feedCSS=feedLayer.style
  1496. feedCSS.borderLeft=show?_lstBord:_lstNullbord
  1497. feedLayer.innerHTML=show?'&nbsp;':''
  1498. }
  1499. else
  1500. {
  1501. if (isLeft)
  1502. {
  1503. if (isVert)
  1504. st.borderTopColor=b
  1505. else
  1506. st.borderLeftColor=b
  1507. }
  1508. else
  1509. {
  1510. if (isVert)
  1511. st.borderBottomColor=b
  1512. else
  1513. st.borderRightColor=b
  1514. }
  1515. if (node)
  1516. {
  1517. var dy=6+(o.selected?3:0)
  1518. elasticZoneSetImg(o.operLayer,28,dy,dy+1,dy+2)
  1519. }
  1520. else
  1521. {
  1522. var dy=(o.selected?3:0)
  1523. elasticZoneSetImg(o.layer,28,dy,dy+1,dy+1,dy+2)
  1524. }
  1525. }
  1526. }
  1527. }
  1528. // ================================================================================
  1529. function AndOrNodeItem_getParentNode()
  1530. // Return [AndOrNodeWidget] the parent node
  1531. {
  1532. return this.par
  1533. }
  1534. // ================================================================================
  1535. function AndOrNodeItem_isNode()
  1536. // Test if it's a node
  1537. {
  1538. return false
  1539. }
  1540. // ================================================================================
  1541. function AndOrNodeItem_init()
  1542. // Initialization
  1543. // Returns : [void]
  1544. {
  1545. var o=this
  1546. o.oldAOItemInit()
  1547. o.layer.onmousedown=AndOrNodeItem_clickCB
  1548. o.layer.onmouseup=AndOrNodeItem_mouseupCB
  1549. if (_ie)
  1550. o.layer.onmousemove=AndOrNodeWidget_triggerDD
  1551. o.layer.onkeydown=AndOrNodeItem_keyDownCB
  1552. addDblClickCB(o.layer,AndOrNodeItem_dblClickCB)
  1553. o.layer.title=o.tooltip
  1554. var dd=o.list.dragDrop
  1555. if (_ie&&dd)
  1556. {
  1557. dd.attachCallbacks(o.layer)
  1558. o.layer.BODDType="item"
  1559. }
  1560. }
  1561. // ================================================================================
  1562. function AndOrNodeItem_getHTML()
  1563. // Returns : [String] the HTML
  1564. {
  1565. var o=this, list=o.list;
  1566. var topBorder=((list.layout==_vertBOList)||(list.layout==_andOrBOList))
  1567. var bottomBorder=(o.par.getLastItem().id==o.id)?topBorder:null
  1568. //only display 10 first caracters of the name
  1569. var text=o.text
  1570. if(list.layout!=_andOrBOList && !list.autofit)
  1571. {
  1572. if(text.length>10) text=text.slice(0,10)+"..."
  1573. }
  1574. return elasticZone(text,_skin+'bolist.gif',3,28,o.selected?84:0,o.id,'treeNormal',o.list.image,0,o.imgIndex*16,null,'AndOrItemTxt_'+o.id,o.fullW,topBorder,bottomBorder)
  1575. }
  1576. // ================================================================================
  1577. function AndOrNodeItem_getDynamicHTML()
  1578. // Returns : [String] the HTML
  1579. {
  1580. var o=this
  1581. var topBorder=((this.list.layout==_vertBOList)||(this.list.layout==_andOrBOList))
  1582. var bottomBorder=(o.par.getLastItem().id==o.id)?topBorder:null
  1583. //only display 10 first caracters of the name
  1584. var text=o.text
  1585. if(this.list.layout!=_andOrBOList)
  1586. {
  1587. if(text.length>10) text=text.slice(0,10)+"..."
  1588. }
  1589. return dynamicElasticZone(text,_skin+'bolist.gif',3,28,o.selected?84:0,o.id,'treeNormal',o.list.image,0,o.imgIndex*16,null,'AndOrItemTxt_'+o.id,o.fullW,topBorder,bottomBorder)
  1590. }
  1591. // ================================================================================
  1592. function AndOrNodeItem_clickCB(e)
  1593. // HTML Callback
  1594. {
  1595. var o=getWidget(this),list=o.list
  1596. o.select(true)
  1597. o.clicked=true
  1598. o.initialX=eventGetX(e)
  1599. o.initialY=eventGetY(e)
  1600. if (list.changeCB)
  1601. list.changeCB()
  1602. return false
  1603. }
  1604. // ================================================================================
  1605. function AndOrNodeItem_mouseupCB()
  1606. {
  1607. var o=getWidget(this)
  1608. o.clicked=false
  1609. }
  1610. // ================================================================================
  1611. function AndOrNodeItem_keyDownCB(e)
  1612. {
  1613. var o=getWidget(this),list=o.list
  1614. var key=eventGetKey(e);
  1615. if (key==46)
  1616. {
  1617. if (list.deleteCB)
  1618. list.deleteCB()
  1619. }
  1620. if(key==13)
  1621. {
  1622. eventCancelBubble(e);
  1623. o.select(true)
  1624. if (list.changeCB)
  1625. list.changeCB()
  1626. }
  1627. }
  1628. // ================================================================================
  1629. function AndOrNodeItem_dblClickCB()
  1630. // HTML Callback
  1631. {
  1632. var o=getWidget(this),list=o.list
  1633. if (list.dblClickCB)
  1634. list.dblClickCB()
  1635. return false
  1636. }
  1637. // ================================================================================
  1638. function AndOrNodeItem_select(sel)
  1639. // Select the current item
  1640. {
  1641. var o=this,list=o.list
  1642. if (sel)
  1643. list.unselect()
  1644. list.selection=sel?o:null
  1645. o.selected=sel
  1646. if (o.layer)
  1647. {
  1648. var dy=sel?3:0
  1649. elasticZoneSetImg(o.layer,28,dy,dy+1,dy+1,dy+2)
  1650. if(sel)
  1651. o.layer.title=_lstSelectedLabel+" "+o.tooltip
  1652. else
  1653. o.layer.title=o.tooltip
  1654. if(sel&&o.layer.focus&&(!isHidden(o.layer)))
  1655. o.layer.focus()
  1656. }
  1657. }
  1658. // ================================================================================
  1659. function AndOrNodeItem_remove()
  1660. // Remove itself
  1661. {
  1662. var o=this
  1663. if (o.par)
  1664. o.par.removeChild(o)
  1665. }
  1666. // ================================================================================
  1667. function AndOrNodeItem_getIndexInParent()
  1668. // return [int] index in parent node (-1 if no parent)
  1669. {
  1670. var o=this,par=o.par
  1671. return par?par.getChildIndex(o):-1
  1672. }
  1673. // ================================================================================
  1674. function AndOrNodeItem_setText(text)
  1675. // Remove itself
  1676. {
  1677. var o=this
  1678. if (o.txtLayer==null)
  1679. o.txtLayer=getLayer("AndOrItemTxt_"+o.id)
  1680. o.text=text
  1681. o.txtLayer.innerHTML=convStr(o.text,true)
  1682. o.tooltip=text
  1683. o.layer.title=o.tooltip
  1684. }
  1685. // ================================================================================
  1686. function AndOrNodeItem_isChildOf(node)
  1687. // Tests if node is a parent
  1688. // return [boolean]
  1689. {
  1690. var p=this.par
  1691. if (p==null)
  1692. return false
  1693. if (p.id==node.id)
  1694. return true
  1695. else
  1696. return p.isChildOf(node)
  1697. }
  1698. // ================================================================================
  1699. function elasticZoneInner(text,url,w,h,dy,id,cls,img,imgDx,imgDy,att,txtId,fullW,topBorder,bottomBorder,crs,extraHTML)
  1700. // Create a zone with a left image, a
  1701. {
  1702. var bodyHTML ='';
  1703. if(extraHTML)
  1704. //bodyHTML = '<div '+attr("id",txtId)+' class="'+cls+'" style="width:0px">'+extraHTML+'</div>'
  1705. bodyHTML = '<table '+attr("id",txtId)+' class="'+cls+'" cellpadding="0" cellspacing="0" border="0"><tr valign="middle"><td>'+extraHTML+'</td></tr></table>'
  1706. else
  1707. bodyHTML = '<nobr '+attr("id",txtId)+' class="'+cls+'">'+convStr(text,true)+'</nobr>'
  1708. return '<tbody><tr valign="middle"><td width="'+w+'">'+imgOffset(url,w,h,0,dy)+'</td>'+
  1709. (img?('<td style="padding-left:2px;'+backImgOffset(url,0,dy+h)+'">'+imgOffset(img,16,16,imgDx,imgDy)+'</td>'):'')+
  1710. '<td '+(att?att:'')+' '+(fullW? 'width="100%"':'')+' style="padding-left:2px;padding-right:'+(img?8:4)+'px;'+backImgOffset(url,0,dy+h)+'">'+bodyHTML+'</td><td width="'+w+'">'+imgOffset(url,w,h,0,dy+(2*h))+'</td></tr></tbody>'
  1711. }
  1712. // ================================================================================
  1713. function elasticZone(text,url,w,h,dy,id,cls,img,imgDx,imgDy,att,txtId,fullW,topBorder,bottomBorder,crs,extraHTML)
  1714. // Create a zone with a left image, a
  1715. {
  1716. var s=""
  1717. if (topBorder!=null)
  1718. s+=(topBorder?"border-top:":"border-left:")+_lstNobord+";"
  1719. if (bottomBorder!=null)
  1720. s+=(bottomBorder?"border-bottom:":"border-right:")+_lstNobord+";"
  1721. crs=crs?crs:_hand
  1722. return '<table '+attr("id",id)+' boelastic="1" tabIndex="0" '+(fullW?'width="100%"':'')+' cellpadding="0" cellspacing="0" border="0" style="'+s+'cursor:'+crs+'" height="'+h+'">' +
  1723. elasticZoneInner(text,url,w,h,dy,id,cls,img,imgDx,imgDy,att,txtId,fullW,topBorder,bottomBorder,crs,extraHTML) +
  1724. '</table>'
  1725. }
  1726. // ================================================================================
  1727. function dynamicElasticZone(text,url,w,h,dy,id,cls,img,imgDx,imgDy,att,txtId,fullW,topBorder,bottomBorder,crs,extraHTML)
  1728. // Create a zone with a left image, a
  1729. {
  1730. crs=crs?crs:_hand
  1731. var theTable=_curDoc.createElement('table')
  1732. if (topBorder!=null)
  1733. {
  1734. if (topBorder)
  1735. theTable.style.borderTop = _lstNobord
  1736. else
  1737. theTable.style.borderLeft = _lstNobord
  1738. }
  1739. if (bottomBorder!=null)
  1740. {
  1741. if (bottomBorder)
  1742. theTable.style.borderBottom = _lstNobord
  1743. else
  1744. theTable.style.borderRight = _lstNobord
  1745. }
  1746. theTable.id = id
  1747. theTable.setAttribute("boelastic","1")
  1748. theTable.tabIndex = 0
  1749. if (fullW)
  1750. theTable.width="100%"
  1751. theTable.cellPadding = 0
  1752. theTable.cellSpacing = 0
  1753. theTable.border = 0
  1754. theTable.style.cursor = crs
  1755. theTable.height = h
  1756. theTable.innerHTML= elasticZoneInner(text,url,w,h,dy,id,cls,img,imgDx,imgDy,att,txtId,fullW,topBorder,bottomBorder,crs,extraHTML)
  1757. return theTable
  1758. }
  1759. // ================================================================================
  1760. function elasticZoneSetImg(lyr,h,dy1,dy2,dy3,dy4)
  1761. {
  1762. if (lyr&&(lyr.getAttribute("boelastic")!=null))
  1763. {
  1764. var c=lyr.childNodes[0].childNodes[0].childNodes,j=1,len=c.length
  1765. for (var i=0;i<len;i++)
  1766. {
  1767. var ce=c[i]
  1768. if (ce.tagName!=null)
  1769. changeOffset(((j==1||j==(len))?ce.childNodes[0]:ce),0,h*eval('dy'+(j++)))
  1770. }
  1771. }
  1772. }
  1773. // ================================================================================
  1774. // ================================================================================
  1775. // ================================================================================
  1776. //
  1777. // OBJECT newAndOrFilter (Constructor)
  1778. //
  1779. // Base class for a filter list OR or AND item (leaf)
  1780. //
  1781. // ================================================================================
  1782. // ================================================================================
  1783. function newAndOrFilter(id,text,imgIndex,value,tooltip)
  1784. // CONSTRUCTOR
  1785. // id [String] the id for DHTML processing
  1786. // filter [Object] filter structure
  1787. // imgIndex [int] image index in the combined image
  1788. // value [String] item value - must be unique in the list
  1789. // tooltip [String] tooltip
  1790. // Return [AndOrNodeWidget] the instance
  1791. {
  1792. var o=newWidget(id)
  1793. o.text=text
  1794. o.isAdvFilter=true;
  1795. o.value=value
  1796. o.tooltip=tooltip?tooltip:''
  1797. o.imgIndex=imgIndex?imgIndex:0
  1798. o.par=null
  1799. o.txtLayer=null
  1800. o.operatorCombo=newCustomCombo('AndOrFilterOperator_'+id,operator_changeCB,true,null);
  1801. o.operatorCombo.par=o
  1802. AndOrFilter_initOpCombo(o.operatorCombo);
  1803. o.defZone=newAdvFilterDef('AndOrFilterDefinition_'+id);
  1804. o.defZone2=newAdvFilterDef('AndOrFilterDefinition2_'+id);
  1805. o.defZone.par=o
  1806. o.defZone2.par=o
  1807. o.getHTML=AndOrFilter_getHTML
  1808. o.getExtraHTML=AndOrFilter_getExtraHTML
  1809. o.getDynamicHTML=AndOrFilter_getDynamicHTML
  1810. o.oldAOItemInit=o.init
  1811. o.init=AndOrFilter_init
  1812. o.select=AndOrFilter_select
  1813. o.isNode=AndOrFilter_isNode
  1814. o.getParentNode=AndOrFilter_getParentNode
  1815. o.getIndexInParent=AndOrFilter_getIndexInParent
  1816. o.remove=AndOrFilter_remove
  1817. o.setText=AndOrFilter_setText
  1818. o.setInsertFeedback=AndOrFilter_setInsertFeedback
  1819. o.isChildOf=AndOrFilter_isChildOf
  1820. o.getDefinition=AndOrFilter_getDefinition
  1821. o.fullW=false
  1822. return o
  1823. }
  1824. // ================================================================================
  1825. function AndOrFilter_setInsertFeedback(show,isAll)
  1826. {
  1827. var o=this,isLeft=(_dropPosition!=-1),st=o.css,b=show?"#C00000":"#FFFFFF"
  1828. var node=o.isNode()
  1829. if (isAll)
  1830. {
  1831. st.borderTopColor=st.borderLeftColor=st.borderBottomColor=st.borderRightColor="#FFFFFF"
  1832. if (node)
  1833. {
  1834. var dy=show?15:(6+(o.selected?3:0))
  1835. elasticZoneSetImg(o.operLayer,28,dy,dy+1,dy+2)
  1836. }
  1837. else
  1838. {
  1839. var dy=show?12:(o.selected?3:0)
  1840. elasticZoneSetImg(o.layer,28,dy,dy+1,dy+1,dy+2)
  1841. }
  1842. }
  1843. else
  1844. {
  1845. var isVert=((o.list.layout==_vertBOList)||(o.list.layout==_andOrBOList))
  1846. // Case of insersion into an empty node
  1847. if (_dropParentWidget&&(_dropFeebackWidget.id==_dropParentWidget.id))
  1848. {
  1849. var feedLayer=o.layer.childNodes[0].childNodes[0].childNodes[1],feedCSS=feedLayer.style
  1850. feedCSS.borderLeft=show?_lstBord:_lstNullbord
  1851. feedLayer.innerHTML=show?'&nbsp;':''
  1852. }
  1853. else
  1854. {
  1855. if (isLeft)
  1856. {
  1857. if (isVert)
  1858. st.borderTopColor=b
  1859. else
  1860. st.borderLeftColor=b
  1861. }
  1862. else
  1863. {
  1864. if (isVert)
  1865. st.borderBottomColor=b
  1866. else
  1867. st.borderRightColor=b
  1868. }
  1869. if (node)
  1870. {
  1871. var dy=6+(o.selected?3:0)
  1872. elasticZoneSetImg(o.operLayer,28,dy,dy+1,dy+2)
  1873. }
  1874. else
  1875. {
  1876. var dy=(o.selected?3:0)
  1877. elasticZoneSetImg(o.layer,28,dy,dy+1,dy+1,dy+2)
  1878. }
  1879. }
  1880. }
  1881. }
  1882. // ================================================================================
  1883. function AndOrFilter_getParentNode()
  1884. // Return [AndOrNodeWidget] the parent node
  1885. {
  1886. return this.par
  1887. }
  1888. // ================================================================================
  1889. function AndOrFilter_isNode()
  1890. // Test if it's a node
  1891. {
  1892. return false
  1893. }
  1894. // ================================================================================
  1895. function AndOrFilter_init()
  1896. // Initialization
  1897. // Returns : [void]
  1898. {
  1899. var o=this
  1900. o.oldAOItemInit()
  1901. o.operatorCombo.init();
  1902. o.defZone.init();
  1903. o.defZone2.init();
  1904. o.defZone2.setDisplay(false);
  1905. o.layer.onmousedown=AndOrFilter_clickCB
  1906. o.layer.onmouseup=AndOrFilter_mouseupCB
  1907. if (_ie)
  1908. o.layer.onmousemove=AndOrNodeWidget_triggerDD
  1909. o.layer.onkeydown=AndOrFilter_keyDownCB
  1910. addDblClickCB(o.layer,AndOrFilter_dblClickCB)
  1911. o.layer.title=o.tooltip
  1912. var dd=o.list.dragDrop
  1913. if (_ie&&dd)
  1914. {
  1915. dd.attachCallbacks(o.layer)
  1916. o.layer.BODDType="item"
  1917. }
  1918. }
  1919. // ================================================================================
  1920. function AndOrFilter_getExtraHTML()
  1921. {
  1922. var o=this,s="";
  1923. s+='<table class="treeNormal" border="0" cellspacing="0" cellpadding="0"><tr valign="middle"><td>';
  1924. s+=o.text+'</td><td>';
  1925. s+=o.operatorCombo.getHTML();
  1926. s+='</td><td>';
  1927. s+=o.defZone.getHTML();
  1928. s+='</td><td>';
  1929. s+=o.defZone2.getHTML();
  1930. s+='</td></tr></table>';
  1931. return s;
  1932. }
  1933. // ================================================================================
  1934. function AndOrFilter_getHTML()
  1935. // Returns : [String] the HTML
  1936. {
  1937. var o=this, list=o.list;
  1938. var topBorder=((list.layout==_vertBOList)||(list.layout==_andOrBOList))
  1939. var bottomBorder=(o.par.getLastItem().id==o.id)?topBorder:null
  1940. //only display 10 first caracters of the name
  1941. var text=o.text
  1942. if(list.layout!=_andOrBOList && !list.autofit)
  1943. {
  1944. if(text.length>10) text=text.slice(0,10)+"..."
  1945. }
  1946. return elasticZone(text,_skin+'bolist.gif',3,28,o.selected?84:0,o.id,'treeNormal',o.list.image,0,o.imgIndex*16,null,'AndOrFilterTxt_'+o.id,o.fullW,topBorder,bottomBorder,null,o.getExtraHTML())
  1947. }
  1948. // ================================================================================
  1949. function AndOrFilter_getDynamicHTML()
  1950. // Returns : [String] the HTML
  1951. {
  1952. var o=this
  1953. var topBorder=((this.list.layout==_vertBOList)||(this.list.layout==_andOrBOList))
  1954. var bottomBorder=(o.par.getLastItem().id==o.id)?topBorder:null
  1955. //only display 10 first caracters of the name
  1956. var text=o.text
  1957. if(this.list.layout!=_andOrBOList)
  1958. {
  1959. if(text.length>10) text=text.slice(0,10)+"..."
  1960. }
  1961. return dynamicElasticZone(text,_skin+'bolist.gif',3,28,o.selected?84:0,o.id,'treeNormal',o.list.image,0,o.imgIndex*16,null,'AndOrFilterTxt_'+o.id,o.fullW,topBorder,bottomBorder,null,o.getExtraHTML())
  1962. }
  1963. // ================================================================================
  1964. function AndOrFilter_clickCB(e)
  1965. // HTML Callback
  1966. {
  1967. var o=getWidget(this),list=o.list
  1968. o.select(true)
  1969. o.clicked=true
  1970. o.initialX=eventGetX(e)
  1971. o.initialY=eventGetY(e)
  1972. if (list.changeCB)
  1973. list.changeCB()
  1974. return false
  1975. }
  1976. // ================================================================================
  1977. function AndOrFilter_mouseupCB()
  1978. {
  1979. var o=getWidget(this)
  1980. o.clicked=false
  1981. }
  1982. // ================================================================================
  1983. function AndOrFilter_keyDownCB(e)
  1984. {
  1985. var o=getWidget(this),list=o.list
  1986. var key=eventGetKey(e);
  1987. if (key==46)
  1988. {
  1989. if (list.deleteCB)
  1990. list.deleteCB()
  1991. }
  1992. if(key==13)
  1993. {
  1994. eventCancelBubble(e);
  1995. o.select(true)
  1996. if (list.changeCB)
  1997. list.changeCB()
  1998. }
  1999. }
  2000. // ================================================================================
  2001. function AndOrFilter_dblClickCB()
  2002. // HTML Callback
  2003. {
  2004. var o=getWidget(this),list=o.list
  2005. if (list.dblClickCB)
  2006. list.dblClickCB()
  2007. return false
  2008. }
  2009. // ================================================================================
  2010. function AndOrFilter_select(sel)
  2011. // Select the current item
  2012. {
  2013. var o=this,list=o.list
  2014. if (sel)
  2015. list.unselect()
  2016. list.selection=sel?o:null
  2017. o.selected=sel
  2018. if (o.layer)
  2019. {
  2020. var dy=sel?3:0
  2021. elasticZoneSetImg(o.layer,28,dy,dy+1,dy+1,dy+2)
  2022. if(sel)
  2023. o.layer.title=_lstSelectedLabel+" "+o.tooltip
  2024. else
  2025. o.layer.title=o.tooltip
  2026. if(sel&&o.layer.focus&&(!isHidden(o.layer)))
  2027. o.layer.focus()
  2028. }
  2029. }
  2030. // ================================================================================
  2031. function AndOrFilter_remove()
  2032. // Remove itself
  2033. {
  2034. var o=this
  2035. if (o.par)
  2036. o.par.removeChild(o)
  2037. }
  2038. // ================================================================================
  2039. function AndOrFilter_getIndexInParent()
  2040. // return [int] index in parent node (-1 if no parent)
  2041. {
  2042. var o=this,par=o.par
  2043. return par?par.getChildIndex(o):-1
  2044. }
  2045. // ================================================================================
  2046. function AndOrFilter_setText(text)
  2047. // Remove itself
  2048. {
  2049. var o=this
  2050. if (o.txtLayer==null)
  2051. o.txtLayer=getLayer("AndOrFilterTxt_"+o.id)
  2052. o.text=text
  2053. o.txtLayer.innerHTML=convStr(o.text,true)
  2054. o.tooltip=text
  2055. o.layer.title=o.tooltip
  2056. }
  2057. // ================================================================================
  2058. function AndOrFilter_isChildOf(node)
  2059. // Tests if node is a parent
  2060. // return [boolean]
  2061. {
  2062. var p=this.par
  2063. if (p==null)
  2064. return false
  2065. if (p.id==node.id)
  2066. return true
  2067. else
  2068. return p.isChildOf(node)
  2069. }
  2070. // ================================================================================
  2071. function AndOrFilter_getDefinition()
  2072. // get the included AndOrBOListWidget
  2073. // return [AndOrBOListWidget]
  2074. {
  2075. return this.defZone
  2076. }
  2077. // ================================================================================
  2078. function AndOrFilter_initOpCombo(fope)
  2079. {
  2080. fope.icon.setClasses("iconnochecknobg", "iconchecknobg", "iconhovernobg", "iconcheckhovernobg")
  2081. fope.arrow.setClasses("iconnochecknobg", "iconchecknobg", "iconhovernobg", "iconcheckhovernobg")
  2082. fope.arrow.overCB="IconWidget_overCB"
  2083. fope.arrow.outCB="IconWidget_outCB"
  2084. fope.icon.overCB="IconWidget_overCB"
  2085. fope.icon.outCB="IconWidget_outCB"
  2086. fope.icon.width=null;
  2087. /*
  2088. for (var i=_topfs._firstFilter;i<=_topfs._lastFilter;i++)
  2089. {
  2090. fope.add(_topfs._labFil[i],""+i);
  2091. }
  2092. */
  2093. fope.add("EQUAL","EQUAL");
  2094. fope.add("NOT_EQUAL","NOT_EQUAL");
  2095. fope.add("GREATER","GREATER");
  2096. fope.add("GREATER_OR_EQUAL","GREATER_OR_EQUAL");
  2097. fope.add("LESS","LESS");
  2098. fope.add("LESS_OR_EQUAL","LESS_OR_EQUAL");
  2099. fope.add("BETWEEN","BETWEEN");
  2100. fope.add("NOT_BETWEEN","NOT_BETWEEN");
  2101. fope.add("IN_LIST","IN_LIST",true);
  2102. fope.add("NOT_IN_LIST","NOT_IN_LIST");
  2103. fope.add("IS_NULL","IS_NULL");
  2104. fope.add("NOT_IS_NULL","NOT_IS_NULL");
  2105. fope.add("LIKE","LIKE");
  2106. fope.add("NOT_LIKE","NOT_LIKE");
  2107. fope.add("BOTH","BOTH");
  2108. fope.add("EXCEPT","EXCEPT");
  2109. }
  2110. // ================================================================================
  2111. function operator_changeCB()
  2112. {
  2113. var o=this, sel = o.getSelection()
  2114. var advflt= o.par;
  2115. if(sel && advflt)
  2116. {
  2117. switch(sel.value)
  2118. {
  2119. case "BETWEEN" :
  2120. case "NOT_BETWEEN" :
  2121. case "BOTH" :
  2122. advflt.defZone2.setDisplay(true);
  2123. break;
  2124. case "IS_NULL" :
  2125. case "NOT_IS_NULL" :
  2126. advflt.defZone.setDisplay(false);
  2127. advflt.defZone2.setDisplay(false);
  2128. break;
  2129. default :
  2130. advflt.defZone.setDisplay(true);
  2131. advflt.defZone2.setDisplay(false);
  2132. break;
  2133. }
  2134. }
  2135. }
  2136. // ================================================================================
  2137. // AdvFilterDef: definition zone of the filter
  2138. // ================================================================================
  2139. _filterDefConst=1
  2140. _filterDefFromList=2
  2141. _filterDefPrompt=3
  2142. _filterDefObj=4
  2143. function newAdvFilterDef(id)
  2144. {
  2145. var o=newWidget(id);
  2146. o.type=_filterDefPrompt;
  2147. o.obj=null;
  2148. o.input="prompt by default ?";
  2149. o.objLabel= newWidget(id+"_objlabel");
  2150. o.inputTxt= newTextFieldWidget(id+"_input",null,null,null,null);
  2151. o.propertyIcn=newIconWidget(id+"_property",_skin+"promptProp.gif",clickPropCB,null,null,16,16,0,0);
  2152. o.typeIcn=newIconWidget(id+"_type",_skin+"filterType.gif",clickTypeCB,null,null,16,16,0,0);
  2153. o.propertyIcn.setClasses("iconnochecknobg", "iconchecknobg", "iconhovernobg", "iconcheckhovernobg");
  2154. o.typeIcn.setClasses("iconnochecknobg", "iconchecknobg", "iconhovernobg", "iconcheckhovernobg");
  2155. var m=o.typeMenu=newMenuWidget(id+"_type_menu");
  2156. //build filter type menu
  2157. m.addCheck("advf_constant","Constant",changeFTypeCB);
  2158. m.addCheck("advf_fromList","From List",changeFTypeCB);
  2159. m.addCheck("advf_prompt","Prompt",changeFTypeCB);
  2160. m.addCheck("advf_object","Object",changeFTypeCB);
  2161. o.inputTxt.afPar=o;
  2162. o.propertyIcn.afPar=o;
  2163. o.typeIcn.afPar=o;
  2164. o.typeMenu.afPar=o;
  2165. o.oldInit=o.init
  2166. o.init=AdvFilterDef_init
  2167. o.getHTML=AdvFilterDef_getHTML
  2168. o.updateUI=AdvFilterDef_updateUI
  2169. return o;
  2170. }
  2171. function AdvFilterDef_getHTML()
  2172. {
  2173. var o=this;
  2174. return(
  2175. '<table id="'+o.id+'" border="0" cellspacing="0" cellpadding="0"><tbody>'+
  2176. '<tr>'+
  2177. '<td id="'+o.id+'_objlabel">'+
  2178. '<table class="treeNormal" border="0" cellspacing="0" cellpadding="0"><tr><td>'+imgOffset(_skin+"qualification.gif",16,16,0,0)+'</td><td><nobr>my object</nobr></td></tr></table>'+
  2179. '</td><td>'+
  2180. o.inputTxt.getHTML()+
  2181. '</td><td>'+
  2182. o.propertyIcn.getHTML()+
  2183. '</td><td>'+
  2184. o.typeIcn.getHTML()+
  2185. '</td>'+
  2186. '</tr>'+
  2187. '</tbody></table>');
  2188. }
  2189. function AdvFilterDef_init()
  2190. {
  2191. var o=this;
  2192. //init widget
  2193. o.oldInit();
  2194. o.objLabel.init();
  2195. o.inputTxt.init();
  2196. o.propertyIcn.init();
  2197. o.typeIcn.init();
  2198. //update UI depending on the type of filter
  2199. o.updateUI();
  2200. }
  2201. function changeFTypeCB()
  2202. {
  2203. var id = this.id;
  2204. var menu=this.par,items=menu.items
  2205. var o=menu.afPar;//AdvFilterDef objet
  2206. for (var i in items)
  2207. {
  2208. var item=items[i]
  2209. item.check(item.id==id)
  2210. }
  2211. switch(id)
  2212. {
  2213. case "advf_constant" :
  2214. o.type = _filterDefConst;
  2215. break;
  2216. case "advf_fromList" :
  2217. o.type = _filterDefFromList;
  2218. alert("lov dialog");
  2219. break;
  2220. case "advf_prompt" :
  2221. o.type = _filterDefPrompt;
  2222. break;
  2223. case "advf_object" :
  2224. o.type = _filterDefObj;
  2225. alert("universe dimensions dialog");
  2226. break;
  2227. }
  2228. o.updateUI();
  2229. }
  2230. function AdvFilterDef_updateUI()
  2231. {
  2232. var o=this;
  2233. switch(o.type)
  2234. {
  2235. case _filterDefConst :
  2236. o.objLabel.setDisplay(false);
  2237. o.inputTxt.setDisplay(true);
  2238. o.inputTxt.setValue("");
  2239. o.propertyIcn.setDisplay(false);
  2240. o.typeMenu.getItemByID("advf_constant").check(true);
  2241. break;
  2242. case _filterDefFromList :
  2243. o.objLabel.setDisplay(false);
  2244. o.inputTxt.setDisplay(true);
  2245. o.inputTxt.setValue("");
  2246. o.propertyIcn.setDisplay(false);
  2247. o.typeMenu.getItemByID("advf_fromList").check(true);
  2248. break;
  2249. case _filterDefPrompt :
  2250. o.objLabel.setDisplay(false);
  2251. o.inputTxt.setDisplay(true);
  2252. o.inputTxt.setValue(o.input);
  2253. o.propertyIcn.setDisplay(true);
  2254. o.typeMenu.getItemByID("advf_prompt").check(true);
  2255. break;
  2256. case _filterDefObj :
  2257. o.objLabel.setDisplay(true);
  2258. o.inputTxt.setDisplay(false);
  2259. o.propertyIcn.setDisplay(false);
  2260. o.typeMenu.getItemByID("advf_object").check(true);
  2261. break;
  2262. }
  2263. }
  2264. function clickPropCB()
  2265. {
  2266. alert("prompt property dialog");
  2267. }
  2268. function clickTypeCB()
  2269. {
  2270. var o=this.afPar, icn = this, l=icn.layer,menu=o.typeMenu;
  2271. menu.show(true,getPosScrolled(l).x + (menu.alignLeft?icn.getWidth():0) ,getPosScrolled(l).y+icn.getHeight()+1);
  2272. IconWidget_overCB(icn.index)
  2273. }