123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: cpscrn
- //
- // (C) Copyright IBM Corp. 2005, 2021
- //
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- //
- //
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- if (window.dojo) {
- dojo.require("dijit.dijit");
- }
- var maximizeBVToAvailableHeight = true;
- /**
- * ui_templates
- * Singleton to hold the current html templates.
- */
- var ui_templates = {
- contentTemplate:
- '<div id="^CONTENTID^" class="^CONTENTCLASS^" style="width:100%; height:100%;">' +
- '<table removeonerror="true" cellspacing="0" cellpadding="0" border="0" width="100%">' +
- '<tr>' +
- '<td style="text-align:center">' +
- '<br><br><br>' +
- '<div>' +
- '<img src="$WEB$/fragments/common/images/progress.gif" border="0">' +
- '<br>' +
- '<span>' +
- PFM.JS.IDS_JS_TAB_WAIT +
- '</span>' +
- '</div>' +
- '<br><br><br>' +
- '</td>' +
- '</tr>' +
- '</table>' +
- '</div>',
- /**
- * get usage:
- * using param names in message string:
- * get(template, "name1", "value1", "name2", "value2", ...)
- * using indexes in message string:
- * get(msg, ["value1", "value2", ...])
- */
- get: function(sourceString) {
- var result = sourceString;
- var i, l=arguments.length;
- if (l == 2 && typeof arguments[1] == "object" && arguments[1].length > 0) {
- // second argument is an array of values
- args = arguments[1];
- l = args.length;
- for (i = 0; i < l; i++) {
- result = result.replace(new RegExp("\\^" + i + "\\^"), args[i]);
- }
- } else {
- for (i = 1; (i + 1) < l; i += 2) {
- result = result.replace(new RegExp("\\^" + arguments[i] + "\\^"), arguments[i + 1]);
- }
- }
- return _F_Config.expandMacros(result);
- },
- preload: function() {
- new Image().src = _F_Config.expandMacros("$WEB$/fragments/common/images/progress.gif");
- }
- };
- /**
- * ui_htabs
- * @param obj containing: "frag" a fragment object, "id" unique identifier,
- * "activeTabID" current active tab identifier and "tabs" array of ui_htab objects.
- */
- function ui_htabs(obj, height) {
- this.parent = null;
- this.tabs = { };
- for (var o in obj) {
- this[o] = obj[o];
- }
- if (this.activeTabID === undefined) {
- for (var t in this.tabs) {
- this.activeTabID = t;
- break;
- }
- }
- this.pos = 0;
- this.scrollTimer = null;
- this.tableID = this.uniqueID() + "table";
- this.tabCellID = this.uniqueID() + "tabscell";
- this.buttons = {
- left: new ui_tabbutton({ id: this.frag.id + this.id + "leftbutton", type: "left" }),
- right: new ui_tabbutton({ id: this.frag.id + this.id + "rightbutton", type: "right" })
- };
- this.buttonsEnabled = false;
- }
- ui_htabs.prototype = {
- uniqueID: function() {
- return this.frag.id + this.id;
- },
-
- attach: function(parent) {
- this.parent = parent;
- for (var t in this.tabs) {
- this.tabs[t].attach(this);
- }
- this.buttons.left.attach(this);
- this.buttons.right.attach(this);
- },
- add: function(tab) {
- this.tabs[tab.id] = tab;
- tab.attach(this);
- },
-
- remove: function(id) {
- if (this.tabs[id] != null) {
- if (this.active() == id) {
- for (var x in this.tabs) {
- if (x != id) {
- this.select(x);
- break;
- }
- }
- }
- delete this.tabs[id];
- }
- },
-
- select: function(id) {
- if (this.tabs[id] != null) {
- var cur = this.active();
- if (cur != "") {
- this.tabs[cur].deselect();
- }
- this.activeTabID = id;
- this.tabs[id].select();
- }
- },
-
- getTab: function(posIdx) {
- var x = 0;
- for (var tabId in this.tabs) {
- if (x++==posIdx) {
- return this.tabs[tabId];
- }
- }
- },
-
- active: function() {
- return this.activeTabID;
- },
-
- getRoot: function() {
- var p = this;
- while (p.parent != null) {
- p = p.parent;
- }
- return p;
- },
-
- isFixed: function() {
- return this.getRoot().fixed == true;
- },
-
- onresize: function() { //ui_htabs
- var _self = this;
- window.setTimeout(function() { _self.adjustLayout(); }, 1);
- if (this.active() != "") {
- this.tabs[this.active()].onresize();
- }
- },
-
- scroll: function(dir) {
- if (!this.buttonsEnabled) {
- return;
- }
- var pos = this.pos + ((dir == "left") ? 5 : -5);
- this.setScrollPosition(pos);
- },
-
- setScrollPosition: function(pos){
- this.pos = pos;
- var table = $(this.tableID);
- if (this.pos >= 0) {
- this.pos = 0;
- } else {
- var td = xParent(xParent(table, true), true);
- var maxX = (xPageX(table) + xWidth(table)) - (xPageX(td) + xWidth(td)) - 5;
- if (maxX < 0) {
- this.pos -= maxX;
- }
- }
-
- table.style.marginLeft = this.pos + "px";
- },
-
- scrollTo: function(tab){
- var node = $(tab.tabID)
- var tabPosition = xLeft(node);
- var tabWidth = xWidth(node);
- var clientWidth = xClientWidth();
- if ((tabPosition + this.pos) > clientWidth) {
- this.setScrollPosition(clientWidth - tabPosition - tabWidth - 30);
- }
- },
-
- startScroll: function(dir) {
- if (!this.buttonsEnabled) {
- return;
- }
-
- // If there is already an active timer, it should be stopped first to avoid it from being lost (i.e.: running) forever
- if (this.scrollTimer != null) {
- window.clearInterval(this.scrollTimer);
- this.scrollTimer = null;
- }
-
- var _self = this;
- this.scrollTimer = window.setInterval(function() { _self.scroll(dir); }, 10);
- },
-
- stopScroll: function() {
- if (!this.buttonsEnabled) {
- return;
- }
- if (this.scrollTimer != null) {
- window.clearInterval(this.scrollTimer);
- this.scrollTimer = null;
- }
- },
-
- adjustLayout: function() {
- var table = $(this.tableID);
- var tabsCell = $(this.tabCellID);
- if (table == null) {
- return;
- }
- if (tabsCell) {
- //Reflow the tabs cell, as the width can become confused if it is hidden and re-shown in IE
- tabsCell.style.width="0";
- tabsCell.style.width="";
- }
- var td = xParent(xParent(table, true), true);
- // test of a firefox bug
- if (xWidth(td) == 0) {
- xWidth(td, xWidth(table));
- }
- var tabX = xPageX(td) + xWidth(td);
- if (this.pos < 0) {
- var maxX = (xPageX(table) + xWidth(table)) - tabX;
- if (maxX < 0) {
- this.pos -= maxX;
- }
- if (this.pos > 0) {
- this.pos = 0;
- }
- table.style.marginLeft = this.pos + "px";
- }
- this.buttonsEnabled = (xPageX(table) + xWidth(table)) >= tabX;
- this.buttons.left.setEnable(this.buttonsEnabled);
- this.buttons.right.setEnable(this.buttonsEnabled);
- }
- };
- /**
- * ui_htab
- * @param obj
- */
- function ui_htab(obj) {
- this.id = null;
- this.parent = null;
- this.loaded = false;
- this.refreshRequired = false;
- this.href = null;
- this.subtabs = null;
- this.width = -1;
- this.height = -1;
- this.customProperties = null;
- for (var o in obj) {
- this[o] = obj[o];
- }
- }
- ui_htab.prototype = {
- uniqueID: function() {
- if (this.parent != null) {
- return this.parent.uniqueID() + this.id;
- }
- return this.id;
- },
-
- attach: function(parent) {
- this.parent = parent;
- var uniqueID = this.parent.uniqueID() + this.id;
- if (this.tabID == null) {
- this.tabID = uniqueID + "tab";
- }
- if (this.pageID == null) {
- this.pageID = uniqueID + "page";
- }
- if (this.contentID == null) {
- this.contentID = uniqueID + "content";
- }
- if (this.subtabs != null) {
- this.subtabs.attach(this);
- }
- var elem = $(this.tabID);
- if (elem != null) {
- xAddEventListener(elem, "click", _F_Document.associate(elem, this, "onclick"));
- xAddEventListener(elem, "keypress", _F_Document.associate(elem, this, "onkeypress"));
- }
- },
- createPage: function() {
- var tabContainer = $(this.parent.frag.id + "bvContainer");
- var pageDiv = document.createElement("DIV");
- pageDiv.id = this.pageID;
- pageDiv.style.display="none";
- pageDiv.style.width="100%";
- pageDiv.style.height="100%";
- pageDiv.setAttribute("role", "tabpanel");
- var tabAnchorId = this.tabID + "_anchor";
- pageDiv.setAttribute("aria-labelledby", tabAnchorId);
- var tabEl = $(tabAnchorId);
- if (tabEl != null){
- tabEl.setAttribute("aria-controls", this.pageID);
- }
-
- var contentDiv = ui_templates.get(
- ui_templates.contentTemplate,
- 'CONTENTID', this.contentID,
- 'CONTENTCLASS', (this.parent.isFixed() ? "cogstyle-htabs-page-content-fixed" : "cogstyle-htabs-page-content")
- );
- pageDiv.innerHTML = contentDiv;
- tabContainer.appendChild(pageDiv);
- },
-
- isLoaded: function() {
- return this.loaded;
- },
- select: function() {
- if (!this.isLoaded()) {
- if ($(this.pageID)) {
- this.loaded = true;
- this.refreshRequired = true;
- } else {
- this.createPage();
- }
- }
- var frag = fragments[this.uniqueID()];
- if (frag) {
- frag.lockUpdates(false);
- frag.raiseEvent("fragment.visibility.change",{"setVisibility":"visible"}, "params", false, false);
- }
- //RTC 200661 not using the 'alt' for now
- //var alt = (this.parent.parent != null) ? "-alt" : "";
- var alt = "";
- var td = $(this.tabID);
-
- var div = xFirstChild(td, "DIV");
- div.className = "cogstyle-htabs" + alt + "-active-left-edge";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-htabs" + alt + "-active-right-edge";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-htabs" + alt + "-active";
- if (this.subtabs != null) {
- $(this.pageID).style.display = "block";
- this.subtabs.tabs[this.subtabs.active()].select();
- } else {
- $(this.pageID).style.display = "block";
- }
-
- // Get the tab title, which is the first anchor in the tab
- var label = xFirstChild(div, "A");
- // Set the tabindex to 0 so it shows up in the tab order
- label.tabIndex=0;
- // Set the focus to the tab title
- label.focus();
- label.setAttribute("aria-selected","true");
- this.refresh();
-
- this.parent.scrollTo(this);
- },
-
- deselect: function() {
- var frag = fragments[this.uniqueID()];
- if (frag) {
- frag.lockUpdates(true);
- frag.raiseEvent("fragment.visibility.change", {"setVisibility":"hidden"}, "params", false, false);
- }
- //var alt = (this.parent.parent != null) ? "-alt" : "";
- var alt = "";
- var td = $(this.tabID);
- var div = xFirstChild(td, "DIV");
- div.className = "cogstyle-htabs" + alt + "-left-edge";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-htabs" + alt + "-right-edge";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-htabs" + alt;
- if (this.subtabs != null) {
- $(this.pageID).style.display = "none";
- this.subtabs.tabs[this.subtabs.active()].deselect();
- } else {
- var pageDIV = $(this.pageID);
- if (pageDIV != null) {
- pageDIV.style.display = "none";
- }
- }
- var label = xFirstChild(div, "A");
- label.setAttribute("aria-selected","false");
- },
-
- refresh: function(force) {
- if (this.href != null) {
- if (!this.isLoaded()) {
- this.loaded = true;
- var frag = new fragment(this.href, this.uniqueID());
- frag.customProperties = this.customProperties;
- frag.retrieve();
- }
- else if (force || this.refreshRequired) {
- this.refreshRequired = false;
- fragments[this.uniqueID()].raiseEvent("fragment.refresh",null,null,false,true);
- }
- } else if (this.subtabs != null) {
- this.subtabs.select(this.subtabs.active());
- }
- var topLevel = this;
- while (topLevel.parent != null) {
- topLevel = topLevel.parent;
- }
- topLevel.onresize();
- },
-
- onclick: function(e, tag) {
- this.parent.select(this.id);
- },
-
- onkeypress: function(evt) {
- evt = evt != null ? evt : window.event;
- var e = evt.srcElement ? evt.srcElement : evt.target;
- var activeTab;
-
- // Left or Up Arrow
- if (evt.keyCode == 37 || evt.keyCode == 38) {
- activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab");
- // Get the previous tab
- var prevTab = activeTab.previousSibling;
- if (prevTab == null) {
- // or last child if you are on the first child.
- prevTab = activeTab.parentNode.lastChild;
- }
- // Extract the relevant part of the tab id
- var prevId = prevTab.id.substring(this.parent.uniqueID().length, prevTab.id.length-3);
- // Select the tab
- this.parent.select(prevId);
- }
- // Right or Down arrow
- else if (evt.keyCode == 39 || evt.keyCode == 40) {
- activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab");
- // Get the next tab
- var nextTab = activeTab.nextSibling;
- if (nextTab == null) {
- // or first child if you are on the last child.
- nextTab = activeTab.parentNode.firstChild;
- }
- // Extract the relevant part of the tab id
- var nextId = nextTab.id.substring(this.parent.uniqueID().length, nextTab.id.length-3);
- // Select the tab
- this.parent.select(nextId);
- }
- xStopPropagation(evt);
- },
-
- onresize: function() { //ui_htab
- if (!this.parent.isFixed())
- {
- //When we aren't in fixed mode, don't do any resizing to the booklet viewer, but propogate the resize event downward
- if (this.subtabs != null) {
- this.subtabs.onresize();
- } else {
- var objectType = this.target.targetType ? this.target.targetType : this.target.type;
- ui_resizeHelper.adjustHeightForFragmentContent(fragments[this.uniqueID()], $(this.contentID), objectType, this.height);
- var list = _F_descendants(this.uniqueID(), null, true);
- _F_resize(list);
- }
- return;
- }
- var parentTab = this.parent.parent;
- // check if top level or sub-level?
- if (parentTab == null) {
- var page = $(this.pageID);
- this.height = xClientHeight() - ui_calcAvailableHeight(page, document.body,true);
- this.width = xClientWidth() - ui_calcAvailableWidth(page, document.body);
-
- if (maximizeBVToAvailableHeight) {
- this.height = ui_calcMaximumHeight(page, document.body, true);
- readjustParentHeight(this.contentID);
- }
- } else {
- this.height = parentTab.height - xHeight(this.parent.tableID) - 1;
- this.width = parentTab.width;
- }
-
- if (this.subtabs != null) {
- this.subtabs.onresize();
- } else {
- var content = $(this.contentID);
- xHeight(content, this.height);
- // resize the fragments (and children)
- var dlist = _F_descendants(this.uniqueID(), null, true);
- _F_resize(dlist);
- }
- },
-
- getVTabs: function() {
- return fragments[this.uniqueID()];
- }
- };
- /**
- * ui_tabbutton
- * @param obj
- */
- function ui_tabbutton(obj) {
- this.id = null;
- this.parent = null;
- this.enabled = false;
- this.hovered = false;
- this.mouseUpHandler = null;
- this.selectStartHandler = function(e) {xPreventDefault(e);return false;};
- for (var o in obj) {
- this[o] = obj[o];
- }
- }
- ui_tabbutton.prototype = {
-
- attach: function(parent) {
- this.parent = parent;
- var elem = $(this.id);
- if (elem != null) {
- xAddEventListener(elem, "mousedown", _F_Document.associate(elem, this, "onmousedown"));
- xAddEventListener(elem, "mouseover", _F_Document.associate(elem, this, "onmouseover"));
- xAddEventListener(elem, "mouseout", _F_Document.associate(elem, this, "onmouseout"));
- xAddEventListener(elem, "keydown", _F_Document.associate(elem, this, "onkeydown"));
- xAddEventListener(elem, "touchstart", _F_Document.associate(elem, this, "ontouchstart"));
- xAddEventListener(elem, "touchend", _F_Document.associate(elem, this, "ontouchend"));
- }
- },
-
- setEnable: function(enable) {
- if (this.enabled != enable) {
- this.enabled = enable;
- this.updateStyles();
- }
- },
-
- updateStyles: function() {
- var style = "cogstyle-htabs-scroll-button";
- if (!this.enabled) {
- style += "-disabled";
- } else if (this.hovered) {
- style += "-hover";
- }
- style += " cogstyle-htabs-scroll-button-" + this.type;
- if (!this.enabled) {
- style += "-disabled";
- }
- $(this.id).className = style;
-
- var scrollImg = $(this.id + "img");
- if (this.enabled) {
- scrollImg.className = "";
- } else {
- scrollImg.className = "cogstyle-img-faded";
- }
- },
-
- onkeydown: function(e, tag){
- if (e.keyCode == 13 || e.keyCode == 32 || e.charCode==32){
- this.parent.scroll(this.type);
- }
- },
-
- onclick: function(e, tag) {
- this.parent.scroll(this.type);
- },
-
- onmousedown: function(e, tag) {
- xPreventDefault(e);
- this.mouseUpHandler = _F_Document.associate(document, this, "onmouseup");
- xAddEventListener(document, "mouseup", this.mouseUpHandler);
- xAddEventListener(document, "selectstart", this.selectStartHandler);
- xAddEventListener(document, "dragstart", this.selectStartHandler);
- this.parent.startScroll(this.type);
- },
- onmouseup: function(e, tag) {
- xRemoveEventListener(document, "mouseup", this.mouseUpHandler);
- xRemoveEventListener(document, "selectstart", this.selectStartHandler);
- xRemoveEventListener(document, "dragstart", this.selectStartHandler);
- this.mouseUpHandler = null;
- this.parent.stopScroll();
- },
- ontouchstart: function(e, tag) {
- xPreventDefault(e);
- this.touchEndHandler = _F_Document.associate(document, this, "ontouchend");
- xAddEventListener(document, "touchend", this.touchEndHandler);
- this.parent.startScroll(this.type);
- },
- ontouchend: function(e, tag) {
- xRemoveEventListener(document, "touchend", this.touchEndHandler);
- this.touchEndHandler = null;
- this.parent.stopScroll();
- },
-
- onmouseover: function(e, tag) {
- if (this.enabled) {
- this.hovered = true;
- this.updateStyles();
- if (this.mouseUpHandler != null) {
- this.parent.startScroll(this.type);
- }
- }
- },
-
- onmouseout: function(e, tag) {
- if (this.enabled) {
- this.parent.stopScroll();
- this.hovered = false;
- this.updateStyles();
- }
- }
- };
- /**
- * ui_vtabs
- * @param obj containing: "frag" the fragment object, "id" unique identifier,
- * "activeTabID" current active tab identifier and "tabs" array of ui_vtab objects.
- */
- function ui_vtabs(obj) {
- this.parent = null;
- this.tabs = { };
- for (var o in obj) {
- this[o] = obj[o];
- }
- if (this.activeTabID === undefined) {
- for (var t in this.tabs) {
- this.activeTabID = t;
- break;
- }
- }
- }
- ui_vtabs.prototype = {
-
- uniqueID: function() {
- return this.frag.id + this.id;
- },
-
- attach: function(parent) {
- this.parent = parent;
- this.bookletViewerContainerID = this.frag.id + "bvContainer";
- if (parent == null) {
- this.toplevel = countLevels(this.frag.parent) == 1;
- this.tabsmainID = this.frag.id + "tabs_main";
- this.tabsareaID = this.frag.id + "tabs_area";
- this.tabsareadivID = this.frag.id + "tabs_area_div";
- this.vtabsMinWidth = 0;
- }
- for (var t in this.tabs) {
- this.tabs[t].attach(this);
- }
- function countLevels(f) {
- var count = 0;
- while (f != null) {
- count++;
- f = f.parent;
- }
- return count;
- }
- },
-
- select: function(id) {
- if (this.tabs[id] != null) {
- var cur = this.active();
- if (cur != "") {
- this.tabs[cur].deselect();
- }
- this.activeTabID = id;
- this.tabs[id].select();
- }
- },
-
- active: function() {
- return this.activeTabID;
- },
-
- getTab: function(posIdx) {
- var x = 0;
- for (var tabId in this.tabs) {
- if (x++==posIdx) {
- return this.tabs[tabId];
- }
- }
- },
-
- getRoot: function() {
- var p = this;
- while (p.parent != null) {
- p = p.parent;
- }
- return p;
- },
-
- isFixed: function() {
- return this.getRoot().fixed == true;
- },
- getVTabsAreaWidth: function() {
- return this.getRoot().vtabsWidth;
- },
-
- getVTabsAreaHeight: function() {
- return this.getRoot().vtabsHeight;
- },
-
- setVTabsAreaWidth: function(vtabsWidth) {
- var o = this.getRoot();
- if (o.vtabsWidth != vtabsWidth) {
- if (vtabsWidth < o.vtabsMinWidth) {
- o.vtabsWidth = o.vtabsMinWidth;
- } else {
- o.vtabsWidth = vtabsWidth;
- }
- o.onresize();
- }
- },
-
- onresize: function() { //ui_vtabs
- var tabsArea = $(this.tabsareaID);
- if (tabsArea != null) {
- if (this.parent == null) {
- var tabsAreaDiv = $(this.tabsareadivID);
- var tabsListDiv = tabsAreaDiv.childNodes[0];
- var tabsFilterDiv = tabsAreaDiv.childNodes[1];
- var tabsMainTable = $(this.tabsmainID);
- // check if top level or embeded in another htabs/vtabs?
- if (this.toplevel) {
- this.vtabsHeight = xClientHeight() - ui_calcAvailableHeight(tabsArea, document.body, true);
- } else {
- var div = $(this.frag.div);
- this.vtabsHeight = xHeight(div) - ui_calcAvailableHeight(tabsArea, div, true);
- }
-
- if (maximizeBVToAvailableHeight) {
- if (this.isFixed()) {
- this.vtabsHeight = ui_calcMaximumHeight(tabsArea, document.body, true);
- }
- }
-
- if (this.isFixed() || _F_Config.application.toLowerCase() == "/cogadmin") {
- if (tabsMainTable.style.height != "100%") {
- tabsMainTable.style.height = "100%";
- }
- }
- xWidth(tabsFilterDiv, this.vtabsWidth);
- xWidth(tabsArea, this.vtabsWidth);
- if (!(xIE4Up)) {
- tabsListDiv.style.width = "auto";
- }
- }
- }
- if (this.active() != "") {
- this.tabs[this.active()].onresize();
- }
-
- }
- };
- /**
- * ui_vtab
- * @param obj
- */
- function ui_vtab(obj) {
- this.id = null;
- this.parent = null;
- this.loaded = false;
- this.refreshRequired = false;
- this.href = null;
- this.subtabs = null;
- this.width = -1;
- this.height = -1;
- this.customProperties = null;
- for (var o in obj) {
- this[o] = obj[o];
- }
- }
- ui_vtab.prototype = {
- uniqueID: function() {
- if (this.parent != null) {
- return this.parent.uniqueID() + this.id;
- }
- return this.id;
- },
-
- attach: function(parent) {
- this.parent = parent;
- var uniqueID = this.parent.uniqueID() + this.id;
- if (this.tabID == null) {
- this.tabID = uniqueID + "tab";
- }
- if (this.pageID == null) {
- this.pageID = uniqueID + "page";
- }
- if (this.filterID == null) {
- this.filterID = uniqueID + "filter";
- }
- if (this.contentID == null) {
- this.contentID = uniqueID + "content";
- }
- if (this.subtabs != null) {
- this.subtabs.attach(this);
- this.subtabsID = uniqueID + "subtabs";
- }
- var elem = $(this.tabID);
- if (elem != null) {
- xAddEventListener(elem, "click", _F_Document.associate(elem, this, "onclick"));
- xAddEventListener(elem, "mouseover", _F_Document.associate(elem, this, "onmouseover"));
- xAddEventListener(elem, "mouseout", _F_Document.associate(elem, this, "onmouseout"));
- xAddEventListener(elem, "keypress", _F_Document.associate(elem, this, "onkeypress"));
- }
- },
- createPage: function() {
- var tabContainer = $(this.parent.frag.id + "tabs_container");
- var pageDiv = document.createElement("DIV");
- pageDiv.id = this.pageID;
- pageDiv.style.width="100%";
- pageDiv.style.height="100%";
- pageDiv.style.display="none";
- pageDiv.setAttribute("role", "tabpanel");
- var tabAnchorId = this.tabID + "_anchor";
- pageDiv.setAttribute("aria-labelledby", tabAnchorId);
- var tabEl = $(tabAnchorId);
- if (tabEl != null){
- tabEl.setAttribute("aria-controls", this.pageID);
- }
-
- var contentDiv = ui_templates.get(
- ui_templates.contentTemplate,
- 'CONTENTID', this.contentID,
- 'CONTENTCLASS', (this.parent.isFixed() ? "cogstyle-vtabs-page-content-fixed" : "cogstyle-vtabs-page-content")
- );
- pageDiv.innerHTML = contentDiv;
- tabContainer.appendChild(pageDiv);
- },
-
- createFilter: function() {
- var filterContainer = $(this.parent.frag.id + "filter_container");
- var filterDiv = document.createElement("DIV");
- filterDiv.id = this.filterID;
- filterDiv.style.display="none";
- filterDiv.className = "cogstyle-filter";
- filterContainer.appendChild(filterDiv);
- },
-
- isLoaded: function() {
- return this.loaded;
- },
- select: function() {
- if (!this.isLoaded()) {
- if ($(this.pageID)) {
- this.loaded = true;
- this.refreshRequired = true;
- } else {
- this.createPage();
- this.createFilter();
- }
- }
- var frag = fragments[this.uniqueID()];
- if (frag) {
- frag.lockUpdates(false);
- frag.raiseEvent("fragment.visibility.change",
- {
- "setVisibility":"visible"
- }, "params", false, false);
- }
- var more = (this.parent.parent != null) ? "-alt" : "";
- more += (this.subtabs) ? "-opened" : "";
- var div = $(this.tabID);
- div.className = "cogstyle-vtabs-active-border";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-vtabs" + more + "-active-left-edge";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-vtabs" + more + "-active-right-edge";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-vtabs" + more + "-active";
- if (this.subtabs != null) {
- $(this.subtabsID).style.display = "block";
- this.subtabs.tabs[this.subtabs.active()].select();
- } else {
- $(this.pageID).style.display = "block";
- var filterDIV = $(this.filterID);
- if (filterDIV != null && filterDIV.firstChild != null) {
- filterDIV.style.display = "block";
- }
- }
-
- // Get the tab title, which is the first anchor in the tab
- var label = xFirstChild(div, "A");
- // when you set the tabindex in IE, it shifts focus to the text inside it
- // if the tabsArea is smaller than the length of the text, it shifts over and hides the icon
- // setting the width of the label fixes this
- xWidth(label, xWidth(div));
- // Set the tabindex to 0 so it shows up in the tab order
- label.tabIndex=0;
- // Set the focus to the tab title
- label.focus();
- label.setAttribute("aria-selected","true");
- this.refresh();
- },
- deselect: function() {
- var frag = fragments[this.uniqueID()];
- if (frag) {
- frag.lockUpdates(true);
- frag.raiseEvent("fragment.visibility.change",
- {
- "setVisibility":"hidden"
- }, "params", false, false);
- }
- var more = (this.parent.parent != null) ? "-alt" : "";
- more += (this.subtabs) ? "-opened" : "";
- var div = $(this.tabID);
- div.className = "";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-vtabs" + more + "-left-edge";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-vtabs" + more + "-right-edge";
- div = xFirstChild(div, "DIV");
- div.className = "cogstyle-vtabs" + more;
- if (this.subtabs != null) {
- $(this.subtabsID).style.display = "none";
- this.subtabs.tabs[this.subtabs.active()].deselect();
- } else {
- var pageDIV = $(this.pageID);
- if (pageDIV != null)
- {
- pageDIV.style.display = "none";
- }
- var filterDIV = $(this.filterID);
- if (filterDIV != null) {
- filterDIV.style.display = "none";
- }
- }
- // Get the tab title, which is the first anchor in the tab
- var label = xFirstChild(div, "A");
- label.setAttribute("aria-selected","false");
- },
- refresh: function(force) {
- if (this.href != null) {
- if (!this.isLoaded()) {
- this.loaded = true;
- var frag = new fragment(this.href, this.uniqueID());
- frag.customProperties = this.customProperties;
- frag.retrieve();
- }
- else if (force || this.refreshRequired) {
- this.refreshRequired = false;
- fragments[this.uniqueID()].raiseEvent("fragment.refresh",null,null,false,true);
- }
- } else if (this.subtabs != null) {
- this.subtabs.select(this.subtabs.active());
- }
- var topLevel = this;
- while (topLevel.parent != null) {
- topLevel = topLevel.parent;
- }
- topLevel.onresize();
- },
-
- onclick: function(e, tag) {
- this.parent.select(this.id);
- },
-
- onkeypress: function(evt) {
- evt = evt != null ? evt : window.event;
- var e = evt.srcElement ? evt.srcElement : evt.target;
- var activeTab;
- // Left or Up Arrow
- if (evt.keyCode == 37 || evt.keyCode == 38) {
- activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab");
- // Get the previous tab
- var prevTab = activeTab.previousSibling;
- if (prevTab == null) {
- // or last child if you are on the first child.
- prevTab = activeTab.parentNode.lastChild;
- }
- // Extract the relevant part of the tab id
- var prevId = prevTab.id.substring(this.parent.uniqueID().length, prevTab.id.length-3);
- // Select the tab
- this.parent.select(prevId);
- }
- // Right or Down arrow
- else if (evt.keyCode == 39 || evt.keyCode == 40) {
- activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab");
- // Get the next tab
- var nextTab = activeTab.nextSibling;
- if (nextTab == null) {
- // or first child if you are on the last child.
- nextTab = activeTab.parentNode.firstChild;
- }
- // Extract the relevant part of the tab id
- var nextId = nextTab.id.substring(this.parent.uniqueID().length, nextTab.id.length-3);
- // Select the tab
- this.parent.select(nextId);
- }
- },
-
- onmouseover: function(e, tag) {
- var div = $(this.tabID);
- div = xFirstChild(div, "DIV");
- var cur = div.className;
- if (cur.indexOf('-hover') == -1) {
- div.className = cur + "-hover";
- }
- },
- onmouseout: function(e, tag) {
- var div = $(this.tabID);
- div = xFirstChild(div, "DIV");
- var cur = div.className;
- var i;
- if ((i = cur.indexOf('-hover')) != -1) {
- div.className = cur.substring(0, i);
- }
- },
- onresize: function() { //ui_vtab
- if (!this.parent.isFixed()) {
- //When we aren't in fixed mode, don't do any resizing to the booklet viewer, but propogate the resize event downward
- if (this.subtabs != null) {
- this.subtabs.onresize();
- } else {
- var objectType = this.target.targetType ? this.target.targetType : this.target.type;
- ui_resizeHelper.adjustHeightForFragmentContent(fragments[this.uniqueID()], $(this.contentID), objectType, this.height);
-
- var list = _F_descendants(this.uniqueID(), null, true);
- _F_resize(list);
- }
- return;
- }
- // check if top level or sub-level?
- var parentTab = this.parent.parent;
- if (parentTab == null) {
- this.height = this.parent.getRoot().vtabsHeight;
-
- if (maximizeBVToAvailableHeight) {
- readjustParentHeight(this.contentID);
- }
- } else {
- // propagate down the size for all tabs
- this.height = parentTab.height;
- }
- if (this.subtabs != null) {
- this.subtabs.onresize();
- } else {
- xHeight(this.contentID, this.height);
- xHeight(this.pageID, this.height);
- //keeps scrollbar from appearing off the side of the page in ie.
- // resize the fragments (and children)
- var dlist = _F_descendants(this.uniqueID(), null, true);
- _F_resize(dlist);
- }
- }
- };
- /**
- * ui_splitter
- * @param obj
- */
- function ui_splitter(obj) {
- this.id = null;
- this.splitterBar = null;
- this.startX = -1;
- for (var o in obj) {
- this[o] = obj[o];
- }
- xAddEventListener($(this.id), "mousedown", _F_Document.associate(window, this, "start"));
- }
- ui_splitter.prototype = {
-
- start: function(e, tag) {
- var evt = new xEvent(e);
- xPreventDefault(e);
-
- var bar = $(this.id);
- var div = document.createElement('DIV');
- div.appendChild(document.createElement('BR'));
- div.className="cogstyle-splitter-bar";
- this.mousemove = _F_Document.associate(window, this, "move");
- xAddEventListener(document, "mousemove", this.mousemove, true);
- this.mouseup = _F_Document.associate(window, this, "stop");
- xAddEventListener(document, "mouseup", this.mouseup, true);
- this.width = xWidth(bar);
- xLeft(div, xPageX(bar));
- xTop(div, xPageY(bar));
- xWidth(div, this.width);
- xHeight(div, xHeight(bar));
- xAppendChild(document.body, div);
- div.style.display = "";
- this.splitterBar = div;
- this.startX = evt.pageX;
- var locker = ui_locker.get();
- locker.show(true);
- },
-
- move: function(e, tag) {
- if (this.startX > 0) {
- var evt = new xEvent(e);
- xPreventDefault(e);
- xLeft(this.splitterBar, evt.pageX - (this.width / 2));
- }
- },
- stop: function(e, tag) {
- if (this.startX > 0) {
- var evt = new xEvent(e);
- xPreventDefault(e);
-
- xHide(this.splitterBar);
- document.body.removeChild(this.splitterBar);
- this.splitterBar = null;
-
- xRemoveEventListener(document, "mousemove", this.mousemove, true);
- xRemoveEventListener(document, "mouseup", this.mouseup, true);
-
- this.resizing.setVTabsAreaWidth(this.resizing.getVTabsAreaWidth() + (evt.pageX - this.startX));
- this.startX = -1;
- }
- var locker = ui_locker.get();
- locker.hide();
- }
- };
- /**
- * ui_error
- * @param fragID the fragment unique identifier
- * @param contentID the identifier of the "content" div receiving the error bar.
- */
- function ui_error(fragID, contentID) {
- this.fragID = fragID;
- this.contentID = contentID;
- this.code = null;
- this.message = null;
- this.details = null;
- }
- ui_error.prototype = {
-
- template: "<div id=\"_THIS_errormsg\"></div>",
-
- setCode: function(code) {
- this.code = code;
- },
-
- setMessage: function(msg) {
- this.message = msg||"";
-
- var div = $(this.fragID + "errormsg");
- if (div != null) {
- div.innerHTML = _F_Strings.htmlEncode(this.message);
- }
- },
-
- setDetails: function(details) {
- this.details = details;
- },
-
- show: function() {
- var div = $(this.fragID + "error");
- if (div == null) {
- var content = $(this.contentID);
- div = document.createElement("DIV");
- div.className = "cogstyle-portlet-error-frame";
- div.id = this.fragID + "error";
- div.innerHTML = this.template.replace(/_THIS_/g, this.fragID);
- content.parentNode.insertBefore(div, content);
- var anchor = $(this.fragID + "error_showdetails");
- if (anchor != null) {
- xAddEventListener(anchor, "click", _F_Document.associate(anchor, this, "showDetails"));
- anchor.href = "javascript:noop()";
- }
- anchor = $(this.fragID + "error_retry");
- if (anchor != null) {
- xAddEventListener(anchor, "click", _F_Document.associate(anchor, this, "retry"));
- anchor.href = "javascript:noop()";
- }
- anchor = $(this.fragID + "error_hide");
- if (anchor != null) {
- xAddEventListener(anchor, "click", _F_Document.associate(anchor, this, "hide"));
- anchor.href = "javascript:noop()";
- }
- }
- $(this.fragID + "errormsg").innerHTML = _F_Strings.htmlEncode(this.message);
- div.style.display = "";
- setTimeout(function(){div.setAttribute("role","alert");},1)
- this.hideLoading();
- },
-
- hide: function() {
- var div = $(this.fragID + "error");
- if (div != null) {
- div.style.display = "none";
- }
- return false;
- },
- hideLoading: function() {
- // get div, get firstchild, check for removeonerror attribute, if there clear div content
- var viewport = $(this.contentID);
- if (viewport) {
- var ele = xFirstChild(viewport);
- if (ele) {
- if (ele.getAttribute("removeonerror") == "true") {
- viewport.innerHTML = "";
- }
- }
- }
- },
- showDetails: function() {
- var dlg = new ui_dialog(this.fragID + "errordetails", PFM.JS.IDS_JS_DETAILS,
- ui_dialog.style.ALERT | ui_dialog.style.BTN_CLOSE | ui_dialog.style.CENTER | ui_dialog.style.RESIZABLE, -1, -1, 500, 300, this.contentID);
- dlg.processCommand = function(cmd) {
- this.destroy();
- return true;
- };
-
- if (this.details != null) {
- var markup = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">";
- if (this.code != null) {
- markup += "<tr><td colspan=\"2\" class=\"portlet-form-label\">" + this.code + "</td></tr>";
- }
- markup +=
- "<tr>" +
- "<td valign=\"top\">" +
- "<img src=\"" + _F_Config.webContent + "/fragments/common/images/msg_error.gif\" style=\"width:32px;height:32px\">" +
- "</td>" +
- "<td class=\"portlet-font\" valign=\"top\">" +
- _F_Strings.htmlEncode(this.message) +
- "</td>" +
- "</tr>" +
- "</table>";
- markup += "<pre>" + _F_Strings.htmlEncode(this.details) + "</pre>";
- dlg.attachContent(markup);
- }
- dlg.show();
- return false;
- },
-
- retry: function() {
- this.hide();
- // TODO: should call a retry instead of retrieve here
- fragments[this.fragID].retrieve();
- return false;
- }
- };
- function ui_fragment_help(frag) {
- if (frag) {
- var sURL = frag.baseURI();
- // replace the macros
- sURL = _F_Config.expandMacros(sURL);
- sURL += ((sURL.indexOf('?') >= 0) ? "&" : "?") + "frag-mode=help";
- var windowHelp = window.open(sURL, "cps_help",
- "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=500");
- if (windowHelp != null) {
- windowHelp.focus();
- }
- }
- }
- /**
- * ui_dialog
- * @param id unique identifier of dialog
- * @param caption text
- * @param styles bit field of STYLES_*
- * @param dx width
- * @param dy height
- * @param contentId Optional unique identifier of the content div for the invoking fragment. Used to set the proper font size.
- * @param srcHref Optional parameter, if passed the dialog system will use this as a url and create an iframe for it.
- */
- function ui_dialog(id, caption, styles, x, y, dx, dy, contentId, srcHref) {
- this.id = id;
- this.caption = caption;
- this.styles = styles;
- this.x = x;
- this.y = y;
- this.dx = dx;
- this.dy = dy;
- this.dlg = null;
- this.backing = null;
- this.content = "";
- this.results = null;
- this.contentId = contentId;
- this.srcHref = (srcHref !== undefined)? srcHref:null;
- this.minDialogWidth = 200;
- this.iframeName = (srcHref !== undefined)? "MODAL_IFRAME" + ( new Date() ).getTime():null;
- this.fragment = null;
- this.eventHandlers = [];
- this.triggerElement = document.activeElement;
- }
- ui_dialog.chain = [];
- ui_dialog.nextX = 0;
- ui_dialog.nextY = 0;
- ui_dialog.style = {};
- ui_dialog.style.BTN_OK = 0;
- ui_dialog.style.BTN_OKCANCEL = 1;
- ui_dialog.style.BTN_OKCANCELAPPLY = 2;
- ui_dialog.style.BTN_CLOSE = 3;
- ui_dialog.style.BTN_CANCEL = 4;
- ui_dialog.style.BTN_YESNO = 5;
- ui_dialog.style.BTN_YESNOCANCEL = 6;
- ui_dialog.style.BTN_NOBUTTONS = 8;
- ui_dialog.style.RESIZABLE = 16;
- ui_dialog.style.MODELESS = 32;
- ui_dialog.style.CENTER = 64;
- ui_dialog.style.IFRAME = 128;
- ui_dialog.style.READONLY = 256;
- ui_dialog.style.ALERT = 512;
- ui_dialog.button = {};
- ui_dialog.button.OK = "ok";
- ui_dialog.button.CANCEL = "cancel";
- ui_dialog.button.APPLY = "apply";
- ui_dialog.button.YES = "yes";
- ui_dialog.button.NO = "no";
- ui_dialog.button.CLOSE = "close";
- ui_dialog.button.CLOSEBOX = "closebox";
- ui_dialog.button.HELPBOX = "helpbox";
- ui_dialog.button._styles_ = [
- [ui_dialog.button.OK],
- [ui_dialog.button.OK, ui_dialog.button.CANCEL],
- [ui_dialog.button.OK, ui_dialog.button.CANCEL, ui_dialog.button.APPLY],
- [ui_dialog.button.CLOSE],
- [ui_dialog.button.CANCEL],
- [ui_dialog.button.YES, ui_dialog.button.NO],
- [ui_dialog.button.YES, ui_dialog.button.NO, ui_dialog.button.CANCEL],
- null,
- []
- ];
- ui_dialog.prototype = {
- create: function() {
- var iframe = null;
- if (xIE4Up) {
- iframe = document.createElement("iframe");
- iframe.id = this.id + "iframe";
- iframe.style.display="none";
- iframe.style.border="0px";
- iframe.style.position="absolute";
- iframe.src = _F_Config.webContent + "/fragments/common/images/space.gif";
- this.backing = iframe;
- document.body.appendChild(iframe);
- }
- var div = document.createElement("DIV");
- div.className = "cogstyle-dialog";
- div.id = this.id;
- div.style.display = "none";
- if ((this.styles & ui_dialog.style.ALERT) == ui_dialog.style.ALERT) {
- div.setAttribute("role", "alert");
- }
- var markup =
- "<table role=\"dialog\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" aria-labelledby=\"" + this.id + "captiontext\">" +
- "<tr>" +
- "<td id=\"" + this.id + "caption\" class=\"cogstyle-dialog-caption\">" +
- "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%\" role=\"presentation\">" +
- "<tr>" +
- "<td id=\"" + this.id + "captiontext\" >" + _F_Strings.htmlEncode(this.caption) + "</td>";
- if (this.fragment != null && _F_Array.indexOf(this.fragment.modes, "help") > -1) {
- markup += "<td style=\"width:16px\">" +
- "<a id=\"" + this.id + "btnhelpbox\" href=\"#\">" + PFM.JS.IDS_JS_HELP_URL + "</a>" +
- "</td>";
- }
- markup += "<td style=\"width:16px\">" +
- "<input id=\"" + this.id + "btnclosebox\" type=\"image\" src=\"" + _F_Config.webContent + "/fragments/common/images/dialog_close.gif\" style=\"width:16px; height:16px\" role=\"button\" title=\""+PFM.JS.IDS_JS_BUTTON_CLOSE+"\" alt=\""+PFM.JS.IDS_JS_BUTTON_CLOSE+"\"/>" +
- "</td>" +
- "</tr>" +
- "</table>" +
- "</td>" +
- "</tr>" +
- "<tr>" +
- "<td class=\"cogstyle-dialog-body\">";
- var tempMarkup = " id=\"" + this.id + "content\" class=\"cogstyle-dialog-content\" style=\"width:" + this.dx + "px;height:" + this.dy + "px";
- if ((this.styles & ui_dialog.style.IFRAME) != ui_dialog.style.IFRAME) {
- markup += "<div" + tempMarkup + "\"></div>";
- } else {
- markup += "<iframe src=\""+_F_Config.webContent+"/fragments/common/images/space.gif\" name=\"" + this.iframeName + "\"" + tempMarkup + " ;margin:0px;padding:0px;border:0px;\"></iframe>";
- }
-
- markup += "<div class=\"cogstyle-dialog-commandbar\">" +
- "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%\" role=\"presentation\"><tr><td>" ;
- var buttons = ui_dialog.button._styles_[this.styles & 15];
- var i, l = buttons.length;
- if (l > 0) {
- for (i=0; i<l; i++) {
- markup +=
- "<input id=\"" + this.id + "btn" + buttons[i] +
- "\" class=\"cogstyle-dialog-button\" type=\"button\" value=\"" +
- PFM.JS["IDS_JS_BUTTON_" + buttons[i].toUpperCase()] + "\" tabIndex=\"0\"/>";
-
- }
- markup+="</td>";
-
- } else {
- markup += "<br>";
- }
-
- if (((this.styles & ui_dialog.style.RESIZABLE) == ui_dialog.style.RESIZABLE) && ((this.styles & ui_dialog.style.IFRAME) != ui_dialog.style.IFRAME)) {
- markup += "<td valign=\"bottom\" style=\"width:12px\">" +
- "<img id=\"" + this.id + "resizebox\" src=\"" + _F_Config.webContent + "/fragments/common/images/dialog_resize.gif\" border=\"0\" style=\"width:12px;height:12px;cursor:nw-resize\" alt=\"\">" +
- "</td>";
- }
- markup += "</tr>" +
- "</table>" +
- "</div>" +
- "</td>" +
- "</tr>" +
- "</table>";
-
- div.innerHTML = markup;
- document.body.appendChild(div);
- this.attachContent(this.content);
-
- for (var b in ui_dialog.button) {
- var btn = $(this.id + "btn" + ui_dialog.button[b]);
- if (btn != null) {
- xAddEventListener(btn, "click", _F_Document.associate(btn, this, "oncommand"));
- }
- }
-
- var capDiv = $(this.id + "caption");
- capDiv.xdlg = this;
- xAddEventListener(div, "mousedown", _F_Document.associate(div, this, "onactivate"));
- xEnableDrag(capDiv, this.onstartmove, this.onmove, null);
- if ((this.styles & ui_dialog.style.RESIZABLE) == ui_dialog.style.RESIZABLE) {
- var resizeBox = $(this.id + "resizebox");
- resizeBox.xdlg = this;
- xEnableDrag(resizeBox, this.onstartresize, this.onresize, null);
- }
- if ((this.styles & ui_dialog.style.IFRAME) == ui_dialog.style.IFRAME) {
- if ((this.styles & ui_dialog.style.RESIZABLE) == ui_dialog.style.RESIZABLE) {
- _F_log("I", "Resize not currently available for dialogs displaying iframes.");
- }
- this.showLoadingIndicator();
- this.postForm(this.srcHref);
- }
- return div;
- },
-
- showLoadingIndicator: function () {
- // BUSY DIV
- var progressDiv = null;
- var dialogIframe;
- progressDiv = $(this.id + "progressDiv");
- if (progressDiv == null) {
- progressDiv = xCreateElement("div");
- progressDiv.id = this.id + "progressDiv";
-
- var progressMarkup= ui_templates.get(ui_templates.contentTemplate, 'CONTENTID', progressDiv.id + "content");
-
- dialogIframe = $(this.id + "content");
- progressDiv.innerHTML = progressMarkup;
- progressDiv.style.height = this.dy;
- progressDiv.style.width = this.dx;
-
- dialogIframe.parentNode.insertBefore(progressDiv, dialogIframe);
- _F_Document.addEventListener(dialogIframe,"load", _F_Document.associate(dialogIframe.id,this,"onContentLoaded"));
- }
- dialogIframe.style.display = "none";
- },
-
- onContentLoaded : function(event) {
- var dialogIframe = $(this.id + "content");
- var progressDiv = $(this.id + "progressDiv");
- if ((dialogIframe) && (dialogIframe.style.display == "none"))
- {
- progressDiv.style.display = "none";
- dialogIframe.style.display = "";
- }
- },
-
-
- postForm: function(url) {
- var iframe = $(this.id + "content");
- var formElement = document.createElement("form");
- formElement.setAttribute("name","_THIS_dlg_window_form");
- formElement.setAttribute("method","POST");
- formElement.setAttribute("target", iframe.name);
-
- var qm_index = url.indexOf("?");
- var action = (qm_index==-1) ? url : url.substring(0, qm_index);
- formElement.setAttribute("action", action);
-
- if (qm_index != -1) {
- var paramString = url.substring(qm_index+1);
- var params = paramString.split("&");
- var i;
- for (i=0; i < params.length; ++i) {
- if (params[i].length>0) {
- var hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
-
- var eq_index = params[i].indexOf("=");
- if (eq_index != -1) {
- hiddenElement.setAttribute("name",unescape(params[i].substring(0,eq_index)));
- hiddenElement.setAttribute("value",unescape(params[i].substring(eq_index+1)));
- } else {
- hiddenElement.setAttribute("name",unescape(params[i]));
- hiddenElement.setAttribute("value","");
- }
- formElement.appendChild(hiddenElement);
- }
- }
- }
- document.body.appendChild(formElement);
- formElement.submit();
- document.body.removeChild(formElement);
- formElement = null;
- },
- destroy: function() {
- this.hide();
- if (xIE4Up) {
- if ($(this.id + "caption")) {
- xDisableDrag(this.id + "caption");
- }
- if ($(this.id + "resizebox")) {
- xDisableDrag(this.id + "resizebox");
- }
- if ((this.styles & ui_dialog.style.IFRAME) == ui_dialog.style.IFRAME) {
- var iFrameObj = $(this.id + "content");
- iFrameObj.parentNode.removeChild(iFrameObj);
- }
- }
- this.dlg.parentNode.removeChild(this.dlg);
- this.dlg = null;
- if (this.backing) {
- this.backing.parentNode.removeChild(this.backing);
- this.backing = null;
- }
- },
-
- show: function() {
- if (this.dlg == null) {
- this.dlg = this.create();
- }
- ui_dialog.chain.push(this);
- this.center(this.x, this.y, this.dx, this.dy);
- this.onactivate();
- if (this.fragment) {
- this.fragment.raiseEvent("cognos.ui.dialog.show", null, null);
- }
- this.initTabStops();
- },
-
- initTabStops: function(skipFocus) {
- for (var i=0; i< this.eventHandlers.length;i++) {
- dojo.disconnect(this.eventHandlers[i]);
- }
- if ((this.styles & ui_dialog.style.MODELESS) == 0) {
- var buttons = ui_dialog.button._styles_[this.styles & 15];
-
- var firstBtn = document.getElementById(this.id + "btn" + buttons[0]);
- var lastBtn = document.getElementById(this.id + "btn" + buttons[buttons.length-1]);
-
- var dialogContainer = document.getElementById(this.id + "content");
-
- tabStops = [];
- if ((this.styles & ui_dialog.style.READONLY) == 0) {
- tabStops = ui_getNavigableElements(dialogContainer);
- this.eventHandlers[this.eventHandlers.length] = dojo.connect(dialogContainer, "onmouseup", function(e){
- for (var i=0;i<tabStops.length;i++) {
- if (tabStops[i]==e.target) {
- tabIdx = i;
- setTimeout(function(){tabStops[tabIdx].focus()},1);
- }
- }
- });
-
- } else {
- this.eventHandlers[this.eventHandlers.length] = dojo.connect(dialogContainer, "onmousedown", function(e){
- dojo.stopEvent(e);
- });
-
- if (tabStops.length > 0) {
- this.eventHandlers[this.eventHandlers.length] = dojo.connect(dialogContainer, "onmouseup", function(e){
- dojo.stopEvent(e);
- setTimeout(function(){tabStops[tabIdx].focus()},1);
- });
- }
- }
-
- for (var i=0; i < buttons.length;i++) {
- tabStops[tabStops.length] = document.getElementById(this.id + "btn" + buttons[i]);
- }
-
- for (var i=0; i < tabStops.length;i++) {
- tabStops[i].tabIndex=i+1;
- }
-
- if (tabStops.length > 0) {
- tabIdx = 0;
- var self = this;
- this.eventHandlers[this.eventHandlers.length] = dojo.connect(dojo.body(), "onkeypress", function(e){
- if (e.charOrCode == dojo.keys.TAB) {
- if (e.shiftKey) {
- if (--tabIdx == -1) {
- dojo.stopEvent(e);
- tabIdx = tabStops.length-1;
- }
- } else if (++tabIdx == tabStops.length) {
- dojo.stopEvent(e);
- tabIdx = 0;
- }
-
- setTimeout(function(){tabStops[tabIdx].focus()},1);
-
- } else if (e.charOrCode == dojo.keys.ESCAPE){
- dojo.stopEvent(e);
- self.processCommand(ui_dialog.button.CANCEL);
- }
-
- });
- if (!skipFocus) {
- tabStops[0].focus();
- }
- }
- }
-
- },
-
- center: function(dialogX, dialogY, dialogW, dialogH) {
-
- if ((this.styles & ui_dialog.style.CENTER) != 0) {
- dialogX = ((xClientWidth() - dialogW ) / 2);
- if (dialogX < 0) {dialogX = 0;}
- dialogY = ((xClientHeight() - dialogH) / 2);
- if (dialogY < 0) {dialogY = 0;}
- } else {
- if (dialogX == -1) {
- ui_dialog.nextX += 20;
- if (ui_dialog.nextX > 200) {ui_dialog.nextX = 0;}
- dialogX = ui_dialog.nextX;
- }
- if (dialogY == -1) {
- ui_dialog.nextY += 20;
- if (ui_dialog.nextY > 200) {ui_dialog.nextY = 0;}
- dialogY = ui_dialog.nextY;
- }
- }
- if ((this.styles & ui_dialog.style.MODELESS) == 0) {
- var locker = ui_locker.get();
- locker.show();
- }
-
- if (this.contentId != null) {
- var content = $(this.contentId);
- this.dlg.style.fontSize = xGetComputedStyle(content, "font-size");
- this.dlg.style.fontFamily = xGetComputedStyle(content, "font-family");
- }
- this.dlg.style.left = dialogX + "px";
- this.dlg.style.top = dialogY + "px";
- this.dlg.style.display = "";
- if (this.backing) {
- this.backing.style.left = dialogX + "px";
- this.backing.style.top = dialogY + "px";
- this.backing.style.display = "";
- xResizeTo(this.backing, xWidth(this.dlg), xHeight(this.dlg));
- }
- },
- hide: function() {
- for (var i=0; i< this.eventHandlers.length;i++) {
- dojo.disconnect(this.eventHandlers[i]);
- }
- if (this.dlg != null) {
- this.dlg.style.display="none";
- }
- if (this.backing) {
- this.backing.style.display="none";
- }
- if (_F_Array.remove(ui_dialog.chain, this) != null) {
- var locker = ui_locker.get();
- if ((this.styles & ui_dialog.style.MODELESS) == 0) {
- locker.hide();
- }
- }
- var currentElement = document.activeElement;
- if (!ui_isTabNavigable(currentElement)) {
- if (this.triggerElement != null) {
- var self = this;
- setTimeout(function(){self.triggerElement.focus();},500);
- }
- }
- },
-
- onactivate: function(e, tag) {
- // move this dialog to the end of the chain
- _F_Array.remove(ui_dialog.chain, this);
- ui_dialog.chain.push(this);
- // change Z order
- var i, l=ui_dialog.chain.length;
- for (i = 0; i < l; i++) {
- if (ui_dialog.chain[i].dlg != null) {
- $(ui_dialog.chain[i].id + "caption").className = "cogstyle-dialog-caption" + ((i < (l - 1)) ? "-inactive" : "");
- ui_dialog.chain[i].dlg.style.zIndex = 9999 + (2*i);
- if (this.backing) {
- ui_dialog.chain[i].backing.style.zIndex = 9999 + ((2*i)-1);
- }
- }
- }
- },
-
- onstartmove: function(e, dx, dy) {
- if (e.xdlg != null) {
- var _self = e.xdlg;
- if (_self != null) {
- var elm = _self.dlg;
- _self.startX = xPageX(elm);
- _self.startY = xPageY(elm);
- _self.lastX = e.xDPX;
- _self.lastY = e.xDPY;
- }
- }
- },
-
- onmove: function(e, dx, dy) {
- if (e.xdlg != null) {
- var _self = e.xdlg;
- if (_self != null) {
- var elm = _self.dlg;
- var nx = _self.startX + (e.xDPX - _self.lastX);
- var ny = _self.startY + (e.xDPY - _self.lastY);
- var cx = xClientWidth();
- if (cx < document.body.scrollWidth) {cx = document.body.scrollWidth;}
- var cy = xClientHeight();
- if (cy < document.body.scrollHeight) {cy = document.body.scrollHeight;}
- var w = xWidth(elm);
- var h = xHeight(elm);
- if (nx < 0) {nx = 0;}
- if (ny < 0) {ny = 0;}
- if ((nx + w) > cx) {nx = cx - w;}
- if ((ny + h) > cy) {ny = cy - h;}
- _self.x = nx;
- _self.y = ny;
- xMoveTo(elm, nx, ny);
- if (_self.backing) {
- xMoveTo(_self.backing, nx, ny);
- }
- }
- }
- },
-
- onstartresize: function(e, dx, dy) {
- if (e.xdlg != null) {
- var _self = e.xdlg;
- if (_self != null) {
- var elm = _self.dlg;
- }
- }
- },
-
- onresize: function(e, dx, dy) {
- if (e.xdlg != null) {
- var _self = e.xdlg;
- if (_self != null) {
- var elm = $(_self.id + "content");
- if ((xWidth(elm) + dx) > _self.minDialogWidth) {
- xResizeTo(elm, xWidth(elm) + dx, xHeight(elm) + dy);
- if (_self.backing) {
- xResizeTo(_self.backing, xWidth(_self.dlg), xHeight(_self.dlg));
- }
- }
- }
- }
- },
- onclose: function() {
- this.hide();
- },
-
- oncommand: function(e, tag) {
- try {
- if (false == this.processCommand(tag.id.substring((this.id + "btn").length))) {
- return;
- }
- }
- catch (err) {
- _F_log("E", err);
- }
- if (this.content && this.contentNativeParent) {
- //Detach the content node from the dialog and re-attach to the native parent
- this.content.parentNode.removeChild(this.content);
- this.contentNativeParent.appendChild(this.content);
- }
- this.hide();
- },
-
- processCommand: function(action) {
- if (this.fragment) {
- if ((action == ui_dialog.button.OK) ||
- (action == ui_dialog.button.APPLY) ||
- (action == ui_dialog.button.YES))
- {
- return this.fragment.raiseEvent("cognos.ui.dialog.ok", null, null);
- }
- else if ((action == ui_dialog.button.CANCEL) ||
- (action == ui_dialog.button.CLOSEBOX) ||
- (action == ui_dialog.button.CLOSE) ||
- (action == ui_dialog.button.NO))
- {
- return this.fragment.raiseEvent("cognos.ui.dialog.cancel", null, null);
- }
- else if ((action == ui_dialog.button.HELPBOX))
- {
- ui_fragment_help(this.fragment);
- return false;
- }
- else
- {
- _F_log("E", "Event " + evt.name + " not handled");
- return false;
- }
- }
- return true;
- },
-
- setCaption: function(text) {
- if (this.dlg != null) {
- $(this.id + "captiontext").innerHTML = _F_Strings.htmlEncode(text);
- } else {
- this.caption = text;
- }
- },
- setContent: function(content) {
- this.content = content;
- if (this.dlg != null) {
- this.attachContent(content);
- }
- },
-
- attachContent: function(content) {
- this.content = content;
- var contentParentDiv = $(this.id + "content");
- if (contentParentDiv) {
- if (typeof content == "string") {
- var tempEl = document.createElement("div");
- tempEl.innerHTML = content;
- contentParentDiv.appendChild(tempEl);
- } else {
- this.contentNativeParent = content.parentNode;
- if (this.contentNativeParent) {
- this.contentNativeParent.removeChild(content);
- }
- contentParentDiv.appendChild(content);
- content.style.display='';
- }
- }
- },
-
- getResults: function() {
- return this.results;
- }
- };
- /**
- * ui_locker - creates a full screen DIV to lock events
- */
- function ui_locker() {
- this.divID = "ui_locker";
- this.backingID = "ui_lockerBacking";
- var backing = $(this.backingID);
-
- if (backing == null) {
- backing = document.createElement("iframe");
- backing.id = this.backingID;
- backing.name = this.backingID;
-
- backing.style.display= "none";
- backing.style.position="absolute";
- backing.style.backgroundColor="#dddddd";
- backing.style.filter="alpha(opacity=0)";
- backing.style.opacity="0.0";
- backing.style.MozOpacity="0.0";
- backing.src = _F_Config.webContent + "/fragments/common/images/space.gif";
- backing.setAttribute("role","presentation");
- document.body.appendChild(backing);
- }
- var div = $(this.divID);
- if (div == null) {
- div = document.createElement("DIV");
- div.id = this.divID;
- div.style.display= "none";
- div.style.position="absolute";
- div.style.backgroundColor="#dddddd";
- document.body.appendChild(div);
- }
- this.count = 0;
- }
- ui_locker.singleton = null;
- ui_locker.get = function() {
- if (ui_locker.singleton == null) {
- ui_locker.singleton = new ui_locker();
- }
- return this.singleton;
- };
- ui_locker.prototype = {
-
- show: function(bHidden) {
- var div = $(this.divID);
- var backing = $(this.backingID);
- if ((++this.count) == 1) {
- div.style.width = "0px";
- div.style.height = "0px";
- div.style.top = "0px";
- div.style.left ="0px";
- div.style.display = "";
- backing.style.width = "0px";
- backing.style.height = "0px";
- backing.style.top = "0px";
- backing.style.left ="0px";
- backing.style.display = "";
- if (bHidden && bHidden == true) {
- div.style.filter="alpha(opacity=0)";
- div.style.opacity="0.0";
- div.style.MozOpacity="0.0";
- } else {
- div.style.filter="alpha(opacity=50)";
- div.style.opacity="0.5";
- div.style.MozOpacity="0.5";
- }
- this.onresize();
- }
- if (ui_dialog.chain != null && ui_dialog.chain.length > 0) {
- // move the glass before this dialog window
- var w = ui_dialog.chain[ui_dialog.chain.length - 1];
- if (w.dlg != null) {
- w.dlg.parentNode.insertBefore(backing, w.dlg);
- w.dlg.parentNode.insertBefore(div, w.dlg);
- }
- }
- },
-
- hide: function() {
- var div = $(this.divID);
- var backing = $(this.backingID);
- if (ui_dialog.chain != null && ui_dialog.chain.length > 0) {
- // move the glass before this dialog window
- var w = ui_dialog.chain[ui_dialog.chain.length - 1];
- if (w.dlg != null) {
- w.dlg.parentNode.insertBefore(backing, w.dlg);
- w.dlg.parentNode.insertBefore(div, w.dlg);
- }
- }
- if ((--this.count) == 0) {
- xDisplay(this.divID, "none");
- xDisplay(this.backingID, "none");
- }
- },
-
- isVisible: function() {
- return (ui_locker.singleton != null) && ("none" != xDisplay(this.divID));
- },
-
- onresize: function() {
- var div = $(this.divID);
- var backing = $(this.backingID);
- var cx = xClientWidth();
- if (cx < document.body.scrollWidth) {cx = document.body.scrollWidth;}
- var cy = xClientHeight();
- if (cy < document.body.scrollHeight) {cy = document.body.scrollHeight;}
- xResizeTo(div, cx, cy);
- xResizeTo(backing, cx, cy);
- }
- };
- /**
- * toolbarButtonMouseOver
- * @deprecated
- */
- function toolbarButtonMouseOver(e) {
- e.className = "cogstyle-btn-over";
- }
- /**
- * toolbarButtonMouseOut
- * @deprecated
- */
- function toolbarButtonMouseOut(e) {
- e.className = "cogstyle-btn-normal";
- }
- var ui_curmenu = null;
- var ui_menuevt = false;
- /**
- * ui_menuShow
- * @param evt
- * @param menu
- */
- function ui_menuShow(evt, menu) {
- ui_menuHide();
- menu.show(evt);
- }
- /**
- * ui_menuUpdate
- * @param menu
- */
- function ui_menuUpdate(menu) {
- menu.rebuild = true;
- }
- /**
- * ui_menuHide
- */
- function ui_menuHide(menu) {
- if (!menu && ui_curmenu) {
- menu = ui_curmenu;
- if (menu.enabled) {
- menu.enabled = false;
- var currentElement = document.activeElement;
- if (!ui_isTabNavigable(currentElement)) {
- if (menu.originalControlElement != null) {
- menu.originalControlElement.focus();
- }
- }
- }
- }
- if (menu != null) {
- if (menu.child) {
- for (var i in menu.child) {
- menu.child[i].enabled = false;
- ui_menuHide(menu.child[i]);
- }
- ui_curmenu = null;
- }
- if (menu.hide) {
- menu.hide();
- }
- }
- }
- /**
- * ui_menuHideHook
- * @param evt
- */
- function ui_menuHideHook(evt) {
- ui_menuHide();
- }
- /**
- * ui_menuMouseOver
- * @param evt
- */
- function ui_menuMouseOver(evt, menu) {
- evt = evt != null ? evt : window.event;
- var e = evt.srcElement ? evt.srcElement : evt.target;
- if (e.tagName == "TD") {
- e = e.parentNode; //get the TR rather than the TD
- }
- if (menu.menudef.items[menu.curitem] && menu.menudef.items[menu.curitem].items != null) {
- menu.child[menu.curitem].enabled = false;
- ui_menuHide(menu.child[menu.curitem]);
- }
- if (menu != null && menu.curitem !=null) {
- document.getElementById(menu.menudef.id + "TR" + menu.curitem).className = "cogstyle-menu-item";
- menu.curitem = e.id.substring(e.id.lastIndexOf("TR")+2);
- }
- e.className = "cogstyle-menu-item-hilite";
- e.focus();
- }
- /**
- * ui_menuMouseOut
- */
- function ui_menuMouseOut(evt) {
- evt = evt != null ? evt : window.event;
- var e = evt.srcElement ? evt.srcElement : evt.target;
- if (e.tagName == "TD") {
- e = e.parentNode; //get the TR rather than the TD
- }
- e.className = "cogstyle-menu-item";
- }
- /**
- * ui_menu
- * @param menudef
- */
- function ui_menu(menudef) {
- this.menu = null;
- this.backing = null;
- this.menudef = menudef;
- this.rebuild = true;
- this.child = null;
- this.enabled = false;
- this.fragment = null;
- this.curitem = null;
- this.selectedItem = null;
- this.originalControlElement = null;
- }
- ui_menu.prototype = {
- build: function() {
- // Remove the old menu if it already exists and is not this menu
- // This menu is taken care of later.
- var oldDiv = $(this.menudef.id + "mainDiv");
-
- if (oldDiv && oldDiv != this.menu) {
- document.body.removeChild(oldDiv);
- }
- var oldBacking = $(this.menudef.id + "backing");
-
- if (oldBacking && oldBacking != this.backing) {
- document.body.removeChild(oldBacking);
- }
-
- if (ui_menuevt == false) {
- //Attach global events used by ui_menus.
- ui_menuevt = true;
- _F_Document.addEventListener(document.body, "mouseup", ui_menuHideHook);
- _F_Document.addEventListener(window, "blur", ui_menuHideHook);
- }
-
- if (this.menu != null) {
- document.body.removeChild(this.menu);
- this.menu = null;
- }
- if (this.backing != null) {
- document.body.removeChild(this.backing);
- this.backing = null;
- }
-
- var pad = false;
- var selected = false;
- for (var i=0; i<this.menudef.items.length; i++) {
- if (this.menudef.items[i].image != null) {
- pad = true;
- if (selected) {break;}
- }
- if (this.menudef.items[i].selected) {
- selected = true;
- if (pad) {break;}
- }
- }
-
- var div = document.createElement('div');
- div.id = this.menudef.id + "mainDiv";
- div.style.display="none";
- div.className="cogstyle-menu-popup";
- // The tab index is required for keyboard events to be processed for the div in FireFox
- div.tabIndex="-1";
- div.setAttribute("aria-label", this.menudef.title || PFM.JS.IDS_JS_ACTION);
-
- xAddEventListener(div, "keyup", _F_Document.associate(window, this, "onkeypress"));
- xAddEventListener(div, "keypress", _F_Document.associate(window, this, "handleTab"));
- var table = document.createElement('table');
- table.cellSpacing="0";
- table.cellPadding="0";
- table.border="0";
- table.setAttribute("role","menu");
- table.setAttribute("aria-label", this.menudef.title || PFM.JS.IDS_JS_ACTION);
- tbody = document.createElement('tbody');
- table.appendChild(tbody);
- for (i=0; i<this.menudef.items.length; i++) {
- if (this.menudef.items[i].getItemState && this.menudef.items[i].getItemState(this.menudef, i) == 'hide') {
- continue;
- }
- if (this.menudef.items[i].separatorBefore) {
- var tr_separator = document.createElement('tr');
- var td_separator = document.createElement('td');
- var separator = document.createElement('div');
- separator.className="cogstyle-menu-item-separator";
- td_separator.appendChild(separator);
- tr_separator.appendChild(td_separator);
- tbody.appendChild(tr_separator);
- }
-
- var tr = document.createElement('tr');
- tr.setAttribute("role","menuitem");
- tr.setAttribute("aria-haspopup", this.menudef.items[i].haspopup && (this.menudef.items[i].haspopup == true) ? "true" : "false");
- tr.setAttribute("tabindex","-1");
- tr.id = this.menudef.id + "TR" + i;
-
- if (selected) {
- var tdSelected = document.createElement('td');
- tdSelected.className="cogstyle-menu-item";
- tdSelected.width="4px";
- if (this.menudef.items[i].selected) {
- this.curitem = this.selectedItem = i; //Use this index as reference for the current and selected item.
- tdSelected.className="cogstyle-menu-item-selected";
- }
- tr.appendChild(tdSelected);
- }
-
- var td = document.createElement('td');
-
- if (this.menudef.items[i].image != null) {
- td.style.backgroundImage="url("+ ((this.menudef.items[i].image.indexOf("http") == 0) ? this.menudef.items[i].image : _F_Config.webContent+this.menudef.items[i].image)+")";
- td.style.backgroundRepeat="no-repeat";
- td.style.backgroundPosition="6px center";
- }
-
- if (pad) {
- td.style.paddingLeft="32px";
- }
- if (this.menudef.items[i].action) {
- tr.className="cogstyle-menu-item";
- td.className="cogstyle-menu-item";
-
- var self = this;
- function menuAction(context) {
- function menuActionFunction(evt) {
- var menuDef = context.menuDef;
- var selectedIdx = context.selectedIdx;
- ui_curmenu.selectMenuItem(menuDef.items[selectedIdx].id);
- ui_menuHide(evt);
- if (self.fragment) {
- self.fragment.raiseEvent("cognos.ui.menu.select", context);
- }
- setTimeout(menuDef.items[selectedIdx].action, 1);
- }
- return menuActionFunction;
- }
- var mouseDownFunction = menuAction({"menuDef":this.menudef,"selectedIdx":i});
- td.className="cogstyle-menu-item";
- EventUtils.addEventListener(tr, "mousedown", mouseDownFunction);
- EventUtils.addEventListener(tr, "mouseout", ui_menuMouseOut);
- EventUtils.addEventListener(tr, "mouseover", _F_Document.associate(tr, this, "onmouseover"));
- } else if (this.menudef.items[i].items) { //this menu item has childen
- tr.key=i;
- td.className="cogstyle-menu-item";
- td.style.backgroundImage="url("+_F_Config.webContent+"/fragments/common/images/right.gif)";
- td.style.backgroundRepeat="no-repeat";
- td.style.backgroundPosition="right";
- td.style.paddingRight="10px";
- if (!this.child) {
- this.child = [];
- }
- this.child[i] = new ui_menu ({id: "child", parent: this, items: this.menudef.items[i].items});
- _F_Document.addEventListener(tr, "mouseout", ui_menuMouseOut);
- _F_Document.addEventListener(tr, "mouseout", _F_Document.associate(tr, this, "onmouseout"));
- tr.onmouseover = _F_Document.associate(tr, this, "onmouseoverParent");
- } else {
- td.className="cogstyle-menu-item-disabled";
- }
- td.appendChild(document.createTextNode(this.menudef.items[i].title));
- tr.appendChild(td);
- tbody.appendChild(tr);
-
- if (this.menudef.items[i].items) {
- var image=document.defaultView ? document.defaultView.getComputedStyle(td,null).backgroundImage : td.currentStyle.backgroundImage;
- if (image.indexOf('right.gif') < 0) {
- //High Contrast Mode detected. Background images are lost so enable checkMark image via applicable CSS class
- td.className="cogstyle-menu-item-parent";
- }
- }
- }
- div.appendChild(table);
-
- var iframe = document.createElement("iframe");
- iframe.id = this.menudef.id + "backing";
- iframe.style.display = "none";
- iframe.style.border = "0px";
- iframe.style.position = "absolute";
- iframe.src = _F_Config.webContent + "/fragments/common/images/space.gif";
-
- document.body.appendChild(iframe);
- document.body.appendChild(div);
-
- this.backing = iframe;
- this.menu = div;
- this.rebuild = false;
- },
-
- show: function(evt) {
- if (this.menu == null || this.rebuild) {
- this.build();
- } else {
- // set the current item to the current selected item
- this.curitem = this.selectedItem;
- }
-
- var e=this.findObject(evt);
- this.originalControlElement = e;
-
- var x=getAbsolutePosX(e) - getScrollPosX(e) + xWidth(e) - (this.menudef.parent ? 0 : xWidth(e)) + 2;
- var y=getAbsolutePosY(e) - getScrollPosY(e) + e.offsetHeight - (this.menudef.parent ? 16 : 0);
-
- this.menu.style.left = "-1000px"; // make it off screen
- this.menu.style.display = "block";
-
- var dropDownHeight = xHeight(this.menu);
- if ((y + dropDownHeight) > xClientHeight()) {
- y = y - dropDownHeight - e.offsetHeight;
- }
-
- // Add the body scroll position to the calculation
- y = y + getBodyScrollPosY();
- x = x + getBodyScrollPosX();
-
- if (y < 0) {
- y = 0;
- }
- this.menu.style.top = y + "px";
- if ((x + this.menu.offsetWidth) > document.body.offsetWidth) {
- x += e.offsetWidth - this.menu.offsetWidth;
- }
- this.menu.style.left = x + "px";
- this.backing.style.top = y + "px";
- this.backing.style.height = xHeight(this.menu);
- this.backing.style.left = x + "px";
- this.backing.style.width = xWidth(this.menu);
- this.backing.style.display = "block";
- if (!this.menudef.parent) {
- ui_curmenu = this;
- this.menu.focus();
- }
- if (this.curitem == null) {
- this.curitem = 0;
- }
- var newElem = document.getElementById(this.menudef.id + "TR" + this.curitem);
- newElem.className = "cogstyle-menu-item-hilite";
- newElem.focus();
- /* find iframes in page and hide menu when they are focused. IE does not trigger the window.onmouseup event when you click on an iframe */
- for (var iframes = document.getElementsByTagName("iframe"), i = iframes.length; i--;) {
- if (iframes[i].getAttribute("menu-focus") == null) {
- _F_Document.addEventListener(iframes[i], "focus", ui_menuHideHook);
- iframes[i].setAttribute("menu-focus", "set");
- }
- if (iframes[i].getAttribute("title") == null) {
- iframes[i].setAttribute("role", "presentation");
- }
- }
- evt.cancelBubble = true;
- if (evt.stopPropagation) {
- evt.stopPropagation();
- }
- this.enabled = true;
- },
-
- hide: function() {
- if ((!this.enabled) && (this.menu != null)) {
- this.backing.style.display="none";
- this.menu.style.display="none";
- if (this.curitem != null) {
- document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
- this.curitem = null;
- }
- }
- },
- hideFocusOnControlElement: function(restoreTriggerFocus) {
- if (this.originalControlElement != null) {
- if (restoreTriggerFocus) {
- this.originalControlElement.focus();
- }
- this.currentControlElement = null;
- }
- ui_menuHide();
- },
- findObject: function(evt) {
- var e=evt.srcElement ? evt.srcElement : evt.target;
- while (e != null) {
- if (typeof e.onclick !== "undefined" || typeof e.onmouseover !== "undefined") {
- return e;
- }
- e = e.parentNode;
- }
- return e;
- },
- handleTab: function(evt){
- this.keyIsUp = true;
- evt = evt != null ? evt : window.event;
- if (evt.keyCode == 9){
- document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
- this.curitem = null;
- this.hideFocusOnControlElement(true);
- }
- },
- onkeypress: function(evt) {
- evt = evt != null ? evt : window.event;
- var e = evt.srcElement ? evt.srcElement : evt.target;
- // Enter: Act on the current menu
- var newElem;
- if (evt.keyCode == 13) {
- if (this.keyIsUp) {
- ui_curmenu.selectMenuItem(this.menudef.items[this.curitem].id);
- ui_menuHide(evt);
- if (this.fragment) {
- this.fragment.raiseEvent("cognos.ui.menu.select", context);
- }
- if (this.menudef.items[this.curitem].action) {
- setTimeout(this.menudef.items[this.curitem].action, 1);
- }
- if (this.menudef.items[this.curitem].items) {
- this.child[this.curitem].show(evt);
- document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
- } else {
- this.curitem = null;
- this.hideFocusOnControlElement();
- }
- }
- this.keyIsUp = false;
-
- }
- // Esc Key: Close menu
- else if (evt.keyCode == 27) {
- document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
- this.curitem = null;
- this.hideFocusOnControlElement(true);
- this.keyIsUp = false;
- }
- // Up Arrow
- else if (evt.keyCode == 38) {
- if (this.curitem != null) {
- document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
-
- if (this.curitem > 0) {
- this.curitem--;
- }
- newElem = document.getElementById(this.menudef.id + "TR" + this.curitem);
- newElem.className = "cogstyle-menu-item-hilite";
- newElem.focus();
- }
- }
- // Down arrow
- else if (evt.keyCode == 40) {
- if (this.curitem != null) {
- document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
- if (this.menudef.items.length-1 > this.curitem) {
- this.curitem++;
- }
- newElem = document.getElementById(this.menudef.id + "TR" + this.curitem);
- newElem.className = "cogstyle-menu-item-hilite";
- newElem.focus();
- }
- else {
- this.curitem = 0;
- newElem = document.getElementById(this.menudef.id + "TR" + this.curitem);
- newElem.className = "cogstyle-menu-item-hilite";
- newElem.focus();
- }
- }
- //tab key
- else if (evt.keyCode == 9) {
- this.hideFocusOnControlElement(true);
- }
- xStopPropagation(evt);
- },
- onmouseover: function(e, tag) {
- ui_menuMouseOver(e, this);
- this.enabled = true;
- },
-
- onmouseoverParent: function(e, tag) {
- ui_menuMouseOver(e, this);
- this.child[tag.key].show(e != null ? e : window.event);
- },
-
- onmouseout: function(e, tag) {
- this.child[tag.key].enabled = false;
- var self = this;
- window.setTimeout(function() { ui_menuHide(self.child[tag.key]); }, 100);
- },
-
- getRootMenuItems: function() {
- return this.menudef.items;
- },
-
- getSubMenuItems: function(item) {
- return item.items;
- },
-
- getMenuItemAndGroup: function(id, group) {
- var itemAndGroup = null;
- var menuItemList;
- if (group) {
- menuItemList = group;
- } else {
- menuItemList = this.menudef.items;
- }
- for (var i=0; i<menuItemList.length; i++) {
- if (menuItemList[i].id != null && menuItemList[i].id == id) {
- itemAndGroup = {};
- itemAndGroup.group = menuItemList;
- itemAndGroup.item = menuItemList[i];
- return itemAndGroup;
- }
- if (menuItemList[i].items) {
- itemAndGroup = this.getMenuItemAndGroup(id, menuItemList[i].items);
- if (itemAndGroup) {return itemAndGroup;}
- }
- }
-
- return null;
- },
-
- selectMenuItem: function(id) {
- var itemAndGroup = this.getMenuItemAndGroup(id);
- if (itemAndGroup) {
- this.clearGroupSelection(itemAndGroup.group);
- itemAndGroup.item.selected = true;
- this.rebuild = true;
- return true;
- }
- return false;
- },
-
- clearGroupSelection: function(group) {
- for (var i=0; i<group.length; i++) {
- if (group[i].selected) {
- this.rebuild = true;
- group[i].selected = false;
- }
- }
- }
- };
- /**
- * ui_dockpane
- * @param obj
- */
- function ui_dockpane(obj) {
- for (var o in obj) {
- this[o] = obj[o];
- }
- if (this.width == null) {
- this.width = 200;
- }
- this.anim_pos = 0;
- this.sid = "";
- }
- ui_dockpane.prototype = {
-
- show: function() {
- this.anim_pos = -this.width;
- this.div.style.left = this.anim_pos+"px";
- this.div.style.top = "0px";
- this.div.style.width = this.width+"px";
- this.div.style.height = "100%";
- this.div.style.display = "block";
- this.parent.style.marginLeft = "0px";
- var self = this;
- this.sid = window.setInterval(function() { self.animate(); }, 10);
- },
- hide: function() {
- this.anim_pos = 0;
- this.div.style.display = "none";
- this.parent.style.marginLeft = "0px";
- },
- animate: function() {
- if (this.anim_pos < 0) {
- this.anim_pos += (this.width / 25);
- this.div.style.left = this.anim_pos+"px";
- } else {
- window.clearInterval(this.sid);
- this.div.style.left = "0px";
- this.parent.style.marginLeft = this.width+"px";
- }
- }
- };
- /**
- * ui_modal_dialog
- * @deprecated
- */
- function ui_modal_dialog() {
- throw 'RuntimeException: ui_modal_dialog is a static class and may not be instantiated';
- }
- var UI_MODAL_DIALOG_VISIBLE_DIALOG = true;
- var UI_MODAL_DIALOG_TRIGGER_ELEMENT = null;
- ui_modal_dialog.open = function (url, showHeader, visibleDialog, forceReload, usePost, contentId) {
- UI_MODAL_DIALOG_TRIGGER_ELEMENT = document.activeElement;
- //if someone has passed in the visible dialog then use it, otherwise default it to true
- if (visibleDialog != null) {
- UI_MODAL_DIALOG_VISIBLE_DIALOG = visibleDialog;
- } else {
- UI_MODAL_DIALOG_VISIBLE_DIALOG = true;
- }
- var modalForceReload = true;
- if (forceReload != null) {
- modalForceReload = forceReload;
- }
- var modalHideHeader = false;
- if (showHeader != null && showHeader == true) {
- modalHideHeader = true;
- }
- var pageBlurBacking = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR_BACKING");
- if (pageBlurBacking == null) {
- pageBlurBacking = document.createElement("iframe");
- pageBlurBacking.id = "UI_MODAL_DIALOG_PAGE_BLUR_BACKING";
- pageBlurBacking.name = "UI_MODAL_DIALOG_PAGE_BLUR_BACKING";
-
- pageBlurBacking.style.display= "none";
- pageBlurBacking.style.position="absolute";
- pageBlurBacking.style.backgroundColor="#eeeeee";
- pageBlurBacking.style.filter="alpha(opacity=0)";
- pageBlurBacking.style.opacity="0.0";
- pageBlurBacking.src = _F_Config.webContent + "/fragments/common/images/space.gif";
- document.body.appendChild(pageBlurBacking);
- }
- var pageBlurDiv = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR");
- if (pageBlurDiv == null) {
- pageBlurDiv = document.createElement("div");
- pageBlurDiv.id = "UI_MODAL_DIALOG_PAGE_BLUR";
- pageBlurDiv.style.display= "none";
- pageBlurDiv.style.position="absolute";
- pageBlurDiv.style.backgroundColor="#eeeeee";
- pageBlurDiv.style.filter="alpha(opacity=50)";
- pageBlurDiv.style.opacity="0.3";
- pageBlurDiv.style.zIndex="8999";
- document.body.appendChild(pageBlurDiv);
- }
- var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV");
- if (iFrameDiv == null) {
- // BUSY DIV
- var iFrameBusy = document.createElement("div");
- iFrameBusy.id = "UI_MODAL_DIALOG_IFRAME_BUSY_DIV";
- iFrameBusy.style.padding="10px";
- iFrameBusy.style.position="absolute";
- document.body.appendChild(iFrameBusy);
- var nobr = document.createElement("div");
- nobr.style.backgroundColor="#EFEFEF";
- nobr.style.padding="10px";
- nobr.style.border="solid 1px black";
- nobr.style.textAlign="center";
- nobr.id ="UI_MODAL_DIALOG_IFRAME_BUSY_IMG";
- iFrameBusy.appendChild(nobr);
- var busyProgressImg = document.createElement("img");
- busyProgressImg.src = _F_Config.webContent + "/fragments/common/images/progress.gif";
- busyProgressImg.align= "absmiddle";
- nobr.appendChild(busyProgressImg);
- var cancelLink = document.createElement("a");
- cancelLink.href="javascript:ui_modal_dialog.close()";
- nobr.appendChild(cancelLink);
- cancelLink.appendChild(document.createTextNode(PFM.JS.IDS_JS_MODAL_CANCEL));
- // IFRAME DIV
- iFrameDiv = document.createElement("div");
- iFrameDiv.id = "UI_MODAL_DIALOG_IFRAME_DIV";
- iFrameDiv.style.padding="0px";
- iFrameDiv.style.display= "none";
- iFrameDiv.style.position="absolute";
- iFrameDiv.style.zIndex="9001";
- iFrameDiv.tabIndex="0";
- iFrameDiv.setAttribute("role", "dialog");
- document.body.appendChild(iFrameDiv);
- // HEADER
- var headerDiv = document.createElement("div");
- headerDiv.id = "UI_MODAL_DIALOG_IFRAME_HEADER_DIV";
- headerDiv.style.textAlign="right";
- headerDiv.style.width = "100%";
- headerDiv.style.paddingTop="3px";
- headerDiv.style.paddingBottom="3px";
- headerDiv.style.borderRight="solid 1px black";
- headerDiv.style.borderLeft="solid 1px black";
- headerDiv.style.borderTop="solid 1px black";
- headerDiv.style.height="20px";
- headerDiv.style.backgroundColor="#eeeeee";
- cancelLink = document.createElement("a");
- cancelLink.style.marginRight="3px";
- cancelLink.href="javascript:ui_modal_dialog.close()";
- var busyImg = document.createElement("img");
- busyImg.id="UI_MODAL_DIALOG_IFRAME_HEADER_DIV_CLOSE";
- busyImg.style.border="solid 1px #eeeeee";
- busyImg.src = _F_Config.webContent + "/fragments/common/images/dialog_close.gif";
- busyImg.border="0";
- busyImg.align= "absmiddle";
- _F_Document.addEventListener(busyImg,"mouseover", function(event) { document.getElementById("UI_MODAL_DIALOG_IFRAME_HEADER_DIV_CLOSE").style.border="solid 1px black";});
- _F_Document.addEventListener(busyImg,"mouseout", function(event) { document.getElementById("UI_MODAL_DIALOG_IFRAME_HEADER_DIV_CLOSE").style.border="solid 1px #eeeeee";});
- cancelLink.appendChild(busyImg);
- headerDiv.appendChild(cancelLink);
- iFrameDiv.appendChild(headerDiv);
- // IFRAME
- var iFrame = null;
- if (xIE4Up) {
- //Get around issue with posting to an iframe causing new window to be opened for IE in quirks mode
- try {
- iFrame = document.createElement('<iframe name="UI_MODAL_DIALOG_IFRAME"/>');
- } catch (e) {
- iFrame = null;
- }
- }
- if (iFrame == null) {
- iFrame = document.createElement("iframe");
- }
- iFrame.id = "UI_MODAL_DIALOG_IFRAME";
- iFrame.name = "UI_MODAL_DIALOG_IFRAME";
-
-
- iFrame.src = _F_Config.webContent + "/fragments/common/images/space.gif";
- iFrame.style.width = "100%";
- iFrame.style.height = "100%";
- iFrame.style.zIndex="9000";
- iFrame.style.backgroundColor="white";
- iFrame.style.borderRight="solid 1px black";
- iFrame.style.borderLeft="solid 1px black";
- iFrame.style.borderBottom="solid 1px black";
- iFrame.border ="0";
- iFrame.style.margin="0px";
- iFrame.fragClientWidth = document.body.clientWidth - 80;
- iFrameDiv.appendChild(iFrame);
- _F_Document.addEventListener(iFrame,"load", function(event) { ui_modal_dialog.loaded(event);});
- _F_Document.addEventListener(window,"resize", function(event) { ui_modal_dialog.resize(event);});
-
- //need to create a dummy element in here so that we can trap the last tab and move the focus back to the top of the dialog
- var dummyEl2 = document.createElement("p");
- dummyEl2.tabIndex = "-1";
- dummyEl2.id="UI_MODAL_DIALOG_TABSTOP2";
- dummyEl2.style.position="absolute";
- iFrameDiv.appendChild(dummyEl2);
- var dummyEl = document.createElement("p");
- dummyEl.tabIndex = "0";
- dummyEl.id="UI_MODAL_DIALOG_TABSTOP";
- dummyEl.style.position="absolute";
- xAddEventListener(dummyEl, "onfocus", this.cycleFocus);
- iFrameDiv.appendChild(dummyEl);
-
- //also need to make sure that you can't back tab out of the dialog
- xAddEventListener(iFrameDiv, "keypress", this.cycleFocusBack);
-
- }
-
- //Show or hide the header.
- var winHeader = document.getElementById("UI_MODAL_DIALOG_IFRAME_HEADER_DIV");
- var content = null;
- if (contentId != null) {
- content = $(contentId);
- winHeader.style.fontSize = xGetComputedStyle(content, "font-size");
- }
- if (modalHideHeader == true) {
- //Display header
- winHeader.style.display = "";
- } else {
- winHeader.style.display = "none";
- }
- // Blur page
- pageBlurDiv.style.width = "100%";
- pageBlurDiv.style.height = Math.max(document.body.scrollHeight, xClientHeight()) + "px";
- pageBlurDiv.style.top = "0";
- pageBlurDiv.style.left ="0";
- pageBlurDiv.style.display = "";
- pageBlurBacking.style.width = "100%";
- pageBlurBacking.style.height = Math.max(document.body.scrollHeight, xClientHeight()) + "px";
- pageBlurBacking.style.top = "0";
- pageBlurBacking.style.left ="0";
- pageBlurBacking.style.display = "";
- // Show busy
- var iFrameBusyDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_BUSY_DIV");
- iFrameBusyDiv.style.top =((document.body.clientHeight - 80 )/ 2) + "px";
- iFrameBusyDiv.style.left =((document.body.clientWidth - 80 )/ 2) + "px";
- if (contentId != null) {
- iFrameBusyDiv.style.fontSize = xGetComputedStyle(content, "font-size");
- }
- iFrameBusyDiv.style.display="";
- // invoke url
- var iFr = document.getElementById("UI_MODAL_DIALOG_IFRAME");
- if (modalForceReload == true) {
- //Add a timestamp to create a unique URL. This prevents the iFrame from using a cached version of the page.
- url += (( url.indexOf('?') + 1 ) ? '&' : '?') + ( new Date() ).getTime();
- }
- if (usePost != null && usePost == true) {
- this.postForm(url);
- } else {
- iFr.src = url;
- }
- };
- ui_modal_dialog.cycleFocusBack = function(event) {
- if (event.keyCode == 9 && event.shiftKey) {
- document.getElementById("UI_MODAL_DIALOG_TABSTOP2").focus();
- }
- };
- ui_modal_dialog.cycleFocus = function() {
- document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV").focus();
- };
- ui_modal_dialog.postForm = function(url) {
- var formElement = document.createElement("form");
- formElement.setAttribute("name","wsrp_rewrite_post_window_form");
- formElement.setAttribute("method","POST");
- formElement.setAttribute("target", "UI_MODAL_DIALOG_IFRAME");
-
- var action =_F_config.gateway; //default
- var qm_index = url.indexOf("?");
- if (qm_index!=0) {
- action = (qm_index==-1) ? url : url.substring(0, qm_index);
- }
- formElement.setAttribute("action", action);
-
- if (qm_index != -1) {
- var paramString = url.substring(qm_index+1);
- var params = paramString.split("&");
- var i;
- for (i=0; i < params.length; ++i) {
- if (params[i].length>0) {
- var hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- var eq_index = params[i].indexOf("=");
- if (eq_index != -1) {
- hiddenElement.setAttribute("name",unescape(params[i].substring(0,eq_index)));
- hiddenElement.setAttribute("value",unescape(params[i].substring(eq_index+1)));
- } else {
- hiddenElement.setAttribute("name",unescape(params[i]));
- hiddenElement.setAttribute("value","");
- }
- formElement.appendChild(hiddenElement);
- }
- }
- }
- document.body.appendChild(formElement);
- formElement.submit();
- document.body.removeChild(formElement);
- formElement = null;
- };
- ui_modal_dialog.loaded = function(event) {
- var pageBlurDiv = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR");
- var pageBlurBacking = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR_BACKING");
- var iFrameBusy = document.getElementById("UI_MODAL_DIALOG_IFRAME_BUSY_DIV");
- var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV");
- var iFrame = document.getElementById("UI_MODAL_DIALOG_IFRAME");
- var dummyEl = document.getElementById("UI_MODAL_DIALOG_TABSTOP");
- var dummyEl2 = document.getElementById("UI_MODAL_DIALOG_TABSTOP2");
- if (iFrameDiv.style.display == "none" && iFrameBusy.style.display == "" && UI_MODAL_DIALOG_VISIBLE_DIALOG) {
- iFrameBusy.style.display="none";
- iFrameDiv.style.width = (xClientWidth() - 80) + "px";
- iFrameDiv.style.height = (xClientHeight() - 80) + "px";
- iFrameDiv.style.top = 30+ getScrollPosY(document.body) + "px";
- iFrameDiv.style.left = "30px";
- dummyEl.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
- dummyEl.style.left = "30px";
- dummyEl2.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
- dummyEl2.style.left = "30px";
- iFrameDiv.style.display = "";
- iFrameDiv.focus();
- return;
- }
- else if ((xIE4Up) && (UI_MODAL_DIALOG_VISIBLE_DIALOG))
- {
- //if the page in the modal dialog is reloaded need to reset the width
- //for ie (it sometimes makes it a little teenie bit too small)
- iFrameBusy.style.display="none";
- iFrameDiv.style.padding = "1px";
- iFrameDiv.style.width = (xClientWidth() - 80) + "px";
- iFrameDiv.style.display = "";
- iFrameDiv.focus();
- return;
- }
- };
- ui_modal_dialog.resize = function(event) {
- var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV");
- var iFrame = document.getElementById("UI_MODAL_DIALOG_IFRAME");
- var dummyEl = document.getElementById("UI_MODAL_DIALOG_TABSTOP");
- var dummyEl2 = document.getElementById("UI_MODAL_DIALOG_TABSTOP");
-
- if ( (!xIE4Up) && UI_MODAL_DIALOG_VISIBLE_DIALOG)
- {
- iFrameDiv.style.width = (xClientWidth() - 80) + "px";
- iFrameDiv.style.height = (xClientHeight() - 80) + "px";
- iFrameDiv.style.top = 30+ getScrollPosY(document.body) + "px";
- iFrameDiv.style.left = "30px";
- dummyEl.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
- dummyEl.style.left = "30px";
- dummyEl2.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
- dummyEl2.style.left = "30px";
- iFrameDiv.style.display = "";
- iFrameDiv.focus();
- return;
- }
- else if ((xIE4Up) && (UI_MODAL_DIALOG_VISIBLE_DIALOG))
- {
- //if the page in the modal dialog is reloaded need to reset the width
- //for ie (it sometimes makes it a little teenie bit too small)
- iFrameDiv.style.padding = "1px";
- iFrameDiv.style.width = (xClientWidth() - 80) + "px";
- iFrameDiv.style.height = (xClientHeight() - 80) + "px";
- dummyEl.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
- dummyEl.style.left = "30px";
- iFrameDiv.style.display = "";
- iFrameDiv.focus();
- return;
- }
- };
- ui_modal_dialog.close = function() {
- UI_MODAL_DIALOG_VISIBLE_DIALOG = false; //Reset the visibility flag
- var pageBlurDiv = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR");
- var pageBlurBacking = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR_BACKING");
- var iFrameBusy = document.getElementById("UI_MODAL_DIALOG_IFRAME_BUSY_DIV");
- var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV");
- pageBlurDiv.style.display="none";
- pageBlurBacking.style.display="none";
- iFrameDiv.style.display="none";
- iFrameBusy.style.display = "none";
- var currentElement = document.activeElement;
- if (!ui_isTabNavigable(currentElement)) {
- if (UI_MODAL_DIALOG_TRIGGER_ELEMENT != null) {
- UI_MODAL_DIALOG_TRIGGER_ELEMENT.focus();
- }
- }
- };
- /**
- * getAbsolutePosX
- * @param e
- */
- function getAbsolutePosX(e) {
- var xx=0 + e.offsetLeft;
- var p=e.offsetParent;
- while(p!=null) {
- xx+=(0 + p.offsetLeft);
- p=p.offsetParent;
- }
- return xx;
- }
- /**
- * getScrollPosX
- * @param e
- */
- function getScrollPosX(e) {
- var xx = 0;
- var p=e;
- do {
- xx += p.scrollLeft || 0;
- p = p.parentNode;
- } while (p!=null);
- return xx;
- }
- /**
- * getBodyScrollPosX
- *
- */
- function getBodyScrollPosX() {
- return document.body.scrollLeft;
- }
- /**
- * getAbsolutePosY
- * @param e
- */
- function getAbsolutePosY(e) {
- var yy=0 + e.offsetTop;
- var p=e.offsetParent;
- while(p!=null) {
- yy+=(0 + p.offsetTop);
- p=p.offsetParent;
- }
- return yy;
- }
- /**
- * getScrollPosY
- * @param e
- */
- function getScrollPosY(e) {
- var yy = 0;
- var p=e;
- do {
- yy += p.scrollTop || 0;
- p = p.parentNode;
- } while (p!=null);
- return yy;
- }
- /**
- * getBodyScrollPosY
- *
- */
- function getBodyScrollPosY() {
- return document.body.scrollTop;
- }
- /**
- * EventUtils
- * @deprecated - use xAddEventListener
- */
- function EventUtils() {
- throw 'RuntimeException: EventUtils is a static utility class and may not be instantiated';
- }
- /**
- * addEventListener
- * @param target
- * @param type
- * @param callback
- * @param captures
- * @deprecated - use xAddEventListener instead.
- */
- EventUtils.addEventListener = function (target, type, callback, capture) {
- _F_Document.addEventListener(target, type, callback, capture);
- };
- /**
- * @deprecated: use _F_Document.associate()
- */
- EventUtils.associate = function (target, obj, methodName) {
- return function(e) {
- e = e||window.event;
- return obj[methodName](e, target);
- };
- };
- /**
- * ui_init - must be called on load of the page
- */
-
- function ui_init() {
- _F_Document.addEventListener(window, "resize", ui_onresize, true);
- fragment.prototype.onerror = function(msg, details, code) {
- if (this.error===undefined) {
- this.error = new ui_error(this.id, this.div);
- }
- this.error.setCode(code);
- this.error.setMessage(msg);
- this.error.setDetails(details);
- this.error.show();
- };
- fragment.prototype.clearerror = function() {
- if (this.error != null) {
- this.error.hide();
- }
- };
- if (window.pageInit) {
- pageInit();
- }
- ui_templates.preload();
- }
- /**
- * ui_onresize - handle the resizing event
- */
- function ui_onresize(evt) {
- ui_menuHideHook(evt);
- var locker = ui_locker.get();
- if (locker.isVisible()) {
- locker.onresize();
- }
- }
- /**
- * ui_calcAvailableHeight - calculate how much height an HTML element can take
- * to maximize itself.
- * @param e the HTML DOM element
- */
- function ui_calcAvailableHeight(e,p,n) {
- var y = 0,
- ey;
- var l = e;
- var ly = xHeight(l);
- while (e) {
- if (xDef(e.offsetHeight)) {
- ey = xHeight(e);
- y += (ey - ly);
- ly = ey;
- } else {
- ly = 0;
- }
- l = e;
- e = xParent(e, n);
- if (e != null && e === p) {
- if (document.body === p) {
- y += xOffsetTop(l);
- }
- e = l = null;
- }
- }
- y += xOffsetTop(l);
- return y;
- }
- /**
- * ui_calcMaximumHeight - calculates the height such that it takes up all browser height starting at 'e'
- */
- function ui_calcMaximumHeight(e, p, n) {
- var y = 0;
-
- while (e) {
- y += xOffsetTop(e);
- e = e.offsetParent;
- if (e == p) {
- break;
- }
- }
-
- return xClientHeight() - y;
- }
- /**
- * readjustParentHeight - readjusts the height of the parents to elinimate scrollbars
- */
- function readjustParentHeight(thisnodeid) {
- var t = document.getElementById(thisnodeid);
- while (t) {
- var parent = t.parentNode;
- if (parent) {
- if (parent.className == "cogstyle-htabs-page-content-fixed" || parent.className == "cogstyle-vtabs-page-content-fixed") {
- parent.style.height = "100%";
- }
- }
- t = parent;
- }
- }
-
- /**
- * ui_calcAvailableWidth - calculate how much width an HTML element can take
- * to maximize itself.
- * @param e the HTML DOM element
- */
- function ui_calcAvailableWidth(e,p,n) {
- var x = 0, ex;
- var l = e;
- var lx = xWidth(l);
- while (e) {
- if (xDef(e.offsetWidth)) {
- ex = xWidth(e);
- x += (ex - lx);
- lx = ex;
- } else {
- lx = 0;
- }
- l = e;
- e = xParent(e,n);
- if (e != null && e === p) {
- e = l = null;
- }
- }
- x += xOffsetLeft(l);
- return x;
- }
- // FIXME! Delete this
- function noop() {
- }
- function handleLogon(href, frag) {
-
- if (frag.mode == "edit") {
- alert(PFM.JS.IDS_JS_TIMEOUT_SETTINGS_LOST);
- }
-
- var href = window.location.href;
- var params = href.split("CAMNamespace=");
- if (params.length > 1) {
- var CAMNamespaceValue;
- var index = params[1].indexOf("&");
- if (index != -1) {
- CAMNamespaceValue = params[1].substring(0, index);
- } else {
- CAMNamespaceValue = params[1];
- }
- window.location.href = _F_Config.gateway + "?CAMNamespace=" + CAMNamespaceValue + "&b_action=xts.run&m=portal/main.xts&m_reload=&m_redirect=" + encodeURIComponent(href);
- } else {
- window.location.href = _F_Config.gateway + "?b_action=xts.run&m=portal/main.xts&m_reload=&m_redirect=" + encodeURIComponent(href);
- }
- }
- /**
- * ui_throbbers
- * @param id
- */
- function ui_throbbers(id, imgSrc) {
- this.id = id;
- this.throbberURI = imgSrc;
- // preload image
- new Image().src = imgSrc;
- }
- ui_throbbers.prototype = {
- map: {},
- getTabFragment: function(frag) {
- while (frag && frag.parent.id != this.id) {
- frag = frag.parent;
- }
- return frag;
- },
-
- throb: function(id, bStart) {
- var img = $(id);
- if (img) {
- var item = this.map[id];
- if (bStart) {
- if (item && item.count > 0) {
- item.count++;
- } else {
- this.map[id] =
- {
- count: 1,
- src: img.src
- };
- img.src = this.throbberURI;
- }
- } else {
- if (item && item.count > 0) {
- item.count--;
- if (item.count == 0) {
- img.src = item.src;
- delete this.map[id];
- }
- }
- }
- if (img.getAttribute("parent")) {
- this.throb(img.getAttribute("parent"), bStart);
- }
- }
- },
- reset: function() {
- for (var id in this.map) {
- var item = this.map[id];
- if (item) {
- if (item.count > 0) {
- var img = $(id);
- if (img) {
- img.src = item.src;
- }
- delete this.map[id];
- }
- }
- }
- },
- handler: function(evt) {
- var frag = this.getTabFragment(evt.target);
- if (frag) {
- this.throb(frag.id + "_throbber", evt.name == "fragment.retrieve.before");
- }
- }
- };
- // Helper methods used to determine the viewer height when displaying various Objects
- var ui_resizeHelper = {
- // Set a default height when the content uses an iframe with 100% height
- adjustHeightForFragmentContent: function(fragment, container, objectType, height) {
- if (container) {
- if (ui_resizeHelper.isIFrameBasedContent(objectType)) {
- var frame = ui_resizeHelper.getFirstVisibleIFrame(container);
- if (frame && (frame.height == "100%" || frame.style.height == "100%")) {
- var heightInPX = "365px";
- if (height > 0)
- {
- heightInPX = height + "px";
- }
- window.setTimeout(function() {
- container.originalHeight = container.style.height;
- container.style.height = heightInPX;
- }, 1);
- return;
- }
- }
-
- // Make sure to restore the original height, if any, when no resizing is required.
- if (container.originalHeight !== undefined){
- container.style.height = container.originalHeight ;
- delete container.originalHeight;
- }
- }
-
- },
-
- //Returns the first visible iframe
- getFirstVisibleIFrame: function(container) {
- var frame = null;
- if (container) {
- var nodeList = container.getElementsByTagName("iframe");
- for (var i = 0; i < nodeList.length; i++) {
- if (nodeList[i].style.display != "none") {
- frame = nodeList[i];
- break;
- }
- }
- }
- return frame;
- },
- // Check if the type of the object that is being viewed might return an iframe based content.\
- isIFrameBasedContent: function(type) {
- var iFrameBasedContent = ['query', 'analysis', 'report', 'reportView', 'output', 'powerPlayReport', 'powerPlay8Report', 'powerPlay8ReportView', 'powerPlayCube', 'document', 'documentContent', 'URL', 'dashboard'];
- return (_F_Array.indexOf(iFrameBasedContent, type) != -1);
- }
- };
- /**
- * ui_getNavigableElements - return an ordererd list of child tab stops for a given parent element
- * @param containerElement
- * @returns array of ordered tabstops
- */
- function ui_getNavigableElements(containerElement) {
-
- var tabStops = [];
-
- if (window.dojo) {
-
- var zeroTabStops = [];
-
- dojo.query("*", containerElement).forEach( function(ele) {
- if (ui_isTabNavigable(ele)) {
- if (ele.tabIndex == 0) {
- zeroTabStops[zeroTabStops.length] = ele;
- } else {
- tabStops[tabStops.length] = ele;
- }
- }
-
- });
-
- tabStops.sort(function(obj1, obj2) {
- return obj1.tabIndex - obj2.tabIndex;
- });
-
- tabStops = tabStops.concat(zeroTabStops);
- }
- return tabStops;
- }
- /**
- * ui_setFocus - set focus to the 1st focusable child tab stop for a given parent element
- * @param containerElement
- * @returns element with focus or null
- */
- function ui_setFocus(containerElement) {
- var tabStops = ui_getNavigableElements(containerElement);
- for (var i=0; i < tabStops.length;i++) {
- tabStops[i].focus();
- if (document.activeElement == tabStops[i]) {
- return tabStops[i];
- }
- }
- return null;
- }
- function ui_isTabNavigable(ele) {
- if (ele) {
- try {
- return (dijit.isTabNavigable(ele) && (!ele.disabled));
- } catch (e) {
- return false;
- }
- }
- return false;
- }
|