palette.js 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281
  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: palette.js
  13. =============================================================
  14. */
  15. _allBOIcons=new Array
  16. _allBOIconsMenus=new Array
  17. //_lastUsedColors=new Array
  18. //_maxUsedColors=8
  19. _menuType_simple=0
  20. _menuType_color =1
  21. _menuType_border=2
  22. // ================================================================================
  23. // ================================================================================
  24. //
  25. // OBJECT NewLabelWidget (Constructor)
  26. //
  27. // Display a simple text. It can be used in a palette for instance
  28. //
  29. // ================================================================================
  30. // ================================================================================
  31. function NewLabelWidget(id,text,convBlanks)
  32. // CONSTRUCTOR
  33. // id [String] the label id for DHTML processing
  34. // text [String] label text
  35. // convBlanks [boolean optional] if true, blank are converted into &nbsp;
  36. {
  37. var o=newWidget(id)
  38. o.text=text
  39. o.convBlanks=convBlanks
  40. o.getHTML=LabelWidget_getHTML
  41. o.setDisabled=LabelWidget_setDisabled
  42. o.dis=false
  43. return o;
  44. }
  45. // ================================================================================
  46. function LabelWidget_setDisabled(dis)
  47. // set the widget disabled
  48. // dis [boolean] if true, disables the widget
  49. {
  50. var o=this
  51. if (o.dis!=dis)
  52. {
  53. o.dis=dis
  54. if (o.layer)
  55. {
  56. o.layer.className="iconText"+(dis?"Dis":"")
  57. }
  58. }
  59. }
  60. // ================================================================================
  61. function LabelWidget_getHTML()
  62. // returns [String] the HTML of a label widget
  63. {
  64. var o=this
  65. return '<div id="'+o.id+'" class="icontext'+(o.dis?"Dis":"")+'" style="white-space:nowrap;margin-right:4px;margin-left:4px;cursor:default">'+convStr(o.text,o.convBlanks)+'</div>'
  66. }
  67. // ================================================================================
  68. // ================================================================================
  69. //
  70. // OBJECT newIconWidget (Constructor)
  71. //
  72. // Display a clickable icon with optional text. It can be used in a palette fo
  73. // instance. The image can be a sub-part of a bigger image
  74. // (use dx and dy to define offset)
  75. //
  76. // ================================================================================
  77. // ================================================================================
  78. function newIconWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy)
  79. // CONTRUCTOR
  80. // id : [String] the icon id for DHTML processing
  81. // src : [String] the icon image url
  82. // clickCB : [Function - optional] callback called when clicking
  83. // text : [String - optional] icon text
  84. // alt : [String] icon tooltip
  85. // w : [int] visible image width
  86. // h : [int] visible image height
  87. // dx : [int - optional] horizontal offset in the image
  88. // dy : [int - optional] vertical offset in the image
  89. // disDx : [int - optional] horizontal offset for disabled state
  90. // disDy : [int - optional] vertical offset for disabled state
  91. {
  92. var o=newWidget(id)
  93. o.src=src
  94. o.clickCB=clickCB
  95. o.text=text
  96. o.alt=alt
  97. o.width=null
  98. o.txtAlign="left"
  99. o.border=4
  100. o.txtNoPadding=false
  101. o.allowDblClick=false
  102. if (src)
  103. {
  104. o.w=(w!=null)?w:16
  105. o.h=(h!=null)?h:16
  106. o.dx=(dx!=null)?dx:0
  107. o.dy=(dy!=null)?dy:0
  108. o.disDx=(disDx!=null)?disDx:0
  109. o.disDy=(disDy!=null)?disDy:0
  110. }
  111. else
  112. {
  113. o.w=1
  114. o.h=16
  115. }
  116. o.dis=false
  117. o.disp=true
  118. o.margin=1
  119. o.extraHTML=''
  120. o.imgLayer=null
  121. o.txtLayer=null
  122. o.overCB="IconWidget_overCB"
  123. o.outCB="IconWidget_outCB"
  124. o.isDisplayed=IconWidget_isDisplayed
  125. o.setDisplay=IconWidget_setDisplay
  126. o.getHTML=IconWidget_getHTML
  127. o.getTxtWidth=IconWidget_getTxtWidth
  128. o.index=_allBOIcons.length++
  129. o.nocheckClass="iconnocheck"
  130. o.hoverClass="iconhover"
  131. o.checkClass="iconcheck"
  132. o.checkhoverClass="iconcheckhover"
  133. o.currentClass=o.nocheckClass
  134. o.currentHoverClass=o.hoverClass
  135. o.setClasses=IconWidget_setClasses
  136. o.internalUpCB=null
  137. o.internalDownCB=IconWidget_internalDownCB
  138. o.internalUpCB=IconWidget_internalUpCB
  139. o.isHover=false
  140. o.changeTooltip=IconWidget_changeTooltip
  141. o.changeText=IconWidget_changeText
  142. o.changeImg=IconWidget_changeImg
  143. o.setDisabled=IconWidget_setDisabled
  144. o.isDisabled=IconWidget_isDisabled
  145. o.acceptClick=IconWidget_acceptClick
  146. _allBOIcons[o.index]=o
  147. o.outEnable=true
  148. o.setCrs=IconWidget_setCrs
  149. o.oldRes=o.resize
  150. o.resize=IconWidget_resize
  151. o.iconOldInit=o.init
  152. o.init=IconWidget_init
  153. return o
  154. }
  155. // ================================================================================
  156. // ================================================================================
  157. //
  158. // OBJECT newIconMenuWidget (Constructor)
  159. //
  160. // An icon widget that add an arrow part at the right. when clicking on the
  161. // right part, a menu pops up
  162. // If no callback is attached, the also pops up when clicking on the left part
  163. // menu.js must be included to use this component
  164. //
  165. // ================================================================================
  166. // ================================================================================
  167. function newIconMenuWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy,isColor,beforeShowCB,menuType)
  168. // CONSTRUCTOR
  169. // id : [String] the icon id for DHTML processing
  170. // src : [String] the icon image url
  171. // clickCB : [Function - optional] callback called when clicking
  172. // text : [String - optional] icon text
  173. // alt : [String] icon tooltip
  174. // w : [int] visible image width
  175. // h : [int] visible image height
  176. // dx : [int - optional] horizontal offset in the image
  177. // dy : [int - optional] vertical offset in the image
  178. // disDx : [int - optional] horizontal offset for disabled state
  179. // disDy : [int - optional] vertical offset for disabled state
  180. {
  181. var o=newWidget(id)
  182. if ( typeof(menuType) == 'undefined' )
  183. menuType=isColor?_menuType_color:_menuType_simple
  184. o.menuItemType = isColor? _isColor:_isNotColor
  185. o.icon=newIconWidget("iconMenu_icon_"+id,src,IconMenuWidget_iconClickCB,text,alt,w,h,dx,dy,disDx,disDy)
  186. o.arrow=newIconWidget("iconMenu_arrow_"+id,_skin+"menus.gif",IconMenuWidget_arrowClickCB,null,(_openMenuPart1+(text?text:(alt?alt:""))+_openMenuPart2),7,16,0,81,0,97)
  187. switch (menuType)
  188. {
  189. case _menuType_color:
  190. o.menu=newMenuColorWidget("iconMenu_menu_"+id,IconMenuWidget_hideCB)
  191. break
  192. case _menuType_border:
  193. o.menu=newMenuBordersWidget("iconMenu_menu_"+id,IconMenuWidget_hideCB,beforeShowCB,IconBordersMenuWidget_internalClickCB)
  194. break
  195. default:
  196. case _menuType_simple:
  197. o.menu=newMenuWidget("iconMenu_menu_"+id,IconMenuWidget_hideCB,beforeShowCB)
  198. break
  199. }
  200. o.icon.par=o
  201. o.arrow.par=o
  202. o.menu.parIcon=o
  203. o.icon.margin=0
  204. o.arrow.margin=0
  205. o.icon.overCB="IconWidget_none"
  206. o.icon.outCB="IconWidget_none"
  207. o.arrow.overCB="IconWidget_none"
  208. o.arrow.outCB="IconWidget_none"
  209. o.margin=1
  210. o.spc=0
  211. o.getHTML=IconMenuWidget_getHTML
  212. o.clickCB=clickCB
  213. o.getMenu=IconMenuWidget_getMenu
  214. o.menIcnOldInit=o.init
  215. o.init=IconMenuWidget_init
  216. o.index=_allBOIconsMenus.length++
  217. _allBOIconsMenus[o.index]=o
  218. o.setDisabled=IconMenuWidget_setDisabled
  219. o.isDisabled=IconMenuWidget_isDisabled
  220. o.disableMenu=IconMenuWidget_disableMenu
  221. o.changeText=IconMenuWidget_changeText
  222. o.imwpResize=o.resize
  223. o.resize=IconMenuWidget_resize
  224. o.focus=IconMenuWidget_focus
  225. o.changeArrowTooltip=IconMenuWidget_changeArrowTooltip
  226. o.disp=true
  227. o.isDisplayed=IconWidget_isDisplayed
  228. o.setDisplay=IconWidget_setDisplay
  229. return o
  230. }
  231. // ================================================================================
  232. function IconMenuWidget_changeText(s)
  233. // Change the icon text
  234. // s [String] : the new text
  235. {
  236. this.icon.changeText(s)
  237. }
  238. // ================================================================================
  239. function IconMenuWidget_changeArrowTooltip(tooltip)
  240. {
  241. this.arrow.changeTooltip(tooltip,false);
  242. }
  243. // ================================================================================
  244. function IconMenuWidget_resize(w,h)
  245. {
  246. var o=this
  247. if (w!=null)
  248. w=Math.max(0,w-2*o.margin)
  249. var d=o.layer.display!="none"
  250. if (d&_moz&&!_saf)
  251. o.setDisplay(false)
  252. o.imwpResize(w,h)
  253. if (w!=null)
  254. o.icon.resize(Math.max(0,w-13-o.spc))
  255. if (d&_moz&&!_saf)
  256. o.setDisplay(true)
  257. }
  258. // ================================================================================
  259. function IconMenuWidget_setDisabled(dis)
  260. {
  261. var o=this
  262. if (dis) {
  263. if (o.menu.isShown()) {
  264. o.menu.show(false)
  265. }
  266. IconMenuWidgetOutCB(o.index)
  267. }
  268. o.icon.setDisabled(dis)
  269. o.arrow.setDisabled(dis)
  270. }
  271. // ================================================================================
  272. function IconMenuWidget_isDisabled()
  273. {
  274. return (this.icon.dis == true)
  275. }
  276. // ================================================================================
  277. function IconMenuWidget_internalCB()
  278. {
  279. var o=this,col=null
  280. if (o.id!=null)
  281. {
  282. col = (o.menuItemType != _isLastUsedColor)? o.id.slice(6) : o.color // "color".length=6
  283. }
  284. var icon=o.par.parIcon
  285. icon.oldColor=icon.curColor
  286. icon.curColor=col
  287. if (icon.curColor!=null)
  288. icon.showSample()
  289. if (icon.clickColor)
  290. icon.clickColor()
  291. }
  292. // ================================================================================
  293. function IconMenuWidget_focus()
  294. {
  295. var o=this
  296. o.arrow.focus()
  297. }
  298. // ================================================================================
  299. function IconMenuWidget_disableMenu(b)
  300. {
  301. var o=this
  302. o.arrow.setDisabled(b)
  303. o.menu.setDisabled(b)
  304. }
  305. // ================================================================================
  306. function IconMenuWidget_getMenu()
  307. {
  308. return this.menu
  309. }
  310. // ================================================================================
  311. function IconWidget_none()
  312. {
  313. }
  314. // ================================================================================
  315. function IconMenuWidget_init()
  316. {
  317. var o=this
  318. o.menIcnOldInit()
  319. o.icon.init()
  320. o.arrow.init()
  321. o.menu.init()
  322. var l=o.layer
  323. l.onmouseover=IconMenuWidget_OverCB
  324. l.onmouseout=IconMenuWidget_OutCB
  325. }
  326. // ================================================================================
  327. function IconMenuWidget_getHTML()
  328. {
  329. var o=this,d=o.disp?"":"display:none;"
  330. return '<table id="'+o.id+'" cellspacing="0" cellpadding="0" border="0" style="'+d+'margin:'+o.margin+'px"><tr><td>'+o.icon.getHTML()+'</td><td style="padding-left:'+o.spc+'px" width="'+(13+o.spc)+'">'+o.arrow.getHTML()+'</td></table>'
  331. }
  332. // ================================================================================
  333. function IconMenuWidget_OverCB()
  334. {
  335. IconMenuWidgetOverCB(getWidget(this).index)
  336. return true
  337. }
  338. // ================================================================================
  339. function IconMenuWidget_OutCB()
  340. {
  341. IconMenuWidgetOutCB(getWidget(this).index)
  342. }
  343. // ================================================================================
  344. function IconMenuWidgetOverCB(i)
  345. {
  346. o=_allBOIconsMenus[i]
  347. IconWidget_overCB(o.icon.index)
  348. IconWidget_overCB(o.arrow.index)
  349. }
  350. // ================================================================================
  351. function IconMenuWidgetOutCB(i)
  352. {
  353. o=_allBOIconsMenus[i]
  354. if (!o.menu.isShown())
  355. {
  356. IconWidget_outCB(o.icon.index)
  357. IconWidget_outCB(o.arrow.index)
  358. }
  359. else
  360. {
  361. IconWidget_overCB(o.icon.index)
  362. IconWidget_overCB(o.arrow.index)
  363. }
  364. }
  365. // ================================================================================
  366. function IconMenuWidget_iconClickCB()
  367. {
  368. var o=this.par
  369. if (o.clickCB==null)
  370. {
  371. var l=o.layer
  372. var position = getPos2(l);
  373. o.menu.show(!o.menu.isShown(),position.x,position.y+o.getHeight()+1,null,null,o)
  374. IconMenuWidgetOverCB(o.index)
  375. }
  376. else
  377. o.clickCB()
  378. }
  379. // ================================================================================
  380. function IconMenuWidget_arrowClickCB()
  381. {
  382. var o=this.par,l=o.layer;
  383. var position = getPos2(l);
  384. o.menu.show(!o.menu.isShown(),position.x,position.y+o.getHeight()+1,null,null,o)
  385. IconMenuWidgetOverCB(o.index)
  386. }
  387. // ================================================================================
  388. function IconMenuWidget_hideCB()
  389. {
  390. var o=this.parIcon
  391. if(o.arrow) {
  392. o.arrow.focus();
  393. }
  394. IconMenuWidgetOutCB(o.index)
  395. }
  396. // ================================================================================
  397. // ================================================================================
  398. //
  399. // OBJECT newRadioIconMenuWidget (Constructor)
  400. //
  401. // like an Icon Widget but behave like radio widget except the button icon only is checked or not
  402. // menu.js must be included to use this component
  403. //
  404. // ================================================================================
  405. // ================================================================================
  406. /*
  407. function newRadioIconMenuWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy,radioIdx,attachMenuCB)
  408. // CONSTRUCTOR
  409. // id : [String] the icon id for DHTML processing
  410. // src : [String] the icon image url
  411. // clickCB : [Function - optional] callback called when clicking
  412. // text : [String - optional] icon text
  413. // alt : [String] icon tooltip
  414. // w : [int] visible image width
  415. // h : [int] visible image height
  416. // dx : [int - optional] horizontal offset in the image
  417. // dy : [int - optional] vertical offset in the image
  418. // disDx : [int - optional] horizontal offset for disabled state
  419. // disDy : [int - optional] vertical offset for disabled state
  420. // radioIdx : [int - optional] the index of the selected menuItem
  421. // attachMenuCB : [Function - optional] callback change dynamically the menu
  422. {
  423. var o=newIconMenuWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy,false)
  424. o.defDx=dx
  425. o.defDy=dy
  426. o.attachMenuCB=null
  427. if (attachMenuCB) {
  428. o.attachMenuCB=attachMenuCB
  429. o.arrow.clickCB=RadioIconMenuWidget_arrowClickCB
  430. }
  431. o.attachMenu=RadioIconMenuWidget_attachMenu
  432. o.updateButton=RadioIconMenuWidget_updateButton
  433. o.radioIdx=radioIdx?radioIdx:-1
  434. o.checked=radioIdx?true:false
  435. return o
  436. }
  437. // ================================================================================
  438. function RadioIconMenuWidget_arrowClickCB()
  439. {
  440. var o=this.par,l=o.layer
  441. o.attachMenuCB()
  442. o.menu.show(!o.menu.isShown(),getPosScrolled(l).x,getPosScrolled(l).y+o.getHeight()+1,null,null,o)
  443. IconMenuWidgetOverCB(o.index)
  444. }
  445. function RadioIconMenuWidget_updateButton(idx)
  446. {
  447. var o=this
  448. o.icon.dis=false
  449. if ((idx != null) && (idx > 0)) {
  450. if (o.radioIdx == idx) return
  451. o.radioIdx=idx
  452. o.checked=true
  453. dx=idx*16
  454. dy=0
  455. cn=o.icon.checkClass
  456. } else {
  457. o.checked=false
  458. dx=16
  459. dy=0
  460. cn=o.icon.nocheckClass
  461. o.radioIdx=0
  462. }
  463. if (o.icon)
  464. {
  465. var lyr=o.icon.layer
  466. if (lyr)
  467. {
  468. o.icon.changeImg(dx,dy)
  469. lyr.className=cn
  470. }
  471. }
  472. if (idx==null) o.setDisabled(true)
  473. //o.icon.
  474. }
  475. // ================================================================================
  476. function RadioIconMenuWidget_attachMenu(menu)
  477. // menu [MenuWidget] the menu to be attached
  478. // return [MenuWidget] the menu to be attached
  479. {
  480. var o=this
  481. o.par=null
  482. o.menu=menu
  483. menu.par=null
  484. menu.container=o
  485. //menu.par=o
  486. //menu.zIndex=o.par.zIndex+2
  487. return menu
  488. }
  489. // ================================================================================
  490. // Icon Color Menu Widget
  491. // ================================================================================
  492. function newIconColorMenuWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy, lastUsedColorsAr)
  493. {
  494. var o=newIconMenuWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy,true)
  495. o.setColor=IconColorMenuWidget_setColor
  496. o.getColor=IconColorMenuWidget_getColor
  497. o.icon.extraHTML='<div id="colSample_'+o.id+'" style="position:relative;top:-6px;left:2px;width:16px;height:4px;overflow:hidden;margin:0px"></div>'
  498. o.curColor=null
  499. o.sampleLayer=null
  500. o.clickColor=clickCB
  501. o.clickCB=null
  502. o.colOldSetDis=o.setDisabled
  503. o.setDisabled=IconColorMenuWidget_setDisabled
  504. o.showSample=IconColorMenuWidget_showSample
  505. o.changeTooltip=IconColorMenuWidget_changeTooltip
  506. var m=o.menu
  507. m.ac=m.addColor
  508. var cb=IconMenuWidget_internalCB
  509. var c1=m.addCheck("color_-1,-1,-1",_default,cb)
  510. c1.leftZoneClass="menuLeftPartColor"
  511. c1.leftZoneSelClass="menuLeftPartSel"
  512. _colorsArr = new Array()
  513. _colorsArr["0,0,0"]=_black
  514. _colorsArr["148,52,0"]=_brown
  515. _colorsArr["49,52,0"]=_oliveGreen
  516. _colorsArr["0,52,0"]=_darkGreen
  517. _colorsArr["0,52,99"]=_darkTeal
  518. _colorsArr["0,0,132"]=_navyBlue
  519. _colorsArr["49,52,148"]=_indigo
  520. _colorsArr["66,65,66"]=_darkGray
  521. _colorsArr["132,4,0"]=_darkRed
  522. _colorsArr["255,101,0"]=_orange
  523. _colorsArr["123,125,0"]=_darkYellow
  524. _colorsArr["0,125,0"]=_green
  525. _colorsArr["0,125,123"]=_teal
  526. _colorsArr["0,0,255"]=_blue
  527. _colorsArr["99,101,148"]=_blueGray
  528. _colorsArr["132,130,132"]=_mediumGray
  529. _colorsArr["255,0,0"]=_red
  530. _colorsArr["255,195,66"]=_lightOrange
  531. _colorsArr["148,199,0"]=_lime
  532. _colorsArr["49,150,99"]=_seaGreen
  533. _colorsArr["49,199,198"]=_aqua
  534. _colorsArr["49,101,255"]=_lightBlue
  535. _colorsArr["132,0,132"]=_violet
  536. _colorsArr["148,150,148"]=_gray
  537. _colorsArr["255,0,255"]=_magenta
  538. _colorsArr["255,199,0"]=_gold
  539. _colorsArr["255,255,0"]=_yellow
  540. _colorsArr["0,255,0"]=_brightGreen
  541. _colorsArr["0,255,255"]=_cyan
  542. _colorsArr["0,199,255"]=_skyBlue
  543. _colorsArr["148,52,99"]=_plum
  544. _colorsArr["198,195,198"]=_lightGray
  545. _colorsArr["255,178,181"]=_pink
  546. _colorsArr["255,199,148"]=_tan
  547. _colorsArr["255,255,206"]=_lightYellow
  548. _colorsArr["206,255,206"]=_lightGreen
  549. _colorsArr["206,255,255"]=_lightTurquoise
  550. _colorsArr["148,199,255"]=_paleBlue
  551. _colorsArr["198,150,255"]=_lavender
  552. _colorsArr["255,255,255"]=_white
  553. with (m)
  554. {
  555. for (var i in _colorsArr) {
  556. ac(_colorsArr[i],i,cb)
  557. }
  558. }
  559. if (lastUsedColorsAr)
  560. {
  561. m.addLastUsed(_lastUsed,lastUsedColorsAr, cb)
  562. }
  563. c1=m.add(null,_moreColors,cb)
  564. c1.leftZoneClass="menuLeftPartColor"
  565. c1.leftZoneSelClass="menuLeftPartSel"
  566. return o
  567. }
  568. // ================================================================================
  569. function IconColorMenuWidget_setColor(color)
  570. {
  571. var o=this,menu=o.menu
  572. menu.uncheckAll()
  573. o.curColor=color
  574. if (color!=null)
  575. {
  576. var id="color_"+color
  577. var items=menu.items
  578. for (var i in items)
  579. {
  580. var item=items[i]
  581. if ((item.menuItemType && (item.menuItemType == _isLastUsedColor) && (color == menu.lastUsedColorsAr[item.idx])) || (item.id==id)){
  582. item.check(true)
  583. break
  584. }
  585. }
  586. }
  587. o.showSample()
  588. }
  589. // ================================================================================
  590. function IconColorMenuWidget_showSample()
  591. {
  592. var o=this
  593. if (o.layer)
  594. {
  595. if (o.sampleLayer==null)
  596. o.sampleLayer=getLayer('colSample_'+o.id)
  597. o.sampleLayer.style.backgroundColor=((o.curColor!='-1,-1,-1')&&(o.curColor!=null)) ? 'rgb('+o.curColor+')' : ''
  598. }
  599. }
  600. // ================================================================================
  601. function IconColorMenuWidget_setDisabled(dis)
  602. {
  603. this.colOldSetDis(dis)
  604. if (this.layer)
  605. this.showSample()
  606. }
  607. // ================================================================================
  608. function IconColorMenuWidget_getColor()
  609. {
  610. return this.curColor
  611. }
  612. // ================================================================================
  613. function IconColorMenuWidget_changeTooltip(s)
  614. {
  615. var o=this
  616. if (s==null) return;
  617. if (o.icon && o.arrow) {
  618. o.icon.alt=s;
  619. o.icon.changeTooltip(s)
  620. o.arrow.changeTooltip(_openMenuPart1+ s +_openMenuPart2)
  621. }
  622. }
  623. */
  624. // ================================================================================
  625. // ================================================================================
  626. //
  627. // OBJECT newIconCheckWidget (Constructor)
  628. //
  629. // Display an icon with check box behaviour. It can be used in a palette for
  630. // instance. The image can be a sub-part of a bigger image
  631. // (use dx and dy to define offset)
  632. //
  633. // ================================================================================
  634. // ================================================================================
  635. function newIconCheckWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy)
  636. // CONSTRUCTOR
  637. // id : [String] the icon id for DHTML processing
  638. // src : [String] the icon image url
  639. // clickCB : [Function - optional] callback called when clicking
  640. // text : [String - optional] icon text
  641. // alt : [String] icon tooltip
  642. // w : [int] visible image width
  643. // h : [int] visible image height
  644. // dx : [int - optional] horizontal offset in the image
  645. // dy : [int - optional] vertical offset in the image
  646. // disDx : [int - optional] horizontal offset for disabled state
  647. // disDy : [int - optional] vertical offset for disabled state
  648. {
  649. var o=newIconWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy)
  650. o.checked=false
  651. o.internalUpCB=IconCheckWidget_internalUpCB
  652. o.internalDownCB=IconCheckWidget_internalDownCB
  653. o.check=IconCheckWidget_check
  654. o.isChecked=IconCheckWidget_isChecked
  655. //o.setIcon=IconCheckWidget_setIcon
  656. o.oldInit=o.init
  657. o.init=IconCheckWidget_init
  658. o.isRadio=false
  659. return o
  660. }
  661. // ================================================================================
  662. // ================================================================================
  663. //
  664. // OBJECT newIconToggleWidget (Constructor)
  665. //
  666. // Display an icon with toggle behaviour, ie. if selected a different images is shown. It can be used in a palette for
  667. // instance. The image can be a sub-part of a bigger image
  668. // (use dx and dy to define offset)
  669. //
  670. // ================================================================================
  671. // ================================================================================
  672. /*
  673. function newIconToggleWidget(id,src,clickCB,text,alt,w,h,dx,dy,togX,togY,disDx,disDy)
  674. // CONSTRUCTOR
  675. // id : [String] the icon id for DHTML processing
  676. // src : [String] the icon image url
  677. // clickCB : [Function - optional] callback called when clicking
  678. // text : [String - optional] icon text
  679. // alt : [String] icon tooltip
  680. // w : [int] visible image width
  681. // h : [int] visible image height
  682. // dx : [int] horizontal offset in the image
  683. // dy : [int] vertical offset in the image
  684. // togX : [int] horizontal offset 2nd image
  685. // togY : [int] vertical offset 2nd image
  686. // disDx : [int - optional] horizontal offset for disabled state
  687. // disDy : [int - optional] vertical offset for disabled state
  688. {
  689. var o=newIconWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy)
  690. o.togX = togX
  691. o.togY = togY
  692. o.checked=false
  693. o.internalUpCB=IconToggleWidget_internalUpCB
  694. o.internalDownCB=IconToggleWidget_internalDownCB
  695. o.check=IconToggleWidget_check
  696. o.isChecked=IconCheckWidget_isChecked
  697. //o.setIcon=IconCheckWidget_setIcon
  698. o.oldInit=o.init
  699. o.init=IconCheckWidget_init
  700. o.isRadio=false
  701. return o
  702. }
  703. // ================================================================================
  704. // ================================================================================
  705. //
  706. // OBJECT newIconRadioWidget (Constructor)
  707. //
  708. // Display an icon with radio button behaviour. It can be used in a palette for
  709. // instance. The image can be a sub-part of a bigger image
  710. // (use dx and dy to define offset)
  711. //
  712. // ================================================================================
  713. // ================================================================================
  714. function newIconRadioWidget(id,src,clickCB,text,alt,group,w,h,dx,dy,disDx,disDy)
  715. // CONSTRUCTOR
  716. // id : [String] the icon id for DHTML processing
  717. // src : [String] the icon image url
  718. // clickCB : [Function - optional] callback called when clicking
  719. // text : [String - optional] icon text
  720. // alt : [String] icon tooltip
  721. // group : [String] icon group - select an icon in a group deselects
  722. // the other icons
  723. // w : [int] visible image width
  724. // h : [int] visible image height
  725. // dx : [int - optional] horizontal offset in the image
  726. // dy : [int - optional] vertical offset in the image
  727. // disDx : [int - optional] horizontal offset for disabled state
  728. // disDy : [int - optional] vertical offset for disabled state
  729. {
  730. var o=newIconCheckWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy)
  731. o.group=group
  732. o.beforeClickCB=IconRadioWidget_uncheckOthers
  733. o.isRadio=true
  734. if (_RadioWidget_groups[group]==null)
  735. _RadioWidget_groups[group]=new Array
  736. o.groupInstance=_RadioWidget_groups[group]
  737. var g=o.groupInstance
  738. o.groupIdx=g.length
  739. g[g.length]=o
  740. return o
  741. }
  742. */
  743. // ================================================================================
  744. // ================================================================================
  745. //
  746. // OBJECT newPaletteContainerWidget (Constructor)
  747. //
  748. // This object is a container for multiple palettes
  749. //
  750. // ================================================================================
  751. // ================================================================================
  752. function newPaletteContainerWidget(id,contextMenu,margin)
  753. // CONSTRUCTOR
  754. // id : [String] the icon id for DHTML processing
  755. {
  756. var o=newWidget(id)
  757. o.beginHTML=PaletteContainerWidget_beginHTML
  758. o.endHTML=PaletteContainerWidget_endHTML
  759. o.add=PaletteContainerWidget_add
  760. o.palettes=new Array
  761. o.contextMenu=contextMenu
  762. o.margin=(margin!=null)?margin:4
  763. return o
  764. }
  765. // ================================================================================
  766. // ================================================================================
  767. //
  768. // OBJECT newPaletteWidget (Constructor)
  769. //
  770. // This object is an horizontal palette, designed to be uses in a palette
  771. // container (see newPaletteContainerWidget)
  772. //
  773. // ================================================================================
  774. // ================================================================================
  775. function newPaletteWidget(id,height)
  776. // CONSTRUCTOR
  777. // id : [String] the icon id for DHTML processing
  778. // height [int - optional] : minimum palette height
  779. {
  780. var o=newWidget(id)
  781. o.getHTML=PaletteWidget_getHTML
  782. o.add=PaletteWidget_add
  783. o.disableChildren=PaletteWidget_disableChildren
  784. o.items=new Array
  785. o.oldInit=o.init
  786. o.init=PaletteWidget_init
  787. o.beginRightZone=PaletteWidget_beginRightZone
  788. o.height=height
  789. o.rightZoneIndex=-1
  790. o.sepCount=0
  791. o.vertPadding=4
  792. return o
  793. }
  794. // ================================================================================
  795. // ================================================================================
  796. //
  797. // OBJECT newPaletteSepWidget (Constructor)
  798. //
  799. // This object is a vertical separator used in a palette
  800. //
  801. // ================================================================================
  802. // ================================================================================
  803. function newPaletteSepWidget(id)
  804. // CONSTRUCTOR
  805. // id : [String] the icon id for DHTML processing
  806. {
  807. var o=newWidget(id)
  808. o.getHTML=PaletteSepWidget_getHTML
  809. o.isSeparator=true
  810. return o
  811. }
  812. // ================================================================================
  813. function newPaletteVerticalSepWidget(id)
  814. // CONSTRUCTOR
  815. // id : [String] the icon id for DHTML processing
  816. {
  817. var o=newWidget(id)
  818. o.getHTML=PaletteVerticalSepWidget_getHTML
  819. o.isSeparator=true
  820. return o
  821. }
  822. function PaletteVerticalSepWidget_getHTML()
  823. {
  824. return img(_skin+"iconsep.gif",6,22,null,' id="'+this.id+'" ')
  825. }
  826. // ================================================================================
  827. function getPaletteSep()
  828. // returns [String] the HTML of a vertical palette separator
  829. {
  830. return img(_skin+"iconsep.gif",6,22)
  831. }
  832. // ================================================================================
  833. function IconRadioWidget_uncheckOthers()
  834. // PRIVATE
  835. {
  836. var g=this.groupInstance,idx=this.groupIdx,len=g.length;
  837. for (var i=0;i<len;i++)
  838. {
  839. if (i!=idx)
  840. {
  841. var c=g[i];
  842. if(c)
  843. c.check(false);
  844. }
  845. }
  846. }
  847. // ================================================================================
  848. function PaletteWidget_beginRightZone()
  849. // begin the right zone of a palette. All added element will be right-aligned
  850. // after this call. This function must be called once in a giver palette
  851. {
  852. this.rightZoneIndex=this.items.length
  853. }
  854. // ================================================================================
  855. function PaletteSepWidget_getHTML()
  856. // returns [String] the HTML of a palette separator
  857. {
  858. return '<div style="background-image:url('+_skin+'sep.gif);height:2px;padding:0px;margin-top:0px;margin-bottom:0px;margin-left:4px;margin-right:4px">'+getSpace(1,2)+'</div>'
  859. }
  860. // ================================================================================
  861. function PaletteContainerWidget_beginHTML()
  862. // returns [String] the begining HTML of a palette container widget
  863. {
  864. var o=this
  865. var cm=o.contextMenu?('oncontextmenu="'+_codeWinName+'.PaletteContainerWidget_contextMenu(this,event);return false"'):''
  866. return '<div '+cm+ 'class="palette" style="overflow:hidden;margin:'+o.margin+'px;" id="'+o.id+'">'
  867. }
  868. _delayedMenu=null
  869. // ================================================================================
  870. function PaletteContainerWidget_contextMenu(o,e)
  871. // PRIVATE
  872. {
  873. if (_ie)
  874. e=_curWin.event
  875. _delayedMenu=getWidget(o).contextMenu
  876. setTimeout('_delayedMenu.par=null;_delayedMenu.show(true,'+absxpos(e)+','+absypos(e)+')',1)
  877. }
  878. // ================================================================================
  879. function PaletteContainerWidget_endHTML()
  880. // returns [String] the end HTML of a palette container widget
  881. {
  882. return '</div>'
  883. }
  884. // ================================================================================
  885. function PaletteContainerWidget_add(palette)
  886. // add a palette in a palette container widget. The palette is horizontal
  887. // and will be displayed at the bottom of the container
  888. // return [String] the HTML
  889. {
  890. this.palettes[this.palettes.length]=palette
  891. return palette
  892. }
  893. // ================================================================================
  894. function PaletteWidget_getHTML()
  895. // return [String] the HTML
  896. {
  897. var o=this,items=o.items,len=items.length,fields=new Array;j=0
  898. fields[j++]='<table style="position:relative;overflow:hidden" id="'+o.id+'" '+attr("height",o.height)+' cellspacing="0" cellpadding="0" '+(_ie?"":'width="100%"')+'><tbody><tr valign="middle">'
  899. fields[j++]='<td align="left" style="padding-left:'+o.vertPadding+'px;padding-right:4px"><table cellspacing="0" cellpadding="0"><tbody><tr valign="middle">'
  900. var haveRightZone=false
  901. for (var i=0;i<len;i++)
  902. {
  903. if (i==o.rightZoneIndex)
  904. {
  905. fields[j++]='</tr></tbody></table></td><td width="100%" align="right" style="padding-right:'+o.vertPadding+'px"><table cellspacing="0" cellpadding="0"><tbody><tr valign="middle">'
  906. haveRightZone=true
  907. }
  908. var it=items[i]
  909. //fields[j++]='<td>'+(it?it.getHTML():getPaletteSep())+'</td>'
  910. fields[j++]='<td>'+it.getHTML()+'</td>'
  911. }
  912. if (!haveRightZone)
  913. fields[j++]='</tr></tbody></table></td><td width="100%" align="right" style="padding-right:4px"><table cellspacing="0" cellpadding="0"><tbody><tr valign="middle"><td></td>'
  914. fields[j++]='</tr></tbody></table></td></tr></tbody></table>'
  915. return fields.join("")
  916. }
  917. // ================================================================================
  918. function PaletteWidget_add(item)
  919. // add an item into a palette. this element is a standard widget, with a valid
  920. // getHTML function. For layout reasons, use only widget that are nor too high
  921. // palette [PaletteWidget}
  922. {
  923. if(item==null)
  924. {
  925. item=newPaletteVerticalSepWidget(this.id+"_palettesep_"+(this.sepCount++))
  926. }
  927. this.items[this.items.length]=item
  928. return item
  929. }
  930. // ================================================================================
  931. function PaletteWidget_disableChildren(dis)
  932. {
  933. var items=this.items
  934. for (var i in items)
  935. {
  936. var item=items[i]
  937. if (item&&(item.isSep!=true))
  938. item.setDisabled(dis)
  939. }
  940. }
  941. // ================================================================================
  942. function PaletteWidget_init()
  943. // inits a palette widget (ie get all layers, style for dynamic management)
  944. // return [String] the HTML
  945. {
  946. this.oldInit()
  947. var items=this.items
  948. for (var i in items)
  949. {
  950. var item=items[i]
  951. if (item)
  952. item.init()
  953. }
  954. }
  955. // ================================================================================
  956. function IconWidget_isDisplayed()
  957. {
  958. return this.disp
  959. }
  960. // ================================================================================
  961. function IconWidget_setDisplay(d)
  962. {
  963. var o=this
  964. if (o.css)
  965. {
  966. var ds=d?"block":"none"
  967. if (o.css.display!=ds)
  968. o.css.display=ds
  969. }
  970. o.disp=d
  971. }
  972. // ================================================================================
  973. function IconWidget_getTxtWidth()
  974. {
  975. var o=this,w=o.width
  976. if (w!=null)
  977. {
  978. w=w-(o.margin*2) // remove table margin
  979. w=w-(o.src?o.w+o.border:1) // Image size
  980. w=w-(o.txtNoPadding?0:((o.src?4:2)+2))
  981. if (_ie)
  982. w-=2
  983. else
  984. w-=2
  985. return Math.max(0,w)
  986. }
  987. else
  988. return -1
  989. }
  990. // ================================================================================
  991. function IconWidget_init()
  992. {
  993. var o=this,dblClick=false
  994. o.iconOldInit()
  995. var l=o.layer
  996. //manage focus for 508
  997. l.tabIndex=o.dis?-1:0
  998. //manage tooltip for 508
  999. l.title=(o.alt?o.alt:(o.text?o.text:""))
  1000. // attach callbacks
  1001. if (o.clickCB)
  1002. {
  1003. l.onclick=IconWidget_upCB
  1004. l.onmousedown=IconWidget_downCB
  1005. if (o.allowDblClick&&(_ie||_saf))
  1006. {
  1007. dblClick=true
  1008. addDblClickCB(l,IconWidget_upCB)
  1009. }
  1010. l.onkeydown=IconWidget_keydownCB
  1011. l.onmouseover=IconWidget_realOverCB
  1012. l.onmouseout=IconWidget_realOutCB
  1013. }
  1014. if (!dblClick)
  1015. addDblClickCB(l,IconWidget_retFalse)
  1016. l.onselectstart=IconWidget_retFalse
  1017. var d=o.disp?"block":"none"
  1018. if (o.css.display!=d)
  1019. o.css.display=d
  1020. }
  1021. // ================================================================================
  1022. function IconWidget_getHTML()
  1023. // returns [String] the HTML of an icon widget
  1024. {
  1025. var o=this,imgCode=o.src?'<div style="overflow:hidden;height:'+(o.h+o.border)+'px;width:'+(o.w+o.border)+'px;">'+simpleImgOffset(o.src,o.w,o.h,o.dis?o.disDx:o.dx,o.dis?o.disDy:o.dy,'IconImg_'+o.id,null,o.alt,'margin:2px;cursor:'+(o.clickCB ? (!o.acceptClick() ? 'default' : _hand):'default'))+o.extraHTML+'</div>':'<div class="icontext" style="width:1px;height:'+(o.h+o.border)+'px"></div>'
  1026. var txtAtt='style="white-space:nowrap;',txtW=o.getTxtWidth()
  1027. if (txtW>=0)
  1028. txtAtt+='text-overflow:ellipsis;overflow:hidden;width:'+txtW+'px'
  1029. txtAtt+='"'
  1030. var d=o.disp?"":"display:none;"
  1031. return '<table style="'+d+'height:'+(o.h+o.border+(_moz?2:0))+'px;'+(o.width!=null?"width:"+o.width+"px;":"")+'margin:'+o.margin+'px" id="'+o.id+'" class="' + o.nocheckClass + '" cellspacing="0" cellpadding="0" border="0"><tr valign="middle">'+
  1032. '<td>'+ ((o.clickCB&&_ie)?lnk(imgCode,null,null,null, ' tabIndex="-1"' ):imgCode)+'</td>'+
  1033. (o.text?'<td align="'+o.txtAlign+'" style="padding-left:'+(o.txtNoPadding?0:(o.src?4:2))+'px;padding-right:'+(o.txtNoPadding?0:2)+'px"><div id="IconImg_Txt_'+o.id+'" class="icontext'+(o.dis?"Dis":"")+'" '+txtAtt+'>'+convStr(o.text)+'</div></td>':'')+
  1034. '</tr></table>'
  1035. }
  1036. // ================================================================================
  1037. function IconWidget_realOutCB()
  1038. {
  1039. var o=getWidget(this)
  1040. eval(o.outCB+'('+o.index+')')
  1041. }
  1042. // ================================================================================
  1043. function IconWidget_realOverCB()
  1044. {
  1045. var o=getWidget(this)
  1046. eval(o.overCB+'('+o.index+')')
  1047. return true
  1048. }
  1049. // ================================================================================
  1050. function IconWidget_retFalse()
  1051. // PRIVATE
  1052. {
  1053. return false
  1054. }
  1055. // ================================================================================
  1056. function IconWidget_resize(w,h)
  1057. {
  1058. var o=this
  1059. if (o.layer)
  1060. o.oldRes(w,h)
  1061. if (o.txtLayer==null)
  1062. o.txtLayer=getLayer("IconImg_Txt_"+o.id)
  1063. if (w!=null)
  1064. {
  1065. o.width=w
  1066. var txtW=o.getTxtWidth()
  1067. if (o.txtLayer&&(txtW>=0))
  1068. {
  1069. o.txtLayer.style.width=''+txtW+'px'
  1070. }
  1071. }
  1072. if (h!=null)
  1073. {
  1074. o.h=h?(h-o.border):o.h
  1075. if (o.txtLayer&&(o.h>=0))
  1076. {
  1077. o.txtLayer.style.height=''+o.h+'px'
  1078. }
  1079. }
  1080. }
  1081. // ================================================================================
  1082. function IconWidget_changeTooltip(s,isTemporary)
  1083. // changes the tooltip of an icon widget
  1084. // s : [String] the new tooltip string.
  1085. {
  1086. var o=this
  1087. if (s==null) return;
  1088. if(!isTemporary)
  1089. o.alt=s;
  1090. if(o.layer)
  1091. o.layer.title=s
  1092. if (o.imgLayer==null)
  1093. o.imgLayer = getLayer('IconImg_'+this.id);
  1094. if (o.imgLayer)
  1095. changeSimpleOffset(o.imgLayer,null,null,null,s)
  1096. }
  1097. // ================================================================================
  1098. function IconWidget_changeText(s)
  1099. // Change the icon text
  1100. // s [String] : the new text
  1101. {
  1102. var o=this
  1103. o.text=s
  1104. if (o.layer)
  1105. {
  1106. if (o.txtLayer==null)
  1107. o.txtLayer=getLayer("IconImg_Txt_"+o.id)
  1108. o.txtLayer.innerHTML=convStr(s)
  1109. }
  1110. }
  1111. function IconWidget_changeImg(dx,dy,src)
  1112. {
  1113. var o=this
  1114. if (src) o.src=src
  1115. if (dx!=null) o.dx=dx
  1116. if (dy!=null) o.dy=dy
  1117. if (o.layer&&(o.imgLayer==null))
  1118. o.imgLayer = getLayer('IconImg_'+this.id);
  1119. if (o.imgLayer)
  1120. changeSimpleOffset(o.imgLayer,dx,dy,o.src)
  1121. }
  1122. // ================================================================================
  1123. function IconWidget_internalDownCB()
  1124. // PRIVATE
  1125. {
  1126. if (!this.dis)
  1127. this.currentHoverClass=this.checkhoverClass
  1128. }
  1129. // ================================================================================
  1130. function IconWidget_internalUpCB()
  1131. // PRIVATE
  1132. {
  1133. if (!this.dis)
  1134. this.currentHoverClass=this.hoverClass
  1135. }
  1136. // ================================================================================
  1137. function IconWidget_setCrs()
  1138. // PRIVATE
  1139. {
  1140. var o=this,crs=(o.clickCB ? (!o.acceptClick() ? 'default' : _hand) : 'default')
  1141. o.css.cursor=crs
  1142. if (o.src)
  1143. {
  1144. if (o.imgLayer==null)
  1145. o.imgLayer = getLayer('IconImg_'+o.id);
  1146. if (o.imgLayer) o.imgLayer.style.cursor=crs
  1147. }
  1148. }
  1149. // ================================================================================
  1150. function IconWidget_downCB()
  1151. // PRIVATE
  1152. {
  1153. var o=getWidget(this)
  1154. if ((o.layer)&&(o.acceptClick()))
  1155. {
  1156. o.internalDownCB()
  1157. o.layer.className=o.currentHoverClass
  1158. }
  1159. if (_ie||_saf)
  1160. return false
  1161. }
  1162. // ================================================================================
  1163. function IconWidget_upCB()
  1164. // PRIVATE
  1165. {
  1166. var o=getWidget(this)
  1167. if ((o.layer)&&(o.acceptClick()))
  1168. {
  1169. o.internalUpCB()
  1170. o.layer.className=o.isHover?o.currentHoverClass:o.currentClass
  1171. o.setCrs()
  1172. setTimeout("delayedClickCB("+o.index+")",1)
  1173. }
  1174. }
  1175. // ================================================================================
  1176. function IconWidget_keydownCB(e)
  1177. {
  1178. if(eventGetKey(e)==13) //enter
  1179. {
  1180. var o=getWidget(this)
  1181. if ((o.layer)&&(o.acceptClick()))
  1182. {
  1183. o.internalUpCB()
  1184. o.layer.className=o.isHover?o.currentHoverClass:o.currentClass
  1185. o.setCrs()
  1186. setTimeout("delayedClickCB("+o.index+")",1)
  1187. }
  1188. eventCancelBubble(e);//be careful ! usefull for dialog box close by Enter keypressed
  1189. }
  1190. }
  1191. // ================================================================================
  1192. function delayedClickCB(index)
  1193. // PRIVATE
  1194. {
  1195. var o=_allBOIcons[index]
  1196. if (o.beforeClickCB)
  1197. o.beforeClickCB()
  1198. if (o.clickCB)
  1199. o.clickCB()
  1200. }
  1201. // ================================================================================
  1202. function IconWidget_overCB(index)
  1203. // PRIVATE
  1204. {
  1205. var o=_allBOIcons[index]
  1206. o.setCrs()
  1207. if ((o.layer)&&(!o.dis)&&!(o.par && o.par.checked)) // if not button container and it is checked
  1208. {
  1209. o.isHover=true
  1210. o.layer.className=o.currentHoverClass
  1211. }
  1212. }
  1213. // ================================================================================
  1214. function IconWidget_outCB(index)
  1215. // PRIVATE
  1216. {
  1217. var o=_allBOIcons[index]
  1218. if ((o.layer)&&(o.outEnable)&&!(o.par && o.par.checked)) // if not button container and it is checked
  1219. {
  1220. o.isHover=false
  1221. o.layer.className=o.currentClass
  1222. }
  1223. }
  1224. // ================================================================================
  1225. function IconCheckWidget_init()
  1226. // inits an icon check widget (ie get all layers, style for dynamic management)
  1227. {
  1228. var o=this
  1229. o.oldInit()
  1230. o.check(o.checked,true)
  1231. }
  1232. // ================================================================================
  1233. function IconCheckWidget_internalDownCB()
  1234. // PRIVATE
  1235. {
  1236. var o=this
  1237. if (o.acceptClick())
  1238. o.currentHoverClass=o.checked?o.hoverClass:o.checkhoverClass
  1239. }
  1240. // ================================================================================
  1241. function IconCheckWidget_internalUpCB()
  1242. // PRIVATE
  1243. {
  1244. var o=this
  1245. if (o.acceptClick())
  1246. {
  1247. o.checked=o.isRadio?true:!o.checked
  1248. o.currentClass=o.checked?this.checkClass:this.nocheckClass
  1249. o.currentHoverClass=o.checked?this.checkhoverClass:this.hoverClass
  1250. }
  1251. }
  1252. /*
  1253. function IconToggleWidget_internalDownCB()
  1254. // PRIVATE
  1255. {
  1256. var o=this
  1257. if (o.acceptClick()) {
  1258. //o.currentHoverClass=o.checked?o.hoverClass:o.checkhoverClass
  1259. }
  1260. }
  1261. // ================================================================================
  1262. function IconToggleWidget_internalUpCB()
  1263. // PRIVATE
  1264. {
  1265. var o=this
  1266. if (o.acceptClick())
  1267. {
  1268. if (o.layer&&(o.imgLayer==null))
  1269. o.imgLayer = getLayer('IconImg_'+this.id);
  1270. if (!o.imgLayer) return
  1271. o.checked=!o.checked
  1272. if (o.checked)
  1273. {
  1274. changeSimpleOffset(o.imgLayer,o.togX,o.togY,o.src)
  1275. } else {
  1276. changeSimpleOffset(o.imgLayer,o.dx,o.dy,o.src)
  1277. }
  1278. }
  1279. }
  1280. */
  1281. // ================================================================================
  1282. function IconCheckWidget_check(checked,force)
  1283. // check or uncheck an icon check widget
  1284. // check : [boolean] specified if the check icon must be checked or not
  1285. // force : [boolean - optional] for internal purpose, do not use it
  1286. {
  1287. var o=this
  1288. if ((o.checked!=checked)||force)
  1289. {
  1290. o.checked=checked
  1291. if (o.layer)
  1292. {
  1293. o.layer.className=o.currentClass=o.checked?this.checkClass:this.nocheckClass
  1294. o.currentHoverClass=o.checked?this.checkhoverClass:this.hoverClass
  1295. }
  1296. }
  1297. if (o.checked&&o.beforeClickCB)
  1298. {
  1299. if (o.layer)
  1300. o.beforeClickCB()
  1301. }
  1302. }
  1303. // ================================================================================
  1304. /*
  1305. function IconToggleWidget_check(checked,force)
  1306. // check or uncheck an icon check widget
  1307. // check : [boolean] specified if the check icon must be checked or not
  1308. // force : [boolean - optional] for internal purpose, do not use it
  1309. {
  1310. var o=this
  1311. if ((o.checked!=checked)||force)
  1312. {
  1313. o.checked=checked
  1314. if (o.layer&&(o.imgLayer==null))
  1315. o.imgLayer = getLayer('IconImg_'+this.id);
  1316. if (!o.imgLayer) return
  1317. if (o.checked)
  1318. {
  1319. changeSimpleOffset(o.imgLayer,o.togX,o.togY,o.src)
  1320. } else {
  1321. changeSimpleOffset(o.imgLayer,o.dx,o.dy,o.src)
  1322. }
  1323. }
  1324. if (o.checked&&o.beforeClickCB)
  1325. {
  1326. if (o.layer)
  1327. o.beforeClickCB()
  1328. }
  1329. }
  1330. */
  1331. // ================================================================================
  1332. function IconCheckWidget_isChecked()
  1333. // return true if checked
  1334. {
  1335. return this.checked
  1336. }
  1337. // ================================================================================
  1338. function IconWidget_setClasses(nocheck, check, hover, checkhover)
  1339. // set the 4 CSS classes for an icon : check/no check, hover/no
  1340. // nocheck : [String] CSS class name for the no check state
  1341. // check : [String] CSS class name for the check state
  1342. // hover : [String] CSS class name for mouse over on a non checked icon
  1343. // checkhover : [String] CSS class name for mouse over on a checked icon
  1344. {
  1345. var o=this
  1346. o.nocheckClass=nocheck
  1347. o.checkClass=check
  1348. o.hoverClass=hover
  1349. o.checkhoverClass=checkhover
  1350. o.currentClass=o.nocheckClass
  1351. o.currentHoverClass=o.hoverClass
  1352. }
  1353. // ================================================================================
  1354. function IconWidget_setDisabled(dis)
  1355. // set the widget disabled (ie insensitive to mouse or keyboard events)
  1356. // dis : [String] if true, disables the widget
  1357. {
  1358. var o=this
  1359. if (o.dis!=dis)
  1360. {
  1361. o.dis=dis
  1362. if (o.layer)
  1363. {
  1364. o.setCrs()
  1365. if (o.src)
  1366. {
  1367. if (o.imgLayer==null)
  1368. o.imgLayer = getLayer('IconImg_'+this.id);
  1369. changeSimpleOffset(o.imgLayer,dis?o.disDx:o.dx,dis?o.disDy:o.dy)
  1370. }
  1371. if (o.text)
  1372. {
  1373. if (o.txtLayer==null)
  1374. o.txtLayer=getLayer("IconImg_Txt_"+o.id)
  1375. o.txtLayer.className="iconText"+(dis?"Dis":"")
  1376. if (dis)
  1377. o.layer.className=o.currentClass
  1378. }
  1379. //manage focus for 508
  1380. o.layer.tabIndex=o.dis?-1:0
  1381. }
  1382. }
  1383. }
  1384. // return treu if the Widget is disabled
  1385. //
  1386. function IconWidget_isDisabled()
  1387. {
  1388. return this.dis?this.dis:false
  1389. }
  1390. function IconWidget_acceptClick()
  1391. {
  1392. var o=this
  1393. if (o.isDisabled()) return false
  1394. if (o.isRadio&&o.checked) return false
  1395. return true
  1396. }
  1397. // ================================================================================
  1398. // ================================================================================
  1399. //
  1400. // OBJECT newCustomCombo (Constructor)
  1401. //
  1402. // This object is a container for multiple palettes
  1403. //
  1404. // ================================================================================
  1405. // ================================================================================
  1406. function newCustomCombo(id,changeCB,noMargin,width,tooltip,url,w,h,dx,dy,disDx,disDy)
  1407. {
  1408. var o=newIconMenuWidget(id,url,null," ",tooltip,w,h,dx,dy,disDx,disDy)
  1409. o.icon.width=width!=null?Math.max(0,width-13):50-(2*o.margin)
  1410. o.icon.setClasses("combonocheck", "combocheck", "combohover", "combocheck")
  1411. o.icon.clip
  1412. o.arrow.setClasses("iconnocheck", "combobtnhover", "combobtnhover", "combobtnhover")
  1413. o.spc=0
  1414. o.margin=2
  1415. if (url==null)
  1416. {
  1417. o.icon.h=12
  1418. o.arrow.h=12
  1419. o.arrow.dy+=2
  1420. o.arrow.disDy+=2
  1421. }
  1422. // Private attributes
  1423. o.counter=0
  1424. o.changeCB=changeCB
  1425. o.selectedItem=null
  1426. o.setOldDid=o.setDisabled
  1427. o.disabled=false
  1428. o.ccomboOldInit=o.init
  1429. // Public methods
  1430. o.init=CustomCombo_init
  1431. o.add=CustomCombo_add
  1432. o.addSeparator=CustomCombo_addSeparator
  1433. o.addMenuItem=CustomCombo_addMenuItem
  1434. o.select=CustomCombo_select
  1435. o.getSelection=CustomCombo_getSelection
  1436. o.valueShow=CustomCombo_valueShow
  1437. o.valueSelect=CustomCombo_valueSelect
  1438. o.setUndefined=CustomCombo_setUndefined
  1439. o.setDisabled=CustomCombo_setDisabled
  1440. o.getVisibleItemsCount=CustomCombo_getVisibleItemsCount
  1441. // Private methods
  1442. o.selectItem=CustomCombo_selectItem
  1443. o.getItemByIndex=CustomCombo_getItemByIndex
  1444. o.getItemIndex=CustomCombo_getItemIndex
  1445. o.setItemDisabled=CustomCombo_setItemDisabled
  1446. return o
  1447. }
  1448. // ================================================================================
  1449. function CustomCombo_init()
  1450. {
  1451. var o=this
  1452. o.ccomboOldInit()
  1453. if(o.disabled) o.icon.changeTooltip(o.icon.alt?o.icon.alt:"",true)
  1454. o.arrow.changeTooltip(_openMenuPart1+(o.icon.alt?o.icon.alt:"")+_openMenuPart2)
  1455. }
  1456. function CustomCombo_add(s,val,selected)
  1457. {
  1458. var o=this
  1459. var item=o.menu.addCheck(o.id+"_it_"+(o.counter++),s,CustomCombo_internalCB)
  1460. item.val=""+val
  1461. item.parCombo=o
  1462. item.isComboVal=true
  1463. if ((o.selectedItem==null)||selected)
  1464. o.selectItem(item)
  1465. }
  1466. // ================================================================================
  1467. function CustomCombo_addSeparator()
  1468. {
  1469. this.menu.addSeparator()
  1470. }
  1471. // ================================================================================
  1472. function CustomCombo_addMenuItem(id,text,cb,icon,dx,dy,disabled,disDx,disDy)
  1473. {
  1474. this.menu.add(id,text,cb,icon,dx,dy,disabled,disDx,disDy)
  1475. }
  1476. // ================================================================================
  1477. function CustomCombo_internalCB()
  1478. // PRIVATE
  1479. {
  1480. var o=this,c=o.parCombo
  1481. c.selectItem(o)
  1482. if (c.changeCB)
  1483. c.changeCB()
  1484. }
  1485. // ================================================================================
  1486. function CustomCombo_getItemByIndex(idx)
  1487. // PRIVATE
  1488. {
  1489. var items=this.menu.items
  1490. return ((idx>=0)&&(idx<items.length))?items[idx]:null
  1491. }
  1492. // ================================================================================
  1493. function CustomCombo_getItemIndex(item)
  1494. // PRIVATE
  1495. {
  1496. var items=this.menu.items,len=items.length,j=0
  1497. for (var i=0;i<len;i++)
  1498. {
  1499. var it=items[i]
  1500. if (it.isComboVal)
  1501. {
  1502. if (it.id==item.id)
  1503. return j
  1504. j++
  1505. }
  1506. }
  1507. return -1
  1508. }
  1509. // ================================================================================
  1510. function CustomCombo_selectItem(item)
  1511. // PRIVATE
  1512. {
  1513. var o=this
  1514. if (o.selectedItem)
  1515. o.selectedItem.check(false)
  1516. if (item)
  1517. {
  1518. o.val=item.val
  1519. o.icon.changeText(o.disabled?"":item.text)
  1520. o.selectedItem=item
  1521. item.check(true)
  1522. if(o.disabled)
  1523. o.icon.changeTooltip(o.icon.alt?o.icon.alt:"",true)
  1524. else
  1525. o.icon.changeTooltip(o.icon.alt?(o.icon.alt+' ('+item.text)+')':(item.text),true)
  1526. }
  1527. else
  1528. {
  1529. o.val=null
  1530. o.icon.changeText("")
  1531. o.icon.changeTooltip(o.icon.alt?o.icon.alt:"",true)
  1532. o.selectedItem=null
  1533. }
  1534. }
  1535. // ================================================================================
  1536. function CustomCombo_setDisabled(d)
  1537. {
  1538. var o=this
  1539. if (o.selectedItem)
  1540. o.icon.changeText(d?"":o.selectedItem.text)
  1541. o.disabled=d
  1542. o.setOldDid(d)
  1543. if(d) o.icon.changeTooltip(o.icon.alt?o.icon.alt:"",true)
  1544. }
  1545. // ================================================================================
  1546. function CustomCombo_select(idx)
  1547. // Select an item in the combo
  1548. // idx : item index (only items added by "add" function are taken in account)
  1549. // to allow menus combining combo items and menu action items
  1550. {
  1551. var o=this,item=o.getItemByIndex(idx)
  1552. if (item)
  1553. o.selectItem(item)
  1554. }
  1555. // ================================================================================
  1556. function CustomCombo_setItemDisabled(idx,disabled)
  1557. // Disable a specific item on the combo box
  1558. // idx [int] item index (only items added by "add" function are taken in account)
  1559. // disabled [boolean] disable if true
  1560. {
  1561. var o=this,item=o.getItemByIndex(idx)
  1562. if (item)
  1563. item.setDisabled(disabled)
  1564. }
  1565. // ================================================================================
  1566. function CustomCombo_getSelection()
  1567. {
  1568. var o=this,it=o.selectedItem
  1569. if (it)
  1570. return {index:o.getItemIndex(it),value:it.val}
  1571. else
  1572. return null
  1573. }
  1574. // ================================================================================
  1575. //return true if selection can be done
  1576. function CustomCombo_valueSelect(v)
  1577. {
  1578. v=""+v
  1579. var o=this,items=o.menu.items,len=items.length
  1580. for (var i=0;i<len;i++)
  1581. {
  1582. var it=items[i]
  1583. if ((it.isComboVal)&&(it.val==v)&&(it.isShown) )
  1584. {
  1585. o.selectItem(it)
  1586. return true
  1587. }
  1588. }
  1589. return false
  1590. }
  1591. // ================================================================================
  1592. function CustomCombo_valueShow(v,show)
  1593. {
  1594. v=""+v
  1595. var o=this,items=o.menu.items,len=items.length
  1596. for (var i=0;i<len;i++)
  1597. {
  1598. var it=items[i]
  1599. if ((it.isComboVal)&&(it.val==v))
  1600. {
  1601. it.show(show)
  1602. return
  1603. }
  1604. }
  1605. }
  1606. // ================================================================================
  1607. function CustomCombo_setUndefined(u)
  1608. {
  1609. var o=this
  1610. if (u)
  1611. o.selectItem(null)
  1612. }
  1613. // ================================================================================
  1614. //by default, return the count of shown elements of type isComboVal
  1615. function CustomCombo_getVisibleItemsCount()
  1616. {
  1617. var o=this,items=o.menu.items,len=items.length,n=0
  1618. for (var i=0;i<len;i++)
  1619. {
  1620. var it=items[i]
  1621. if ((it.isComboVal)&&(it.isShown))
  1622. {
  1623. n++
  1624. }
  1625. }
  1626. return n;
  1627. }
  1628. // ================================================================================
  1629. // ================================================================================
  1630. //
  1631. // OBJECT newCustomTextFieldWidget (Constructor)
  1632. //
  1633. // This object is a Textfield followed by an IconMenuWidget
  1634. //
  1635. // ================================================================================
  1636. // ================================================================================
  1637. function newComboTextFieldWidget(id,changeCB,maxChar,keyUpCB,enterCB,noMargin,tooltip,width,focusCB,blurCB)
  1638. {
  1639. var o=newTextFieldWidget(id,changeCB,maxChar,keyUpCB,enterCB,noMargin,tooltip,width,focusCB,blurCB)
  1640. o.par=null
  1641. o.oldInit=o.init
  1642. o.init=ComboTextFieldWidget_init
  1643. o.setContentEditable=ComboTextFieldWidget_setContentEditable
  1644. o.isContentEditable=ComboTextFieldWidget_isContentEditable
  1645. o.getHTML=ComboTextFieldWidget_getHTML
  1646. o.oldSetDisabled=o.setDisabled
  1647. o.setDisabled=ComboTextFieldWidget_setDisabled
  1648. return o
  1649. }
  1650. // ================================================================================
  1651. function ComboTextFieldWidget_init()
  1652. {
  1653. var o=this
  1654. o.oldInit()
  1655. var l=o.layer
  1656. if (l!=null)
  1657. {
  1658. o.setContentEditable(true)
  1659. l.onclick=ComboTextFieldWidget_onClick
  1660. }
  1661. }
  1662. // ================================================================================
  1663. function ComboTextFieldWidget_setContentEditable(d)
  1664. {
  1665. var o=this, l=o.layer
  1666. o.contentEditable=d
  1667. if (l)
  1668. {
  1669. l.contentEditable=d
  1670. l.style.cursor=d?'text':_hand
  1671. l.className=d?'comboEditable':'combo'
  1672. }
  1673. }
  1674. // ================================================================================
  1675. function ComboTextFieldWidget_isContentEditable()
  1676. {
  1677. var o=this
  1678. return o.contentEditable
  1679. }
  1680. // ================================================================================
  1681. function ComboTextFieldWidget_onClick()
  1682. {
  1683. var o=getWidget(this)
  1684. if (o.contentEditable)
  1685. return
  1686. if (o.par!=null)
  1687. o.par.clickCB()
  1688. }
  1689. // ================================================================================
  1690. function ComboTextFieldWidget_getHTML()
  1691. {
  1692. var o=this
  1693. return '<input'+(o.disabled?' disabled':'')+' oncontextmenu="event.cancelBubble=true;return true" style="'+sty("width",this.width)+(_moz?'margin-top:1px;margin-bottom:1px;padding-left:2px;padding-right:2px;':'')+ (_isQuirksMode ? 'height:18px;' : 'height:14px;') + 'margin-left:'+(this.noMargin?0:10)+'px" onfocus="'+_codeWinName+'.TextFieldWidget_focus(this)" onblur="'+_codeWinName+'.TextFieldWidget_blur(this)" onchange="'+_codeWinName+'.TextFieldWidget_changeCB(event,this)" onkeydown=" return '+_codeWinName+'.TextFieldWidget_keyDownCB(event,this);" onkeyup=" return '+_codeWinName+'.TextFieldWidget_keyUpCB(event,this);" onkeypress=" return '+_codeWinName+'.TextFieldWidget_keyPressCB(event,this);" type="text" '+attr('maxLength',this.maxChar)+' ondragstart="event.cancelBubble=true;return true" onselectstart="event.cancelBubble=true;return true" class="combo" id="'+this.id+'" name="'+this.id+'"'+attr('title',this.tooltip)+' value="">'
  1694. }
  1695. // ================================================================================
  1696. function ComboTextFieldWidget_setDisabled(d)
  1697. {
  1698. var o=this
  1699. o.oldSetDisabled(d)
  1700. //o.layer.className=d?'comboDisabled':'combo'
  1701. }
  1702. // ================================================================================
  1703. // ================================================================================
  1704. //
  1705. // OBJECT newTextComboWidget (Constructor)
  1706. //
  1707. // This object is a Textfield followed by an IconMenuWidget
  1708. //
  1709. // ================================================================================
  1710. // ================================================================================
  1711. function newTextComboWidget(id,maxChar,tooltip,w,changeCB,checkCB,beforeShowCB,formName)
  1712. // CONSTRUCTOR
  1713. // id : [String] the icon id for DHTML processing
  1714. // maxChar : [int] text field maximum length
  1715. // tooltip : [String] arrow icon tooltip
  1716. // w : [int] TextComboWidget width
  1717. // changeCB : [Function - optional] callback called when selecting or typing a value
  1718. // checkCB : [Function - optional] callback called when typing a value to check its validity
  1719. // beforeShowCB : [Function - optional] callback called before showing the menu
  1720. // formName : [String - optional] specify a specific ID/Name for using the text fielad inside a form
  1721. {
  1722. var o=newWidget(id)
  1723. // basic widgets
  1724. o.text=newComboTextFieldWidget((formName?formName:"text_"+id),TextComboWidget_checkCB,maxChar,null/*keyUpCB*/,TextComboWidget_enterCB,true,tooltip,w-13)
  1725. o.arrow=newIconWidget("arrow_"+id,_skin+"menus.gif",TextComboWidget_arrowClickCB,null,(_openMenuPart1+(tooltip?tooltip:"")+_openMenuPart2),7,16,0,81,0,97)
  1726. o.menu=newMenuWidget("menu_"+id,TextComboWidget_hideCB,beforeShowCB)
  1727. o.arrow.setClasses("iconnocheck", "combobtnhover", "combobtnhover", "combobtnhover")
  1728. // set the parent
  1729. o.text.par=o
  1730. o.arrow.par=o
  1731. o.menu.parIcon=o
  1732. // properties
  1733. o.arrow.margin=0
  1734. o.arrow.overCB="IconWidget_none"
  1735. o.arrow.outCB="IconWidget_none"
  1736. o.margin=0
  1737. o.spc=0
  1738. o.counter=0
  1739. // to align the text field and arrow icon
  1740. o.arrow.h=12
  1741. o.arrow.dy+=2
  1742. o.arrow.disDy+=2
  1743. o.index=_allBOIconsMenus.length++
  1744. _allBOIconsMenus[o.index]=o
  1745. // public methods
  1746. o.menIcnOldInit=o.init
  1747. o.init=TextComboWidget_init
  1748. o.imwpResize=o.resize
  1749. o.resize=TextComboWidget_resize
  1750. o.getHTML=TextComboWidget_getHTML
  1751. o.setDisabled=TextComboWidget_setDisabled
  1752. o.isDisabled=TextComboWidget_isDisabled
  1753. o.add=TextComboWidget_add
  1754. o.addSeparator=TextComboWidget_addSeparator
  1755. o.addMenuItem=TextComboWidget_addMenuItem
  1756. o.select=TextComboWidget_select
  1757. o.getSelection=TextComboWidget_getSelection
  1758. o.valueShow=TextComboWidget_valueShow
  1759. o.valueSelect=TextComboWidget_valueSelect
  1760. o.setUndefined=TextComboWidget_setUndefined
  1761. o.setContentEditable=TextComboWidget_setContentEditable
  1762. o.isContentEditable=TextComboWidget_isContentEditable
  1763. // private methods
  1764. o.changeCB=changeCB
  1765. o.checkCB=checkCB
  1766. o.clickCB=TextComboWidget_clickCB
  1767. o.selectItem=TextComboWidget_selectItem
  1768. o.getItemByIndex=TextComboWidget_getItemByIndex
  1769. o.getItemIndex=TextComboWidget_getItemIndex
  1770. o.setItemDisabled=TextComboWidget_setItemDisabled
  1771. o.text.enterCancelBubble=false
  1772. return o
  1773. }
  1774. // ================================================================================
  1775. function TextComboWidget_init()
  1776. // Initialize the TextIconMenuWidget
  1777. {
  1778. var o=this
  1779. o.menIcnOldInit()
  1780. o.text.init()
  1781. o.arrow.init()
  1782. o.menu.init()
  1783. var l=o.layer
  1784. l.onmouseover=TextCombo_OverCB
  1785. l.onmouseout=TextCombo_OutCB
  1786. }
  1787. // ================================================================================
  1788. function TextComboWidget_getHTML()
  1789. // Return the HTML of the TextIconMenuWidget
  1790. {
  1791. var o=this, s=''
  1792. s+='<table id="'+o.id+'" cellspacing="0" cellpadding="0" border="0" style="cursor:default;margin:'+o.margin+'px"><tbody><tr>'
  1793. s+='<td>'+o.text.getHTML()+'</td>'
  1794. s+='<td style="padding-left:'+o.spc+'px" width="'+(13+o.spc)+'">'+o.arrow.getHTML()+'</td>'
  1795. s+='</tr></tbody></table>'
  1796. return s
  1797. }
  1798. // ================================================================================
  1799. function TextComboWidget_resize(w,h)
  1800. // Resize the TextIconMenuWidget
  1801. {
  1802. var o=this
  1803. if (w!=null)
  1804. w=Math.max(0,w-2*o.margin)
  1805. var d=o.layer.display!="none"
  1806. if (d&_moz&&!_saf)
  1807. o.setDisplay(false)
  1808. o.imwpResize(w,h)
  1809. if (d&_moz&&!_saf)
  1810. o.setDisplay(true)
  1811. }
  1812. // ================================================================================
  1813. function TextComboWidget_add(s,val,selected)
  1814. // Add a new item in the menu
  1815. // s [string] displayed value
  1816. // val [string] internal value
  1817. // selected [boolean] item selected or not
  1818. {
  1819. var o=this
  1820. var item=o.menu.addCheck(o.id+"_it_"+(o.counter++),s,TextComboWidget_internalCB)
  1821. item.val=""+val
  1822. item.parCombo=o
  1823. item.isComboVal=true
  1824. if ((o.selectedItem==null)||selected)
  1825. o.selectItem(item)
  1826. }
  1827. // ================================================================================
  1828. function TextComboWidget_addSeparator()
  1829. // Add a separator to the menu
  1830. {
  1831. this.menu.addSeparator()
  1832. }
  1833. // ================================================================================
  1834. function TextComboWidget_addMenuItem(id,text,cb,icon,dx,dy,disabled,disDx,disDy)
  1835. // Add a new item to the menu
  1836. {
  1837. this.menu.add(id,text,cb,icon,dx,dy,disabled,disDx,disDy)
  1838. }
  1839. // ================================================================================
  1840. function TextComboWidget_setDisabled(d)
  1841. // Enable/Disable the TextIconMenuWidget
  1842. {
  1843. var o=this
  1844. /* if (o.selectedItem)
  1845. o.text.setValue(d?"":o.selectedItem.text)*/
  1846. o.text.setDisabled(d)
  1847. o.arrow.setDisabled(d)
  1848. o.menu.setDisabled(d)
  1849. o.disabled=d
  1850. /* if(d)
  1851. o.icon.changeTooltip(o.icon.alt?o.icon.alt:"",true)*/
  1852. }
  1853. // ================================================================================
  1854. function TextComboWidget_isDisabled()
  1855. {
  1856. var o=this
  1857. return o.disabled
  1858. }
  1859. // ================================================================================
  1860. function TextComboWidget_select(idx)
  1861. // Select an item in the TextIconMenuWidget
  1862. // idx : item index (only items added by "add" function are taken in account)
  1863. // to allow menus combining combo items and menu action items
  1864. {
  1865. var o=this,item=o.getItemByIndex(idx)
  1866. if (item)
  1867. o.selectItem(item)
  1868. }
  1869. // ================================================================================
  1870. function TextComboWidget_setItemDisabled(idx,disabled)
  1871. // Disable a specific item on the TextIconMenuWidget
  1872. // idx [int] item index (only items added by "add" function are taken in account)
  1873. // disabled [boolean] disable if true
  1874. {
  1875. var o=this,item=o.getItemByIndex(idx)
  1876. if (item)
  1877. item.setDisabled(disabled)
  1878. }
  1879. // ================================================================================
  1880. function TextComboWidget_getSelection()
  1881. // Return the value selected in the TextIconMenuWidget
  1882. // It is either a value selected from the menu or the
  1883. // value type in the textfield
  1884. {
  1885. var o=this,it=o.selectedItem
  1886. var txt=o.text.getValue()
  1887. if (it)
  1888. return {index:o.getItemIndex(it),value:it.val}
  1889. else
  1890. return {index:-1,value:txt}
  1891. }
  1892. // ================================================================================
  1893. function TextComboWidget_valueSelect(v)
  1894. {
  1895. v=""+v
  1896. var o=this,items=o.menu.items,len=items.length
  1897. for (var i=0;i<len;i++)
  1898. {
  1899. var it=items[i]
  1900. if ((it.isComboVal)&&(it.val==v))
  1901. {
  1902. o.selectItem(it)
  1903. return
  1904. }
  1905. }
  1906. o.text.setValue(v)
  1907. }
  1908. // ================================================================================
  1909. function TextComboWidget_valueShow(v,show)
  1910. {
  1911. v=""+v
  1912. var o=this,items=o.menu.items,len=items.length
  1913. for (var i=0;i<len;i++)
  1914. {
  1915. var it=items[i]
  1916. if ((it.isComboVal)&&(it.val==v))
  1917. {
  1918. it.show(show)
  1919. return
  1920. }
  1921. }
  1922. o.text.setValue(v)
  1923. o.text.show(show)
  1924. }
  1925. // ================================================================================
  1926. function TextComboWidget_setUndefined(u)
  1927. {
  1928. var o=this
  1929. if (u)
  1930. o.selectItem(null)
  1931. }
  1932. // ================================================================================
  1933. function TextComboWidget_setContentEditable(d)
  1934. {
  1935. var o=this
  1936. o.text.setContentEditable(d)
  1937. }
  1938. // ================================================================================
  1939. function TextComboWidget_isContentEditable()
  1940. {
  1941. var o=this
  1942. return o.text.isContentEditable()
  1943. }
  1944. // ================================================================================
  1945. function TextComboWidget_selectItem(item)
  1946. // PRIVATE
  1947. {
  1948. var o=this
  1949. if (o.selectedItem)
  1950. o.selectedItem.check(false)
  1951. if (item)
  1952. {
  1953. o.val=item.val
  1954. o.text.setValue(/*o.disabled?"":*/item.text)
  1955. o.selectedItem=item
  1956. item.check(true)
  1957. /* if(o.disabled)
  1958. o.text.changeTooltip(o.icon.alt?o.icon.alt:"",true)
  1959. else
  1960. o.text.changeTooltip(o.icon.alt?(o.icon.alt+' ('+item.text)+')':(item.text),true) */
  1961. }
  1962. else
  1963. {
  1964. o.val=null
  1965. o.text.setValue("")
  1966. // o.text.changeTooltip(o.icon.alt?o.icon.alt:"",true)
  1967. o.selectedItem=null
  1968. }
  1969. }
  1970. // ================================================================================
  1971. function TextComboWidget_getItemByIndex(idx)
  1972. // PRIVATE
  1973. {
  1974. var items=this.menu.items
  1975. return ((idx>=0)&&(idx<items.length))?items[idx]:null
  1976. }
  1977. // ================================================================================
  1978. function TextComboWidget_getItemIndex(item)
  1979. // PRIVATE
  1980. {
  1981. var items=this.menu.items,len=items.length,j=0
  1982. for (var i=0;i<len;i++)
  1983. {
  1984. var it=items[i]
  1985. if (it.isComboVal)
  1986. {
  1987. if (it.id==item.id)
  1988. return j
  1989. j++
  1990. }
  1991. }
  1992. return -1
  1993. }
  1994. // ================================================================================
  1995. function TextComboWidget_changeCB()
  1996. // PRIVATE
  1997. {
  1998. var p=this.par
  1999. var b=true
  2000. if (p.checkCB)
  2001. b=p.checkCB()
  2002. if (!b)
  2003. return
  2004. if (p.changeCB)
  2005. p.changeCB()
  2006. }
  2007. // ================================================================================
  2008. function TextComboWidget_enterCB()
  2009. // PRIVATE
  2010. {
  2011. var p=this.par
  2012. // 1st : Unselect any selected element from the menu
  2013. if (p.selectedItem)
  2014. {
  2015. p.selectedItem.check(false)
  2016. p.selectedItem=null
  2017. }
  2018. //2nd : Call the callBack function
  2019. var b=true
  2020. if (p.checkCB)
  2021. b=p.checkCB()
  2022. if (!b)
  2023. return
  2024. if (p.changeCB)
  2025. p.changeCB()
  2026. }
  2027. // ================================================================================
  2028. function TextComboWidget_checkCB()
  2029. // PRIVATE
  2030. {
  2031. var p=this.par
  2032. if (p.checkCB)
  2033. p.checkCB()
  2034. }
  2035. // ================================================================================
  2036. function TextComboWidget_hideCB()
  2037. // PRIVATE
  2038. {
  2039. var o=this.parIcon;
  2040. if(o.arrow)
  2041. o.arrow.focus();
  2042. TextComboOutCB(o.index)
  2043. }
  2044. // ================================================================================
  2045. function TextComboWidget_arrowClickCB()
  2046. // PRIVATE
  2047. {
  2048. this.par.clickCB()
  2049. }
  2050. // ================================================================================
  2051. function TextComboWidget_clickCB()
  2052. // PRIVATE
  2053. {
  2054. var o=this,l=o.layer
  2055. o.menu.show(!o.menu.isShown(),getPosScrolled(l).x,getPosScrolled(l).y+o.getHeight()+1,null,null,o)
  2056. TextComboOverCB(o.index)
  2057. }
  2058. // ================================================================================
  2059. function TextCombo_OverCB()
  2060. // PRIVATE
  2061. {
  2062. TextComboOverCB(getWidget(this).index)
  2063. return true
  2064. }
  2065. // ================================================================================
  2066. function TextComboOverCB(i)
  2067. // PRIVATE
  2068. {
  2069. var o=_allBOIconsMenus[i]
  2070. IconWidget_overCB(o.arrow.index) // Re-use method from IconWidget class
  2071. }
  2072. // ================================================================================
  2073. function TextCombo_OutCB(i)
  2074. // PRIVATE
  2075. {
  2076. TextComboOutCB(getWidget(this).index)
  2077. }
  2078. // ================================================================================
  2079. function TextComboOutCB(i)
  2080. // PRIVATE
  2081. {
  2082. var o=_allBOIconsMenus[i]
  2083. if (!o.menu.isShown())
  2084. IconWidget_outCB(o.arrow.index) // Re-use method from IconWidget class
  2085. else
  2086. IconWidget_overCB(o.arrow.index)
  2087. }
  2088. // ================================================================================
  2089. function TextComboWidget_internalCB()
  2090. // PRIVATE
  2091. {
  2092. var o=this,c=o.parCombo
  2093. c.selectItem(o)
  2094. if (c.changeCB)
  2095. c.changeCB()
  2096. }
  2097. // ================================================================================
  2098. function TextComboWidget_keyUpCB()
  2099. // PRIVATE
  2100. {
  2101. }
  2102. // ================================================================================
  2103. // ================================================================================
  2104. //
  2105. // OBJECT newIconScrollMenuWidget (Constructor)
  2106. //
  2107. // An icon widget that add an arrow part at the right. when clicking on the
  2108. // right part, a menu pops up
  2109. // If no callback is attached, the also pops up when clicking on the left part
  2110. // menu.js must be included to use this component
  2111. //
  2112. // ================================================================================
  2113. // ================================================================================
  2114. /*
  2115. function newIconScrollMenuWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy,
  2116. changeCB,multi,width,lines,tooltip,dblClickCB,keyUpCB,showLabel,label,convBlanks,beforeShowCB)
  2117. // CONSTRUCTOR
  2118. // id [String] the icon id for DHTML processing
  2119. // src [String] the icon image url
  2120. // clickCB [Function - optional] callback called when clicking
  2121. // text [String - optional] icon text
  2122. // alt [String] icon tooltip
  2123. // w [int] visible image width
  2124. // h [int] visible image height
  2125. // dx [int - optional] horizontal offset in the image
  2126. // dy [int - optional] vertical offset in the image
  2127. // disDx [int - optional] horizontal offset for disabled state
  2128. // disDy [int - optional] vertical offset for disabled state
  2129. // changeCB [Function - optional] calback when selection is changed by the user
  2130. // multi [boolean - optional] if true, multiselection is enabled
  2131. // lines [int] number of visible lines
  2132. // tooltip [String - optional] tooltip for 508
  2133. // dblClickCB [Function - optional] calback when an item is double-clicked
  2134. // keyUpCB [Function - optional] calback when a key
  2135. // showLabel [boolean - optional] if true a label is displayed
  2136. // label [boolean - optional] text of the label
  2137. // convBlanks [int - optional]
  2138. // beforeShowCB [Function - optional] callback called before showing the menu
  2139. {
  2140. var o=newIconMenuWidget(id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy)
  2141. o.menu=newScrollMenuWidget("iconMenu_menu_"+id,changeCB,multi,width,lines,tooltip,dblClickCB,keyUpCB,showLabel,label,convBlanks,beforeShowCB)
  2142. o.add=IconScrollMenu_add
  2143. return o
  2144. }
  2145. // ================================================================================
  2146. function IconScrollMenu_add(s,val,sel,id)
  2147. {
  2148. this.menu.add(s,val,sel,id)
  2149. }
  2150. // ================================================================================
  2151. // ================================================================================
  2152. //
  2153. // OBJECT newPaneWidget (Constructor)
  2154. //
  2155. // creates a pane with multiple switchable zones
  2156. //
  2157. //
  2158. // ================================================================================
  2159. // ================================================================================
  2160. function newPaneWidget(id,tooltip,w,h,x,y,changeCB)
  2161. // id [String] the pane id for DHTML processing
  2162. // w [Int - Optional] the pane width (100 px if ommited or null)
  2163. // h [Int - Optional] the pane height (400 px if ommited or null)
  2164. // Returns [PaneWidget] the new instance
  2165. {
  2166. var o=newWidget(id)
  2167. // Private Fields
  2168. o.items=new Array
  2169. o.w=(w==null?100:w)
  2170. o.h=(w==null?400:h)
  2171. o.x=x
  2172. o.y=y
  2173. o.changeCB=changeCB
  2174. o.pal = newPaletteWidget("palette_"+id);
  2175. o.pal.vertPadding=0
  2176. o.panes = new Array;
  2177. o.panemenu = null
  2178. o.selection=-1
  2179. o.topH=_ie?18:17
  2180. o.bottomH=24+(_ie?0:2)
  2181. o.tooltip=tooltip
  2182. o.iframe=newWidget("_iframe"+o.id)
  2183. o.title=newWidget("paneTitleB_"+o.id)
  2184. // Methods
  2185. o.add = PaneWidget_add
  2186. o.valueSelect = PaneWidget_valueSelect
  2187. o.valueShow = PaneWidget_valueShow
  2188. o.getSelection = PaneWidget_getSelection
  2189. // Standard widget methods
  2190. o.getHTML=PaneWidget_getHTML
  2191. o.oldInit=o.init
  2192. o.init=PaneWidget_init
  2193. o.oldResize=o.resize
  2194. o.resize=PaneWidget_resize
  2195. o.getFrame=PaneWidget_getFrame
  2196. o.resizePalette=PaneWidget_resizePalette
  2197. return o
  2198. }
  2199. // ================================================================================
  2200. function PaneWidget_getSelection()
  2201. {
  2202. var o=this,i=o.selection
  2203. if (i==-1)
  2204. return null
  2205. else
  2206. return {index:i,value:o.panes[i].value}
  2207. }
  2208. // ================================================================================
  2209. function PaneWidget_resize(w,h)
  2210. {
  2211. var o=this
  2212. o.w=w
  2213. o.h=h
  2214. o.oldResize(Math.max(0,w+(_ie?0:-2)),Math.max(0,h+(_ie?0:-2)))
  2215. o.pal.resize(Math.max(0,w-2))
  2216. o.title.resize(Math.max(0,w-2))
  2217. o.iframe.resize(Math.max(0,o.w-2),Math.max(0,o.h-(o.topH+o.bottomH)-3))
  2218. o.resizePalette()
  2219. }
  2220. // ================================================================================
  2221. function PaneWidget_resizePalette()
  2222. // PRIVATE
  2223. {
  2224. var o=this,nbButton=0,panes=o.panes,len=panes.length;maxVisible=Math.floor((o.w-22)/24),j=0,hasMenu=false
  2225. for (var i=0;i<len;i++)
  2226. {
  2227. var pane=panes[i],isVis=j<maxVisible,menu=o.menu
  2228. pane.button.setDisplay(pane.shown&&(isVis))
  2229. if (menu)
  2230. {
  2231. var menuItem=menu.getItem(i),show=pane.shown&&(!isVis)
  2232. menuItem.show(show)
  2233. if (show)
  2234. hasMenu=true
  2235. }
  2236. if (pane.shown) j++
  2237. }
  2238. o.panemenu.setDisplay(hasMenu)
  2239. }
  2240. // ================================================================================
  2241. function PaneWidget_init()
  2242. {
  2243. var o=this
  2244. o.oldInit()
  2245. o.pal.init()
  2246. o.panemenu.init()
  2247. o.iframe.init()
  2248. o.title.init()
  2249. }
  2250. // ================================================================================
  2251. function PaneWidget_getFrame()
  2252. {
  2253. return eval("_curWin.frames._iframe"+this.id)
  2254. }
  2255. // ================================================================================
  2256. function PaneWidget_valueShow(value,show)
  2257. {
  2258. var o=this,panes=o.panes,index=-1,pane=null
  2259. for (i=0;i<panes.length;i++)
  2260. {
  2261. pane=panes[i]
  2262. if (pane.value==value)
  2263. {
  2264. index=i
  2265. break
  2266. }
  2267. }
  2268. if (pane)
  2269. {
  2270. //pane.button.setDisplay(show)
  2271. o.resizePalette()
  2272. pane.menuItem.show(show)
  2273. pane.shown=show
  2274. }
  2275. }
  2276. // ================================================================================
  2277. function PaneWidget_valueSelect(value)
  2278. {
  2279. var o=this,panes=o.panes,index=-1,pane=null,oldSel=o.selection
  2280. for (i=0;i<panes.length;i++)
  2281. {
  2282. pane=panes[i]
  2283. if (pane.value==value)
  2284. {
  2285. index=i
  2286. break
  2287. }
  2288. }
  2289. // Deselect prev
  2290. if (o.selection>=0)
  2291. {
  2292. var oldPane=panes[o.selection]
  2293. if (oldPane)
  2294. {
  2295. oldPane.menuItem.check(false)
  2296. oldPane.button.check(false)
  2297. }
  2298. }
  2299. if (index>=0)
  2300. {
  2301. pane.menuItem.check(true)
  2302. pane.button.check(true)
  2303. o.title.setHTML(convStr(pane.name))
  2304. var hasChanged=(o.selection!=index)
  2305. o.selection=index
  2306. if (hasChanged)
  2307. {
  2308. if ((oldSel!=-1)&&(o.changeCB))
  2309. o.changeCB()
  2310. frameNav("_iframe"+o.id,pane.url,false,_curWin)
  2311. }
  2312. }
  2313. else
  2314. {
  2315. if (o.selection!=-1)
  2316. {
  2317. o.selection=-1
  2318. frameNav("_iframe"+o.id,_skin+"../../empty.html",false,_curWin)
  2319. }
  2320. }
  2321. }
  2322. // ================================================================================
  2323. function PaneWidget_getHTML()
  2324. {
  2325. var o=this,panes=o.panes,pal=o.pal
  2326. if (o.panemenu == null)
  2327. {
  2328. pal.beginRightZone()
  2329. var pm=o.panemenu = newIconWidget("__panemenu_"+o.id,_skin+'panemenu.gif',PaneWidget_buttonCB,null,null,9,16);
  2330. pm.isPaneMenu=true
  2331. pm.parPane=o
  2332. pal.add(pm)
  2333. var menu=o.menu = newMenuWidget("panemenu_"+o.id);
  2334. for (var i=0; i<panes.length; i++)
  2335. {
  2336. var pane=panes[i]
  2337. var m=menu.addCheck("m__"+pane.button.id,pane.name,PaneWidget_buttonCB,pane.icon,pane.button.dx,pane.button.dy)
  2338. m.paneElement=pane
  2339. pane.menuItem=m
  2340. }
  2341. }
  2342. o.resizePalette()
  2343. var absSty = ((o.x!=null)&&(o.y!=null)) ? "position:absolute;left:"+o.x+"px;top:"+o.y+"px;" : ""
  2344. return '<div class="treeZone" id="'+o.id+'" style="'+absSty+'overflow:hidden;width:'+(o.w+(_ie?0:-2))+'px;height:'+(o.h+(_ie?0:-2))+'px">' +
  2345. '<div class="titlepane" id="paneTitleB_'+o.id+'" style="overflow:hidden;background-image:url('+_skin+'panetitle.gif);height:'+(o.topH)+'px"></div>'+
  2346. '<iframe class="treeZone" style="border-width:0px;border-bottom-width:1px;width:'+Math.max(0,o.w-2)+'px;height:'+(Math.max(0,o.h-(o.topH+o.bottomH)-3))+'px" id="_iframe'+o.id+'" name="iframe_'+o.id+'" title="'+convStr(o.tooltip)+'" frameborder="0" src="'+_skin+'../../empty.html"></iframe>'+
  2347. '<div class="panelzone" id="paneTools_'+o.id+'" style="height:'+o.bottomH+'px">'+pal.getHTML()+'</div>' +
  2348. '</div>'
  2349. }
  2350. // ================================================================================
  2351. function PaneWidget_add(value,name,icon,dx,dy,url)
  2352. {
  2353. newPaneElement(this,this.id+"_item_"+value,value,name,icon,dx,dy,url)
  2354. }
  2355. // ================================================================================
  2356. function PaneWidget_buttonCB()
  2357. {
  2358. var o=this
  2359. if (o.isPaneMenu)
  2360. {
  2361. var m = o.parPane.panemenu,l = m.layer
  2362. o.parPane.menu.show(true,getPosScrolled(l).x+m.getWidth()+1,getPosScrolled(l).y+16)
  2363. }
  2364. else
  2365. {
  2366. var paneE = o.paneElement
  2367. paneE.par.valueSelect(paneE.value)
  2368. }
  2369. }
  2370. // ================================================================================
  2371. // ================================================================================
  2372. //
  2373. // OBJECT newPaneElementWidget (Constructor)
  2374. //
  2375. // creates a pane with multiple switchable zones
  2376. //
  2377. //
  2378. // ================================================================================
  2379. // ================================================================================
  2380. function newPaneElement(par,id,value,name,icon,dx,dy,url)
  2381. {
  2382. var o=new Object
  2383. o.par=par
  2384. par.panes[par.panes.length]=o
  2385. o.value=value
  2386. o.name=name
  2387. o.icon=icon
  2388. o.button=newIconCheckWidget(id,icon,PaneWidget_buttonCB,null,name,16,16,dx,dy);
  2389. o.button.paneElement=o
  2390. o.url=url
  2391. par.pal.add(o.button)
  2392. o.shown=true
  2393. }
  2394. // ================================================================================
  2395. // ================================================================================
  2396. //
  2397. // OBJECT newButtonMenuWidget (Constructor)
  2398. //
  2399. //
  2400. // ================================================================================
  2401. // ================================================================================
  2402. function newButtonMenuWidget(id,label,width,tooltip,beforeShowCB,tabIndex)
  2403. {
  2404. var o=newButtonWidget(id,label,ButtonMenuWidget_clickCB,width,null,tooltip,tabIndex,0,_skin+"menus.gif",7,16,0,81,true,0,97)
  2405. o.menu = newMenuWidget("buttonMenu_menu_"+id,null,beforeShowCB);
  2406. o.getMenu=IconMenuWidget_getMenu
  2407. return o;
  2408. }
  2409. // ================================================================================
  2410. function ButtonMenuWidget_clickCB()
  2411. // PRIVATE
  2412. {
  2413. var o=this,l=o.layer;
  2414. o.menu.show(!o.menu.isShown(),getPosScrolled(l).x,getPosScrolled(l).y+o.getHeight(),null,null,o)
  2415. }
  2416. _scrollW=20
  2417. _scrollH=20
  2418. _margin=2
  2419. // ================================================================================
  2420. // ================================================================================
  2421. //
  2422. // OBJECT newIconTableWidgetElem (Constructor)
  2423. //
  2424. // Display a clickable icon with optional text. It can be used in a palette fo
  2425. // instance. The image can be a sub-part of a bigger image
  2426. // (use dx and dy to define offset)
  2427. //
  2428. // ================================================================================
  2429. // ================================================================================
  2430. function newIconTableWidgetElem(parid,id,src,clickCB,text,alt,w,h,dx,dy,disDx,disDy,maxW,maxH)
  2431. {
  2432. var o=newIconRadioWidget(id,src,clickCB,text,alt,"grp_"+parid,w,h,dx,dy,disDx,disDy)
  2433. // Properties
  2434. o.txtNoPadding=true
  2435. o.txtAlign='center'
  2436. o.margin=0
  2437. o.maxW=maxW
  2438. o.maxH=maxH
  2439. o.imgW=w+o.border
  2440. o.imgH=h+o.border
  2441. o.txtW=maxW-2*_margin
  2442. // Methods
  2443. o.oldGetHTML=o.getHTML
  2444. o.getHTML=IconTableWidgetElem_getHTML
  2445. o.oldResize=o.resize
  2446. o.resize=IconTableWidgetElem_resize
  2447. return o
  2448. }
  2449. // ================================================================================
  2450. function IconTableWidgetElem_getHTML()
  2451. // returns [String] the HTML of an icon widget
  2452. {
  2453. var o=this,imgCode=o.src?'<div style="overflow:hidden;width:'+o.imgW+'px;height:'+o.imgH+'">'+simpleImgOffset(o.src,o.w,o.h,o.dis?o.disDx:o.dx,o.dis?o.disDy:o.dy,'IconImg_'+o.id,null,o.alt,'margin:2px;cursor:'+(o.clickCB ? (!o.acceptClick() ? 'default' : _hand):'default'))+o.extraHTML+'</div>':'<div class="icontext" style="width:1px;"></div>'
  2454. var txtAtt='style="white-space:normal;'
  2455. txtAtt+='text-overflow:ellipsis;overflow:hidden;width:'+o.txtW+'px;'
  2456. txtAtt+='"'
  2457. var d=o.disp?"":"display:none;"
  2458. return '<table style="'+d+'width:'+o.maxW+'px;height:'+o.maxH+'margin:0px" id="'+o.id+'" class="' + o.nocheckClass + '" cellspacing="0" cellpadding="0" border="0"><tr valign="middle">'+
  2459. '<td align="center">'+ ((o.clickCB&&_ie)?lnk(imgCode,null,null,null, ' tabIndex="-1"' ):imgCode)+'</td></tr><tr>'+
  2460. (o.text?'<td align="center"><div id="IconImg_Txt_'+o.id+'" class="iconTableText'+(o.dis?"Dis":"")+'" '+txtAtt+'>'+convStr(o.text)+'</div></td>':'')+
  2461. '</tr></table>'
  2462. }
  2463. // ================================================================================
  2464. function IconTableWidgetElem_resize(w,h)
  2465. {
  2466. var o=this
  2467. if (w!=null)
  2468. o.oldResize(w-2*_margin,null)
  2469. if (h!=null)
  2470. o.oldResize(null,h-2*_margin)
  2471. }
  2472. // ================================================================================
  2473. // ================================================================================
  2474. //
  2475. // OBJECT newIconTableWidget (Constructor)
  2476. //
  2477. // Display a table of clickable icons.
  2478. //
  2479. // ================================================================================
  2480. // ================================================================================
  2481. function newIconTableWidget(id,horiz,w,h)
  2482. // CONTRUCTOR
  2483. // id : [String] the icon id for DHTML processing
  2484. // horiz : [boolean] if true, table is horizontal (1 row and n columns)
  2485. // if false, table is vertical (n rows and 1 column)
  2486. // w : [int] width
  2487. // h : [int] height
  2488. {
  2489. var o=newScrolledZoneWidget(id,0,0,w,h)
  2490. // Properties
  2491. o.horiz=horiz
  2492. o.padding=2
  2493. o.icnTblLayer=null
  2494. o.contCSS=null
  2495. o.elems=new Array
  2496. // Methods
  2497. o.oldInit=o.init
  2498. o.init=IconTableWidget_init
  2499. o.oldResize2=o.resize
  2500. o.resize=IconTableWidget_resize
  2501. o.getHTML=IconTableWidget_getHTML
  2502. o.add=IconTableWidget_add
  2503. o.select=IconTableWidget_select
  2504. return o
  2505. }
  2506. // ================================================================================
  2507. function IconTableWidget_init()
  2508. {
  2509. var o=this, len=o.elems.length
  2510. //o.oldInit()
  2511. for (var i=0;i<len;i++)
  2512. o.elems[i].init()
  2513. o.icnTblLayer=getLayer(_codeWinName+'icnTbl'+o.id)
  2514. o.contCSS=o.icnTblLayer.style
  2515. }
  2516. // ================================================================================
  2517. function IconTableWidget_resize(w,h)
  2518. {
  2519. var o=this
  2520. //o.oldResize2(w,h)
  2521. if (w!=null)
  2522. {
  2523. if (o.contCSS!=null)
  2524. o.contCSS.width=''+w+'px'
  2525. }
  2526. if (h!=null)
  2527. {
  2528. if (o.contCSS!=null)
  2529. o.contCSS.height=''+h+'px'
  2530. }
  2531. }
  2532. // ================================================================================
  2533. function IconTableWidget_getHTML()
  2534. {
  2535. var o=this, s=''
  2536. // s+= o.beginHTML()
  2537. s+= '<table id="'+_codeWinName+'icnTbl'+o.id+'" width="'+o.w+'" height="'+o.h+'px" class="iconTableZone" cellspacing="0" cellpadding="0"><tbody>'
  2538. s+= '<tr valign="top"><td>'
  2539. s+= '<table cellspacing="0" cellpadding="'+o.padding+'px"><tbody>'
  2540. if (o.horiz)
  2541. {
  2542. s+= '<tr>'
  2543. for (var i=0;i<o.elems.length;i++)
  2544. {
  2545. s+= '<td align="center">'
  2546. s+= o.elems[i].getHTML()
  2547. s+= '</td>'
  2548. }
  2549. s+= '</tr>'
  2550. }
  2551. else
  2552. {
  2553. for (var i=0;i<o.elems.length;i++)
  2554. {
  2555. s+= '<tr><td align="center">'
  2556. s+= o.elems[i].getHTML()
  2557. s+= '</td></tr>'
  2558. }
  2559. }
  2560. s+= '</tbody></table>'
  2561. s+= '</td><tr>'
  2562. s+= '</tbody></table>'
  2563. // s+= o.endHTML()
  2564. return s
  2565. }
  2566. // ================================================================================
  2567. function IconTableWidget_add(src,clickCB,text,alt,w,h,dx,dy,disDx,disDy)
  2568. {
  2569. var o=this, len=o.elems.length, icn=null
  2570. var maxW=o.horiz?o.h:o.w
  2571. maxW-=2*_margin
  2572. var maxH=maxW
  2573. icn=newIconTableWidgetElem(o.id,"iconTable_icon_"+len+o.id,src,clickCB,text,alt,
  2574. w,h,dx,dy,disDx,disDy,maxW,maxH)
  2575. icn.par=this
  2576. o.elems[len]=icn
  2577. }
  2578. // ================================================================================
  2579. function IconTableWidget_select(index)
  2580. {
  2581. var o=this
  2582. var e=o.elems[index]
  2583. if ( e==null )
  2584. return
  2585. e.check(true)
  2586. }
  2587. // ================================================================================
  2588. // Icon Border Menu Widget
  2589. // ================================================================================
  2590. function newIconBordersMenuWidget(id,clickCB,beforeShowCB)
  2591. {
  2592. var o=newIconMenuWidget(id,_skin+'../borders.gif',IconBordersMenuWidget_iconInternalClickCB,null,null,16,16,0,0,0,16,false,beforeShowCB,_menuType_border)
  2593. // properties
  2594. o.selectedBorder=new Object
  2595. o.selectedBorder.top=0
  2596. o.selectedBorder.bot=0
  2597. o.selectedBorder.left=0
  2598. o.selectedBorder.right=0
  2599. o.lastSelectedBorder=new Object
  2600. o.lastSelectedBorder.top=0
  2601. o.lastSelectedBorder.bot=0
  2602. o.lastSelectedBorder.left=0
  2603. o.lastSelectedBorder.right=0
  2604. o.bordersClickCB=clickCB
  2605. // methods
  2606. o.getSelectedBorder=IconBordersMenuWidget_getSelectedBorder
  2607. o.getLastSelectedBorder=IconBordersMenuWidget_getLastSelectedBorder
  2608. return o
  2609. }
  2610. // ================================================================================
  2611. function IconBordersMenuWidget_getSelectedBorder()
  2612. {
  2613. var o=this
  2614. return o.selectedBorder
  2615. }
  2616. // ================================================================================
  2617. function IconBordersMenuWidget_getLastSelectedBorder()
  2618. {
  2619. var o=this
  2620. return o.lastSelectedBorder
  2621. }
  2622. // ================================================================================
  2623. function IconBordersMenuWidget_iconInternalClickCB()
  2624. {
  2625. var o=this
  2626. o.selectedBorder.top=o.lastSelectedBorder.top
  2627. o.selectedBorder.bot=o.lastSelectedBorder.bot
  2628. o.selectedBorder.left=o.lastSelectedBorder.left
  2629. o.selectedBorder.right=o.lastSelectedBorder.right
  2630. if (o.bordersClickCB)
  2631. o.bordersClickCB()
  2632. }
  2633. // ================================================================================
  2634. function IconBordersMenuWidget_internalClickCB()
  2635. {
  2636. var o=this
  2637. var top=bot=left=right=-1
  2638. switch (o.id)
  2639. {
  2640. case "border_0":
  2641. top=bot=left=right=0
  2642. break;
  2643. case "border_1":
  2644. bot=1
  2645. break;
  2646. case "border_2":
  2647. left=1
  2648. break;
  2649. case "border_3":
  2650. right=1
  2651. break;
  2652. case "border_4":
  2653. bot=2
  2654. break;
  2655. case "border_5":
  2656. bot=3
  2657. break;
  2658. case "border_6":
  2659. top=bot=1
  2660. break;
  2661. case "border_7":
  2662. top=1;bot=2
  2663. break;
  2664. case "border_8":
  2665. top=1;bot=3
  2666. break;
  2667. case "border_9":
  2668. top=bot=left=right=1
  2669. break;
  2670. case "border_10":
  2671. top=bot=left=right=2
  2672. break;
  2673. case "border_11":
  2674. top=bot=left=right=3
  2675. break;
  2676. case "border_12":
  2677. top=bot=left=right=-2
  2678. break;
  2679. }
  2680. // Set the selection
  2681. var pp=o.par.parIcon
  2682. pp.selectedBorder.top=top
  2683. pp.selectedBorder.bot=bot
  2684. pp.selectedBorder.left=left
  2685. pp.selectedBorder.right=right
  2686. if (o.id!="border_12")
  2687. {
  2688. // Update the menu icon
  2689. pp.icon.changeImg(16*o.idx,0)
  2690. // Save the previous border
  2691. pp.lastSelectedBorder.top=top
  2692. pp.lastSelectedBorder.bot=bot
  2693. pp.lastSelectedBorder.left=left
  2694. pp.lastSelectedBorder.right=right
  2695. }
  2696. // Call the menu callback
  2697. if (pp.bordersClickCB)
  2698. pp.bordersClickCB()
  2699. }
  2700. */