12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: cpscrn
- //
- // (C) Copyright IBM Corp. 2005, 2022
- //
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- //
- //
- /*
- * Global objects:
- * _F_Ajax : Allows AJAX calls back to IBM Cognos gateway or web content.
- * _F_Config : Configuration (browser, XMLHttpRequest, URI, etc.)
- * _F_Document : Allows high-level modification of the HTML document.
- * _F_DOM : Helper functions for reading XML document.
- * _F_Drag : Drag & Drop functionality
- * _F_Event : Event module
- * _F_Form : Form helper functions
- * _F_Queue : Queue and runable management
- * _F_Resource : Resource loading (LINK & SCRIPT)
- * _F_Strings : String helper functions
- */
- /**
- * _F_Config : Configuration (browser, XMLHttpRequest, URI, etc.)
- */
- _F_Config =
- {
- origObj: window._F_Config !== undefined? window._F_Config : null,
- version: (window._F_Config !== undefined && window._F_Config.version !== undefined)? window._F_Config.version: "1.0.2",
- browser: "unknown",
- browserVersion: "unknown",
- OS: "unknown",
- enableLog: false,
- xmlHttpDefault: null,
- webContent: (window._F_Config !== undefined && window._F_Config.webContent !== undefined)? window._F_Config.webContent:null,
- gateway: (window._F_Config !== undefined && window._F_Config.gateway !== undefined)? window._F_Config.gateway:null,
- application: (window._F_Config !== undefined && window._F_Config.application !== undefined)? window._F_Config.application:null,
- help: (window._F_Config !== undefined && window._F_Config.help !== undefined)? window._F_Config.help:null,
- responsePattern: (window._F_Config !== undefined && window._F_Config.responsePattern !== undefined)? window._F_Config.responsePattern:null,
- cookieSecure: (window._F_Config !== undefined && window._F_Config.cookieSecure !== undefined)? window._F_Config.cookieSecure:null,
- initialize: function()
- {
- this.browser = this.lookup(this.browsers).toLowerCase() || "unknown";
- this.browserVersion = this.parseVersion(navigator.userAgent) || this.parseVersion(navigator.appVersion) || "unknown";
- this.OS = this.lookup(this.systems) || "unknown";
- this.xmlHttpDefault = this.findXMLHttpActiveXVersion();
- if (this.origObj != null){
- for (var key in this.origObj){
- if ((this[key] === undefined)&& !(this.origObj[key] instanceof Function)){
- this[key] = this.origObj[key];
- }
- }
- delete this.origObj;
- }
-
-
- // create authtoken
- if(window.CAMAuthenticityTokenSession){
- var authTokenSession = new CAMAuthenticityTokenSession();
- this.authToken = authTokenSession.generate();
- }
- },
- getSecure: function()
- {
- if (this.cookieSecure === 'true') {
- return true;
- }
- return null;
- },
- /**
- * Expands the $CGI$ and $WEB$ macros to their configured values or values passed in the params parameter
- * E.g. $CGI$/dashboard?x=1 ==> /cognos8/cgi-bin/cognos.cgi
- * @param text usually an url
- * @param params an associative array containing values to replace the macros with. This param is optional
- */
- expandMacros: function(text, params)
- {
- var theGateway = this.gateway;
- var theWebContent = this.webContent;
- var theProductLocale = this.productLocale;
- var theSkin = this.skin;
- if (typeof params !== 'undefined'){
- if (typeof params.gateway !== 'undefined'){
- theGateway = params.gateway;
- }
- if (typeof params.webContent !== 'undefined'){
- theWebContent = params.webContent;
- }
- if (typeof params.productLocale !== 'undefined'){
- theProductLocale = params.productLocale;
- }
- if (typeof params.skin !== 'undefined'){
- theSkin = params.skin;
- }
- }
- return text.replace(/\$CGI\$/g, theGateway).replace(/\$WEB\$/g, theWebContent).replace(/\$PRODUCT_LOCALE\$/g, theProductLocale).replace(/\$SKIN\$/g, theSkin);
- },
-
- /**
- * Builds a url to the gateway.
- * @param uri (e.g. /xts.run?m=/portal/main.xts)
- */
- buildGatewayURI: function(uri)
- {
- return this.gateway + (uri||"");
- },
- /**
- * Builds a url to an fragment application.
- * @param app (e.g. "/dashboard") if not specified, _F_Config.application will be used.
- * @param uri (e.g. "/pages/dashboard.xml)
- */
- buildApplicationURI: function(app, uri)
- {
- return this.gateway + (app||this.application) + (uri||"");
- },
- /**
- * Builds a url to a web content resource.
- * @param uri
- */
- buildWebContentURI: function(uri)
- {
- return this.webContent + (uri||"");
- },
- lookup: function(data)
- {
- var i, l = data.length;
- for (i = 0; i < l; i++)
- {
- this.versionKey = data[i].partialKey || data[i].identity;
- var agent = data[i].agent;
- if (agent) {
- if (agent.indexOf(data[i].key) != -1) {
- return data[i].identity;
- }
- } else if (data[i].prop) {
- return data[i].identity;
- }
- }
- },
- parseVersion: function(s)
- {
- var index = s.indexOf(this.versionKey);
- if (index == -1) {
- return;
- }
- return parseFloat(s.substring(index + this.versionKey.length + 1).replace(/[^\d\.\-\+]/g, '_')); //sanitize before parse to avoid XSS vulnerability!
- },
-
- findXMLHttpActiveXVersion: function()
- {
- if (window.ActiveXObject || "ActiveXObject" in window)
- {
- var i, l = this.xmlHttpVersions.length;
- for (i = 0; i < l; i++)
- {
- try
- {
- // Try and create the ActiveXObject for Internet Explorer, if it doesn't work, try again.
- var xmlhttp = new ActiveXObject(this.xmlHttpVersions[i]);
- if (xmlhttp) {
- return this.xmlHttpVersions[i];
- }
- }
- catch (e)
- {
- // this ActiveX is not there, continue with next one in list
- }
- }
- }
- return null;
- },
-
- emptyFunction: function() {},
- browsers: [
- { agent: navigator.userAgent, key: "MSIE", identity: "Explorer", partialKey: "MSIE" },
- { agent: navigator.userAgent, key: "Firefox", identity: "Firefox" },
- { agent: navigator.userAgent, key: "Gecko", identity: "Mozilla", partialKey: "rv" },
- { agent: navigator.userAgent, key: "Mozilla", identity: "Netscape", partialKey: "Mozilla" },
- { agent: navigator.userAgent, key: "Netscape", identity: "Netscape" },
- { prop: window.opera, identity: "Opera" },
- { agent: navigator.vendor, key: "Apple", identity: "Safari" }
- ],
- systems: [
- { agent: navigator.platform, key: "Win", identity: "Windows" },
- { agent: navigator.platform, key: "Mac", identity: "Mac" },
- { agent: navigator.platform, key: "Linux", identity: "Linux" }
- ],
- xmlHttpVersions: [
- "Msxml2.XMLHTTP.6.0",
- "Msxml2.XMLHTTP.3.0",
- "Msxml2.XMLHTTP",
- "Microsoft.XMLHTTP"
- ]
- };
- /**
- * @deprecated: use _F_Config variable
- */
- var _F_config = _F_Config;
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // utility functions
- function $()
- {
- var element;
- if (arguments.length == 1) {
- element = arguments[0];
- if (typeof element == 'string') {
- return document.getElementById(element);
- }
- return element;
- } else {
- var elements = [];
- var i, l = arguments.length;
- for (i = 0; i < l; i++) {
- element = arguments[i];
- if (typeof element == 'string') {
- element = document.getElementById(element);
- }
- elements.push(element);
- }
- return elements;
- }
- }
- /**
- * _F_Strings : String helper functions
- */
- var _F_Strings =
- {
- normalize: function(text)
- {
- if (text == null) {
- return null;
- }
- // remove whitespace at beginning and end of the string and
- // replace multiple whitespace characters with a single space
- return text.replace(/^\s*|\s*$/g,"").replace(/\s+/g," ");
- },
-
- urlEncode: function(text)
- {
- return encodeURIComponent(text);
- },
-
- urlDecode: function(text)
- {
- return decodeURIComponent(text);
- },
-
- htmlEncode: function(text)
- {
- return text
- .replace(/\&/g, "&")
- .replace(/</g, "<")
- .replace(/>/g, ">");
- },
-
- htmlDecode: function(text)
- {
- return text
- .replace(/\</g, '<')
- .replace(/\>/g, '>')
- .replace(/\&/g, '&');
- },
-
- xmlEncode: function(text)
- {
- return text
- .replace(/\&/g, "&")
- .replace(/</g, "<");
- },
-
- xmlDecode: function(text)
- {
- return text
- .replace(/\</g, "<")
- .replace(/\>/g, ">")
- .replace(/\'/g, "'")
- .replace(/\"/g, '"')
- .replace(/\&/g, "&");
- }
- };
- /**
- * @deprecated: use _F_Strings.urlEncode()
- */
- function urlEncode(text)
- {
- _F_log("W", "DEPRECATED FUNCTION: urlEncode --> _F_Strings.urlEncode");
- return _F_Strings.urlEncode(text);
- }
- /**
- * @deprecated: use _F_Strings.htmlEncode()
- */
- function htmlEncode(text)
- {
- _F_log("W", "DEPRECATED FUNCTION: htmlEncode --> _F_Strings.htmlEncode");
- return _F_Strings.htmlEncode(text);
- }
- /**
- * @deprecated: use _F_Strings.xmlEncode()
- */
- function xmlEncode(text)
- {
- _F_log("W", "DEPRECATED FUNCTION: xmlEncode --> _F_Strings.xmlEncode");
- return _F_Strings.xmlEncode(text);
- }
- /**
- * @deprecated: use _F_Strings.normalize()
- */
- function _F_strip(str)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_strip --> _F_Strings.normalize");
- return _F_Strings.normalize(str);
- }
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // Additional Array features
- var _F_Array =
- {
- indexOf: function(array, value, begin, strict)
- {
- for (var i = +begin || 0, l = array.length; i < l; i++) {
- if (array[i] === value || strict && array[i] == value) {
- return i;
- }
- }
- return -1;
- },
- unique: function (array, strict)
- {
- var a = [], i, l = array.length;
- for (i = 0; i < l; i++) {
- if (this.indexOf(a, array[i], 0, strict) < 0) {
- a.push(array[i]);
- }
- }
- return a;
- },
- forEach: function(array, func, thisArg)
- {
- if (typeof func == "function") {
- var i, v, l = array.length;
- if (thisArg === undefined) {
- for (i = 0; i < l; i++) {
- func(array[i]);
- }
- } else {
- for (i = 0; i < l; i++) {
- func.call(thisArg, array[i]);
- }
- }
- }
- },
-
- insert: function(array, i, obj)
- {
- if (i !== undefined && obj !==undefined) {
- array.splice(i, 0, obj);
- }
- },
- remove: function(array, obj)
- {
- if (obj !== undefined)
- {
- var i = this.indexOf(array, obj);
- if (i >= 0)
- {
- array.splice(i, 1);
- return obj;
- }
- }
- return null;
- },
- removeAt: function(array, i)
- {
- if (i !== undefined) {
- array.splice(i, 1);
- }
- }
- };
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // client-side logging functions
- function _F_log(type, msg)
- {
- if (!_F_Config.enableLog) {
- return;
- }
- // Check for Firefox's Firebug extension
- if (window.console !== undefined)
- {
- //Builing params array without the debug key.
- var params = [];
- for (var i=1; i < arguments.length; i++)
- {
- params[i-1] = arguments[i];
- }
- switch (type)
- {
- case undefined:
- break;
- case "W":
- console.warn.apply(console, params);
- break;
- case "E":
- console.error.apply(console, params);
- break;
- case "I":
- console.info.apply(console, params);
- break;
- case "D":
- case "L":
- default:
- console.debug.apply(console, params);
- break;
- }
- }
- else
- {
- // basic status logger:
- switch (type)
- {
- case undefined:
- window.status = "";
- break;
- case "W":
- window.status = "WARNING: " + msg;
- break;
- case "E":
- window.status = "ERROR: " + msg;
- break;
- case "I":
- window.status = "INFO: " + msg;
- break;
- case "D":
- default:
- window.status = "DEBUG: " + msg;
- break;
- }
- }
- }
- function _F_alert(msg, title)
- {
- if (title != null) {
- window.alert(title + "\n\n" + msg);
- } else {
- window.alert(msg);
- }
- }
- /**
- * _F_Resource : Resource loading (LINK & SCRIPT)
- */
- var _F_Resource =
- {
- loaded: [],
- initialize: function()
- {
- var nodes = document.getElementsByTagName("SCRIPT");
- var l = nodes.length;
- var i = 0, j=0;
- var attrs;
- for (i = 0; i < l; i++)
- {
- attrs = nodes[i].attributes;
- for (j = 0; j < attrs.length; j++) {
- if (attrs[j].nodeName == "src")
- {
- this.loaded.push(attrs[j].nodeValue);
- break;
- }
- }
- }
-
- nodes = document.getElementsByTagName("LINK");
- l = nodes.length;
- for (i = 0; i < l; i++)
- {
- attrs = nodes[i].attributes;
- for (j = 0; j < attrs.length; j++) {
- if (attrs[j].nodeName == "href")
- {
- this.loaded.push(attrs[j].nodeValue);
- break;
- }
- }
- }
- },
-
- loadResource: function(tagName, href, arg1)
- {
- if (_F_Array.indexOf(this.loaded, href) == -1)
- {
- tagName = tagName.toUpperCase();
- var head = document.getElementsByTagName('HEAD').item(0);
- var node = document.createElement(tagName);
- var _self = this;
-
- switch (tagName)
- {
- case "SCRIPT":
- node.onload = node.onreadystatechange = function()
- {
- if (this.readyState && this.readyState != 'loaded' && this.readyState != 'complete') {
- return;
- }
-
- if (_F_Array.indexOf(_self.loaded, href) != -1) {
- return;
- }
-
- _self.loaded.push(href);
- _F_runQueue.resume();
- };
- node.type = 'text/javascript';
- node.src = href;
- head.appendChild(node);
- break;
-
- case "LINK":
- var cssLoaded = function () {
- if (_F_Array.indexOf(_self.loaded, href) != -1) {
- // For a CSS file that has import(s), multiple callbacks are possible - which can cause
- // synchronization issues when loading script resources - especially in IE.
- // This code ensures 'spurious' callbacks are ignored.
- return;
- }
- _self.loaded.push(href);
- _F_runQueue.resume();
- }
-
- if (xIE4Up) {
- // Only IE support the onload event for loading CSS
- node.onload = function(){
- cssLoaded();
- };
- }
-
- node.type = 'text/css';
- node.rel = "stylesheet";
- if (arg1 != null && arg1 != "") {
- node.media = arg1;
- }
- node.href = href;
- head.appendChild(node);
- if (!xIE4Up) {
- // Browser other than IE do not support the onload event for CSS loading.
- // In this case, we simply poll and check when it's loaded
- var cssId = "css_" +(new Date).getTime();
- node.id = cssId;
- var count = 0;
- var checkCSS = function() {
- if (count > 250){
- cssLoaded();
- return;
- }
-
- try {
- for(var i = 0; i < document.styleSheets.length; i++) {
- if(document.styleSheets[i].ownerNode.id == cssId) {
- document.styleSheets[i].cssRules;
- cssLoaded();
- return;
- }
- }
- } catch(e) {
- //swallow any exception and just fall through to trying again
- //since firefox throws exception...but safari does not
- }
- count++;
- window.setTimeout(checkCSS, 50);
- }
- checkCSS();
- }
-
- break;
-
- default:
- _F_log("E", "unsupported tag named: " + tagName);
- break;
- }
- // indicate to stop the run of the queue
- return true;
- }
- return false;
- }
- };
- /**
- * _F_Ajax : Allows AJAX calls back to IBM Cognos gateway or web content.
- *
- * The url is absolute to the web server. Two macros are supported to ease the url construction:
- * - $WEB$ is replaced by the web content root.
- * - $CGI$ is replaced by the gateway.
- *
- * Usage:
- * <pre>
- * var x = new _F_Ajax.Request( "$CGI$/xts.run",
- * {
- * method: "get",
- * parameters: { m: "/read.xts", path: "/content" },
- * onSuccess: function(transport) { jscode },
- * onFailure: function() { jscode },
- * });
- * </pre>
- *
- * Options are:
- * asynchronous(true) : Determines whether XMLHttpRequest is used asynchronously or not.
- * contentType("application/x-www-form-urlencoded") : The Content-Type header for the request.
- * encoding("UTF-8") : The encoding of the request contents.
- * method("post") : The HTTP method to use for the request.
- * parameters(hash-object) : The parameters for the request, which will be encoded into the URL for a 'get' method, or into the request body for the other methods.
- * postBody(null) : Specific contents for the request body on a 'post' method. If it is not provided, the contents of the parameters option will be used instead.
- * requestHeaders(hash-object) : Request headers as an object, with properties representing headers.
- * onSuccess(function) : Invoked when a request completes and its status code is undefined or belongs in the 2xy family.
- * onFailure(function) : Invoked when a request completes and its status code exists but is not in the 2xy family.
- * onException(function) : Triggered whenever an XMLHttpRequest error arises.
- */
- var _F_Ajax =
- {
- getTransport: function()
- {
- if (_F_Config.xmlHttpDefault != null) {
- return new ActiveXObject(_F_Config.xmlHttpDefault);
- }
- // Well if there is no ActiveXObject available it must be firefox, opera, or something else
- if (typeof XMLHttpRequest != 'undefined')
- {
- try
- {
- return new XMLHttpRequest();
- }
- catch (e)
- {
- _F_alert(e);
- }
- }
- throw "No XMLHttpRequest object is available";
- }
- };
- /**
- * Creates a request object.
- * @param url - (mandatory) target url (may contains macros).
- * @param options - (mandatory) request's options.
- */
- _F_Ajax.Request = function(url, options, caller)
- {
-
- try
- {
- var asynchronous = (options.asynchronous !== undefined) ? options.asynchronous : true;
- var contentType = options.contentType || "application/x-www-form-urlencoded";
- var encoding = options.encoding;
- var method = (options.method || "post").toLowerCase();
- var params = "";
- var parts = [];
- // replace the supported macros
- url = _F_Config.expandMacros(url);
-
- if (typeof options.parameters == "object")
- {
- for (var p in options.parameters)
- {
- var value = options.parameters[p];
- parts.push(encodeURIComponent(p) + '=' + ((value != null) ? encodeURIComponent(value) : ''));
- }
- params = parts.join('&');
- if (params != "")
- {
- url += ((url.indexOf('?') >= 0) ? '&' : '?') + params;
- params = "";
- }
- }
-
- if ((method == "post" || method == "put") && (options.postBody === undefined))
- {
- parts = url.split('?');
- url = parts[0];
- params = parts[1];
- }
-
- this.transport = _F_Ajax.getTransport();
- this.transport.open(method.toUpperCase(), url, asynchronous);
- var headers =
- {
- "X-Fragment-Version": _F_Config.version,
- "X-Controller-Agent": "fragment/" + _F_Config.version,
- "Accept": "text/javascript, text/html, application/xml, text/xml, */*"
- };
- if (method == 'post') {
- headers['Content-Type'] = contentType + (encoding ? '; charset=' + encoding : '');
-
- // XSRF-TOKEN cookie is null when disableXSRFCheck=true in bootstrap.properties.
- var xsrfTokenCookie = _F_Document.getCookie("XSRF-TOKEN");
- if (xsrfTokenCookie) {
- headers['X-XSRF-TOKEN'] = xsrfTokenCookie;
- }
- }
- for (var rh in options.requestHeaders) {
- headers[rh] = options.requestHeaders[rh];
- }
- for (var h in headers) {
- this.transport.setRequestHeader(h, headers[h]);
- }
- if (asynchronous)
- {
- var _self = this;
- this.transport.onreadystatechange = function()
- {
- try
- {
- if (_self.transport.readyState == 4)
- {
- if (_self.transport.status >= 200 && _self.transport.status < 300)
- {
- if (typeof options.onSuccess == "function") {
- options.onSuccess.call(_self, _self.transport);
- }
- }
- else
- {
- if (typeof options.onFailure == "function") {
- options.onFailure.call(_self, _self.transport);
- }
- }
-
- // fix for IE memory leak
- _self.transport.onreadystatechange = _F_Config.emptyFunction;
- }
- }
- catch (e)
- {
- try
- {
- if (typeof options.onException == "function") {
- if (this.status !== 0) {
- options.onException.call(this, e);
- }
- }
- }
- catch (e1)
- {
- _F_alert(e1);
- }
- }
- }; // of function
- }
- this.transport.send(options.postBody || params);
-
- if (!asynchronous)
- {
- try
- {
- if (this.transport.status >= 200 && this.transport.status < 300)
- {
- if (typeof options.onSuccess == "function") {
- options.onSuccess.call(this, this.transport);
- }
- }
- else
- {
- if (typeof options.onFailure == "function") {
- options.onFailure.call(this, this.transport);
- }
- }
- }
- catch (e)
- {
- try
- {
- if (typeof options.onException == "function") {
- options.onException.call(this, e);
- }
- }
- catch (e1)
- {
- _F_alert(e1);
- }
- }
- }
- }
- catch (e2)
- {
- try
- {
- if (typeof options.onException == "function") {
- options.onException.call(this, e2);
- }
- }
- catch (e3)
- {
- _F_alert(e3);
- }
- this.transport.abort();
- }
- };
- _F_Ajax.Request.prototype =
- {
- getHeader: function(name)
- {
- try
- {
- return this.transport.getResponseHeader(name);
- }
- catch (e)
- {
- return null;
- }
- },
-
- getResponseXml: function () {
- var responseXML = null;
- if (this.transport.status === 200) {
- if ("ActiveXObject" in window) {
- responseXML = new ActiveXObject("Microsoft.XMLDOM");
- responseXML.async = "false";
- responseXML.loadXML(this.transport.responseText);
- } else {
- var parser = new DOMParser();
- responseXML = parser.parseFromString(this.transport.responseText, "text/xml");
- }
- }
- return responseXML;
- },
- getResponseText: function()
- {
- return (this.transport.status === 200) ? this.transport.responseText : null;
- },
- getStatus: function()
- {
- return this.transport.status;
- }
- };
- /**
- * _F_Document : Allows high-level modification of the HTML document.
- */
- var _F_Document =
- {
- associate: function (target, obj, methodName)
- {
- return function(e)
- {
- e = e||window.event;
- return obj[methodName](e, target);
- };
- },
- addEventListener: function (node, type, callback, capture)
- {
- type = type.toLowerCase();
- if (node.addEventListener) {
- node.addEventListener(type, callback, capture);
- } else if (node.attachEvent) {
- node.attachEvent('on' + type, callback);
- } else {
- node['on' + type] = callback;
- }
- },
- buildHeadTagId: function(id, tagName)
- {
- return (id + tagName.toLowerCase() + "s");
- },
- addHeadTag: function(tagName, text, id)
- {
- try
- {
- var head = document.getElementsByTagName('HEAD').item(0);
- var domTag, domText;
- if (id)
- {
- domTag = $(id);
- if (domTag && domTag.parentNode == head) {
- head.removeChild(domTag);
- }
- }
-
- tagName = tagName.toUpperCase();
- domTag = document.createElement(tagName);
- if (id) {
- domTag.id = id;
- }
-
- if (tagName == 'SCRIPT')
- {
- domTag.type = 'text/javascript';
- domTag.text = text;
- }
- else if (tagName == 'STYLE')
- {
- domTag.type = 'text/css';
- if (domTag.styleSheet)
- {
- domTag.styleSheet.cssText = text;
- }
- else
- {
- domText = document.createTextNode(text);
- domTag.appendChild(domText);
- }
- }
- else
- {
- domText = document.createTextNode(text);
- domTag.appendChild(domText);
- }
- head.appendChild(domTag);
- }
- catch (e)
- {
- _F_log("E", e);
- }
- },
- removeHeadTag: function(id)
- {
- if (id)
- {
- var head = document.getElementsByTagName('HEAD').item(0);
- var domTag = $(id);
- if (domTag && domTag.parentNode == head) {
- head.removeChild(domTag);
- }
- domtag = null;
- }
- },
- extractTagText: function(text, tagName)
- {
- var lowerText = text.toLowerCase();
- tagName = tagName.toLowerCase();
- var fromIndex = lowerText.indexOf("<" + tagName);
- if (fromIndex == -1) {
- return "";
- }
-
- // skip attributes
- fromIndex = lowerText.indexOf(">", fromIndex + tagName.length + 1);
- if (fromIndex == -1) {
- return "";
- }
- fromIndex++;
-
- var toIndex = lowerText.indexOf("</" + tagName + ">", fromIndex);
- if (toIndex == -1) {
- return "";
- }
- return text.substring(fromIndex, toIndex);
- },
-
- addHeadUniqueTag: function(parts, id, tagName)
- {
- if (parts)
- {
- var combinedParts = "";
- var i, l = parts.length;
- for (i = 0; i < l; i++) {
- combinedParts += this.extractTagText(parts[i], tagName);
- }
- if (combinedParts != "") {
- this.addHeadTag(tagName, combinedParts, this.buildHeadTagId(id, tagName));
- }
- }
- },
- getCookie: function(name)
- {
- var value = null;
- if (document.cookie.length > 0)
- {
- var search = name + "=";
- var index = document.cookie.indexOf(search);
- if (index != -1)
- {
- var start = index + search.length;
- var end = document.cookie.indexOf(";", start);
- if (end == -1) {
- end = document.cookie.length;
- }
- value = unescape(document.cookie.substring(start, end));
- }
- }
- return value;
- },
-
- setCookie: function(name, value, expires, path, domain, secure)
- {
- if (typeof expires == "number")
- {
- expires = new Date(new Date().getTime() + (1000 * expires));
- }
- if (!secure) {
- secure = _F_Config.getSecure();
- }
- document.cookie = name + "=" + value +
- ((expires) ? "; expires=" + expires.toGMTString() : "") +
- ((path) ? "; path=" + path : "") +
- ((domain) ? "; domain=" + domain : "") +
- ((secure) ? "; secure" : "");
- },
-
- getTextContent: function(obj){
- if (obj.innerText) {
- return obj.innerText;
- }
- else if (obj.textContent) {
- return obj.textContent;
- }
- else {
- return "";
- }
- },
- parseXml: function(xmlString)
- {
- var xmlDoc = findXMLHttpActiveXVersion();
- if (xmlDoc) {
- xmlDoc.async="false";
- xmlDoc.loadXML(xmlString);
- } else {
- var parser = new DOMParser();
- xmlDoc = parser.parseFromString(xmlString,"text/xml");
- }
-
- return xmlDoc;
- }
- };
- /**
- * _F_DOM : Helper functions for reading XML document.
- */
- var _F_DOM =
- {
- selectNodes: function(node, xpath)
- {
- var arr = [];
-
- var doc = (node.ownerDocument) ? node.ownerDocument : node;
- if(doc.evaluate) {
- var results = doc.evaluate(xpath, node, doc.createNSResolver(doc.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
- if (results)
- {
- node = results.iterateNext();
- while (node != null)
- {
- arr.push(node);
- node = results.iterateNext();
- }
- return arr;
- }
- }
- else if('all' in document && 'selectNodes' in node) {
- var nodes = node.selectNodes(xpath);
- var i, l = nodes.length;
- for (i=0; i<l; i++)
- {
- arr.push(nodes.item(i));
- }
- return arr;
- }
- return null;
- },
-
- selectSingleNode: function (node, xpath)
- {
- var doc = (node.ownerDocument) ? node.ownerDocument : node;
- if (doc.evaluate) {
- var results = doc.evaluate(xpath, node, doc.createNSResolver(doc.documentElement), XPathResult.FIRST_ORDERED_NODE_TYPE, null);
- if (results && results.singleNodeValue) {
- return results.singleNodeValue;
- }
- return null;
- }
- else if ('all' in document && 'selectSingleNode' in node) {
- return node.selectSingleNode(xpath);
- }
- return null;
- },
-
- getAttribute: function(node, name)
- {
- return node.getAttribute(name);
- },
-
- text: function(node)
- {
- function deepScanText(node)
- {
- var v = "";
- var n = node.firstChild;
- while (n != null)
- {
- if (n.nodeType == 3) {
- v += n.nodeValue;
- }
- else if (n.nodeType == 4) {
- v += n.data;
- }
- else if (n.nodeType == 1) {
- v += deepScanText(n);
- }
- n = n.nextSibling;
- }
- return v;
- }
- if (node == null || node === undefined) {
- return "";
- }
- if (document.all) {
- return node.text;
- }
- else if (node.nodeValue) {
- return node.nodeValue;
- }
- return deepScanText(node);
- }
- };
- /**
- * @deprecated use _F_DOM.selectNodes()
- */
- function _F_DOM_selectNodes(node, xpath)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_DOM_selectNodes --> _F_DOM.selectNodes");
- return _F_DOM.selectNodes(node, xpath);
- }
- /**
- * @deprecated use _F_DOM.selectSingleNode()
- */
- function _F_DOM_selectSingleNode(node, xpath)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_DOM_selectSingleNode --> _F_DOM.selectSingleNode");
- return _F_DOM.selectSingleNode(node, xpath);
- }
- /**
- * @deprecated use _F_DOM.getAttribute()
- */
- function _F_DOM_getAttribute(node, name)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_DOM_getAttribute --> _F_DOM.getAttribute");
- return _F_DOM.getAttribute(node, name);
- }
- /**
- * @deprecated use _F_DOM.text()
- */
- function _F_DOM_text(node)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_DOM_text --> _F_DOM.text");
- return _F_DOM.text(node);
- }
- /**
- * _F_Form : Form helper functions
- */
- var _F_Form =
- {
- /**
- * Finds a form based on its unique name (e.g. _THIS_form)
- */
- find: function(name)
- {
- return document.forms[name];
- },
- lookupAction: function(action)
- {
- var forms = document.forms;
- var i, l = forms.length;
- for (i = 0; i < l; i++) {
- if (forms[i].action.indexOf(action) > -1) {
- return forms[i];
- }
- }
- return null;
- },
- getParamForInput: function(form, elem)
- {
- if (elem.disabled) {
- return null;
- }
-
- switch (elem.type)
- {
- case "select-multiple":
- var s = "";
- var i, l = elem.options.length;
- for (i = 0; i < l; i++) {
- if (elem.options[i].selected)
- {
- if (s != "") {
- s += "&";
- }
- s += this.getParamName(form, elem.name) + "=" + _F_Strings.urlEncode(elem.options[i].value);
- }
- }
- if (s != "") {
- return s;
- }
- break;
- case "select-one":
- if (elem.selectedIndex >= 0) {
- return this.getParamName(form, elem.name) + "=" + _F_Strings.urlEncode(elem.value);
- }
- break;
- case "radio":
- case "checkbox":
- if (!elem.checked) {
- return null;
- }
- case "text":
- case "textarea":
- case "password":
- case "hidden":
- case "submit":
- if (elem.value != null) {
- return this.getParamName(form, elem.name) + "=" + _F_Strings.urlEncode(elem.value);
- }
- // all other cases, return null
- case "button":
- return null;
- default:
- _F_log("W", "unsupported input named: " + elem.name + " (" + elem.type + ")");
- break;
- }
- return null;
- },
-
- /**
- * Used to override the input names (globally).
- */
- getParamName: function(form, name)
- {
- return name;
- },
-
- getParams: function(form)
- {
- var s = "";
- if (form != null)
- {
- var i, l = form.elements.length;
- for (i = 0; i < l; i++)
- {
- var elem = form.elements[i];
- if (elem.name != null && elem.name != "")
- {
- var param = this.getParamForInput(form, elem);
- if (param != null) {
- s += "&" + param;
- }
- }
- }
- }
- return s;
- },
-
- getActionParams: function(action)
- {
- return this.getParams(this.lookupAction(action));
- }
- };
- /**
- * @deprecated use _F_Form.getParams()
- */
- function _F_formScan(form)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_formScan --> _F_Form.getParams");
- return _F_Form.getParams(form);
- }
- /**
- * @deprecated use _F_Form.getParamsForAction()
- */
- function _F_formParams(action)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_formParams --> _F_Form.getActionParams");
- return _F_Form.getActionParams(action);
- }
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // Fragment Functions
- function _F_depth(obj)
- {
- var p = obj.parent;
- var count = 1;
- while (p != null)
- {
- count++;
- p = p.parent;
- }
- return count;
- }
- function _F_descendants(sId, sIdExclude, assoc)
- {
- // descendants all start with sId, excluding sId
- var list = [];
- for (var id in fragments)
- {
- if (fragments[id] != null) {
- if (id.indexOf(sId) == 0 && id != sIdExclude) {
- list.push(id);
- }
- }
- }
- // make sure the list is sorted on ids
- list = list.sort();
-
- var result = (assoc) ? {} : [];
- var i, l=list.length;
- if (assoc) {
- for (i=0; i<l; i++) {
- result[list[i]] = fragments[list[i]];
- }
- } else {
- for (i=0; i<l; i++) {
- result.push(fragments[list[i]]);
- }
- }
- return result;
- }
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // Fragment Event Object
- var _F_Event =
- {
- distributedEvents:
- [
- "fragment.load",
- "fragment.unload",
- "fragment.resize",
- "fragment.refresh",
- "fragment.visibility.change"
- ],
-
- propagatedEvents:
- [
- "fragment.load",
- "fragment.unload",
- "fragment.resize",
- "fragment.refresh",
- "fragment.windowstate.change",
- "fragment.visibility.change"
- ],
-
- /**
- * helper function that will dispatch an event to other members of a list
- */
- dispatch: function(list, evt, bReflected)
- {
- var targetIndex = _F_Array.indexOf(list, evt.target.id);
- var i, l = list.length;
- for (i = 0; i < l; i++)
- {
- if (i != targetIndex)
- {
- var oEvent = new _F_Event.Event();
- oEvent.initEvent(evt.name, evt.type, evt.payload, evt.bubbles, evt.cancelable);
- oEvent.source = evt.source;
- oEvent.reflected = bReflected;
- fragments[list[i]].dispatchEvent(oEvent);
- oEvent = null;
- }
- }
- },
-
- /**
- * Distribute event to a list
- */
- distribute: function(list, evt)
- {
- // ignore all reflected events
- if (evt.reflected) {
- return;
- }
-
- if (window._F_Debug !== undefined && evt.debugEnabled())
- {
- var phase = "";
- switch (evt.eventPhase) { case 1: phase = "CAPTURE"; break; case 2: phase = "TARGET"; break; case 3: phase = "BUBBLE"; }
- var source = evt.source ? evt.source.id : "none";
- _F_Debug.log.group("eventDistributor: " + evt.name + " (" + phase + ") - id: " + evt.currentTarget.id + " src: " + source);
- }
-
- // pass-down specific fragment events if raised on distributor fragment
- if (evt.eventPhase == evt.AT_TARGET && evt.name.indexOf("fragment.") == 0)
- {
- if (_F_Array.indexOf(this.distributedEvents, evt.name) > -1)
- {
- this.dispatch(list, evt, false);
- }
- }
- else
- {
- // if non-fragment event fired by child of page, distribute event to other children
- if (evt.name.indexOf("fragment.") != 0)
- {
- var targetIndex = _F_Array.indexOf(list, evt.target.id);
- if (targetIndex > -1) {
- this.dispatch(list, evt, true);
- }
- }
- }
-
-
- // prevent the default behaviour for fragment.refresh events targetted at an event distributor
- if (evt.eventPhase == evt.AT_TARGET && "fragment.refresh" == evt.name) {
- evt.preventDefault();
- }
- if (window._F_Debug !== undefined && evt.debugEnabled()) {
- _F_Debug.log.groupEnd();
- }
- },
- /**
- * Executes the event's handler function
- */
- execute: function(frag, listener, evt)
- {
- // handle late bound functions
- var func = null;
- if (typeof listener[1] == "string")
- {
- try
- {
- func = eval(listener[1]);
- }
- catch (e)
- {
- }
- }
- else {
- func = listener[1];
- }
-
- if (typeof func == "function")
- {
- try
- {
- func.call(frag, evt);
- }
- catch (e1)
- {
- _F_log("E", "Error in event handler function: " + e1 + ", function name=" + listener[1]);
- }
- }
- else {
- _F_log("E", "Expecting an event handler function, got: " + listener[1]);
- }
- }
- };
-
- _F_Event.Event = function()
- {
- this.name = "";
- this.type = "";
- this.payload = null;
- this.source = null;
- this.target = null;
- this.currentTarget = null;
- this.eventPhase = 0;
- this.bubbles = true;
- this.cancelable = true;
- this.cancelled = false;
- this.stopped = false;
- this.timeStamp = new Date();
- this.reflected = false;
- };
- _F_Event.Event.prototype =
- {
- CAPTURING_PHASE: 1,
- AT_TARGET: 2,
- BUBBLING_PHASE: 3,
- initEvent: function(name, type, payload, canBubble, cancelable)
- {
- this.name = name;
- this.type = type;
- this.payload = payload;
- this.bubbles = canBubble;
- this.cancelable = cancelable;
- this.cancelled = false;
- this.stopped = false;
- },
- preventDefault: function()
- {
- if (this.cancelable) {
- this.cancelled = true;
- }
- },
- stopPropagation: function()
- {
- this.stopped = true;
- }
- };
- /**
- * @deprecated: use _F_Event.distribute()
- */
- function _F_eventDistributor(list, evt)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_eventDistributor --> _F_Event.distribute");
- _F_Event.distribute(list, evt);
- }
- /**
- * @deprecated: use fragment.proxyEvent()
- */
- function _F_eventProxy(evt)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_eventProxy --> this.proxyEvent");
- this.proxyEvent(evt);
- }
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // Fragment Object
- // associative array of all active fragments by id
- var fragments = {};
- function fragment(path, id, div)
- {
- this.id = id;
- this.path = path;
- this.parent = findParent(this.id);
- this.div = div ? div : id + "content";
- this.state = null;
- this.custom = null;
- this.mode = "view";
- this.windowState = "normal";
- this.visibility = "visible";
- this.view = "";
- this.transientState = {};
- this.eventListeners = [];
- this.modes = [];
- this.windowStates = [];
- this.loaded = false;
- this.page = false;
- this.validator = null;
- this.internal = {
- requestCount: 0,
- locked: false,
- dirty: false
- };
- this.addEventListener("fragment.visibility.change", this.setVisibilityEvent, false);
- fragments[this.id] = this;
- function findParent(sId)
- {
- // parent has longest subid
- var frag = null;
- var fraglen = 0;
- for (var id in fragments)
- {
- var test = fragments[id];
- if (test != null)
- {
- if (sId != test.id && sId.indexOf(test.id) == 0 && test.id.length > fraglen)
- {
- frag = test;
- fraglen = frag.id.length;
- }
- }
- }
- return frag;
- }
- }
- fragment.prototype =
- {
- getRoot: function()
- {
- var frag = this;
- while (frag.parent) {
- frag = frag.parent;
- }
- return frag;
- },
- getChildren: function()
- {
- var children = [];
- for (var sId in fragments) {
- if (fragments[sId].parent == this) {
- children.push(fragments[sId]);
- }
- }
- return children;
- },
- getAncestors: function()
- {
- var ancestors = [];
- var frag = this.parent;
- while (frag)
- {
- ancestors.push(frag);
- frag = frag.parent;
- }
- return ancestors;
- },
- baseURI: function()
- {
- return "$CGI$" + _F_Config.application + this.path;
- },
- attach: function (obj)
- {
- for (var prop in obj) {
- this[prop] = obj[prop];
- }
- },
- encodedTransients: function()
- {
- var name;
- var transients = {};
-
- // add any page level trans, if they are not already included
- var p = this.getPageFragment();
- for (name in p.transientState) {
- if (transients[name] === undefined) {
- transients[name] = p.transientState[name];
- }
- }
-
- // finally, add global transients, if they are not already included
- for (name in this.transientGlobal) {
- if (transients[name] === undefined) {
- transients[name] = this.transientGlobal[name];
- }
- }
- // assemble everything as url
- var s = "";
- for (name in transients) {
- s += "&" + _F_Strings.urlEncode(name) + "=" + _F_Strings.urlEncode(transients[name]);
- }
- return s;
- },
-
- fragmentURI: function()
- {
- var s = "frag-id=" + this.id +
- "&frag-agent=" + _F_Strings.urlEncode(navigator.userAgent) +
- "&frag-mode=" + this.mode;
- if (_F_config.authToken) {
- s += "&frag-authToken=" + _F_Strings.urlEncode(_F_config.authToken);
- }
-
- if (this.validator != null && this.validator.remote) {
- s += "&frag-validator=" + this.validator.remote;
- }
- if (this.loaded && this.mode != "view" && _F_Array.indexOf(this.modes, this.mode) == -1) {
- s += "&frag-delegate=" + _F_Strings.urlEncode(this.mode);
- }
-
- if (this.view != "") {
- s += "&frag-view=" + _F_Strings.urlEncode(this.view);
- }
- if (this.windowState != "") {
- s += "&frag-windowState=" + _F_Strings.urlEncode(this.windowState);
- }
- if (this.channel !== undefined && this.channel != null) {
- s += "&frag-channel=" + _F_Strings.urlEncode(this.channel);
- }
- // state
- if (this.state != null) {
- s += "&frag-state=" + _F_Strings.urlEncode(this.state);
- }
- // custom properties
- if (this.custom != null) {
- s += "&frag-custom=" + _F_Strings.urlEncode(this.custom);
- }
- // transient properties
- s += this.encodedTransients();
-
-
- if (this.customProperties != null){
- var customParams = "";
- for (var cp in this.customProperties){
- if (customParams != "") {
- customParams += "&";
- }
- customParams+=cp + "=" + _F_Strings.urlEncode(this.customProperties[cp]);
- }
- s += "&frag-customProperties=" + _F_Strings.urlEncode(customParams);
- }
-
- return s;
- },
- renderURI: function(excludeDescendantState)
- {
- var s = this.baseURI();
- s += ((s.indexOf('?') >= 0) ? "&" : "?") + this.fragmentURI();
- if (excludeDescendantState === undefined || excludeDescendantState == false)
- {
- var descendants = _F_descendants(this.id, this.id);
- if (descendants)
- {
- for (var i=0; i < descendants.length; i++)
- {
- s += "&frag-sub=" + _F_Strings.urlEncode(descendants[i].fragmentURI());
- }
- }
- }
- return s;
- },
- interactionURI: function(sParams, excludeDescendantState)
- {
- if (sParams && sParams != "")
- {
- if (sParams.indexOf('&') != 0) {
- return (this.renderURI(excludeDescendantState) + "&" + sParams);
- }
- else {
- return (this.renderURI(excludeDescendantState) + sParams);
- }
- }
- return this.renderURI(excludeDescendantState);
- },
- update: function(markup, div)
- {
- div = div ? div : this.div;
- var divTag = $(div);
- var bFullUpdate = divTag == $(this.div);
- var bHasHtml = false;
- if (divTag != null)
- {
- if (bFullUpdate) {
- this.raiseEvent("fragment.unload", null, "", false, false);
- }
-
- var tempNode = document.createElement("div");
- // to get around IE problem. If markup starts with script tag, no at scripts will be loaded in the DOM
- tempNode.innerHTML = "<span style='display:none'> </span>" + markup;
- tempNode.removeChild(tempNode.firstChild);
-
- var scriptElements = tempNode.getElementsByTagName("SCRIPT");
- var scripts = [];
- var length = scriptElements.length;
- for (var i = length - 1 ; i >= 0; i--){
- scripts.unshift("<script>"+scriptElements[i].text+"</script>");
- if(scriptElements[i].parentNode){
- scriptElements[i].parentNode.removeChild(scriptElements[i]);
- }
- }
-
- var styleElements = tempNode.getElementsByTagName("STYLE");
- var styles = [];
- length = styleElements.length;
- for (var j = length - 1 ; j >= 0 ; j--){
- styles.unshift("<style>" + styleElements[j].innerHTML +"</style>");
- if(styleElements[j].parentNode){
- styleElements[j].parentNode.removeChild(styleElements[j]);
- }
- }
-
- // styles need to be available when html is inserted
- _F_Document.addHeadUniqueTag(styles, div, 'style');
-
- if (tempNode.childNodes){
- var nodesLength = tempNode.childNodes.length;
- for (var k = nodesLength - 1 ; k >= 0; k--){
- if ((tempNode.childNodes[k].nodeType != 3) ||
- (tempNode.childNodes[k].nodeType == 3 && tempNode.childNodes[k].nodeValue.replace(/^\s*|\s*$/g,"") != "")){
- if (!bHasHtml){
- divTag.innerHTML = "";
- divTag.appendChild(tempNode.childNodes[k]);
- bHasHtml = true;
- }else{
- divTag.insertBefore(tempNode.childNodes[k], divTag.firstChild);
- }
-
- }
- }
- }
-
- tempNode = null;
-
- /*
- This is to get around a FF issue where the script is loaded asynchronously.
- This means that the "fragment.load" event might be raised before the fragment script is evaluated.
- To get around the problem, we add the code that raises the event to the fragment script.
- */
- if (bFullUpdate && !xIE4Up){
- var loadEventScript = "<script>;fragments['"+this.id+"'].raiseEvent(\"fragment.load\", {source: \"retrieve\"}, \"\", false, false);</script>";
- scripts.push(loadEventScript);
- }
-
- // html needs to be available to javascript once it is inserted
- _F_Document.addHeadUniqueTag(scripts, div, 'script');
- if (window._F_Debug !== undefined && this.debugEnabled())
- {
- _F_Debug.log.logDetails("Update innerHTML for fragment: " + this.id + "\ttitle: " + _F_Strings.normalize(this.title), this);
- }
-
- if (bFullUpdate && xIE4Up) {
- this.raiseEvent("fragment.load", {source: "retrieve"}, "", false, false);
- }
- }
- else {
- _F_log("W", "target div was not found: "+div);
- }
- return bHasHtml;
- },
-
- performAction: function(sParams)
- {
- this.retrieve(sParams);
- },
- retrieve: function(sParams, dest, synchronous, excludeDescendantState)
- {
- if (!this.loaded) {
- if (!sParams) {
- sParams = "";
- }
- sParams += "&frag-action=attach";
- }
-
- if ( _F_depth(this) > 100)
- {
- window[this.id] = this;
- fragments[this.id] = this;
- this.processError("maxnestedlevels", PFM.JS.IDS_JS_ERROR_RETRIEVE, "");
- return;
- }
- // TODO: this function is added in uicommon.js, it should be removed and replaced with events
- if (this.clearerror) {
- this.clearerror();
- }
-
- this.send(sParams, dest, synchronous, excludeDescendantState);
- },
-
- send: function(sParams, dest, synchronous, excludeDescendantState)
- {
- if (this.internal.locked > 0)
- {
- // don't process this send, just mark the fragment as dirty
- this.internal.dirty = true;
- return;
- }
- else
- {
- this.internal.dirty = false;
- if (!this.raiseEvent("fragment.retrieve.before", sParams, "xsd:string"))
- {
- // preventDefault() was called, so invoke the "after" event
- // to keep the before/after contract valid.
- this.raiseEvent("fragment.retrieve.after", false, "xsd:boolean");
- return;
- }
- }
- // now we can process the request
- this.setRefreshDelay(0); // cancel any pending delay
- var requestCount = ++this.internal.requestCount;
- var _self = this;
- var requestOptions = {
- requestHeaders:
- {
- "Connection": "keep-alive",
- "Accept": "text/xml,application/xml"
- },
- onSuccess: function(transport)
- {
- // make the _THIS_ variable visible
- window[_self.id] = _self;
- fragments[_self.id] = _self;
-
- if (dest == null) {
- dest = _self.div;
- }
- if (dest == _self.div) {
- if (requestCount != _self.internal.requestCount)
- {
- _F_log("W", "discarding expired response for fragment: "+_self.id);
- _self.raiseEvent("fragment.retrieve.after", false, "xsd:boolean");
- return; //out of sequence detected - discard this response!
- }
- }
- var responseXML = this.getResponseXml();
-
- var xmlParseError = false;
- if (responseXML) {
- if ((responseXML.parseError && responseXML.parseError.errorCode != 0) ||
- (responseXML.documentElement && responseXML.documentElement.nodeName == "parsererror")) {
- xmlParseError = true;
- }
- } else {
- xmlParseError = true;
- }
-
- if (!xmlParseError)
- {
- var fragNode = _F_DOM.selectSingleNode(responseXML, "/fragment");
- if (fragNode != null)
- {
- var list = [];
- var i, l, href;
- var linkNodes = _F_DOM.selectNodes(fragNode, "./css");
- if (linkNodes && linkNodes.length > 0)
- {
- l = linkNodes.length;
- for (i = 0; i < l; i++)
- {
- href = _F_DOM.getAttribute(linkNodes[i], "href");
- var media = _F_DOM.getAttribute(linkNodes[i], "media");
- list.push(["LINK", href, media]);
- }
- }
-
- var librarieNodes = _F_DOM.selectNodes(fragNode, "./library");
- if (librarieNodes && librarieNodes.length > 0)
- {
- l = librarieNodes.length;
- for (i = 0; i < l; i++)
- {
- href = _F_DOM.getAttribute(librarieNodes[i], "href");
- list.push(["SCRIPT", href]);
- }
- }
- var processFragmentXMLFunction;
- if (xIE4Up && !synchronous) {
- // COGCQ0019952
- processFragmentXMLFunction = function(){
- var _args = arguments;
- setTimeout(function(){
- _self.processFragmentXML.apply(_self, _args);
- }, 1);
- };
- } else {
- processFragmentXMLFunction = _self.processFragmentXML;
- }
- _self.loadFragmentResources(list, processFragmentXMLFunction, fragNode, dest);
-
- }
- else
- {
- // check if we got an SOAP-Fault
- var fault = _F_DOM.selectSingleNode(responseXML, "/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Fault']");
- if (fault != null)
- {
- var code = _F_DOM.text(_F_DOM.selectSingleNode(fault, "./faultcode"));
- var msg = _F_DOM.text(_F_DOM.selectSingleNode(fault, "./faultstring"));
- var details = _F_DOM.text(_F_DOM.selectSingleNode(fault, "./faultdetails"));
- _self.processError(code, msg, details);
- }
- else
- {
- _self.processError("unexpected", PFM.JS.IDS_JS_ERROR_UNEXPECTED_RESPONSE, "");
- }
-
- _self.raiseEvent("fragment.retrieve.after", false, "xsd:boolean");
- _F_log("W", "expecting <fragment> XML for fragment: "+_self.id);
- }
- }
- else
- {
- //DEBUG: error response most likely html, show it
- var txt = this.getResponseText();
- var ecode = _F_Document.extractTagText(txt, "ERROR_CODE");
- if (ecode == "CAM_PASSPORT_ERROR")
- {
- // substitute the error code to an invalid passport
- _self.processError("invalidCredentials", null, null);
-
- _self.raiseEvent("fragment.retrieve.after", false, "xsd:boolean");
- _F_log("W", "expecting XML, got HTML for fragment: "+_self.id);
- }
- else
- {
- var bReloadPage = false;
- if (txt != null && _F_Config.responsePattern != null && _F_Config.responsePattern.length > 0)
- {
- var patterns = _F_Config.responsePattern.split(",");
- var i, l;
- var upperTxt = txt.toUpperCase();
- for (i = 0, l = patterns.length; i < l; i++) {
- if (patterns[i] != "" && (upperTxt.indexOf(patterns[i].toUpperCase()) != -1)) {
- // Ignore the HTML response, and reload the page. This will force the same HTML response to be returned
- // to this current page (presumably a 3rd party login page) and hopefully they will then redirect you back to
- // the current location. (pre AJAX/fragment action)
- bReloadPage = true;
- location.reload();
- }
- }
- }
- if (!bReloadPage) {
- // open up that HTML markup and let the end-user deal with it
- var emsg = _F_Document.extractTagText(txt, "ERROR_MSG");
- var edetails = _F_Document.extractTagText(txt, "ERROR_DETAILS");
- _self.processError(ecode, emsg, edetails);
- var w = window.open(_F_Config.webContent + "/common/blank.html", _self.id, "width=700,height=600,resizable,status=no,menubar=no,toolbar=no,location=no");
- w.document.open();
- w.document.write(txt);
- w.document.close();
- w.focus();
-
- _self.raiseEvent("fragment.retrieve.after", false, "xsd:boolean");
- _F_log("W", "expecting XML, got HTML for fragment: "+_self.id);
- }
- }
- }
- },
-
- onFailure: function(transport)
- {
- _self.raiseEvent("fragment.retrieve.after", false, "xsd:boolean");
- _F_log("E", "XMLHttp " + transport.status + ", " + transport.statusText);
- _F_alert("#" + transport.status + "\n" + transport.statusText, _self.title);
- },
-
- onException: function(request, e)
- {
- _self.raiseEvent("fragment.retrieve.after", false, "xsd:boolean");
- _F_alert(e, _self.title);
- }
- };
- if (synchronous != null && synchronous == true)
- {
- requestOptions.asynchronous=false;
- }
- var fragRequest = new _F_Ajax.Request(this.interactionURI(sParams, excludeDescendantState), requestOptions, this);
- },
-
- processFragmentXML: function(fragNode, dest)
- {
- // respond to delay
- var delayNode = _F_DOM.selectSingleNode(fragNode, "./delay");
- if (delayNode)
- {
- var period = _F_DOM.text(_F_DOM.selectSingleNode(delayNode, "period"));
- this.setRefreshDelay(period);
- }
- var bHasHtml = false;
- if (dest !== undefined)
- {
- var markupNode = _F_DOM.selectSingleNode(fragNode, "./markup/markupString");
- if (markupNode)
- {
- var markup = _F_DOM.text(markupNode);
- if (markup == "" && delayNode)
- {
- markup = _F_DOM.text(_F_DOM.selectSingleNode(delayNode, "message"));
- }
- if (markup != "")
- {
- try
- {
- bHasHtml = this.update(markup, dest);
- if (this.onupdate) {
- this.onupdate();
- }
- }
- catch (e)
- {
- _F_log("E", "execution error when updating markup for fragment: "+this.id);
- }
- }
- else {
- _F_log("W", "no markup text in markupString for fragment: "+this.id);
- }
- markupNode = null;
- }
- }
- // respond to newWindow
- var newWindowStateNode = _F_DOM.selectSingleNode(fragNode, "./newWindowState");
- // and to newMode
- var newModeNode = _F_DOM.selectSingleNode(fragNode, "./newMode");
- if (newWindowStateNode || newModeNode)
- {
- var newWindowState = _F_DOM.text(newWindowStateNode);
- var newMode = _F_DOM.text(newModeNode);
- if (newWindowState != "")
- {
- // this markup is already using the new window state, assign it right away
- this.setWindowState(newWindowState, "internal");
- }
-
- if (newMode != "")
- {
- // this markup is already using the new mode, assign it right away
- this.setMode(newMode, "internal");
- }
-
- // check if we must reload the fragment because no html was returned.
- if (!bHasHtml) {
- this.setRefreshDelay(1);
- }
- }
- // respond to validator
- var validatorNode = _F_DOM.selectSingleNode(fragNode, "./validator");
- if (validatorNode)
- {
- if (this.validator == null)
- {
- this.validator = {};
- this.validator.remote = null;
- this.validator.client = null;
- }
- try
- {
- this.validator.remote = _F_DOM.text(_F_DOM.selectSingleNode(validatorNode, "./remote"));
- this.validator.client = eval(_F_DOM.text(_F_DOM.selectSingleNode(validatorNode, "./client")));
- }
- catch (e1)
- {
- this.validator = null;
- _F_log("E", e1);
- }
- }
- var preferredTitleNode = _F_DOM.selectSingleNode(fragNode, "./preferredTitle");
- if (preferredTitleNode) {
- this.setTitle(_F_DOM.text(preferredTitleNode));
- }
- else if (this.info != null) {
- this.setTitle(this.info.title);
- }
- // respond to custom update
- var i, l;
- var customUpdateNode = _F_DOM.selectSingleNode(fragNode, "./customUpdate");
- if (customUpdateNode)
- {
- var customParams = _F_DOM.selectNodes(customUpdateNode, "./param");
- if(customParams && customParams.length > 0){
- this.customProperties = {};
- l = customParams.length;
- for (i = 0; i < l; i++)
- {
- var paramName = _F_DOM.getAttribute(customParams[i], "name");
- this.customProperties[paramName] = _F_DOM.text(customParams[i]);
- }
- }else{
- this.customProperties = {};
- this.custom = _F_DOM.text(customUpdateNode);
- }
-
- }
-
- // respond to state update
- var stateNode = _F_DOM.selectSingleNode(fragNode, "./state");
- if (stateNode)
- {
- this.state = _F_DOM.text(stateNode);
- }
-
- // raise events
- var eventNodes = _F_DOM.selectNodes(fragNode, "./event");
- if (eventNodes)
- {
- l = eventNodes.length;
- for (i = 0; i < l; i++)
- {
- var eventName = _F_DOM.getAttribute(eventNodes[i], "name");
- var eventType = _F_DOM.getAttribute(eventNodes[i], "type");
- var eventPayload = _F_DOM.selectSingleNode(eventNodes[i], "./payload");
- var payload = null;
- if (eventType.indexOf('params') > -1 && _F_DOM.selectSingleNode(eventPayload, "./params"))
- {
- var params = _F_DOM.selectNodes(eventPayload, "./params/param");
- payload = {};
- var j, m = params.length;
- for (j = 0; j < m; j++)
- {
- var name = _F_DOM.getAttribute(params[j], "name");
- var value = _F_DOM.text(params[j]);
- payload[name] = value;
- }
- }
- else
- {
- var payloadRoot = _F_DOM.selectSingleNode(eventPayload, "./*");
- if (payloadRoot) {
- payload = payloadRoot;
- }
- else {
- payload = _F_DOM.text(eventPayload);
- }
- }
- var evt = new _F_Event.Event();
- evt.initEvent(eventName, eventType, payload, true, true);
- evt.source = this;
- this.dispatchEvent(evt);
- }
- }
-
- var errorNode = _F_DOM.selectSingleNode(fragNode, "./error");
- if (errorNode)
- {
- var code = _F_DOM.text(_F_DOM.selectSingleNode(errorNode, "code"));
- var msg = _F_DOM.text(_F_DOM.selectSingleNode(errorNode, "message"));
- var details = _F_DOM.text(_F_DOM.selectSingleNode(errorNode, "details"));
- this.processError(code, msg, details);
- }
- // respond to transient updates
- var transientUpdateNodes = _F_DOM.selectNodes(fragNode, "./transientUpdate");
- if (transientUpdateNodes && transientUpdateNodes.length > 0)
- {
- var list = [];
- l = transientUpdateNodes.length;
- for (i = 0; i < l; i++)
- {
- var transUpdate = {};
- transUpdate.name = _F_DOM.getAttribute(transientUpdateNodes[i], "name");
- transUpdate.scope = _F_DOM.getAttribute(transientUpdateNodes[i], "scope");
- transUpdate.channel = _F_DOM.getAttribute(transientUpdateNodes[i], "channel");
- transUpdate.value = _F_DOM.text(transientUpdateNodes[i]);
- list[i] = transUpdate;
- }
-
- this.transientUpdateList(list, true);
- }
-
- // process subfragments
- var subfragmentNodes = _F_DOM.selectNodes(fragNode, "./subfragment/fragment");
- if (subfragmentNodes && subfragmentNodes.length > 0)
- {
- l = subfragmentNodes.length;
- for (i = 0; i < l; i++)
- {
- var fragID = _F_DOM.text(_F_DOM.selectSingleNode(subfragmentNodes[i], "./id"));
- var subfrag = fragments[fragID];
- if (subfrag !== undefined) {
- subfrag.processFragmentXML(subfragmentNodes[i]);
- }
- else {
- _F_log("E", "expecting fragment object for fragment id: " + fragID);
- }
- }
- }
-
- this.raiseEvent("fragment.retrieve.after", true, "xsd:boolean", true, false);
-
- // don't stop the queue processing
- return false;
- },
-
- loadFragmentResources: function(list, func)
- {
- if (window._F_Debug !== undefined && this.debugEnabled())
- {
- _F_Debug.log.logText("Begin _F_loadFragmentResources for id: " + this.id );
- }
-
- var args = Array.prototype.slice.call(arguments, 2);
- if (list.length == 0)
- {
- // nothing to load, execute right away
- if (typeof func == "function")
- {
- func.apply(this, args);
- }
- }
- else
- {
- // load external files
- var i, l;
- for (i = 0, l = list.length; i < l; i++)
- {
- _F_runQueue.add(_F_Resource, _F_Resource.loadResource, list[i]);
- }
- if (typeof func == "function")
- {
- _F_runQueue.add(this, func, args);
- }
-
- // execute first in queue
- _F_runQueue.run();
- }
-
- if (window._F_Debug !== undefined && this.debugEnabled())
- {
- _F_Debug.log.logText("End _F_loadFragmentResources for id: " + this.id);
- }
- },
-
- lockUpdates: function(locked)
- {
- //-- Bug Fix: Firefox bug that destroys the PDF document when we hide the iframe.
- // This is a firefox specific fix, referenced in firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=180802
- var embedFrames = [];
-
- function isEmbedFrame(iframe)
- {
- var doc = null;
- try
- {
- doc = iframe.contentDocument.firstChild;
- }
- catch (e)
- {
- doc = null;
- }
- return (doc
- && doc.tagName == "HTML"
- && doc.firstChild.tagName == "BODY"
- && doc.firstChild.firstChild.tagName == "EMBED"
- && doc.firstChild.firstChild.type.indexOf("pdf") > -1);
- }
- function addEmbedFrame(iframe)
- {
- if (_F_Array.indexOf(embedFrames, iframe, 0, true) < 0) {
- embedFrames.push(iframe);
- }
- }
- function searchEmbedFrames(frag)
- {
- // detect firefox browser, return if not
- if (_F_config.browser != "firefox") {
- return false;
- }
- // search fragment markup for iframes
- var div = $(frag.div);
- if (div)
- {
- var iframes = div.getElementsByTagName("iframe");
-
- // for each iframe check for embedded pdf
- if (iframes)
- {
- var i, l = iframes.length;
- for (i = 0; i < l; i++)
- {
- if (isEmbedFrame(iframes[i])) {
- addEmbedFrame(iframes[i]);
- }
- }
- }
- }
- }
-
- function reloadEmbedFrames()
- {
- var i, l = embedFrames.length;
- for (i = 0; i < l; i++)
- {
- embedFrames[i].setAttribute("src", embedFrames[i].getAttribute("src"));
- }
- }
- //-- /Bug Fix
-
- var list = _F_descendants(this.id);
- var i, l = list.length;
- if (locked)
- {
- for (i = 0; i < l; i++) {
- list[i].internal.locked++;
- }
- }
- else
- {
- var skipChildren = "";
- for (i = 0; i < l; i++)
- {
- var frag = list[i];
- if (0 <= (--frag.internal.locked))
- {
- frag.internal.locked = 0; // safety net
- if (frag.internal.dirty)
- {
- if (skipChildren != "" && (0 == frag.id.indexOf(skipChildren)))
- {
- // the parent fragment's retrieve is already called,
- // don't retrieve this child.
- frag.internal.dirty = false;
- continue;
- }
- else {
- skipChildren = frag.id;
- }
-
- frag.retrieve();
- }
- else {
- searchEmbedFrames(frag);
- }
- }
- }
- reloadEmbedFrames();
- }
- },
-
- /**
- * Callback function used to process logon fault.
- */
- processingLogon: null,
-
- processErrorHref: function() {
- return window.location.href;
- },
-
- processError: function(code, message, details)
- {
- if (code == "invalidCredentials")
- {
- if (window.handleLogon != null)
- {
- if (this.processingLogon == null)
- {
- xAddEventListener(window, "beforeunload", _F_config.emptyFunction); // hack: so onload event will be fired on cancel or back action
- var dashboard_login = _F_Document.getCookie("frag_login");
- if (dashboard_login == "true") {
- //Simply display the error
- this.onerror(message, details, code);
- return;
- }
- _F_Document.setCookie("frag_login", "true", 60);
- var _self = this;
- var href = this.processErrorHref();
- var rmidx = href.indexOf("#");
- if (rmidx != -1) {
- href = href.substring(0, rmidx);
- }
- window.location.replace(href + "#frag-logon"); //to mark that we're in a logon process
- this.processingLogon = window.setTimeout(
- function()
- {
- handleLogon(href, _self);
- _self.processingLogon = null;
- },
- 10);
-
- }
- return;
- }
- }
- this.onerror(message, details, code);
- },
-
- /**
- * Calls the client validator library for one specific parameter.
- * @param param
- * @param value
- * @return See validator.js for the meaning of the error codes
- * 0 = success
- * less than 0 = execution error of the validator's generated code
- * greater then 0 = validation error code.
- */
- validate: function(param, value)
- {
- if (this.validator != null &&
- this.validator.client != null &&
- typeof this.validator.client.verify == "function")
- {
- return this.validator.client.verify(param, value);
- }
- return 0;
- },
- //- events
- EVENT_NAME: 0,
- EVENT_FUNC: 1,
- EVENT_USECAP: 2,
- /**
- * Returns an array of indexes for matching event listeners, null if no match.
- * @param name: the event's name
- */
- findEventListeners: function(name)
- {
- // note: avoid creating unnecessary array objects
- var result = null;
- var i, l = this.eventListeners.length;
- for (i = 0; i < l; i++)
- {
- var sMatch = this.eventListeners[i][this.EVENT_NAME];
- if (sMatch == "*")
- {
- if (result == null) {
- result = [];
- }
- result.push(this.eventListeners[i]);
- continue;
- }
-
- if (sMatch.indexOf(".*") == sMatch.length - 2)
- {
- if (name.indexOf(sMatch.substring(0, sMatch.length - 1)) == 0)
- {
- if (result == null) {
- result = [];
- }
- result.push(this.eventListeners[i]);
- }
- }
- else
- if (name == sMatch)
- {
- if (result == null) {
- result = [];
- }
- result.push(this.eventListeners[i]);
- }
- }
- return result;
- },
- addEventListener: function(name, listener, useCapture)
- {
- useCapture = useCapture === undefined ? false : useCapture;
-
- // make sure listener not already in list
- var i, l = this.eventListeners.length;
- for (i = 0; i < l; i++) {
- if (this.eventListeners[i][this.EVENT_NAME] == name &&
- this.eventListeners[i][this.EVENT_FUNC] == listener &&
- this.eventListeners[i][this.EVENT_USECAP] == useCapture) {
- return;
- }
- }
-
- this.eventListeners.push([name, listener, useCapture]);
- if (window._F_Debug !== undefined && this.debugEnabled())
- {
- _F_Debug.log.logDetails("Added event listener for fragment: " + this.id + "\ttitle: " + _F_Strings.normalize(this.title) + "\tevent: " + name, this);
- }
- },
- removeEventListener: function(name, listener, useCapture)
- {
- useCapture = useCapture === undefined ? false : useCapture;
-
- // find listener
- var i, l = this.eventListeners.length;
- for (i = 0; i < l; i++)
- {
- if (this.eventListeners[i][this.EVENT_NAME] == name &&
- this.eventListeners[i][this.EVENT_FUNC] == listener &&
- this.eventListeners[i][this.EVENT_USECAP] == useCapture)
- {
- _F_Array.removeAt(this.eventListeners, i);
- if (window._F_Debug !== undefined && this.debugEnabled())
- {
- _F_Debug.log.logDetails("Removed event listener for fragment: " + this.id + "\ttitle: " + _F_Strings.normalize(this.title) + "\tevent: " + name, this);
- }
- break;
- }
- }
- },
- dispatchEvent: function(evt)
- {
- if (window._F_Debug !== undefined && evt.debugEnabled())
- {
- _F_Debug.log.logText("dispatchEvent: " + evt.name + " - id: " + this.id);
- }
- // prepare event object
- evt.target = this;
- evt.cancelled = false;
- evt.stopped = false;
- // prepare list of ancestor event handlers
- var scope = this.getAncestors();
- var indexes = new Array(scope.length);
- var hasListener = false;
- var i, l = scope.length;
- for (i = 0; i < l; i++)
- {
- indexes[i] = scope[i].findEventListeners(evt.name);
- if (indexes[i]) {
- hasListener = true;
- }
- }
- // capture phase
- if (hasListener)
- {
- evt.eventPhase = evt.CAPTURING_PHASE;
- l = scope.length;
- for (i = l - 1; i >= 0; i--)
- {
- if (indexes[i])
- {
- var j, m = indexes[i].length;
- for (j = 0; j < m; j++)
- {
- var listener = indexes[i][j];
- // useCapture true?
- if (listener[this.EVENT_USECAP])
- {
- evt.currentTarget = scope[i];
- _F_Event.execute(scope[i], listener, evt);
- }
- }
- if (evt.stopped) {
- return !evt.cancelled;
- }
- }
- }
- }
- // list of target event listeners
- var targetListeners = this.findEventListeners(evt.name);
- // at target phase
- if (targetListeners)
- {
- evt.eventPhase = evt.AT_TARGET;
- evt.currentTarget = this;
- l = targetListeners.length;
- for (i = 0; i < l; i++)
- {
- var listener1 = targetListeners[i];
- _F_Event.execute(this, listener1, evt);
- }
- if (evt.stopped) {
- return !evt.cancelled;
- }
- }
- // bubbling phase
- if (evt.bubbles && hasListener)
- {
- evt.eventPhase = evt.BUBBLING_PHASE;
- l = scope.length;
- for (i = 0; i < l; i++)
- {
- if (indexes[i])
- {
- var k, n = indexes[i].length;
- for (k = 0; k < n; k++)
- {
- var listener2 = indexes[i][k];
- // useCapture false?
- if (!listener2[this.EVENT_USECAP])
- {
- evt.currentTarget = scope[i];
- _F_Event.execute(scope[i], listener2, evt);
- }
- }
- if (evt.stopped) {
- return !evt.cancelled;
- }
- }
- }
- }
- // default behaviour for fragment events
- if (!evt.cancelled)
- {
- if ("fragment.refresh" == evt.name)
- {
- this.retrieve("frag-event=" + _F_Strings.urlEncode("name=" + evt.name));
- }
- }
- return !evt.cancelled;
- },
- raiseEvent: function(name, payload, type, bubbles, cancelable)
- {
- // If not initialized, we queue the event
- if (!this.onloadInitialized ){
- _F_eventQueue.add(this, this.raiseEvent, arguments);
- // we return trues so we don't cancel the event. Canceling it will affect the source fragment (e.g. canceling a retrieve event)
- return true;
- }
-
- bubbles = bubbles === undefined ? true : bubbles;
- cancelable = cancelable === undefined ? true : cancelable;
- var evt = new _F_Event.Event();
- evt.initEvent(name, type, payload, bubbles, cancelable);
- evt.source = this;
- return this.dispatchEvent(evt);
- },
- /**
- * Proxy an event to every children
- */
- proxyEvent: function(evt)
- {
- if (window._F_Debug !== undefined && evt.debugEnabled())
- {
- var phase = "";
- switch (evt.eventPhase) { case 1: phase = "CAPTURE"; break; case 2: phase = "TARGET"; break; case 3: phase = "BUBBLE"; }
- var source = evt.source ? evt.source.id : "none";
- _F_Debug.log.group("eventProxy: " + evt.name + " (" + phase + ") - id: " + this.id + " src: " + source);
- }
-
- // pass-down specific events if raised on proxy fragment
- var children;
- if (evt.eventPhase == evt.AT_TARGET)
- {
- var bPropagate = false;
-
- if (evt.name.indexOf("fragment.") == 0)
- {
- bPropagate = _F_Array.indexOf(_F_Event.propagatedEvents, evt.name) > -1;
- }
- else
- {
- // make sure event doesn't come from child
- bPropagate = !(evt.proxy && evt.proxy == this);
- }
-
- if (bPropagate)
- {
- children = this.getChildren();
- var i, l = children.length;
- for (i = 0; i < l; i++) {
- children[i].dispatchEvent(evt);
- }
- }
- }
- else
- {
- if (evt.name.indexOf("fragment.") != 0)
- {
- // fire event on self if event source is immediate child or from a child event proxy
- children = this.getChildren();
- if (_F_Array.indexOf(children, evt.source) > -1 || _F_Array.indexOf(children, evt.proxy) > -1)
- {
- evt.stopPropagation();
- var oEvent = new _F_Event.Event();
- oEvent.initEvent(evt.name, evt.type, evt.payload, evt.bubbles, evt.cancelable);
- oEvent.source = evt.source;
- oEvent.proxy = this;
- this.dispatchEvent(oEvent);
- }
- }
- }
-
- // prevent the default behaviour for fragment.refresh events targetted at an event proxy
- if (evt.eventPhase == evt.AT_TARGET && "fragment.refresh" == evt.name) {
- evt.preventDefault();
- }
- if (window._F_Debug !== undefined && evt.debugEnabled()) {
- _F_Debug.log.groupEnd();
- }
- },
- //- onload
- onloadInitialized: false,
- onloadHandlers: [],
-
- // old code for backwards compatibility (to be removed)
- setOnloadHandler: function(func)
- {
- if (this.onloadInitialized) {
- func();
- }
- else {
- this.onloadHandlers.push(func);
- }
- },
- //- transient properties
- transientGlobal: { },
- transientUpdate: function(sName, sValue, sScope, sChannel)
- {
- var scope;
- sChannel = ((sChannel == null || sChannel === undefined) ? this.channel||"" : sChannel);
- var sKey = sName + "[" + sChannel + "]";
- if (sScope == 'private')
- {
- // private communication
- scope = [this];
- }
- else if (sScope == 'page')
- {
- // set value in page transients
- var p = this.getPageFragment();
- p.transientState[sKey] = sValue;
- scope = _F_descendants(p.id);
- }
- else if (!(sScope) || sScope == "" || sScope == "application")
- {
- // set value in global transients
- scope = [];
- this.transientGlobal[sKey] = sValue;
- for (var id in fragments)
- {
- if (fragments[id] != null)
- {
- scope.push(fragments[id]);
- }
- }
- }
- else
- {
- // unsupported scope, do nothing
- scope = [];
- }
- var i, l;
- var refreshList = (arguments.length > 4) ? arguments[4] : null;
- if (refreshList)
- {
- l = scope.length;
- for (i = 0; i < l; i++)
- {
- try
- {
- if (scope[i].transientUpdateCheck(sName, sValue, sChannel, false)) {
- refreshList.push(scope[i]);
- }
- }
- catch (e)
- {
- _F_log("E", e);
- }
- }
- }
- else
- {
- l = scope.length;
- for (i = 0; i < l; i++)
- {
- try
- {
- scope[i].transientUpdateCheck(sName, sValue, sChannel, true);
- }
- catch (e1)
- {
- _F_log("E", e1);
- }
- }
- }
- },
-
- transientUpdateList: function(list)
- {
- if (list == null || list.length == 0) {
- return;
- }
- var serverUpdate = (arguments.length > 1) ? arguments[1] : false;
-
- var refreshList = [];
-
- var i, l = list.length;
- for (i = 0; i < l; i++) {
- this.transientUpdate(list[i].name, list[i].value, list[i].scope, list[i].channel, refreshList);
- }
- refreshList = _F_Array.unique(refreshList);
-
- if (serverUpdate) {
- _F_Array.remove(refreshList, this);
- }
-
- l = refreshList.length;
- for (i = 0; i < l; i++){
- var frag = refreshList[i];
- if (frag.raiseEvent("fragment.transientUpdate", list, "")){
- frag.retrieve();
- }
- }
-
- },
- /**
- * transientUpdateCheck - checks if this fragment should be refreshed because
- * the value was changed for the specified channel.
- * @param sName transient name
- * @param sValue new value
- * @param sChannel which channel name (string or undefined/null/'' are considered global)
- * @param bRefreshNow allow the call to retrieve
- */
- transientUpdateCheck: function(sName, sValue, sChannel, bRefreshNow)
- {
- if (this.transients)
- {
- var i, l = this.transients.length;
- for (i = 0; i < l; i++) {
- if (this.transients[i] == sName)
- {
- if ((this.transientState[sName] != sValue) && ((this.channel||'') == (sChannel||'')))
- {
- var refresh = this.transientNotify(sName, sValue);
- if (refresh && bRefreshNow){
- if (this.raiseEvent("fragment.transientUpdate", [{name: sName, value:sValue, channel:sChannel}], "")){
- this.retrieve();
- }
- }
- return refresh;
- }
- return false;
- }
- }
- }
- return false;
- },
- /**
- * transientNotify: assign the new value and returns true to do the
- * automatic refresh(), otherwise return false.
- * @param sName transient name
- * @param sValue new value to be set
- */
- transientNotify: function(sName, sValue)
- {
- this.transientState[sName] = sValue;
-
- if (window._F_Debug !== undefined && this.debugEnabled())
- {
- _F_Debug.log.logDetails("Transient Notify fragment: " + this.id + "\ttitle: " + _F_Strings.normalize(this.title),
- "name = " + sName + " value = " + sValue);
- }
-
- return true;
- },
- getPageFragment: function()
- {
- var p = this;
- while (p != null)
- {
- if (p.page) {
- return p;
- }
- p = p.parent;
- }
- return (this.parent != null) ? this.parent : this;
- },
- /**
- * Method sets the title of the fragment, the title will be added to the caption of the
- * fragment if the fragment has a caption.
- * When the method is called the fragment.title.change event is fired.
- * The event will have an object payload, containing the currentTitle and the newTitle.
- * If no one in the fragment chain handles the event and calls preventDefault,
- * the default behavior of fragment.retrieve() will occur.
- * @param text: title's text
- */
- setTitle: function(text)
- {
- if (this.raiseEvent("fragment.title.change",
- {
- "currentTitle":this.title,
- "newTitle":text
- },
- "params"))
- {
- this.title = text;
- }
- },
- /**
- * Method sets the mode of the fragment, modes can be any mode defined
- * in the fragment implementation file.
- * When the method is called the fragment.mode.change event is fired.
- * This event has an object payload, containing the currentMode and the newMode.
- * If no one in the fragment chain handles the event and calls preventDefault,
- * the default behavior of fragment.retrieve() will occur.
- * @param mode: new fragment mode
- */
- setMode: function(mode)
- {
- if (mode != "" && mode != this.mode)
- {
- var currentMode = this.mode;
- this.mode = mode;
- var performDefault = this.raiseEvent("fragment.mode.change",
- {
- "currentMode":currentMode,
- "newMode":this.mode
- }
- , "params");
- if (performDefault && (arguments[1] === undefined || arguments[1] != "internal")) {
- this.retrieve();
- }
- }
- },
- /**
- * Method sets the windowState of the fragment, windowState can be normal, maximized or minimized.
- * When the method is called the fragment.windowstate.change event is fired.
- * This event has an object payload, containing the currentWindowState and the newWindowState.
- * If no one in the fragment chain handles the event and calls preventDefault,
- * the default behavior of fragment.retrieve() will occur.
- * @param windowState: new fragment window state
- */
- setWindowState: function(windowState)
- {
- if (windowState != "" && windowState != this.windowState)
- {
- //Raising windowstate changed event
- var performDefault = this.raiseEvent("fragment.windowstate.change",
- {
- "currentWindowState":this.windowState,
- "newWindowState":windowState
- }
- , "params");
- this.windowState = windowState;
- //Raise a visiblility change event with siblings
- var siblings = this.parent.getChildren();
- var visibility = windowState=="maximized" ? "hidden" : "visible";
- for (var i=0; i<siblings.length; i++)
- {
- if (siblings[i].id != this.id)
- {
- siblings[i].raiseEvent("fragment.visibility.change",
- {
- "setVisibility":visibility
- }
- , "params", false, false);
- }
- else
- {
- siblings[i].raiseEvent("fragment.visibility.change",
- {
- "setVisibility":"visible"
- }
- , "params", false, false);
- }
- }
-
- if (performDefault && (_F_Array.indexOf(this.windowStates, windowState) > -1) && ((arguments[1] === undefined)||(arguments[1] != "internal"))) {
- this.retrieve();
- }
- }
- },
- /**
- * Default event handler for the fragment.visibility.change event. This event handler should be called first as it will
- * calculate and set old/new visibility for the fragment and update both the fragment and event with this data for the
- * use of subsequent window.visibility.change event handlers.
- * @param evt: window.visibility.change event object
- */
- setVisibilityEvent: function(evt)
- {
- if (evt.eventPhase == evt.AT_TARGET)
- {
- evt.payload.currentVisibility = this.visibility;
- var newVisibility;
- if (evt.payload.setVisibility == "hidden")
- {
- newVisibility = "hidden";
- }
- else
- {
- if (this.windowState == "minimized")
- {
- newVisibility = "hidden";
- }
- else
- {
- newVisibility = "visible";
- }
- }
- evt.payload.newVisibility = newVisibility;
- this.visibility = newVisibility;
- }
- },
- /**
- * Instruct this fragment to refresh itself in a number of seconds.
- * Calling this method with a value of 0 will cancel the current pending refresh, however
- * there's no garantee that the refresh would be effectively cancelled.
- * @param sec: number of seconds
- */
- setRefreshDelay: function(sec)
- {
- if (this.refreshTimeout) {
- window.clearInterval(this.refreshTimeout);
- }
- if (sec > 0)
- {
- var _self = this;
- this.refreshTimeout = window.setTimeout(
- function()
- {
- _self.retrieve();
- },
- sec * 1000);
- }
- },
-
- //- error handling
-
- onerror: function(msg, details, code)
- {
- _F_alert(code + ":\n" + msg + "\n\n" + details, this.title);
- },
- /**
- * Destroys a fragment and all its children.
- */
- destroy: function()
- {
- // call event handlers and delete this object
- this.raiseEvent("fragment.unload", null, "", true, false);
- // recursively call destroy on children
- var children = this.getChildren();
- var i, l = children.length;
- for (i = 0; i < l; i++) {
- children[i].destroy();
- }
- // remove private scripts and styles
- _F_Document.removeHeadTag(_F_Document.buildHeadTagId(this.id, "SCRIPT"));
- _F_Document.removeHeadTag(_F_Document.buildHeadTagId(this.id, "LINK"));
- if ($(this.div)) {
- $(this.div).innerHTML = "";
- }
- this.raiseEvent("fragment.destroy", null, "", true, false);
- delete fragments[this.id];
- },
- reloadAll: function ()
- {
- var action = _F_Config.gateway + _F_Config.application;
- var formElement = document.createElement("form");
- formElement.setAttribute("name","pageload");
- formElement.setAttribute("method","POST");
- formElement.setAttribute("action",_F_Config.gateway);
-
- hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- hiddenElement.setAttribute("name","b_action");
- hiddenElement.setAttribute("value",_F_Config.application.substring(1));
- formElement.appendChild(hiddenElement);
-
- for (var id in fragments)
- {
- var frag = fragments[id];
- if (frag.parent == null)
- {
- var path = frag.path;
- if (frag.id == "cm")
- {
- hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- hiddenElement.setAttribute("name","pathinfo");
- hiddenElement.setAttribute("value","/cm");
- formElement.appendChild(hiddenElement);
- hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- hiddenElement.setAttribute("name","path");
- hiddenElement.setAttribute("value","storeID(\"" + frag.path.substring(frag.path.lastIndexOf("/")+1) + "\")");
- formElement.appendChild(hiddenElement);
- }
- else
- {
- hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- hiddenElement.setAttribute("name","pathinfo");
- hiddenElement.setAttribute("value",frag.path);
- formElement.appendChild(hiddenElement);
- }
- }
- //Raise an event before capturing the state of the fragment so that any needed updates can be done
- frag.raiseEvent("fragment.reload", null, "", false, false);
-
- hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- hiddenElement.setAttribute("name","frag-sub");
- hiddenElement.setAttribute("value",frag.fragmentURI());
- formElement.appendChild(hiddenElement);
- }
- //Assume a header is present
- hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- hiddenElement.setAttribute("name","frag-header");
- hiddenElement.setAttribute("value","true");
- formElement.appendChild(hiddenElement);
- document.body.appendChild(formElement);
- formElement.submit();
- document.body.removeChild(formElement);
- formElement = null;
- }
- };
- //--------------------------------------------------------------
- // Drag and Drop
- // find the nearest element up the chain that begins with "labelPrefix" in its id
- function _F_findParentObj(obj, labelPrefix)
- {
- while (obj)
- {
- if (obj.id && obj.id.indexOf(labelPrefix) == 0) {
- return obj;
- }
- obj = xParent(obj, true);
- }
- return obj;
- }
- // find the nearest element up the chain that begins with "label" in its id
- function _F_ancestorFragments(obj)
- {
- var list = [];
- while (obj)
- {
- var id = obj.id;
- if (id && id.indexOf('content') == id.length - 7) {
- list.push(obj);
- }
- obj = xParent(obj, true);
- }
- return list;
- }
- //-- dragContext Object
- function dragContext(obj)
- {
- this.obj = obj;
- if (this.obj.getAttributeNode("payload")) {
- this.payload = this.obj.getAttributeNode("payload").nodeValue;
- }
- if (this.obj.getAttributeNode("itemtitle")) {
- this.title = this.obj.getAttributeNode("itemtitle").nodeValue;
- }
- if (this.obj.getAttributeNode("dragtype"))
- {
- this.type = this.obj.getAttributeNode("dragtype").nodeValue;
- }
- else
- {
- // extract object class and any extra info
- var s = obj.id.substring(9);
- s = s.substring(0, s.indexOf("_"));
- var n = s.indexOf(".");
- if (n != -1)
- {
- this.type = s.substring(0, n);
- this.info = s.substring(n+1);
- }
- else {
- this.type = s;
- }
- }
- // drop target handling
- this.xevent = null;
- this.dropType = 0;
- this.dropTarget = null;
- this.dropHandler = null;
- // drag icon display states
- this.imgPath = _F_Config.webContent + "/fragments/dragdrop/images/";
- this.bDragMulti = false; // _multi
- this.bDragDrop = false; // _nodrop
- this.bDragCopy = false; // _copy
- this.init();
- }
- dragContext.prototype =
- {
- div: null,
- img: null,
- icons: [],
- iconNames:
- [
- "drag_cursor",
- "drag_cursor_copy",
- "drag_cursor_nodrop",
- "drag_cursor_multi",
- "drag_cursor_multi_copy",
- "drag_cursor_multi_nodrop",
- "drag_cursor_multi_nodrop_copy"
- ],
- init: function()
- {
- if (!this.div)
- {
- this.div = document.createElement('DIV');
- this.div.setAttribute("id", "F_dragDiv");
- this.div.style.position = "absolute";
- this.div.style.visibility = "hidden";
- this.div.style.zIndex = "100";
-
- this.img = document.createElement('IMG');
- this.img.setAttribute("name", "F_dragImage");
- this.img.setAttribute("src", this.imgPath + "drag_cursor.gif");
- this.img.setAttribute("width", "22");
- this.img.setAttribute("height", "22");
- this.img.setAttribute("border", "0");
-
- this.div.appendChild(this.img);
- document.body.appendChild(this.div);
- // load images
- var i, l = this.iconNames.length;
- for (i = 0; i < l; i++)
- {
- var icon = new Image(22, 22);
- icon.src = this.imgPath + this.iconNames[i] + ".gif";
- this.icons[this.iconNames[i]] = icon;
- }
- }
- },
-
- updateIcon: function()
- {
- var sName = "drag_cursor" +
- (this.bDragMulti ? "_multi" : "") +
- (this.bDragDrop ? "" : "_nodrop") +
- (this.bDragCopy ? "_copy" : "");
- if (this.icons[sName]) {
- this.img.src = this.icons[sName].src;
- }
- },
- canDrop: function(bDrop)
- {
- if (this.bDragDrop != bDrop)
- {
- this.bDragDrop = bDrop;
- this.updateIcon();
- }
- },
- capture: function(e)
- {
- this.xevent = e;
- xMoveTo(this.div, e.pageX + 5, e.pageY + 8);
- xShow(this.div);
- this.updateIcon();
- },
- ENTER: 0,
- MOVE: 1,
- LEAVE: 2,
- DROP: 3,
-
- move: function(e)
- {
- this.xevent = e;
- xMoveTo(this.div, e.pageX + 5, e.pageY + 8);
-
- var droplist = _F_ancestorFragments(e.target);
- var drop = null;
- var frag = null;
- var i, l = droplist.length;
- for (i = 0; i < l; i++)
- {
- var id = droplist[i].id.substring(0, droplist[i].id.length - 7);
- frag = fragments[id];
- if (frag && frag.ondrop)
- {
- drop = droplist[i];
- break;
- }
- }
- if (drop != this.dropTarget)
- {
- if (this.dropTarget)
- {
- this.dropType = this.LEAVE;
- this.dropHandler(this);
- this.dropTarget = null;
- this.dropHandler = null;
- this.canDrop(false);
- }
- }
- if (drop)
- {
- this.dropTarget = drop;
- this.dropHandler = frag.ondrop;
- this.dropType = this.ENTER;
- this.dropHandler(this);
- }
- if (this.dropTarget)
- {
- this.dropType = this.MOVE;
- this.dropHandler(this);
- }
- },
- release: function(e)
- {
- this.xevent = e;
- xHide(this.div);
- if (this.dropTarget)
- {
- this.dropType = this.bDragDrop ? this.DROP : this.LEAVE;
- this.dropHandler(this);
- this.dropTarget = null;
- this.dropHandler = null;
- }
- }
- };
- //-- _F_Drag Singleton
- var _F_Drag =
- {
- obj: null,
- startX: 0,
- startY: 0,
- dragging: false,
- context: null,
- pending: function(obj, e)
- {
- this.obj = obj;
- this.startX = e.pageX;
- this.startY = e.pageY;
- this.dragging = false;
- this.context = null;
- },
- start: function(e)
- {
- this.dragging = true;
- this.context = new dragContext(this.obj);
- this.context.capture(e);
- },
- move: function(e)
- {
- if (!this.dragging)
- {
- // check for drag outside the start rect
- if ((e.pageX > (this.startX + 8)) || (e.pageX < (this.startX - 8)) ||
- (e.pageY > (this.startY + 8)) || (e.pageY < (this.startY - 8)))
- {
- this.start(e);
- }
- }
-
- if (this.context) {
- this.context.move(e);
- }
- },
- stop: function(e)
- {
- if (this.context) {
- this.context.release(e);
- }
-
- this.obj = null;
- this.dragging = false;
- this.context = null;
- }
- };
- //-- Mouse Event handling
- function _F_dragMD(evt)
- {
- // capture events
- var e = new xEvent(evt);
-
- var obj = _F_findParentObj(e.target, 'dragitem_');
- if (obj)
- {
- xPreventDefault(evt);
- _F_Drag.pending(obj, e);
- xAddEventListener(document, "mousemove", _F_dragMM, false);
- xAddEventListener(document, "mouseup", _F_dragMU, false);
- }
- }
- function _F_dragMM(evt)
- {
- var e = new xEvent(evt);
- xPreventDefault(evt);
- _F_Drag.move(e);
- }
- function _F_dragMU(evt)
- {
- var e = new xEvent(evt);
- xPreventDefault(evt);
- _F_Drag.stop(e);
-
- xRemoveEventListener(document, "mousemove", _F_dragMM);
- xRemoveEventListener(document, "mouseup", _F_dragMU);
- }
- //------------------------------------------------------------------------------
- // execute a method on an object with arguments
- var _F_Queue =
- {
- };
- _F_Queue.Runnable = function(obj, func, args)
- {
- this.obj = obj;
- this.func = func;
- this.args = args;
- };
- _F_Queue.Runnable.prototype =
- {
- run: function()
- {
- var stopRun = this.func.apply(this.obj, this.args);
- this.func = null;
- this.obj = null;
- this.args = null;
- return stopRun;
- }
- };
- _F_Queue.Queue = function()
- {
- this.head = null;
- this.tail = null;
- };
- _F_Queue.Queue.prototype =
- {
- add: function(obj)
- {
- var newEntry =
- {
- value: obj,
- next: null
- };
- if (this.tail) {
- this.tail.next = newEntry;
- }
- else {
- this.head = newEntry;
- }
- this.tail = newEntry;
- },
-
- hasNext: function()
- {
- return (this.head != null);
- },
-
- next: function()
- {
- var entry = this.head;
- var obj = entry.value;
- this.head = entry.next;
- if (entry.next == null) {
- this.tail = null;
- }
-
- entry.next = null;
- delete (entry);
- return obj;
- }
- };
- _F_Queue.RunQueue = function()
- {
- this.queue = new _F_Queue.Queue();
- this.isRunning = false;
- };
- _F_Queue.RunQueue.prototype =
- {
- add: function(obj, func, args)
- {
- this.queue.add(new _F_Queue.Runnable(obj, func, args));
- },
- run: function()
- {
- if (!this.isRunning){
- this.isRunning = true;
- this.resume();
- }
-
- },
- resume: function()
- {
- while (this.queue.hasNext()) {
- if (this.queue.next().run()) {
- break;
- }
- }
-
- this.isRunning = this.queue.hasNext();
- }
- };
- var _F_runQueue = new _F_Queue.RunQueue();
- var _F_eventQueue = new _F_Queue.RunQueue();
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // Framework
- function _F_attach(obj)
- {
- var frag = fragments[obj.id];
- if (!frag) {
- frag = new fragment(obj.path, obj.id, obj.div);
- }
- if (!frag.loaded)
- {
- frag.attach(obj);
- if (frag.title) {
- frag.setTitle(frag.title);
- }
- frag.loaded = true;
- if (window._F_Debug !== undefined && frag.debugEnabled())
- {
- _F_Debug.log.logDetails("Attach fragment: " + frag.id + "\ttitle: " + _F_Strings.normalize(frag.title),
- "path: " + obj.path, frag);
- }
-
- frag.raiseEvent("fragment.create", null, "", true, false);
- }
- else
- {
- frag.channel = obj.channel;
- }
- return frag;
- }
- function _F_resize()
- {
- var skipChildren = null;
- var list = (arguments.length == 1) ? arguments[0] : fragments;
- for (var id in list)
- {
- if (skipChildren != null && id.indexOf(skipChildren) == 0) {
- continue;
- }
- if (fragments[id] != null && fragments[id].onresize && fragments[id].onresize() == true) {
- skipChildren = id;
- }
- else {
- skipChildren = null;
- }
- }
- }
- function _F_onload(){
- if (window.location.href.indexOf("#frag-logon") != -1) {
- document.cookie = "frag_login=";
- }
- fragment.prototype.onloadInitialized = true;
-
- // old code for backwards compatibility (to be removed)
- var i, l = fragment.prototype.onloadHandlers.length;
- for (i = 0; i < l; i++) {
- fragment.prototype.onloadHandlers[i]();
- }
- // fire "fragment.load" event on all fragments
- var oEvent = new _F_Event.Event();
- var isbrowserBack = false;
- var backJaxForm = $('cps_backjaxform');
- if (typeof backJaxForm != "undefined" && backJaxForm != null)
- {
- if (typeof backJaxForm.visited != "undefined")
- {
- isbrowserBack = ("true" == backJaxForm.visited.value);
- backJaxForm.visited.value = "true";
- }
- }
- oEvent.initEvent("fragment.load", "", {source: isbrowserBack? "cache" : "dom"}, false, false);
- for (var id in fragments)
- {
- if (fragments[id].parent == null)
- {
- oEvent.source = fragments[id];
- fragments[id].dispatchEvent(oEvent);
- }
- }
- _F_eventQueue.run();
- while(_F_eventQueue.queue.hasNext()) {
- _F_eventQueue.resume();
- }
- }
- function _F_onresize()
- {
- _F_resize();
- return true;
- }
- function _F_init()
- {
- _F_Config.initialize();
- _F_Resource.initialize();
- _F_onload();
- _F_Document.addEventListener(window, "resize", _F_onresize, true);
- _F_Document.addEventListener(document, "mousedown", _F_dragMD);
- if (window._F_Debug !== undefined && _F_Debug.enabled)
- {
- _F_Debug.initialize();
- }
-
- }
- function _F_getFragmentByID(fid)
- {
- return window.fragments[fid];
- }
- _F_Document.addEventListener(window, "load", _F_init);
- /**
- * @deprecated: use _F_Document.getCookie()
- */
- function _F_getCookie(name)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_getCookie --> _F_Document.getCookie");
- return _F_Document.getCookie(name);
- }
- /**
- * @deprecated: use _F_Document.setCookie()
- */
- function _F_setCookie(name, value, expires, path, domain, secure)
- {
- _F_log("W", "DEPRECATED FUNCTION: _F_setCookie --> _F_Document.setCookie");
- _F_Document.setCookie(name, value, expires, path, domain, secure);
- }
|