function Loaded_Chart(id){
};
function Render_Count(id,_1){
};
function Scrolled_Chart(id,_2,_3){
if(id=="undefined"){
Px.Ex.Application.currentScreen.chartScrollStart=_2;
Px.Ex.Application.currentScreen.chartScrollSpan=_3;
}
};
dojo.declare("Px.Ex.XhrMixin",null,{cancelXhr:function(){
try{
if(this.defers){
dojo.forEach(this.defers,function(v,i,a){
if(v){
v.cancel();
}
});
delete this.defers;
}
}
catch(ex){
}
},addDeferred:function(_1){
if(!this.defers){
this.defers=[];
}
this.defers.push(_1);
this.defers=dojo.map(this.defers,function(v,i,a){
if(v&&v.fired==-1){
return v;
}
return undefined;
});
},xhr:function(_2){
var _3=Px.Ex.Application.xhr(_2);
this.addDeferred(_3);
return _3;
},xhrLoad:function(_4){
if(_4.selector){
var fn=_4.load;
_4.load=function(_5,_6){
dojo.query(_4.selector).html(_5);
if(fn){
fn(_5,_6);
}
};
}
return this.xhr(_4);
}});
dojo.addOnLoad(function(){
var _1=Px.Ex.Application.getScreenId();
var _2={handle:dojo.hitch(Px.Ex.Application,"showScreen",_1),changeUrl:_1};
dojo.back.setInitialState(_2);
});
function isDefined(_3){
return (typeof _3=="undefined")?false:true;
};
function removeWidget(_4){
try{
var _5=dijit.byId(_4);
if(_5){
try{
_5.destroyRecursive(false);
}
catch(e1){
}
try{
_5.destroy(false);
}
catch(e2){
}
}
}
catch(e){
}
};
function isInArray(_6,_7){
var _8=_7.length;
for(var i=0;i<_8;i++){
if(_7[i]==_6){
return true;
}
}
return false;
};
function removeFromArray(_9,_a){
var _b=_a.length;
var _c=[];
for(var i=0;i<_b;i++){
if(_a[i]==_9){
_c.push(i);
}
}
for(var j=_c.length-1;j>=0;j--){
_a.splice(_c[j],1);
}
};
(function(){
var _d=dojo.data.util.sorter.basicComparator;
dojo.data.util.sorter.basicComparator=function(a,b){
if(a&&a.toLowerCase){
a=a.toLowerCase();
}
if(b&&b.toLowerCase){
b=b.toLowerCase();
}
return _d(a,b);
};
})();
dojo.getObject("Px.Exelate",true);
Px.Ex.Application={Width:{LOGIN:"500px",MAIN:"910px"},Titles:{COMMON:document.title},UserMenu:{},Patterns:{EMAIL:/^[^@]+@[^@]+\.\w{2,}$/,PHONE:/^(?:ext|EXT|x|\d|[-xX+ \\(\\)])+$/,NAME:/^(?:\w|\d|\s|[._\-+=$#@&*,()\[\]{}|])+$/,NAME_STR:"(?:\\w|\\d|\\s|[\\._\\-\\+=$#@&*,\\(\\)\\[\\]\\{\\}\\|])+"},Ids:{TEXI_COMMON:"TEXI",PAGE_LOGIN:"TEXI-LOGIN",PAGE_DASHBOARD_ID:"T4T-DASH",PAGE_ACTIVITY_REPORT_ID:"T4T-REP01",PAGE_PAYMENTS_REPORT_ID:"T4T-REP02",PAGE_DATA_GROUPS_REPORT_ID:"T4T-REP03",PAGE_DEAL_PERFORMANCE_REPORT_ID:"T4T-REP04",PAGE_BUY_PERFORMANCE_REPORT_ID:"T4B-REP01",PAGE_BUY_REPORT_ID:"T4B-REP02",PAGE_TOOLS_ID:"T4T-CONTACT",PAGE_SETTINGS_ID:"T4T-SETTINGS",PAGE_MANAGE_TPUBS_ID:"T4E-MNGTPUB",PAGE_MANAGE_BUYERS_ID:"T4E-MNGBUYER",PAGE_CONTRACTS_ID:"T4E-TPUBCONTRACT",PAGE_TPUB_USERS_ID:"T4E-TPUBUSER",PAGE_BUYERS_USERS_ID:"T4E-BUYERUSER",PAGE_EXELATE_USERS_ID:"T4E-EXELATEUSER",PAGE_NETWORKS_MONITOR_ID:"T4T-NETMON",PAGE_INSIGHT_FOR_TPUBS_ID:"T4T-INSIGHT01",PAGE_DEMOGRAPHICS_ID:"T4T-INSIGHT02",PAGE_TARGETING_SEGMENTS_ID:"T4T-INSIGHT03",PAGE_DDDEALS_ID:"T4T-3D",PAGE_DATA_TAGS_ID:"T4T-3DTAGS",PAGE_DEAL_SETTINGS_ID:"T4T-3DSET",PAGE_BUYER_DASHBOARD_ID:"T4B-DBDASH",PAGE_RATE_CARD_ID:"T4T-RATE",PAGE_BILLING_NETADJ_ID:"T4E-BILLNETADJ",PAGE_BUYER_REQUEST_ID:"T4T-BUYERREQ",PAGE_SEGMENTS_ID:"T4T-SEGMNG",PAGE_DIRECT_BUYERS_REPORT_ID:"T4T-REP05",PAGE_CATEGORY_PERMISSIONS_ID:"T4T-BUYERCATPERM",PAGE_CONFIG_META_VIEWER_ID:"T4E-METAVIEWER",PAGE_SEGMENT_DELIVERY_ID:"T4E-SEGDLV",PAGE_TEST_BED_ID:"T4E-TESTBED"},cleanup:function(){
this._finalizeCurrentScreen();
var _e=Px.Ex.Application;
delete _e.currentScreen;
delete _e.currentScreenId;
delete _e.contactRoleLoaded;
delete _e.permissionsLoaded;
delete _e.__permissions;
delete _e.__contactRole;
delete _e.__menuMap;
delete _e.__initScreenId;
delete _e.__insightInitArgs;
delete Px.Ex.Application._currentPublisherCode;
delete Px.Ex.Application._currentBuyerCode;
_e.login=new Px.Ex.Login();
_e.resetPassword=new Px.Ex.ResetPassword();
_e.changePassword=new Px.Ex.ChangePassword();
if(_e.menu){
_e.menu.destroy();
}
_e.menu=new Px.Ex.Menu();
if(_e.footer){
_e.footer.destroy();
}
_e.footer=new Px.Ex.Footer();
if(_e.title){
_e.title.cleanUp();
}
_e.title=new Px.Ex.Title();
},init:function(){
dojo.addOnLoad(function(){
$.tablesorter.defaults.widgets=["zebra"];
$.tablesorter.defaults.sortMultiSortKey="ctrlKey";
Px.Ex.Application.loadInitData(function(){
Px.Ex.Application.cleanup();
Px.Ex.Application.startUp();
});
});
},validateBrowser:function(){
var _f;
if(this.isIPhoneOrIPod()){
if(this.isLabSubDomain()){
return true;
}
}else{
if(dojo.isIE){
_f=dojo.isIE;
if(_f>=7){
return true;
}
}else{
if(dojo.isFF){
_f=dojo.isFF;
if(_f>=2){
return true;
}
}else{
if(dojo.isChrome){
return true;
}else{
if(dojo.isOpera){
return true;
}else{
if(dojo.isSafari){
_f=dojo.isSafari;
if(_f>=3){
return true;
}
}
}
}
}
}
}
Px.Ex.Application.xhr({url:"/login/browser-support",load:function(_10){
dojo.query(".texi_content_container").html(_10);
}});
return false;
},isIPhoneOrIPod:function(){
if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))){
return true;
}else{
return false;
}
},isLabSubDomain:function(){
if(document.domain=="lab.texi.exelate.com"){
return true;
}else{
return false;
}
},startUp:function(){
var _11=function(_12,_13){
var app=Px.Ex.Application;
if(_12.userName){
app.xhr({url:"/user/new-view-data",handleAs:"json",load:app.changeView});
app.login.userName=_12.userName;
app.contactRoleLoaded=true;
app.permissionsLoaded=true;
app.__permissions=_12.permissions;
app.__contactRole=_12.contactRole;
if(_12.publisher){
app._currentPublisherCode=_12.publisher.publisherCode;
}
if(_12.buyer){
app._currentBuyerCode=_12.buyer.buyerID;
}
app.__menuMap=_12.menu;
app.setFrameWidth(app.Width.MAIN,function(){
var _14=app.getScreenId();
app.showScreen(_14);
});
}else{
app.login.show();
}
};
if(Px.Ex.Application.validateBrowser()){
Px.Ex.Application.xhr({url:"/login/already-logged",load:_11,handleAs:"json"});
}
},setFrameWidth:function(_15,_16){
$(".texi_content_container .wrapper").animate({width:_15},1500,_16);
},loadInitData:function(_17){
Px.Ex.Application.xhr({url:"/index/init-data",load:function(_18){
var app=Px.Ex.Application;
app._setWaitImage(_18.waitImage);
app._showErrors=_18.show_errors;
dojo.mixin(app.Titles,_18.titles);
dojo.mixin(app.UserMenu,_18.userMenu);
if(_17){
_17();
}
},handleAs:"json"});
},loadWaitImage:function(_19){
var app=Px.Ex.Application;
if(app._waitImageUrl){
if(_19){
_19();
}
}else{
dojo.xhrGet({url:"/index/wait-image",handleAs:"json",load:dojo.hitch(this,function(_1a){
app._setWaitImage(_1a.waitImage);
if(_19){
_19();
}
}),error:dojo.hitch(this,function(_1b){
if(_19){
_19();
}
})});
}
},_setWaitImage:function(url){
var app=Px.Ex.Application;
app._waitImageUrl=url;
app._waitHtml="<div class=\"texi_wait\"><img src=\""+app._waitImageUrl+"\" alt=\"loading...\"/>";
},getWaitHtml:function(){
return Px.Ex.Application._waitHtml;
},getNiceWaitHtml:function(){
return "<div class=\"texi_wait\"><img src=\""+"/release/dojo/dijit/themes/tundra/images/treeExpand_loading.gif"+"\" alt=\"loading...\"/>";
},getWaitImageUrl:function(){
return Px.Ex.Application._waitImageUrl;
},xhr:function(_1c){
var _1d=_1c.method?_1c.method.toUpperCase():"POST";
var _1e=dojo.xhr(_1d,{url:_1c.url,content:_1c.content,handle:function(_1f,_20){
if(Px.Ex.Application.__xhr_counter&&Px.Ex.Application.__xhr_counter>0){
Px.Ex.Application.__xhr_counter--;
}
if(_1c.handle){
_1c.handle(_1f,_20);
}
if(_1f instanceof Error){
if(_1c.error){
_1c.error(_1f,_20);
}
if(_1f.dojoType!="cancel"){
Px.Ex.Application.showGlobalError(_1f,_20);
}
}else{
if(_20.xhr.responseText=="\"not logged\""){
Px.Ex.Application._relogin=true;
Px.Ex.Application.__doReloginAfter();
}else{
if(_1c.load){
_1c.load(_1f,_20);
}
}
}
if(!Px.Ex.Application.__xhr_counter){
Px.Ex.Application.__doReloginAfter();
}
},handleAs:_1c.handleAs||"text",preventCache:_1c.preventCache||false},_1d=="POST");
if(!Px.Ex.Application.__xhr_counter){
Px.Ex.Application.__xhr_counter=0;
}
Px.Ex.Application.__xhr_counter++;
return _1e;
},showGlobalError:function(_21,_22){
if(Px.Ex.Application._showErrors){
var msg=Px.Ex.Application._extractError(_21,_22);
var num=dojo.query(".texi-global-error","divGlobalError").length+1;
msg=num+". "+dojo.date.stamp.toISOString(new Date())+": "+msg;
var div=dojo.create("div",{className:"texi-global-error",innerHTML:msg},"divGlobalError","first");
}
},_extractError:function(_23,_24){
var reg=/<b>Message:<\/b>(.*)$/m;
var _25=false;
var msg;
if(_23["return"]!==undefined){
_23=_23["return"];
}
if(!msg&&_23.responseText){
var m=_23.responseText.match(reg);
if(m){
msg=m[1];
}
}
if(!msg&&_23.message){
msg=_23.message;
}
if(!msg&&_23.errorMessage){
msg=_23.errorMessage;
}
if(msg=="missing ) in parenthetical"||msg=="invalid regular expression flag b"||msg=="unterminated parenthetical"||msg=="Unexpected token <"||msg=="Syntax error"){
msg=(_24&&_24.xhr)?_24.xhr.responseText:msg;
_25=true;
}
if(!msg){
msg=_23;
}
if(!dojo.isString(msg)){
if(msg.faultcode!==undefined&&msg.faultstring!==undefined){
msg="Error: "+msg.faultcode+"<br>Description: "+msg.faultstring;
}else{
msg=dojo.toJson(msg);
}
}
if(!_25&&_23.message&&msg!=_23.message){
msg=_23.message+"<br>"+msg;
}
return msg;
},__doReloginAfter:function(){
setTimeout(Px.Ex.Application.doRelogin,10);
},_clearContent:function(){
dojo.forEach(["divLogout","divGlobalError","divMenu","divSubMenu","divContent"],function(_26){
dojo.empty(_26);
});
},doRelogin:function(){
var app=Px.Ex.Application;
if(app._relogin){
app._relogin=undefined;
$.modal.impl.close();
closeMessageDialog();
closeDialog();
var _27=app.login.userName;
app.cleanup();
app.restoreView();
app._clearContent();
app.setFrameWidth(Px.Ex.Application.Width.LOGIN);
app.login.show(true,_27);
}
},logout:function(){
Px.Ex.Application.xhr({url:"/login/logout",load:function(_28){
Px.Ex.Application.restoreView();
Px.Ex.Application._clearContent();
Px.Ex.Application.setFrameWidth(Px.Ex.Application.Width.LOGIN);
Px.Ex.Application.cleanup();
Px.Ex.Application.login.show();
}});
},animateErrorMessage:function(_29,_2a){
var _2b=dojo.query(_29);
_2b.html(_2a);
_2b.animateProperty({duration:400,properties:{color:{end:"red"},backgroundColor:{end:"black"}},onEnd:function(){
_2b.animateProperty({duration:1000,properties:{color:{end:"black"},backgroundColor:{end:"white"}}}).play();
}}).play();
},deleteInsightInitArgs:function(){
delete Px.Ex.Application.__insightInitArgs;
},setContactRoleLoaded:function(_2c){
var app=Px.Ex.Application;
if(_2c){
app.__contactRole=_2c;
app.contactRoleLoaded=true;
}else{
delete app.__contactRole;
delete app.contactRoleLoaded;
}
},allowEditSettings:function(){
var app=Px.Ex.Application;
return app.__contactRole&&app.__permissions&&app.__permissions["T4T-SETTINGS"]&&app.__permissions["T4T-ACTIVE-TP"]&&app.__permissions["T4T-ACTIVE-TP-EDIT"];
},restoreView:function(){
var reg=/texi_css_T4.\.css/;
dojo.query("head link").forEach(function(v){
if(reg.test(v.href)){
dojo.destroy(v);
}
});
reg=/texi_css_TDM\.css/;
dojo.query("head link").forEach(function(v){
if(reg.test(v.href)){
dojo.destroy(v);
}
});
if(Px.Ex.Application._old_logo_text!==undefined){
dojo.query(".texi-logo-text").html(Px.Ex.Application._old_logo_text);
delete Px.Ex.Application._old_logo_text;
}
if(Px.Ex.Application._old_title!==undefined){
Px.Ex.Application.Titles.COMMON=Px.Ex.Application._old_title;
delete Px.Ex.Application._old_title;
}
},changeView:function(_2d){
Px.Ex.Application.restoreView();
Px.Ex.Application._old_logo_text=dojo.query(".texi-logo-text")[0].innerHTML;
Px.Ex.Application._old_title=Px.Ex.Application.Titles.COMMON;
Px.Ex.Application._scroller_tab_percent=_2d.scrollerTabPercent;
dojo.query(".texi-logo-text").html(_2d.logoText);
Px.Ex.Application.Titles.COMMON=_2d.pageTitle;
dojo.create("link",{type:"text/css",rel:"stylesheet",href:_2d.css},dojo.query("head")[0]);
},loadUserData:function(){
var app=Px.Ex.Application;
app.xhr({url:"/user/data",load:function(_2e){
app.__contactRole=_2e.contactRole;
if(app.__contactRole.isEntityPublisher&&!app.__contactRole.isEntityBuyer){
app._currentPublisherCode=app.__contactRole.contactEntity;
}else{
if(!app.__contactRole.isEntityPublisher&&app.__contactRole.isEntityBuyer){
app._currentBuyerCode=app.__contactRole.contactEntity;
}
}
app.__permissions=_2e.permissions;
app.__menuMap=_2e.menu;
delete _2e.permissions;
delete _2e.menu;
app.changeView(_2e);
app.contactRoleLoaded=true;
app.permissionsLoaded=true;
app.setFrameWidth(app.Width.MAIN,function(){
var _2f=app.getScreenId();
app.showScreen(_2f);
});
},handleAs:"json"});
},forcePublisherExistence:function(_30){
if(!Px.Ex.Application._currentPublisherCode){
var dlg=new Px.Ex.SettingsDialog({callback:_30,withMessage:true,requirePublisher:true,requireBuyer:false});
dlg.show();
}else{
_30();
}
},forceBuyerExistence:function(_31){
if(!Px.Ex.Application._currentBuyerCode){
var dlg=new Px.Ex.SettingsDialog({callback:_31,withMessage:true,requireBuyer:true,requirePublisher:false});
dlg.show();
}else{
_31();
}
},forcePublisherOrBuyerExistence:function(_32){
if((!Px.Ex.Application._currentPublisherCode)&&(!Px.Ex.Application._currentBuyerCode)){
var dlg=new Px.Ex.SettingsDialog({callback:_32,withMessage:true,requireBuyer:true,requirePublisher:true});
dlg.show();
}else{
_32();
}
},getScreenId:function(){
var url=window.location.toString();
var _33=url.slice(url.lastIndexOf("#")+1);
return _33;
},normalizeScreenId:function(_34){
var ids=Px.Ex.Application.Ids;
var _35=[ids.PAGE_DASHBOARD_ID,ids.PAGE_ACTIVITY_REPORT_ID,ids.PAGE_PAYMENTS_REPORT_ID,ids.PAGE_DATA_GROUPS_REPORT_ID,ids.PAGE_DEAL_PERFORMANCE_REPORT_ID,ids.PAGE_BUY_PERFORMANCE_REPORT_ID,ids.PAGE_BUY_REPORT_ID,ids.PAGE_TOOLS_ID,ids.PAGE_SETTINGS_ID,ids.PAGE_MANAGE_TPUBS_ID,ids.PAGE_MANAGE_BUYERS_ID,ids.PAGE_CONTRACTS_ID,ids.PAGE_TPUB_USERS_ID,ids.PAGE_BUYERS_USERS_ID,ids.PAGE_NETWORKS_MONITOR_ID,ids.PAGE_INSIGHT_FOR_TPUBS_ID,ids.PAGE_DEMOGRAPHICS_ID,ids.PAGE_TARGETING_SEGMENTS_ID,ids.PAGE_DDDEALS_ID,ids.PAGE_DEAL_SETTINGS_ID,ids.PAGE_DATA_TAGS_ID,ids.PAGE_BUYER_DASHBOARD_ID,ids.PAGE_RATE_CARD_ID,ids.PAGE_BILLING_NETADJ_ID,ids.PAGE_BUYER_REQUEST_ID,ids.PAGE_SEGMENTS_ID,ids.PAGE_DIRECT_BUYERS_REPORT_ID,ids.PAGE_CATEGORY_PERMISSIONS_ID,ids.PAGE_EXELATE_USERS_ID,ids.PAGE_CONFIG_META_VIEWER_ID,ids.PAGE_SEGMENT_DELIVERY_ID,ids.PAGE_TEST_BED_ID];
if(dojo.indexOf(_35,_34)>=0){
return _34;
}
return Px.Ex.Application.getInitScreenId();
},getInitScreenId:function(){
var app=Px.Ex.Application;
if(app.__initScreenId){
return app.__initScreenId;
}
var def=app.Ids.PAGE_DASHBOARD_ID;
if(app.__menuMap){
var _36=app.__menuMap.menues;
if(!_36){
return def;
}
if(!dojo.isArray(_36)){
_36=[_36];
}
var _37=_36[0].menuCode;
dojo.some(_36,function(v){
if(v.parentEntryCode==_37){
app.__initScreenId=v.screenId;
return true;
}
return false;
});
if(app.__initScreenId){
return app.__initScreenId;
}
}
return def;
},changeURL:function(_38){
var url=window.location.toString();
url=url.replace(/(#.*|)$/,"#"+_38);
window.location.href=url;
},_finalizeCurrentScreen:function(){
var app=Px.Ex.Application;
app.closeTooltip();
if(app.currentScreen&&app.currentScreen.cancelXhr){
app.currentScreen.cancelXhr();
}
if(app.currentScreen&&app.currentScreen.destroy){
app.currentScreen.destroy();
}
app.clearContent();
},reloadScreen:function(){
var app=Px.Ex.Application;
if(!app.currentScreenId){
return;
}
app.showScreen.call(app,app.currentScreenId,true,false);
},reloadScreenIfNeeded:function(_39,_3a){
var ids=Px.Ex.Application.Ids;
var _3b=[ids.PAGE_DASHBOARD_ID,ids.PAGE_ACTIVITY_REPORT_ID,ids.PAGE_PAYMENTS_REPORT_ID,ids.PAGE_DATA_GROUPS_REPORT_ID,ids.PAGE_DEAL_PERFORMANCE_REPORT_ID,ids.PAGE_TOOLS_ID,ids.PAGE_NETWORKS_MONITOR_ID,ids.PAGE_INSIGHT_FOR_TPUBS_ID,ids.PAGE_DEMOGRAPHICS_ID,ids.PAGE_TARGETING_SEGMENTS_ID,ids.PAGE_DDDEALS_ID,ids.PAGE_DEAL_SETTINGS_ID,ids.PAGE_DATA_TAGS_ID,ids.PAGE_RATE_CARD_ID,ids.PAGE_BUYER_REQUEST_ID,ids.PAGE_DIRECT_BUYERS_REPORT_ID];
var _3c=[ids.PAGE_TOOLS_ID,ids.PAGE_BUY_REPORT_ID];
var _3d=Px.Ex.Application.currentScreenId;
if(_39&&dojo.some(_3b,function(v){
return _3d==v;
})||_3a&&dojo.some(_3c,function(v){
return _3d==v;
})){
Px.Ex.Application.reloadScreen();
}
},showScreen:function(_3e,_3f,_40){
var app=Px.Ex.Application;
var _41=(app.currentScreenId==undefined);
app.screenShown=false;
if(app.currentScreen&&app.currentScreen.beforeClose&&!_40){
if(_3e==app.Ids.PAGE_LOGIN){
app.menu.bindLogout();
}
app.currentScreen.beforeClose.call(app.currentScreen,dojo.hitch(app,"showScreen",_3e,_3f,true));
return;
}
if(_3e==app.Ids.PAGE_LOGIN){
delete app.currentScreenId;
app._finalizeCurrentScreen();
app.logout();
return;
}
_3e=app.normalizeScreenId(_3e);
if(_41){
dojo.io.iframe.send({url:"/login/get-google-analytics-tag",content:{initialScreenId:_3e},preventCache:true});
}
app.showMenu(_3e,function(){
$("#divContentLoading").fadeOut("slow");
});
if(!_3f){
var _42={handle:dojo.hitch(app,"showScreen",_3e,true,false),changeUrl:_3e};
dojo.back.addToHistory(_42);
}
app.showUserId();
var _43=false;
app._finalizeCurrentScreen();
switch(_3e){
case app.Ids.PAGE_DASHBOARD_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.DashboardScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_ACTIVITY_REPORT_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.TPubActivityReportScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_PAYMENTS_REPORT_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.TPubPaymentsReportScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_DATA_GROUPS_REPORT_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.TPubDataGroupsReportScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_DEAL_PERFORMANCE_REPORT_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.DealPerformanceReportScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_BUY_PERFORMANCE_REPORT_ID:
this.forceBuyerExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.BuyPerformanceReportScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_BUY_REPORT_ID:
this.forceBuyerExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.BuyReportScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_TOOLS_ID:
this.forcePublisherOrBuyerExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.ContactDetailsScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_SETTINGS_ID:
this.forcePublisherOrBuyerExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.SettingsScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_MANAGE_TPUBS_ID:
_43=app._showScreen(Px.Ex.ManageTpubsScreen);
break;
case app.Ids.PAGE_MANAGE_BUYERS_ID:
_43=app._showScreen(Px.Ex.ManageBuyersScreen);
break;
case app.Ids.PAGE_CONTRACTS_ID:
_43=app._showScreen(Px.Ex.ContractsScreen,{tpubId:Px.Ex.Application._tpubId,tpubName:Px.Ex.Application._tpubName});
app._deleteTpubIdTpubName();
break;
case app.Ids.PAGE_TPUB_USERS_ID:
_43=app._showScreen(Px.Ex.TPubUsersScreen,{tpubId:Px.Ex.Application._tpubId,tpubName:Px.Ex.Application._tpubName});
app._deleteTpubIdTpubName();
break;
case app.Ids.PAGE_BUYERS_USERS_ID:
_43=app._showScreen(Px.Ex.BuyersUsersScreen,{buyerId:Px.Ex.Application._currentBuyerCode});
break;
case app.Ids.PAGE_EXELATE_USERS_ID:
_43=app._showScreen(Px.Ex.ExelateUsersScreen);
break;
case app.Ids.PAGE_NETWORKS_MONITOR_ID:
this.forcePublisherOrBuyerExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.BuyersMonitorScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_INSIGHT_FOR_TPUBS_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.InsightForTpubsScreen,app.__insightInitArgs);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_DEMOGRAPHICS_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.DemographicsScreen,app.__insightInitArgs);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_TARGETING_SEGMENTS_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.TargetingSegmentsScreen,app.__insightInitArgs);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_DDDEALS_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.DirectDataDealsScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_DEAL_SETTINGS_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.DealSettingsScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_DATA_TAGS_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.DataTagsScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_BUYER_DASHBOARD_ID:
this.forceBuyerExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.BuyerDashboardScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_RATE_CARD_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.RateCardScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_BILLING_NETADJ_ID:
_43=app._showScreen(Px.Ex.BillingNetAdjScreen);
break;
case app.Ids.PAGE_BUYER_REQUEST_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.BuyerRequestScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_SEGMENTS_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.SegmentsScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_DIRECT_BUYERS_REPORT_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.DirectBuysReportScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_CATEGORY_PERMISSIONS_ID:
this.forcePublisherExistence(dojo.hitch(this,function(){
_43=Px.Ex.Application._showScreen(Px.Ex.BuyerCategoryPermissionsScreen);
this.endShowScreen(_43,_3e);
}));
break;
case app.Ids.PAGE_CONFIG_META_VIEWER_ID:
_43=Px.Ex.Application._showScreen(Px.Ex.ConfigMetaViewerScreen);
this.endShowScreen(_43,_3e);
break;
case app.Ids.PAGE_SEGMENT_DELIVERY_ID:
_43=Px.Ex.Application._showScreen(Px.Ex.SegmentDeliveryDashboardScreen);
this.endShowScreen(_43,_3e);
break;
case app.Ids.PAGE_TEST_BED_ID:
_43=Px.Ex.Application._showScreen(Px.Ex.TestBedScreen);
this.endShowScreen(_43,_3e);
break;
default:
alert("Unknown screenId: '"+_3e+"'!");
break;
}
this.endShowScreen(_43,_3e);
},endShowScreen:function(_44,_45){
var app=Px.Ex.Application;
if(_44){
app.menu.redrawMenu.call(app.menu,_45);
app.footer.update();
app.currentScreenId=_45;
}
app.screenShown=_44;
},screen:undefined,getCurrentScreenIdTitle:function(){
var app=Px.Ex.Application;
if(app.screen=="login"||app.screen=="reset"){
return {id:app.Ids.PAGE_LOGIN,title:app.Titles.LOGIN};
}else{
return app.menu?app.menu.getCurrentScreenIdTitle():{id:app.Ids.TEXI_COMMON,title:app.Titles.COMMON};
}
},getScreenIdTitle:function(_46){
var app=Px.Ex.Application;
return app.menu?app.menu.getScreenIdTitle(_46):{id:app.Ids.TEXI_COMMON,title:app.Titles.COMMON};
},showUserId:function(){
var app=Px.Ex.Application;
if(!app.menu||app.menu.logoutMenuLoaded){
return;
}
app.xhr({url:"/user/userid",load:function(_47){
app.__userId=_47.userid;
app.menu.addUserIdToLogout(_47.userid);
},handleAs:"json"});
},showMenu:function(_48,_49){
Px.Ex.Application.menu.draw(_48,_49);
return true;
},_deleteTpubIdTpubName:function(){
delete Px.Ex.Application._tpubId;
delete Px.Ex.Application._tpubName;
},_showScreen:function(o,arg){
var a=Px.Ex.Application;
if(!a.contactRoleLoaded){
return false;
}
if(!a.permissionsLoaded){
return false;
}
var s=(arg===undefined?new o():new o(arg));
s.draw();
a.currentScreen=s;
return true;
},unpdateInsightInitArgs:function(_4a,_4b,_4c){
Px.Ex.Application.__insightInitArgs={date:_4a,daysBack:_4b,htmlOfSelectDate:_4c};
},enterPressed:function(_4d){
return function(e){
if(e.which==13){
e.stopPropagation();
_4d();
return false;
}
return true;
};
},enterKeyDown:function(_4e){
return function(e){
if(e.keyCode==13){
e.stopPropagation();
_4e();
return false;
}
return true;
};
},clearContent:function(){
dojo.empty("divContent");
},closeTooltip:function(){
if(dijit._masterTT){
dijit._masterTT._onDeck=null;
if(dijit._masterTT.aroundNode){
dijit.hideTooltip(dijit._masterTT.aroundNode);
}
}
},showMsgDialog:function(msg,_4f,_50){
var _51,div,c=dojo.create;
_51=c("div",{});
div=c("div",{innerHTML:msg,className:_4f||"error-message"},_51);
div=c("div",{className:"button-layout"},_51);
div=c("div",{className:"button-ok"},div);
dlg=new Px.Ex.Dialog({"class":_50||"error-dialog",content:_51});
dlg.connect(div,"onclick",dojo.hitch(dlg,"onCancel"));
dlg.show();
return dlg;
}};
dojo.declare("Px.Ex.EmptyMessageMixin",null,{emptyMessage:"$_unset_$",getErrorMessage:function(_52){
var v=this.attr("value");
if(this instanceof Px.Ex.FilteringSelect){
v=this.attr("displayedValue");
}
if(this.emptyMessage!="$_unset_$"&&(v===null||v==""||typeof v=="number"&&isNaN(v))){
return this.emptyMessage;
}
return this.inherited(arguments);
}});
dojo.declare("Px.Ex.ValidationTextBox",[dijit.form.ValidationTextBox,Px.Ex.EmptyMessageMixin],{});
dojo.declare("Px.Ex.ValidationTextarea",[dijit.form.ValidationTextBox,dijit.form.SimpleTextarea,Px.Ex.EmptyMessageMixin],{firstTime:true,inOnChange:false,postCreate:function(){
this.inherited(arguments);
},isValid:function(){
var val=this.getDisplayedValue();
if(this.inOnChange){
return (val!=""?true:false);
}else{
this.inherited();
}
},validate:function(){
this.inherited(arguments);
if(arguments.length==0){
this.validate(false);
}
},onChange:function(){
this.inOnChange=true;
this.validate(true);
this.inOnChange=false;
},onFocus:function(){
if(this.firstTime){
this.firstTime=false;
}else{
if(!this.isValid()){
this.displayMessage(this.getErrorMessage());
}
}
},isValid2:function(){
var val=this.getDisplayedValue();
return (val!=""?true:false);
},onBlur:function(){
this.validate(false);
}});
dojo.declare("Px.Ex.FilteringSelect",[dijit.form.FilteringSelect,Px.Ex.EmptyMessageMixin],{valueType:"string",_getDisplayedValueAttr:function(){
return this.textbox.value;
},_getValueAttr:function(){
return this.valueType=="number"?this.valueNode.value-0:this.valueNode.value;
}});
dojo.declare("Px.Ex.DateTextBoxWithIcon",[dijit.form.DateTextBox,Px.Ex.EmptyMessageMixin],{templateString:"<div class=\"dijit dijitReset dijitInlineTable dijitLeft\"\r\n\tid=\"widget_${id}\"\r\n\tdojoAttachEvent=\"onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse\" waiRole=\"presentation\"\r\n\t><div style=\"overflow:hidden;\"\r\n\t\t><div class=\"dijitReset dijitCalendarIcon\" dojoAttachEvent=\"onclick:_onCalendar\"><br></div\r\n\t\t><div class=\"dijitReset dijitValidationIcon\"><br></div\r\n\t\t><div class=\"dijitReset dijitValidationIconText\">&Chi;</div\r\n\t\t><div class=\"dijitReset dijitInputField\"\r\n\t\t\t><input class=\"dijitReset\" dojoAttachPoint='textbox,focusNode' autocomplete=\"off\"\r\n\t\t\t${nameAttrSetting} type='${type}'\r\n\t\t/></div\r\n\t></div\r\n></div>\r\n",_onCalendar:function(e){
this._open();
},_open:function(){
if(this.disabled||this.readOnly||!this.popupClass){
return;
}
this.inherited(arguments);
dojo.style(this._picker.domNode.parentNode,"position","absolute");
}});
dojo.declare("Px.Ex.CustomizedDateTextBox",[Px.Ex.DateTextBoxWithIcon,Px.Ex.EmptyMessageMixin],{getEmptyDate:function(){
return new Date();
},_open:function(){
if(this.disabled||this.readOnly||!this.popupClass){
return;
}
var _53=this;
if(!this._picker){
var _54=dojo.getObject(this.popupClass,false);
this._picker=new _54({onValueSelected:function(_55){
if(_53._tabbingAway){
delete _53._tabbingAway;
}else{
_53.focus();
}
setTimeout(dojo.hitch(_53,"_close"),1);
dijit.form._DateTimeTextBox.superclass._setValueAttr.call(_53,_55,true);
},lang:_53.lang,constraints:_53.constraints,isDisabledDate:function(_56){
var _57=dojo.date.compare;
var _58=_53.constraints;
return _58&&(_58.min&&(_57(_58.min,_56,"date")>0)||(_58.max&&_57(_58.max,_56,"date")<0));
}});
this._picker.attr("value",this.attr("value")||this.getEmptyDate());
}
if(!this._opened){
dijit.popup.open({parent:this,popup:this._picker,around:this.domNode,onCancel:dojo.hitch(this,this._close),onClose:function(){
_53._opened=false;
}});
this._opened=true;
}
dojo.marginBox(this._picker.domNode,{w:this.domNode.offsetWidth});
dojo.style(this._picker.domNode.parentNode,"position","absolute");
}});
dojo.declare("Px.Ex.NumberTextBox",[dijit.form.NumberTextBox,Px.Ex.EmptyMessageMixin],{templateString:"<div class=\"dijit dijitReset dijitInlineTable dijitLeft dijitNumberTextBox\"\r\n\tid=\"widget_${id}\"\r\n\tdojoAttachEvent=\"onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse\" waiRole=\"presentation\"\r\n\t><div style=\"overflow:hidden;\"\r\n\t\t><div class=\"dijitReset dijitValidationIcon\"><br></div\r\n\t\t><div class=\"dijitReset dijitValidationIconText\">&Chi;</div\r\n\t\t><div class=\"dijitReset dijitInputField\"\r\n\t\t\t><input class=\"dijitReset\" style=\"text-align:right;\" dojoAttachPoint='textbox,focusNode' autocomplete=\"off\"\r\n\t\t\t${nameAttrSetting} type='${type}'\r\n\t\t/></div\r\n\t></div\r\n></div>\r\n",tooltipPosition:["before","after"],format:function(_59,_5a){
if(typeof _59!="number"){
return String(_59);
}
if(isNaN(_59)){
return "";
}
if(("rangeCheck" in this)&&!this.rangeCheck(_59,_5a)){
return String(_59);
}
if(this.editOptions&&this._focused){
_5a=dojo.mixin(dojo.mixin({},_5a),this.editOptions);
}
return this._formatter(_59,_5a);
}});
dojo.declare("Px.Ex.SearchTextBox",[dijit.form.MappedTextBox],{templateString:"<div class=\"dijit dijitReset dijitInlineTable dijitLeft\"\r\n\tid=\"widget_${id}\"\r\n\tdojoAttachEvent=\"onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse\" waiRole=\"presentation\"\r\n\t><div style=\"overflow:hidden;\"\r\n\t\t><div class=\"dijitReset dijitSearchIcon unselectable\" dojoAttachEvent=\"onclick:_onSearch\"><br></div\r\n\t\t><div class=\"dijitReset dijitValidationIcon\"><br></div\r\n\t\t><div class=\"dijitReset dijitValidationIconText\">&Chi;</div\r\n\t\t><div class=\"dijitReset dijitInputField\"\r\n\t\t\t><input class=\"dijitReset\" dojoAttachPoint='textbox,focusNode' autocomplete=\"off\"\r\n\t\t\t${nameAttrSetting} type='${type}'\r\n\t\t/></div\r\n\t></div\r\n></div>\r\n",emptyText:"Search",_onSearch:function(e){
},buildRendering:function(){
this.inherited(arguments);
this.clearValue();
},clearValue:function(){
this.attr("value","");
this._onBlurEmptyText();
},_onBlurEmptyText:function(){
if(this.valueNode.value==""){
this.textbox.value=this.emptyText;
dojo.addClass(this.textbox,"empty-text");
this._grayMode=true;
}
},_onBlur:function(e){
if(this.disabled){
return;
}
this._setBlurValue();
this.inherited(arguments);
this._onBlurEmptyText();
},_onFocusEmptyText:function(){
if(this.valueNode.value==""){
this.textbox.value="";
dojo.removeClass(this.textbox,"empty-text");
delete this._grayMode;
}
},_onFocus:function(e){
if(this.disabled){
return;
}
this._onFocusEmptyText();
this._refreshState();
this.inherited(arguments);
},_getValueAttr:function(){
if(this._grayMode){
return "";
}
return this.inherited(arguments);
},reset:function(){
}});
dojo.declare("Px.Ex.ProgressBar",[dijit._Widget,dijit._Templated],{templateString:"<table style=\"border-collapse:collapse;\"><tbody><tr><td><div class=\"progress fill\" dojoAttachPoint=\"progressBarFill\"></div></td><td><div class=\"progress\" dojoAttachPoint=\"progressBarEmpty\"></div></td></tr></tbody></table>",progress:0,maximum:100,width:100,constructor:function(){
},postCreate:function(){
this.inherited(arguments);
dojo.style(this.domNode,"width",this.width+"px");
this.showProgress(this.progress);
},showProgress:function(p){
if(p<0){
p=0;
}
if(p>this.maximum){
p=this.maximum;
}
var _5b=Math.round(this.width/this.maximum*p);
var _5c=this.width-_5b;
if(_5c<0){
_5c=0;
}
dojo.style(this.progressBarFill,"width",_5b+"px");
dojo.style(this.progressBarEmpty,"width",_5c+"px");
}});
dojo.declare("Px.Ex.TitlePane",[dijit.TitlePane],{postCreate:function(){
this.inherited(arguments);
this._resetValue=this.open;
},toggle:function(){
if(this.readOnly){
return;
}
this.inherited(arguments);
},reset:function(){
if(this.open!=this._resetValue){
this.toggle();
}
},expand:function(){
this.attr("open",true);
},collapse:function(){
this.attr("open",false);
},_getValueAttr:function(_5d){
return this.open;
}});
dojo.declare("Px.Ex.Standby",[dojox.widget.Standby],{underlayOpacity:0.75,_fadeIn:function(){
var _5e=dojo.animateProperty({node:this._underlayNode,properties:{opacity:{start:0,end:this.underlayOpacity}}});
var _5f=dojo.animateProperty({node:this._imageNode,properties:{opacity:{start:0,end:1}}});
var _60=dojo.fx.combine([_5e,_5f]);
_60.play();
},_fadeOut:function(){
var _61=this;
var _62=dojo.animateProperty({node:this._underlayNode,properties:{opacity:{start:this.underlayOpacity,end:0}},onEnd:function(){
dojo.style(_61._underlayNode,"display","none");
}});
var _63=dojo.animateProperty({node:this._imageNode,properties:{opacity:{start:1,end:0}},onEnd:function(){
dojo.style(_61._imageNode,"display","none");
}});
var _64=dojo.fx.combine([_62,_63]);
_64.play();
}});
dojo.declare("Px.Ex.Form",[dijit.form.Form],{withReadOnly:false,onSubmit:function(){
return false;
},_getValueAttr:function(){
var obj={};
dojo.forEach(this.getDescendants(),function(_65){
var _66=_65.name;
if(!_66||_65.disabled||(!this.withReadOnly&&_65.readOnly)){
return;
}
var _67=_65.attr("value");
if(typeof _65.checked=="boolean"){
if(/Radio/.test(_65.declaredClass)){
if(_67!==false){
dojo.setObject(_66,_67,obj);
}else{
_67=dojo.getObject(_66,false,obj);
if(_67===undefined){
dojo.setObject(_66,null,obj);
}
}
}else{
var ary=dojo.getObject(_66,false,obj);
if(!ary){
ary=[];
dojo.setObject(_66,ary,obj);
}
if(_67!==false){
ary.push(_67);
}
}
}else{
dojo.setObject(_66,_67,obj);
}
},this);
this._removeArrays(obj);
return obj;
},_removeArrays:function(o){
var o2={};
for(var p in o){
if(dojo.isArray(o[p])){
if(o[p].length==1){
o[p]=o[p][0];
}else{
if(o[p].length==0){
o[p]="";
}
}
}
}
},isDirty:function(_68){
if(!_68){
_68=this;
}
return dojo.some([_68].concat(_68.getDescendants()),function(_69){
if(_69._resetValue!==undefined&&!_69._notIncludeInDirty){
if(typeof _69.checked=="boolean"){
return _69.params.checked!=_69.attr("checked");
}
var _6a=_69._resetValue;
val=_69.attr("value");
if(_6a&&_6a.getTime&&val&&val.getTime){
return _6a.getTime()!=val.getTime();
}else{
if((typeof _6a=="number")&&isNaN(_6a)&&(typeof val=="number")&&isNaN(val)){
return false;
}
}
return _6a!=val;
}
return false;
});
},updateWidgetsForReset:function(_6b){
if(!_6b){
_6b=this;
}
dojo.forEach([_6b].concat(_6b.getDescendants()),function(_6c){
if(_6c._resetValue!==undefined){
_6c._resetValue=_6c.attr("value");
if(typeof _6c.checked=="boolean"){
_6c.params.checked=_6c.attr("checked");
}
}
});
}});
dojo.declare("Px.Ex.ReportDateFilter",undefined,{START_DATE:1,END_DATE:2,constructor:function(_6d){
this.NOW=_6d.NOW;
this.messages=_6d.messages;
},createDateFilter:function(_6e,div){
var bk=false;
while(bk==false){
switch(_6e){
case this.START_DATE:
try{
this.startDate=new Px.Ex.DateTextBoxWithIcon({value:this.NOW,"class":"filter-start-date",name:"start",id:"filterStartDateId"});
bk=true;
}
catch(e){
bk=false;
}
break;
case this.END_DATE:
try{
this.endDate=new Px.Ex.DateTextBoxWithIcon({value:this.NOW,"class":"filter-end-date",name:"end",id:"filterEndDateId"});
bk=true;
}
catch(e){
bk=false;
}
break;
}
}
switch(_6e){
case this.START_DATE:
try{
this.startDate.startup();
}
catch(e){
}
this.startDate.placeAt(div);
break;
case this.END_DATE:
try{
this.endDate.startup();
}
catch(e){
}
this.endDate.placeAt(div);
break;
}
},create:function(_6f){
var _70,_71,tr,td,div,c=dojo.create;
var m=this.messages;
this.layout=_70=c("table",{},_6f);
_71=c("tbody",{},_70);
tr=c("tr",{},_71);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"filterDateRangeId",innerHTML:m.labelDateRange||"Date Range:"},td);
td=c("td",{className:"vmiddle"},tr);
var _72=new dojo.data.ItemFileReadStore({data:{identifier:"id",label:"name",items:[{id:"mtd",name:m.listRangeMtd||"Month to Date"},{id:"mty",name:m.listRangeMty||"Month till Yesterday"},{id:"lastMonth",name:m.listRangeMonth||"Last Month"},{id:"today",name:m.listRangeToday||"Today"},{id:"yesterday",name:m.listRangeYesterday||"Yesterday"},{id:"last7",name:m.listRange7||"Last 7 Days"},{id:"last30",name:m.listRange30||"Last 30 Days"},{id:"year",name:m.listRangeYear||"This Year"},{id:"custom",name:m.listRangeCustom||"Custom..."}]}});
this.dateRange=new Px.Ex.FilteringSelect({store:_72,id:"filterDateRangeId",searchAttr:"name",onChange:dojo.hitch(this,"dateRangeChanged"),required:true,value:"mtd","class":"filter-date-range"});
this.dateRange.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"filterStartDateId",innerHTML:m.labelDateStart||"Start Date"},td);
td=c("td",{className:"vmiddle"},tr);
this.createDateFilter(this.START_DATE,td);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"filterEndDateId",innerHTML:m.labelDateEnd||"End Date"},td);
td=c("td",{className:"vmiddle"},tr);
this.createDateFilter(this.END_DATE,td);
td=c("td",{style:{width:"100%"},className:"vmiddle time-group-by"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m.labelDateGroupBy||"Group by:"},td);
td=c("td",{className:"vmiddle"},tr);
this.groupByYear=new dijit.form.RadioButton({checked:false,value:"Year",name:"timeGroupBy"});
this.groupByYear.placeAt(td);
td=c("td",{className:"vmiddle radio"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":this.groupByYear.id,innerHTML:m.labelYear||"Year"},td);
td=c("td",{className:"vmiddle"},tr);
this.groupByMonth=new dijit.form.RadioButton({checked:true,value:"Month",name:"timeGroupBy"});
this.groupByMonth.placeAt(td);
td=c("td",{className:"vmiddle radio"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":this.groupByMonth.id,innerHTML:m.labelMonth||"Month"},td);
td=c("td",{className:"vmiddle"},tr);
this.groupByDate=new dijit.form.RadioButton({checked:false,value:"Date",name:"timeGroupBy"});
this.groupByDate.placeAt(td);
td=c("td",{className:"vmiddle radio"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":this.groupByDate.id,innerHTML:m.labelDate||"Date"},td);
td=c("td",{className:"vmiddle"},tr);
this.groupByNone=new dijit.form.RadioButton({checked:false,value:"none",name:"timeGroupBy"});
this.groupByNone.placeAt(td);
td=c("td",{className:"vmiddle radio"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":this.groupByNone.id,innerHTML:m.labelNone||"None"},td);
},dateRangeChanged:function(v){
var _73=true;
var _74,end;
if(v=="custom"){
_73=false;
}else{
if(v=="mtd"){
_74=new Date(Number(this.NOW));
_74.setDate(1);
end=this.NOW;
}else{
if(v=="mty"){
end=dojo.date.add(this.NOW,"day",-1);
_74=new Date(Number(end));
_74.setDate(1);
}else{
if(v=="lastMonth"){
_74=dojo.date.add(this.NOW,"day",-1);
_74=dojo.date.add(_74,"month",-1);
_74.setDate(1);
end=dojo.date.add(_74,"month",1);
end=dojo.date.add(end,"day",-1);
}else{
if(v=="today"){
_74=end=this.NOW;
}else{
if(v=="yesterday"){
_74=end=dojo.date.add(this.NOW,"day",-1);
}else{
if(v=="last7"){
_74=dojo.date.add(this.NOW,"day",-7);
end=this.NOW;
}else{
if(v=="last30"){
_74=dojo.date.add(this.NOW,"day",-30);
end=this.NOW;
}else{
if(v=="year"){
_74=new Date(Number(this.NOW));
_74.setMonth(0,1);
end=this.NOW;
}
}
}
}
}
}
}
}
}
if(_74){
this.startDate.attr("value",_74);
}
if(end){
this.endDate.attr("value",end);
}
this.startDate.attr("readOnly",_73);
this.endDate.attr("readOnly",_73);
dojo.toggleClass(this.startDate.focusNode,"readonly",_73);
dojo.toggleClass(this.endDate.focusNode,"readonly",_73);
dojo.query("label[for=\""+this.startDate.id+"\"]",this.layout).toggleClass("readonly",_73);
dojo.query("label[for=\""+this.endDate.id+"\"]",this.layout).toggleClass("readonly",_73);
},update:function(){
this.dateRangeChanged(this.dateRange.attr("value"));
}});
dojo.declare("Px.Ex.FilterDialogMixin",undefined,{ops:undefined,filteredOps:undefined,ch:undefined,postMixInProperties:function(){
var _75=dojo.i18n.getLocalization("dijit","common");
dojo.mixin(this,_75);
this.inherited(arguments);
},createContent:function(){
this.ch=this._makeSelectControl();
this.ch.startup();
this.searchCtrl=this._makeSearchControl();
this.connect(this.searchCtrl,"onChange","onSearch");
var div,c=dojo.create;
div=c("div",{},this.containerNode);
this._addSearchControl(div);
this._addCloseButton(div);
div=c("div",{},this.containerNode);
this._addSelectControl(div);
div=c("div",{className:"button-container"},this.containerNode);
this._addButtons(div);
},_makeSelectControl:function(){
var ch=new dojox.form.CheckedMultiSelect({multiple:"true",options:this.filteredOps,onChange:dojo.hitch(this,"onChange")});
return ch;
},_makeSearchControl:function(){
var _76=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true});
return _76;
},_addSearchControl:function(_77){
this.searchCtrl.placeAt(_77);
},_addSelectControl:function(_78){
this.ch.placeAt(_78);
},_addCloseButton:function(_79){
var _7a,c=dojo.create;
this.closeButtonNode=c("span",{className:"dijitDialogCloseIcon",title:this.buttonCancel},_79);
this.connect(this.closeButtonNode,"onmouseenter","_onCloseEnter");
this.connect(this.closeButtonNode,"onmouseleave","_onCloseLeave");
this.connect(this.closeButtonNode,"onclick","onCancel");
},_onCloseEnter:function(){
dojo.addClass(this.closeButtonNode,"dijitDialogCloseIcon-hover");
},_onCloseLeave:function(){
dojo.removeClass(this.closeButtonNode,"dijitDialogCloseIcon-hover");
},onCancel:function(){
this._onCloseLeave();
this.inherited(arguments);
},_addButtons:function(_7b){
var div,_7c,c=dojo.create;
_7c=c("span",{className:"button-layout"},_7b);
div=c("div",{className:"dijitInline btn-clear"},_7c);
this.connect(div,"onclick","clear");
div=c("div",{className:"dijitInline btn-select-all"},_7c);
this.connect(div,"onclick","selectAll");
},clear:function(){
this.ch.attr("value",[]);
},selectAll:function(){
this.ch.attr("value",this.ch.getOptions());
},getSelected:function(){
return dojo.map(dojo.filter(this.filteredOps,"return item.selected;"),"return item.o;");
},clearFilter:function(){
this.clear();
dojo.forEach(this.filteredOps,"delete item.selected;");
},onSearch:function(val){
this.searching=true;
if(val==""){
var ops=this.filteredOps;
}else{
val=val.toLowerCase();
var ops=dojo.filter(this.filteredOps,function(v){
return v.label.toLowerCase().indexOf(val)>=0;
});
}
this.setOptions(ops);
delete this.searching;
},setOptions:function(ops){
this.ch.options=ops;
this.ch._loadChildren.call(this.ch);
}});
dojo.declare("Px.Ex.SingleSelectDialogMixin",undefined,{ops:undefined,filteredOps:undefined,ch:undefined,postMixInProperties:function(){
var _7d=dojo.i18n.getLocalization("dijit","common");
dojo.mixin(this,_7d);
this.inherited(arguments);
},createContent:function(){
this.ch=this._makeSelectControl();
this.ch.startup();
this.searchCtrl=this._makeSearchControl();
this.connect(this.searchCtrl,"onChange","onSearch");
var div,c=dojo.create;
div=c("div",{},this.containerNode);
this._addSearchControl(div);
this._addCloseButton(div);
div=c("div",{},this.containerNode);
this._addSelectControl(div);
},_makeSelectControl:function(){
var ch=new dojox.form.CheckedMultiSelect({multiple:"false",options:this.filteredOps,onChange:dojo.hitch(this,"onChange")});
return ch;
},_makeSearchControl:function(){
var _7e=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true});
return _7e;
},_addSearchControl:function(_7f){
this.searchCtrl.placeAt(_7f);
},_addSelectControl:function(_80){
this.ch.placeAt(_80);
},_addCloseButton:function(_81){
var _82,c=dojo.create;
this.closeButtonNode=c("span",{className:"dijitDialogCloseIcon",title:this.buttonCancel},_81);
this.connect(this.closeButtonNode,"onmouseenter","_onCloseEnter");
this.connect(this.closeButtonNode,"onmouseleave","_onCloseLeave");
this.connect(this.closeButtonNode,"onclick","onCancel");
},_onCloseEnter:function(){
dojo.addClass(this.closeButtonNode,"dijitDialogCloseIcon-hover");
},_onCloseLeave:function(){
dojo.removeClass(this.closeButtonNode,"dijitDialogCloseIcon-hover");
},onCancel:function(){
this._onCloseLeave();
this.inherited(arguments);
},getSelected:function(){
return dojo.map(dojo.filter(this.filteredOps,"return item.selected;"),"return item.o;");
},clearFilter:function(){
this.clear();
dojo.forEach(this.filteredOps,"delete item.selected;");
},onSearch:function(val){
this.searching=true;
if(val==""){
var ops=this.filteredOps;
}else{
val=val.toLowerCase();
var ops=dojo.filter(this.filteredOps,function(v){
return v.label.toLowerCase().indexOf(val)>=0;
});
}
this.setOptions(ops);
delete this.searching;
},setOptions:function(ops){
this.ch.options=ops;
this.ch._loadChildren.call(this.ch);
}});
closeDialog=function(){
if(Px.Ex.Dialog.prototype._dlgs){
dojo.forEach(Px.Ex.Dialog.prototype._dlgs,function(v){
try{
v.cancelXhr();
v.destroyRecursive();
}
catch(e){
}
});
delete Px.Ex.Dialog.prototype._dlgs;
}
};
dojo.declare("Px.Ex.Dialog",[dijit.Dialog,Px.Ex.XhrMixin],{templateString:null,templateString:"<div class=\"dijitDialog\" tabindex=\"-1\" waiRole=\"dialog\" waiState=\"labelledby-${id}_title\">"+"<span dojoAttachPoint=\"closeLabelNode\" class=\"dijitDialogCloseLabel\" dojoAttachEvent=\"onclick: onCancel, onmouseenter: _onCloseLabelEnter, onmouseleave: _onCloseLabelLeave\">${buttonClose}</span>"+"<span dojoAttachPoint=\"closeButtonNode\" class=\"dijitDialogCloseIcon\" dojoAttachEvent=\"onclick: onCancel, onmouseenter: _onCloseEnter, onmouseleave: _onCloseLeave\" title=\"${buttonClose}\">"+"<span dojoAttachPoint=\"closeText\" class=\"closeText\" title=\"${buttonCancel}\">x</span>"+"</span>"+"<div dojoAttachPoint=\"titleBar\" class=\"dialogTitleBar\"></div>"+"<div dojoAttachPoint=\"containerNode\" class=\"dijitDialogPaneContent\"></div>"+"</div>",duration:1000,standby:undefined,rotationImage:undefined,underlayOpacity:0.75,closeMessageBoxConfig:undefined,buttonClose:"Close",modal:true,constructor:function(){
this.loadingMessage=Px.Ex.Application.getWaitHtml();
},startup:function(){
this.inherited(arguments);
var _1={target:this.containerNode,color:"#fff",underlayOpacity:this.underlayOpacity};
if(this.rotationImage){
_1.image=this.rotationImage;
}
this.standby=new Px.Ex.Standby(_1,dojo.create("div",{},this.containerNode));
this.standby.startup();
dojo.style(this.containerNode,"border","none");
dojo.style(this.domNode,"overflow","visible");
var _2={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _3=new curvyCorners(_2,this.domNode);
_3.applyCornersToAll();
},showRotation:function(_4){
if(!this.standby){
return;
}
if(_4){
this.standby.show();
}else{
this.standby.hide();
}
},showError:function(_5){
var c=this.attr("content");
if(c&&c.destroy){
c.destroy();
}
var _6=dojo.create("div",{innerHTML:_5.responseText||_5.message||_5,style:{color:"red",background:"#e1e1e1",maxHeight:"300px",overflow:"auto"}});
this.attr("content",_6);
},_size:function(){
},_setup:function(){
var _7=this.domNode;
if(this.titleBar&&this.draggable){
this._moveable=(dojo.isIE==6)?new dojo.dnd.TimedMoveable(_7,{handle:this.titleBar}):new dojo.dnd.Moveable(_7,{handle:this.titleBar,timeout:0});
dojo.subscribe("/dnd/move/stop",this,"_endDrag");
}else{
dojo.addClass(_7,"dijitDialogFixed");
}
var _8={dialogId:this.id,"class":dojo.map(this["class"].split(/\s/),function(s){
return s+"_underlay";
}).join(" ")};
var _9=dijit._underlay;
if(!_9){
_9=dijit._underlay=new dijit.DialogUnderlay(_8);
}
var _a=this.modal;
this._fadeIn=dojo.fadeIn({node:_7,duration:this.duration,beforeBegin:function(){
_9.attr(_8);
if(_a){
_9.show();
}
},onEnd:dojo.hitch(this,function(){
if(this.autofocus){
this._getFocusItems(this.domNode);
dijit.focus(this._firstFocusItem);
}
})});
this._fadeOut=dojo.fadeOut({node:_7,duration:this.duration,onEnd:dojo.hitch(this,function(){
_7.style.visibility="hidden";
_7.style.top="-9999px";
dijit._underlay.hide();
dojo.forEach(this._connects,function(_b){
dojo.forEach(_b,dojo.disconnect);
});
dijit.focus(this._savedFocus);
this.beforeDestroy();
this.destroyRecursive();
this.afterDestroy();
})});
},firstFocus:function(){
this._getFocusItems(this.domNode);
var fn=dojo.hitch(this,function(_c){
dijit.focus(this._firstFocusItem);
if(dojo.isIE&&document.activeElement!=this._firstFocusItem){
this.stopClosing(true);
setTimeout(_c,100);
}else{
this.stopClosing(false);
}
});
fn(fn);
},componentFocus:function(c){
var fn=dojo.hitch(this,function(_d){
dijit.focus(c.focusNode);
if(dojo.isIE&&document.activeElement!=c.focusNode){
this.stopClosing(true);
setTimeout(_d,100);
}else{
this.stopClosing(false);
}
});
fn(fn);
},show:function(){
this.startup();
this.inherited(arguments);
if(!this.modal){
this._clearKeys();
}
this._modalconnects.push(dojo.connect(dojo.body(),"onkeypress",function(e){
if(e.charOrCode==dojo.keys.ESCAPE){
dojo.stopEvent(e);
}
}));
this._modalconnects.push(dojo.connect(dojo.doc.documentElement,"onkeyup",this,"_onKeyUp"));
if(!Px.Ex.Dialog.prototype._dlgs){
Px.Ex.Dialog.prototype._dlgs=[];
}
Px.Ex.Dialog.prototype._dlgs.unshift(this);
},updateWidgetsForReset:function(_e){
dojo.forEach([_e].concat(_e.getDescendants()),function(_f){
if(_f._resetValue!==undefined){
_f._resetValue=_f.attr("value");
if(typeof _f.checked=="boolean"){
_f.params.checked=_f.attr("checked");
}
}
});
},isDirty:function(_10){
if(!_10){
_10=this;
}
return dojo.some([_10].concat(_10.getDescendants()),function(_11){
if(_11._resetValue!==undefined&&!_11._notIncludeInDirty){
if(typeof _11.checked=="boolean"){
return _11.params.checked!=_11.attr("checked");
}
var _12=_11._resetValue;
val=_11.attr("value");
if(_12&&_12.getTime&&val&&val.getTime){
return _12.getTime()!=val.getTime();
}else{
if((typeof _12=="number")&&isNaN(_12)&&(typeof val=="number")&&isNaN(val)){
return false;
}
}
return _12!=val;
}
return false;
});
},resetWidgets:function(_13){
dojo.forEach([_13].concat(_13.getDescendants()),function(_14){
if(_14.reset){
_14.reset();
}
});
},validateWidgets:function(_15){
var _16=false;
return dojo.every(dojo.map([_15].concat(_15.getDescendants()),function(_17){
_17._hasBeenBlurred=true;
var _18=_17.disabled||!_17.validate||_17.validate();
if(!_18&&!_16){
dijit.scrollIntoView(_17.containerNode||_17.domNode);
_17.focus();
_16=true;
}
return _18;
}),function(_19){
return _19;
});
},isValidWidgets:function(_1a){
return dojo.every(dojo.map([_1a].concat(_1a.getDescendants()),function(_1b){
var _1c=_1b.disabled||!_1b.isValid||_1b.isValid();
return _1c;
}),function(_1d){
return _1d;
});
},isValidArray:function(arr,_1e){
return dojo.every(arr,function(_1f){
var _20=_1f.disabled||!_1f.isValid||_1f.isValid();
return _20;
});
},getValueObject:function(_21){
var obj={};
dojo.forEach([_21].concat(_21.getDescendants()),function(_22){
var _23=_22.name;
if(!_23||_22.disabled){
return;
}
var _24=_22.attr("value");
if((typeof _24=="number")&&isNaN(_24)){
_24=null;
}
if(typeof _22.checked=="boolean"){
if(/Radio/.test(_22.declaredClass)){
if(_24!==false){
dojo.setObject(_23,_24,obj);
}else{
_24=dojo.getObject(_23,false,obj);
if(_24===undefined){
dojo.setObject(_23,null,obj);
}
}
}else{
dojo.setObject(_23,_22.checked,obj);
}
}else{
dojo.setObject(_23,_24,obj);
}
});
return obj;
},_onKey:function(evt){
if(evt.type!="keypress"){
this.inherited(arguments);
}
},_onKeyUp:function(evt){
if(evt.keyCode==dojo.keys.ESCAPE){
var _25=evt.target;
while(_25){
if(_25==this.domNode){
this.onCancel();
dojo.stopEvent(evt);
return;
}
_25=_25.parentNode;
}
}
},_onCloseLabelEnter:function(){
dojo.addClass(this.closeLabelNode,"dijitDialogCloseLabel-hover");
},_onCloseLabelLeave:function(){
dojo.removeClass(this.closeLabelNode,"dijitDialogCloseLabel-hover");
},_getDirtyAttr:function(){
return false;
},_clearKeys:function(){
var n=-1,el=dojo.doc.documentElement;
dojo.some(this._modalconnects,function(v,i){
if(v[0]===el&&v[1]=="onkeypress"){
n=i;
return true;
}
return false;
});
if(n>=0){
dojo.disconnect(this._modalconnects[n]);
this._modalconnects.splice(n,1);
this._keypress_disconnected=true;
}
},_restoreKeys:function(){
if(this._keypress_disconnected){
delete this._keypress_disconnected;
this._modalconnects.push(dojo.connect(dojo.doc.documentElement,"onkeypress",this,"_onKey"));
}
},_hideHook:function(_26){
if(this.attr("dirty")){
var _27=dojo.hitch(this,"_restoreKeys");
this._clearKeys();
var _28={message:"The data has been changed. Close anyway?",okLabel:"Ok",cancelLabel:"Cancel",okCallback:_26,cancelCallback:_27};
dojo.mixin(_28,this.closeMessageBoxConfig);
var d=new Px.Ex.MessageDialog(_28);
d.show();
}else{
_26();
}
},hide:function(){
if(this._doNotHide){
return;
}
var _29=dojo.hitch(this,"inherited",arguments);
this._hideHook(dojo.hitch(this,function(){
_29();
}));
},layout:function(){
if(this.domNode.style.visibility!="hidden"){
if(this.modal){
dijit._underlay.layout();
}
this._position();
}
},stopClosing:function(_2a){
if(_2a){
this._doNotHide=true;
}else{
delete this._doNotHide;
}
},beforeDestroy:function(){
},afterDestroy:function(){
},destroyRecursive:function(){
if(Px.Ex.Dialog.prototype._dlgs){
var i=dojo.indexOf(Px.Ex.Dialog.prototype._dlgs,this);
if(i>=0){
Px.Ex.Dialog.prototype._dlgs.splice(i,1);
}
}
try{
this.inherited(arguments);
}
catch(e){
}
},destroy:function(){
if(this.standby){
try{
this.standby.destroyRecursive();
}
catch(e){
}
}
this.inherited(arguments);
if(dijit._masterTT){
dijit._masterTT._onDeck=null;
if(dijit._masterTT.aroundNode){
dijit.hideTooltip(dijit._masterTT.aroundNode);
}
}
}});
closeMessageDialog=function(){
if(Px.Ex.MessageDialog.prototype._dlgs){
dojo.forEach(Px.Ex.MessageDialog.prototype._dlgs,function(v){
try{
v.destroyRecursive();
}
catch(e){
}
});
delete Px.Ex.MessageDialog.prototype._dlgs;
}
};
dojo.declare("Px.Ex.MessageDialog",[dojox.widget.Dialog],{message:"Are Your Sure?",okLabel:"OK",cancelLabel:"Cancel",modal:true,duration:500,okCallback:undefined,cancelCallback:undefined,contentClass:"message-box",layoutClass:"message-box-layout",messageClass:"message-box-message",imageClass:"message-box-question",buttonsClass:"message-box-buttons",okButtonClass:"message-box-ok",cancelButtonClass:"message-box-cancel",buttonStyles:[],startup:function(){
this.inherited(arguments);
this.attr("content",this.createContent());
dojo.style(this.containerNode,"border","none");
dojo.style(this.domNode,"overflow","visible");
dojo.addClass(this.domNode,this.contentClass);
var _1={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _2=new curvyCorners(_1,this.domNode);
_2.applyCornersToAll();
},createContent:function(){
var _3,_4,tr,td,_5,c=dojo.create;
_3=c("table",{className:this.layoutClass});
_4=c("tbody",{},_3);
tr=c("tr",{},_4);
td=c("td",{},tr);
c("div",{className:this.imageClass},td);
td=c("td",{style:{verticalAlign:"top"}},tr);
c("div",{innerHTML:this.message,className:this.messageClass},td);
tr=c("tr",{},_4);
td=c("td",{colSpan:2,className:this.buttonsClass},tr);
var _6,_7,_8,_9,_a;
_6=c("table",{style:{margin:"0 auto"}},td);
_7=c("tbody",{},_6);
_8=c("tr",{},_7);
_9=c("td",{},_8);
_a=c("div",{className:this.cancelButtonClass,title:"ESC"},_9);
this.connect(_a,"onclick","onCancelBtn");
_9=c("td",{},_8);
_a=c("div",{className:this.okButtonClass,title:"ENTER"},_9);
this.connect(_a,"onclick","onOkBtn");
return _3;
},onOkBtn:function(){
this._okClicked=true;
this.hide();
},onCancelBtn:function(){
delete this._okClicked;
this.hide();
},_position:function(){
if(!dojo.hasClass(dojo.body(),"dojoMove")){
var _b=this.domNode;
var _c=dijit.getViewport();
var p=this._relativePosition;
var mb=p?null:dojo.marginBox(_b);
dojo.style(_b,{left:Math.floor(_c.l+(p?p.l:(_c.w-mb.w)/2))+"px",top:Math.floor(_c.t+(p?p.t:(_c.h-mb.h)/2))+"px"});
}
},show:function(){
if(Px.Ex.MessageDialog.prototype._dlgs&&Px.Ex.MessageDialog.prototype._dlgs.length){
closeMessageDialog();
}
if(this.open){
return;
}
this.startup();
if(!this._alreadyInitialized){
this._setup();
this._alreadyInitialized=true;
dojo.style(this.domNode,{zIndex:1100});
dojo.style(this.underlay.domNode,{zIndex:1099});
}
if(this._fadeOut.status()=="playing"){
this._fadeOut.stop();
}
this._modalconnects.push(dojo.connect(window,"onscroll",this,"layout"));
this._modalconnects.push(dojo.connect(window,"onresize",this,function(){
var _d=dijit.getViewport();
if(!this._oldViewport||_d.h!=this._oldViewport.h||_d.w!=this._oldViewport.w){
this.layout();
this._oldViewport=_d;
}
}));
this._modalconnects.push(dojo.connect(dojo.doc.documentElement,"onkeypress",this,"_onKey"));
dojo.style(this.domNode,{opacity:0,visibility:""});
if(this._fixSizes){
dojo.style(this.containerNode,{width:"auto",height:"auto"});
}
this.open=true;
this._onShow();
this._size();
this._position();
this._fadeIn.play();
this._savedFocus=dijit.getFocus(this);
if(this.modal){
}else{
this._modalconnects.push(dojo.connect(this.underlay.domNode,"onclick",this,"onCancel"));
}
this._modalconnects.push(dojo.connect(this.domNode,"onmouseenter",this,"_handleNav"));
this._modalconnects.push(dojo.connect(this.domNode,"onmouseleave",this,"_handleNav"));
this._modalconnects.push(dojo.connect(dojo.doc.documentElement,"onkeyup",this,"_onKeyUp"));
if(!Px.Ex.MessageDialog.prototype._dlgs){
Px.Ex.MessageDialog.prototype._dlgs=[];
}
Px.Ex.MessageDialog.prototype._dlgs.unshift(this);
},_onKeyUp:function(_e){
if(_e.keyCode==dojo.keys.ESCAPE){
var _f=_e.target;
while(_f){
if(_f==this.domNode){
this.onCancel();
dojo.stopEvent(_e);
return;
}
_f=_f.parentNode;
}
}else{
if(_e.keyCode==dojo.keys.ENTER){
var _f=_e.target;
while(_f){
if(_f==this.domNode){
this.onOkBtn();
dojo.stopEvent(_e);
return;
}
_f=_f.parentNode;
}
}
}
},uninitialize:function(){
var _10=false;
if(this._fadeIn&&this._fadeIn.status()=="playing"){
_10=true;
this._fadeIn.stop();
}
if(this._fadeOut&&this._fadeOut.status()=="playing"){
_10=true;
this._fadeOut.stop();
}
if(this.open||_10){
this.underlay.hide();
}
if(this._moveable){
this._moveable.destroy();
}
},layout:function(){
this._setSize();
if(this.domNode.style.visibility!="hidden"){
this.underlay.layout();
this._position();
}
},_setup:function(){
var _11=this.domNode;
if(this.titleBar&&this.draggable){
this._moveable=(dojo.isIE==6)?new dojo.dnd.TimedMoveable(_11,{handle:this.titleBar}):new dojo.dnd.Moveable(_11,{handle:this.titleBar,timeout:0});
dojo.subscribe("/dnd/move/stop",this,"_endDrag");
}else{
dojo.addClass(_11,"dijitDialogFixed");
}
var _12={dialogId:this.id,"class":dojo.map(this["class"].split(/\s/),function(s){
return s+"_underlay";
}).join(" ")};
this.underlay=new dijit.DialogUnderlay(_12);
this._fadeIn=dojo.fadeIn({node:_11,duration:this.duration,beforeBegin:dojo.hitch(this,function(){
this.underlay.attr(_12);
this.underlay.show();
}),onEnd:dojo.hitch(this,function(){
if(this.autofocus){
this._getFocusItems(this.domNode);
dijit.focus(this._firstFocusItem);
}
})});
this._fadeOut=dojo.fadeOut({node:_11,duration:this.duration,onEnd:dojo.hitch(this,function(){
_11.style.visibility="hidden";
_11.style.top="-9999px";
this.underlay.hide();
this.underlay.destroyRecursive();
delete this.underlay;
if(this._okClicked&&this.okCallback){
this.okCallback();
}else{
if(!this._okClicked&&this.cancelCallback){
this.cancelCallback();
}
}
dijit.focus(this._savedFocus);
this.destroyRecursive();
})});
this._navIn=dojo.fadeIn({node:this.closeButtonNode});
this._navOut=dojo.fadeOut({node:this.closeButtonNode});
if(!this.showTitle){
dojo.addClass(this.domNode,"dojoxDialogNoTitle");
}
},destroyRecursive:function(){
if(Px.Ex.MessageDialog.prototype._dlgs){
var i=dojo.indexOf(Px.Ex.MessageDialog.prototype._dlgs,this);
if(i>=0){
Px.Ex.MessageDialog.prototype._dlgs.splice(i,1);
}
}
try{
this.inherited(arguments);
}
catch(e){
}
}});
(function(){
closeOKMessageDialog=function(){
if(Px.Ex.OKMessageDialog.prototype._dlgs){
dojo.forEach(Px.Ex.OKMessageDialog.prototype._dlgs,function(v){
try{
v.destroyRecursive();
}
catch(e){
}
});
delete Px.Ex.OKMessageDialog.prototype._dlgs;
}
};
dojo.declare("Px.Ex.OKMessageDialog",[dojox.widget.Dialog],{message:"Are Your Sure?",okLabel:"OK",cancelLabel:"Cancel",modal:true,duration:500,okCallback:undefined,cancelCallback:undefined,contentClass:"okmessage-box",layoutClass:"message-box-layout",messageClass:"message-box-message",imageClass:"",buttonsClass:"message-box-buttons",okButtonClass:"message-box-ok",cancelButtonClass:"message-box-cancel",startup:function(){
this.inherited(arguments);
this.attr("content",this.createContent());
dojo.style(this.containerNode,"border","none");
dojo.style(this.domNode,"overflow","visible");
dojo.addClass(this.domNode,this.contentClass);
var _1={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _2=new curvyCorners(_1,this.domNode);
_2.applyCornersToAll();
},createContent:function(){
var _3,_4,tr,td,_5,c=dojo.create;
_3=c("table",{className:this.layoutClass});
_4=c("tbody",{},_3);
tr=c("tr",{},_4);
td=c("td",{},tr);
c("div",{className:this.imageClass},td);
td=c("td",{style:{verticalAlign:"top",width:"350px",textAlign:"center"}},tr);
c("div",{innerHTML:this.message,className:this.messageClass},td);
tr=c("tr",{},_4);
td=c("td",{colSpan:2,className:this.buttonsClass,style:{width:"350px"}},tr);
var _6;
_6=c("div",{className:this.okButtonClass,title:"ENTER",style:{marginLeft:"auto",marginRight:"auto"}},td);
this.connect(_6,"onclick","onOkBtn");
return _3;
},onOkBtn:function(){
this._okClicked=true;
this.hide();
},onCancelBtn:function(){
delete this._okClicked;
this.hide();
},_position:function(){
if(!dojo.hasClass(dojo.body(),"dojoMove")){
var _7=this.domNode;
var _8=dijit.getViewport();
var p=this._relativePosition;
var mb=p?null:dojo.marginBox(_7);
dojo.style(_7,{left:Math.floor(_8.l+(p?p.l:(_8.w-mb.w)/2))+"px",top:Math.floor(_8.t+(p?p.t:(_8.h-mb.h)/2))+"px"});
}
},show:function(){
if(Px.Ex.OKMessageDialog.prototype._dlgs&&Px.Ex.OKMessageDialog.prototype._dlgs.length){
closeOKMessageDialog();
}
if(this.open){
return;
}
this.startup();
if(!this._alreadyInitialized){
this._setup();
this._alreadyInitialized=true;
dojo.style(this.domNode,{zIndex:1100});
dojo.style(this.underlay.domNode,{zIndex:1099});
}
if(this._fadeOut.status()=="playing"){
this._fadeOut.stop();
}
this._modalconnects.push(dojo.connect(window,"onscroll",this,"layout"));
this._modalconnects.push(dojo.connect(window,"onresize",this,function(){
var _9=dijit.getViewport();
if(!this._oldViewport||_9.h!=this._oldViewport.h||_9.w!=this._oldViewport.w){
this.layout();
this._oldViewport=_9;
}
}));
this._modalconnects.push(dojo.connect(dojo.doc.documentElement,"onkeypress",this,"_onKey"));
dojo.style(this.domNode,{opacity:0,visibility:""});
if(this._fixSizes){
dojo.style(this.containerNode,{width:"auto",height:"auto"});
}
this.open=true;
this._onShow();
this._size();
this._position();
this._fadeIn.play();
this._savedFocus=dijit.getFocus(this);
if(this.modal){
}else{
this._modalconnects.push(dojo.connect(this.underlay.domNode,"onclick",this,"onCancel"));
}
this._modalconnects.push(dojo.connect(this.domNode,"onmouseenter",this,"_handleNav"));
this._modalconnects.push(dojo.connect(this.domNode,"onmouseleave",this,"_handleNav"));
this._modalconnects.push(dojo.connect(dojo.doc.documentElement,"onkeyup",this,"_onKeyUp"));
if(!Px.Ex.OKMessageDialog.prototype._dlgs){
Px.Ex.OKMessageDialog.prototype._dlgs=[];
}
Px.Ex.OKMessageDialog.prototype._dlgs.unshift(this);
},_onKeyUp:function(_a){
if(_a.keyCode==dojo.keys.ESCAPE){
var _b=_a.target;
while(_b){
if(_b==this.domNode){
this.onCancel();
dojo.stopEvent(_a);
return;
}
_b=_b.parentNode;
}
}else{
if(_a.keyCode==dojo.keys.ENTER){
var _b=_a.target;
while(_b){
if(_b==this.domNode){
this.onOkBtn();
dojo.stopEvent(_a);
return;
}
_b=_b.parentNode;
}
}
}
},uninitialize:function(){
var _c=false;
if(this._fadeIn&&this._fadeIn.status()=="playing"){
_c=true;
this._fadeIn.stop();
}
if(this._fadeOut&&this._fadeOut.status()=="playing"){
_c=true;
this._fadeOut.stop();
}
if(this.open||_c){
this.underlay.hide();
}
if(this._moveable){
this._moveable.destroy();
}
},layout:function(){
this._setSize();
if(this.domNode.style.visibility!="hidden"){
this.underlay.layout();
this._position();
}
},_setup:function(){
var _d=this.domNode;
if(this.titleBar&&this.draggable){
this._moveable=(dojo.isIE==6)?new dojo.dnd.TimedMoveable(_d,{handle:this.titleBar}):new dojo.dnd.Moveable(_d,{handle:this.titleBar,timeout:0});
dojo.subscribe("/dnd/move/stop",this,"_endDrag");
}else{
dojo.addClass(_d,"dijitDialogFixed");
}
var _e={dialogId:this.id,"class":dojo.map(this["class"].split(/\s/),function(s){
return s+"_underlay";
}).join(" ")};
this.underlay=new dijit.DialogUnderlay(_e);
this._fadeIn=dojo.fadeIn({node:_d,duration:this.duration,beforeBegin:dojo.hitch(this,function(){
this.underlay.attr(_e);
this.underlay.show();
}),onEnd:dojo.hitch(this,function(){
if(this.autofocus){
this._getFocusItems(this.domNode);
dijit.focus(this._firstFocusItem);
}
})});
this._fadeOut=dojo.fadeOut({node:_d,duration:this.duration,onEnd:dojo.hitch(this,function(){
_d.style.visibility="hidden";
_d.style.top="-9999px";
this.underlay.hide();
this.underlay.destroyRecursive();
delete this.underlay;
if(this._okClicked&&this.okCallback){
this.okCallback();
}else{
if(!this._okClicked&&this.cancelCallback){
this.cancelCallback();
}
}
dijit.focus(this._savedFocus);
this.destroyRecursive();
})});
this._navIn=dojo.fadeIn({node:this.closeButtonNode});
this._navOut=dojo.fadeOut({node:this.closeButtonNode});
if(!this.showTitle){
dojo.addClass(this.domNode,"dojoxDialogNoTitle");
}
},destroyRecursive:function(){
if(Px.Ex.OKMessageDialog.prototype._dlgs){
var i=dojo.indexOf(Px.Ex.OKMessageDialog.prototype._dlgs,this);
if(i>=0){
Px.Ex.OKMessageDialog.prototype._dlgs.splice(i,1);
}
}
try{
this.inherited(arguments);
}
catch(e){
}
}});
})();
(function(){
closeEmptyMessageDialog=function(){
if(Px.Ex.EmptyMessageDialog.prototype._dlgs){
dojo.forEach(Px.Ex.EmptyMessageDialog.prototype._dlgs,function(v){
try{
v.destroyRecursive();
}
catch(e){
}
});
delete Px.Ex.EmptyMessageDialog.prototype._dlgs;
}
};
dojo.declare("Px.Ex.EmptyMessageDialog",[dojox.widget.Dialog],{message:"Are Your Sure?",modal:true,duration:500,contentClass:"message-box",layoutClass:"message-box-layout",messageClass:"message-box-message",imageClass:"message-box-question",buttonsClass:"message-box-buttons",buttonsClasses:[],buttonsCallbacks:[],buttonsTooltips:[],startup:function(){
this.inherited(arguments);
this.attr("content",this.createContent());
dojo.style(this.containerNode,"border","none");
dojo.style(this.domNode,"overflow","visible");
dojo.addClass(this.domNode,this.contentClass);
var _1={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _2=new curvyCorners(_1,this.domNode);
_2.applyCornersToAll();
},createContent:function(){
var _3,_4,tr,td,_5,c=dojo.create;
_3=c("table",{className:this.layoutClass});
_4=c("tbody",{},_3);
tr=c("tr",{},_4);
td=c("td",{},tr);
c("div",{className:this.imageClass},td);
td=c("td",{style:{verticalAlign:"top"}},tr);
c("div",{innerHTML:this.message,className:this.messageClass},td);
tr=c("tr",{},_4);
td=c("td",{colSpan:2,className:this.buttonsClass},tr);
var _6,_7,_8,_9,_a;
_6=c("table",{style:{margin:"0 auto"}},td);
_7=c("tbody",{},_6);
_8=c("tr",{},_7);
if(this.buttonsClasses.length>0){
for(var i in this.buttonsClasses){
_9=c("td",{},_8);
_a=c("div",{className:this.buttonsClasses[i],title:this.buttonsTooltips[i]},_9);
this.connect(_a,"onclick",dojo.hitch(this,"buttonCallback",this.buttonsCallbacks[i]));
}
}
return _3;
},buttonCallback:function(_b){
this._callback=_b;
this.hide();
},_position:function(){
if(!dojo.hasClass(dojo.body(),"dojoMove")){
var _c=this.domNode;
var _d=dijit.getViewport();
var p=this._relativePosition;
var mb=p?null:dojo.marginBox(_c);
dojo.style(_c,{left:Math.floor(_d.l+(p?p.l:(_d.w-mb.w)/2))+"px",top:Math.floor(_d.t+(p?p.t:(_d.h-mb.h)/2))+"px"});
}
},show:function(){
if(Px.Ex.EmptyMessageDialog.prototype._dlgs&&Px.Ex.EmptyMessageDialog.prototype._dlgs.length){
closeEmptyMessageDialog();
}
if(this.open){
return;
}
this.startup();
if(!this._alreadyInitialized){
this._setup();
this._alreadyInitialized=true;
dojo.style(this.domNode,{zIndex:1100});
dojo.style(this.underlay.domNode,{zIndex:1099});
}
if(this._fadeOut.status()=="playing"){
this._fadeOut.stop();
}
this._modalconnects.push(dojo.connect(window,"onscroll",this,"layout"));
this._modalconnects.push(dojo.connect(window,"onresize",this,function(){
var _e=dijit.getViewport();
if(!this._oldViewport||_e.h!=this._oldViewport.h||_e.w!=this._oldViewport.w){
this.layout();
this._oldViewport=_e;
}
}));
this._modalconnects.push(dojo.connect(dojo.doc.documentElement,"onkeypress",this,"_onKey"));
dojo.style(this.domNode,{opacity:0,visibility:""});
if(this._fixSizes){
dojo.style(this.containerNode,{width:"auto",height:"auto"});
}
this.open=true;
this._onShow();
this._size();
this._position();
this._fadeIn.play();
this._savedFocus=dijit.getFocus(this);
if(this.modal){
}else{
this._modalconnects.push(dojo.connect(this.underlay.domNode,"onclick",this,"onCancel"));
}
this._modalconnects.push(dojo.connect(this.domNode,"onmouseenter",this,"_handleNav"));
this._modalconnects.push(dojo.connect(this.domNode,"onmouseleave",this,"_handleNav"));
this._modalconnects.push(dojo.connect(dojo.doc.documentElement,"onkeyup",this,"_onKeyUp"));
if(!Px.Ex.EmptyMessageDialog.prototype._dlgs){
Px.Ex.EmptyMessageDialog.prototype._dlgs=[];
}
Px.Ex.EmptyMessageDialog.prototype._dlgs.unshift(this);
},_onKeyUp:function(_f){
if(_f.keyCode==dojo.keys.ESCAPE){
var _10=_f.target;
while(_10){
if(_10==this.domNode){
this.onCancel();
dojo.stopEvent(_f);
return;
}
_10=_10.parentNode;
}
}else{
if(_f.keyCode==dojo.keys.ENTER){
var _10=_f.target;
while(_10){
if(_10==this.domNode){
dojo.stopEvent(_f);
return;
}
_10=_10.parentNode;
}
}
}
},uninitialize:function(){
var _11=false;
if(this._fadeIn&&this._fadeIn.status()=="playing"){
_11=true;
this._fadeIn.stop();
}
if(this._fadeOut&&this._fadeOut.status()=="playing"){
_11=true;
this._fadeOut.stop();
}
if(this.open||_11){
this.underlay.hide();
}
if(this._moveable){
this._moveable.destroy();
}
},layout:function(){
this._setSize();
if(this.domNode.style.visibility!="hidden"){
this.underlay.layout();
this._position();
}
},_setup:function(){
var _12=this.domNode;
if(this.titleBar&&this.draggable){
this._moveable=(dojo.isIE==6)?new dojo.dnd.TimedMoveable(_12,{handle:this.titleBar}):new dojo.dnd.Moveable(_12,{handle:this.titleBar,timeout:0});
dojo.subscribe("/dnd/move/stop",this,"_endDrag");
}else{
dojo.addClass(_12,"dijitDialogFixed");
}
var _13={dialogId:this.id,"class":dojo.map(this["class"].split(/\s/),function(s){
return s+"_underlay";
}).join(" ")};
this.underlay=new dijit.DialogUnderlay(_13);
this._fadeIn=dojo.fadeIn({node:_12,duration:this.duration,beforeBegin:dojo.hitch(this,function(){
this.underlay.attr(_13);
this.underlay.show();
}),onEnd:dojo.hitch(this,function(){
if(this.autofocus){
this._getFocusItems(this.domNode);
dijit.focus(this._firstFocusItem);
}
})});
this._fadeOut=dojo.fadeOut({node:_12,duration:this.duration,onEnd:dojo.hitch(this,function(){
_12.style.visibility="hidden";
_12.style.top="-9999px";
this.underlay.hide();
this.underlay.destroyRecursive();
delete this.underlay;
if(this._callback){
this._callback();
}
dijit.focus(this._savedFocus);
this.destroyRecursive();
})});
this._navIn=dojo.fadeIn({node:this.closeButtonNode});
this._navOut=dojo.fadeOut({node:this.closeButtonNode});
if(!this.showTitle){
dojo.addClass(this.domNode,"dojoxDialogNoTitle");
}
},destroyRecursive:function(){
if(Px.Ex.EmptyMessageDialog.prototype._dlgs){
var i=dojo.indexOf(Px.Ex.EmptyMessageDialog.prototype._dlgs,this);
if(i>=0){
Px.Ex.EmptyMessageDialog.prototype._dlgs.splice(i,1);
}
}
try{
this.inherited(arguments);
}
catch(e){
}
}});
})();
dojo.declare("Px.Ex.GridToolbar",[Px.Ex.XhrMixin],{constructor:function(_1){
this._tag=_1.tag;
this._title=_1.title;
this._file=_1.file;
this._url=_1.url;
this._htmlContentNode=_1.htmlContentNode;
this._dateSelectNode=_1.dateSelectNode;
this._xmlContentNode=_1.xmlContentNode;
},bind:function(){
dojo.connect(dojo.byId("div"+this._tag+"ExcelButton"),"onclick",dojo.hitch(this,function(){
var _2=document.createElement("form");
dojo.attr(_2,"method","post");
document.body.appendChild(_2);
dojo.io.iframe.send({form:_2,content:{format:"excel",title:dojo.hitch(this,"_getTitle")(),htmlcontent:dojo.hitch(this,"_getHtmlContent")(),file:this._file},url:this._url,error:dojo.hitch(this,function(_3){
}),preventCache:true,timeout:10});
document.body.removeChild(_2);
}));
dojo.connect(dojo.byId("div"+this._tag+"PdfButton"),"onclick",dojo.hitch(this,function(){
var _4=document.createElement("form");
dojo.attr(_4,"method","post");
document.body.appendChild(_4);
dojo.io.iframe.send({form:_4,content:{format:"pdf",title:dojo.hitch(this,"_getTitle")(),htmlcontent:dojo.hitch(this,"_getHtmlContent")(),file:this._file},url:this._url,error:dojo.hitch(this,function(_5){
}),preventCache:true,timeout:10});
document.body.removeChild(_4);
}));
dojo.connect(dojo.byId("div"+this._tag+"XmlButton"),"onclick",dojo.hitch(this,function(){
var _6=document.createElement("form");
dojo.attr(_6,"method","post");
document.body.appendChild(_6);
dojo.io.iframe.send({form:_6,content:{format:"xml",htmlcontent:dojo.hitch(this,"_getXmlContent")(),file:this._file},url:this._url,error:dojo.hitch(this,function(_7){
}),preventCache:true,timeout:10});
document.body.removeChild(_6);
}));
dojo.connect(dojo.byId("div"+this._tag+"PrintButton"),"onclick",dojo.hitch(this,function(){
var _8=document.createElement("form");
dojo.attr(_8,"method","post");
document.body.appendChild(_8);
dojo.io.iframe.send({form:_8,content:{format:"print",title:dojo.hitch(this,"_getTitle")(),htmlcontent:dojo.hitch(this,"_getHtmlContent")()},url:this._url,error:dojo.hitch(this,function(_9){
}),preventCache:true,timeout:10});
document.body.removeChild(_8);
}));
},_getHtmlContent:function(){
var _a=dojo.byId(this._htmlContentNode).innerHTML;
_a=_a.replace(/^\s*/,"").replace(/\s*$/,"");
var _b=_a.toLowerCase().indexOf("<table");
var _c=_a.toLowerCase().lastIndexOf("</table>");
return (_a.substring(_b,_c+8));
},_getXmlContent:function(){
return (dojo.byId(this._xmlContentNode).innerHTML);
},_getTitle:function(){
return (this._title+": "+dojo.byId(this._dateSelectNode).innerHTML);
}});
dojo.declare("Px.Ex.ModalDialogMixin",null,{modalDialog:function(_1){
var _2=function(_3){
_3.overlay.fadeIn("slow",function(){
});
_3.container.show("slow",function(){
_3.data.fadeIn("slow");
});
};
var _4=function(_5){
$("#divModalDialog #cancel").unbind("click");
$("#divModalDialog #submit").unbind("click");
_5.data.fadeOut("slow",function(){
_5.container.hide("slow",function(){
});
_5.overlay.fadeOut("slow",function(){
$.modal.close();
});
});
};
$("#divModalDialog").modal({close:false,onShow:_1,onOpen:_2,onClose:_4,overlay:"20"});
$("#divModalDialogContent").empty().append(Px.Ex.Application.getWaitHtml());
var _6={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _7=new curvyCorners(_6,"modalContainer");
_7.applyCornersToAll();
var _8=dojo.marginBox("modalContainer");
dojo.style("modalContainer",{left:_8.l,top:_8.t});
new dojo.dnd.Moveable(dojo.byId("modalContainer"),{handle:dojo.byId("divDialogSubMenu"),timeout:0});
},unbindSubmitCancelEvents:function(){
$("#divModalDialog #cancel").unbind("click");
$("#divModalDialog #submit").unbind("click");
},showDialogContentOnError:function(_9){
$("#divDialogLoading").fadeOut("fast",function(){
var _a=_9["faultstring"];
if(!_a){
if(_9["return"]&&_9["return"].errorMessage){
_a=_9["return"].errorMessage;
}else{
_a="UNKNOWN ERROR";
}
}
if(_9.id){
_a=_9.id+": "+_a;
}
dojo.query("#divModalDialog #error").html(_a);
$("#divModalDialogContent").fadeIn("slow");
});
},showDialogContentOnSuccess:function(_b){
$("#divDialogLoading").fadeOut("fast",function(){
$("#divModalDialogContent").html(_b).fadeIn("slow",function(){
setTimeout(function(){
$.modal.impl.close();
},1000);
});
});
},showDialogContent:function(_c){
$("#divDialogLoading").fadeOut("fast",function(){
$("#divModalDialogContent").fadeIn("slow",_c?_c():"");
});
},hideDialogContentAndWait:function(_d){
$("#divModalDialogContent").fadeOut("slow",function(){
$("#divDialogLoading").empty().append(Px.Ex.Application.getWaitHtml()).fadeIn("slow",function(){
if(_d){
_d();
}
});
});
},setTopCss:function(_e){
if(_e===undefined){
_e=50;
}
dojo.animateProperty({node:"modalContainer",duration:1000,properties:{top:{end:_e,units:"px"}}}).play();
},animateErrorMessage:function(_f){
Px.Ex.Application.animateErrorMessage("#divModalDialog #error",_f);
},clearError:function(){
dojo.query("#divModalDialog #error").empty();
}});
dojo.declare("Px.Ex.ChartMixin",null,{makeFlashChart:function(_1){
var _2="";
_1.chart_id=_1.divId+"chartId";
dojo.byId(_1.divId).innerHTML=this.getFlashChart(_1);
return _1.chart_id;
},getFlashChart:function(_3){
var _4=_3.chart_id;
if(!AC_FL_RunContent||!DetectFlashVer){
html="This page requires AC_RunActiveContent.js.";
}else{
var _5=DetectFlashVer(9,0,45);
if(_5){
html=AC_FL_RunContent("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0","width",_3.width,"height",_3.height,"scale","noscale","salign","LT","bgcolor","#F9F9F9","wmode","opaque","movie","/charts","src","/charts","FlashVars","chart_id="+_4+"&"+(_3.data?"library_path=/charts_library&xml_data="+_3.data:"library_path=/charts_library&xml_source="+_3.path),"id",_4,"name",_4,"menu","true","allowFullScreen","true","allowScriptAccess","sameDomain","quality","high","align","middle","pluginspage","http://www.macromedia.com/go/getflashplayer","play","true","devicefont","false");
}else{
html="This content requires the Adobe Flash Player. "+"<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.";
}
}
return _3.header+html;
}});
dojo.declare("Px.Ex.MonthAndDaysBack",[Px.Ex.XhrMixin],{constructor:function(_1){
this.labels=[3,7,14,30,60];
this.initDate=_1?_1.date:undefined;
this.initDaysBack=_1?_1.daysBack:this.labels[4];
this.htmlOfSelectDate=_1?_1.htmlOfSelectDate:undefined;
this._animateBars=_1&&(_1._animateBars!==undefined)?_1._animateBars:true;
},createSliderDaysBack:function(){
var _2=dojo.byId("divDaysBack");
if(!_2){
return;
}
var _3=document.createElement("div");
_2.appendChild(_3);
this.sliderRules=new dijit.form.HorizontalRuleLabels({count:this.labels.length,labels:this.labels,style:"height:1em;"},_3);
var _4=dojo.indexOf(this.labels,this.initDaysBack)+1;
if(_4<1){
_4=dojo.indexOf(this.labels,14)+1;
}
if(_4<1){
_4=1;
}
if(this.labels[_4-1]!=this.initDaysBack){
this.initDaysBack=this.labels[_4-1];
this.updateInitArgs();
}
this.theSlider=new dijit.form.HorizontalSlider({value:_4,onChange:dojo.hitch(this,"onDaysBackChange"),style:"width:150px;",minimum:1,maximum:this.labels.length,discreteValues:this.labels.length,intermediateChanges:false,showButtons:false},_2);
this.theSlider.startup();
this.sliderRules.startup();
},loadTpubDates:function(){
var _5=dojo.hitch(this,function(){
dojo.query("#divTpubDates").html(this.htmlOfSelectDate);
var _6=dojo.byId("insightMonthSelect");
if(!_6){
return;
}
this.monthSelectConnection=dojo.connect(_6,"onchange",this,"onMonthChange");
_6.value=this.initDate;
this.initDate=_6.value;
this.monthSelectInitialized();
});
if(this.htmlOfSelectDate){
_5();
return;
}
dojo.query("#divTpubDates").html(Px.Ex.Application.getNiceWaitHtml());
this.xhr({url:"/insight/tpub-dates",load:dojo.hitch(this,function(_7){
var _8;
if(_7["return"]&&_7["return"].reports){
_7=_7["return"].reports;
if(!dojo.isArray(_7)){
_7=[_7];
}
var _9=_7.length-1;
var _a=dojo.date.stamp.fromISOString(_7[_9].reportMonth);
var _b=new Date();
if(_b.getDate()<4&&_b.getMonth()==_a.getMonth()&&_b.getFullYear()==_a.getFullYear()){
--_9;
}
var _c=_7[_9].reportMonth;
_8="<select id=\"insightMonthSelect\" class=\"insight-month-select\">";
var _d=[];
dojo.forEach(_7,function(v,i,a){
var d=dojo.date.stamp.fromISOString(v.reportMonth);
var s=dojox.date.posix.strftime(d,"%b %Y");
_d.unshift(dojo.string.substitute("<option value=\"${value}\">${date}</option>",{value:v.reportMonth,date:s}));
});
_8+=_d.join("");
_8+="</select>";
if(!this.initDate){
this.initDate=_c;
}
this.htmlOfSelectDate=_8;
}else{
_8="";
}
_5();
}),handleAs:"json"});
},updateInitArgs:function(){
Px.Ex.Application.unpdateInsightInitArgs(this.initDate,this.initDaysBack,this.htmlOfSelectDate);
},monthSelectInitialized:function(){
this.updateInitArgs();
},onMonthChange:function(e){
this.initDate=e.target.value;
this.updateInitArgs();
},onDaysBackChange:function(v){
this.initDaysBack=this.labels[v-1];
this.updateInitArgs();
},destroy:function(){
if(this.monthSelectConnection){
dojo.disconnect(this.monthSelectConnection);
}
if(this.theSlider){
this.theSlider.destroyRecursive();
}
}});
dojo.declare("Px.Ex.Bar",null,{constructor:function(_1){
dojo.mixin(this,_1);
this.s=this._makeBar();
},_makeBar:function(){
var w=Math.round(this.width/this.max*this.data);
var s="<div class=\"bar-base\" style=\"width:"+this.width+"px;\">";
s+="<div class=\"bar\" style=\"width:"+(this.zeroWidth?0:w)+"px;\" id="+w+">\n</div>";
s+="</div>";
return s;
},getHtml:function(){
return this.s;
}});
(function(){
dojo.declare("Px.Ex.Login",null,{message:"",show:function(_1){
var _2=this;
var _3=this.getUserFromCookie();
Px.Ex.Application.menu.buildSubTitle(Px.Ex.Application.Titles.LOGIN);
Px.Ex.Application.xhr({url:"/login/dialog",content:{with_message:_1==null?false:true},load:dojo.hitch(this,function(_4){
dojo.query("#divContent").html(_4);
Px.Ex.Application.screen="login";
Px.Ex.Application.footer.update();
this.checkSaveUser(_3!=null&&_3.length>0);
this.bindEvents();
if(_3){
dojo.byId("input_username").value=_3;
dojo.byId("input_password").focus();
}else{
dojo.byId("input_username").focus();
}
})});
},setMessage:function(_5){
this.message=_5;
},getUserFromCookie:function(){
return dojo.cookie("texi_user_cookie");
},checkSaveUser:function(_6){
dojo.byId("checkboxSaveUser").checked=_6;
},saveOrDeleteUserCookie:function(){
var _7=dojo.byId("checkboxSaveUser").checked;
var _8={expires:3650,path:"/"};
if(!_7){
_8.expires=-1;
}
value=this.userName;
dojo.cookie("texi_user_cookie",value,_8);
this.getUserFromCookie();
},bindEvents:function(){
var _9=this;
var _a=dojo.hitch(this,"validateAndSend");
var _b=Px.Ex.Application.enterPressed(_a);
$("#divContent #submit").click(_a);
$("#divContent #reset_password").click(dojo.hitch(Px.Ex.Application.resetPassword,"show"));
$("#input_username").keypress(_b);
$("#input_password").keypress(_b);
if(this.message){
dojo.query("#divContent #error").html(this.message);
this.message=undefined;
}
},validateAndSend:function(){
dojo.query("#divContent #error").empty();
var _c=dojo.trim(dojo.byId("input_username").value);
this.userName=_c;
var _d=dojo.byId("input_password").value;
if(_c.length&&_d.length){
_d=$.base64Encode(_d);
var fn=dojo.hitch(this,"response");
dojo.query("#divContent").wipeOut({onEnd:function(){
var _e=dojo.query("#divContentLoading");
_e.html(Px.Ex.Application.getWaitHtml());
_e.wipeIn({onEnd:function(){
Px.Ex.Application.xhr({url:"/login/validate",content:{username:_c,password:_d},load:fn,handleAs:"json"});
}}).play();
}}).play();
}else{
Px.Ex.Application.animateErrorMessage("#divContent #error","Please, type your username and password!");
}
},response:function(_f,_10){
var ret=_f["return"];
if(ret==1){
this.saveOrDeleteUserCookie();
this.mainCallback();
}else{
if(ret==-1){
this.saveOrDeleteUserCookie();
this.changePasswordCallback();
}else{
var _11;
if(ret==0){
_11="Username and password do not match. Please try again.";
}else{
_11=_f["faultstring"]?_f["faultstring"]:"UNKNOWN ERROR";
}
var _12=dojo.query("#divContentLoading");
_12.wipeOut({onEnd:function(){
dojo.query("#divContent #error").html(_11);
dojo.query("#divContent").wipeIn().play();
}}).play();
_12.empty();
}
}
},clearFields:function(){
dojo.byId("input_username").value="";
dojo.byId("input_password").value="";
},mainCallback:function(){
dojo.query("#divContent").empty().wipeIn({onEnd:function(){
Px.Ex.Application.screen=undefined;
delete Px.Ex.Application.contactRoleLoaded;
delete Px.Ex.Application.permissionsLoaded;
Px.Ex.Application.loadUserData();
}}).play();
},changePasswordCallback:function(){
Px.Ex.Application.changePassword.show();
}});
})();
dojo.declare("Px.Ex.ResetPassword",[Px.Ex.XhrMixin],{email:"",show:function(){
var _1=this;
$("#divContent").fadeOut("slow",function(){
Px.Ex.Application.menu.buildSubTitle(Px.Ex.Application.Titles.RESET_PASSWORD);
_1.xhrLoad({selector:"#divContent",url:"/login/reset-dialog",load:function(_2){
Px.Ex.Application.screen="reset";
$("#divContent").fadeIn("slow",function(){
$("#input_email").focus();
_1.bindEvents.call(_1);
});
}});
});
},bindEvents:function(){
var _3=dojo.hitch(this,"validateAndSend");
var _4=Px.Ex.Application.enterPressed(_3);
$("#submit").click(_3);
$("#input_email").keypress(_4);
$("#input_code").keypress(_4);
$("#cancel").click(function(){
$("#divContent").fadeOut("slow",function(){
$("#divContent").empty();
Px.Ex.Application.login.show.call(Px.Ex.Application.login);
$("#divContent").fadeIn("slow");
});
});
},validateAndSend:function(){
var _5=this;
$("#divContent #error").html("");
var _6=$.trim($("#input_email").val());
_5.email=_6;
var _7=$.trim($("#input_code").val());
var _8=_6.length&&_7.length;
var _9=_8&&_6.search(Px.Ex.Application.Patterns.EMAIL)!=-1;
if(_9){
$("#divContent").fadeOut("slow",function(){
_5.xhr({url:"/login/reset-password",content:{email:_6,code:_7},handleAs:"json",load:dojo.hitch(_5,"response")});
$("#divContentLoading").empty().append(Px.Ex.Application.getWaitHtml()).fadeIn("slow");
});
}else{
if(!_8){
Px.Ex.Application.animateErrorMessage("#divContent #error","Please, type your email and code!");
}else{
Px.Ex.Application.animateErrorMessage("#divContent #error","\"Your Email\" should be of e-mail account format");
}
}
},response:function(_a){
var _b=this;
$("#divContentLoading").fadeOut("slow",function(){
if(_a["return"]){
_b.email=undefined;
_b.xhrLoad({selector:"#divContent",url:"/login/reset-dialog",load:function(_c){
$("#divContent").fadeOut("slow",function(){
$("#divContent").empty();
Px.Ex.Application.login.setMessage.call(Px.Ex.Application.login,_a["return"].errorMessage);
Px.Ex.Application.login.show.call(Px.Ex.Application.login);
$("#divContent").fadeIn("slow");
});
}});
}else{
_b.xhrLoad({selector:"#divContent",url:"/login/reset-dialog",load:function(_d){
$("#error").html(_a["faultstring"]!==undefined?_a["faultstring"]:"UNKNOWN ERROR");
$("#divContent").fadeIn("slow",function(){
if(_a["wrongcode"]){
$("#input_email").val(_b.email);
$("#input_code").focus();
}else{
_b.email=undefined;
$("#input_email").focus();
}
_b.bindEvents.call(_b);
});
}});
}
}).empty();
}});
dojo.declare("Px.Ex.ChangePassword",[Px.Ex.XhrMixin],{passwordExpiredString:"Your password is expired, please insert a new password",show:function(){
var _1=this;
$("#divContent").fadeOut("slow");
$("#divContentLoading").fadeOut("slow",function(){
Px.Ex.Application.menu.buildSubTitle(Px.Ex.Application.Titles.CHANGE_PASSWORD);
_1.xhrLoad({selector:"#divContent",url:"/login/change-password-dialog",load:function(_2){
Px.Ex.Application.screen="change-password";
$("#divContent #error").html(Px.Ex.ChangePassword.passwordExpiredString);
$("#divContent").fadeIn("slow",function(){
_1.bindEvents.call(_1);
$("#input_old_password").focus();
});
}});
});
},bindEvents:function(){
var _3=dojo.hitch(this,"validateAndSend");
var _4=Px.Ex.Application.enterPressed(_3);
$("#submit").click(_3);
$("#input_old_password").keypress(_4);
$("#input_new_password").keypress(_4);
$("#input_new_password_verify").keypress(_4);
$("#cancel").click(function(){
$("#divContent").fadeOut("slow",function(){
$("#divContent").empty();
Px.Ex.Application.login.show.call(Px.Ex.Application.login);
$("#divContent").fadeIn("slow");
});
});
},unbindEvents:function(){
$("#submit").unbind("click");
$("#cancel").unbind("click");
$("#input_old_password").unbind("keypress");
$("#input_new_password").unbind("keypress");
$("#input_new_password_verify").unbind("keypress");
},validateAndSend:function(){
$("#divContent #error").html("");
var _5=$("#input_old_password").val();
var _6=$("#input_new_password").val();
var _7=$("#input_new_password_verify").val();
var _8="";
if(_5.length==0){
_8="Please, type current password!";
}else{
if(_6.length==0){
_8="Please, type new password!";
}else{
if(_7.length==0){
_8="Please, confirm new password!";
}else{
if(_5==_6){
_8="The new password must be different from your current password.";
}else{
if(_6!=_7){
_8="The new password and the confirmation new password don't match. Please type the same password in both boxes.";
}
}
}
}
}
if(_8){
Px.Ex.Application.animateErrorMessage("#divContent #error",_8);
return;
}
_5=$.base64Encode(_5);
_6=$.base64Encode(_6);
_7=$.base64Encode(_7);
var _9=this;
$("#divContent").fadeOut("slow",function(){
_9.xhr({url:"/login/change-password",content:{oldPassword:_5,newPassword:_6,newPasswordVerify:_7},handleAs:"json",load:dojo.hitch(_9,"response")});
$("#divContentLoading").empty().append(Px.Ex.Application.getWaitHtml()).fadeIn("slow");
});
},response:function(_a){
var _b=this;
$("#divContentLoading").fadeOut("slow",function(){
var _c="";
var _d=false;
if(_a["return"]&&_a["return"].success){
_c=_a["return"].errorMessage;
_d=true;
_b.unbindEvents();
$("#divContent").html(_c);
}else{
_c=_a["faultstring"];
if(!_c){
if(_a["return"]){
_c=_a["return"].errorMessage;
}
}
if(!_c){
_c="UNKNOWN ERROR";
}
$("#divContent #error").html(_c);
}
$("#divContent").fadeIn("slow",function(){
if(!_d){
return;
}
setTimeout(function(){
$("#divContentLoading").empty().append(Px.Ex.Application.getWaitHtml()).fadeIn("slow");
Px.Ex.Application.login.mainCallback.call(Px.Ex.Application.login);
},2000);
});
}).empty();
}});
dojo.declare("Px.Ex.Title",null,{constructor:function(){
this.start();
},changeCurrentTitle:function(){
var o=Px.Ex.Application.getCurrentScreenIdTitle();
var t=document.title;
var _1=Px.Ex.Application.Titles.COMMON;
var _2=_1+" ["+o.title+"]";
if((o.title!==undefined)&&(t!=_2)){
document.title=_2;
}
},start:function(){
this.ID=setInterval(dojo.hitch(this,"changeCurrentTitle"),2000);
},cleanUp:function(){
clearInterval(this.ID);
}});
dojo.declare("Px.Ex.Footer",null,{constructor:function(){
this._connections=[];
this.connectHelp();
},connectHelp:function(){
var _1=dojo.query("#help","divMainFooter")[0];
if(_1){
this._connections.push(dojo.connect(_1,"onclick",this,"onHelp"));
}
},onHelp:function(){
if(this._help_shown){
return;
}
this._help_shown=true;
var _2=new Px.Ex.HelpDialog({afterDestroy:dojo.hitch(this,function(){
delete this._help_shown;
})});
_2.show();
return false;
},update:function(){
var o=Px.Ex.Application.getCurrentScreenIdTitle();
var _3=o.id==Px.Ex.Application.Ids.TEXI_COMMON||o.id==Px.Ex.Application.Ids.PAGE_LOGIN;
dojo.query(".hide_on_login","divMainFooter").toggleClass("texi-hidden",_3);
},destroy:function(){
dojo.forEach(this._connections,dojo.disconnect,this);
}});
dojo.declare("Px.Ex.DashboardScreen",[Px.Ex.XhrMixin,Px.Ex.ChartMixin],{draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/dashboard/screen",load:dojo.hitch(this,function(_1){
dojo.byId("divContent").innerHTML=_1;
this.showCharts();
})});
},showCharts:function(){
dojo.query("#divDashboardGraphs span").empty().forEach(function(v){
var _2=v.id;
var _3=1;
if(_3){
this.makeChart(_2);
}else{
var _4="/dashboard-chart/"+_2;
this.xhr({url:_4,load:function(_5){
v.innerHTML=_5;
}});
}
},this);
},makeChart:function(_6){
var _7="/dashboard-chart/"+_6;
var _8="";
var _9="434";
var _a="280";
switch(_6){
case "monthly-payments":
break;
case "hourly-volume":
_9="868";
break;
case "daily-volume":
break;
case "gender":
break;
case "age-groups":
break;
default:
return;
break;
}
this.makeFlashChart({divId:_6,width:_9,height:_a,path:_7,header:_8});
}});
dojo.declare("Px.Ex.SegmentDeliveryDashboardScreen",[Px.Ex.XhrMixin],{FILTER_SEGMENTS:1,FILTER_BUYERS:2,draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/segment-delivery/segment-delivery-dashboard-screen",load:dojo.hitch(this,function(_1){
dojo.byId("divContent").innerHTML=_1;
dojo.parser.parse("divContent");
this.parseServerData();
this.createScreen();
})});
},_createDropDown:function(_2){
var fn=null;
var _3;
if(_2==this.FILTER_SEGMENTS){
fn=Px.Ex.SegmentDeliveryDashboardScreen.SegmentFilterDialog;
_3=new fn({parent:this,data:{segments:this._segmentList}});
}else{
if(_2==this.FILTER_BUYERS){
fn=Px.Ex.SegmentDeliveryDashboardScreen.BuyerFilterDialog;
_3=new fn({parent:this,data:{buyers:this._buyerList}});
}
}
_3.startup();
return _3;
},onBuyerFilterDialog:function(_4){
},onSegmentFilterDialog:function(_5){
},parseServerData:function(){
if(dojo.byId("buyerList")){
this._buyerList=dojo.fromJson(dojo.byId("buyerList").innerHTML);
}else{
this._buyerList=[];
}
if(dojo.byId("segmentList")){
this._segmentList=dojo.fromJson(dojo.byId("segmentList").innerHTML);
}else{
this._segmentList=[];
}
if(dojo.byId("messageList")){
this._messageList=dojo.fromJson(dojo.byId("messageList").innerHTML);
}else{
this._messageList=[];
}
},createScreen:function(){
this._buyerFilterButton=new dijit.form.DropDownButton({"class":"segdlv-segment-filter",dropDown:this._createDropDown(this.FILTER_BUYERS)});
this._buyerFilterButton.placeAt(dojo.byId("buyerDropDownButton"));
dojo.byId("buyerDropDownButton").title=this._messageList["SEGDLV-TOOLTIP-FILTER-BUYERS"];
dojo.byId("buyerDropDownTitle").innerHTML=this._messageList["SEGDLV-TITLE-FILTER-BUYERS"];
this._segmentFilterButton=new dijit.form.DropDownButton({"class":"segdlv-segment-filter",dropDown:this._createDropDown(this.FILTER_SEGMENTS)});
this._segmentFilterButton.placeAt(dojo.byId("segmentDropDownButton"));
dojo.byId("segmentDropDownButton").title=this._messageList["SEGDLV-TOOLTIP-FILTER-SEGMENTS"];
dojo.byId("segmentDropDownTitle").innerHTML=this._messageList["SEGDLV-TITLE-FILTER-SEGMENTS"];
}});
dojo.declare("Px.Ex.SegmentDeliveryDashboardScreen.BuyerFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var _6=[];
if(this.data){
var b=this.data.buyers;
if(!dojo.isArray(b)){
b=[b];
}
_6=dojo.map(b,function(v){
return {value:v.buyerCode+"",label:v.buyerName,o:v};
});
}
this.filteredOps=this.ops=_6;
this.createContent();
},onBlur:function(){
this.parent.onBuyerFilterDialog(this.getSelected());
},onChange:function(_7){
if(this.searching){
return;
}
}});
dojo.declare("Px.Ex.SegmentDeliveryDashboardScreen.SegmentFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var _8=[];
if(this.data){
var b=this.data.segments;
if(!dojo.isArray(b)){
b=[b];
}
_8=dojo.map(b,function(v){
return {value:v.channelDisplayCode+"",label:v.channelName,o:v};
});
}
this.filteredOps=this.ops=_8;
this.createContent();
},onBlur:function(){
this.parent.onSegmentFilterDialog(this.getSelected());
},onChange:function(_9){
if(this.searching){
return;
}
}});
dojo.declare("Px.Ex.TPubActivityReportScreen",[Px.Ex.XhrMixin],{constructor:function(){
this.dailyActivityToolbar=new Px.Ex.GridToolbar({tag:"ReportDailyActivity",title:"Daily Activity Report",file:"daily_activity_report",htmlContentNode:"divReportDailyActivity",dateSelectNode:"tableDailyActivityTitle",xmlContentNode:"tableDailyActivityRaw",url:"/report/export"});
this.channelActivityToolbar=new Px.Ex.GridToolbar({tag:"ReportChannelActivity",title:"Segment Activity Report",file:"segment_activity_report",htmlContentNode:"divReportChannelActivity",dateSelectNode:"tableChannelActivityTitle",xmlContentNode:"tableChannelActivityRaw",url:"/report/export"});
},draw:function(){
this.xhr({url:"/report/activity",load:dojo.hitch(this,function(_1){
dojo.query("#divContent").html(_1);
if(!dojo.query("#divMonthYearForActivity select").length){
return;
}
this.bindDateChooser();
this.dailyActivityToolbar.bind();
this.channelActivityToolbar.bind();
this.loadReportChannelActivity();
this.loadReportDailyActivity();
})});
},bindDateChooser:function(){
var _2=this;
$("#divMonthYearForActivity select").change(function(){
_2.cancelXhr();
$("#divReportChannelActivity").empty().append(Px.Ex.Application.getWaitHtml());
$("#divReportDailyActivity").empty().append(Px.Ex.Application.getWaitHtml());
_2.loadReportChannelActivity();
_2.loadReportDailyActivity();
});
},loadReportChannelActivity:function(){
var _3=$("#divMonthYearForActivity select").val();
$("#divReportChannelActivity").empty().append(Px.Ex.Application.getWaitHtml());
this.xhr({url:"/report/channel-activity",content:{date:_3},load:dojo.hitch(this,function(_4){
dojo.query("#divReportChannelActivity").html(_4);
$("#tableChannelActivity").addClass("tablesorter");
$("#tableChannelActivity").tablesorter({});
var td=$("#tableChannelActivity td");
if(td.length){
$("#tableChannelActivity").trigger("sorton",[[[1,0]]]);
}
var _5=$("#divMonthYearForActivity select").val();
dojo.byId("tableChannelActivityTitle").innerHTML=_5.substring(0,7);
})});
},loadReportDailyActivity:function(){
var _6=$("#divMonthYearForActivity select").val();
$("#divReportDailyActivity").empty().append(Px.Ex.Application.getWaitHtml());
this.xhr({url:"/report/daily-activity",content:{date:_6},load:dojo.hitch(this,function(_7){
dojo.query("#divReportDailyActivity").html(_7);
$("#tableDailyActivity").addClass("tablesorter");
$("#tableDailyActivity").tablesorter();
var td=$("#tableDailyActivity td");
if(td.length){
$("#tableDailyActivity").trigger("sorton",[[[0,0]]]);
}
var _8=$("#divMonthYearForActivity select").val();
dojo.byId("tableDailyActivityTitle").innerHTML=_8.substring(0,7);
})});
}});
dojo.declare("Px.Ex.TPubPaymentsReportScreen",[Px.Ex.XhrMixin],{constructor:function(){
this.monthlyPerformanceToolbar=new Px.Ex.GridToolbar({tag:"ReportMonthlyPerformance",title:"Monthly Performance Report",file:"monthly_performance_report",htmlContentNode:"divReportMonthlyPerformance",dateSelectNode:"tableMonthlyPerformanceTitle",xmlContentNode:"tableMonthlyPerformanceRaw",url:"/report/export"});
},draw:function(){
this.xhr({url:"/report/payments",load:dojo.hitch(this,function(_1){
dojo.query("#divContent").html(_1);
if(!$("#divMonthYearForPayments select").length){
return;
}
this.loadPublisherContractDetails();
this.bindDateChooser();
this.monthlyPerformanceToolbar.bind();
this.loadReportMonthlyPerformance();
})});
},bindDateChooser:function(){
var _2=this;
$("#divMonthYearForPayments select").change(function(){
_2.cancelXhr();
$("#divReportMonthlyPerformance").empty().append(Px.Ex.Application.getWaitHtml());
_2.loadPublisherContractDetails();
_2.loadReportMonthlyPerformance();
});
},loadPublisherContractDetails:function(){
if(this._publisherContractDetailsLoaded){
return;
}
$("#divPublisherContractDetails").empty().append(Px.Ex.Application.getWaitHtml());
this.xhr({url:"/report/publisher-contract",load:dojo.hitch(this,function(_3){
dojo.query("#divPublisherContractDetails").html(_3);
this._publisherContractDetailsLoaded=true;
})});
},loadReportMonthlyPerformance:function(){
var _4=$("#divMonthYearForPayments select").val();
if(!_4){
return;
}
$("#divReportMonthlyPerformance").empty().append(Px.Ex.Application.getWaitHtml());
this.xhr({url:"/report/monthly-performance",content:{date:_4},load:dojo.hitch(this,function(_5){
dojo.query("#divReportMonthlyPerformance").html(_5);
$("#tableMonthlyPerformance").addClass("tablesorter");
$("#tableMonthlyPerformance").tablesorter();
$("#tableMonthlyPerformance2").addClass("tablesorter");
$("#tableMonthlyPerformance2").tablesorter();
var td=$("#tableMonthlyPerformance td");
if(td.length){
$("#tableMonthlyPerformance").trigger("sorton",[[[0,0]]]);
}
td=$("#tableMonthlyPerformance2 td");
if(td.length){
$("#tableMonthlyPerformance2").trigger("sorton",[[[0,0]]]);
}
var _6=$("#divMonthYearForPayments select").val();
dojo.byId("tableMonthlyPerformanceTitle").innerHTML=_6.substring(0,7);
})});
}});
dojo.declare("Px.Ex.TPubDataGroupsReportScreen",[Px.Ex.XhrMixin],{constructor:function(){
this.dataGroupsToolbar=new Px.Ex.GridToolbar({tag:"ReportGroupActivity",title:"Data Groups Report",file:"data_groups_report",htmlContentNode:"divReportGroupActivity",dateSelectNode:"tableGroupActivityTitle",xmlContentNode:"tableGroupActivityRaw",url:"/report/export"});
},draw:function(){
this.xhr({url:"/report/data-groups",load:dojo.hitch(this,function(_1){
dojo.query("#divContent").html(_1);
if(!$("#divMonthYearForActivity select").length){
return;
}
this.bindDateChooser();
this.dataGroupsToolbar.bind();
this.loadReportGroupActivity();
})});
},bindDateChooser:function(){
var _2=this;
$("#divMonthYearForActivity select").change(function(){
_2.cancelXhr();
$("#divReportChannelActivity").empty().append(Px.Ex.Application.getWaitHtml());
_2.loadReportGroupActivity();
});
},loadReportGroupActivity:function(){
var _3=$("#divMonthYearForActivity select").val();
$("#divReportGroupActivity").empty().append(Px.Ex.Application.getWaitHtml());
this.xhr({url:"/report/group-activity",content:{date:_3},load:dojo.hitch(this,function(_4){
dojo.query("#divReportGroupActivity").html(_4);
$("#tableGroupActivity").addClass("tablesorter");
$("#tableGroupActivity").tablesorter({});
var td=$("#tableGroupActivity td");
if(td.length){
$("#tableGroupActivity").trigger("sorton",[[[1,0]]]);
}
var _5=$("#divMonthYearForActivity select").val();
dojo.byId("tableGroupActivityTitle").innerHTML=_5.substring(0,7);
})});
}});
dojo.declare("Px.Ex.DealPerformanceReportScreen",[Px.Ex.XhrMixin],{BUYERS:1,DEALS:2,draw:function(){
this._buyersInFilter=[];
this._dealsInFilter=[];
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/performance-report/deal-screen",load:dojo.hitch(this,"createScreen"),handleAs:"json"});
},createScreen:function(_1){
dojo.empty("divContent");
if(_1.access_denied){
dojo.byId("divContent").innerHTML=_1.access_denied;
return;
}
var _2,_3,tr,td,_4,c=dojo.create;
this.NOW=dojo.date.stamp.fromISOString(_1.now);
this.NOW.setHours(0,0,0,0);
this.data=_1;
this.dateFilter=new Px.Ex.ReportDateFilter({NOW:this.NOW,messages:this.data.messages});
this._c=new dijit.layout.ContentPane({"class":"performance-report deal"}).placeAt("divContent");
this.createFilter();
_4=c("div",{className:"buttons"},this._c.containerNode);
_2=c("table",{},_4);
_3=c("tbody",{},_2);
tr=c("tr",{},_3);
td=c("td",{},tr);
_4=c("div",{className:"button-reset"},td);
this._c.connect(_4,"onclick",dojo.hitch(this,"resetFilter"));
td=c("td",{},tr);
_4=c("div",{className:"button-run"},td);
this._c.connect(_4,"onclick",dojo.hitch(this,"showReport"));
this.createGridToolbar();
this.reportDiv=c("div",{className:"report",id:"reportContainer"},this._c.containerNode);
},createFilter:function(){
var _5,_6,tr,td,_7,c=dojo.create;
var m=this.data.messages;
this.filter=new Px.Ex.TitlePane({open:true,duration:500,title:m.filterTitle||"Report parameters","class":"filter-pane"}).placeAt(this._c.containerNode);
this.form=new Px.Ex.Form({withReadOnly:true}).placeAt(this.filter.containerNode);
var _8=this.form.domNode;
_7=c("div",{className:"dates-main-layout"},_8);
this.dateFilter.create(_7);
_7=c("div",{className:"fields-main-layout"},_8);
this._createFieldsFilter(_7);
this.dateFilter.update();
},_createFieldsFilter:function(_9){
var _a,_b,tr,td,_c,dd,c=dojo.create;
var m=this.data.messages;
_a=c("table",{className:"layout"},_9);
_b=c("tbody",{},_a);
tr=c("tr",{},_b);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m.labelBuyer||"Buyer(s):"},td);
td=c("td",{className:"vmiddle"},tr);
this.buyerFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.BUYERS)});
this.buyerFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
_c=c("div",{className:"filter-clear-button"},td);
this._c.connect(_c,"onclick",dojo.hitch(this,function(){
this._buyersInFilter.length=0;
this._showBuyersInFilter();
this.buyerFilterButton.dropDown.clearFilter();
this.dealFilterButton.dropDown.filterDeals(this._buyersInFilter);
this._showDealsInFilter();
}));
td=c("td",{style:{width:"100%"}},tr);
this.buyerNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m.filterAll||"All",onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.buyerNames.attr("value"),this.buyerNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.buyerNames.domNode);
})});
this.buyerNames.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
this.groupByBuyers=new dijit.form.CheckBox({checked:false,"class":"filter-groupby",name:"buyerGroupBy",value:"Buyer"});
this.groupByBuyers.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":this.groupByBuyers.id,innerHTML:m.labelGroupBy||"Group by"},td);
tr=c("tr",{className:"vspacer"},_b);
tr=c("tr",{},_b);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m.labelDeal||"Deal(s):"},td);
td=c("td",{className:"vmiddle"},tr);
this.dealFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.DEALS)});
this.dealFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
_c=c("div",{className:"filter-clear-button"},td);
this._c.connect(_c,"onclick",dojo.hitch(this,function(){
this._dealsInFilter.length=0;
this._showDealsInFilter();
this.dealFilterButton.dropDown.clearFilter();
}));
td=c("td",{style:{width:"99%"},className:"vmiddle"},tr);
this.dealNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m.filterAll||"All",onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.dealNames.attr("value"),this.dealNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.dealNames.domNode);
})});
this.dealNames.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
this.groupByDeals=new dijit.form.CheckBox({checked:false,"class":"filter-groupby",name:"dealGroupBy",value:"Deal"});
this.groupByDeals.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":this.groupByDeals.id,innerHTML:m.labelGroupBy||"Group by"},td);
},_createDropDown:function(_d){
var fn=null;
if(_d==this.BUYERS){
fn=Px.Ex.DealPerformanceReport.BuyerFilterDialog;
}else{
if(_d==this.DEALS){
fn=Px.Ex.DealPerformanceReport.DealFilterDialog;
}
}
var _e=new fn({parent:this,data:this.data});
_e.startup();
return _e;
},createGridToolbar:function(){
var _f,_10,tr,td,div,c=dojo.create;
var m=this.data.messages;
this.gridToolbar=c("div",{className:"grid-toolbar texi-hidden"},this._c.containerNode);
_f=c("table",{className:"layout"},this.gridToolbar);
_10=c("tbody",{},_f);
tr=c("tr",{},_10);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button excel unselectable",unselectable:true,title:m.tooltipExcel||"Export to Excel",id:"divDealPerformanceExcelButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button pdf unselectable",unselectable:true,title:m.tooltipPdf||"Export to PDF",id:"divDealPerformancePdfButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button xml unselectable",unselectable:true,title:m.tooltipXML||"Export to XML",id:"divDealPerformanceXmlButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button print unselectable",unselectable:true,title:m.tooltipPrint||"Print",id:"divDealPerformancePrintButton"},td);
this.gridToolbarObj=new Px.Ex.GridToolbar({tag:"DealPerformance",title:m.reportTitle||"Data Deal Performance Report",file:"data_deal_performance_report",url:"/report/export",htmlContentNode:"reportContainer",dateSelectNode:"tableReportTitle",xmlContentNode:"tableReportRaw"});
this.gridToolbarObj.bind();
this._c.connect(this.gridToolbar,"onmousedown",dojo.hitch(this,function(e){
var _11=e.target;
if((dojo.isIE&&e.button==1||e.button==0)&&dojo.hasClass(_11,"tool-button")){
dojo.addClass(_11,"active");
}
}));
this._c.connect(this.gridToolbar,"onmouseup",dojo.hitch(this,function(e){
var _12=e.target;
if((dojo.isIE&&e.button==1||e.button==0)&&dojo.hasClass(_12,"tool-button")){
dojo.removeClass(_12,"active");
var o=this.getParams();
dojo.byId("tableReportTitle").innerHTML=o.start.slice(0,10)+" - "+o.end.slice(0,10);
}
}));
},resetFilter:function(){
this.form.reset();
this.filter.reset();
this.dateFilter.update();
this._buyersInFilter.length=0;
this._dealsInFilter.length=0;
this.buyerFilterButton.dropDown.clearFilter();
this.dealFilterButton.dropDown.clearFilter();
},_showBuyersInFilter:function(){
this._showInFilter(this._buyersInFilter,"buyerName",this.buyerNames);
},_showDealsInFilter:function(){
this._showInFilter(this._dealsInFilter,"dealName",this.dealNames);
},_showInFilter:function(arr,_13,_14){
var m=this.data.messages;
var a;
if(arr.length){
a=dojo.map(arr,function(v){
return v[_13];
});
}else{
a=[m.filterAll||"All"];
}
_14.attr("value",a.join(", "));
},getParams:function(){
if(!this.form.isValid()){
this.filter.attr("open",true);
this._timer=setTimeout(dojo.hitch(this.form,"validate"),this.filter.attr("duration"));
return null;
}
var o=this.form.attr("value");
if(o.timeGroupBy=="none"){
delete o.timeGroupBy;
}
o.groupBy=o.dealGroupBy||o.buyerGroupBy;
delete o.dealGroupBy;
delete o.buyerGroupBy;
o.start=dojo.date.stamp.toISOString(o.start,{zulu:false,milliseconds:false}).slice(0,19);
o.end=dojo.clone(o.end);
o.end.setHours(23,59,59);
o.end=dojo.date.stamp.toISOString(o.end,{zulu:false,milliseconds:false}).slice(0,19);
if(this._buyersInFilter.length){
o.buyerIds=dojo.map(this._buyersInFilter,"return item.buyerCode;").join(",");
}
if(this._dealsInFilter.length){
o.dealIds=dojo.map(this._dealsInFilter,"return item.dealCode;").join(",");
}
return o;
},showReport:function(){
var o=this.getParams();
if(!o){
return;
}
dojo.removeClass(this.gridToolbar,"texi-hidden");
this.reportDiv.innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/performance-report/deal-report",content:o,load:dojo.hitch(this,function(_15){
dojo.empty(this.reportDiv);
this.reportDiv.innerHTML=_15;
$("#tableReport").addClass("tablesorter");
$("#tableReport").tablesorter({});
var td=$("#tableReport td");
if(td.length){
$("#tableReport").trigger("sorton",o.timeGroupBy?[[[0,0],[1,0]]]:[[[0,0]]]);
}
}),error:dojo.hitch(this,function(err){
this.reportDiv.innerHTML=Px.Ex.Application._extractError(err);
dojo.addClass(this.gridToolbar,"texi-hidden");
})});
},destroy:function(){
clearTimeout(this._timer);
if(this._c){
this._c.destroyRecursive();
}
}});
dojo.declare("Px.Ex.DealPerformanceReport.BuyerFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.buyers&&this.data.buyers["return"]&&this.data.buyers["return"].buyers){
var b=this.data.buyers["return"].buyers;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.buyerCode+"",label:v.buyerName,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._buyersInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showBuyersInFilter"))();
this.parent.dealFilterButton.dropDown.filterDeals(this.parent._buyersInFilter);
(dojo.hitch(this.parent,"_showDealsInFilter"))();
}});
dojo.declare("Px.Ex.DealPerformanceReport.DealFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.deals&&this.data.deals["return"]&&this.data.deals["return"].deals){
var b=this.data.deals["return"].deals;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.dealCode+"",label:v.dealName,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._dealsInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showDealsInFilter"))();
},filterDeals:function(_16){
if(_16.length==0){
this.filteredOps=this.ops;
}else{
var _17={};
dojo.forEach(_16,function(v){
_17[v.buyerCode]=1;
});
var fo=[];
dojo.forEach(this.ops,function(v){
if(v.o.buyerCode in _17){
fo.push(v);
}else{
delete v.selected;
}
});
this.filteredOps=fo;
}
this.onSearch(this.searchCtrl.attr("value"));
this.onChange();
}});
dojo.declare("Px.Ex.BuyPerformanceReportScreen",[Px.Ex.XhrMixin],{CATEGORIES:1,SEGMENTS:2,draw:function(){
this._categoriesInFilter=[];
this._segmentsInFilter=[];
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/performance-report/buy-screen",load:dojo.hitch(this,"createScreen"),handleAs:"json"});
},showSettingsDialog:function(_1){
var _2=new Px.Ex.SettingsDialog({callback:_1,withMessage:true,requireBuyer:true});
_2.show();
},editSettings:function(){
this.showSettingsDialog(dojo.hitch(this,function(_3,_4,_5,_6){
if(_6&&this.reportDiv.innerHTML){
this.showReport();
}
}));
},createScreen:function(_7){
dojo.empty("divContent");
if(_7.access_denied){
dojo.byId("divContent").innerHTML=_7.access_denied;
return;
}
if(!_7.buyerCode){
this.showSettingsDialog();
}
var _8,_9,tr,td,_a,c=dojo.create;
this.NOW=dojo.date.stamp.fromISOString(_7.now);
this.NOW.setHours(0,0,0,0);
this.data=_7;
this.dateFilter=new Px.Ex.ReportDateFilter({NOW:this.NOW,messages:this.data.messages});
this._c=new dijit.layout.ContentPane({"class":"performance-report deal"}).placeAt("divContent");
this.createFilter();
_a=c("div",{className:"buttons"},this._c.containerNode);
_8=c("table",{},_a);
_9=c("tbody",{},_8);
tr=c("tr",{},_9);
td=c("td",{},tr);
_a=c("div",{className:"button-reset"},td);
this._c.connect(_a,"onclick",dojo.hitch(this,"resetFilter"));
td=c("td",{},tr);
_a=c("div",{className:"button-run"},td);
this._c.connect(_a,"onclick",dojo.hitch(this,"showReport"));
this.createGridToolbar();
this.reportDiv=c("div",{className:"report",id:"reportContainer"},this._c.containerNode);
},createFilter:function(){
var _b,_c,tr,td,_d,c=dojo.create;
var m=this.data.messages;
this.filter=new Px.Ex.TitlePane({open:true,duration:500,title:m.filterTitle||"Report parameters","class":"filter-pane"}).placeAt(this._c.containerNode);
this.form=new Px.Ex.Form({withReadOnly:true}).placeAt(this.filter.containerNode);
var _e=this.form.domNode;
_d=c("div",{className:"dates-main-layout"},_e);
this.dateFilter.create(_d);
_d=c("div",{className:"fields-main-layout"},_e);
this._createFieldsFilter(_d);
this.dateFilter.update();
},_createFieldsFilter:function(_f){
var _10,_11,tr,td,div,c=dojo.create;
var m=this.data.messages;
_10=c("table",{className:"layout"},_f);
_11=c("tbody",{},_10);
tr=c("tr",{},_11);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m.labelCategory||"Category(s):"},td);
td=c("td",{className:"vmiddle"},tr);
this.categoryFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.CATEGORIES)});
this.categoryFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"filter-clear-button"},td);
this._c.connect(div,"onclick",dojo.hitch(this,function(){
this._categoriesInFilter.length=0;
this._showCategoriesInFilter();
this.categoryFilterButton.dropDown.clearFilter();
this.segmentFilterButton.dropDown.filterSegments(this._categoriesInFilter);
this._showSegmentsInFilter();
}));
td=c("td",{style:{width:"100%"}},tr);
this.categoryNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m.filterAll||"All",onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.categoryNames.attr("value"),this.categoryNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.categoryNames.domNode);
})});
this.categoryNames.placeAt(td);
tr=c("tr",{className:"vspacer"},_11);
tr=c("tr",{},_11);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m.labelDeal||"Segment(s):"},td);
td=c("td",{className:"vmiddle"},tr);
this.segmentFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.SEGMENTS)});
this.segmentFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"filter-clear-button"},td);
this._c.connect(div,"onclick",dojo.hitch(this,function(){
this._segmentsInFilter.length=0;
this._showSegmentsInFilter();
this.segmentFilterButton.dropDown.clearFilter();
}));
td=c("td",{style:{width:"99%"},className:"vmiddle"},tr);
this.segmentNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m.filterAll||"All",onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.segmentNames.attr("value"),this.segmentNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.segmentNames.domNode);
})});
this.segmentNames.placeAt(td);
},_createDropDown:function(_12){
var fn=null;
if(_12==this.CATEGORIES){
fn=Px.Ex.BuyPerformanceReport.SegmentCategoryFilterDialog;
}else{
if(_12==this.SEGMENTS){
fn=Px.Ex.BuyPerformanceReport.SegmentFilterDialog;
}
}
var dlg=new fn({parent:this,data:this.data});
dlg.startup();
return dlg;
},createGridToolbar:function(){
var _13,_14,tr,td,div,c=dojo.create;
var m=this.data.messages;
this.gridToolbar=c("div",{className:"grid-toolbar texi-hidden"},this._c.containerNode);
_13=c("table",{className:"layout"},this.gridToolbar);
_14=c("tbody",{},_13);
tr=c("tr",{},_14);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button excel unselectable",unselectable:true,title:m.tooltipExcel||"Export to Excel",id:"divBuyPerformanceExcelButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button pdf unselectable",unselectable:true,title:m.tooltipPdf||"Export to PDF",id:"divBuyPerformancePdfButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button xml unselectable",unselectable:true,title:m.tooltipXML||"Export to XML",id:"divBuyPerformanceXmlButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button print unselectable",unselectable:true,title:m.tooltipPrint||"Print",id:"divBuyPerformancePrintButton"},td);
this.gridToolbarObj=new Px.Ex.GridToolbar({tag:"BuyPerformance",title:m.reportTitle||"Data Buy Performance Report",file:"data_buy_performance_report",url:"report/export",htmlContentNode:"reportContainer",dateSelectNode:"tableReportTitle",xmlContentNode:"tableReportRaw"});
this.gridToolbarObj.bind();
this._c.connect(this.gridToolbar,"onmousedown",dojo.hitch(this,function(e){
var _15=e.target;
if((dojo.isIE&&e.button==1||e.button==0)&&dojo.hasClass(_15,"tool-button")){
dojo.addClass(_15,"active");
}
}));
this._c.connect(this.gridToolbar,"onmouseup",dojo.hitch(this,function(e){
var _16=e.target;
if((dojo.isIE&&e.button==1||e.button==0)&&dojo.hasClass(_16,"tool-button")){
dojo.removeClass(_16,"active");
var o=this.getParams();
dojo.byId("tableReportTitle").innerHTML=o.start.slice(0,10)+" - "+o.end.slice(0,10);
}
}));
},resetFilter:function(){
this.form.reset();
this.filter.reset();
this.dateFilter.update();
this._categoriesInFilter.length=0;
this._segmentsInFilter.length=0;
this.categoryFilterButton.dropDown.clearFilter();
this.segmentFilterButton.dropDown.clearFilter();
},_showCategoriesInFilter:function(){
this._showInFilter(this._categoriesInFilter,"categoryName",this.categoryNames);
},_showSegmentsInFilter:function(){
this._showInFilter(this._segmentsInFilter,"channelName",this.segmentNames);
},_showInFilter:function(arr,_17,_18){
var m=this.data.messages;
var a;
if(arr.length){
a=dojo.map(arr,function(v){
return v[_17];
});
}else{
a=[m.filterAll||"All"];
}
_18.attr("value",a.join(", "));
},getParams:function(){
if(!this.form.isValid()){
this.filter.attr("open",true);
this._timer=setTimeout(dojo.hitch(this.form,"validate"),this.filter.attr("duration"));
return null;
}
var o=this.form.attr("value");
if(o.timeGroupBy=="none"){
delete o.timeGroupBy;
}
o.start=dojo.date.stamp.toISOString(o.start,{zulu:false,milliseconds:false}).slice(0,19);
o.end=dojo.clone(o.end);
o.end.setHours(23,59,59);
o.end=dojo.date.stamp.toISOString(o.end,{zulu:false,milliseconds:false}).slice(0,19);
if(this._categoriesInFilter.length){
o.categoryIds=dojo.map(this._categoriesInFilter,"return item.categoryCode;").join(",");
}
if(this._segmentsInFilter.length){
o.segmentIds=dojo.map(this._segmentsInFilter,"return item.channelDisplayCode;").join(",");
}
return o;
},_showReport:function(_19){
dojo.removeClass(this.gridToolbar,"texi-hidden");
this.reportDiv.innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/performance-report/buy-report",content:_19,load:dojo.hitch(this,function(_1a){
dojo.empty(this.reportDiv);
this.reportDiv.innerHTML=_1a;
$("#tableReport").addClass("tablesorter");
$("#tableReport").tablesorter({});
var td=$("#tableReport td");
if(td.length){
$("#tableReport").trigger("sorton",o.timeGroupBy?[[[0,0],[1,0]]]:[[[0,0]]]);
}
}),error:dojo.hitch(this,function(err){
this.reportDiv.innerHTML=Px.Ex.Application._extractError(err);
dojo.addClass(this.gridToolbar,"texi-hidden");
})});
},showReport:function(){
var o=this.getParams();
if(!o){
return;
}
this.reportDiv.innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/performance-report/buyer-code",load:dojo.hitch(this,function(_1b){
dojo.empty(this.reportDiv);
if(!_1b.buyerCode){
this.showSettingsDialog(dojo.hitch(this,function(_1c,_1d,_1e,_1f){
if(_1e&&_1f){
this._showReport(o);
}
}));
}else{
this._showReport(o);
}
}),error:dojo.hitch(this,function(err){
this.reportDiv.innerHTML=Px.Ex.Application._extractError(err);
}),handleAs:"json"});
},destroy:function(){
clearTimeout(this._timer);
if(this._c){
this._c.destroyRecursive();
}
}});
dojo.declare("Px.Ex.BuyPerformanceReport.SegmentCategoryFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.segmentCategories&&this.data.segmentCategories["return"]&&this.data.segmentCategories["return"].categories){
var b=this.data.segmentCategories["return"].categories;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.categoryCode+"",label:v.categoryName,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._categoriesInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showCategoriesInFilter"))();
this.parent.segmentFilterButton.dropDown.filterSegments(this.parent._categoriesInFilter);
(dojo.hitch(this.parent,"_showSegmentsInFilter"))();
}});
dojo.declare("Px.Ex.BuyPerformanceReport.SegmentFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.segments&&this.data.segments["return"]&&this.data.segments["return"].segments){
var b=this.data.segments["return"].segments;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.channelDisplayCode+"",label:v.channelName,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._segmentsInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showSegmentsInFilter"))();
},filterSegments:function(_20){
if(_20.length==0){
this.filteredOps=this.ops;
}else{
var _21={};
dojo.forEach(_20,function(v){
_21[v.categoryCode]=1;
});
var fo=[];
dojo.forEach(this.ops,function(v){
if(v.o.segmentCategory in _21){
fo.push(v);
}else{
delete v.selected;
}
});
this.filteredOps=fo;
}
this.onSearch(this.searchCtrl.attr("value"));
this.onChange();
}});
dojo.declare("Px.Ex.BuyReportScreen",[Px.Ex.XhrMixin],{SEGMENTS:1,DATABUYS:2,STATUSES:3,FIELDS:4,draw:function(){
this._segmentsInFilter=[];
this._dataBuysInFilter=[];
this._statusesInFilter=[];
this._fieldsInFilter=[];
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/buy-report/screen",load:dojo.hitch(this,"createScreen"),handleAs:"json"});
},showSettingsDialog:function(_1){
var _2=new Px.Ex.SettingsDialog({callback:_1,withMessage:true,requireBuyer:true});
_2.show();
},createScreen:function(_3,_4){
dojo.empty("divContent");
if(_3.access_denied){
dojo.byId("divContent").innerHTML=_3.access_denied;
return;
}
if(!_3.buyerCode){
this.showSettingsDialog();
return;
}
this.data=_3;
if(this.data.segments&&!this.data.segments["return"]){
Px.Ex.Application.showGlobalError(this.data.segments,_4);
}
if(this.data.dataBuys&&!this.data.dataBuys["return"]){
Px.Ex.Application.showGlobalError(this.data.dataBuys,_4);
}
var _5,_6,tr,td,_7,c=dojo.create;
this.NOW=dojo.date.stamp.fromISOString(_3.now);
this.NOW.setHours(0,0,0,0);
this.dateFilter=new Px.Ex.ReportDateFilter({NOW:this.NOW,messages:this.data.messages});
this._c=new dijit.layout.ContentPane({"class":"performance-report buy-details"}).placeAt("divContent");
this.createFilter();
_7=c("div",{className:"buttons"},this._c.containerNode);
_5=c("table",{},_7);
_6=c("tbody",{},_5);
tr=c("tr",{},_6);
td=c("td",{},tr);
_7=c("div",{className:"button-reset"},td);
this._c.connect(_7,"onclick",dojo.hitch(this,"resetFilter"));
td=c("td",{},tr);
_7=c("div",{className:"button-run"},td);
this._c.connect(_7,"onclick",dojo.hitch(this,"showReport"));
this.createGridToolbar();
this.reportDiv=c("div",{className:"report"},this._c.containerNode);
},createFilter:function(){
var _8,_9,tr,td,_a,c=dojo.create;
var m=this.data.messages;
this.filter=new Px.Ex.TitlePane({open:true,duration:500,title:m.filterTitle||"Report parameters","class":"filter-pane"}).placeAt(this._c.containerNode);
this.form=new Px.Ex.Form({withReadOnly:true}).placeAt(this.filter.containerNode);
var _b=this.form.domNode;
_a=c("div",{className:"dates-main-layout"},_b);
this.dateFilter.create(_a);
_a=c("div",{className:"fields-main-layout"},_b);
this._createFieldsFilter(_a);
this.dateFilter.update();
},_createFieldsFilter:function(_c){
var _d,_e,tr,td,_f,c=dojo.create;
var m=this.data.messages;
_d=c("table",{className:"layout"},_c);
_e=c("tbody",{},_d);
tr=c("tr",{},_e);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m.labelSegment||"Segment(s):"},td);
td=c("td",{className:"vmiddle"},tr);
this.segmentFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.SEGMENTS)});
this.segmentFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
_f=c("div",{className:"filter-clear-button"},td);
this._c.connect(_f,"onclick",dojo.hitch(this,function(){
this._segmentsInFilter.length=0;
this._showSegmentsInFilter();
this.segmentFilterButton.dropDown.clearFilter();
this.dataBuyFilterButton.dropDown.filterDataBuys(this._segmentsInFilter);
this._showDataBuysInFilter();
}));
td=c("td",{style:{width:"100%"}},tr);
this.segmentNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m.filterAll||"All",onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.segmentNames.attr("value"),this.segmentNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.segmentNames.domNode);
})});
this.segmentNames.placeAt(td);
tr=c("tr",{className:"vspacer"},_e);
tr=c("tr",{},_e);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m.labelDataBuy||"Data Buy(s):"},td);
td=c("td",{className:"vmiddle"},tr);
this.dataBuyFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.DATABUYS)});
this.dataBuyFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
_f=c("div",{className:"filter-clear-button"},td);
this._c.connect(_f,"onclick",dojo.hitch(this,function(){
this._dataBuysInFilter.length=0;
this._showDataBuysInFilter();
this.dataBuyFilterButton.dropDown.clearFilter();
}));
td=c("td",{style:{width:"99%"},className:"vmiddle"},tr);
this.dataBuyNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m.filterAll||"All",onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.dataBuyNames.attr("value"),this.dataBuyNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.dataBuyNames.domNode);
})});
this.dataBuyNames.placeAt(td);
tr=c("tr",{className:"vspacer"},_e);
tr=c("tr",{},_e);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m.labelStatus||"Status(es):"},td);
td=c("td",{className:"vmiddle"},tr);
this.statusFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.STATUSES)});
this.statusFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
_f=c("div",{className:"filter-clear-button"},td);
this._c.connect(_f,"onclick",dojo.hitch(this,function(){
this._statusesInFilter.length=0;
this._showStatusesInFilter();
this.statusFilterButton.dropDown.clearFilter();
}));
td=c("td",{style:{width:"99%"},className:"vmiddle"},tr);
this.statusNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m.filterAll||"All",onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.statusNames.attr("value"),this.statusNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.statusNames.domNode);
})});
this.statusNames.placeAt(td);
tr=c("tr",{className:"vspacer"},_e);
tr=c("tr",{},_e);
td=c("td",{className:"vmiddle",colSpan:6},tr);
c("div",{className:"separator"},td);
tr=c("tr",{className:"vspacer"},_e);
tr=c("tr",{className:"fields"},_e);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m.labelFields||"Fields:"},td);
td=c("td",{className:"vmiddle"},tr);
this.fieldFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.FIELDS)});
this.fieldFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
_f=c("div",{className:"filter-clear-button"},td);
this._c.connect(_f,"onclick",dojo.hitch(this,function(){
this.fieldFilterButton.dropDown.clearFilter();
}));
td=c("td",{style:{width:"99%"},className:"vmiddle"},tr);
this.fieldNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m.filterAll||"All",onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.fieldNames.attr("value"),this.fieldNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.fieldNames.domNode);
}),reset:function(){
}});
this.fieldNames.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
td=c("td",{className:"vmiddle"},tr);
},_createDropDown:function(_10){
var fn=null;
if(_10==this.SEGMENTS){
fn=Px.Ex.BuyReport.SegmentFilterDialog;
}else{
if(_10==this.DATABUYS){
fn=Px.Ex.BuyReport.DataBuyFilterDialog;
}else{
if(_10==this.STATUSES){
fn=Px.Ex.BuyReport.StatusFilterDialog;
}else{
if(_10==this.FIELDS){
fn=Px.Ex.BuyReport.FieldDialog;
}
}
}
}
var dlg=new fn({parent:this,data:this.data});
dlg.startup();
return dlg;
},createGridToolbar:function(){
var _11,_12,tr,td,div,c=dojo.create;
var m=this.data.messages;
this.gridToolbar=c("div",{className:"grid-toolbar texi-hidden"},this._c.containerNode);
_11=c("table",{className:"layout"},this.gridToolbar);
_12=c("tbody",{},_11);
tr=c("tr",{},_12);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button excel unselectable",unselectable:true,title:m.tooltipExcel||"Export to Excel",id:"divBuyReportExcelButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button pdf unselectable",unselectable:true,title:m.tooltipPdf||"Export to PDF",id:"divBuyReportPdfButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button xml unselectable",unselectable:true,title:m.tooltipXML||"Export to XML",id:"divBuyReportXmlButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button print unselectable",unselectable:true,title:m.tooltipPrint||"Print",id:"divBuyReportPrintButton"},td);
this.gridToolbarObj=new Px.Ex.GridToolbar({tag:"BuyReport",title:m.reportTitle||"Data Buy Report",file:"data_buy_report",url:"/report/export",htmlContentNode:"reportContainer",dateSelectNode:"tableReportTitle",xmlContentNode:"tableReportRaw"});
this.gridToolbarObj.bind();
this._c.connect(this.gridToolbar,"onmousedown",dojo.hitch(this,function(e){
var _13=e.target;
if((dojo.isIE&&e.button==1||e.button==0)&&dojo.hasClass(_13,"tool-button")){
dojo.addClass(_13,"active");
}
}));
this._c.connect(this.gridToolbar,"onmouseup",dojo.hitch(this,function(e){
var _14=e.target;
if((dojo.isIE&&e.button==1||e.button==0)&&dojo.hasClass(_14,"tool-button")){
dojo.removeClass(_14,"active");
var o=this.getParams();
dojo.byId("tableReportTitle").innerHTML=o.start.slice(0,10)+" - "+o.end.slice(0,10);
}
}));
},canFitInViewPort:function(){
if(!dojo.byId("tableReport")){
return false;
}
var _15=dojo.marginBox(dojo.byId("tableReport"));
var _16=_15.h;
var _17=dijit.getViewport();
var _18=_17.h;
return (_18>=_16)?true:false;
},_expandCollapseGrid:function(){
if(!dojo.byId("tableReport")){
return;
}
var pos=dojo.style("tableReport","position");
pos=(pos=="absolute"?"":"absolute");
var w=(pos=="absolute"?"auto":"99.9%");
if(pos=="absolute"){
if(!this._hasScroll()){
return;
}
dojo.byId("reportContainer").scrollLeft=0;
this._setUpperScroll(false);
}else{
this._setUpperScroll(true);
}
dojo.style("tableReport",{position:pos,width:w});
if(pos=="absolute"){
this._setContainerHeight();
this._moveButton(true);
}else{
this._moveButton(false);
}
},_hasScroll:function(){
if(!dojo.byId("tableReport")){
return false;
}
var _19=dojo.isChrome?1:0;
return (dojo.contentBox("reportContainer").w<dojo.marginBox("tableReport").w-_19);
},_setUpperScroll:function(_1a){
if(!dojo.byId("tableReport")){
return;
}
var _1b=dojo.isIE?18:17;
dojo.marginBox("aboveReportContent",{w:dojo.marginBox("tableReport").w,h:_1b});
dojo.contentBox("aboveReport",{h:_1b});
if((_1a)&&(this._hasScroll())){
if(!this.canFitInViewPort()){
dojo.byId("aboveReport").style.visibility="visible";
}else{
dojo.byId("aboveReport").style.visibility="hidden";
}
this._bindScrollBars(true);
}else{
dojo.byId("aboveReport").style.visibility="hidden";
this._bindScrollBars(false);
}
},_setContainerHeight:function(){
if(!dojo.byId("tableReport")){
return;
}
var o=dojo.marginBox("tableReport");
var o2=dojo.contentBox("reportContainer");
o2.h=o.h;
dojo.contentBox("reportContainer",o2);
},_bindScrollBars:function(_1c){
if(_1c){
if(!dojo.byId("tableReport")){
return;
}
var c=this._scroll_connections=[];
this._scroll_connections.push(dojo.connect(dojo.byId("aboveReport"),"onscroll",this,function(e){
if(this._bottom_scrolling){
return;
}
this._top_scrolling=true;
dojo.byId("reportContainer").scrollLeft=dojo.byId("aboveReport").scrollLeft;
delete this._top_scrolling;
}));
this._scroll_connections.push(dojo.connect(dojo.byId("reportContainer"),"onscroll",this,function(e){
if(this._top_scrolling){
return;
}
this._bottom_scrolling=true;
dojo.byId("aboveReport").scrollLeft=dojo.byId("reportContainer").scrollLeft;
delete this._bottom_scrolling;
}));
}else{
if(!this._scroll_connections){
return;
}
dojo.forEach(this._scroll_connections,dojo.disconnect,this);
delete this._scroll_connections;
}
},_addExpandRightButton:function(){
if(!this._hasScroll()){
return;
}
var m=this.data.messages;
var b=this.expandGridRightButton=dojo.create("div",{className:"expand-collapse-grid-right",title:m.tooltipExpandCollapseGrid||"Expand-collase grid"},"reportContainer","after");
var hh=this._right_button_handlers=[];
hh.push(dojo.connect(b,"onclick",this,"_expandCollapseGrid"));
hh.push(dojo.connect(b,"onmouseenter",this,function(){
dojo.addClass(this.expandGridRightButton,"active");
}));
hh.push(dojo.connect(b,"onmouseleave",this,function(){
dojo.removeClass(this.expandGridRightButton,"active");
}));
hh.push(dojo.connect(window,"onresize",this,function(){
if(this.right!==undefined){
this._moveButton(this.right);
}
}));
this._moveButton(false);
},_moveButton:function(_1d){
if(!this.expandGridRightButton){
return;
}
this.right=!!_1d;
if(_1d){
var m=dojo.marginBox("tableReport");
var c=dojo.contentBox("tableReport");
var _1e=dojo.isIE?2:(dojo.isFF?1:1);
var _1f=dojo.isFF?1:2;
dojo.marginBox(this.expandGridRightButton,{l:m.l+m.w,t:m.t+_1f,h:c.h+_1e});
}else{
var _1e=dojo.isFF?1:2;
if(dojo.isIE){
var m0=dojo.marginBox(dojo.query(".texi_container")[0]);
var m1=dojo.marginBox(dojo.query(".texi_content_container")[0]);
var m2=dojo.marginBox(dojo.query(".buy-details")[0]);
var m=dojo.marginBox("reportContainer");
var c=dojo.contentBox("reportContainer");
m.l+=m0.l+m1.l+m2.l;
m.t+=m0.t+m1.t+m2.t;
dojo.marginBox(this.expandGridRightButton,{l:m.l+m.w-1,t:m.t+_1e,h:c.h-_1e});
}else{
var m=dojo.marginBox("reportContainer");
var c=dojo.contentBox("reportContainer");
dojo.marginBox(this.expandGridRightButton,{l:m.l+m.w,t:m.t+_1e,h:c.h-_1e});
}
}
dojo.attr(this.expandGridRightButton,"title",(_1d?"Collapse grid":"Expand grid"));
dojo.toggleClass(this.expandGridRightButton,"right",_1d);
},_removeExpandRightButton:function(){
if(!this.expandGridRightButton){
return;
}
if(this._right_button_handlers){
dojo.forEach(this._right_button_handlers,dojo.disconnect,this);
delete this._right_button_handlers;
}
dojo.destroy(this.expandGridRightButton);
delete this.expandGridRightButton;
delete this.right;
},resetFilter:function(){
this.form.reset();
this.filter.reset();
this.dateFilter.update();
this._segmentsInFilter.length=0;
this._dataBuysInFilter.length=0;
this._statusesInFilter.length=0;
this.segmentFilterButton.dropDown.clearFilter();
this.dataBuyFilterButton.dropDown.clearFilter();
this.statusFilterButton.dropDown.clearFilter();
this.fieldFilterButton.dropDown.reset();
},_showSegmentsInFilter:function(){
this._showInFilter(this._segmentsInFilter,"channelName",this.segmentNames);
},_showDataBuysInFilter:function(){
this._showInFilter(this._dataBuysInFilter,"dataBuyName",this.dataBuyNames);
},_showStatusesInFilter:function(){
this._showInFilter(this._statusesInFilter,"label",this.statusNames);
},_showFieldsInFilter:function(){
this._showInFilter(this._fieldsInFilter,"label",this.fieldNames);
},_showInFilter:function(arr,_20,_21){
var m=this.data.messages;
var a;
if(arr.length){
a=dojo.map(arr,function(v){
return v[_20];
});
}else{
a=[m.filterAll||"All"];
}
_21.attr("value",a.join(", "));
},getParams:function(){
if(!this.form.isValid()){
this.filter.attr("open",true);
this._timer=setTimeout(dojo.hitch(this.form,"validate"),this.filter.attr("duration"));
return null;
}
var o=this.form.attr("value");
if(o.timeGroupBy=="none"){
delete o.timeGroupBy;
}
o.start=dojo.date.stamp.toISOString(o.start,{zulu:false,milliseconds:false}).slice(0,19);
o.end=dojo.clone(o.end);
o.end.setHours(23,59,59);
o.end=dojo.date.stamp.toISOString(o.end,{zulu:false,milliseconds:false}).slice(0,19);
if(this._segmentsInFilter.length){
o.segmentIds=dojo.map(this._segmentsInFilter,"return item.channelDisplayCode;").join(",");
}
if(this._dataBuysInFilter.length){
o.dataBuyIds=dojo.map(this._dataBuysInFilter,"return item.dataBuyCode;").join(",");
}
if(this._statusesInFilter.length){
o.statusIds=dojo.map(this._statusesInFilter,"return item.value;").join(",");
}
if(this._fieldsInFilter.length){
o.fields=dojo.map(this._fieldsInFilter,"return item.id;").join("a");
}
return o;
},_showReport:function(_22){
dojo.removeClass(this.gridToolbar,"texi-hidden");
this._setUpperScroll(false);
this._removeExpandRightButton();
dojo.empty(this.reportDiv);
this.reportDiv.innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/buy-report/report",content:_22,load:dojo.hitch(this,function(_23){
dojo.empty(this.reportDiv);
this.reportDiv.innerHTML=_23;
$("#tableReport").addClass("tablesorter");
$("#tableReport").tablesorter({});
this._setContainerHeight();
this._setUpperScroll(true);
this._addExpandRightButton();
}),error:dojo.hitch(this,function(err){
this.reportDiv.innerHTML=Px.Ex.Application._extractError(err);
dojo.addClass(this.gridToolbar,"texi-hidden");
})});
},showReport:function(){
var o=this.getParams();
if(!o){
return;
}
this._showReport(o);
},destroy:function(){
clearTimeout(this._timer);
if(this._c){
this._c.destroyRecursive();
}
}});
dojo.declare("Px.Ex.BuyReport.SegmentFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.segments&&this.data.segments["return"]&&this.data.segments["return"].segments){
var b=this.data.segments["return"].segments;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.channelDisplayCode+"",label:v.channelName,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._segmentsInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showSegmentsInFilter"))();
this.parent.dataBuyFilterButton.dropDown.filterDataBuys(this.parent._segmentsInFilter);
(dojo.hitch(this.parent,"_showDataBuysInFilter"))();
}});
dojo.declare("Px.Ex.BuyReport.DataBuyFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.dataBuys&&this.data.dataBuys["return"]&&this.data.dataBuys["return"].dataBuys){
var b=this.data.dataBuys["return"].dataBuys;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.dataBuyCode+"",label:v.dataBuyName,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._dataBuysInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showDataBuysInFilter"))();
},filterDataBuys:function(_24){
if(_24.length==0){
this.filteredOps=this.ops;
}else{
var _25={};
dojo.forEach(_24,function(v){
_25[v.segmentCode]=1;
});
var fo=[];
dojo.forEach(this.ops,function(v){
if(v.o.segmentCode in _25){
fo.push(v);
}else{
delete v.selected;
}
});
this.filteredOps=fo;
}
this.onSearch(this.searchCtrl.attr("value"));
this.onChange();
}});
dojo.declare("Px.Ex.BuyReport.StatusFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.statuses){
var b=this.data.statuses;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.value+"",label:v.label,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._statusesInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showStatusesInFilter"))();
}});
dojo.declare("Px.Ex._CheckedMultiSelectItem",[dojox.form._CheckedMultiSelectItem],{itemSelected:false,postMixInProperties:function(){
this.readOnly=this.option.readOnly=this.option.readOnly||false;
this.inherited(arguments);
},_onClick:function(e){
if(!e.shiftKey||!this.parent._anchor||(this.parent._anchor===this)){
if(!e.ctrlKey&&!e.shiftKey){
this.parent.clearItemSelection();
}
this.setItemSelection(!this.itemSelected);
}else{
this.parent.selectItemInterval(this);
}
},setItemSelection:function(sel){
this._selectItem(sel);
if(this.itemSelected){
this.parent._anchor=this;
}else{
delete this.parent._anchor;
}
},_selectItem:function(sel){
this.itemSelected=sel;
dojo.toggleClass(this.domNode,"item-selected",sel);
}});
dojo.declare("Px.Ex.CheckedMultiSelect",[dojox.form.CheckedMultiSelect],{_addOptionItem:function(_26){
var _27=new Px.Ex._CheckedMultiSelectItem({option:_26,parent:this});
dojo.attr(_27.labelNode,"unselectable",true);
this.wrapperDiv.appendChild(_27.domNode);
},clearItemSelection:function(){
dojo.forEach(this._getChildren(),"item.setItemSelection(false);",this);
delete this._anchor;
},selectItemInterval:function(_28){
if(!this._anchor||_28===this._anchor){
return;
}
var _29=this._getChildren();
var _2a=-1;
for(var i=0,len=_29.length;i<len;++i){
if(_2a>=0){
_29[i]._selectItem(true);
if((_29[i]===this._anchor)||(_29[i]===_28)){
this._anchor==_29[i];
break;
}
}
if(_2a==-1&&((_29[i]===this._anchor)||(_29[i]===_28))){
_2a=i;
_29[i]._selectItem(true);
}
}
},hasFirst:function(){
var _2b=this._getChildren();
if(_2b[0].itemSelected){
return false;
}
return dojo.some(_2b,"return item.itemSelected;");
},hasPrev:function(){
var _2c=this._getChildren();
if(_2c[0].itemSelected){
return false;
}
return dojo.some(_2c,"return item.itemSelected;");
},hasNext:function(){
var _2d=this._getChildren();
if(_2d[_2d.length-1].itemSelected){
return false;
}
return dojo.some(_2d,"return item.itemSelected;");
},hasLast:function(){
var _2e=this._getChildren();
if(_2e[_2e.length-1].itemSelected){
return false;
}
return dojo.some(_2e,"return item.itemSelected;");
},first:function(){
var _2f=this._getChildren();
if(_2f[0].itemSelected){
return;
}
var _30=0;
var _31=false;
for(var i=1,len=_2f.length;i<len;++i){
if(_2f[i].itemSelected){
if(_30==0){
_30=i;
}
dojo.place(_2f[i].domNode,_2f[i-_30].domNode,"before");
var _32=_2f.splice(i,1);
_2f.splice(i-_30,0,_32[0]);
_32=this.options.splice(i,1);
this.options.splice(i-_30,0,_32[0]);
if(!_31){
dijit.scrollIntoView(_2f[i-_30].domNode);
_31=true;
}
}
}
},prev:function(){
var _33=this._getChildren();
if(_33[0].itemSelected){
return;
}
var _34=false;
for(var i=1,len=_33.length;i<len;++i){
if(_33[i].itemSelected){
dojo.place(_33[i].domNode,_33[i-1].domNode,"before");
var _35=_33.splice(i,1);
_33.splice(i-1,0,_35[0]);
_35=this.options.splice(i,1);
this.options.splice(i-1,0,_35[0]);
if(!_34){
dijit.scrollIntoView(_33[i-1].domNode);
_34=true;
}
}
}
},next:function(){
var _36=this._getChildren();
if(_36[_36.length-1].itemSelected){
return;
}
var _37=false;
for(var i=_36.length-1;i>=0;--i){
if(_36[i].itemSelected){
dojo.place(_36[i].domNode,_36[i+1].domNode,"after");
var _38=_36.splice(i,1);
_36.splice(i+1,0,_38[0]);
_38=this.options.splice(i,1);
this.options.splice(i+1,0,_38[0]);
if(!_37){
dijit.scrollIntoView(_36[i+1].domNode);
_37=true;
}
}
}
},last:function(){
var _39=this._getChildren();
if(_39[_39.length-1].itemSelected){
return;
}
var _3a=0;
var _3b=false;
for(var i=_39.length-1;i>=0;--i){
if(_39[i].itemSelected){
if(_3a==0){
_3a=_39.length-1-i;
}
dojo.place(_39[i].domNode,_39[i+_3a].domNode,"after");
var _3c=_39.splice(i,1);
_39.splice(i+_3a,0,_3c[0]);
_3c=this.options.splice(i,1);
this.options.splice(i+_3a,0,_3c[0]);
if(!_3b){
dijit.scrollIntoView(_39[i+_3a].domNode);
_3b=true;
}
}
}
}});
dojo.declare("Px.Ex.BuyReport.FieldDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
this.filteredOps=this.ops=this._getOps();
this.createContent();
setTimeout(dojo.hitch(this,"onChange"),0);
},_makeSelectControl:function(){
var ch=new Px.Ex.CheckedMultiSelect({multiple:"true",options:this.filteredOps,onChange:dojo.hitch(this,"onChange")});
return ch;
},_addSearchControl:function(_3d){
var div,_3e,c=dojo.create;
_3e=c("span",{className:"button-layout"},_3d);
div=c("div",{className:"dijitInline btn-first unselectable",unselectable:true},_3e);
this.connect(div,"onclick","first");
div=c("div",{className:"dijitInline btn-up unselectable",unselectable:true},_3e);
this.connect(div,"onclick","prev");
div=c("div",{className:"dijitInline btn-down unselectable",unselectable:true},_3e);
this.connect(div,"onclick","next");
div=c("div",{className:"dijitInline btn-last unselectable",unselectable:true},_3e);
this.connect(div,"onclick","last");
div=c("div",{className:"dijitInline"},_3e);
this.searchCtrl.placeAt(div);
},_preventMove:function(){
return this.searching||(this.searchCtrl.attr("value")!="");
},first:function(){
if(this._preventMove()){
return;
}
if(!this.ch.hasFirst()){
return;
}
this.ch.first();
this.onChange();
},prev:function(){
if(this._preventMove()){
return;
}
if(!this.ch.hasPrev()){
return;
}
this.ch.prev();
this.onChange();
},next:function(){
if(this._preventMove()){
return;
}
if(!this.ch.hasNext()){
return;
}
this.ch.next();
this.onChange();
},last:function(){
if(this._preventMove()){
return;
}
if(!this.ch.hasLast()){
return;
}
this.ch.last();
this.onChange();
},_getOps:function(){
var ops=[];
if(this.data.fields){
var b=this.data.fields;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.value+"",label:v.label,selected:v.selected,readOnly:v.readOnly,o:v};
});
}
return ops;
},onChange:function(val){
if(this.searching){
return;
}
this.parent._fieldsInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showFieldsInFilter"))();
},clear:function(){
var ops=dojo.filter(this.ch.getOptions(),function(v){
if(!v.readOnly){
v.selected=false;
}
return v.selected;
},this);
this.ch.attr("value",ops);
},clearFilter:function(){
this.clear();
dojo.forEach(this.filteredOps,"if (!item.readOnly) item.selected = false;");
this.onChange();
},reset:function(){
this.filteredOps=this.ops=this._getOps();
if(this.searchCtrl.attr("value")!=""){
this.searchCtrl.clearValue();
}else{
this.onSearch("");
}
this.clearFilter();
}});
dojo.declare("Px.Ex.DirectBuysReportScreen",[Px.Ex.XhrMixin],{SEGMENTS:1,BUYERS:2,STATUSES:3,FIELDS:4,draw:function(){
this._segmentsInFilter=[];
this._buyersInFilter=[];
this._statusesInFilter=[];
this._fieldsInFilter=[];
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/branded-tabs/direct-buys-report-screen",load:dojo.hitch(this,"createScreen"),handleAs:"json"});
},createScreen:function(_1,_2){
dojo.empty("divContent");
if(_1.accessDenied){
dojo.byId("divContent").innerHTML=_1.accessDenied;
return;
}
this.data=_1;
if(this.data.segments&&!this.data.segments["return"]){
Px.Ex.Application.showGlobalError(this.data.segments,_2);
}
if(this.data.buyers&&!this.data.buyers["return"]){
Px.Ex.Application.showGlobalError(this.data.buyers,_2);
}
var _3,_4,tr,td,_5,c=dojo.create;
this.NOW=dojo.date.stamp.fromISOString(_1.now);
this.NOW.setHours(0,0,0,0);
this.dateFilter=new Px.Ex.ReportDateFilter({NOW:this.NOW,messages:this.data.messages});
this._c=new dijit.layout.ContentPane({"class":"performance-report buy-details"}).placeAt("divContent");
this.createFilter();
_5=c("div",{className:"buttons"},this._c.containerNode);
_3=c("table",{},_5);
_4=c("tbody",{},_3);
tr=c("tr",{},_4);
td=c("td",{},tr);
_5=c("div",{className:"button-reset"},td);
this._c.connect(_5,"onclick",dojo.hitch(this,"resetFilter"));
td=c("td",{},tr);
_5=c("div",{className:"button-run"},td);
this._c.connect(_5,"onclick",dojo.hitch(this,"showReport"));
this.createGridToolbar();
this.reportDiv=c("div",{className:"report"},this._c.containerNode);
},resetFilter:function(){
this.form.reset();
this.filter.reset();
this.dateFilter.update();
this._segmentsInFilter.length=0;
this._buyersInFilter.length=0;
this._statusesInFilter.length=0;
this.segmentFilterButton.dropDown.clearFilter();
this.buyerFilterButton.dropDown.clearFilter();
this.statusFilterButton.dropDown.clearFilter();
this.fieldFilterButton.dropDown.reset();
},showReport:function(){
var o=this.getParams();
if(!o){
return;
}
this._showReport(o);
},getParams:function(){
if(!this.form.isValid()){
this.filter.attr("open",true);
this._timer=setTimeout(dojo.hitch(this.form,"validate"),this.filter.attr("duration"));
return null;
}
var o=this.form.attr("value");
if(o.timeGroupBy=="none"){
delete o.timeGroupBy;
}
o.publisherCode=this.data.publisherCode;
o.start=dojo.date.stamp.toISOString(o.start,{zulu:false,milliseconds:false}).slice(0,19);
o.end=dojo.clone(o.end);
o.end.setHours(23,59,59);
o.end=dojo.date.stamp.toISOString(o.end,{zulu:false,milliseconds:false}).slice(0,19);
o.showTotals=this.showTotals.checked?1:0;
if(this._segmentsInFilter.length){
o.segmentIds=dojo.map(this._segmentsInFilter,"return item.channelDisplayCode;").join(",");
}
if(this._buyersInFilter.length){
o.buyerIds=dojo.map(this._buyersInFilter,"return item.buyerCode;").join(",");
}
if(this._statusesInFilter.length){
o.statusIds=dojo.map(this._statusesInFilter,"return item.value;").join(",");
}
if(this._fieldsInFilter.length){
o.fields=dojo.map(this._fieldsInFilter,"return item.id;").join("a");
}
return o;
},_showReport:function(_6){
dojo.removeClass(this.gridToolbar,"texi-hidden");
this._setUpperScroll(false);
this._removeExpandRightButton();
dojo.empty(this.reportDiv);
this.reportDiv.innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/branded-tabs/direct-buys-report-report",content:_6,load:dojo.hitch(this,function(_7){
dojo.empty(this.reportDiv);
this.reportDiv.innerHTML=_7;
$("#tableReport").addClass("tablesorter");
$("#tableReport").tablesorter({});
this._setContainerHeight();
this._setUpperScroll(true);
this._addExpandRightButton();
}),error:dojo.hitch(this,function(_8){
this.reportDiv.innerHTML=Px.Ex.Application._extractError(_8);
dojo.addClass(this.gridToolbar,"texi-hidden");
})});
},_hasScroll:function(){
if(!dojo.byId("tableReport")){
return false;
}
var _9=dojo.isChrome?1:0;
return (dojo.contentBox("reportContainer").w<dojo.marginBox("tableReport").w-_9);
},_expandCollapseGrid:function(){
if(!dojo.byId("tableReport")){
return;
}
var _a=dojo.style("tableReport","position");
_a=(_a=="absolute"?"":"absolute");
var w=(_a=="absolute"?"auto":"99.9%");
if(_a=="absolute"){
if(!this._hasScroll()){
return;
}
dojo.byId("reportContainer").scrollLeft=0;
this._setUpperScroll(false);
}else{
this._setUpperScroll(true);
}
dojo.style("tableReport",{position:_a,width:w});
if(_a=="absolute"){
this._setContainerHeight();
this._moveButton(true);
}else{
this._moveButton(false);
}
},_moveButton:function(_b){
if(!this.expandGridRightButton){
return;
}
this.right=!!_b;
if(_b){
var m=dojo.marginBox("tableReport");
var c=dojo.contentBox("tableReport");
var _c=dojo.isIE?2:(dojo.isFF?1:1);
var _d=dojo.isFF?1:2;
dojo.marginBox(this.expandGridRightButton,{l:m.l+m.w,t:m.t+_d,h:c.h+_c});
}else{
var _c=dojo.isFF?1:2;
if(dojo.isIE){
var m0=dojo.marginBox(dojo.query(".texi_container")[0]);
var m1=dojo.marginBox(dojo.query(".texi_content_container")[0]);
var m2=dojo.marginBox(dojo.query(".buy-details")[0]);
var m=dojo.marginBox("reportContainer");
var c=dojo.contentBox("reportContainer");
m.l+=m0.l+m1.l+m2.l;
m.t+=m0.t+m1.t+m2.t;
dojo.marginBox(this.expandGridRightButton,{l:m.l+m.w-1,t:m.t+_c,h:c.h-_c});
}else{
var m=dojo.marginBox("reportContainer");
var c=dojo.contentBox("reportContainer");
dojo.marginBox(this.expandGridRightButton,{l:m.l+m.w,t:m.t+_c,h:c.h-_c});
}
}
dojo.attr(this.expandGridRightButton,"title",(_b?"Collapse grid":"Expand grid"));
dojo.toggleClass(this.expandGridRightButton,"right",_b);
},_addExpandRightButton:function(){
if(!this._hasScroll()){
return;
}
var m=this.data.messages;
var b=this.expandGridRightButton=dojo.create("div",{className:"expand-collapse-grid-right",title:m["REP05_Tooltip_ExpandGridToRight"]},"reportContainer","after");
var hh=this._right_button_handlers=[];
hh.push(dojo.connect(b,"onclick",this,"_expandCollapseGrid"));
hh.push(dojo.connect(b,"onmouseenter",this,function(){
dojo.addClass(this.expandGridRightButton,"active");
}));
hh.push(dojo.connect(b,"onmouseleave",this,function(){
dojo.removeClass(this.expandGridRightButton,"active");
}));
hh.push(dojo.connect(window,"onresize",this,function(){
if(this.right!==undefined){
this._moveButton(this.right);
}
}));
this._moveButton(false);
},_removeExpandRightButton:function(){
if(!this.expandGridRightButton){
return;
}
if(this._right_button_handlers){
dojo.forEach(this._right_button_handlers,dojo.disconnect,this);
delete this._right_button_handlers;
}
dojo.destroy(this.expandGridRightButton);
delete this.expandGridRightButton;
delete this.right;
},_setContainerHeight:function(){
if(!dojo.byId("tableReport")){
return;
}
var o=dojo.marginBox("tableReport");
var o2=dojo.contentBox("reportContainer");
o2.h=o.h;
dojo.contentBox("reportContainer",o2);
},_removeExpandRightButton:function(){
if(!this.expandGridRightButton){
return;
}
if(this._right_button_handlers){
dojo.forEach(this._right_button_handlers,dojo.disconnect,this);
delete this._right_button_handlers;
}
dojo.destroy(this.expandGridRightButton);
delete this.expandGridRightButton;
delete this.right;
},_setUpperScroll:function(_e){
if(!dojo.byId("tableReport")){
return;
}
var _f=dojo.isIE?18:17;
dojo.marginBox("aboveReportContent",{w:dojo.marginBox("tableReport").w,h:_f});
dojo.contentBox("aboveReport",{h:_f});
if((_e)&&(this._hasScroll())){
if(!this.canFitInViewPort()){
dojo.byId("aboveReport").style.visibility="visible";
}else{
dojo.byId("aboveReport").style.visibility="hidden";
}
this._bindScrollBars(true);
}else{
dojo.byId("aboveReport").style.visibility="hidden";
this._bindScrollBars(false);
}
},_bindScrollBars:function(_10){
if(_10){
if(!dojo.byId("tableReport")){
return;
}
var c=this._scroll_connections=[];
this._scroll_connections.push(dojo.connect(dojo.byId("aboveReport"),"onscroll",this,function(e){
if(this._bottom_scrolling){
return;
}
this._top_scrolling=true;
dojo.byId("reportContainer").scrollLeft=dojo.byId("aboveReport").scrollLeft;
delete this._top_scrolling;
}));
this._scroll_connections.push(dojo.connect(dojo.byId("reportContainer"),"onscroll",this,function(e){
if(this._top_scrolling){
return;
}
this._bottom_scrolling=true;
dojo.byId("aboveReport").scrollLeft=dojo.byId("reportContainer").scrollLeft;
delete this._bottom_scrolling;
}));
}else{
if(!this._scroll_connections){
return;
}
dojo.forEach(this._scroll_connections,dojo.disconnect,this);
delete this._scroll_connections;
}
},canFitInViewPort:function(){
if(!dojo.byId("tableReport")){
return false;
}
var _11=dojo.marginBox(dojo.byId("tableReport"));
var _12=_11.h;
var _13=dijit.getViewport();
var _14=_13.h;
return (_14>=_12)?true:false;
},createFilter:function(){
var _15,_16,tr,td,div,c=dojo.create;
var m=this.data.messages;
this.filter=new Px.Ex.TitlePane({open:true,duration:500,title:m["REP05_Title_ReportParameters"],"class":"filter-pane"}).placeAt(this._c.containerNode);
this.form=new Px.Ex.Form({withReadOnly:true}).placeAt(this.filter.containerNode);
var _17=this.form.domNode;
div=c("div",{className:"dates-main-layout"},_17);
this.dateFilter.create(div);
div=c("div",{className:"fields-main-layout"},_17);
this._createFieldsFilter(div);
this.dateFilter.update();
},createGridToolbar:function(){
var _18,_19,tr,td,div,c=dojo.create;
var m=this.data.messages;
this.gridToolbar=c("div",{className:"grid-toolbar texi-hidden"},this._c.containerNode);
_18=c("table",{className:"layout"},this.gridToolbar);
_19=c("tbody",{},_18);
tr=c("tr",{},_19);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button excel unselectable",unselectable:true,title:m["REP05_Tooltip_GridToolbar_ExportExcel"],id:"divDirectBuysReportExcelButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button pdf unselectable",unselectable:true,title:m["REP05_Tooltip_GridToolbar_ExportPDF"],id:"divDirectBuysReportPdfButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button xml unselectable",unselectable:true,title:m["REP05_Tooltip_GridToolbar_ExportXML"],id:"divDirectBuysReportXmlButton"},td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"tool-button print unselectable",unselectable:true,title:m["REP05_Tooltip_GridToolbar_ExportPrint"],id:"divDirectBuysReportPrintButton"},td);
this.gridToolbarObj=new Px.Ex.GridToolbar({tag:"DirectBuysReport",title:m["REP05_Title_ExportedReport"],file:"direct_buys_report",url:"/report/export",htmlContentNode:"reportContainer",dateSelectNode:"tableReportTitle",xmlContentNode:"tableReportRaw"});
this.gridToolbarObj.bind();
this._c.connect(this.gridToolbar,"onmousedown",dojo.hitch(this,function(e){
var _1a=e.target;
if((dojo.isIE&&e.button==1||e.button==0)&&dojo.hasClass(_1a,"tool-button")){
dojo.addClass(_1a,"active");
}
}));
this._c.connect(this.gridToolbar,"onmouseup",dojo.hitch(this,function(e){
var _1b=e.target;
if((dojo.isIE&&e.button==1||e.button==0)&&dojo.hasClass(_1b,"tool-button")){
dojo.removeClass(_1b,"active");
var o=this.getParams();
dojo.byId("tableReportTitle").innerHTML=o.start.slice(0,10)+" - "+o.end.slice(0,10);
}
}));
},_createFieldsFilter:function(_1c){
var _1d,_1e,tr,td,div,c=dojo.create;
var m=this.data.messages;
_1d=c("table",{className:"layout"},_1c);
_1e=c("tbody",{},_1d);
tr=c("tr",{},_1e);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m["REP05_Title_Segments"]},td);
td=c("td",{className:"vmiddle"},tr);
this.segmentFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.SEGMENTS)});
this.segmentFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"filter-clear-button"},td);
this._c.connect(div,"onclick",dojo.hitch(this,function(){
this._segmentsInFilter.length=0;
this._showSegmentsInFilter();
this.segmentFilterButton.dropDown.clearFilter();
}));
td=c("td",{style:{width:"100%"}},tr);
this.segmentNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m["REP05_NoFilterApplied"],onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.segmentNames.attr("value"),this.segmentNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.segmentNames.domNode);
})});
this.segmentNames.placeAt(td);
tr=c("tr",{className:"vspacer"},_1e);
tr=c("tr",{},_1e);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m["REP05_Title_Buyers"]},td);
td=c("td",{className:"vmiddle"},tr);
try{
this.buyerFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.BUYERS)});
}
catch(e){
alert(e.message);
}
this.buyerFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"filter-clear-button"},td);
this._c.connect(div,"onclick",dojo.hitch(this,function(){
this._buyersInFilter.length=0;
this._showBuyersInFilter();
this.buyerFilterButton.dropDown.clearFilter();
}));
td=c("td",{style:{width:"99%"},className:"vmiddle"},tr);
this.buyerNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m["REP05_NoFilterApplied"],onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.buyerNames.attr("value"),this.buyerNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.buyerNames.domNode);
})});
this.buyerNames.placeAt(td);
tr=c("tr",{className:"vspacer"},_1e);
tr=c("tr",{},_1e);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m["REP05_Title_Statuses"]},td);
td=c("td",{className:"vmiddle"},tr);
this.statusFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.STATUSES)});
this.statusFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"filter-clear-button"},td);
this._c.connect(div,"onclick",dojo.hitch(this,function(){
this._statusesInFilter.length=0;
this._showStatusesInFilter();
this.statusFilterButton.dropDown.clearFilter();
}));
td=c("td",{style:{width:"99%"},className:"vmiddle"},tr);
this.statusNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",value:m["REP05_NoFilterApplied"],onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.statusNames.attr("value"),this.statusNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.statusNames.domNode);
})});
this.statusNames.placeAt(td);
tr=c("tr",{className:"vspacer"},_1e);
tr=c("tr",{},_1e);
td=c("td",{className:"vmiddle",colSpan:6},tr);
c("div",{className:"separator"},td);
tr=c("tr",{className:"vspacer"},_1e);
tr=c("tr",{className:"fields"},_1e);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m["REP05_Title_Fields"]},td);
td=c("td",{className:"vmiddle"},tr);
this.fieldFilterButton=new dijit.form.DropDownButton({"class":"filter-button",dropDown:this._createDropDown(this.FIELDS)});
this.fieldFilterButton.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
div=c("div",{className:"filter-clear-button"},td);
this._c.connect(div,"onclick",dojo.hitch(this,function(){
this.fieldFilterButton.dropDown.clearFilter();
}));
td=c("td",{style:{},className:"vmiddle"},tr);
_1d=c("table",{},td),_1e=c("tbody",{},_1d);
tr=c("tr",{},_1e);
td=c("td",{},tr);
this.fieldNames=new dijit.form.TextBox({readOnly:true,"class":"filter-names",style:"width: 630px;",value:m["REP05_NoFilterApplied"],onMouseEnter:dojo.hitch(this,function(){
dijit.showTooltip(this.fieldNames.attr("value"),this.fieldNames.domNode,["above","below"]);
}),onMouseLeave:dojo.hitch(this,function(){
dijit.hideTooltip(this.fieldNames.domNode);
}),reset:function(){
}});
this.fieldNames.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
this.showTotals=new dijit.form.CheckBox({checked:false,"class":"filter-groupby",name:"showTotals",value:"dontShowTotals"});
this.showTotals.placeAt(td);
td=c("td",{className:"vmiddle"},tr);
c("label",{className:"label unselectable",unselectable:true,"for":"",innerHTML:m["REP05_Title_ShowTotals"]},td);
},_createDropDown:function(_1f){
var fn=null;
if(_1f==this.SEGMENTS){
fn=Px.Ex.DirectBuysReport.SegmentFilterDialog;
}else{
if(_1f==this.BUYERS){
fn=Px.Ex.DirectBuysReport.BuyerFilterDialog;
}else{
if(_1f==this.STATUSES){
fn=Px.Ex.DirectBuysReport.StatusFilterDialog;
}else{
if(_1f==this.FIELDS){
fn=Px.Ex.DirectBuysReport.FieldDialog;
}
}
}
}
var dlg=new fn({parent:this,data:this.data});
dlg.startup();
return dlg;
},_showInFilter:function(arr,_20,_21){
var m=this.data.messages;
var a;
if(arr.length){
a=dojo.map(arr,function(v){
return v[_20];
});
}else{
a=[m["REP05_NoFilterApplied"]];
}
_21.attr("value",a.join(", "));
},_showSegmentsInFilter:function(){
this._showInFilter(this._segmentsInFilter,"channelName",this.segmentNames);
},_showBuyersInFilter:function(){
this._showInFilter(this._buyersInFilter,"buyerName",this.buyerNames);
},_showStatusesInFilter:function(){
this._showInFilter(this._statusesInFilter,"label",this.statusNames);
},_showFieldsInFilter:function(){
this._showInFilter(this._fieldsInFilter,"label",this.fieldNames);
},destroy:function(){
try{
clearTimeout(this._timer);
}
catch(e){
}
try{
if(this._c){
this._c.destroyRecursive();
}
}
catch(e){
}
try{
this.buyerFilterButton.destroyRecursive();
}
catch(e){
}
try{
this.buyerNames.destroyRecursive();
}
catch(e){
}
try{
dojo.destroy(this.dateFilter);
}
catch(e){
}
try{
this.fieldFilterButton.destroyRecursive();
}
catch(e){
}
try{
this.fieldNames.destroyRecursive();
}
catch(e){
}
try{
this.filter.destroyRecursive();
}
catch(e){
}
try{
this.form.destroyRecursive();
}
catch(e){
}
try{
dojo.destroy(this.gridToolbar);
}
catch(e){
}
try{
dojo.destroy(this.gridToolbarObj);
}
catch(e){
}
try{
dojo.destroy(this.NOW);
}
catch(e){
}
try{
this.segmentFilterButton.destroyRecursive();
}
catch(e){
}
try{
this.segmentNames.destroyRecursive();
}
catch(e){
}
try{
this.showTotals.destroyRecursive();
}
catch(e){
}
try{
this.statusFilterButton.destroyRecursive();
}
catch(e){
}
try{
this.statusNames.destroyRecursive();
}
catch(e){
}
}});
dojo.declare("Px.Ex.DirectBuysReport.SegmentFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.segments&&this.data.segments["return"]&&this.data.segments["return"].segments){
var b=this.data.segments["return"].segments;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.channelDisplayCode+"",label:v.channelName,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._segmentsInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showSegmentsInFilter"))();
}});
dojo.declare("Px.Ex.DirectBuysReport.BuyerFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.buyers&&this.data.buyers["return"]){
var b=this.data.buyers["return"].buyers;
if(b!=undefined){
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.buyerCode+"",label:v.buyerName,o:v};
});
}
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._buyersInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showBuyersInFilter"))();
}});
dojo.declare("Px.Ex.DirectBuysReport.StatusFilterDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.statuses){
var b=this.data.statuses;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.value+"",label:v.label,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.parent._statusesInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showStatusesInFilter"))();
}});
dojo.declare("Px.Ex.DirectBuysReport.FieldDialog",[dijit.TooltipDialog,Px.Ex.FilterDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
this.filteredOps=this.ops=this._getOps();
this.createContent();
setTimeout(dojo.hitch(this,"onChange"),0);
},_makeSelectControl:function(){
var ch=new Px.Ex.CheckedMultiSelect({multiple:"true",options:this.filteredOps,onChange:dojo.hitch(this,"onChange")});
return ch;
},_addSearchControl:function(_22){
var div,_23,c=dojo.create;
_23=c("span",{className:"button-layout"},_22);
div=c("div",{className:"dijitInline btn-first unselectable",unselectable:true},_23);
this.connect(div,"onclick","first");
div=c("div",{className:"dijitInline btn-up unselectable",unselectable:true},_23);
this.connect(div,"onclick","prev");
div=c("div",{className:"dijitInline btn-down unselectable",unselectable:true},_23);
this.connect(div,"onclick","next");
div=c("div",{className:"dijitInline btn-last unselectable",unselectable:true},_23);
this.connect(div,"onclick","last");
div=c("div",{className:"dijitInline"},_23);
this.searchCtrl.placeAt(div);
},_preventMove:function(){
return this.searching||(this.searchCtrl.attr("value")!="");
},first:function(){
if(this._preventMove()){
return;
}
if(!this.ch.hasFirst()){
return;
}
this.ch.first();
this.onChange();
},prev:function(){
if(this._preventMove()){
return;
}
if(!this.ch.hasPrev()){
return;
}
this.ch.prev();
this.onChange();
},next:function(){
if(this._preventMove()){
return;
}
if(!this.ch.hasNext()){
return;
}
this.ch.next();
this.onChange();
},last:function(){
if(this._preventMove()){
return;
}
if(!this.ch.hasLast()){
return;
}
this.ch.last();
this.onChange();
},_getOps:function(){
var ops=[];
if(this.data.fields){
var b=this.data.fields;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.value+"",label:v.label,selected:v.selected,readOnly:v.readOnly,o:v};
});
}
return ops;
},onChange:function(val){
if(this.searching){
return;
}
this.parent._fieldsInFilter=this.getSelected();
(dojo.hitch(this.parent,"_showFieldsInFilter"))();
},clear:function(){
var ops=dojo.filter(this.ch.getOptions(),function(v){
if(!v.readOnly){
v.selected=false;
}
return v.selected;
},this);
this.ch.attr("value",ops);
},clearFilter:function(){
this.clear();
dojo.forEach(this.filteredOps,"if (!item.readOnly) item.selected = false;");
this.onChange();
},reset:function(){
this.filteredOps=this.ops=this._getOps();
if(this.searchCtrl.attr("value")!=""){
this.searchCtrl.clearValue();
}else{
this.onSearch("");
}
this.clearFilter();
}});
dojo.declare("Px.Ex.ContactDetailsScreen",[Px.Ex.ModalDialogMixin,Px.Ex.XhrMixin],{draw:function(){
this._connections=[];
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/contact-details/screen",load:dojo.hitch(this,function(_1){
dojo.query("#divContent").html(_1);
if(dojo.byId("T4T-CONTACT-PWD")){
this._connections.push(dojo.connect(dojo.byId("T4T-CONTACT-PWD"),"onclick",this,"changePassword"));
}
if(dojo.byId("T4T-CONTACT-EDITMAIN")){
this._connections.push(dojo.connect(dojo.byId("T4T-CONTACT-EDITMAIN"),"onclick",this,"editMainContact"));
}
if(dojo.byId("T4T-CONTACT-EDITBILLING")){
this._connections.push(dojo.connect(dojo.byId("T4T-CONTACT-EDITBILLING"),"onclick",this,"editBillingContact"));
}
if(dojo.byId("T4T-CONTACT-EDITPAY")){
this._connections.push(dojo.connect(dojo.byId("T4T-CONTACT-EDITPAY"),"onclick",this,"editPaymentDetails"));
}
this._addActiveCombo();
})});
},_addActiveCombo:function(){
var _2=dojo.byId("T4T-ACTIVE-TP-EDIT");
if(!_2){
return;
}
var o=dojo.fromJson(_2.innerHTML);
dojo.empty(_2);
if(!o.publisher){
return;
}
dojo.removeClass(_2,"texi-hidden");
var _3=[{id:"P",name:o.publisher}];
if(o.buyer){
_3.push({id:"B",name:o.buyer});
}
var _4=new dojo.data.ItemFileReadStore({data:{identifier:"id",label:"name",items:_3}});
this.combo=new Px.Ex.FilteringSelect({store:_4,value:"P",onChange:dojo.hitch(this,"activeChanged"),readOnly:_3.length<=1});
this.combo.placeAt(_2);
this._currentActive="P";
},activeChanged:function(_5){
if(_5&&_5!=this._currentActive){
this._currentActive=_5;
this._reloadData();
}
},_reloadData:function(){
var _6=this._currentActive=="B";
dojo.toggleClass("T4T-CONTACT-PAYMENT-label","texi-hidden",_6);
dojo.toggleClass("T4T-CONTACT-PAYMENT","texi-hidden",_6);
dojo.toggleClass("T4T-CONTACT-EDITPAY","texi-hidden",_6);
try{
if(this._xhrs){
dojo.forEach(this._xhrs,function(v,i,a){
if(v){
v.cancel();
}
});
}
}
catch(ex){
}
this._xhrs=[];
this._xhrs.push(this.showContactData(true));
this._xhrs.push(this.showContactData(false));
},changePassword:function(){
var _7=dojo.hitch(this,function(_8){
this.setTopCss(100);
Px.Ex.Application.menu.buildDialogSubTitle(Px.Ex.Application.Titles.CHANGE_PASSWORD);
this.xhrLoad({selector:"#divModalDialogContent",url:"/login/change-password-dialog",load:dojo.hitch(this,"bindChangePasswordDialogEvents")});
});
this.modalDialog(_7);
},bindChangePasswordDialogEvents:function(){
setTimeout(function(){
var _9;
try{
_9=dojo.byId("input_old_password");
_9.focus();
}
catch(e){
}
if(dojo.isIE&&document.activeElement!=_9){
setTimeout(arguments.callee,500);
}
},500);
$("#divModalDialog #submit").click(dojo.hitch(this,"validateAndSendChangePassword"));
$("#divModalDialog #cancel").click(function(){
$.modal.impl.close();
});
var fn=dojo.hitch(this,"validateAndSendChangePassword");
dojo.forEach(["#input_old_password","#input_new_password","#input_new_password_verify"],function(v){
$(v).keydown(Px.Ex.Application.enterKeyDown(fn));
});
},validateAndSendChangePassword:function(){
this.clearError();
var _a=$("#input_old_password").val();
var _b=$("#input_new_password").val();
var _c=$("#input_new_password_verify").val();
var _d="";
if(_a.length==0){
_d="Please, type current password!";
}else{
if(_b.length==0){
_d="Please, type new password!";
}else{
if(_c.length==0){
_d="Please, confirm new password!";
}else{
if(_a==_b){
_d="The new password must be different from your current password.";
}else{
if(_b!=_c){
_d="The new password and the confirmation new password don't match.<br/>Please type the same password in both boxes.";
}
}
}
}
}
if(_d){
this.animateErrorMessage(_d);
return false;
}
_a=$.base64Encode(_a);
_b=$.base64Encode(_b);
_c=$.base64Encode(_c);
this.hideDialogContentAndWait(dojo.hitch(this,function(){
this.xhr({url:"/login/change-password",content:{oldPassword:_a,newPassword:_b,newPasswordVerify:_c},handleAs:"json",load:dojo.hitch(this,"changePasswordResponse")});
}));
return false;
},changePasswordResponse:function(_e){
if(_e["return"]&&_e["return"].success){
this.showDialogContentOnSuccess(_e["return"].errorMessage);
}else{
this.showDialogContentOnError(_e);
}
},setLargerCss:function(){
$("#modalContainer").animate({width:"450px",marginLeft:"-225px",top:"10%"},1);
},setMiddleCss:function(){
$("#modalContainer").animate({width:"500px",marginLeft:"-250px"},1);
},editMainContact:function(){
var _f=dojo.hitch(this,function(_10){
this.setLargerCss();
this.setTopCss();
Px.Ex.Application.menu.buildDialogSubTitle(Px.Ex.Application.Titles.MAIN_CONTACT);
this.xhrLoad({selector:"#divModalDialogContent",url:"/contact-details/main-contact-dialog",load:dojo.hitch(this,"bindEditMainContactDialogEvents"),content:{active:this._currentActive||""}});
});
this.modalDialog(_f);
},bindEditMainContactDialogEvents:function(){
var _11=this;
$("#divModalDialog #submit").click(dojo.hitch(_11,"validateAndSendEditContact","main"));
$("#divModalDialog #cancel").click(function(){
$.modal.impl.close();
});
this.handleCountryAndState();
},handleCountryAndState:function(){
var _12=dojo.byId("countryHidden"),_13=dojo.byId("country"),_14=dojo.byId("stateHidden");
if(!_12||!_13||!_14){
return;
}
var _15=_12.value.toUpperCase();
$("#country").val(_15);
var _16=_14.value.toUpperCase();
var _17=dojo.hitch(this,"loadStates",_16);
$("#country").change(_17);
_17();
},loadStates:function(_18){
this.xhrLoad({selector:"#divState",url:"/contact-details/states",content:{country:$("#country").val().toUpperCase()},load:function(){
$("#state").val(_18);
if($("#state").val()!=_18){
$("#state").val("  ");
}
}});
},validateAndSendEditContact:function(_19){
var _1a;
var _1b;
if(_19=="main"){
_1a="/contact-details/update-main-contact";
_1b=$("#contactCode").val();
}else{
_1a="/contact-details/update-billing-contact";
_1b=this.billingContactCode;
}
if(_1b==0){
return;
}
this.clearError();
var _1c=$.trim($("#firstName").val());
var _1d=$.trim($("#lastName").val());
var _1e=$.trim($("#jobTitle").val());
var _1f=$.trim($("#emailAddress").val());
var _20=$.trim($("#landPhone").val());
var _21=$.trim($("#cellPhone").val());
var fax=$.trim($("#fax").val());
var _22=$.trim($("#address").val());
var _23=$.trim($("#city").val());
var _24=$.trim($("#zipCode").val());
var _25="";
var _26=Px.Ex.Application.Patterns.EMAIL;
var _27=Px.Ex.Application.Patterns.PHONE;
if(_1c.length==0){
_25="Please, type first name!";
}else{
if(_1d.length==0){
_25="Please, type last name!";
}else{
if(_1f.search(_26)==-1){
_25="Please, type true email!";
}else{
if(_20&&(_20.search(_27)==-1)){
_25="Please, type true phone number!";
}else{
if(_21&&(_21.search(_27)==-1)){
_25="Please, type true mobile phone number!";
}else{
if(_22.length==0){
_25="Please, type address!";
}else{
if(_23.length==0){
_25="Please, type city!";
}
}
}
}
}
}
}
if(_25){
this.animateErrorMessage(_25);
return;
}
this.hideDialogContentAndWait(dojo.hitch(this,function(){
this.xhr({url:_1a,content:{address:_22,cellPhone:_21,city:_23,contactCode:_1b,country:$("#country").val(),emailAddress:_1f,fax:fax,firstName:_1c,jobTitle:_1e,landPhone:_20,lastName:_1d,middleName:$("#middleName").val(),state:$("#state").val(),suffix:$("#suffix").val(),title:$("#title").val(),zipCode:_24},load:dojo.hitch(this,"editContactResponse",_19),handleAs:"json"});
}));
},editContactResponse:function(_28,_29){
if(_29["return"]&&_29["return"].success){
this.showDialogContentOnSuccess(_28+" contact updated successfully!");
this.showContactData(_28=="main");
}else{
this.showDialogContentOnError(_29);
}
},showContactData:function(_2a){
var div;
var _2b;
if(_2a){
div="T4T-CONTACT-MAIN";
_2b="/contact-details/main-contact";
}else{
div="T4T-CONTACT-BILLING";
_2b="/contact-details/billing-contact";
}
dojo.query("#"+div).html(Px.Ex.Application.getNiceWaitHtml());
return this.xhrLoad({selector:"#"+div,url:_2b,content:{active:this._currentActive||""}});
},editBillingContact:function(){
var _2c=dojo.hitch(this,function(_2d){
this.setLargerCss();
this.setTopCss();
Px.Ex.Application.menu.buildDialogSubTitle(Px.Ex.Application.Titles.BILLING_CONTACT);
this.xhrLoad({selector:"#divModalDialogContent",url:"/contact-details/billing-contact-dialog",load:dojo.hitch(this,"bindEditBillingContactDialogEvents"),content:{active:this._currentActive||""}});
});
this.modalDialog(_2c);
},bindEditBillingContactDialogEvents:function(){
this.billingContactCode=$("#contactCode").val();
var _2e=this;
$("#asMain").click(function(){
var _2f;
if($("#asMain").is(":checked")){
_2f="main";
}else{
_2f="billing";
}
$("#divContactPanel").fadeOut("slow",function(){
$("#divContactPanelLoading").empty().append(Px.Ex.Application.getWaitHtml()).fadeIn("slow",function(){
_2e.xhrLoad({selector:"#divContactPanel",url:"/contact-details/contact-panel",content:{contactType:_2f,active:this._currentActive||""},load:function(){
_2e.handleCountryAndState();
$("#divContactPanelLoading").fadeOut("slow",function(){
$("#divContactPanel").fadeIn("slow",function(){
$("#asMain").attr("disabled",false);
});
}).empty();
}});
$(this).attr("disabled",true);
});
});
});
$("#divModalDialog #submit").click(dojo.hitch(_2e,"validateAndSendEditContact","billing"));
$("#divModalDialog #cancel").click(function(){
$.modal.impl.close();
});
this.handleCountryAndState();
},editPaymentDetails:function(){
var _30=dojo.hitch(this,function(_31){
this.setMiddleCss();
this.setTopCss();
Px.Ex.Application.menu.buildDialogSubTitle(Px.Ex.Application.Titles.PAYMENT_DETAILS);
this.xhrLoad({selector:"#divModalDialogContent",url:"/contact-details/payment-details-dialog",load:dojo.hitch(this,"bindEditPaymentDetailsDialogEvents")});
});
this.modalDialog(_30);
},bindEditPaymentDetailsDialogEvents:function(){
var _32=$("#paymentMethodCode").val();
$("#payment_methods").val(_32);
var _33=this;
$("#divModalDialog #submit").click(dojo.hitch(_33,"validateAndSendEditPaymentDetails"));
$("#divModalDialog #cancel").click(function(){
$.modal.impl.close();
});
},validateAndSendEditPaymentDetails:function(){
if($("#divModalDialog #paymentMethodCode").val()==0){
return;
}
this.clearError();
this.hideDialogContentAndWait(dojo.hitch(this,function(){
this.xhr({url:"/contact-details/update-payment-details",content:{paymentInstructions:$("#payment_instructions").val(),paymentMethodCode:$("#payment_methods").val()},handleAs:"json",load:dojo.hitch(this,"editPaymentDetailsResponse")});
}));
},editPaymentDetailsResponse:function(_34){
if(_34["return"]&&_34["return"].success){
this.showDialogContentOnSuccess("payment details updated successfully!");
var div="T4T-CONTACT-PAYMENT";
var _35="/contact-details/publisher-payment";
dojo.query("#"+div).html(Px.Ex.Application.getNiceWaitHtml());
this.xhrLoad({selector:"#"+div,url:_35});
}else{
this.showDialogContentOnError(_34);
}
},destroy:function(){
this.cancelXhr();
if(this.combo){
this.combo.destroyRecursive();
delete this.combo;
}
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
}
}});
dojo.declare("Px.Ex.SettingsScreen",[Px.Ex.XhrMixin],{constructor:function(){
this._connections=[];
},draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/settings/screen",load:dojo.hitch(this,function(_1){
dojo.query("#divContent").html(_1);
var _2=dojo.byId("T4T-ACTIVE-TP-EDIT");
if(_2){
this._connections.push(dojo.connect(_2,"onclick",this,"editSettings"));
}
var _3=dojo.byId("T4T-RELOAD-SEC");
if(_3){
this._connections.push(dojo.connect(_3,"onclick",this,"reloadSecurity"));
}
})});
},editSettings:function(){
if(!Px.Ex.Application.allowEditSettings()){
return;
}
var _4=new Px.Ex.SettingsDialog({callback:dojo.hitch(this,"editSettingsCallback")});
_4.show();
},editSettingsCallback:function(_5,_6){
var _7=dojo.byId("T4T-ACTIVE-TB");
if(_7){
_7.innerHTML=_5;
}
if(_6!=""){
var _8=dojo.byId("T4T-ACTIVE-TP");
if(_8){
_8.innerHTML=_6;
}
}
},reloadSecurity:function(){
dojo.style(dojo.byId("T4T-RELOAD-SEC"),"display","none");
dojo.byId("reloadSecurityMessage").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/settings/reload-security",handleAs:"json",load:dojo.hitch(this,function(_9){
var _a;
if(_9&&_9["return"]){
_a=_9["return"].errorMessage;
if(!_a&&!_9["return"].success){
_a="UNKNOWN ERROR";
}
if(_a==undefined){
_a="";
}
}else{
_a="UNKNOWN ERROR";
}
dojo.byId("reloadSecurityMessage").innerHTML=_a;
dojo.style(dojo.byId("T4T-RELOAD-SEC"),"display","");
}),error:function(_b){
dojo.byId("reloadSecurityMessage").innerHTML=_b.message||dojo.toJson(_b);
dojo.style(dojo.byId("T4T-RELOAD-SEC"),"display","");
}});
},destroy:function(){
dojo.forEach(this._connections,dojo.disconnect,this);
}});
dojo.declare("Px.Ex.SettingsDialog",[Px.Ex.Dialog],{callback:undefined,"class":"settings-dialog",withMessage:false,requireBuyer:false,requirePublisher:false,autofocus:false,constructor:function(){
this.rotationImage=Px.Ex.Application.getWaitImageUrl();
},startup:function(){
this.inherited(arguments);
var _1=Px.Ex.Application.Titles.EDIT_SETTINGS;
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(_1);
this.attr("content",Px.Ex.Application.getWaitHtml());
this.xhr({url:"/settings/settings-dialog",load:dojo.hitch(this,"createContent"),error:dojo.hitch(this,"showError"),handleAs:"json"});
},createContent:function(_2){
if(_2.error){
this.destroy();
return;
}
this.data=_2;
var h={};
dojo.forEach(_2.networks,function(v){
h[v.networkCode]=dojo.clone(v);
});
this.networksHash=h;
var m=_2.messages;
var _3,_4,tr,td,_5,c=dojo.create;
_3=c("table",{className:"layout"});
_4=c("tbody",{},_3);
if(this.withMessage&&this.requireBuyer&&!this.requirePublisher){
tr=c("tr",{},_4);
td=c("td",{className:"message",innerHTML:m.dialogMessage1},tr);
}
if(this.withMessage&&!this.requireBuyer&&this.requirePublisher){
tr=c("tr",{},_4);
td=c("td",{className:"message",innerHTML:m.dialogMessage2},tr);
}
tr=c("tr",{},_4);
td=c("td",{className:"cell"},tr);
c("label",{innerHTML:m.labelPublisher||"Active T-Pub:",className:"label","for":"settingsLivePublishersId"},td);
tr=c("tr",{},_4);
td=c("td",{className:"cell"},tr);
this.publishersStore=new dojo.data.ItemFileReadStore({data:{identifier:"publisherCode",items:_2.livePublishers}});
var _6=new Px.Ex.FilteringSelect({store:this.publishersStore,id:"settingsLivePublishersId",name:"publisherCode",searchAttr:"publisherName",required:this.requirePublisher,trim:true,"class":"publisher-name",value:_2.publisherCode,invalidMessage:m.invalidPublisherName||"$_unset_$",emptyMessage:m.emptyPublisherName||"$_unset_$",promptMessage:m.promptPublisherName||""});
_6.placeAt(td);
tr=c("tr",{},_4);
td=c("td",{className:"v-space",colSpan:2},tr);
tr=c("tr",{},_4);
td=c("td",{className:"cell"},tr);
c("label",{innerHTML:m.labelNetwork||"Active Data Buyer:",className:"label","for":"settingsNetworksId"},td);
tr=c("tr",{},_4);
td=c("td",{className:"cell"},tr);
this.networksStore=new dojo.data.ItemFileReadStore({data:{identifier:"networkCode",items:_2.networks}});
var _7=new Px.Ex.FilteringSelect({store:this.networksStore,id:"settingsNetworksId",name:"networkCode",searchAttr:"networkName",required:this.requireBuyer,trim:true,"class":"network-name",value:_2.networkCode,invalidMessage:m.invalidNetworkName||"$_unset_$",emptyMessage:m.emptyNetworkName||"$_unset_$",promptMessage:m.promptNetworkName||""});
_7.placeAt(td);
tr=c("tr",{},_4);
this.errorMessageTd=c("td",{className:"error-message"},tr);
tr=c("tr",{},_4);
td=c("td",{style:{textAlign:"center"}},tr);
var _8,_9,_a,_b,_c;
_8=c("table",{className:"button-layout"},td);
_9=c("tbody",{},_8);
_a=c("tr",{},_9);
_b=c("td",{},_a);
_c=c("div",{className:"cancel-button"},_b);
this.connect(_c,"onclick","onCancel");
_b=c("td",{},_a);
_c=c("div",{className:"save-button"},_b);
this.connect(_c,"onclick","onSave");
this.attr("content",_3);
this.connect(_3,"onkeydown",dojo.hitch(this,function(e){
if((e.keyCode==dojo.keys.ENTER||e.keyCode==dojo.keys.NUMPAD_ENTER)&&e.target.type!="textarea"){
setTimeout(dojo.hitch(this,"onSave"),10);
}
}));
if(this.requireBuyer){
this.componentFocus(_7);
}else{
if(this.requirePublisher){
this.componentFocus(_6);
}else{
this.firstFocus();
}
}
},onSave:function(){
dojo.empty(this.errorMessageTd);
if(!this.validateWidgets(this)){
return;
}
var o=this.getValueObject(this);
o.network=dojo.toJson(o.networkCode?this.networksHash[o.networkCode]:null);
var _d=networkChanged=false;
if(o.publisherCode!=this.data.publisherCode){
_d=true;
}
if(o.networkCode!=this.data.networkCode){
networkChanged=true;
}
if(!_d&&!networkChanged){
return;
}
this.showRotation(true);
this.stopClosing(true);
this.xhr({url:"/settings/save-settings",content:o,load:dojo.hitch(this,"onSaveSuccess",_d,networkChanged),error:dojo.hitch(this,"onSaveError"),handleAs:"json"});
},onSaveSuccess:function(_e,_f,_10){
this.showRotation(false);
this.stopClosing(false);
var _11=_10.network?_10.network.buyerName:"";
var _12=_10.network?_10.network.buyerID:0;
var _13=_12!=this.data.buyerID;
var _14=_10.publisherResult.publisherChanged;
var _15="";
Px.Ex.Application.deleteInsightInitArgs();
if(_10.network){
Px.Ex.Application._currentBuyerCode=_10.network.buyerID;
}
if(_10.publisherResult.success){
Px.Ex.Application.setContactRoleLoaded(_10.publisherResult.contactRole);
Px.Ex.Application._currentPublisherCode=_10.publisherResult.contactRole.contactEntity;
_15=_10.publisherResult.tpubName;
if(_15===undefined){
_15="";
}
}else{
this.errorMessageTd.innerHTML=dojo.toJson(_10.publisherResult);
}
if(this.callback){
this.callback(_11,_15,_12,_13);
}
if(_10.publisherResult.success){
this.onExecute();
}
if(_14||_13){
Px.Ex.Application.reloadScreenIfNeeded(_14,_13);
}
},onSaveError:function(_16){
this.showRotation(false);
this.stopClosing(false);
this.errorMessageTd.innerHTML=_16.message;
},destroy:function(){
this.cancelXhr();
this.inherited(arguments);
}});
dojo.declare("Px.Ex.ManageTpubsScreen",[Px.Ex.XhrMixin],{selectedLetter:"all",tpubDialog:undefined,draw:function(){
this.xhr({url:"/sellers/manage-tpubs-screen",load:dojo.hitch(this,function(_1){
dojo.byId("divContent").innerHTML=_1;
this.hideResponse();
this.decorateQuickCreate();
this.bindNewTpubButton();
this.bindQuickCreateButtonAndText();
this.bindQuickCreateResponseButtons();
this.bindSortButton();
this.bindFilter();
this.createTpubsGrid();
})});
},decorateQuickCreate:function(){
if(dojo.byId("divQuickCreateTpubHeader")){
var _2={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _3=new curvyCorners(_2,dojo.byId("roundedFormBorderId"));
_3.applyCornersToAll();
var _4=dojo.byId("divQuickCreateTpubHeader");
var _5="<ul><li class=\"first last\"><span class=\"active\"><span>"+_4.innerHTML+"</span></span></li></ul>";
_4.innerHTML=_5;
}
},bindNewTpubButton:function(){
var _6=dojo.hitch(this,"onNewTpub");
$("#T4E-NEW-TPUB").click(_6);
},bindQuickCreateButtonAndText:function(){
if(dojo.byId("inputNewTpubName")){
var _7=dojo.hitch(this,this.onQuickCreate);
$("#T4E-QC-TPUB").click(_7);
var _8=Px.Ex.Application.enterPressed(_7);
$("#inputNewTpubName").keypress(_8);
dojo.byId("inputNewTpubName").focus();
dojo.byId("quick-create-error").innerHTML="";
}
},animateErrorMessage:function(id,_9){
var _a=dojo.byId(id);
_a.innerHTML=_9;
dojo.fx.chain([dojo.animateProperty({node:_a,duration:400,properties:{backgroundColor:{end:"black"}}}),dojo.animateProperty({node:_a,duration:1000,properties:{backgroundColor:{end:"white"}}})]).play();
},bindQuickCreateResponseButtons:function(){
var _b=dojo.hitch(this,function(){
this.editTpub(this._createdTpubId);
});
$("#buttonQcResponseEdit").click(_b);
_b=dojo.hitch(this,function(){
this.showContractsScreen(this._createdTpubId);
});
$("#buttonQcResponseContracts").click(_b);
_b=dojo.hitch(this,function(){
this.showUsersScreen(this._createdTpubId);
});
$("#buttonQcResponseUsers").click(_b);
},makeSearchControl:function(){
this.searchControl=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true,emptyText:"Search by name or by ID"},"tpubSearchId");
this.searchControl.startup();
this.searchControl.connect(this.searchControl,"onChange",dojo.hitch(this,"onChangeSearchText"));
},onChangeSearchText:function(_c){
if(this.grid._isLoading){
return;
}
if(this.timer){
clearTimeout(this.timer);
}
this.timer=setTimeout(dojo.hitch(this,"onFilterLetterChanged"),250);
},bindFilter:function(){
this.makeSearchControl();
this.selectedLetter="all";
$(".filter-letter").filter("#all").addClass("filter-letter-selected");
$(".filter-letter").hover(function(){
$(this).addClass("filter-letter-hover");
},function(){
$(this).removeClass("filter-letter-hover");
});
var _d=this;
$(".filter-letter").click(function(){
if(_d.grid._isLoading){
return;
}
$(".filter-letter").removeClass("filter-letter-selected");
$(this).addClass("filter-letter-selected");
var id=$(this).attr("id");
if(id!=_d.selectedLetter){
_d.selectedLetter=id;
_d.onFilterLetterChanged();
}
});
},bindSortButton:function(){
var _e=dojo.hitch(this,"sortGrid");
$("#divSortButton").click(function(){
_e(dojo.hasClass("divSortButton","sort-button-desc"));
});
},sortGrid:function(_f){
if(this.grid._isLoading){
return;
}
this.grid.setSortIndex(1,_f);
this.showSort(_f);
},showSort:function(asc){
dojo.toggleClass("divSortButton","sort-button-desc",!asc);
},hideResponse:function(){
if(dojo.byId("divQuickCreateResponse")){
dojo.fx.wipeOut({node:dojo.byId("divQuickCreateResponse"),duration:1}).play();
}
},showResponse:function(id,_10,_11){
this._createdTpubId=id;
dojo.byId("spanNewTpubName").innerHTML=_11;
dojo.byId("spanNewTpubDisplayCode").innerHTML=_10;
dojo.fx.wipeIn({node:dojo.byId("divQuickCreateResponse")}).play();
},clearQuickCreate:function(){
if(dojo.byId("inputNewTpubName")){
dojo.byId("inputNewTpubName").value="";
dojo.byId("inputUsReporting").checked=false;
dojo.byId("inputDemographic").checked=false;
}
},onNewTpub:function(){
this.tpubDialog=new Px.Ex.TPubDialog({reloadTpubsGrid:dojo.hitch(this,"reloadTpubsGrid"),showUsersScreen:dojo.hitch(this,"showUsersScreen")});
this.tpubDialog.show();
},onQuickCreate:function(){
dojo.fx.wipeOut({node:dojo.byId("divQuickCreateResponse")}).play();
dojo.byId("quick-create-error").innerHTML="";
var _12=dojo.trim(dojo.byId("inputNewTpubName").value);
var _13=dojo.byId("inputUsReporting").checked?1:0;
var _14=dojo.byId("inputDemographic").checked?1:0;
var err="";
if(_12.length==0){
err="Please, type the name of new T-Pub!";
}else{
if(_12.length>50){
err="T-Pub's name is too long";
}else{
if(!Px.Ex.Application.Patterns.NAME.test(_12)){
err="T-Pub's name can contains english letters, numbers, spaces, . _ - + = $ # @ & * , ( ) [ ] { } | only";
}
}
}
if(err){
this.animateErrorMessage("quick-create-error",err);
dojo.byId("inputNewTpubName").focus();
return;
}
var _15=dojo.hitch(this,function(_16){
this.showResponse(_16.publisherCode,_16.displayCode,_12);
this.clearQuickCreate();
this.reloadTpubsGrid();
});
var _17=dojo.hitch(this,function(_18,_19){
dojo.fx.chain([dojo.fx.wipeOut({node:dojo.byId("divQuickCreateIndicator")}),dojo.fx.wipeIn({node:dojo.byId("divQuickCreateForm"),onEnd:function(){
if(_18["return"]){
_18=_18["return"];
if(_18.errorMessage){
dojo.byId("quick-create-error").innerHTML="Error: "+_18.errorMessage;
}else{
_15(_18);
}
}else{
dojo.byId("quick-create-error").innerHTML="Error: "+_18.faultstring+"<br>Code: "+_18.faultcode;
}
}})]).play();
});
var fn=dojo.hitch(this,"xhr",{url:"/sellers/new-tpub",content:{publisherName:_12,usReporting:_13,demographic:_14},handleAs:"json",load:_17});
dojo.fx.chain([dojo.fx.wipeOut({node:dojo.byId("divQuickCreateForm"),onEnd:function(){
dojo.byId("divQuickCreateIndicator").innerHTML=Px.Ex.Application.getWaitHtml();
}}),dojo.fx.wipeIn({node:dojo.byId("divQuickCreateIndicator"),onEnd:fn})]).play();
},onFilterLetterChanged:function(){
if(this.grid){
var _1a=this.searchControl.attr("value");
var _1b=parseInt(_1a);
if(isNaN(_1b)||_1b<100||_1a.length!=(_1b+"").length){
_1b=undefined;
}
var _1c=_1a.length?"name: '*"+_1a+"*'":"name: '*'";
var _1d={ignoreCase:true};
if(this.selectedLetter.length==1){
_1c="name: '"+this.selectedLetter+"*'";
if(_1a.length){
_1c+=" && name: '*"+_1a+"*'";
}
}else{
if(this.selectedLetter=="other"){
_1c="NOT name: 'A*' && NOT name: 'B*' && NOT name: 'C*' && NOT name: 'D*' && NOT name: 'E*' && NOT name: 'F*' && NOT name: 'G*' && NOT name: 'H*' && NOT name: 'I*' && NOT name: 'J*' && NOT name: 'K*' && NOT name: 'L*' && NOT name: 'M*' && NOT name: 'N*' && NOT name: 'O*' && NOT name: 'P*' && NOT name: 'Q*' && NOT name: 'R*' && NOT name: 'S*' && NOT name: 'T*' && NOT name: 'U*' && NOT name: 'V*' && NOT name: 'W*' && NOT name: 'X*' && NOT name: 'Y*' && NOT name: 'Z*'";
if(_1a.length){
_1c+=" && name: '*"+_1a+"*'";
}
}
}
if(_1b){
_1c="("+_1c+") || displayCode: "+_1b;
}
this.grid.setQuery(_1c,_1d);
this.searchControl.focus();
}
},reloadTpubsGrid:function(){
if(!this.store){
return;
}
var h=this.grid.attr("autoHeight");
this.grid.attr("autoHeight",1);
this.store.close();
this.grid.filter(this.grid.query,"rerender=true");
this.grid.attr("autoHeight",h);
},createTpubsGrid:function(){
this.store=new dojox.data.AndOrReadStore({clearOnClose:true,url:"/sellers/publishers-list"});
var _1e=dojo.hitch(this,function(_1f){
return "";
});
var _20=dojo.hitch(this,function(_21,_22){
var _23=this.grid.getItem(_22);
if(!_23){
return "";
}
return dojo.string.substitute("<a class=\"a-in-grid\" id=\"edit,${id}\" href=\"javascript:\">Edit</a> | <a class=\"a-in-grid\" id=\"contracts,${id}\" href=\"javascript:\">Contracts</a> | <a class=\"a-in-grid\" id=\"users,${id}\" href=\"javascript:\">Users</a> | <a class=\"a-in-grid\" id=\"buyers,${id},${tpubName}\" href=\"javascript:\">Direct Buyers</a>",{id:_23.id,tpubName:_23.name[0]});
});
var _24=dojo.hitch(this,function(_25,_26){
var _27=this.grid.getItem(_26);
if(!_27){
return "";
}
return dojo.string.substitute("<a class=\"tpub-name-in-grid\" id=\"${id}\" href=\"javascript:\">${name}</a>",{id:_27.id,name:_25,i:_26+1});
});
var _28=[[{name:"",get:_1e,formatter:_20,styles:"text-align:center;",width:"22em",noresize:true},{name:"T-Pub",field:"name",width:"100%",formatter:_24}]];
var _29=dojo.hitch(this,function(){
this.grid=new dojox.grid.DataGrid({loadingMessage:Px.Ex.Application.getWaitHtml(),store:this.store,query:{name:"*"},queryOptions:{ignoreCase:true},clientSort:true,autoHeight:23,height:"35em",selectionMode:"single",canSort:function(_2a){
return Math.abs(_2a)==2;
},structure:_28});
dojo.byId("divTpubsGridContainer").appendChild(this.grid.domNode);
this.grid.startup();
var _2b=dojo.hitch(this,"onGridClick");
this.grid.connect(this.grid,"onClick",_2b);
var _2c=dojo.hitch(this,"onRowDblClick");
this.grid.connect(this.grid,"onRowDblClick",_2c);
this.grid.connect(this.grid,"onMouseOverRow",dojo.hitch(this,function(e){
if(e.cellNode&&e.cellIndex==1){
if(e.target.nodeName=="A"){
var _2d=e.grid.getItem(e.rowIndex);
var _2e=e.grid.store.getValue(_2d,"displayCode");
var msg="T-Pub ID = "+_2e;
clearTimeout(this._tooltipTimer);
dijit.showTooltip(msg,e.cellNode,["below","above"]);
this._tooltipTimer=setTimeout(dojo.hitch(this,"hideTooltip",e.cellNode),1500);
}else{
this.hideTooltip(e.cellNode);
}
}
}));
this.grid.connect(this.grid,"onMouseOutRow",dojo.hitch(this,function(e){
if(e.cellNode&&e.cellIndex==1){
this.hideTooltip(e.cellNode);
}
}));
});
dojo.addOnLoad(_29);
},hideTooltip:function(_2f){
clearTimeout(this._tooltipTimer);
dijit.hideTooltip(_2f);
},onGridClick:function(e){
if(e.target.nodeName!="A"){
return;
}
var a=e.target.id.split(/,/);
if(a.length==1){
this.viewTpub(a[0]);
}else{
if(a[0]=="contracts"){
this.showContractsScreen(a[1]);
}else{
if(a[0]=="users"){
this.showUsersScreen(a[1]);
}else{
if(a[0]=="edit"){
this.editTpub(a[1]);
}else{
if(a[0]=="buyers"){
this.showDirectBuyersDialog(a[1],a[2]);
}
}
}
}
}
},showDirectBuyersDialog:function(_30,_31){
this.tpubDirectBuyersDialog=new Px.Ex.DirectBuyerDialog({tpubId:_30,tpubName:_31});
this.tpubDirectBuyersDialog.show();
},onRowDblClick:function(e){
var _32=this.grid.getItem(e.rowIndex);
if(_32){
this.viewTpub(_32.id);
}
},viewTpub:function(id){
this.tpubDialog=new Px.Ex.TPubDialog({tpubId:id,readOnly:true});
this.tpubDialog.show();
},editTpub:function(id){
this.tpubDialog=new Px.Ex.TPubDialog({tpubId:id,reloadTpubsGrid:dojo.hitch(this,"reloadTpubsGrid"),showUsersScreen:dojo.hitch(this,"showUsersScreen")});
this.tpubDialog.show();
},_getTpubName:function(id){
var s=this.grid.store;
var _33=s._getItemByIdentity(id);
return _33?s.getValue(_33,"name"):"";
},showContractsScreen:function(id){
Px.Ex.Application._tpubId=id;
Px.Ex.Application._tpubName=this._getTpubName(id);
Px.Ex.Application.showScreen(Px.Ex.Application.Ids.PAGE_CONTRACTS_ID);
},showUsersScreen:function(id){
Px.Ex.Application._tpubId=id;
Px.Ex.Application._tpubName=this._getTpubName(id);
Px.Ex.Application.showScreen(Px.Ex.Application.Ids.PAGE_TPUB_USERS_ID);
},destroy:function(){
if(this.timer){
clearTimeout(this.timer);
}
if(this.searchControl){
this.searchControl.destroyRecursive();
delete this.searchControl;
}
if(this.grid){
this.grid.destroyRecursive();
delete this.grid;
}
}});
dojo.declare("Px.Ex.ManageBuyersScreen",[Px.Ex.XhrMixin],{BUYERNAME_REGEXP:"[a-zA-Z0-9\\x20\\x2e\\x5f\\x2d\\x2b\\x3d\\x2d\\x24\\x23\\x40\\x2a\\x2c\\x28\\x29\\x5b\\x5d\\x7b\\x7d\\x7c\\x21]*",BUYERURL_REGEXP:"^([A-Za-z]+://)?[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&?/.=]+$",BUYER_DIRECT_DISPLAYCODE_REGEXP:"D[A-Z]{3}",BUYER_PLATFORM_DISPLAYCODE_REGEXP:"[A-Z]{3}",PLATFORM_TYPE:3,NETWORK_TYPE:4,DIRECT_BUYER_TYPE:6,_connections:[],_quickCreateResponseConnections:[],draw:function(){
this.xhrLoad({selector:"#divContent",url:"/buyers/manage-buyers-screen",load:dojo.hitch(this,function(_1){
this.parseServerData();
this.handleQuickCreate();
this.handleBuyerGrid();
})});
},fetchNewBuyerRequests:function(){
if(!this._serverData.newBuyerRequests){
dojo.xhrGet({sync:true,url:"/buyers/new-buyer-request-list",content:{},load:dojo.hitch(this,function(_2){
this._serverData.newBuyerRequests=_2;
}),error:dojo.hitch(this,function(_3){
this._serverData.newBuyerRequests=null;
}),handleAs:"json"});
}
},handleBuyerGrid:function(){
if(this._serverData.permissions["T4E-MNGBUYER-BUYERLIST"]){
this.bindSortButton();
this.bindFilter();
this.createBuyersGrid();
}
},showQuickCreateResponse:function(_4,id,_5){
dojo.byId("spanNewBuyerName").innerHTML=_4;
dojo.byId("spanNewBuyerID").innerHTML=id;
dojox.fx.wipeTo({node:dojo.byId("divQuickCreateResponse"),duration:300,height:65}).play();
dojo.forEach(this._quickCreateResponseConnections,dojo.disconnect,this);
if(this._serverData.permissions["T4E-MNGBUYER-EDIT"]){
dojo.style(dojo.byId("quickCreateEditLink"),"display","block");
this._quickCreateResponseConnections.push(dojo.connect(dojo.byId("quickCreateEditLink"),"onclick",dojo.hitch(this,"onEditBuyer",id)));
}else{
dojo.style(dojo.byId("quickCreateEditLink"),"display","none");
}
if((this._serverData.permissions["T4E-MNGBUYER-USERS"])&&(_5!=this.DIRECT_BUYER_TYPE)){
dojo.style(dojo.byId("quickCreateUsersLink"),"display","block");
this._quickCreateResponseConnections.push(dojo.connect(dojo.byId("quickCreateUsersLink"),"onclick",dojo.hitch(this,"onBuyerUsers",id)));
}else{
dojo.style(dojo.byId("quickCreateUsersLink"),"display","none");
}
},onEditBuyer:function(_6){
},onBuyerUsers:function(_7){
this.showUsersScreen(_7);
},reloadBuyersGrid:function(){
if(!this._gridStore){
return;
}
var h=this._grid.attr("autoHeight");
this._grid.attr("autoHeight",1);
this._gridStore.close();
this._gridStore._jsonData=this.getGridData();
this._gridStore.fetch();
this._grid._refresh();
this._grid.setSortIndex(3,!dojo.hasClass("divSortButton","sort-button-desc"));
this._grid.filter(this._grid.query,"rerender=true");
this._grid.attr("autoHeight",h);
},makeSearchControl:function(){
this._searchControl=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true,emptyText:this._serverData.messages["T4E_MNGBUYER_Caption_SearchBuyer_EmptyTest"]},"buyerSearchId");
this._searchControl.startup();
this._searchControl.connect(this._searchControl,"onChange",dojo.hitch(this,"onChangeSearchText"));
},bindFilter:function(){
this.makeSearchControl();
this._selectedLetter="all";
$(".filter-letter").filter("#all").addClass("filter-letter-selected");
$(".filter-letter").hover(function(){
$(this).addClass("filter-letter-hover");
},function(){
$(this).removeClass("filter-letter-hover");
});
var _8=this;
$(".filter-letter").click(function(){
if(_8._grid._isLoading){
return;
}
$(".filter-letter").removeClass("filter-letter-selected");
$(this).addClass("filter-letter-selected");
var id=$(this).attr("id");
if(id!=_8._selectedLetter){
_8._selectedLetter=id;
_8.onFilterLetterChanged();
}
});
},bindSortButton:function(){
var _9=dojo.hitch(this,"sortGrid");
$("#divSortButton").click(function(){
_9(dojo.hasClass("divSortButton","sort-button-desc"));
});
},sortGrid:function(_a){
if(this._grid._isLoading){
return;
}
this._grid.setSortIndex(3,_a);
this.showSort(_a);
},showSort:function(_b){
dojo.toggleClass("divSortButton","sort-button-desc",!_b);
},getGridData:function(){
var _c=[];
dojo.forEach(this._serverData.buyers,dojo.hitch(this,function(v){
var _d=dojo.clone(v);
var _e;
switch(_d.type){
case this.DIRECT_BUYER_TYPE:
_e=this._serverData.messages["T4E_MNGBUYER_Type_Caption_DirectBuyer"];
break;
case this.NETWORK_TYPE:
_e=this._serverData.messages["T4E_MNGBUYER_Type_Caption_Network"];
break;
case this.PLATFORM_TYPE:
_e=this._serverData.messages["T4E_MNGBUYER_Type_Caption_Platform"];
break;
}
_d.sortInfo=_e+_d.networkName;
_c.push(_d);
}),this);
return {identifier:"networkCode",label:"networkName",items:_c};
},createBuyersGrid:function(){
var _f=this.getGridData();
this._gridStore=new dojox.data.AndOrReadStore({clearOnClose:true,data:_f});
var _10=dojo.hitch(this,function(_11){
return "";
});
var _12=dojo.hitch(this,function(_13,_14){
var _15=this._grid.getItem(_14);
if(!_15){
return "";
}
var _16=[];
if(this._serverData.permissions["T4E-MNGBUYER-EDIT"]){
_16.push("<a class=\"a-in-grid\" id=\"edit,"+_15.networkCode+"\" href=\"javascript:\">"+this._serverData.messages["T4E_MNGBUYER_Link_Edit"]+"</a>");
}
if(this._serverData.permissions["T4E-MNGBUYER-USERS"]){
if(_15.type!=this.DIRECT_BUYER_TYPE){
_16.push("<a class=\"a-in-grid\" id=\"users,"+_15.networkCode+"\" href=\"javascript:\">"+this._serverData.messages["T4E_MNGBUYER_Link_Users"]+"</a>");
}else{
_16.push("<span class=\"a-disabled\" id=\"users,"+_15.networkCode+"\" href=\"javascript:\">"+this._serverData.messages["T4E_MNGBUYER_Link_Users"]+"</span>");
}
}
return _16.join(" | ");
});
var _17=dojo.hitch(this,function(){
if(!this._serverData.permissions["T4E-MNGBUYER-EDIT"]&&!this._serverData.permissions["T4E-MNGBUYER-USERS"]){
return true;
}else{
return false;
}
})();
var _18=dojo.hitch(this,function(){
var res=0;
if(this._serverData.permissions["T4E-MNGBUYER-EDIT"]){
res+=3;
}
if(this._serverData.permissions["T4E-MNGBUYER-USERS"]){
res+=4;
}
return res+"em";
})();
var _19=dojo.hitch(this,function(_1a,_1b){
var _1c=this._grid.getItem(_1b);
if(!_1c){
return "";
}
var _1d;
switch(_1a){
case this.PLATFORM_TYPE:
className="manage_buyers_sp";
_1d=this._serverData.messages["T4E_MNGBUYER_Type_Tooltip_Platform"];
break;
case this.NETWORK_TYPE:
className="manage_buyers_an";
_1d=this._serverData.messages["T4E_MNGBUYER_Type_Tooltip_Network"];
break;
case this.DIRECT_BUYER_TYPE:
className="manage_buyers_db";
_1d=this._serverData.messages["T4E_MNGBUYER_Type_Tooltip_DirectBuyer"];
break;
}
return "<div title=\""+_1d+"\" class=\""+className+"\"></div>";
});
var _1e=dojo.hitch(this,function(_1f,_20){
var _21=this._grid.getItem(_20);
if(!_21){
return "";
}
return dojo.string.substitute("<a class=\"tpub-name-in-grid\" id=\"${id}\" href=\"javascript:\">${name}</a>",{id:_21.networkCode,name:_1f,i:_20+1});
});
var _22=[[{name:"",get:_10,formatter:_12,styles:"padding-left: 5px;",width:_18,noresize:true,hidden:_17},{name:"Type",field:"type",width:"30px",formatter:_19},{name:"Buyer",field:"networkName",width:"100%",formatter:_1e},{name:"Sort",field:"sortInfo",hidden:true}]];
this._grid=new dojox.grid.DataGrid({loadingMessage:Px.Ex.Application.getWaitHtml(),store:this._gridStore,query:{networkName:"*"},queryOptions:{ignoreCase:true},clientSort:true,autoHeight:18,height:"35em",selectionMode:"single",canSort:function(_23){
return true;
},structure:_22});
dojo.byId("divBuyersGridContainer").appendChild(this._grid.domNode);
this._grid.startup();
this._grid.setSortIndex(3,true);
var _24=dojo.hitch(this,"onGridClick");
this._grid.connect(this._grid,"onClick",_24);
var _25=dojo.hitch(this,"onRowDblClick");
this._grid.connect(this._grid,"onRowDblClick",_25);
this._grid.connect(this._grid,"onMouseOverRow",dojo.hitch(this,function(e){
if(e.cellNode&&e.cellIndex==2){
if(e.target.nodeName=="A"){
var _26=e.grid.getItem(e.rowIndex);
var _27=e.grid.store.getValue(_26,"networkCode");
var _28=e.grid.store.getValue(_26,"displayCode");
var msg="Display Code = "+_28+" | ID = "+_27;
clearTimeout(this._tooltipTimer);
dijit.showTooltip(msg,e.cellNode,["below","above"]);
this._tooltipTimer=setTimeout(dojo.hitch(this,"hideTooltip",e.cellNode),1500);
}else{
this.hideTooltip(e.cellNode);
}
}
}));
this._grid.connect(this._grid,"onMouseOutRow",dojo.hitch(this,function(e){
if(e.cellNode&&e.cellIndex==1){
this.hideTooltip(e.cellNode);
}
}));
},hideTooltip:function(_29){
clearTimeout(this._tooltipTimer);
dijit.hideTooltip(_29);
},onRowDblClick:function(e){
var _2a=this._grid.getItem(e.rowIndex);
if(_2a){
this.onEditBuyer(this._gridStore.getValue(this._grid.getItem(e.rowIndex),"networkCode"));
}
},onGridClick:function(e){
if(e.target.nodeName!="A"){
return;
}
var a=e.target.id.split(/,/);
if(a.length==1){
}else{
if(a[0]=="users"){
this.onBuyerUsers(a[1]);
}else{
if(a[0]=="edit"){
this.onEditBuyer(a[1]);
}
}
}
},onChangeSearchText:function(_2b){
if(this._grid._isLoading){
return;
}
if(this._timer){
clearTimeout(this._timer);
}
this._timer=setTimeout(dojo.hitch(this,"onFilterLetterChanged"),250);
},onFilterLetterChanged:function(){
if(this._grid){
var _2c=this._searchControl.attr("value");
var _2d=parseInt(_2c);
if(isNaN(_2d)||_2c.length!=(_2d+"").length){
_2d=undefined;
}
var _2e=_2c.length?"networkName: '*"+_2c+"*'":"networkName: '*'";
var _2f={ignoreCase:true};
if(this._selectedLetter.length==1){
_2e="networkName: '"+this._selectedLetter+"*'";
if(_2c.length){
_2e+=" && networkName: '*"+_2c+"*'";
}
}else{
if(this._selectedLetter=="other"){
_2e="NOT networkName: 'A*' && NOT networkName: 'B*' && NOT networkName: 'C*' && NOT networkName: 'D*' && NOT networkName: 'E*' && NOT networkName: 'F*' && NOT networkName: 'G*' && NOT networkName: 'H*' && NOT networkName: 'I*' && NOT networkName: 'J*' && NOT networkName: 'K*' && NOT networkName: 'L*' && NOT networkName: 'M*' && NOT networkName: 'N*' && NOT networkName: 'O*' && NOT networkName: 'P*' && NOT networkName: 'Q*' && NOT networkName: 'R*' && NOT networkName: 'S*' && NOT networkName: 'T*' && NOT networkName: 'U*' && NOT networkName: 'V*' && NOT networkName: 'W*' && NOT networkName: 'X*' && NOT networkName: 'Y*' && NOT networkName: 'Z*'";
if(_2c.length){
_2e+=" && networkName: '*"+_2c+"*'";
}
}
}
_2e="("+_2e+") || displayCode: "+_2c;
if(_2d){
_2e="("+_2e+") || networkCode: "+_2d;
}
this._grid.setQuery(_2e,_2f);
this._searchControl.focus();
}
},showUsersScreen:function(id){
Px.Ex.Application._currentBuyerCode=id;
Px.Ex.Application.showScreen(Px.Ex.Application.Ids.PAGE_BUYERS_USERS_ID);
},handleQuickCreate:function(){
if(this._serverData.permissions["T4E-MNGBUYER-QUICKCREATE"]){
this.decorateQuickCreate();
dojo.byId("divQuickCreateIndicator").innerHTML=Px.Ex.Application.getWaitHtml();
this.drawQuickCreateFields();
this.bindQuickCreateEvents();
}
},bindQuickCreateEvents:function(){
this._connections.push(dojo.connect(this._quickCreate_type,"onChange",dojo.hitch(this,function(_30){
switch(parseInt(_30)){
case this.PLATFORM_TYPE:
this._quickCreate_displayCode.regExp=this.BUYER_PLATFORM_DISPLAYCODE_REGEXP;
this._quickCreate_displayCode.invalidMessage=this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerDisplayCode_Invalid_Platform"];
break;
case this.DIRECT_BUYER_TYPE:
this._quickCreate_displayCode.regExp=this.BUYER_DIRECT_DISPLAYCODE_REGEXP;
this._quickCreate_displayCode.invalidMessage=this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerDisplayCode_Invalid_DirectBuyer"];
break;
}
})));
if(dojo.byId("createButton")){
this._connections.push(dojo.connect(dojo.byId("createButton"),"onclick",dojo.hitch(this,"onQuickCreate")));
}
if(dojo.byId("quick-create-import")){
var _31;
if(dojo.isIE){
_31="manage_buyers_create_import msie";
}else{
_31="manage_buyers_create_import";
}
this._quickCreate_importTooltipDialog=new Px.Ex.ManageBuyersScreen.ImportTooltipDialog({parentObj:this});
this._quickCreate_importTooltipDialog.startup();
this._quickCreate_importButton=new dijit.form.DropDownButton({"class":_31,dropDown:this._quickCreate_importTooltipDialog,title:this._serverData.messages["T4E_MNGBUYER_QuickCreate_ImportButton_Tooltip"]},"quick-create-import");
this._quickCreate_importButton.connect("onclick",dojo.hitch(this,function(){
this.fetchNewBuyerRequests();
}));
}
},onQuickCreate:function(){
this._quickCreate_name._hasBeenBlurred=true;
this._quickCreate_type._hasBeenBlurred=true;
this._quickCreate_displayCode._hasBeenBlurred=true;
this._quickCreate_url._hasBeenBlurred=true;
var _32=this._quickCreate_name.validate(false);
var _33=this._quickCreate_type.validate(false);
var _34=this._quickCreate_displayCode.validate(false);
var _35=this._quickCreate_url.validate(false);
if(_32&&_33&&_34&&_35){
dojox.fx.wipeTo({node:dojo.byId("divQuickCreateResponse"),duration:300,height:1}).play();
this.clearErrorMessage();
this.showQuickCreateWaitingSign(true);
this.xhr({sync:true,content:{buyerName:this._quickCreate_name.value,buyerType:this._quickCreate_type.value,buyerDisplayCode:this._quickCreate_displayCode.value,buyerURL:this._quickCreate_url.value,allowExternalCampaign:this.convertBoolToXhr(dojo.byId("inputQuickCreateAllowExternalCampaign").checked),allowCPMBuy:this.convertBoolToXhr(dojo.byId("inputQuickCreateAllowCPMBuy").checked),allowCampaignCredit:this.convertBoolToXhr(dojo.byId("inputQuickCreateAllowCampaignCredit").checked)},url:"/buyers/create-new-buyer",load:dojo.hitch(this,function(_36){
this.showQuickCreateWaitingSign(false);
if(_36["return"]){
this.addNewBuyer(this._quickCreate_displayCode.value,_36["return"],null,this._quickCreate_name.value,parseInt(this._quickCreate_type.value));
this.showQuickCreateResponse(this._quickCreate_name.value,_36["return"],this._quickCreate_type.value);
this.clearAllFields();
this.reloadBuyersGrid();
}else{
this.animateErrorMessage("quick-create-error",_36["faultstring"]);
}
}),error:dojo.hitch(this,function(_37){
this.showQuickCreateWaitingSign(false);
this.animateErrorMessage("quick-create-error",_37["faultstring"]);
}),handleAs:"json"});
}
},addNewBuyer:function(_38,_39,_3a,_3b,_3c){
this._serverData.buyers.push({displayCode:_38,networkCode:_39,networkId:_3a,networkName:_3b,type:_3c});
},showQuickCreateWaitingSign:function(_3d){
if(_3d==true){
dojo.style(dojo.byId("divQuickCreateIndicator"),"display","block");
}else{
dojo.style(dojo.byId("divQuickCreateIndicator"),"display","none");
}
},clearErrorMessage:function(){
dojo.byId("quick-create-error").innerHTML="";
},clearAllFields:function(){
this._quickCreate_name.reset();
this._quickCreate_type.reset();
this._quickCreate_displayCode.reset();
this._quickCreate_url.reset();
dojo.byId("inputQuickCreateAllowExternalCampaign").checked=false;
dojo.byId("inputQuickCreateAllowCPMBuy").checked=false;
dojo.byId("inputQuickCreateAllowCPMBuy").checked=false;
dojo.byId("inputQuickCreateAllowCampaignCredit").checked=false;
},convertBoolToXhr:function(_3e){
if(_3e==true){
return 1;
}else{
return 0;
}
},animateErrorMessage:function(id,_3f){
var _40=dojo.byId(id);
_40.innerHTML=_3f;
dojo.fx.chain([dojo.animateProperty({node:_40,duration:400,properties:{backgroundColor:{end:"black"}}}),dojo.animateProperty({node:_40,duration:1000,properties:{backgroundColor:{end:"white"}}})]).play();
},drawQuickCreateFields:function(){
this._quickCreate_name=new Px.Ex.ValidationTextBox({"class":"form-input",intermediateChanges:true,name:"quickCreateName",tabIndex:1,trim:true,regExp:this.BUYERNAME_REGEXP,required:true,maxLength:49,promptMessage:this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerName_Prompt"]||"",invalidMessage:this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerName_Invalid"]||"$_unset_$",emptyMessage:this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerName_Empty"]||"$_unset_$"},"inputName");
dojo.parser.parse(dojo.byId("divQuickCreateForm"));
this._quickCreate_type=dijit.byId("quickCreateType");
this._quickCreate_displayCode=new Px.Ex.ValidationTextBox({"class":"form-input",intermediateChanges:false,name:"quickCreateDisplayCode",tabIndex:3,trim:true,lowercase:false,regExp:this.BUYER_DIRECT_DISPLAYCODE_REGEXP,required:false,promptMessage:this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerDisplayCode_Prompt"]||"",invalidMessage:this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerDisplayCode_Invalid_DirectBuyer"]||"$_unset_$",emptyMessage:this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerDisplayCode_Empty"]||"$_unset_$"},"inputDisplayCode");
this._quickCreate_url=new Px.Ex.ValidationTextBox({"class":"form-input",intermediateChanges:false,name:"quickCreateUrl",tabIndex:4,trim:true,lowercase:true,regExp:this.BUYERURL_REGEXP,required:true,promptMessage:this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerUrl_Prompt"]||"",invalidMessage:this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerUrl_Invalid"]||"$_unset_$",emptyMessage:this._serverData.messages["T4E_MNGBUYER_QuickCreate_BuyerUrl_Empty"]||"$_unset_$"},"inputURL");
},decorateQuickCreate:function(){
if(dojo.byId("divQuickCreateTpubHeader")){
var _41={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _42=new curvyCorners(_41,dojo.byId("roundedFormBorderId"));
_42.applyCornersToAll();
var _43=dojo.byId("divQuickCreateTpubHeader");
var _44="<ul><li class=\"first last\"><span class=\"active\"><span>"+_43.innerHTML+"</span></span></li></ul>";
_43.innerHTML=_44;
}
},parseServerData:function(){
this._serverData={};
if(dojo.byId("messages")){
this._serverData.messages=dojo.fromJson(dojo.byId("messages").innerHTML);
}
if(dojo.byId("buyers")){
this._serverData.buyers=dojo.fromJson(dojo.byId("buyers").innerHTML);
}
if(dojo.byId("permissions")){
this._serverData.permissions=dojo.fromJson(dojo.byId("permissions").innerHTML);
}
},destroy:function(){
try{
dojo.forEach(this._connections,dojo.disconnect,this);
}
catch(e){
}
try{
dojo.forEach(this._quickCreateResponseConnections,dojo.disconnect,this);
}
catch(e){
}
try{
this._quickCreate_importButton.destroyRecursive(false);
}
catch(e){
}
try{
this._quickCreate_name.destroyRecursive(false);
}
catch(e){
}
try{
this._quickCreate_type.destroyRecursive(false);
}
catch(e){
}
try{
this._quickCreate_displayCode.destroyRecursive(false);
}
catch(e){
}
try{
this._quickCreate_url.destroyRecursive(false);
}
catch(e){
}
try{
if(this._gridStore){
if(this._gridStore.isDirty){
this._gridStore.revert();
}
this._gridStore.close();
}
}
catch(e){
}
try{
if(this._grid){
this._grid.destroyRecursive(false);
}
}
catch(e){
}
try{
if(this._searchControl){
this._searchControl.destroyRecursive(false);
}
}
catch(e){
}
}});
dojo.declare("Px.Ex.ManageBuyersScreen.ImportTooltipDialog",[dijit.TooltipDialog],{"class":"filter-popup-dialog",style:"width: 270px",parentObj:undefined,_connections:[],startup:function(){
this.inherited(arguments);
this.createContent();
},_addCloseButton:function(_45){
var _46,c=dojo.create;
this.closeButtonNode=dojo.create("span",{className:"dijitDialogCloseIcon",title:this.parentObj._serverData.messages["T4E_MNGBUYER_QuickCreate_ImportButton_Dialog_Close_Tooltip"]},_45);
this.connect(this.closeButtonNode,"onmouseenter","_onCloseEnter");
this.connect(this.closeButtonNode,"onmouseleave","_onCloseLeave");
this.connect(this.closeButtonNode,"onclick","onCancel");
},_onCloseEnter:function(){
dojo.addClass(this.closeButtonNode,"dijitDialogCloseIcon-hover");
},_onCloseLeave:function(){
dojo.removeClass(this.closeButtonNode,"dijitDialogCloseIcon-hover");
},onCancel:function(){
this._onCloseLeave();
this.inherited(arguments);
},onOK:function(){
if(this._requestsGrid.selection.selectedIndex!=-1){
this.parentObj._quickCreate_name.attr("value",this.getGridValue(this._requestsGrid.selection.selectedIndex,"buyerName"));
this.parentObj._quickCreate_url.attr("value",this.getGridValue(this._requestsGrid.selection.selectedIndex,"buyerUrl"));
this.onCancel();
}
},onOpen:function(){
if(dojo.byId("gridDiv").innerHTML==""){
this.parentObj.fetchNewBuyerRequests();
this.createGrid();
}else{
this._requestsGrid.selection.clear();
}
},createGrid:function(){
this._requestsStore=new dojo.data.ItemFileReadStore({clearOnClose:true,data:{identifier:"requestCode",label:"buyerUrl",items:this.parentObj._serverData.newBuyerRequests}});
dateFormatter=dojo.hitch(this,function(_47,_48){
var d=_47;
try{
d=dojo.date.locale.format(dojo.date.stamp.fromISOString(_47),{selector:"date",datePattern:"yyyy-MM-dd"});
}
catch(e){
}
return d;
});
buyerNameFormatter=dojo.hitch(this,function(_49,_4a){
return "<div class=\"dojoxEllipsis\">"+_49+"</div>";
});
this._requestsGrid=new dojox.grid.DataGrid({loadingMessage:Px.Ex.Application.getWaitHtml(),store:this._requestsStore,query:{requestStatus:"1"},queryOptions:{ignoreCase:true},clientSort:true,height:"20em",selectionMode:"single",canSort:function(_4b){
return true;
},structure:[[{name:"Date",field:"requestDate",formatter:dateFormatter,noresize:true},{name:"Buyer Name",field:"buyerName",formatter:buyerNameFormatter,noresize:true,width:"100%"}]],onCellMouseOver:dojo.hitch(this,function(e){
var _4c="";
var _4d=this._requestsGrid.getItem(e.rowIndex);
var _4e=this._requestsStore.getValue(_4d,"buyerName");
var _4f=this._requestsStore.getValue(_4d,"buyerUrl");
var _50=this._requestsStore.getValue(_4d,"buyerContactDetails");
var _51=this._requestsStore.getValue(_4d,"remarks");
if(dojo.isIE){
var _52="newBuyerRequestsLog_requestTooltip_LongValue_IE";
}else{
var _52="newBuyerRequestsLog_requestTooltip_LongValue_FFChrome";
}
if(_51==""){
_51="&nbsp;";
}
_4c+="<div class=\"newBuyerRequestsLog_requestTooltip\">";
_4c+="<div class=\"newBuyerRequestsLog_requestTooltip_Title\">";
_4c+=this.parentObj._serverData.messages["T4E_MNGBUYER_QuickCreate_ImportButton_Dialog_Tooltip_Title"];
_4c+="</div>";
_4c+="<table class=\"newBuyerRequestsLog_requestTooltip_Table\">";
_4c+="<tr>";
_4c+="<td>";
_4c+=this.parentObj._serverData.messages["T4E_MNGBUYER_QuickCreate_ImportButton_Dialog_Tooltip_BuyerName"]+":&nbsp;";
_4c+="</td>";
_4c+="<td>";
_4c+="<div class=\"newBuyerRequestsLog_requestTooltip_Value\">";
_4c+=_4e;
_4c+="</div>";
_4c+="</td>";
_4c+="</tr>";
_4c+="<tr>";
_4c+="<td>";
_4c+=this.parentObj._serverData.messages["T4E_MNGBUYER_QuickCreate_ImportButton_Dialog_Tooltip_BuyerURL"]+":&nbsp;";
_4c+="</td>";
_4c+="<td>";
_4c+="<div class=\"newBuyerRequestsLog_requestTooltip_Value\">";
_4c+="<a href=\""+_4f+"\" target=\"_blank\">"+_4f+"</a>";
_4c+="</div>";
_4c+="</td>";
_4c+="</tr>";
_4c+="<tr>";
_4c+="<td>";
_4c+=this.parentObj._serverData.messages["T4E_MNGBUYER_QuickCreate_ImportButton_Dialog_Tooltip_BuyerContactDetails"]+":&nbsp;";
_4c+="</td>";
_4c+="<td>";
_4c+="<div class=\"newBuyerRequestsLog_requestTooltip_Value "+_52+"\">";
_4c+=this.convertNewLineToBR(_50);
_4c+="</div>";
_4c+="</td>";
_4c+="</tr>";
_4c+="<tr>";
_4c+="<td>";
_4c+=this.parentObj._serverData.messages["T4E_MNGBUYER_QuickCreate_ImportButton_Dialog_Tooltip_Remarks"]+":&nbsp;";
_4c+="</td>";
_4c+="<td>";
_4c+="<div class=\"newBuyerRequestsLog_requestTooltip_Value "+_52+"\">";
_4c+=this.convertNewLineToBR(_51);
_4c+="</div>";
_4c+="</td>";
_4c+="</tr>";
_4c+="</table>";
_4c+="</div>";
dijit.showTooltip(_4c,e.rowNode);
}),onCellMouseOut:dojo.hitch(this,function(e){
dijit.hideTooltip(e.rowNode);
})});
this._requestsGrid.placeAt(dojo.byId("gridDiv"));
this._requestsGrid.startup();
this._requestsGrid._refresh();
},convertNewLineToBR:function(_53){
var res;
res=_53.replace(/\r\n/gi,"<br>");
res=res.replace(/\n/gi,"<br>");
return res;
},getGridValue:function(_54,_55){
var val=this._requestsStore.getValue(this._requestsGrid.getItem(_54),_55);
return val;
},createContent:function(){
var _56=dojo.create("div",{id:"closeButton"},this.containerNode);
this._addCloseButton(_56);
var _57=dojo.create("div",{id:"contentDiv"},this.containerNode);
dojo.style(_57,"marginTop","20px");
var _58=dojo.create("div",{id:"cpationDiv",innerHTML:this.parentObj._serverData.messages["T4E_MNGBUYER_QuickCreate_ImportButton_Dialog_Caption"]},_57);
var _59=dojo.create("div",{id:"gridDiv"},_57);
var _5a=dojo.create("div",{id:"buttonsDiv"},_57);
dojo.style(_5a,"marginTop","20px");
var _5b=dojo.create("table",{},_5a);
dojo.style(_5b,"marginLeft","auto");
dojo.style(_5b,"marginRight","auto");
var _5c=dojo.create("tbody",{},_5b);
var _5d=dojo.create("tr",{},_5c);
var _5e=dojo.create("td",{},_5d);
var _5f=dojo.create("div",{className:"manage_buyers_cancelButton"},_5e);
this._connections.push(dojo.connect(_5f,"onclick",dojo.hitch(this,"onCancel")));
var _5e=dojo.create("td",{},_5d);
var _60=dojo.create("div",{className:"manage_buyers_okButton"},_5e);
this._connections.push(dojo.connect(_60,"onclick",dojo.hitch(this,"onOK")));
}});
dojo.declare("Px.Ex.TPubDialog",[Px.Ex.ModalDialogMixin,Px.Ex.XhrMixin],{tpubId:0,reloadTpubsGrid:undefined,showUsersScreen:undefined,readOnly:false,publisher:undefined,constructor:function(_1){
dojo.mixin(this,_1);
},show:function(){
var _2=dojo.hitch(this,"loadAddEditDialog");
this.modalDialog(_2);
},loadAddEditDialog:function(){
this.setTopCss(50);
var _3=this.tpubId>0?(this.readOnly?Px.Ex.Application.Titles.TPUB_DETAILS:Px.Ex.Application.Titles.EDIT_TPUB):Px.Ex.Application.Titles.NEW_TPUB;
Px.Ex.Application.menu.buildDialogSubTitle(_3);
this.xhrLoad({selector:"#divModalDialogContent",content:{tpubId:this.tpubId,readOnly:this.readOnly},url:"/sellers/tpub-dialog",load:dojo.hitch(this,"bindNewTpubDialogEvents")});
},cleanupForm:function(){
var f=dojo.getObject("_form",false,this);
if(f){
f.form.destroyRecursive();
delete f;
}
},bindNewTpubDialogEvents:function(){
$("#divModalDialog #cancel").click(dojo.hitch(this,function(){
$.modal.impl.close();
this.cleanupForm();
}));
if(!this.readOnly){
$("#divModalDialog #submit").click(dojo.hitch(this,"validateAndSendNewTpub"));
}
dojo.query("#divDialogSubMenu2").html(Px.Ex.Application.menu.getSubTitleHtml(Px.Ex.Application.Titles.TPUB_CONTRACT));
var _4=dojo.getObject("_form",true,this);
_4.form=new dijit.form.Form({onSubmit:function(){
return false;
}},"newTpubFormId");
_4.form.connect(_4.form.domNode,"onkeydown",dojo.hitch(this,function(e){
if((e.keyCode==dojo.keys.ENTER||e.keyCode==dojo.keys.NUMPAD_ENTER)&&e.target.type!="textarea"){
setTimeout(dojo.hitch(this,this.validateAndSendNewTpub),10);
}
}));
var _5,_6;
if(dojo.byId("div-publisher-id")){
_5=dojo.fromJson(dojo.byId("div-publisher-id").innerHTML);
this.publisher=_5;
_6=dojo.fromJson(dojo.byId("div-contract-id").innerHTML);
if(_6&&_6.billingType==1){
_6.billingPrice*=100;
}
this.contract=_6;
dojo.byId("usReportingId").checked=_5.usReporting;
dojo.byId("demographicId").checked=_5.demographic;
}
var m=dojo.fromJson(dojo.byId("div-messages-id").innerHTML);
_4.tpubName=new Px.Ex.ValidationTextBox({"class":"new-tpub-dialog tpub-name",name:"tpubName",trim:true,required:true,tabIndex:1,promptMessage:m.promptTpubName||"",invalidMessage:m.invalidTpubName||"$_unset_$",emptyMessage:m.emptyTpubName||"$_unset_$",disabled:this.readOnly,maxLength:50,value:_5?_5.entityName:"",regExp:"(?:\\w|\\s|\\d|[\\.\\-+=$#@&\\*,\\(\\)[\\]{}\\|])*"},"tpubNameId");
_4.tpubUrl=new Px.Ex.ValidationTextBox({"class":"new-tpub-dialog tpub-url",name:"tpubUrl",trim:true,required:false,tabIndex:2,promptMessage:m.promptTpubUrl||"",invalidMessage:m.invalidTpubUrl||"$_unset_$",emptyMessage:m.emptyTpubUrl||"$_unset_$",disabled:this.readOnly,value:_5?_5.entityUrl:"",regExp:"([h,H][t,T][t,T][p,P][s,S]?\\://)?((([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])*)\\.)+[a-zA-Z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(/[a-zA-Z0-9%_.~+-]*)*(\\?[a-zA-Z0-9%;&_.~+=-]*)?(\\#[-a-zA-Z0-9_]*)?"},"tpubUrlId");
dojo.attr("usReportingId","tabIndex","3");
dojo.attr("demographicId","tabIndex","4");
_4.tpubNotes=new dijit.form.SimpleTextarea({"class":"new-tpub-dialog tpub-notes",name:"tpubNotes",tabIndex:5,disabled:this.readOnly,value:_5?_5.notes:"",trim:true},"tpubNotesId");
_4.contractName=new Px.Ex.ValidationTextBox({"class":"new-tpub-dialog contract-name",name:"contractName",trim:true,required:true,tabIndex:6,maxLength:50,promptMessage:m.promptContractName||"",invalidMessage:m.invalidContractName||"$_unset_$",emptyMessage:m.emptyContractName||"$_unset_$",disabled:this.readOnly,value:_6?_6.contractName:"",regExp:"(?:\\w|\\s|\\d|[\\.\\-+=$#@&\\*,\\(\\)[\\]{}\\|])*"},"contractNameId");
if(!this.readOnly){
_4.tpubName.onBlur=_4.contractName.onFocus=function(){
if(_4.contractName.attr("value")==""){
if(!_4.tpubName.isValid()){
return;
}
var _7=_4.tpubName.attr("value");
if(_7==""){
return;
}
var d=new Date();
_4.contractName.attr("value",_7+" "+dojo.date.locale.format(d,{datePattern:"MMM",selector:"date"})+" "+dojo.date.locale.format(d,{datePattern:"yyyy",selector:"date"}));
}
};
}
dojo.attr("billingTypeId","tabIndex","7");
_4.rate=new Px.Ex.NumberTextBox({"class":"new-tpub-dialog rate",name:"rate",intermediateChanges:true,tabIndex:8,constraints:{min:0,max:100,pattern:"#,###,###,##0.####"},promptMessage:m.promptRate||"",invalidMessage:m.invalidRate||"$_unset_$",emptyMessage:m.emptyRate||"$_unset_$",required:true,disabled:this.readOnly,value:_6?_6.billingPrice:66.66},"rateId");
_4.monthlyMin=new Px.Ex.NumberTextBox({"class":"new-tpub-dialog monthly-min",name:"monthlyMin",intermediateChanges:true,tabIndex:9,constraints:{min:0,pattern:"#,###,###,##0"},promptMessage:m.promptMonthlyMin||"",invalidMessage:m.invalidMonthlyMin||"$_unset_$",emptyMessage:m.emptyMonthlyMin||"$_unset_$",required:true,disabled:this.readOnly,value:_6?_6.monthMinPayment:0},"monthlyMinId");
_4.monthlyMax=new Px.Ex.NumberTextBox({"class":"new-tpub-dialog monthly-max",name:"monthlyMax",intermediateChanges:true,tabIndex:10,constraints:{min:0,pattern:"#,###,###,##0"},promptMessage:m.promptMonthlyMax||"",invalidMessage:m.invalidMonthlyMax||"$_unset_$",emptyMessage:m.emptyMonthlyMax||"$_unset_$",required:true,disabled:this.readOnly,value:_6?_6.monthMaxPayment:0},"monthlyMaxId");
_4.monthlyUniques=new Px.Ex.NumberTextBox({"class":"new-tpub-dialog monthly-uniques",name:"monthlyUniques",intermediateChanges:true,tabIndex:11,constraints:{min:0,pattern:"#,###,###,##0.####"},promptMessage:m.promptUniques||"",invalidMessage:m.invalidUniques||"$_unset_$",emptyMessage:m.emptyUniques||"$_unset_$",required:true,disabled:this.readOnly,value:_6?_6.ucpmmin:0},"monthlyUniquesId");
if(!this.readOnly){
_4.monthlyMin.onChange=function(_8){
var _9=_4.monthlyMax.attr("value");
if(_9==0){
_8=0;
}
if(_4.monthlyMax.constraints.min!=_8){
_4.monthlyMax.constraints.min=_8;
_4.monthlyMax.validate();
}
};
_4.monthlyMax.onChange=function(_a){
if(_a==0&&_4.monthlyMax.constraints.min!=0){
_4.monthlyMax.constraints.min=0;
_4.monthlyMax.validate();
}else{
_4.monthlyMin.onChange(_4.monthlyMin.attr("value"));
}
};
}
dojo.attr("contractActiveId","tabIndex","12");
dojo.attr("contractDefaultId","tabIndex","13");
var _b=new Date();
_b.setDate(1);
_b.setHours(0,0,0,0);
var _c=new Px.Ex.DateTextBoxWithIcon({required:true,value:_b,tabIndex:14,disabled:this.readOnly,constraints:{min:_b},invalidMessage:m.invalidStart||"$_unset_$",emptyMessage:m.emptyStart||"$_unset_$",promptMessage:m.promptStart||"","class":"new-tpub-dialog start-date",name:"startDate"},"startDateId");
var fn=function(){
var d=_c.attr("value");
if(!d){
d=new Date();
}
d.setDate(1);
d=dojo.date.add(d,"month",1);
return d;
};
var _d=new Px.Ex.CustomizedDateTextBox({constraints:{min:_b},getEmptyDate:fn,tabIndex:15,disabled:this.readOnly,invalidMessage:m.invalidEnd||"$_unset_$",emptyMessage:m.emptyEnd||"$_unset_$",promptMessage:m.promptEnd||"","class":"new-tpub-dialog end-date",name:"endDate"},"endDateId");
if(!this.readOnly){
_c.onChange=function(_e){
_d.constraints.min=_e;
_d.validate();
};
}
_4.startDate=_c;
_4.endDate=_d;
dojo.attr("countingMethodId","tabIndex","16");
if(dojo.byId("div-publisher-id")&&!this.readOnly){
$("#divModalDialog #advanced_edit").click(dojo.hitch(this,function(){
if(!this._form.form.validate()){
return;
}
var _f=dojo.hitch(this,function(){
this.advancedEditDialog(false,this._getFormData());
});
var _10=dojo.hitch(this,function(){
this.unbindSubmitCancelEvents();
$("#divModalDialog #advanced_edit").unbind("click");
this.cleanupForm();
this.advancedEditDialog(false);
});
var _11=dojo.hitch(this,function(){
if(!this._startFormData){
return false;
}
return (this._startFormData!=dojo.toJson(this._getFormData()));
});
if(_11()){
var d=new Px.Ex.MessageDialog({message:"The data has been changed. Do you want to save these changes?",okLabel:"Yes",cancelLabel:"No",okCallback:_f,cancelCallback:_10});
d.show();
}else{
_10();
}
}));
}
if(!this.readOnly&&dojo.byId("billingTypeId").value==1){
this._form.revshareWasSelected=true;
}
var _12=dojo.hitch(this,function(val){
if(val==1){
this._form.rate.constraints.max=100;
if(!this.readOnly){
this._form.rate.attr("value","66.66");
this._form.revshareWasSelected=true;
}
dojo.style("beforeRateId","display","none");
dojo.style("afterRateId","display","inline");
}else{
delete this._form.rate.constraints.max;
dojo.style("beforeRateId","display","inline");
dojo.style("afterRateId","display","none");
if(!this.readOnly&&this._form.revshareWasSelected){
this._form.rate.attr("value","");
delete this._form.revshareWasSelected;
}
}
if(!this.readOnly){
this._form.rate.attr("value",this._form.rate.attr("value"));
this._form.rate.validate();
}
if(val==2&&!this.readOnly){
_4.monthlyMin.attr("readOnly",true);
_4.monthlyMin.attr("value",_4.rate.attr("value"));
_4.rate.onChange=function(val){
_4.monthlyMin.attr("value",val);
};
}else{
_4.monthlyMin.attr("readOnly",false);
_4.rate.onChange=function(val){
};
}
if(!this.readOnly){
this.buildCountingMethodCombo();
}
});
_4.form.connect(dojo.byId("billingTypeId"),"onchange",function(e){
_12(e.target.value);
});
if(!this.readOnly){
_4.form.connect(dojo.byId("demographicId"),"onchange",dojo.hitch(this,function(e){
this.buildCountingMethodCombo();
}));
_4.monthlyUniques.onChange=dojo.hitch(this,function(e){
this.buildCountingMethodCombo();
});
}
this.prepareCountingMethodsCombo();
this.buildCountingMethodCombo();
if(_6){
delete _c.constraints.min;
_c.validate();
_c.attr("value",_6.startDate?dojo.date.stamp.fromISOString(_6.startDate):"");
_d.constraints.min=_c.attr("value");
_d.attr("value",_6.endDate?dojo.date.stamp.fromISOString(_6.endDate):"");
dojo.forEach(dojo.byId("billingTypeId").options,function(v,i,a){
if(v.value==_6.billingType){
dojo.byId("billingTypeId").selectedIndex=i;
}
});
dojo.byId("contractActiveId").checked=_6.active;
dojo.byId("contractDefaultId").checked=_6.defaultContract;
dojo.forEach(dojo.byId("countingMethodId").options,function(v,i,a){
if(v.value==_6.invoiceType){
dojo.byId("countingMethodId").selectedIndex=i;
}
});
if(_6.billingType!=1){
_12();
}
}
if(this.readOnly){
dojo.attr("usReportingId","disabled","disabled");
dojo.attr("demographicId","disabled","disabled");
dojo.attr("contractActiveId","disabled","disabled");
dojo.attr("contractDefaultId","disabled","disabled");
dojo.attr("billingTypeId","disabled","disabled");
dojo.attr("countingMethodId","disabled","disabled");
}
_4.tpubName.focus();
if(dojo.byId("div-publisher-id")&&!this.readOnly){
this._startFormData=dojo.toJson(this._getFormData());
}else{
this._startFormData=undefined;
}
},prepareCountingMethodsCombo:function(){
var _13=dojo.byId("countingMethodId");
this._countingMethodOptions=[];
dojo.forEach(_13.options,function(v){
this._countingMethodOptions.push([v.value,v.innerHTML]);
},this);
_13.innerHTML="";
},buildCountingMethodCombo:function(){
var _14=dojo.byId("countingMethodId");
_14.innerHTML="";
if(Boolean(dijit.byId("monthlyUniquesId").attr("value"))){
dojo.forEach(this._countingMethodOptions,function(v){
if(v[0]=="10"){
dojo.create("option",{value:v[0],innerHTML:v[1],selected:"selected"},_14);
}
});
}else{
if(dojo.byId("demographicId").checked){
dojo.forEach(this._countingMethodOptions,function(v){
if(v[0]=="9"){
dojo.create("option",{value:v[0],innerHTML:v[1],selected:"selected"},_14);
}
});
}else{
var o=dojo.byId("billingTypeId");
var val=o.options[o.selectedIndex].value;
if(val=="1"){
dojo.forEach(this._countingMethodOptions,function(v){
if(dojo.indexOf(["1","9","10"],v[0])!=-1){
var op=dojo.create("option",{value:v[0],innerHTML:v[1]},_14);
if(v[0]=="1"){
op.selected="selected";
}
}
});
}else{
if(val=="2"){
dojo.forEach(this._countingMethodOptions,function(v){
if(v[0]=="2"){
dojo.create("option",{value:v[0],innerHTML:v[1],selected:"selected"},_14);
}
});
}else{
if(val=="3"){
dojo.forEach(this._countingMethodOptions,function(v){
if(dojo.indexOf(["3","4","5","8"],v[0])!=-1){
var op=dojo.create("option",{value:v[0],innerHTML:v[1]},_14);
if(v[0]=="4"){
op.selected="selected";
}
}
});
}else{
if(val=="4"){
dojo.forEach(this._countingMethodOptions,function(v){
if(dojo.indexOf(["6","8"],v[0])!=-1){
var op=dojo.create("option",{value:v[0],innerHTML:v[1]},_14);
if(v[0]=="6"){
op.selected="selected";
}
}
});
}
}
}
}
}
}
},_getFormData:function(){
var o=this._form.form.attr("value");
dojo.forEach(["usReporting","demographic","contractActive","contractDefault"],function(v){
o[v]=dojo.byId(v+"Id").checked?"on":"";
});
dojo.forEach(["billingType","countingMethod"],function(v){
var _15=dojo.byId(v+"Id");
var val=_15.options[_15.selectedIndex].value;
o[v]=val;
});
if(!isNaN(o.rate)&&o.billingType=="1"){
o.rate=o.rate/100;
}
dojo.forEach(["rate","monthlyMax","monthlyMin","monthlyUniques"],function(v){
if(isNaN(o[v])){
o[v]=null;
}
});
if(o.startDate){
o.startDate=dojo.date.stamp.toISOString(o.startDate,{zulu:true,milliseconds:true});
}
if(o.endDate){
o.endDate=dojo.date.stamp.toISOString(o.endDate,{zulu:true,milliseconds:true});
}
if(this.tpubId){
o.publisherCode=this.tpubId;
}
o.contractCode=this.contract?this.contract.contractCode:-1;
return o;
},validateAndSendNewTpub:function(){
if(!this._form.form.validate()){
return;
}
this.clearError();
this.hideDialogContentAndWait(dojo.hitch(this,function(){
this.xhr({url:"/sellers/add-edit-tpub-full",content:this._getFormData(),handleAs:"json",load:dojo.hitch(this,"addEditTpubResponse",this.tpubId)});
}));
},addEditTpubResponse:function(_16,_17){
if(_16){
if(_17["return"]){
ret=_17["return"];
if(ret.success!==undefined&&!ret.success){
this.showDialogContentOnError(_17);
}else{
this.publisher=ret;
this.cleanupForm();
this.unbindSubmitCancelEvents();
this.showDialogContentOnSuccess("T-Pub "+ret.entityName+" was saved successfully!");
this.reloadTpubsGrid();
}
}else{
this.showDialogContentOnError(_17);
}
}else{
var _18=dojo.hitch(this,function(_19){
this.cleanupForm();
this.unbindSubmitCancelEvents();
this.tpubId=_19.publisherCode;
this.xhrLoad({selector:"#divModalDialogContent",content:{id:_19.publisherCode,name:_19.entityName,displayCode:_19.displayCode},url:"/sellers/new-tpub-success-dialog",load:dojo.hitch(this,"bindNewTpubSuccessDialogEvents")});
this.reloadTpubsGrid();
});
if(_17["return"]){
ret=_17["return"];
if(ret.success!==undefined&&!ret.success){
this.showDialogContentOnError(_17);
}else{
this.publisher=ret;
_18(ret);
this.setTopCss(100);
}
}else{
this.showDialogContentOnError(_17);
}
}
},unbindNewTpubSuccessDialogEvents:function(){
$("#divModalDialog #done").unbind("click");
$("#divModalDialog #edit").unbind("click");
$("#divModalDialog #advanced_edit").unbind("click");
$("#divModalDialog #create_texi_users").unbind("click");
},bindNewTpubSuccessDialogEvents:function(){
this.showDialogContent();
$("#divModalDialog #done").click(dojo.hitch(this,function(){
this.unbindNewTpubSuccessDialogEvents();
$.modal.impl.close();
}));
$("#divModalDialog #advanced_edit").click(dojo.hitch(this,function(){
this.unbindNewTpubSuccessDialogEvents();
this.advancedEditDialog(true);
}));
$("#divModalDialog #edit").click(dojo.hitch(this,function(){
this.unbindNewTpubSuccessDialogEvents();
dojo.query("#divModalDialogContent").html(Px.Ex.Application.getWaitHtml());
this.loadAddEditDialog();
}));
$("#divModalDialog #create_texi_users").click(dojo.hitch(this,function(){
this.unbindNewTpubSuccessDialogEvents();
$.modal.impl.close();
if(this.showUsersScreen){
this.showUsersScreen(this.tpubId);
}
}));
},advancedEditDialog:function(_1a,_1b){
var _1c=dojo.hitch(this,function(){
var _1d=new Px.Ex.TPubAdvancedDialog({tpubId:this.tpubId,publisher:this.publisher,fromNew:_1a});
_1d.loadDialog();
});
var _1e=dojo.hitch(this,function(_1f){
if(_1f["return"]){
ret=_1f["return"];
if(ret.success!==undefined&&!ret.success){
this.showDialogContentOnError(_1f);
}else{
this.publisher=ret;
this.reloadTpubsGrid();
this.unbindSubmitCancelEvents();
$("#divModalDialog #advanced_edit").unbind("click");
this.cleanupForm();
_1c();
}
}else{
this.showDialogContentOnError(_1f);
}
});
this.hideDialogContentAndWait(dojo.hitch(this,function(){
if(_1b){
this.xhr({url:"/sellers/add-edit-tpub-full",content:_1b,handleAs:"json",load:_1e});
}else{
_1c();
}
}));
}});
(function(){
dojo.declare("Px.Ex.TPubAdvancedDialog",[Px.Ex.ModalDialogMixin,Px.Ex.XhrMixin],{tpubId:0,publisher:undefined,fromNew:false,constructor:function(_1){
dojo.mixin(this,_1);
this._segments=undefined;
},show:function(){
var _2=dojo.hitch(this,"loadDialog");
this.modalDialog(_2);
},loadDialog:function(){
this.setTopCss(50);
var _3=Px.Ex.Application.Titles.ADVANCED_EDIT;
Px.Ex.Application.menu.buildDialogSubTitle(_3);
this.xhrLoad({selector:"#divModalDialogContent",content:{tpubId:this.tpubId,publisher:dojo.toJson(this.publisher)},url:"/sellers/advanced-edit-dialog",load:dojo.hitch(this,"bindDialogEvents")});
},bindDialogEvents:function(){
this.showDialogContent();
this.setTopCss(50);
$("#divModalDialog #cancel").click(dojo.hitch(this,function(){
$.modal.impl.close();
this.cleanupForm();
}));
$("#divModalDialog #submit").click(dojo.hitch(this,"validateAndSend"));
this._connections=[];
this._connections.push(dojo.connect(dojo.byId("advancedEditFormId"),"onkeydown",this,function(e){
if((e.keyCode==dojo.keys.ENTER||e.keyCode==dojo.keys.NUMPAD_ENTER)&&e.target.type!="textarea"){
setTimeout(dojo.hitch(this,this.validateAndSend),10);
}
}));
this._segments={};
dojo.forEach(dojo.byId("segmentsId").options,function(v){
this._segments[v.value]=v.text;
},this);
dojo.forEach(dojo.byId(["count","show"]),function(v){
this.bindRowButtons(v,true);
},this);
this.createDaysBackControl(this.publisher.liveInsightDays,this.publisher.liveInsightOn);
if(this.fromNew&&this.publisher&&this.publisher.demographic){
this.setDefault();
}else{
this.setSegments("count",this.publisher.segmentsToCount);
this.setSegments("show",this.publisher.segmentsToShow);
this.setSegments("insight",this.publisher.historyChannelsToShow);
this.enableInsight(this.publisher.liveInsightOn);
dojo.byId("insightId").checked=Boolean(this.publisher.liveInsightOn);
}
this._connections.push(dojo.connect(dojo.byId("insightId"),"onclick",this,function(e){
this.enableInsight(e.target.checked);
}));
if(dojo.isChrome){
dojo.style("insightSegmentsId","height","100%");
}
},createDaysBackControl:function(_4,_5){
this.setDaysBackValue(_4);
this.showDaysBack(!_5);
},setSegments:function(s,_6){
if(!_6||_6.length==0){
return;
}
_6=_6.split(/,/);
var _7=[];
dojo.forEach(dojo.byId("segmentsId").options,function(v){
for(var i=_6.length-1;i>=0;--i){
if(_6[i]==v.value){
_7.push(v);
_6.splice(i,1);
break;
}
}
});
if(!_7.length){
return;
}
var o=dojo.byId(s+"SegmentsId");
try{
dojo.forEach(_7,function(v){
o.add(new Option(v.text,v.value));
});
}
catch(e){
dojo.forEach(_7,function(v){
o.add(new Option(v.text,v.value),null);
});
}
},enableInsight:function(_8){
this.bindRowButtons("insight",_8);
dojo.byId("insightSegmentsId").disabled=!_8;
this.showDaysBack(_8);
},showDaysBack:function(_9){
dojo.style("daysBackId","visibility",_9?"visible":"hidden");
dojo.query("label[for='daysBackId']").style("visibility",_9?"visible":"hidden");
},bindRowButtons:function(s,_a){
var c=this["_connections_"+s];
if(_a){
if(!c){
c=this["_connections_"+s]=[];
}else{
return;
}
c.push(dojo.connect(dojo.byId(s+"-right-id"),"onclick",null,dojo.hitch(this,"addSelected",s)));
c.push(dojo.connect(dojo.byId(s+"-left-id"),"onclick",null,dojo.hitch(this,"removeSelected",s)));
c.push(dojo.connect(dojo.byId(s+"-right-all-id"),"onclick",null,dojo.hitch(this,"addAll",s)));
c.push(dojo.connect(dojo.byId(s+"-left-all-id"),"onclick",null,dojo.hitch(this,"removeAll",s)));
}else{
if(!c){
return;
}
dojo.forEach(c,dojo.disconnect);
delete this["_connections_"+s];
}
},setDefault:function(){
var _b=[];
var _c=[];
var _d={"80869":1,"80870":1};
var _e={"80869":1,"80870":1,"80871":1,"80872":1,"80873":1,"80874":1,"80875":1,"80876":1,"80877":1};
dojo.forEach(dojo.byId("segmentsId").options,function(v){
if(v.value in _d){
_b.push(v);
}
if(v.value in _e){
_c.push(v);
}
});
var _f=dojo.byId("showSegmentsId");
var _10=dojo.byId("countSegmentsId");
try{
dojo.forEach(_c,function(v){
_f.add(new Option(v.text,v.value));
});
}
catch(e){
dojo.forEach(_c,function(v){
_f.add(new Option(v.text,v.value),null);
});
}
try{
dojo.forEach(_b,function(v){
_10.add(new Option(v.text,v.value));
});
}
catch(e){
dojo.forEach(_b,function(v){
_10.add(new Option(v.text,v.value),null);
});
}
this.setDaysBackValue(30);
},setDaysBackValue:function(val){
val=val||30;
dojo.some([val,30],function(v,i,a){
return dojo.some(dojo.byId("daysBackId").options,function(v,i,a){
if(v.value==val){
dojo.byId("daysBackId").selectedIndex=i;
}
return v.value==val;
});
});
},addSelected:function(s){
var o=dojo.byId(s+"SegmentsId");
o.selectedIndex=-1;
var ops={};
var add=[];
dojo.forEach(o.options,function(v){
ops[v.value]=v;
add.push(v);
});
var _11=dojo.byId("segmentsId").options;
var _12=false;
o.options.length=0;
dojo.forEach(_11,function(v){
if(v.selected){
if(!(v.value in ops)){
add.push(new Option(v.text,v.value,false,true));
_12=true;
}else{
ops[v.value].selected=true;
}
}
});
if(_12){
add.sort(function(a,b){
return a.text>b.text?1:(a.text<b.text?-1:0);
});
}
try{
dojo.forEach(add,function(v){
o.add(v);
});
}
catch(e){
dojo.forEach(add,function(v){
o.add(v,null);
});
}
},removeSelected:function(s){
var o=dojo.byId(s+"SegmentsId");
var ops=o.options;
for(var i=ops.length-1;i>=0;--i){
if(ops[i].selected){
o.remove(i);
}
}
},addAll:function(s){
this.removeAll(s);
var o=dojo.byId(s+"SegmentsId");
var _13=dojo.byId("segmentsId").options;
try{
dojo.forEach(_13,function(v){
o.add(new Option(v.text,v.value));
});
}
catch(e){
dojo.forEach(_13,function(v){
o.add(new Option(v.text,v.value),null);
});
}
},removeAll:function(s){
var o=dojo.byId(s+"SegmentsId");
for(var i=o.options.length-1;i>=0;--i){
o.remove(i);
}
},cleanupForm:function(){
dojo.forEach(dojo.byId(["count","show","insight"]),function(v){
this.bindRowButtons(v,false);
},this);
dojo.forEach(this._connections,dojo.disconnect,this);
},getSegmentIds:function(s){
return dojo.map(dojo.byId(s+"SegmentsId").options,function(v){
return v.value;
}).join(",");
},validateAndSend:function(){
this.publisher.liveInsightOn=dojo.byId("insightId").checked;
if(this.publisher.liveInsightOn){
this.publisher.liveInsightDays=dojo.byId("daysBackId").value;
this.publisher.historyChannelsToShow=this.getSegmentIds("insight");
if(this.publisher.historyChannelsToShow==""){
this.animateErrorMessage("Please add at least one segment to the Insight segment selection area or uncheck Insight");
return;
}
}else{
this.publisher.liveInsightDays=0;
this.publisher.historyChannelsToShow="";
}
this.publisher.segmentsToCount=this.getSegmentIds("count");
this.publisher.segmentsToShow=this.getSegmentIds("show");
this.clearError();
this.hideDialogContentAndWait(dojo.hitch(this,function(){
this.xhr({url:"/sellers/advanced-edit",content:{publisher:dojo.toJson(this.publisher)},handleAs:"json",load:dojo.hitch(this,"advancedEditResponse")});
}));
},advancedEditResponse:function(_14){
if(_14["return"]){
ret=_14["return"];
if(ret.success!==undefined&&!ret.success){
this.showDialogContentOnError(_14);
}else{
this.publisher=ret;
this.cleanupForm();
this.showDialogContentOnSuccess("T-Pub "+ret.entityName+" was saved successfully!");
}
}else{
this.showDialogContentOnError(_14);
}
}});
})();
(function(){
dojo.declare("Px.Ex.TPubUserDialog",[Px.Ex.ModalDialogMixin,Px.Ex.XhrMixin],{user:undefined,messages:undefined,EMAIL_REGEXP:".*",NAME_REGEXP:".*",reloadUsersGrid:undefined,constructor:function(_1){
dojo.mixin(this,_1);
},show:function(){
var _2=dojo.hitch(this,"loadDialog");
this.modalDialog(_2);
},loadDialog:function(){
this.setTopCss(50);
var _3=Px.Ex.Application.Titles.EDIT_TPUB_USER;
Px.Ex.Application.menu.buildDialogSubTitle(_3);
this.xhrLoad({selector:"#divModalDialogContent",content:{user:dojo.toJson(this.user)},url:"/sellers/tpub-user-dialog",load:dojo.hitch(this,"bindDialogEvents")});
},cleanupForm:function(){
if(this._form){
this._form.destroyRecursive();
delete this._form;
}
},bindDialogEvents:function(){
var u=this.user=dojo.fromJson(dojo.byId("userDataId").innerHTML);
$("#divModalDialog #cancel").click(dojo.hitch(this,function(){
$.modal.impl.close();
this.cleanupForm();
}));
if(!this.readOnly){
$("#divModalDialog #submit").click(dojo.hitch(this,"validateAndSend"));
}
var f=this._form=new dijit.form.Form({onSubmit:function(){
return false;
}},"editUserFormId");
f.connect(f.domNode,"onkeydown",dojo.hitch(this,function(e){
if((e.keyCode==dojo.keys.ENTER||e.keyCode==dojo.keys.NUMPAD_ENTER)&&e.target.type!="textarea"){
setTimeout(dojo.hitch(this,this.validateAndSend),10);
}
}));
var m=this.messages;
dojo.byId("usernameId2").innerHTML=u.userName;
dojo.byId("emailId2").innerHTML=u.email;
new Px.Ex.ValidationTextBox({name:"firstName",value:u.firstName,trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptFirstName||"",invalidMessage:m.invalidFirstName||"$_unset_$",emptyMessage:m.emptyFirstName||"$_unset_$","class":"form-input"},"firstNameId2");
new Px.Ex.ValidationTextBox({name:"lastName",value:u.lastName,trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptLastName||"",invalidMessage:m.invalidLastName||"$_unset_$",emptyMessage:m.emptyLastName||"$_unset_$","class":"form-input"},"lastNameId2");
new dijit.form.CheckBox({name:"active",checked:u.active},"activeId2");
new dijit.form.CheckBox({name:"sendWelcomeEmail",checked:u.sendWelcomeEmail},"sendWelcomeEmailId2");
new dijit.form.CheckBox({name:"passwordExpiration",checked:u.passwordExpiration},"passwordExpirationId2");
this.userRolesStore=new dojo.data.ItemFileReadStore({data:dojo.fromJson(dojo.byId("userRolesDataId").value)});
this.userRolesCombo=new Px.Ex.FilteringSelect({name:"roleCode",store:this.userRolesStore,value:u.roleCode,promptMessage:m.promptUserRoles||"",invalidMessage:m.invalidUserRoles||"$_unset_$",emptyMessage:m.emptyUserRoles||"$_unset_$",searchAttr:"name","class":"form-input"},"roleId2");
},validateAndSend:function(){
if(!this._form.validate()){
return;
}
var o=this._form.attr("value");
o.active=o.active[0]||"";
o.sendWelcomeEmail=o.sendWelcomeEmail[0]||"";
o.passwordExpiration=o.passwordExpiration[0]||"";
o=dojo.mixin({},this.user,o);
this._newUser=o;
this.clearError();
this.hideDialogContentAndWait(dojo.hitch(this,function(){
this.xhr({url:"/sellers/save-user",content:{user:dojo.toJson(o)},handleAs:"json",load:dojo.hitch(this,"saveUserResponse")});
}));
},saveUserResponse:function(_4){
if(_4["return"]){
ret=_4["return"];
if(ret.success!==undefined&&!ret.success){
this.showDialogContentOnError(_4);
}else{
this.cleanupForm();
this.showDialogContentOnSuccess("User "+this._newUser.userName+" was saved successfully!");
this.reloadUsersGrid();
}
}else{
this.showDialogContentOnError(_4);
}
},destroy:function(){
this.cleanupForm();
}});
})();
dojo.declare("Px.Ex.ContractsScreen",[Px.Ex.XhrMixin],{tpubId:0,tpubName:"",constructor:function(_1){
dojo.mixin(this,_1);
},draw:function(){
var _2=this;
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/sellers/contracts",content:{tpubId:this.tpubId,tpubName:this.tpubName},load:function(_3){
dojo.byId("divContent").innerHTML=_3;
}});
}});
dojo.declare("Px.Ex.TPubUsersScreen",[Px.Ex.XhrMixin],{tpubId:0,tpubName:"",allowSetUserStatus:false,allowEditUser:false,messages:undefined,ALL_REGEXP:".*",EMAIL_REGEXP:"[^@]+@[^@]+\\.\\w{2,}",PWD_REGEXP:".*\\d+.*",NAME_REGEXP:"[a-zA-Z. -]*",constructor:function(_1){
dojo.mixin(this,_1);
},draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhrLoad({selector:"#divContent",url:"/sellers/users",content:{tpubId:this.tpubId,tpubName:this.tpubName},load:dojo.hitch(this,"createScreen")});
},createScreen:function(_2){
this.tpubId=dojo.byId("tpubId").value;
this.allowSetUserStatus=dojo.byId("allowSetUserStatusId").value;
this.allowEditUser=dojo.byId("allowEditUserId").value;
this.messages=dojo.fromJson(dojo.byId("div-messages-id").innerHTML);
if(dojo.byId("tpubComboId")){
this.createTpubCombo("tpubComboId");
}
if(dojo.byId("usersListId")){
this.createUsersGrid("usersListId");
}
if(dojo.byId("roundedFormBorderId")){
this.prepareCreateUserForm();
this._showTpubName();
}
},createTpubCombo:function(_3){
this.tpubStore=new dojo.data.ItemFileReadStore({data:dojo.fromJson(dojo.byId("tpubComboDataId").value)});
this.tpubCombo=new dijit.form.FilteringSelect({store:this.tpubStore,value:dojo.byId("tpubId").value,searchAttr:"name",onChange:dojo.hitch(this,"onChangeTpub")},_3);
this.tpubCombo.startup();
},onChangeTpub:function(_4){
if(this.usersStore._loadInProgress){
this.tpubCombo.attr("value",this.tpubId);
return;
}
this.tpubId=_4;
this.reloadUsersGrid();
},reloadUsersGrid:function(){
if(!this.usersGrid){
return;
}
this.usersStore.save();
this.usersStore.close();
this.usersStore._jsonFileUrl=this._getUsersUrl();
this.usersGrid.selection.deselectAll();
this.usersGrid._refresh();
this._showTpubName();
},_showTpubName:function(){
try{
var _5=this.tpubStore.getLabel(this.tpubStore._getItemByIdentity(this.tpubId));
dojo.byId("usersForId").innerHTML=_5;
dojo.byId("tpubnameId").innerHTML=_5;
}
catch(e){
}
},_getUsersUrl:function(){
return "/sellers/users-list"+"?entityCode="+this.tpubId;
},_itemToObject:function(_6,_7){
var _8={};
for(var _9 in _7){
if(_9!==_6._storeRefPropName&&_9!==_6._itemNumPropName&&_9!==_6._reverseRefMap&&_9!==_6._rootItemPropName){
var _a=_9;
var _b=_6.getValues(_7,_a);
if(_b.length==1){
_8[_a]=_6._flatten(_b[0]);
}else{
var _c=[];
for(var j=0;j<_b.length;++j){
_c.push(_6._flatten(_b[j]));
_8[_a]=_c;
}
}
}
}
return _8;
},_onUsersStoreSet:function(_d,_e,_f,_10){
if(_e!="active"||_f==_10){
this.usersStore.save();
return;
}
if(this.allowSetUserStatus){
this.standBy.show();
this.xhr({url:"/sellers/activate-user",content:{user:dojo.toJson(this._itemToObject(this.usersStore,_d))},handle:dojo.hitch(this,function(_11){
this.standBy.hide();
if(_11 instanceof Error||!_11["return"]||!_11["return"].success){
this.disconnectUsersStore();
this.usersStore.setValue(_d,_e,_f);
this.usersStore.save();
this.connectUsersStore();
}
}),handleAs:"json"});
this.usersStore.save();
}else{
this.disconnectUsersStore();
this.usersStore.setValue(_d,_e,_f);
this.usersStore.save();
this.connectUsersStore();
}
},connectUsersStore:function(){
this._usersStoreConnection=dojo.connect(this.usersStore,"onSet",this,"_onUsersStoreSet");
},disconnectUsersStore:function(){
if(this._usersStoreConnection){
dojo.disconnect(this._usersStoreConnection);
}
},createUsersGrid:function(div){
this.standBy=new dojox.widget.Standby({target:dojo.body()},dojo.create("div",{},dojo.body()));
this.standBy.startup();
this.usersStore=new dojo.data.ItemFileWriteStore({clearOnClose:true,url:this._getUsersUrl()});
this.connectUsersStore();
var _12=dojo.hitch(this,function(_13){
return "";
});
var _14=dojo.hitch(this,function(_15,_16){
var _17=this.usersGrid.getItem(_16);
if(!_17){
return "";
}
return "<a class=\"a-in-grid\" href=\"javascript:\">Edit</a>";
});
var _18=dojo.hitch(this,function(_19,_1a){
if(_19!=null){
return dojo.string.substitute("<div class=\"dojoxEllipsis\" title=\"${0}\">${1}</div>",[_19,_19]);
}else{
return ("<div class=\"dojoxEllipsis\" style=\"white-space:nowrap;\">N/A</div>");
}
});
var _1b=[{defaultCell:{styles:"white-space:nowrap;"},cells:[{name:"",get:_12,formatter:_14,styles:"text-align:center;",width:"30px",noresize:true,hidden:!this.allowEditUser},{name:"Active",field:"active",width:"40px",noresize:true,editable:true,type:dojox.grid.cells.Bool,styles:"text-align:center;vertical-align:bottom;padding-bottom:2px;"},{name:"First name",field:"firstName",formatter:_18,width:"60px",noresize:true},{name:"Last name",field:"lastName",formatter:_18,width:"83px",noresize:true},{name:"Email",field:"email",formatter:_18,width:"115px",noresize:true},{name:"Role",field:"role",formatter:_18,width:"73px",noresize:true},{name:"Last login",field:"lastLogin",formatter:_18,width:"100%",noresize:true},{name:"contact code",field:"contactCode",hidden:true}]}];
var _1c=dojo.hitch(this,function(){
var _1d={loadingMessage:Px.Ex.Application.getWaitHtml(),store:this.usersStore,query:{email:"*"},queryOptions:{ignoreCase:true},clientSort:true,onFetchError:dojo.hitch(this,function(_1e,req){
if(!req){
return;
}
this.usersGrid._pending_requests[req.start]=false;
}),autoHeight:20,height:"35em",selectionMode:"single",canSort:function(_1f){
return Math.abs(_1f)!=1;
},structure:_1b};
_1d.onRowContextMenu=function(){
};
_1d.selectable=true;
this.usersGrid=new dojox.grid.DataGrid(_1d,div);
this.usersGrid.startup();
this.usersGrid.connect(this.usersGrid,"onRowClick",dojo.hitch(this,function(e){
if(e.cellIndex!=0||e.target.nodeName.toUpperCase()!="A"){
return;
}
var _20=this._itemToObject(e.grid.store,e.grid.getItem(e.rowIndex));
var dlg=new Px.Ex.TPubUserDialog({user:_20,messages:this.messages,EMAIL_REGEXP:this.EMAIL_REGEXP,NAME_REGEXP:this.NAME_REGEXP,reloadUsersGrid:dojo.hitch(this,"reloadUsersGrid")});
dlg.show();
}));
this.usersGrid.connect(this.usersGrid,"onStyleRow",dojo.hitch(this,function(e){
try{
var _21=this.usersGrid.getItem(e.index);
if(_21){
var _22=this.usersGrid.store.getValue(_21,"active");
if(!_22){
e.customClasses+=" user-not-active-class";
}
}
}
catch(e){
}
}));
});
dojo.addOnLoad(_1c);
},prepareCreateUserForm:function(){
this.decorateCreateUserForm();
var f=this._form=new dijit.form.Form({"class":"create-user-form",onSubmit:function(){
return false;
}},"createUserFormId");
if(dojo.byId("T4E-TPUBUSR-CREATE")){
f.connect(dojo.byId("T4E-TPUBUSR-CREATE"),"onclick",dojo.hitch(this,"onCreateUser"));
f.connect(f.domNode,"onkeydown",dojo.hitch(this,function(e){
if((e.keyCode==dojo.keys.ENTER||e.keyCode==dojo.keys.NUMPAD_ENTER)&&e.target.type!="textarea"){
setTimeout(dojo.hitch(this,this.onCreateUser),10);
}
}));
}
var m=this.messages;
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"email",trim:true,regExp:this.EMAIL_REGEXP,required:true,promptMessage:m.promptEmail||"",invalidMessage:m.invalidEmail||"$_unset_$",emptyMessage:m.emptyEmail||"$_unset_$","class":"form-input"},"emailId");
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"firstName",trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptFirstName||"",invalidMessage:m.invalidFirstName||"$_unset_$",emptyMessage:m.emptyFirstName||"$_unset_$","class":"form-input"},"firstNameId");
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"lastName",trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptLastName||"",invalidMessage:m.invalidLastName||"$_unset_$",emptyMessage:m.emptyLastName||"$_unset_$","class":"form-input"},"lastNameId");
this.userRolesStore=new dojo.data.ItemFileReadStore({data:dojo.fromJson(dojo.byId("userRolesDataId").value)});
this.userRolesCombo=new Px.Ex.FilteringSelect({name:"roleCode",store:this.userRolesStore,value:3,promptMessage:m.promptUserRoles||"",invalidMessage:m.invalidUserRoles||"$_unset_$",emptyMessage:m.emptyUserRoles||"$_unset_$",searchAttr:"name","class":"form-input"},"roleId");
new dijit.form.CheckBox({name:"sendWelcomeEmail",checked:true},"sendWelcomeEmailId");
new dijit.form.CheckBox({name:"generateNewPassword",style:{display:"none"},checked:true},"generateNewPasswordId");
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"password",style:{display:"none"},trim:true,type:"password",regExp:this.ALL_REGEXP,promptMessage:m.promptPassword||"",invalidMessage:m.invalidPassword||"$_unset_$",emptyMessage:m.emptyPassword||"$_unset_$","class":"form-input"},"initialPasswordId");
var _23=dojo.byId("sendToId").innerHTML;
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"secondEmail",style:{display:"none"},trim:true,regExp:this.ALL_REGEXP,promptMessage:m.promptSecondEmail||"",invalidMessage:m.invalidSecondEmail||"$_unset_$",emptyMessage:m.emptySecondEmail||"$_unset_$","class":"form-input",value:_23},"sendToId");
f.connect(dijit.byId("sendWelcomeEmailId"),"onClick",dojo.hitch(this,"onSendWelcomeEmail"));
f.connect(dijit.byId("generateNewPasswordId"),"onClick",dojo.hitch(this,"onGenerateNewPassword"));
},showLabel:function(_24,_25){
dojo.query("label[for='"+_24+"']").style("display",_25?"inline":"none");
},showDijit:function(id,_26){
dijit.byId(id).attr("style",{display:_26?"":"none"});
},onSendWelcomeEmail:function(e){
var _27=e.target.checked;
this.showDijit("generateNewPasswordId",!_27);
this.showLabel("generateNewPasswordId",!_27);
var _28=dijit.byId("generateNewPasswordId").checked;
var id=_28?"sendToId":"initialPasswordId";
this.showDijit(id,!_27);
this.showLabel(id,!_27);
this.updatePasswordConstraints();
this.updateSecondEmailConstraints();
},onGenerateNewPassword:function(e){
var _29=e.target.checked;
this.showDijit("sendToId",_29);
this.showLabel("sendToId",_29);
this.showDijit("initialPasswordId",!_29);
this.showLabel("initialPasswordId",!_29);
this.updatePasswordConstraints();
this.updateSecondEmailConstraints();
},updatePasswordConstraints:function(){
var p=dijit.byId("initialPasswordId");
if(!dijit.byId("sendWelcomeEmailId").checked&&!dijit.byId("generateNewPasswordId").checked&&!dijit.byId("initialPasswordId").required){
p.required=true;
p.regExp=this.PWD_REGEXP;
}else{
p.required=false;
p.regExp=this.ALL_REGEXP;
}
},updateSecondEmailConstraints:function(){
if(!dijit.byId("sendWelcomeEmailId").checked&&dijit.byId("generateNewPasswordId").checked){
dijit.byId("sendToId").regExp=this.EMAIL_REGEXP;
}else{
dijit.byId("sendToId").regExp=this.ALL_REGEXP;
}
},decorateCreateUserForm:function(){
var _2a={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _2b=new curvyCorners(_2a,dojo.byId("roundedFormBorderId"));
_2b.applyCornersToAll();
var _2c=dojo.byId("createUserHeaderId");
var _2d="<ul><li class=\"first last\"><span class=\"active\"><span>"+_2c.innerHTML+"</span></span></li></ul>";
_2c.innerHTML=_2d;
},showCreateUserError:function(_2e){
dojo.byId("createUserErrorId").innerHTML=_2e;
},showCreateMessage:function(_2f){
var _30=[];
if(_2f){
_30.push(dojo.string.substitute("User <span class=\"bold\">${userName}</span> was created successfully!",_2f));
if(_2f.sendWelcomeEmail){
_30.push(dojo.string.substitute("A welcome email was sent to <span class=\"bold\">${email}</span>.",_2f));
}
if((_2f.generateNewPassword)&&(_2f.sendWelcomeEmail)){
_30.push(dojo.string.substitute("Password was sent to <span class=\"bold\">${email}</span>.",_2f));
}
if((_2f.generateNewPassword)&&(!_2f.sendWelcomeEmail)){
_30.push(dojo.string.substitute("Password was sent to <span class=\"bold\">${secondEmail}</span>.",_2f));
}
}
dojo.byId("createUserMessageId").innerHTML=_30.join("<br>");
},onCreateUser:function(){
if(isDefined(this.usersStore)){
if(this.usersStore._loadInProgress){
return;
}
}
this.showCreateUserError("");
this.showCreateMessage();
if(!this._form.validate()){
return;
}
o=this._form.attr("value");
o.entityCode=this.tpubId;
o.sendWelcomeEmail=o.sendWelcomeEmail[0]||"";
o.generateNewPassword=o.generateNewPassword[0]||"";
o.passwordExpiration=true;
if(o.sendWelcomeEmail||o.generateNewPassword){
o.password="";
}
o.password=$.base64Encode(o.password);
if(!o.sendWelcomeEmail&&!o.generateNewPassword){
o.secondEmail="";
o.passwordExpiration=false;
}
o.userName=o.email;
var _31=dojo.clone(o);
delete o.generateNewPassword;
var _32=dojo.hitch(this,function(_33,_34){
dojo.fx.chain([dojo.fx.wipeOut({node:dojo.byId("divXhrIndicator")}),dojo.fx.wipeIn({node:dojo.byId("createUserFormId"),onEnd:dojo.hitch(this,function(){
if(_33["return"]){
if(!_33["return"].success){
this.showCreateUserError("Error: "+_33["return"].errorMessage);
}else{
this._form.reset();
this.showDijit("generateNewPasswordId",false);
this.showLabel("generateNewPasswordId",false);
this.showDijit("initialPasswordId",false);
this.showLabel("initialPasswordId",false);
this.showDijit("sendToId",false);
this.showLabel("sendToId",false);
this.updatePasswordConstraints();
this.updateSecondEmailConstraints();
this.reloadUsersGrid();
this.showCreateMessage(_31);
dijit.byId("emailId").focus();
}
}else{
this.showCreateUserError("Error: "+_33.faultstring+"<br>Code: "+_33.faultcode);
}
})})]).play();
});
var fn=dojo.hitch(this,"xhr",{url:"/sellers/create-user",content:{user:dojo.toJson(o)},handleAs:"json",load:_32});
dojo.fx.chain([dojo.fx.wipeOut({node:dojo.byId("createUserFormId"),onEnd:function(){
dojo.byId("divXhrIndicator").innerHTML=Px.Ex.Application.getWaitHtml();
}}),dojo.fx.wipeIn({node:dojo.byId("divXhrIndicator"),onEnd:fn})]).play();
},destroy:function(){
try{
this.tpubCombo.destroyRecursive();
}
catch(e){
}
try{
this.standBy.destroyRecursive();
}
catch(e){
}
this.disconnectUsersStore();
try{
this.usersGrid.destroyRecursive();
}
catch(e){
}
try{
this._form.destroyRecursive();
}
catch(e){
}
}});
dojo.declare("Px.Ex.ExelateUsersScreen",[Px.Ex.XhrMixin],{ALL_REGEXP:".*",EMAIL_REGEXP:"[^@]+@[^@]+\\.\\w{2,}",PWD_REGEXP:".*\\d+.*",NAME_REGEXP:"[a-zA-Z. -]*",EXELATE_DEFAULT_ENTITY:11,draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhrLoad({selector:"#divContent",url:"/exelate/users",content:{},load:dojo.hitch(this,"createScreen")});
},createScreen:function(){
this.parseServerData();
this.handlePermissions();
if(dojo.byId("usersListId")){
this.createUsersGrid("usersListId");
}
if(dojo.byId("roundedFormBorderId")){
this.prepareCreateUserForm();
}
},itemToObject:function(_1,_2){
var _3={};
for(var _4 in _2){
if(_4!==_1._storeRefPropName&&_4!==_1._itemNumPropName&&_4!==_1._reverseRefMap&&_4!==_1._rootItemPropName){
var _5=_4;
var _6=_1.getValues(_2,_5);
if(_6.length==1){
_3[_5]=_1._flatten(_6[0]);
}else{
var _7=[];
for(var j=0;j<_6.length;++j){
_7.push(_1._flatten(_6[j]));
_3[_5]=_7;
}
}
}
}
return _3;
},handlePermissions:function(){
if(this._serverData.permissions){
this._allowSetUserStatus=(this._serverData.permissions["T4E-EXELATEUSER-LIST-SETSTATUS"]==true);
this._allowEditUser=(this._serverData.permissions["T4E-EXELATEUSER-LIST-EDIT"]==true);
}
},connectUsersStore:function(){
this._usersStoreConnection=dojo.connect(this._usersStore,"onSet",this,"onUsersStoreSet");
},disconnectUsersStore:function(){
if(this._usersStoreConnection){
dojo.disconnect(this._usersStoreConnection);
}
},onUsersStoreSet:function(_8,_9,_a,_b){
if(_9!="active"||_a==_b){
this._usersStore.save();
return;
}
if(this._allowSetUserStatus){
this._standBy.show();
this.xhr({url:"/exelate/activate-user",content:{user:dojo.toJson(this.itemToObject(this._usersStore,_8))},handle:dojo.hitch(this,function(_c){
this._standBy.hide();
if(_c instanceof Error||!_c["return"]||!_c["return"].success){
this.disconnectUsersStore();
this._usersStore.setValue(_8,_9,_a);
this._usersStore.save();
this.connectUsersStore();
}
}),handleAs:"json"});
this._usersStore.save();
}else{
this.disconnectUsersStore();
this._usersStore.setValue(_8,_9,_a);
this._usersStore.save();
this.connectUsersStore();
}
},createUsersGrid:function(_d){
this._standBy=new dojox.widget.Standby({target:dojo.body()},dojo.create("div",{},dojo.body()));
this._standBy.startup();
this._usersStore=new dojo.data.ItemFileWriteStore({clearOnClose:true,data:{identifier:"contactCode",label:"userName",items:this._serverData.eXelateUsers}});
this.connectUsersStore();
var _e=dojo.hitch(this,function(_f){
return "";
});
var _10=dojo.hitch(this,function(_11,_12){
var _13=this._usersGrid.getItem(_12);
if(!_13){
return "";
}
return "<a class=\"a-in-grid\" href=\"javascript:\">Edit</a>";
});
var _14=dojo.hitch(this,function(_15,_16){
if(_15!=null){
return dojo.string.substitute("<div class=\"dojoxEllipsis\" title=\"${0}\">${1}</div>",[_15,_15]);
}else{
return ("<div class=\"dojoxEllipsis\" style=\"white-space:nowrap;\">N/A</div>");
}
});
var _17=[{defaultCell:{styles:"white-space:nowrap;"},cells:[{name:"",get:_e,formatter:_10,styles:"text-align:center;",width:"30px",noresize:true,hidden:!this._allowEditUser},{name:"Active",field:"active",width:"40px",noresize:true,editable:true,type:dojox.grid.cells.Bool,styles:"text-align:center;vertical-align:bottom;padding-bottom:2px;"},{name:"First name",field:"firstName",formatter:_14,width:"60px",noresize:true},{name:"Last name",field:"lastName",formatter:_14,width:"83px",noresize:true},{name:"Email",field:"email",formatter:_14,width:"115px",noresize:true},{name:"Role",field:"role",formatter:_14,width:"73px",noresize:true},{name:"Last login",field:"lastLogin",formatter:_14,width:"100%",noresize:true},{name:"contact code",field:"contactCode",hidden:true}]}];
var _18=dojo.hitch(this,function(){
var _19={loadingMessage:Px.Ex.Application.getWaitHtml(),store:this._usersStore,query:{email:"*"},queryOptions:{ignoreCase:true},clientSort:true,onFetchError:dojo.hitch(this,function(_1a,req){
if(!req){
return;
}
this._usersGrid._pending_requests[req.start]=false;
}),autoHeight:20,height:"35em",selectionMode:"single",canSort:function(_1b){
return Math.abs(_1b)!=1;
},structure:_17};
_19.onRowContextMenu=function(){
};
_19.selectable=true;
this._usersGrid=new dojox.grid.DataGrid(_19,_d);
this._usersGrid.startup();
this._usersGrid.connect(this._usersGrid,"onRowClick",dojo.hitch(this,function(e){
if(e.cellIndex!=0||e.target.nodeName.toUpperCase()!="A"){
return;
}
var _1c=this.itemToObject(e.grid.store,e.grid.getItem(e.rowIndex));
var dlg=new Px.Ex.ExelateUserDialog({user:_1c,messages:this._serverData.messages,EMAIL_REGEXP:this.EMAIL_REGEXP,NAME_REGEXP:this.NAME_REGEXP,reloadUsersGrid:dojo.hitch(this,"reloadUsersGrid"),roles:this._serverData.eXelateRoles});
dlg.show();
}));
this._usersGrid.connect(this._usersGrid,"onStyleRow",dojo.hitch(this,function(e){
try{
var _1d=this._usersGrid.getItem(e.index);
if(_1d){
var _1e=this._usersGrid.store.getValue(_1d,"active");
if(!_1e){
e.customClasses+=" user-not-active-class";
}
}
}
catch(e){
}
}));
});
dojo.addOnLoad(_18);
},parseServerData:function(){
this._serverData={};
if(dojo.byId("permissions")){
this._serverData.permissions=dojo.fromJson(dojo.byId("permissions").innerHTML);
}
if(dojo.byId("messages")){
this._serverData.messages=dojo.fromJson(dojo.byId("messages").innerHTML);
}
if(dojo.byId("userRolesDataId")){
this._serverData.eXelateRoles=dojo.fromJson(dojo.byId("userRolesDataId").value);
}
if(dojo.byId("eXelateUsers")){
this._serverData.eXelateUsers=dojo.fromJson(dojo.byId("eXelateUsers").innerHTML);
}
},decorateCreateUserForm:function(){
var _1f={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _20=new curvyCorners(_1f,dojo.byId("roundedFormBorderId"));
_20.applyCornersToAll();
var _21=dojo.byId("createUserHeaderId");
var _22="<ul><li class=\"first last\"><span class=\"active\"><span>"+_21.innerHTML+"</span></span></li></ul>";
_21.innerHTML=_22;
},onCreateUser:function(){
if(isDefined(this._usersStore)){
if(this._usersStore._loadInProgress){
return;
}
}
this.showCreateUserError("");
this.showCreateMessage();
if(!this._form.validate()){
return;
}
o=this._form.attr("value");
o.entityCode=this.EXELATE_DEFAULT_ENTITY;
o.sendWelcomeEmail=o.sendWelcomeEmail[0]||"";
o.generateNewPassword=o.generateNewPassword[0]||"";
o.passwordExpiration=true;
if(o.sendWelcomeEmail||o.generateNewPassword){
o.password="";
}
o.password=$.base64Encode(o.password);
if(!o.sendWelcomeEmail&&!o.generateNewPassword){
o.secondEmail="";
o.passwordExpiration=false;
}
o.userName=o.email;
var _23=dojo.clone(o);
delete o.generateNewPassword;
var _24=dojo.hitch(this,function(_25,_26){
dojo.fx.chain([dojo.fx.wipeOut({node:dojo.byId("divXhrIndicator")}),dojo.fx.wipeIn({node:dojo.byId("createUserFormId"),onEnd:dojo.hitch(this,function(){
if(_25["return"]){
if(!_25["return"].success){
this.showCreateUserError("Error: "+_25["return"].errorMessage);
}else{
this._form.reset();
this.showDijit("generateNewPasswordId",false);
this.showLabel("generateNewPasswordId",false);
this.showDijit("initialPasswordId",false);
this.showLabel("initialPasswordId",false);
this.showDijit("sendToId",false);
this.showLabel("sendToId",false);
this.updatePasswordConstraints();
this.updateSecondEmailConstraints();
this.reloadUsersGrid();
this.showCreateMessage(_23);
dijit.byId("emailId").focus();
}
}else{
this.showCreateUserError("Error: "+_25.faultstring+"<br>Code: "+_25.faultcode);
}
})})]).play();
});
var fn=dojo.hitch(this,"xhr",{url:"/exelate/create-user",content:{user:dojo.toJson(o)},handleAs:"json",load:_24});
dojo.fx.chain([dojo.fx.wipeOut({node:dojo.byId("createUserFormId"),onEnd:function(){
dojo.byId("divXhrIndicator").innerHTML=Px.Ex.Application.getWaitHtml();
}}),dojo.fx.wipeIn({node:dojo.byId("divXhrIndicator"),onEnd:fn})]).play();
},reloadUsersGrid:function(){
if(!this._usersGrid){
return;
}
this._usersStore.save();
this._usersStore.close();
this._usersStore._jsonFileUrl="/exelate/users-list";
this._usersGrid.selection.deselectAll();
this._usersGrid._refresh();
},onSendWelcomeEmail:function(e){
var _27=e.target.checked;
this.showDijit("generateNewPasswordId",!_27);
this.showLabel("generateNewPasswordId",!_27);
var _28=dijit.byId("generateNewPasswordId").checked;
var id=_28?"sendToId":"initialPasswordId";
this.showDijit(id,!_27);
this.showLabel(id,!_27);
this.updatePasswordConstraints();
this.updateSecondEmailConstraints();
},onGenerateNewPassword:function(e){
var _29=e.target.checked;
this.showDijit("sendToId",_29);
this.showLabel("sendToId",_29);
this.showDijit("initialPasswordId",!_29);
this.showLabel("initialPasswordId",!_29);
this.updatePasswordConstraints();
this.updateSecondEmailConstraints();
},updatePasswordConstraints:function(){
var p=dijit.byId("initialPasswordId");
if(!dijit.byId("sendWelcomeEmailId").checked&&!dijit.byId("generateNewPasswordId").checked&&!dijit.byId("initialPasswordId").required){
p.required=true;
p.regExp=this.PWD_REGEXP;
}else{
p.required=false;
p.regExp=this.ALL_REGEXP;
}
},updateSecondEmailConstraints:function(){
if(!dijit.byId("sendWelcomeEmailId").checked&&dijit.byId("generateNewPasswordId").checked){
dijit.byId("sendToId").regExp=this.EMAIL_REGEXP;
}else{
dijit.byId("sendToId").regExp=this.ALL_REGEXP;
}
},showDijit:function(id,_2a){
dijit.byId(id).attr("style",{display:_2a?"":"none"});
},showLabel:function(_2b,_2c){
dojo.query("label[for='"+_2b+"']").style("display",_2c?"inline":"none");
},showCreateUserError:function(_2d){
dojo.byId("createUserErrorId").innerHTML=_2d;
},showCreateMessage:function(_2e){
var _2f=[];
if(_2e){
_2f.push(dojo.string.substitute(this._serverData.messages["T4E_EXELATEUSER_New_Response_UserCreated"],["<span class=\"bold\">"+_2e.userName+"</span>"]));
if(_2e.sendWelcomeEmail){
_2f.push(dojo.string.substitute(this._serverData.messages["T4E_EXELATEUSER_New_Response_WelcomeEmail"],["<span class=\"bold\">"+_2e.email+"</span>"]));
}
if((_2e.generateNewPassword)&&(_2e.sendWelcomeEmail)){
_2f.push(dojo.string.substitute(this._serverData.messages["T4E_EXELATEUSER_New_Response_PasswordSent"],["<span class=\"bold\">"+_2e.email+"</span>"]));
}
if((_2e.generateNewPassword)&&(!_2e.sendWelcomeEmail)){
_2f.push(dojo.string.substitute(this._serverData.messages["T4E_EXELATEUSER_New_Response_PasswordSent"],["<span class=\"bold\">"+_2e.secondEmail+"</span>"]));
}
}
dojo.byId("createUserMessageId").innerHTML=_2f.join("<br>");
},prepareCreateUserForm:function(){
this.decorateCreateUserForm();
var f=this._form=new dijit.form.Form({"class":"create-user-form",onSubmit:function(){
return false;
}},"createUserFormId");
if(dojo.byId("T4E-EXELATEUSER-CREATE")){
f.connect(dojo.byId("T4E-EXELATEUSER-CREATE"),"onclick",dojo.hitch(this,"onCreateUser"));
f.connect(f.domNode,"onkeydown",dojo.hitch(this,function(e){
if((e.keyCode==dojo.keys.ENTER||e.keyCode==dojo.keys.NUMPAD_ENTER)&&e.target.type!="textarea"){
setTimeout(dojo.hitch(this,this.onCreateUser),10);
}
}));
}
this._fieldEmail=new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"email",trim:true,regExp:this.EMAIL_REGEXP,required:true,promptMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_Email_Prompt"]||"",invalidMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_Email_Invalid"]||"$_unset_$",emptyMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_Email_Invalid"]||"$_unset_$","class":"form-input"},"emailId");
this._fieldFirstName=new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"firstName",trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_FirstName_Prompt"]||"",invalidMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_FirstName_Invalid"]||"$_unset_$",emptyMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_FirstName_Empty"]||"$_unset_$","class":"form-input"},"firstNameId");
this._fieldLastName=new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"lastName",trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_LastName_Prompt"]||"",invalidMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_LastName_Invalid"]||"$_unset_$",emptyMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_LastName_Empty"]||"$_unset_$","class":"form-input"},"lastNameId");
this._userRolesStore=new dojo.data.ItemFileReadStore({data:{identifier:"roleCode",label:"roleName",items:this._serverData.eXelateRoles}});
this._userRolesCombo=new Px.Ex.FilteringSelect({name:"roleCode",store:this._userRolesStore,promptMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_Role_Prompt"]||"",invalidMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_Role_Invalid"]||"$_unset_$",emptyMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_Role_Empty"]||"$_unset_$",searchAttr:"roleName","class":"form-input"},"roleId");
this._fieldSendWelcomeEmail=new dijit.form.CheckBox({name:"sendWelcomeEmail",checked:true},"sendWelcomeEmailId");
this._fieldGenerateNewPassword=new dijit.form.CheckBox({name:"generateNewPassword",style:{display:"none"},checked:true},"generateNewPasswordId");
this._fieldInitialPassword=new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"password",style:{display:"none"},trim:true,type:"password",regExp:this.ALL_REGEXP,promptMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_Password_Prompt"]||"",invalidMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_Password_Invalid"]||"$_unset_$",emptyMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_Password_Empty"]||"$_unset_$","class":"form-input"},"initialPasswordId");
var _30=dojo.byId("sendToId").innerHTML;
this._fieldSendTo=new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"secondEmail",style:{display:"none"},trim:true,regExp:this.ALL_REGEXP,promptMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_SecondEmail_Prompt"]||"",invalidMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_SecondEmail_Invalid"]||"$_unset_$",emptyMessage:this._serverData.messages["T4E_EXELATEUSER_New_Request_Field_SecondEmail_Empty"]||"$_unset_$","class":"form-input",value:_30},"sendToId");
f.connect(dijit.byId("sendWelcomeEmailId"),"onClick",dojo.hitch(this,"onSendWelcomeEmail"));
f.connect(dijit.byId("generateNewPasswordId"),"onClick",dojo.hitch(this,"onGenerateNewPassword"));
},destroy:function(){
try{
dojo.disconnect(this._usersStoreConnection);
}
catch(e){
}
try{
this._form.destroyRecursive(false);
}
catch(e){
}
try{
this._fieldEmail.destroyRecursive(false);
}
catch(e){
}
try{
this._fieldFirstName.destroyRecursive(false);
}
catch(e){
}
try{
this._fieldGenerateNewPassword.destroyRecursive(false);
}
catch(e){
}
try{
this._fieldInitialPassword.destroyRecursive(false);
}
catch(e){
}
try{
this._fieldLastName.destroyRecursive(false);
}
catch(e){
}
try{
this._fieldSendTo.destroyRecursive(false);
}
catch(e){
}
try{
this._fieldSendWelcomeEmail.destroyRecursive(false);
}
catch(e){
}
try{
this._standBy.destroyRecursive(false);
}
catch(e){
}
try{
this._userRolesStore.close();
}
catch(e){
}
try{
this._userRolesCombo.destroyRecursive(false);
}
catch(e){
}
try{
this._usersStore.close();
}
catch(e){
}
try{
this._usersGrid.destroyRecursive(false);
}
catch(e){
}
}});
dojo.declare("Px.Ex.ExelateUserDialog",[Px.Ex.ModalDialogMixin,Px.Ex.XhrMixin],{user:undefined,messages:undefined,EMAIL_REGEXP:".*",NAME_REGEXP:".*",reloadUsersGrid:undefined,roles:undefined,constructor:function(_31){
dojo.mixin(this,_31);
},show:function(){
var _32=dojo.hitch(this,"loadDialog");
this.modalDialog(_32);
},loadDialog:function(){
this.setTopCss(50);
var _33=Px.Ex.Application.Titles.EDIT_EXELATE_USER;
Px.Ex.Application.menu.buildDialogSubTitle(_33);
this.xhrLoad({selector:"#divModalDialogContent",content:{user:dojo.toJson(this.user)},url:"/exelate/exelate-user-dialog",load:dojo.hitch(this,"bindDialogEvents")});
},cleanupForm:function(){
if(this._form){
this._form.destroyRecursive();
delete this._form;
}
},bindDialogEvents:function(){
var u=this.user=dojo.fromJson(dojo.byId("userDataId").innerHTML);
$("#divModalDialog #cancel").click(dojo.hitch(this,function(){
$.modal.impl.close();
this.cleanupForm();
}));
if(!this.readOnly){
$("#divModalDialog #submit").click(dojo.hitch(this,"validateAndSend"));
}
var f=this._form=new dijit.form.Form({onSubmit:function(){
return false;
}},"editUserFormId");
f.connect(f.domNode,"onkeydown",dojo.hitch(this,function(e){
if((e.keyCode==dojo.keys.ENTER||e.keyCode==dojo.keys.NUMPAD_ENTER)&&e.target.type!="textarea"){
setTimeout(dojo.hitch(this,this.validateAndSend),10);
}
}));
var m=this.messages;
dojo.byId("usernameId2").innerHTML=u.userName;
dojo.byId("emailId2").innerHTML=u.email;
new Px.Ex.ValidationTextBox({name:"firstName",value:u.firstName,trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptFirstName||"",invalidMessage:m.invalidFirstName||"$_unset_$",emptyMessage:m.emptyFirstName||"$_unset_$","class":"form-input"},"firstNameId2");
new Px.Ex.ValidationTextBox({name:"lastName",value:u.lastName,trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptLastName||"",invalidMessage:m.invalidLastName||"$_unset_$",emptyMessage:m.emptyLastName||"$_unset_$","class":"form-input"},"lastNameId2");
new dijit.form.CheckBox({name:"active",checked:u.active},"activeId2");
new dijit.form.CheckBox({name:"sendWelcomeEmail",checked:u.sendWelcomeEmail},"sendWelcomeEmailId2");
new dijit.form.CheckBox({name:"passwordExpiration",checked:u.passwordExpiration},"passwordExpirationId2");
this.userRolesStore=new dojo.data.ItemFileReadStore({data:{identifier:"roleCode",label:"roleName",items:this.roles}});
this.userRolesCombo=new Px.Ex.FilteringSelect({name:"roleCode",store:this.userRolesStore,value:u.roleCode,promptMessage:this.messages["T4E_EXELATEUSER_New_Request_Field_Role_Prompt"]||"",invalidMessage:this.messages["T4E_EXELATEUSER_New_Request_Field_Role_Invalid"]||"$_unset_$",emptyMessage:this.messages["T4E_EXELATEUSER_New_Request_Field_Role_Empty"]||"$_unset_$",searchAttr:"roleName","class":"form-input"},"roleId2");
},validateAndSend:function(){
if(!this._form.validate()){
return;
}
var o=this._form.attr("value");
o.active=o.active[0]||"";
o.sendWelcomeEmail=o.sendWelcomeEmail[0]||"";
o.passwordExpiration=o.passwordExpiration[0]||"";
o=dojo.mixin({},this.user,o);
this._newUser=o;
this.clearError();
this.hideDialogContentAndWait(dojo.hitch(this,function(){
this.xhr({url:"/sellers/save-user",content:{user:dojo.toJson(o)},handleAs:"json",load:dojo.hitch(this,"saveUserResponse")});
}));
},saveUserResponse:function(_34){
if(_34["return"]){
ret=_34["return"];
if(ret.success!==undefined&&!ret.success){
this.showDialogContentOnError(_34);
}else{
this.cleanupForm();
this.showDialogContentOnSuccess("User "+this._newUser.userName+" was saved successfully!");
this.reloadUsersGrid();
}
}else{
this.showDialogContentOnError(_34);
}
},destroy:function(){
this.cleanupForm();
}});
dojo.declare("Px.Ex.InsightForTpubsScreen",[Px.Ex.MonthAndDaysBack,Px.Ex.ChartMixin],{chartScrollStart:-1,chartScrollSpan:-1,hidePrintButton:false,constructor:function(_1){
},draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/insight/insight-for-tpubs-screen",load:dojo.hitch(this,function(_2){
dojo.query("#divContent").html(_2);
this.bind();
this.createSliderDaysBack();
this.loadTpubDates();
})});
},bind:function(){
if(this._connections==undefined){
this._connections=[];
}
this._connections.push(dojo.connect(dojo.byId("divPrintButton"),"onclick",this,"print"));
},print:function(){
var _3={script:"PrintInsightForTpubs",date:this.initDate,daysBack:this.initDaysBack,start:this.chartScrollStart,span:this.chartScrollSpan};
window.open("/index/single-page"+"?"+dojo.objectToQuery(_3));
},clearCharts:function(){
delete this.insightOverlapData;
this.createInsightOverlapGraph();
this.updateInsightOverlapStats();
delete this.insightOverlapTrendData;
this.createInsightOverlapTrendGraph();
},showCharts:function(){
this.showInsightOverlapGraph();
this.showInsightOverlapTrendGraph();
},monthSelectInitialized:function(){
this.inherited(arguments);
if(!this.initDate){
return;
}
this.createInsightOverlapGraph();
this.createInsightOverlapTrendGraph();
this.showCharts();
},onMonthChange:function(e){
this.inherited(arguments);
this.cancelXhr();
this.clearCharts();
this.showCharts();
},onDaysBackChange:function(v){
this.inherited(arguments);
this.updateInsightOverlapGraph();
this.updateInsightOverlapTrendGraph();
},createInsightOverlapGraph:function(){
this.insightOverlapChartId=this.makeFlashChart({divId:"divInsightOverlapGraph",width:"550px",height:"190px",path:"dummy.xml",header:""});
},showInsightOverlapGraph:function(){
if(!this.initDate){
return;
}
this.xhr({url:"/insight/insight-overlap",content:{date:this.initDate},load:dojo.hitch(this,function(_4){
this.insightOverlapData=_4;
this.updateInsightOverlapGraph();
}),handleAs:"json"});
},updateInsightOverlapGraph:function(){
if(!this.insightOverlapData){
return;
}
var _5=this.initDaysBack;
var _6=[];
if(!this.insightOverlapData.processed){
if(this.insightOverlapData["return"]&&this.insightOverlapData["return"].overlaps){
_6=this.insightOverlapData["return"].overlaps;
if(!dojo.isArray(_6)){
_6=[_6];
}
}
this.insightOverlapData={};
dojo.forEach(_6,function(v){
if(v.daysCount!=undefined){
var _7="_"+v.daysCount;
this.insightOverlapData[_7]?this.insightOverlapData[_7].push(v):this.insightOverlapData[_7]=[v];
}
},this);
this.insightOverlapData.processed="processed";
}
_6=this.insightOverlapData["_"+_5];
var _8=!!_6;
if(!_8){
_6=[{insightOverlap:1}];
}
var _9=_8?20:20;
var _a=["<chart>","<license>FTQ9BQJFR7YULQZ0B6SVMYWHM5SXBL</license>","<chart_data>","<row>","<null/>"];
var _b=[];
var _c=dojox.math.round(_6[0].insightOverlap*100);
if(_8){
_a.push("<string>Uniques Overlap</string>");
_b.push("<number>"+_c+"</number>");
_a.push("<string>No Overlap</string>");
_b.push("<number label=''>"+(100-_c)+"</number>");
}else{
_a.push("<string>No Data</string>");
_b.push("<number>"+_c+"</number>");
}
_a.push("</row>");
_a.push("<row>");
_a.push("<string/>");
_a.push(_b.join(""));
_a.push("</row>");
_a.push("</chart_data>");
_a.push("<chart_type>3d pie</chart_type>");
_a.push("<chart_transition type='scale' delay='0.5' duration='0.2' order='category' />");
_a.push("<chart_pref select='true' />");
_a.push("<axis_value show_min='0' font='Arial' bold='1' size='10' color='959698' alpha='75' orientation='horizontal' />");
_a.push("<axis_category skip='0' font='Arial' size='10' color='959698' alpha='75'/>");
_a.push("<chart_rect x='80' y='-10' width='220' height='200' />");
_a.push("<chart_label prefix='' suffix='%' hide_zero='false' font='arial' bold='true' size='10' color='959698' alpha='100' position='outside'/>");
_a.push("<legend layout='vertical' font='Arial' alpha='100' x='404' y='4' size='10' height='"+_9+"' width='100' toggle='0' color='959698' fill_color='F0F0F2' fill_alpha='100'/>");
_a.push("<series_color>");
if(_8){
_a.push("<color>E7801B</color>");
_a.push("<color>60C11A</color>");
}else{
_a.push("<color>FFFFFF</color>");
}
_a.push("</series_color>");
_a.push("<series transfer='0'/>");
_a.push("</chart>");
var _d=_a.join("");
dojo.doc[this.insightOverlapChartId].Update_XML(_d,false);
this.updateInsightOverlapStats();
},updateInsightOverlapStats:function(){
var _e={demoOverlap:"",segmentOverlap:"",multipleSources:""};
if(this.insightOverlapData&&this.insightOverlapData.processed){
var d=this.insightOverlapData["_"+this.initDaysBack];
if(d){
_e.demoOverlap=dojox.math.round(d[0].demoOverlap*100,0)+"%";
_e.segmentOverlap=dojox.math.round(d[0].segmentOverlap*100,0)+"%";
_e.multipleSources=dojox.math.round(d[0].multipleSources*100,0)+"%";
}
}
dojo.query("#divDemoOverlap").html(_e.demoOverlap);
dojo.query("#divSegmentOverlap").html(_e.segmentOverlap);
dojo.query("#divMultipleSources").html(_e.multipleSources);
},createInsightOverlapTrendGraph:function(_f){
_f=_f||"dummy.xml";
this.insightOverlapTrendChartId=this.makeFlashChart({divId:"divInsightOverlapTrendGraph",width:"870px",height:"190px",path:_f,header:""});
},showInsightOverlapTrendGraph:function(){
if(!this.initDate){
return;
}
var _10=dojo.date.stamp.fromISOString(this.initDate);
this.selMonth=_10.getMonth()+1;
var _11=new Date();
var _12,to,_13,_14;
if(_11.getMonth()==_10.getMonth()&&_11.getFullYear()==_10.getFullYear()){
to=dojo.date.stamp.toISOString(_11,{zulu:true,milliseconds:true});
_10=dojo.date.add(_10,"month",-3);
_13=new Date();
_13.setUTCFullYear(_10.getFullYear(),_10.getMonth(),1);
_13.setUTCHours(0,0,0,0);
_12=dojo.date.stamp.toISOString(_13,{zulu:true,milliseconds:true});
this.monthType=0;
}else{
if(_11.getMonth()-1==_10.getMonth()&&_11.getFullYear()==_10.getFullYear()||_11.getMonth()==0&&_10.getMonth()==11&&_11.getFullYear()-1==_10.getFullYear()){
to=dojo.date.stamp.toISOString(_11,{zulu:true,milliseconds:true});
_10=dojo.date.add(_10,"month",-2);
_13=new Date();
_13.setUTCFullYear(_10.getFullYear(),_10.getMonth(),1);
_13.setUTCHours(0,0,0,0);
_12=dojo.date.stamp.toISOString(_13,{zulu:true,milliseconds:true});
this.monthType=1;
}else{
_14=dojo.date.add(_10,"month",1);
var _15=new Date();
_15.setUTCFullYear(_14.getFullYear(),_14.getMonth(),dojo.date.getDaysInMonth(_14));
_15.setUTCHours(23,59,59,999);
to=dojo.date.stamp.toISOString(_15,{zulu:true,milliseconds:true});
_13=dojo.date.add(_10,"month",-1);
var _16=new Date();
_16.setUTCFullYear(_13.getFullYear(),_13.getMonth(),1);
_16.setUTCHours(0,0,0,0);
_12=dojo.date.stamp.toISOString(_16,{zulu:true,milliseconds:true});
this.monthType=2;
}
}
this.chartScrollStart=this._start==undefined?-1:this._start;
this.chartScrollSpan=this._span==undefined?-1:this._span;
delete this._start,this._span;
this.xhr({url:"/insight/insight-overlap-trend",content:{to:to,from:_12,daysBack:this.initDaysBack},load:dojo.hitch(this,function(_17){
this.insightOverlapTrendData=_17;
this.updateInsightOverlapTrendGraph();
}),handleAs:"json"});
},updateInsightOverlapTrendGraph:function(){
if(!this.insightOverlapTrendData){
return;
}
var _18=this.initDaysBack;
data=this.insightOverlapTrendData["_"+_18];
var _19=!!data;
if(!data){
data=[];
}
var _1a=[];
var _1b=[];
var _1c=[];
dojo.forEach(data,function(v){
var _1d=v.reportDate.substr(8,2);
if(_1d=="01"){
_1d=v.reportDate.substr(0,10);
}
_1a.push("<string>"+_1d+"</string>");
_1b.push("<number>"+v.dailyUniques+"</number>");
_1c.push("<number>"+v.insightUniques+"</number>");
});
var _1e=_1a.join("");
var _1f=_1b.join("");
var _20=_1c.join("");
var arr=["<chart>","<license>FTQ9BQJFR7YULQZ0B6SVMYWHM5SXBL</license>","<axis_value alpha='0' />","<axis_category alpha='0' />","<axis_ticks value_ticks='false' category_ticks='false' />","<chart_border top_thickness='0' bottom_thickness='0' left_thickness='0' right_thickness='0' />","<chart_data>","<row>","<null/>"];
arr.push(_1e);
arr.push("</row>");
arr.push("<row>");
arr.push("<string>Daily Uniques</string>");
arr.push(_1f);
arr.push("</row>");
arr.push("<row>");
arr.push("<string>Insight Overlap</string>");
arr.push(_20);
arr.push("</row>");
arr.push("</chart_data>");
arr.push("<chart_grid_h alpha='0' />");
arr.push("<chart_grid_v alpha='5' color='000000' thickness='1' />");
arr.push("<chart_pref line_thickness='1' point_shape='none' fill_shape='false' />");
arr.push("<chart_rect positive_alpha='0' x='60' y='144' width='800' height='36' />");
arr.push("<chart_type>Line</chart_type>");
arr.push("<draw>");
arr.push("<rect shadow='high2' layer='background' x='60' y='20' width='800' height='160' line_thickness='0' fill_color='92a99f' fill_alpha='100' />");
arr.push("<rect layer='background' x='60' y='120' width='800' height='60' line_thickness='1' fill_color='DDDDDD' fill_alpha='50' />");
arr.push("<image url='/charts.swf?library_path=/charts_library&xml_source="+"/insight/insight-overlap-trend-inner"+"?params="+_18+"_"+this.monthType+"_"+this.selMonth+"_"+this.chartScrollStart+"_"+this.chartScrollSpan+"' />");
arr.push("</draw>");
arr.push("<filter>");
arr.push("<shadow id='high' distance='5' angle='45' alpha='35' blurX='10' blurY='10' />");
arr.push("<shadow id='high2' distance='5' angle='45' alpha='35' blurX='10' blurY='10' knockout='true' />");
arr.push("<shadow id='low' distance='2' angle='45' alpha='35' blurX='5' blurY='5' />");
arr.push("<bevel id='bg' angle='90' blurX='0' blurY='100' distance='25' highlightAlpha='10' highlightColor='ffffff' shadowColor='4c5e6f' shadowAlpha='20' inner='true' />");
arr.push("</filter>");
arr.push("<legend layout='hide' />");
arr.push("<series_color>");
arr.push("<color>60C11A</color>");
arr.push("<color>E7801B</color>");
arr.push("</series_color>");
arr.push("</chart>");
var xml=arr.join("");
dojo.doc[this.insightOverlapTrendChartId].Update_XML(xml,false);
if(!this.hidePrintButton){
dojo.style("divPrintButton","visibility","visible");
}
dojo.publish("insightForTpubsChartsShown");
},destroy:function(){
this.inherited(arguments);
if(dojo.isArray(this._connections)){
dojo.forEach(this._connections,function(v){
dojo.disconnect(v);
});
delete this._connections;
}
}});
dojo.declare("Px.Ex.DemographicsScreen",[Px.Ex.MonthAndDaysBack,Px.Ex.ChartMixin],{colors:["rgb(248,105,109)","rgb(249,132,112)","rgb(250,163,118)","rgb(251,190,123)","rgb(255,220,130)","rgb(236,231,131)","rgb(205,222,130)","rgb(170,209,126)","rgb(134,200,126)","rgb(99,190,123)"],hidePrintButton:false,constructor:function(_1){
},draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/insight/demographics-screen",load:dojo.hitch(this,function(_2){
dojo.query("#divContent").html(_2);
this.bind();
this.createSliderDaysBack();
this.loadTpubDates();
})});
},bind:function(){
if(this._connections==undefined){
this._connections=[];
}
this._connections.push(dojo.connect(dojo.byId("divPrintButton"),"onclick",this,"print"));
},print:function(){
var _3={script:"PrintDemographics",date:this.initDate,daysBack:this.initDaysBack};
window.open("/index/single-page"+"?"+dojo.objectToQuery(_3));
},clearCharts:function(){
delete this.reportPublisherInsightSegmentsData;
this.makeDemographicOverlapTable();
this.createGenderOverlapGraph();
this.createAgeOverlapGraph();
},showCharts:function(){
this.show();
},_updateCharts:function(){
this.makeDemographicOverlapTable();
this.updateGenderOverlapGraph();
this.updateAgeOverlapGraph();
if(!this.hidePrintButton){
dojo.style("divPrintButton","visibility","visible");
}
dojo.publish("demographicsChartsShown");
},monthSelectInitialized:function(){
this.inherited(arguments);
if(!this.initDate){
return;
}
this.clearCharts();
this.showCharts();
},onMonthChange:function(e){
this.inherited(arguments);
this.cancelXhr();
this.clearCharts();
this.showCharts();
},onDaysBackChange:function(v){
this.inherited(arguments);
this._updateCharts();
},createGenderOverlapGraph:function(){
this.genderOverlapChartId=this.makeFlashChart({divId:"divGenderOverlapGraph",width:"430px",height:"250px",path:"dummy.xml",header:""});
},createAgeOverlapGraph:function(){
this.ageOverlapChartId=this.makeFlashChart({divId:"divAgeOverlapGraph",width:"434px",height:"250px",path:"dummy.xml",header:""});
},show:function(){
if(!this.initDate){
return;
}
this.xhr({url:"/insight/report-publisher-insight-segments",content:{date:this.initDate},load:dojo.hitch(this,function(_4){
this.reportPublisherInsightSegmentsData=_4;
this.prepareInsightSegmentsData();
this._anim=this._animateBars;
this._updateCharts();
}),handleAs:"json"});
},prepareInsightSegmentsData:function(){
var _5=[];
this.maxUniques=0;
if(!this.reportPublisherInsightSegmentsData.processed){
if(this.reportPublisherInsightSegmentsData["return"]&&this.reportPublisherInsightSegmentsData["return"].segments){
_5=this.reportPublisherInsightSegmentsData["return"].segments;
if(!dojo.isArray(_5)){
_5=[_5];
}
}
this.reportPublisherInsightSegmentsData={};
dojo.forEach(_5,function(v){
if(v.daysCount!=undefined){
if(v.segmentUniques>this.maxUniques){
this.maxUniques=v.segmentUniques;
}
var _6="_"+v.daysCount;
this.reportPublisherInsightSegmentsData[_6]?this.reportPublisherInsightSegmentsData[_6].push(v):this.reportPublisherInsightSegmentsData[_6]=[v];
}
},this);
this.reportPublisherInsightSegmentsData.processed="processed";
}
},_updateOverlapGraph:function(_7,_8,_9){
if(!this.reportPublisherInsightSegmentsData){
return;
}
var _a=this.initDaysBack;
var _b=this.reportPublisherInsightSegmentsData["_"+_a];
if(!_b){
_b=[];
}
if(!_9){
_9=["9F3FBA","F56413","FDB513","FAF238","86CD49","77C9EF","CBF0F8"];
}
var _c=["<chart>","<license>FTQ9BQJFR7YULQZ0B6SVMYWHM5SXBL</license>","<chart_data>","<row>","<null/>"];
var _d=[];
dojo.forEach(_b,function(v){
if(v.segmentName.match(_7)){
_c.push("<string>"+v.segmentName+"</string>");
_d.push("<number>"+dojox.math.round(v.segmentOverlap*100)+"</number>");
}
});
var _e=true;
var _f="No data";
if(_d.length==0){
_c.push("<string>"+_f+"</string>");
_d.push("<number>100</number>");
_e=false;
}
var _10=_e?20:20;
_c.push("</row>");
_c.push("<row>");
_c.push("<string/>");
_c.push(_d.join(""));
_c.push("</row>");
_c.push("</chart_data>");
_c.push("<chart_type>3d pie</chart_type>");
_c.push("<chart_transition type='scale' delay='0.5' duration='0.2' order='category' />");
_c.push("<chart_pref select='true' />");
_c.push("<axis_value show_min='0' font='Arial' bold='1' size='10' color='959698' alpha='75' orientation='horizontal' />");
_c.push("<axis_category skip='0' font='Arial' size='10' color='959698' alpha='75'/>");
_c.push("<chart_rect x='44' y='-10' width='260' height='260' />");
_c.push("<chart_label prefix='' suffix='%' hide_zero='false' font='arial' bold='true' size='10' color='959698' alpha='100' position='outside'/>");
_c.push("<legend layout='vertical' font='Arial' alpha='100' x='330' y='4' size='10' height='"+_10+"' width='60' color='959698' fill_color='F0F0F2' fill_alpha='100'/>");
_c.push("<series_color>");
if(_e){
dojo.forEach(_9,function(v){
_c.push("<color>"+v+"</color>");
});
}else{
_c.push("<color>FFFFFF</color>");
}
_c.push("</series_color>");
_c.push("<series transfer='0'/>");
_c.push("</chart>");
var xml=_c.join("");
dojo.doc[_8].Update_XML(xml,false);
},updateGenderOverlapGraph:function(){
this._updateOverlapGraph(/^Gender\:/,this.genderOverlapChartId,["60C11A","E7801B"]);
},updateAgeOverlapGraph:function(){
this._updateOverlapGraph(/^Age\:/,this.ageOverlapChartId);
},makeDemographicOverlapTable:function(){
var _11=this.initDaysBack;
var _12=this.reportPublisherInsightSegmentsData?this.reportPublisherInsightSegmentsData["_"+_11]:[];
if(!_12){
_12=[];
}
var _13=[];
var age=[];
dojo.forEach(_12,function(v){
if(v.segmentName.match(/^Gender\:/)){
_13.push(v);
}else{
if(v.segmentName.match(/^Age\:/)){
age.push(v);
}
}
});
var s="<table class=\"table\"><tbody>";
s+=this._makeDemographicOverlapRows(_13,false);
s+=this._makeSpacerRow(_13.length==0&&age.length==0);
s+=this._makeDemographicOverlapRows(age,true);
s+="</tbody></table>";
dojo.query("#divDemographicOverlap").html(s);
anim=this._anim;
if(anim){
dojo.query(".bar","divDemographicOverlap").forEach(function(v){
dojo.anim(v,{width:v.id},1500);
});
this._anim=false;
}
},_makeSpacerRow:function(_14){
return _14?"":"<tr><td class=\"border-bottom\">&nbsp;</td><td class=\"border-bottom\"></td><td class=\"border-bottom\"></td><td class=\"border-bottom\"></td></tr>";
},_makeDemographicOverlapRows:function(_15,_16){
if(_15.length==0){
return "";
}
var s="";
var _17=_16?_15.length-1:-1;
dojo.forEach(_15,function(v,i){
var cls=i!=_17?"border-bottom":"";
s+="<tr><td class=\""+cls+" border-right\"><div class=\"label\">"+v.segmentName+"</div></td>";
var _18={max:this.maxUniques,data:v.segmentUniques,width:550,zeroWidth:this._anim};
s+="<td style=\"vertical-align:middle;\" class=\""+cls+"\">"+new Px.Ex.Bar(_18).getHtml()+"</td>";
s+="<td style=\"width:100%;\" class=\""+cls+"\"></td>";
s+="<td class=\""+cls+"\"><div class=\"data\">"+dojo.number.format(v.segmentUniques,{pattern:"#,##0"})+"</div></td></tr>";
},this);
return s;
},destroy:function(){
this.inherited(arguments);
if(dojo.isArray(this._connections)){
dojo.forEach(this._connections,dojo.disconnect,this);
delete this._connections;
}
}});
dojo.declare("Px.Ex.TargetingSegmentsScreen",[Px.Ex.MonthAndDaysBack],{header1:"",header2:"",remark:"",tooltip1:"",tooltip2:"",hidePrintButton:false,constructor:function(_1){
},draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/insight/targeting-segments-screen",load:dojo.hitch(this,function(_2){
dojo.byId("divContent").innerHTML=_2;
this.bind();
this.clearChart();
this.createSliderDaysBack();
this.loadTpubDates();
})});
},bind:function(){
if(this._connections==undefined){
this._connections=[];
}
this._connections.push(dojo.connect(dojo.byId("divPrintButton"),"onclick",this,"print"));
},print:function(){
var _3={script:"PrintTargetingSegments",date:this.initDate,daysBack:this.initDaysBack};
window.open("/index/single-page"+"?"+dojo.objectToQuery(_3));
},clearChart:function(){
delete this.reportPublisherInsightSegmentsData;
this.makeChart();
},monthSelectInitialized:function(){
this.inherited(arguments);
this.showChart();
},onMonthChange:function(e){
this.inherited(arguments);
this.cancelXhr();
this.clearChart();
this.showChart();
},onDaysBackChange:function(v){
this.inherited(arguments);
this.makeChart();
},showChart:function(){
if(!this.initDate){
return;
}
dojo.query("#divTargetingSegments").html(Px.Ex.Application.getWaitHtml());
this.xhr({url:"/insight/targeting-segments",content:{date:this.initDate},load:dojo.hitch(this,function(_4){
this.reportPublisherInsightSegmentsData=_4;
this.prepareInsightSegmentsData();
this._anim=this._animateBars;
this.makeChart();
if(!this.hidePrintButton){
dojo.style("divPrintButton","visibility","visible");
}
}),handleAs:"json"});
},prepareInsightSegmentsData:function(){
var _5=[];
this.maxUniques=0;
if(!this.reportPublisherInsightSegmentsData.processed){
if(this.reportPublisherInsightSegmentsData["return"]&&this.reportPublisherInsightSegmentsData["return"].segments){
_5=this.reportPublisherInsightSegmentsData["return"].segments;
if(!dojo.isArray(_5)){
_5=[_5];
}
}
this.reportPublisherInsightSegmentsData={};
dojo.forEach(_5,function(v){
if(v.daysCount!=undefined){
if(v.segmentUniques>this.maxUniques){
this.maxUniques=v.segmentUniques;
}
var _6="_"+v.daysCount;
this.reportPublisherInsightSegmentsData[_6]?this.reportPublisherInsightSegmentsData[_6].push(v):this.reportPublisherInsightSegmentsData[_6]=[v];
}
},this);
this.reportPublisherInsightSegmentsData.processed="processed";
}
},makeChart:function(){
var _7=this.initDaysBack;
var _8=this.reportPublisherInsightSegmentsData?this.reportPublisherInsightSegmentsData["_"+_7]:[];
if(!_8){
_8=[];
}
if(_8.length==0){
dojo.empty("divTargetingSegments");
return;
}
var s="<table class=\"table\"><tbody>";
s+=this._makeRows(_8);
s+="</tbody></table>";
dojo.query("#divTargetingSegments").html(s);
anim=this._anim;
if(anim){
dojo.query(".bar","divTargetingSegments").forEach(function(v){
dojo.anim(v,{width:v.id},1500);
});
this._anim=false;
}
dojo.publish("targetingSegmentsChartShown");
},_makeRows:function(_9){
if(_9.length==0){
return "";
}
var s="";
var _a=_9.length-1;
dojo.forEach(_9,function(v,i){
var _b=i!=_a?"border-bottom":"";
s+="<tr><td class=\""+_b+" border-right\"><div class=\"label\" title=\""+v.segmentName+"\">"+v.segmentName+"</div></td>";
var _c={max:this.maxUniques,data:v.segmentUniques,width:520,zeroWidth:this._anim};
s+="<td style=\"vertical-align:middle;\" class=\""+_b+"\">"+new Px.Ex.Bar(_c).getHtml()+"</td>";
s+="<td style=\"width:100%;\" class=\""+_b+"\"></td>";
s+="<td class=\""+_b+"\"><div class=\"data\">"+dojo.number.format(v.segmentUniques,{pattern:"#,##0"})+"</div></td></tr>";
},this);
return s;
},destroy:function(){
this.inherited(arguments);
if(dojo.isArray(this._connections)){
dojo.forEach(this._connections,dojo.disconnect,this);
delete this._connections;
}
}});
dojo.require("dojox.gfx");
dojo.declare("Px.Ex.BuyersMonitorScreen",[Px.Ex.XhrMixin],{data1:[],data2:[],data3:[],proxy1:"/buyers-monitor/proxy1",proxy2:"/buyers-monitor/proxy2",TIMEOUT1:20,TIMEOUT2:20,TIMEOUT3:20,draw:function(){
dojo.query("#divContent").html(Px.Ex.Application.getWaitHtml());
this.xhrLoad({selector:"#divContent",url:"/buyers-monitor/screen",load:dojo.hitch(this,"_prepareScreen")});
},_extractBase:function(_1){
var _2=_1;
var i=_2.indexOf("?");
if(i>=0){
_2=_2.substr(0,i);
}
i=_2.lastIndexOf("/");
if(i>=0){
_2=_2.substr(0,i+1);
}
this.base=_2;
},_getHiddenPane:function(){
var p=new dijit.layout.ContentPane({href:this.proxy1,extractContent:true,doLayout:false,isContainer:false,preload:false,preventCache:true,style:{width:"0px",height:"0px",display:"none"},onDownloadError:dojo.hitch(this,"_showError")});
p.placeAt("divContent");
p.startup();
return p;
},_makeHiddenPanes:function(){
this.hiddenPane1=this._getHiddenPane();
this.hiddenPane2=this._getHiddenPane();
this.hiddenPane3=this._getHiddenPane();
},_showError:function(_3){
Px.Ex.Application.showGlobalError(_3);
return "";
},_loadData1:function(){
if(this.timer1){
clearTimeout(this.timer1);
}
this.hiddenPane1.attr({href:this.proxy1,preload:true,ioArgs:{content:{url:this.url}},onLoad:dojo.hitch(this,"_parseData1")});
this.hiddenPane1.refresh();
},_loadData2:function(_4){
if(this.timer2){
clearTimeout(this.timer2);
}
if(_4){
this.url2=this.base+_4;
}
this.hiddenPane2.attr({href:this.proxy2,preload:true,preventCache:false,ioArgs:{content:{url:this.url2}},onLoad:dojo.hitch(this,"_parseData2")});
this.hiddenPane2.refresh();
},_loadData3:function(_5){
if(this.timer3){
clearTimeout(this.timer3);
}
if(_5){
this.url3=_5;
}
this.hiddenPane3.attr({href:this.proxy2,preload:true,preventCache:false,ioArgs:{content:{url:this.url3}},onLoad:dojo.hitch(this,"_parseData3")});
this.hiddenPane3.refresh();
},_clearHiddenPane:function(_6){
var p=this["hiddenPane"+_6];
if(p){
p.attr({preload:false,onLoad:function(){
}});
p.attr("content","");
}
},_getCurrentBase:function(){
return location.protocol+"//"+location.host+"/";
},_bindCloseGridButtons:function(){
if(!this._connections){
this._connections=[];
}
dojo.forEach([2,3],function(v){
this._connections.push(dojo.connect(dojo.byId("closeGrid"+v+"Id"),"onclick",null,dojo.hitch(this,"onCloseGrid",v)));
},this);
},_prepareScreen:function(){
if(!dojo.byId("grid1Id")){
return;
}
dojo.query("#grid1Id").html(Px.Ex.Application.getWaitHtml());
var _7=dojo.fromJson(dojo.byId("configId").innerHTML);
this.url=_7.url;
this.TIMEOUT1=_7.timeout1;
this.TIMEOUT2=_7.timeout2;
this.TIMEOUT3=_7.timeout3;
this._buyers=dojo.fromJson(dojo.byId("buyersId").innerHTML);
dojo.empty("configId");
dojo.empty("buyersId");
this._extractBase(this.url);
this._makeHiddenPanes();
this._loadData1();
this._bindCloseGridButtons();
},_makeGrid1:function(){
this.store1=new dojo.data.ItemFileReadStore({clearOnClose:true,data:{identifier:"site",items:{}}});
var _8=dojo.hitch(this,function(_9,_a){
var _b=this.grid1.getItem(_a);
if(!_b){
return "";
}
var _c=this.store1.getValue(_b,"status");
var _d="site-status "+_c;
var _e=this.store1.getValue(_b,"site");
return dojo.string.substitute("<span class=\"${cls}\">${site}</span>",{cls:_d,site:_e});
});
var _f=dojo.hitch(this,function(_10,_11){
var _12=this.grid1.getItem(_11);
if(!_12){
return "";
}
var _13=this.store1.getValue(_12,"status");
var cls="tested "+_13;
var _14=this.store1.getValue(_12,"tested");
return dojo.string.substitute("<span class=\"${cls}\">${tested}</span>",{cls:cls,tested:_14});
});
var _15=dojo.hitch(this,function(_16,_17){
var _18=this.grid1.getItem(_17);
if(!_18){
return "";
}
var _19=this.store1.getValue(_18,"status");
var cls="status "+_19;
return dojo.string.substitute("<div class=\"${cls}\"></div>",{cls:cls,status:_19});
});
var _1a=[{defaultCell:{styles:"white-space:nowrap;",headerStyles:"cursor:pointer;",noresize:true},cells:[{name:"Buyer",field:"site",formatter:_8,width:"140px",headerStyles:"text-align:center;cursor:pointer;"},{name:"Last tested from",field:"tested",formatter:_f,width:"180px",headerStyles:"text-align:center;cursor:pointer;"},{name:"Status",field:"status",formatter:_15,width:"100%",styles:"text-align:center;vertical-align:middle;"}]}];
this.grid1=new dojox.grid.DataGrid({store:this.store1,query:{site:"*"},queryOptions:{ignoreCase:true},clientSort:true,onFetchError:dojo.hitch(this,function(_1b,req){
if(!req){
return;
}
this.grid1._pending_requests[req.start]=false;
}),style:{width:"400px"},autoHeight:200,selectionMode:"none",canSort:function(_1c){
return true;
},structure:_1a},"grid1Id");
this.grid1.connect(this.grid1,"onCellClick",dojo.hitch(this,function(e){
if(e.cell.field=="site"&&e.target.nodeName=="SPAN"){
var _1d=this.grid1.getItem(e.rowIndex);
if(!_1d){
return;
}
this._selectedSite=this.store1.getValue(_1d,"site");
this.grid1.update();
var _1e=this.store1.getValue(_1d,"href");
this.onTable1(_1e);
}
}));
this.grid1.connect(this.grid1,"onStyleRow",dojo.hitch(this,function(row){
if(!this._selectedSite){
return;
}
var _1f=this.grid1.getItem(row.index);
if(!_1f){
return;
}
if(this._selectedSite==this.store1.getValue(_1f,"site")){
row.customClasses+=(row.over?" selected-row-over":" selected-row");
}
}));
this.grid1.connect(this.grid1,"onCellMouseOver",function(e){
if(e.cellNode&&e.cell.field=="status"){
var _20=e.grid.getItem(e.rowIndex);
var _21=e.grid.store.getValue(_20,"status");
dijit.showTooltip(_21,e.cellNode);
}
});
this.grid1.connect(this.grid1,"onCellMouseOut",function(e){
if(e.cellNode&&e.cell.field=="status"){
dijit.hideTooltip(e.cellNode);
}
});
this.grid1.startup();
},_makeGrid:function(num){
this["store"+num]=new dojo.data.ItemFileReadStore({clearOnClose:true,data:{identifier:"uptime",items:{}}});
var _22=dojo.hitch(this,function(_23,_24){
var _25=this["grid"+num].getItem(_24);
if(!_25){
return "";
}
var _26=this["store"+num].getValue(_25,"uptime");
var _27=this["store"+num].getValue(_25,"percent");
var _28=this["store"+num].getValue(_25,"href");
var _29=this["store"+num].getValue(_25,"total");
var ret=[];
var cls=_29?"period-uptime-total":_28?"period-uptime-a":"period-uptime-text";
ret.push(dojo.string.substitute("<div><span class=\"${cls}\">${uptime}</span></div>",{cls:cls,uptime:_26}));
cls="period-uptime-percent";
var _2a=isNaN(parseFloat(_27))?"":"%";
var len=150;
var _2b=_2a==""?"":dojo.string.substitute("<div style=\"width:${len}px;\"><div class=\"percent-graph\" style=\"width:${ps}px;\"></div></div>",{len:len+2,ps:Math.round(_27/100*len)});
ret.push(dojo.string.substitute("<table><tbody><tr><td>${graph}</td><td><span class=\"${cls}\">${percent}</span>${sign}</td></tr></tbody></table>",{cls:cls,percent:_27,sign:_2a,graph:_2b}));
return ret.join("");
});
var _2c=dojo.hitch(this,function(_2d,_2e){
var _2f=this["grid"+num].getItem(_2e);
if(!_2f){
return "";
}
var _30=this["store"+num].getValue(_2f,"total");
var _31=this["store"+num].getValue(_2f,"response");
var cls=_30?"response-time total":"response-time normal";
return dojo.string.substitute("<span class=\"${cls}\">${response}</span>",{cls:cls,response:_31});
});
var _32=[{defaultCell:{styles:"white-space:nowrap;",noresize:true},cells:[{name:"Period/Uptime",field:"uptime",formatter:_22,width:"250px",headerStyles:"text-align:center;"},{name:"Response Time",field:"response",formatter:_2c,width:"100%",styles:"text-align:center;",cellStyles:"vertical-align:middle;"}]}];
var _33=this["grid"+num]=new dojox.grid.DataGrid({store:this["store"+num],query:{uptime:"*"},queryOptions:{ignoreCase:true},clientSort:true,onFetchError:dojo.hitch(this,function(_34,req){
if(!req){
return;
}
this["grid"+num]._pending_requests[req.start]=false;
}),style:{width:"400px"},autoHeight:200,rowsPerPage:200,selectionMode:"none",canSort:function(_35){
return false;
},structure:_32},"grid"+num+"Id");
this["grid"+num].connect(this["grid"+num],"onCellClick",dojo.hitch(this,function(e){
if(e.cell.field=="uptime"&&e.target.nodeName=="SPAN"&&dojo.hasClass(e.target,"period-uptime-a")){
var _36=this["grid"+num].getItem(e.rowIndex);
if(!_36){
return;
}
if(num==2){
this._selectedUptime=this.store2.getValue(_36,"uptime");
this.grid2.update();
}
var _37=this["store"+num].getValue(_36,"href");
this["onTable"+num](_37);
}
}));
if(num==2){
this.grid2.connect(this.grid2,"onStyleRow",dojo.hitch(this,function(row){
if(!this._selectedUptime){
return;
}
var _38=this.grid2.getItem(row.index);
if(!_38){
return;
}
if(this._selectedUptime==this.store2.getValue(_38,"uptime")){
row.customClasses+=(row.over?" selected-row-over":" selected-row");
}
}));
}
this["grid"+num].startup();
},_makeGrid2and3:function(){
this._makeGrid(2);
this.showGrid(2,false);
this._makeGrid(3);
this.showGrid(3,false);
},_parseData1:function(_39){
this.data1=this._filterData1(this._extractData1());
this._clearHiddenPane(1);
this.showData1(this.data1);
this.timer1=setTimeout(dojo.hitch(this,"_loadData1"),this.TIMEOUT1*1000);
},_filterData1:function(_3a){
if(this._buyers.length){
var b=this._buyers;
var B={};
dojo.forEach(b,function(v){
B[v.buyerName]=v.displayCode;
});
b=[];
for(var nm in B){
b.push({buyerName:nm,displayCode:B[nm]});
}
var d=[];
dojo.forEach(_3a,function(v){
for(i=0,len=b.length;i<len;++i){
var o=b[i];
if(v.text.indexOf(o.displayCode)>0){
v.text=o.buyerName;
d.push(v);
b.splice(i,1);
break;
}
}
},this);
_3a=d;
}else{
_3a=[];
}
return _3a;
},_imgToStatus:function(img){
var _3b;
if(!img){
_3b="unknown";
}else{
if(img.indexOf("stat_ok.gif")>=0){
_3b="ok";
}else{
if(img.indexOf("btn-stopped.gif")>=0){
_3b="stopped";
}else{
if(img.indexOf("stat_down.gif")>=0){
_3b="down";
}else{
_3b="unknown";
}
}
}
}
return _3b;
},_extractData1:function(){
var _3c=this._getCurrentBase();
var _3d=[];
dojo.query("#graphtablebg table td",this.hiddenPane1.domNode).forEach(function(v,i){
var m=i%3;
if(m==0){
var o={};
var a=dojo.query("a",v);
o.href=a.attr("href")[0];
o.text=a[0].innerHTML;
if(dojo.isIE&&dojo.isIE<8&&o.href.substr(0,_3c.length)==_3c){
o.href=o.href.substr(_3c.length);
}
_3d.push(o);
}else{
if(m==1){
o=_3d[_3d.length-1];
o.value=dojo.trim(v.innerHTML);
}else{
o=_3d[_3d.length-1];
var im=dojo.query("img",v);
o.img=im.length?im.attr("src")[0]:"";
if(dojo.isIE&&dojo.isIE<8&&o.img.substr(0,_3c.length)==_3c){
o.img=o.img.substr(_3c.length);
}
o.status=this._imgToStatus(o.img);
}
}
},this);
return _3d;
},_extractData2:function(_3e){
var _3f=this._getCurrentBase();
var _40=[];
var o={};
o.img=dojo.query("table#maintable tr:nth-child(3) td:nth-child(3) img",_3e).attr("src")[0];
if(!o.img){
return _40;
}
o.text=dojo.trim(dojo.query("table#maintable tr:nth-child(2) td:first-child span.btxt",_3e)[0].innerHTML);
o.value=dojo.trim(dojo.query("table#maintable tr:nth-child(3) td:nth-child(2) span.btxt b",_3e)[0].innerHTML);
if(dojo.isIE&&dojo.isIE<8&&o.img.substr(0,_3f.length)==_3f){
o.img=o.img.substr(_3f.length);
}
o.status=this._imgToStatus(o.img);
_40.push(o);
dojo.query("#graphtablebg table.normtext td[id=\"stattd\"]",_3e).forEach(function(v,i){
var m=i%2;
if(m==0){
var o={};
o.href="";
var a=dojo.query("> a",v);
if(a.length){
o.href=a.attr("href")[0];
o.periodUptime=dojo.trim(a[0].innerHTML);
}else{
o.periodUptime=dojo.trim(v.childNodes[0].nodeValue);
}
var p=dojo.query("td.normtext > span.btxt > strong",v);
o.percent=p.length?p[0].innerHTML:dojo.query("span",v)[0].innerHTML;
if(o.percent.charAt(o.percent.length-1)=="%"){
o.percent=o.percent.substr(0,o.percent.length-1);
}
while(o.percent.indexOf("&nbsp;")==0){
o.percent=o.percent.substr(6);
}
_40.push(o);
}else{
o=_40[_40.length-1];
var div=dojo.query("div",v);
o.responseTime=div[0].innerHTML;
}
},this);
this._addAverage(_40);
return _40;
},_addAverage:function(_41){
var _42=0;
var _43=0;
dojo.forEach(_41,function(v,i){
if(i>0){
var ps=parseFloat(v.percent);
if(isNaN(ps)){
ps=0;
}
_42+=ps;
var rt=parseFloat(v.responseTime);
if(isNaN(rt)){
rt=0;
}
_43+=rt;
}
});
var cnt=_41.length-1;
_41.push({responseTime:dojox.math.round(_43/cnt,4),percent:dojox.math.round(_42/cnt,4),periodUptime:"Overall Average",total:true});
},showData1:function(_44){
var _45=[];
dojo.forEach(_44,function(v){
_45.push({site:v.text,href:v.href,tested:v.value,status:v.status});
},this);
if(!this.grid1){
this._makeGrid1();
this._makeGrid2and3();
}
this.store1.close();
this.store1._jsonData={identifier:"site",items:_45};
this.store1.fetch();
this.grid1._refresh(true);
if(Px.Ex.Application._currentPublisherCode){
this.showLeftTitle(1,"Active Buyers");
}else{
this.showLeftTitle(1,"~");
}
},showLeftTitle:function(num,_46){
var h=dojo.marginBox(dojo.query(".dojoxGridScrollbox",this["grid"+num].domNode)[0]).h;
var w=20;
h=parseInt(h);
if(this["_surface"+num]){
this["_surface"+num].destroy();
}
if(h<10){
delete this["_surface"+num];
return;
}
var _47=this["_surface"+num]=dojox.gfx.createSurface("leftTitleDiv"+num+"Id",w,h);
var t=_47.createText({x:0,y:0,text:_46,align:"middle"});
t.setFont({family:"Arial",size:"14px",weight:"bold",rotated:true});
var tw=t.getTextWidth();
_47.remove(t);
var _48=10;
if(tw>h-_48){
var _49=h;
h=tw+_48;
if(h-_49-2<0){
h+=4;
}
_47.setDimensions(w,h);
dojo.empty("indicator"+num+"Id");
dojo.create("div",{style:{height:(h-_49-2)+"px"},className:"under-grid"},"indicator"+num+"Id");
}
var _4a=_47.createPath("");
var r=8;
var _4b=dojo.isIE?0:1;
_4a.moveTo(w,h-1).hLineTo(r+1).arcTo(r,r,0,false,true,1,h-r-1).vLineTo(r+_4b).arcTo(r,r,0,false,true,r+1,_4b).hLineTo(w).closePath();
var _4c=this._getDisplayVersionColor();
_4a.setFill(_4c).setStroke(_4c);
var c={x:parseInt(w/2),y:parseInt(h/2)};
t=_47.createText({x:c.x,y:c.y+6,text:_46,align:"middle"});
if(_46!="~"){
t.setFill("white");
}else{
t.setFill(_4c);
}
t.setFont({family:"Arial",size:"14px",weight:"bold",rotated:true});
var m=dojox.gfx.matrix;
t.setTransform(m.rotategAt(-90,c.x,c.y));
},_getDisplayVersionColor:function(){
return dojo.getComputedStyle(dojo.query(".texi-logo-text")[0]).color;
},showData2:function(num,_4d){
var _4e=[];
dojo.forEach(_4d,function(v,i){
if(i>0){
_4e.push({uptime:v.periodUptime,href:v.href,response:v.responseTime,percent:v.percent,total:v.total});
}
},this);
this["store"+num].close();
this["store"+num]._jsonData={identifier:"uptime",items:_4e};
this["store"+num].fetch();
this["grid"+num]._refresh();
this.showGrid(num,_4d.length);
this.showTitle2(num,_4d);
},showTitle2:function(num,_4f){
this.showLeftTitle(num,this._selectedSite);
},showGrid:function(num,_50){
this["grid"+num].attr({style:{visibility:(_50?"visible":"hidden")}});
dojo.style("closeGrid"+num+"Id","visibility",(_50?"visible":"hidden"));
},onTable1:function(_51){
this._clearHiddenPane(2);
this.data2=[];
this.showData2(2,this.data2);
this._clearHiddenPane(3);
this.data3=[];
this.showData2(3,this.data3);
delete this._selectedUptime;
if(this.timer2){
clearTimeout(this.timer2);
}
if(this.timer3){
clearTimeout(this.timer3);
}
dojo.query("#indicator2Id").empty().html(Px.Ex.Application.getWaitHtml());
dojo.empty("indicator3Id");
this._loadData2(_51);
},onCloseGrid:function(num){
if(num==2){
this._clearHiddenPane(2);
this.data2=[];
this.showData2(2,this.data2);
if(this.timer2){
clearTimeout(this.timer2);
}
dojo.query("#indicator2Id").empty();
delete this._selectedSite;
delete this._selectedUptime;
this.grid1.update();
}
if(num==2||num==3){
this._clearHiddenPane(3);
this.data3=[];
this.showData2(3,this.data3);
if(this.timer3){
clearTimeout(this.timer3);
}
dojo.query("#indicator3Id").empty();
if(num==3){
this.grid2.update();
}
}
},_parseData2:function(){
dojo.query("#indicator2Id").empty();
this.data2=this._extractData2(this.hiddenPane2.domNode);
this._clearHiddenPane(2);
if(dojo.isFF){
this.showData2(2,[]);
}
this.showData2(2,this.data2);
this.timer2=setTimeout(dojo.hitch(this,"_loadData2",undefined),this.TIMEOUT2*1000);
},onTable2:function(_52){
this._clearHiddenPane(3);
this.data3=[];
this.showData2(3,this.data3);
if(this.timer3){
clearTimeout(this.timer3);
}
dojo.query("#indicator3Id").empty().html(Px.Ex.Application.getWaitHtml());
this._loadData3(_52);
},_parseData3:function(){
dojo.query("#indicator3Id").empty();
this.data3=this._extractData2(this.hiddenPane3.domNode);
this._clearHiddenPane(3);
this.showData2(3,this.data3);
this.timer3=setTimeout(dojo.hitch(this,"_loadData3",undefined),this.TIMEOUT3*1000);
},onTable3:function(_53){
},destroy:function(){
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
}
this.cancelXhr();
dojo.forEach(["timer1","timer2","timer3"],function(v){
if(this[v]){
clearTimeout(this[v]);
}
});
dojo.forEach([1,2,3],function(v){
try{
if(this["_surface"+v]){
this["_surface"+v].destroy();
}
}
catch(e){
}
},this);
dojo.forEach(["hiddenPane1","hiddenPane2","hiddenPane3","grid1","grid2","grid3"],function(v){
try{
if(this[v]){
this[v].destroyRecursive();
}
}
catch(e){
}
},this);
}});
dojo.declare("Px.Ex.DirectDataDealsScreen",[Px.Ex.XhrMixin],{NOTE_INDICATION_FIELD:"numOfNotes",_gridArchiveCollapsed:true,_searchValue:"",_allow:[],dialogMessages:undefined,validateMaxMessages:undefined,publisherSettings:undefined,_handlers:[],ACTIVE:1,INACTIVE:2,ARCHIVED:3,NORMAL:1,HIGH:2,VALIDATE_NEW:1,VALIDATE_ACTIVATE:2,VALIDATE_TO_HIGH_PRIORITY:3,MAX_DEALS_ATTRIBUTE_ID:2,MAX_ACTIVE_ATTRIBUTE_ID:3,MAX_HIGH_ATTRIBUTE_ID:4,_currentGridData:undefined,draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhrLoad({selector:"#divContent",url:"/direct-data-deals/screen",load:dojo.hitch(this,"createScreen")});
},createScreen:function(){
if(!dojo.byId("gridArchiveId")){
return;
}
this._allow=dojo.fromJson(dojo.byId("allowId").innerHTML);
this.dialogMessages=dojo.fromJson(dojo.byId("dialogMessagesId").innerHTML);
this.validateMaxMessages=dojo.fromJson(dojo.byId("validateMaxMessagesId").innerHTML);
this.publisherSettings=this._preparePublisherSettings(dojo.fromJson(dojo.byId("publisherSettingsId").innerHTML));
if(this._allow["create-deal"]){
if(!this._handlers){
this._handlers=[];
}
this._handlers.push(dojo.connect(dojo.byId("createDealId"),"onclick",this,function(e){
if(!this.validateMax(this.VALIDATE_NEW)){
return;
}
var _1=new Px.Ex.DealDialog({closeCallback:dojo.hitch(this,function(_2,_3,_4,_5){
this.reloadGrids([this.gridCurrent]);
if((_3==0)&&(_4==this.ACTIVE)){
this.sendConfirmationEmail(_5);
}
}),messages:this.dialogMessages});
_1.show();
}));
}
this.makeCurrentGrid();
this.loadCurrentGrid();
this.makeArchiveGrid();
this.makeSearchControl();
},_preparePublisherSettings:function(_6){
var _7=[this.MAX_DEALS_ATTRIBUTE_ID,this.MAX_ACTIVE_ATTRIBUTE_ID,this.MAX_HIGH_ATTRIBUTE_ID];
var ps={};
dojo.forEach(_7,function(v){
ps[v]=0;
});
dojo.every(_6,function(v){
var i=dojo.indexOf(_7,v.attributeId);
if(i>=0){
ps[_7[i]]=v.attributeNumericValue;
if(_7.length==1){
return false;
}
_7.splice(i,1);
}
return true;
},this);
return ps;
},_makeGridStructure:function(_8){
var _9=dojo.hitch(this,function(_a,_b){
var _c=_8?this.gridArchive:this.gridCurrent;
var _d=_c.getItem(_b);
if(!_d){
return "";
}
var _e=_c.store.getValue(_d,"dealStatus");
var _f=_c.store.getValue(_d,"dealCode");
var cls="deal-name";
if(_e!=this.ACTIVE){
cls+=" inactive";
}
var _10=dojo.string.substitute("<span class=\"${cls}\">${data}</span>",{data:_a,cls:cls});
if(_c.store.getValue(_d,this.NOTE_INDICATION_FIELD)&&(_c.store.getValue(_d,this.NOTE_INDICATION_FIELD)>0)&&this._allow["notes_show"]){
return "<table id=\"deal_name_"+_f+"\" style=\"width: 100%;\"><tbody><tr><td>"+_10+"</td><td style=\"vertical-align: middle;\"><div class=\"notesIndicationDDD\"></div></td></tr></tbody></table>";
}else{
return "<div id=\"deal_name_"+_f+"\">"+_10+"</div>";
}
});
var _11=dojo.hitch(this,function(_12,_13){
var _14=_8?this.gridArchive:this.gridCurrent;
var _15=_14.getItem(_13);
if(!_15){
return "";
}
var _16=_14.store.getValue(_15,"buyername");
if(_12){
return dojo.string.substitute("<img src=\"/logo/Logo-${src}\" alt=\"${alt}\" height=\"20px\" style=\"vertical-align:middle;\"></img>",{src:_12,alt:_16});
}
return _16;
});
var _17=dojo.hitch(this,function(_18,_19){
var _1a=_8?this.gridArchive:this.gridCurrent;
var _1b=_1a.getItem(_19);
if(!_1b){
return "";
}
var _1c=_1a.store.getValue(_1b,"dealPriority");
var _1d=_1a.store.getValue(_1b,"dealStatus");
var cls="";
if(_1d!=this.ACTIVE){
cls="inactive";
}else{
if(_1c==this.NORMAL){
cls="normal";
}else{
if(_1c==this.HIGH){
cls="high";
}
}
}
return dojo.string.substitute("<div class=\"${cls}\"></div>",{cls:"status "+cls});
});
var _1e=dojo.hitch(this,function(_1f,_20){
var n=_1f;
try{
n=dojo.number.format(n,{pattern:"#,##0.#################"});
}
catch(e){
}
return n;
});
var _21=dojo.hitch(this,function(_22,_23){
var d=_22;
try{
d=d.slice(0,10);
}
catch(e){
}
return d;
});
var _24=[{defaultCell:{styles:"white-space:nowrap;",headerStyles:"text-align:center;cursor:pointer;",noresize:true},cells:[{name:"Deal Name",field:"dealName",formatter:_9,width:"290px"},{name:"Buyer",field:"buyerLogoURL",formatter:_11,width:"130px",cellStyles:"text-align:center;vertical-align:middle;"},{name:"Activity",field:"dealStatusFull",formatter:_17,width:"60px",cellStyles:"text-align:center;vertical-align:middle;"},{name:"Rate",field:"rateString",width:"140px"},{name:_8?"Total Uniques":"MTD Uniques",field:_8?"totalUniques":"mtdVolume",formatter:_1e,width:"80px",cellStyles:"text-align:right;"},{name:_8?"Last Active":"End Date",field:"end",formatter:_21,width:"100%",cellStyles:"text-align:center;"}]}];
return _24;
},_addTooltip:function(_25){
_25.connect(_25,"onCellMouseOver",dojo.hitch(this,function(e){
if(e.cellNode&&e.cell.field=="dealStatusFull"){
var _26=e.grid.getItem(e.rowIndex);
var _27=e.grid.store.getValue(_26,"dealStatus");
var _28=e.grid.store.getValue(_26,"dealPriority");
var s="UNKNOWN";
if(_27==this.INACTIVE){
s="Inactive";
}else{
if(_27==this.ARCHIVED){
s="Archived";
}else{
if(_27==this.ACTIVE){
if(_28==this.NORMAL){
s="Active, Normal Priority";
}else{
if(_28==this.HIGH){
s="Active, High Priority";
}else{
s="Active";
}
}
}
}
}
dijit.showTooltip(s,e.cellNode);
}else{
if(e.cellNode&&e.cell.field=="buyerLogoURL"){
var _26=e.grid.getItem(e.rowIndex);
var s=e.grid.store.getValue(_26,"buyername");
dijit.showTooltip(s,e.cellNode);
}
}
}));
_25.connect(_25,"onCellMouseOut",dojo.hitch(this,function(e){
if(e.cellNode&&e.cell.field=="dealStatusFull"||e.cell.field=="buyerLogoURL"){
dijit.hideTooltip(e.cellNode);
}
}));
},_addPopupMenu:function(_29){
_29.connect(_29,"onCellContextMenu",dojo.hitch(this,"showPopupMenu"));
if(!this._handlers){
this._handlers=[];
}
this._handlers.push(dojo.connect(_29.domNode,"onmousemove",this,function(e){
this._pageX=e.pageX;
this._pageY=e.pageY;
}));
_29.connect(_29,"onMouseOverRow",dojo.hitch(this,function(e){
if(e.cellNode&&e.cell.field=="dealName"){
clearTimeout(this._popupMenuTimer);
if(e.target.nodeName=="SPAN"){
this._popupMenuTimer=setTimeout(dojo.hitch(this,"showPopupMenu",false,e.grid,e.rowIndex),2000);
}
}
}));
_29.connect(_29,"onMouseOutRow",dojo.hitch(this,function(e){
if(e.cellNode&&e.cell.field=="dealName"){
clearTimeout(this._popupMenuTimer);
}
}));
this.popupMenu=new dijit.PopupMenuDialog({"class":"texi-popup-menu-dialog"});
this.popupMenu.startup();
if(dojo.isChrome){
this.popupMenu._openIn(-1000,-1000);
this.popupMenu.close();
}
this.popupMenu.connect(this.popupMenu,"onClose",dojo.hitch(this,function(){
dojo.forEach(this._menuConnections,dojo.disconnect,this);
delete this._menuConnections;
}));
},showPopupMenu:function(e,_2a,_2b){
clearTimeout(this._popupMenuTimer);
if(e){
_2a=e.grid;
_2b=e.rowIndex;
}
var _2c=this.createPopupMenu(_2a,_2b);
this.popupMenu.attr("content",_2c);
if(e&&e.type=="contextmenu"){
this.popupMenu._openMyself(e);
}else{
this.popupMenu._openIn(this._pageX,this._pageY);
}
},createPopupMenu:function(_2d,_2e){
var _2f;
if(_2d===this.gridCurrent){
var row=_2d.getItem(_2e);
var _30=_2d.store.getValue(row,"dealStatus");
var _31=_2d.store.getValue(row,this.NOTE_INDICATION_FIELD);
var _32=_2d.store.getValue(row,"dealPriority");
_2f=[{id:"view",title:"View",allow:this._allow["menu-view"]},{id:"edit",title:"Edit",allow:this._allow["menu-edit"]}];
if(_30==this.INACTIVE){
_2f.push({id:"activate",title:"Activate",allow:this._allow["menu-activate"]});
}else{
if(_30==this.ACTIVE){
_2f.push({id:"deactivate",title:"Deactivate",allow:this._allow["menu-deactivate"]});
}
}
_2f.push({id:"archive",title:"Move to Archive",allow:this._allow["menu-archive"]});
if(_30==this.ACTIVE){
if(_32==this.NORMAL){
_2f.push({id:"set-priority-high",title:"Set to High Priority",allow:this._allow["menu-set-priority"]});
}else{
if(_32==this.HIGH){
_2f.push({id:"set-priority-normal",title:"Set to Normal Priority",allow:this._allow["menu-set-priority"]});
}
}
}
if((_31!=undefined)&&(_31!=null)&&(_31>0)){
_2f.push({id:"notes_show",title:"View Notes",allow:this._allow["notes_show"]});
}else{
_2f.push({id:"notes_add",title:"Add A Note",allow:(this._allow["notes_show"]&&this._allow["notes_add"])});
}
}else{
var row=_2d.getItem(_2e);
var _31=_2d.store.getValue(row,this.NOTE_INDICATION_FIELD);
_2f=[{id:"view",title:"View",allow:this._allow["menu-view"]},{id:"edit",title:"Edit",allow:this._allow["menu-edit"]},{id:"activate",title:"Activate",allow:this._allow["menu-activate"]}];
if((_31!=undefined)&&(_31!=null)&&(_31>0)){
_2f.push({id:"notes_show",title:"View Notes",allow:this._allow["notes_show"]});
}else{
_2f.push({id:"notes_add",title:"Add A Note",allow:(this._allow["notes_show"]&&this._allow["notes_add"])});
}
}
var _33=dojo.create("ul",{className:"texi-popup-menu"});
this._menuConnections=[];
dojo.forEach(_2f,function(v){
var li=dojo.create("li",{innerHTML:v.title,id:v.id,className:v.allow?"":"grayed"},_33);
if(v.allow){
this._menuConnections.push(dojo.connect(li,"onmouseover",this,function(e){
dojo.addClass(li,"active");
}));
this._menuConnections.push(dojo.connect(li,"onmouseout",this,function(e){
dojo.removeClass(li,"active");
}));
this._menuConnections.push(dojo.connect(li,"onclick",this,dojo.hitch(this,"onMenuItemClick",_2d,_2e)));
}
},this);
return _33;
},onMenuItemClick:function(_34,_35,e){
var _36=e.target.id;
this.popupMenu.close();
var _37=_34.getItem(_35);
var _38=_34.store.getValue(_37,"dealStatus");
if(!_37){
return;
}
var _39=_34.store.getValue(_37,"dealCode");
var _3a=[];
if(dojo.indexOf(["activate","deactivate","archive"],_36)>=0){
if(_34===this.gridCurrent){
_3a.push(this.gridCurrent);
if(_36=="archive"){
_3a.push(this.gridArchive);
}
}else{
_3a.push(this.gridCurrent);
_3a.push(this.gridArchive);
}
var _3b=(_36=="activate"?this.ACTIVE:(_36=="deactivate"?this.INACTIVE:this.ARCHIVED));
if(_3b==this.ACTIVE&&!this.validateMax(this.VALIDATE_ACTIVATE)){
return;
}
this.xhr({url:"/direct-data-deals/set-data-deal-status",content:{dealCode:_39,status:_3b},load:dojo.hitch(this,"setStatusPriorityResponse",_3a,_36),handleAs:"json"});
}else{
if(dojo.indexOf(["set-priority-high","set-priority-normal"],_36)>=0){
_3a.push(this.gridCurrent);
var _3c=(_36=="set-priority-high"?this.HIGH:this.NORMAL);
if(_3c==this.HIGH&&!this.validateMax(this.VALIDATE_TO_HIGH_PRIORITY)){
return;
}
this.xhr({url:"/direct-data-deals/set-data-deal-priority",content:{dealCode:_39,priority:_3c},load:dojo.hitch(this,"setStatusPriorityResponse",_3a,_36),handleAs:"json"});
}else{
if(dojo.indexOf(["notes_show","notes_add"],_36)>=0){
this.onNotesIndicationClick(_34,_35);
}else{
var _3d=(_36=="view");
var dlg=new Px.Ex.DealDialog({viewOnly:_3d,previousDealStatus:_38,dealCode:_39,messages:this.dialogMessages,allow:this._allow,closeCallback:dojo.hitch(this,function(_3e,_3f,_40,_41){
var _42;
if(!_3e){
_42=[this.gridCurrent];
}else{
if(_40==3){
_42=[this.gridArchive];
}else{
_42=[this.gridCurrent,this.gridArchive];
}
}
this.reloadGrids(_42);
if((_40==this.ACTIVE)&&(_3f>0)&&(_3f!=_40)){
this.sendConfirmationEmail(_41);
}
})});
dlg.show();
}
}
}
},setStatusPriorityResponse:function(_43,_44,_45){
if(_45["return"]&&_45["return"].success){
this.reloadGrids(_43);
}else{
var msg=_44+": ";
msg+=(_45["return"]&&_45["return"].errorMessage)?_45["return"].errorMessage:dojo.toJson(_45);
this._showMsgDialog(msg);
}
},_showMsgDialog:function(msg,_46){
return Px.Ex.Application.showMsgDialog(msg,_46);
},reloadGrids:function(_47){
dojo.forEach(_47,function(_48){
if(_48===this.gridCurrent){
this.loadCurrentGrid();
}else{
if(!this._gridArchiveCollapsed){
this.expandArchiveGrid(false);
this.expandArchiveGrid(true);
}
}
},this);
},makeCurrentGrid:function(){
this.storeCurrent=new dojo.data.ItemFileReadStore({clearOnClose:true,data:{identifier:"dealCode",items:[]}});
var _49=this._makeGridStructure();
this.gridCurrent=new dojox.grid.DataGrid({store:this.storeCurrent,query:{dealCode:"*"},queryOptions:{ignoreCase:true},clientSort:true,onFetchError:dojo.hitch(this,function(_4a,req){
if(!req){
return;
}
this.gridCurrent._pending_requests[req.start]=false;
}),style:{width:"100%"},autoHeight:1000,rowsPerPage:1000,selectionMode:"none",canSort:function(_4b){
return true;
},onStyleRow:function(_4c){
this.edit.styleRow(_4c);
},structure:_49},"gridCurrentId");
this._addTooltip(this.gridCurrent);
this._addPopupMenu(this.gridCurrent);
this.gridCurrent.startup();
},loadCurrentGrid:function(){
delete this._currentGridData;
this.onLoadCurrentGrid({identifier:"dealCode",items:[]});
this._currentGridDataLoading=true;
dojo.query("#indicatorCurrentId").empty().html(Px.Ex.Application.getWaitHtml());
this.xhr({url:"/direct-data-deals/data-deals",content:{archive:""},load:dojo.hitch(this,"onLoadCurrentGrid"),error:dojo.hitch(this,function(_4d){
delete this._currentGridDataLoading;
dojo.byId("indicatorCurrentId").innerHTML=_4d;
}),handleAs:"json"});
},onLoadCurrentGrid:function(_4e){
if(this._waitDialog){
try{
this._waitDialog.hide();
}
catch(e){
}
delete this._waitDialog;
}
this._currentGridData=dojo.clone(_4e);
if(_4e.identifier&&_4e.items){
this._addStatusFullColumn(_4e);
dojo.query("#indicatorCurrentId").empty();
this.storeCurrent.close();
this.storeCurrent._jsonData=_4e;
this.storeCurrent.fetch();
this.gridCurrent._refresh();
this._showUpperLabel("currentGridLabelId",_4e);
this._handlers.push(dojo.connect(this.gridCurrent,"postresize",dojo.hitch(this,function(){
this.showCurrentLeftTitle();
})));
this.gridCurrent.resize();
this.gridCurrent.connect(this.gridCurrent,"onCellClick",dojo.hitch(this,"onGridCellClick"));
}else{
dojo.query("#indicatorCurrentId").empty().html(dojo.toJson(_4e));
this._showUpperLabel("currentGridLabelId");
}
delete this._currentGridDataLoading;
},onGridCellClick:function(e){
if(e.target.className=="notesIndicationDDD"){
if(e.grid==this.gridCurrent){
if(!this._fireTwicePrevent){
this._fireTwicePrevent=true;
this.onNotesIndicationClick(e.grid,e.target,e.rowIndex);
}else{
delete this._fireTwicePrevent;
}
}else{
this.onNotesIndicationClick(e.grid,e.rowIndex);
}
}
},onNotesIndicationClick:function(_4f,_50){
var _51=_4f.store.getValue(_4f.getItem(_50),"dealCode");
var _52;
dojo.xhrGet({sync:true,url:"/notes/get-data-deal-notes",content:{dataDealCode:_51},load:dojo.hitch(this,function(_53){
_52=_53;
}),error:dojo.hitch(this,function(_54){
_52=_54;
}),handleAs:"json"});
if(_52.notes){
var _55=dojo.coords(dojo.byId("deal_name_"+_51).parentNode);
new Px.Ex.DataDealNotes.NotesWidgetDialog({teXiServerResponse:_52,addPermission:this._allow["notes_add"],x:_55.x+_55.w,y:_55.y}).show();
}
},showCurrentLeftTitle:function(){
this._showLeftTitle("Current Deals",this._getDisplayVersionColor(),this.gridCurrent,"_surfaceCurrent","leftTitleDivCurrentId","indicatorCurrentId");
},showArchiveLeftTitle:function(){
this._showLeftTitle("Archive","#c0c0c0",this.gridArchive,"_surfaceArchive","leftTitleDivArchiveId","indicatorArchiveId");
},_getDisplayVersionColor:function(){
return dojo.getComputedStyle(dojo.query(".texi-logo-text")[0]).color;
},_addStatusFullColumn:function(_56){
dojo.forEach(_56.items,function(v){
v.dealStatusFull=v.dealStatus*10+(v.dealStatus==this.ACTIVE&&v.dealPriority==this.HIGH?0:5);
},this);
},_showUpperLabel:function(_57,_58){
dojo.empty(_57);
if(!_58||_58.items.length==0){
if(_57.indexOf("archive")>=0){
dojo.create("span",{className:"upper-label title",innerHTML:"Data Deals Archive"},_57);
}
return;
}
var _59=dojo.filter(_58.items,function(v){
return v.dealStatus==this.ACTIVE;
},this);
var _5a="&nbsp;";
var _5b=_59.length;
var _5c=_58.items.length-_5b;
var is=(_5b==1?"is":"are");
dojo.create("span",{className:"upper-label",innerHTML:"There "+is+" currently"},_57);
if(_5b){
var str=_5a+_5b+" Active Deal";
if(_5b!=1){
str+="s";
}
dojo.create("span",{className:"upper-label active",innerHTML:str},_57);
}
if(_5c){
var str=_5a;
if(_5b){
str+="+ ";
}
str+=_5c+" Inactive Deal";
if(_5c!=1){
str+="s";
}
dojo.create("span",{className:"upper-label inactive",innerHTML:str},_57);
}
},_showLeftTitle:function(_5d,_5e,_5f,_60,_61,_62){
var _63="12px";
var h=dojo.marginBox(dojo.query(".dojoxGridScrollbox",_5f.domNode)[0]).h;
var w=20;
h=parseInt(h);
if(this[_60]){
this[_60].destroy();
}
if(h<10){
delete this[_60];
return;
}
var _64=this[_60]=dojox.gfx.createSurface(_61,w,h);
var t=_64.createText({x:0,y:0,text:_5d,align:"middle"});
t.setFont({family:"Arial",size:_63,weight:"bold",rotated:true});
var tw=t.getTextWidth();
_64.remove(t);
var _65=10;
if(tw>h-_65){
var _66=h;
h=tw+_65;
if(h-_66-2<0){
h+=4;
}
_64.setDimensions(w,h);
dojo.query("#"+_62).empty();
dojo.create("div",{style:{height:(h-_66-2)+"px"},className:"under-grid"},_62);
}
var _67=_64.createPath("");
var r=8;
var _68=dojo.isIE?0:1;
_67.moveTo(w,h-1).hLineTo(r+1).arcTo(r,r,0,false,true,1,h-r-1).vLineTo(r+_68).arcTo(r,r,0,false,true,r+1,_68).hLineTo(w).closePath();
_67.setFill(_5e).setStroke(_5e);
var c={x:parseInt(w/2),y:parseInt(h/2)};
t=_64.createText({x:c.x,y:c.y+6,text:_5d,align:"middle"});
t.setFill("white");
t.setFont({family:"Arial",size:_63,weight:"bold",rotated:true});
var m=dojox.gfx.matrix;
t.setTransform(m.rotategAt(-90,c.x,c.y));
},makeArchiveGrid:function(){
this.storeArchive=new dojo.data.ItemFileReadStore({clearOnClose:true,data:{identifier:"dealCode",items:[]}});
var _69=this._makeGridStructure("Archive=true");
this.gridArchive=new dojox.grid.DataGrid({store:this.storeArchive,query:{dealCode:"*"},queryOptions:{ignoreCase:true},clientSort:true,onFetchError:dojo.hitch(this,function(_6a,req){
if(!req){
return;
}
this.gridCurrent._pending_requests[req.start]=false;
}),style:{width:"850px"},autoHeight:8,selectionMode:"none",canSort:function(_6b){
return true;
},onStyleRow:function(_6c){
this.edit.styleRow(_6c);
},structure:_69},"gridArchiveId");
this._addTooltip(this.gridArchive);
this._addPopupMenu(this.gridArchive);
this.gridArchive.startup();
this.gridArchive.connect(this.gridArchive,"onCellClick",dojo.hitch(this,"onGridCellClick"));
this.gridArchive.connect(dojo.byId("expandCollapseGridArchiveId"),"onclick",dojo.hitch(this,"onExpandCollpseArchiveGrid"));
this._showUpperLabel("archiveGridLabelId");
},onExpandCollpseArchiveGrid:function(){
this.expandArchiveGrid(this._gridArchiveCollapsed);
},expandArchiveGrid:function(_6d){
if(this._deferred){
this._deferred.cancel();
delete this._deferred;
return;
}
delete this._archiveData;
if(_6d){
dojo.query("#indicatorArchiveId").empty().html(Px.Ex.Application.getWaitHtml());
this._showArchiveExpandButton(false);
this._deferred=this.xhr({url:"/direct-data-deals/data-deals",content:{archive:"on"},load:dojo.hitch(this,function(_6e){
if(_6e&&_6e.items){
this._addStatusFullColumn(_6e);
}
var d=this._filterArchiveData(_6e,this._searchValue);
this._showGridArchive(d);
if(_6e&&_6e.items&&_6e.items.length){
this._gridArchiveCollapsed=false;
this._archiveData=_6e;
}else{
this._showArchiveExpandButton(true);
}
if(this._deferred){
delete this._deferred;
}
}),error:dojo.hitch(this,function(_6f){
dojo.query("#indicatorArchiveId").empty();
this._gridArchiveCollapsed=true;
this._showArchiveExpandButton(true);
}),handleAs:"json"});
}else{
this._showArchiveExpandButton(true);
dojo.query("#indicatorArchiveId").empty();
this._showGridArchive({identifier:"dealCode",items:[]});
this._gridArchiveCollapsed=true;
}
},_showArchiveExpandButton:function(_70){
var _71="expand-grid",_72="collapse-grid";
if(_70){
_72="expand-grid";
_71="collapse-grid";
}
dojo.removeClass("expandCollapseGridArchiveId",_71);
dojo.addClass("expandCollapseGridArchiveId",_72);
},_showGridArchive:function(_73){
if(_73.identifier&&_73.items){
dojo.query("#indicatorArchiveId").empty();
this.storeArchive.close();
this.storeArchive._jsonData=_73;
this.storeArchive.fetch();
this.gridArchive._refresh();
this.gridArchive.attr("autoHeight",0);
this.gridArchive.attr("autoHeight",8);
this.showArchiveLeftTitle();
this.gridArchive._refresh();
this._showUpperLabel("archiveGridLabelId",_73);
}else{
dojo.query("#indicatorArchiveId").empty().html(dojo.toJson(_73));
this._showUpperLabel("archiveGridLabelId");
}
},makeSearchControl:function(){
this.searchControl=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true,emptyText:"Search Archive"},"archiveSerachId");
this.searchControl.startup();
this.searchControl.connect(this.searchControl,"onChange",dojo.hitch(this,"onChangeSearchText"));
},onChangeSearchText:function(_74){
this._searchValue=_74;
if(!this._archiveData){
return;
}
if(this.gridArchive._isLoading){
return;
}
clearTimeout(this._searchTimer);
this._searchTimer=setTimeout(dojo.hitch(this,"searchArchive",_74),250);
},searchArchive:function(_75){
var _76=this._filterArchiveData(this._archiveData,_75);
this._showGridArchive(_76);
},_filterArchiveData:function(_77,_78){
if(_78==undefined||!_78.length){
return dojo.clone(_77);
}
var val=_78.toLowerCase();
var _79=[];
dojo.forEach(_77.items,function(v){
if(v.dealName.toLowerCase().indexOf(val)>=0||v.buyername.toLowerCase().indexOf(val)>=0){
_79.push(dojo.clone(v));
}
});
return {identifier:_77.identifier,label:_77.label,items:_79};
},_countCurrentGridData:function(){
if(this._currentGridDataLoading||!this._currentGridData||!this._currentGridData.items){
return undefined;
}
var all=0,_7a=0,_7b=0;
dojo.forEach(this._currentGridData.items,function(v){
++all;
if(v.dealStatus==this.ACTIVE){
++_7a;
if(v.dealPriority==this.HIGH){
++_7b;
}
}
},this);
return {all:all,active:_7a,high:_7b};
},validateMax:function(_7c){
var cnt=this._countCurrentGridData();
if(cnt===undefined){
this._waitDialog=this._showMsgDialog(this.validateMaxMessages["dataNotLoaded"],"warning-message");
return false;
}
var msg=[];
if(_7c==this.VALIDATE_NEW){
if(cnt.all>=this.publisherSettings[this.MAX_DEALS_ATTRIBUTE_ID]){
msg.push(dojo.string.substitute(this.validateMaxMessages["numberOfDealsBreach"],[this.publisherSettings[this.MAX_DEALS_ATTRIBUTE_ID]]));
}
}else{
if(_7c==this.VALIDATE_ACTIVATE){
if(cnt.active>=this.publisherSettings[this.MAX_ACTIVE_ATTRIBUTE_ID]){
msg.push(dojo.string.substitute(this.validateMaxMessages["numberOfActiveBreach"],[this.publisherSettings[this.MAX_ACTIVE_ATTRIBUTE_ID]]));
}
}else{
if(_7c==this.VALIDATE_TO_HIGH_PRIORITY){
if(cnt.high>=this.publisherSettings[this.MAX_HIGH_ATTRIBUTE_ID]){
msg.push(dojo.string.substitute(this.validateMaxMessages["numberOfHighBreach"],[this.publisherSettings[this.MAX_HIGH_ATTRIBUTE_ID]]));
}
}else{
return true;
}
}
}
if(msg.length){
this._showMsgDialog(msg.join("<br><br>"),"info-message");
return false;
}
return true;
},sendConfirmationEmail:function(_7d){
this.xhr({url:"/direct-data-deals/send-confirmation-email",content:{dealCode:_7d},handleAs:"json"});
},destroy:function(){
clearTimeout(this._searchTimer);
clearTimeout(this._popupMenuTimer);
if(this._handlers){
dojo.forEach(this._handlers,dojo.disconnect,this);
}
if(this._menuConnections){
dojo.forEach(this._menuConnections,dojo.disconnect,this);
}
dojo.forEach([this.popupMenu,this.gridArchive,this.gridCurrent,this.searchControl],function(v){
try{
if(v){
v.destroyRecursive();
}
}
catch(e){
}
});
dojo.forEach(["_surfaceCurrent","_surfaceArchive"],function(v){
try{
if(this[v]){
this[v].destroy();
}
}
catch(e){
}
},this);
}});
dojo.declare("Px.Ex.DealDialog",[Px.Ex.Dialog],{VALIDATION_INTERVAL:1000,DEAL_DETAILS_I:0,DATES_I:1,PRICING_I:2,DEFINE_PIXEL_I:3,DELIVERY_I:4,SITES_I:5,ADVANCED_I:6,_connections:[],viewOnly:false,dealCode:0,previousDealStatus:0,closeCallback:undefined,messages:undefined,"class":"deal-dialog",_dealWasArchived:false,_savedDealStatus:0,constructor:function(_1){
dojo.mixin(this,_1);
var m=this.messages;
this.buttonClose=m.buttonClose||this.buttonClose;
this.rotationImage=Px.Ex.Application.getWaitImageUrl();
this._subscribtions=[];
var vo=this.viewOnly;
this.PROGRESS_LIST=[{label:m.listDealDeatils||"Deal Details",className:vo?"closed":"opened",progress:vo?1:0,div:undefined},{label:m.listDates||"Dates",className:vo?"closed":"default",progress:1,div:undefined},{label:m.listPricing||"Pricing",className:vo?"closed":"default",progress:1,div:undefined},{label:m.listDefinePixel||"Define Pixel",className:vo?"closed":"opened",progress:vo?1:0,div:undefined},{label:m.listDelivery||"Delivery",className:vo?"closed":"opened",progress:vo?1:0,div:undefined},{label:m.listSites||"Sites",className:vo?"closed":"opened",progress:vo?1:0,div:undefined},{label:m.listAdvanced||"Advanced",className:"opened",progress:0,div:undefined}];
this.EMPTY_DEAL={buyerCode:null,buyerLogoURL:null,buyername:null,datesDefined:false,dealCode:null,dealName:null,dealRate:null,dealStatus:2,dealStatusName:null,end:null,monthlyDeliveryIndication:false,mtdVolume:null,ownerCode:null,pixelData:null,priceDefined:false,priceTypeCode:1,dealPriority:1,dealPriorityName:null,rateString:"1",start:null,targetOnAllSites:true,templateCode:null,uniqueUsers:null,uniques30Days:false,usOnly:false};
this.deal=undefined;
this.NOW=new Date();
this.NOW.setHours(0,0,0,0);
},startup:function(){
this.inherited(arguments);
var _2=this.dealCode?(this.viewOnly?Px.Ex.Application.Titles.DEAL_DETAILS:Px.Ex.Application.Titles.EDIT_DEAL):Px.Ex.Application.Titles.NEW_DEAL;
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(_2);
this._createLayout();
removeWidget("dealMaster");
this.master=new dijit.layout.StackContainer({id:"dealMaster"},this.masterDiv);
this.createProgressBar(100,7);
dojo.forEach(this.PROGRESS_LIST,function(v,i){
this.PROGRESS_LIST[i].div=dojo.create("div",{className:"progress-list-item "+v.className,innerHTML:v.label},this.indicatorDiv);
},this);
this.showProgress();
this.showRotation(true);
this.xhr({content:{dealCode:this.dealCode},url:"/direct-data-deals/dialog",load:dojo.hitch(this,"createContent"),error:dojo.hitch(this,"showXhrError"),handleAs:"json"});
},_createLayout:function(){
var m=this.messages;
var _3,_4,tr,td,_5,c=dojo.create;
_3=c("table",{className:"deal-dialog-layout"},this.containerNode);
_4=c("tbody",{},_3);
tr=c("tr",{},_4);
td=c("td",{className:"border-right border-bottom",innerHTML:"&nbsp;"},tr);
td=c("td",{className:"border-bottom"},tr);
_5=c("div",{className:"progress-label",innerHTML:m.precessCompletion||"Process completion"},td);
tr=c("tr",{},_4);
td=c("td",{className:"border-right border-bottom main-layout"},tr);
this.masterDiv=c("div",{className:"master-div"},td);
td=c("td",{className:"border-bottom indicator-layout"},tr);
this.indicatorDiv=c("div",{},td);
this.errorDiv=c("div",{className:"centre texi-error-text texi-dialog-error-text"},this.containerNode);
_5=c("div",{className:"centre"},this.containerNode);
this.buttons={};
_3=c("table",{className:"buttons-layout"},this.containerNode);
_4=c("tbody",{},_3);
tr=c("tr",{},_4);
if(this.viewOnly){
td=c("td",{},tr);
this.buttons.next=c("div",{className:"button-next",tabindex:-1},td);
this.buttons.prev=c("div",{className:"button-prev",style:{display:"none"},tabindex:-1},td);
td=c("td",{},tr);
this.buttons.advanced=c("div",{className:"button-advanced",style:{display:"none"},tabindex:-1},td);
}else{
td=c("td",{},tr);
this.buttons.reset=c("div",{className:"button-reset",tabindex:-1},td);
td=c("td",{},tr);
c("div",{className:"spacer-h-big"},td);
td=c("td",{},tr);
this.buttons.save1=c("div",{className:"button-save",tabindex:-1},td);
this.buttons.prev=c("div",{className:"button-prev",style:{display:"none"},tabindex:-1},td);
td=c("td",{},tr);
c("div",{className:"spacer-h-small"},td);
td=c("td",{},tr);
this.buttons.next=c("div",{className:"button-next",tabindex:-1},td);
this.buttons.save2=c("div",{className:"button-save",style:{display:"none"},tabindex:-1},td);
td=c("td",{},tr);
c("div",{className:"spacer-h-small"},td);
td=c("td",{},tr);
this.buttons.advanced=c("div",{className:"button-advanced",style:{visibility:"hidden"},tabindex:-1},td);
td=c("td",{},tr);
c("div",{className:"spacer-h-middle"},td);
td=c("td",{},tr);
this.buttons.done_disabled=c("div",{className:"button-done-disabled",tabindex:-1},td);
this.buttons.done=c("div",{className:"button-done",style:{display:"none"},tabindex:-1},td);
}
},createContent:function(_6){
if(_6.notes&&_6.notes.notes){
if(this.allow["notes_show"]){
this._notesButton=dojo.create("div",{className:"notesButtonDataDeal"},this.indicatorDiv);
if(_6.notes.notes.length==0){
dojo.toggleClass(this._notesButton,"notesButtonNone",true);
}
this._connections.push(dojo.connect(this._notesButton,"onclick",dojo.hitch(this,function(){
if(!this._notesWidgetDiv){
this._notesWidgetDiv=dojo.create("div",{className:"notesWidgetDataDeal"},this.indicatorDiv);
this._notesWidget=new Px.Ex.DataDealNotes.NotesWidgetWizard({addPermission:this.allow["notes_add"],teXiServerResponse:_6.notes,Height:448,onBeforeCloseCallback:dojo.hitch(this,function(){
if(this._notesWidget.getNotesScrollableArea().countNotes()>1){
dojo.toggleClass(this._notesButton,"notesButtonNone",false);
}
return true;
}),onAfterCloseCallback:dojo.hitch(this,function(){
delete this._notesWidgetDiv;
})});
this._notesWidget.placeAt(this._notesWidgetDiv);
this._notesWidget.startup();
}
})));
}
}
this.NOW=dojo.date.stamp.fromISOString(_6.now);
this.NOW.setHours(0,0,0,0);
this.showRotation(false);
if(_6.deal){
this.deal=_6.deal;
if(this.deal.dealStatus==3){
this._dealWasArchived=true;
}
if(this.deal.start){
this.deal.start=dojo.date.stamp.fromISOString(this.deal.start);
this.deal.start.setHours(0,0,0,0);
}
if(this.deal.end){
this.deal.end=dojo.date.stamp.fromISOString(this.deal.end);
this.deal.end.setHours(0,0,0,0);
}
this.tags=_6.dealTags;
}else{
this.EMPTY_DEAL.ownerCode=_6.publisherCode;
}
this.BUYERS_DATA=_6.buyers;
this.TEMPLATES_DATA=_6.templates;
this.page1=new Px.Ex.DealDialog.Page1({BUYERS_DATA:this.BUYERS_DATA,TEMPLATES_DATA:this.TEMPLATES_DATA,NOW:this.NOW,xhr:dojo.hitch(this,"xhr"),viewOnly:this.viewOnly,deal:this.deal,messages:this.messages,stopClosing:dojo.hitch(this,"stopClosing"),showRotation:dojo.hitch(this,"showRotation"),_restoreKeys:dojo.hitch(this,"_restoreKeys"),_clearKeys:dojo.hitch(this,"_clearKeys"),isDirty:dojo.hitch(this,"isDirty"),resetWidgets:dojo.hitch(this,"resetWidgets")});
this.page2=new Px.Ex.DealDialog.Page2({viewOnly:this.viewOnly,deal:this.deal,tags:this.tags,messages:this.messages});
this.master.addChild(this.page1);
this.master.addChild(this.page2);
this.master.startup();
this._position();
this._subscribtions.push(dojo.subscribe("dealMaster-selectChild",this,"pageChanged"));
this.connect(this.buttons.next,"onclick","showNextPage");
this.connect(this.buttons.prev,"onclick","showPrevPage");
this.connect(this.buttons.advanced,"onclick","showAdvanced");
if(!this.viewOnly){
this.connect(this.buttons.reset,"onclick","resetPage");
var _7=dojo.hitch(this,function(e){
this.savePage();
});
this.connect(dojo.byId(this.buttons.save1),"onclick",_7);
this.connect(dojo.byId(this.buttons.save2),"onclick",_7);
this.connect(dojo.byId(this.buttons.done),"onclick","onDone");
}
this.firstFocus();
if(!this.viewOnly){
this.startValidating();
}
},startValidating:function(){
this._validationTimer=setInterval(dojo.hitch(this,"validateAndShow"),this.VALIDATION_INTERVAL);
},stopValidating:function(){
clearInterval(this._validationTimer);
},validateAndShow:function(){
var p=this.master.selectedChildWidget,n=0,_8;
if(p===this.page1){
_8=this.isValidArray([this.page1.dealName,this.page1.buyerName]);
if(_8){
++n;
}
this.setProgressItemState(this.DEAL_DETAILS_I,_8?"closed":"opened");
_8=!this.page1.panelDates.open||this.isValidArray([this.page1.dateStart,this.page1.dateEnd]);
if(_8){
++n;
}
this.setProgressItemState(this.DATES_I,_8?(this.page1.panelDates.open?"closed":"default"):"opened");
_8=!this.page1.panelPrices.open||this.isValidArray([this.page1.priceType,this.page1.priceValue]);
if(_8){
++n;
}
this.setProgressItemState(this.PRICING_I,_8?(this.page1.panelPrices.open?"closed":"default"):"opened");
_8=this.isValidArray([this.page1]);
if(_8){
++n;
}
this.page1.showError(!_8);
this.setProgressItemState(this.DEFINE_PIXEL_I,_8?"closed":"opened");
}else{
if(p===this.page2){
_8=this.isValidArray([this.page2.deliveryValue]);
var _9=false;
if(_8){
++n;
var _a=this.page2.deliveryValue.attr("value");
if((typeof _a=="number")&&isNaN(_a)){
_9=true;
}
}
this.setProgressItemState(this.DELIVERY_I,_8?(_9?"default":"closed"):"opened");
var _b=this.page2.getTagsState();
if(_b=="closed"||_b=="default"){
++n;
this.page2.showError(false);
}else{
this.page2.showError(true);
}
this.setProgressItemState(this.SITES_I,_b);
}
}
},showAdvanced:function(){
},createProgressBar:function(w,m){
this.progressBar=new Px.Ex.ProgressBar({width:w,maximum:m,progress:0,style:{display:this.viewOnly?"none":""}}).placeAt(this.indicatorDiv);
},resetPage:function(){
this.clearXhrError();
var p=this.master.selectedChildWidget;
if(p===this.page2){
p.clearAndDisableSearchControl(false);
}else{
if(p===this.page1){
p.page2.allowShowError(false);
}
}
this.resetWidgets(p);
},_getDirtyAttr:function(){
if(this.viewOnly||!this.master){
return false;
}
var p=this.master.selectedChildWidget;
return this.isDirty(p);
},savePage:function(_c){
this.clearXhrError();
if(!this.validateCurrentPage()){
return;
}
if(!this.attr("dirty")){
if(_c){
_c();
}
return;
}
var p=this.master.selectedChildWidget;
var o=this.getValueObject(p);
var _d=null;
var _e=null;
if(p===this.page1){
if(o.start){
o.start=dojo.date.stamp.toISOString(o.start,{zulu:false,milliseconds:false}).slice(0,19);
}
if(o.end){
o.end=dojo.date.stamp.toISOString(o.end,{zulu:false,milliseconds:false}).slice(0,19);
o.end=o.end.replace("00:00:00","23:59:59");
}
o.pixelData=p.getPixelData();
if(o.pixelData){
o.templateCode=null;
}else{
p.page1._templateFieldsBeforeSave=dojo.clone(p.page1.templateFields);
p.page1.updateTemplateFieldData();
_e=p.page1.templateFields;
}
if(!this.deal||!this.deal.dealCode){
o=dojo.mixin({},this.EMPTY_DEAL,o);
this.deal=o;
this.page2.deal=this.deal;
}else{
this._dealBeforeSave=dojo.clone(this.deal);
o=dojo.mixin(this.deal,o);
}
}else{
if(p===this.page2){
o.dealPriority=o.dealPriority?2:1;
o.dealStatus=(o.dealStatus?1:(this._dealWasArchived?3:2));
this._dealBeforeSave=dojo.clone(this.deal);
o=dojo.mixin(this.deal,o);
p.updateTagsData();
if(!o.targetOnAllSites){
_d=this.tags;
}
}
}
if(!o.datesDefined){
o.start=null;
o.end=null;
}
if(this._dealBeforeSave){
o=dojo.clone(o);
dojo.forEach(["start","end"],function(v){
var _f=this._dealBeforeSave[v];
if(_f&&_f instanceof Date){
_f=dojo.date.stamp.toISOString(_f,{zulu:false,milliseconds:false}).slice(0,19);
}
if(o[v]&&_f&&o[v]==_f){
o[v]=null;
}
},this);
}
if(!o.priceDefined){
o.priceTypeCode=null;
o.dealRate=null;
}
if(o.priceTypeCode==1){
o.dealRate=null;
o.rateString="Revshare";
}
this.stopClosing(true);
this.showRotation(true);
this.xhr({url:"/direct-data-deals/edit-deal",content:{deal:dojo.toJson(o),tags:dojo.toJson(_d),templateFields:dojo.toJson(_e)},load:dojo.hitch(this,"dealSaved",_c),error:dojo.hitch(this,"showXhrError"),handleAs:"json"});
},showXhrError:function(_10,_11){
this.showRotation(false);
this.stopClosing(false);
if(this._dealBeforeSave){
this.deal=this._dealBeforeSave;
this.page2.deal=this.deal;
delete this._dealBeforeSave;
}
if(this.page2&&this.page2._tagsBeforeSave){
this.tags=this.pane2._tagsBeforeSave;
this.page2.tags=this.tags;
delete this.pane2._tagsBeforeSave;
}
if(this.page1&&this.page1.page1&&this.page1.page1._templateFieldsBeforeSave){
this.page1.page1.templateFields=this.page1.page1._templateFieldsBeforeSave;
delete this.page1.page1._templateFieldsBeforeSave;
}
this._showErrorMessage(_10,_11);
},_showErrorMessage:function(_12,_13){
var msg=Px.Ex.Application._extractError(_12,_13);
msg=msg.replace(/\<br\>/ig,"&nbsp;");
this.errorDiv.innerHTML=msg;
this._xhrErrorTimer=setTimeout(dojo.hitch(this,"clearXhrError"),5000);
},clearXhrError:function(){
dojo.empty(this.errorDiv);
clearTimeout(this._xhrErrorTimer);
delete this._xhrErrorTimer;
},_updateWidgetsForReset:function(){
var p=this.master.selectedChildWidget;
this.updateWidgetsForReset(p);
if(p===this.page2){
p.makeTagsPanelOpened();
}
},dealSaved:function(_14,_15,_16){
this._dealSaved=true;
this.showRotation(false);
this.stopClosing(false);
var _17=false;
if(_15.dealCode!==undefined){
if(!_15.dealCode){
_17=true;
_15=_15.dealResult;
this._showErrorMessage(_15,_16);
this.deal=this._dealBeforeSave;
this.page2.deal=this.deal;
this.page1.page1.templateFields=this.page1.page1._templateFieldsBeforeSave;
this.page1.page1.updateTemplateFields();
}
if(_15.dealCode&&this.deal){
this.deal.dealCode=_15.dealCode;
var tfr=_15.templateFieldsResult;
if(tfr){
if(tfr["return"]){
tfr=tfr["return"];
}
if(!tfr.success){
_17=true;
this._showErrorMessage(_15,_16);
this.page1.page1.templateFields=this.page1.page1._templateFieldsBeforeSave;
this.page1.page1.updateTemplateFields();
}
}
this._updateWidgetsForReset();
}
if(_15.tags){
this.tags=_15.tags;
this.page2.deal=this.deal;
this.page2.tags=this.tags;
this.page1.page1.deal=this.deal;
}
}else{
var msg;
var d=_15;
_15=d["dealResult"];
if(_15["return"]){
_15=_15["return"];
}
if(!_15.success){
_17=true;
this._showErrorMessage(_15,_16);
this.deal=this._dealBeforeSave;
this.page2.deal=this.deal;
this.tags=this.pane2._tagsBeforeSave;
this.page2.tags=this.tags;
this.page2.updateTagListAndCheckboxes();
this.page1.page1.deal=this.deal;
}
if(_15.success){
this._savedDealStatus=this.deal.dealStatus;
var p=this.master.selectedChildWidget;
_15=d["tagsResult"];
if(_15){
if(_15["return"]){
_15=_15["return"];
}
if(!_15.success){
_17=true;
this._showErrorMessage(_15,_16);
this.tags=this.pane2._tagsBeforeSave;
this.page2.tags=this.tags;
this.page2.updateTagListAndCheckboxes();
}
}
_15=d["templateFieldsResult"];
if(_15){
if(_15["return"]){
_15=_15["return"];
}
if(!_15.success){
_17=true;
this._showErrorMessage(_15,_16);
this.page1.page1.templateFields=this.page1.page1._templateFieldsBeforeSave;
this.page1.page1.updateTemplateFields();
}
}
this._updateWidgetsForReset();
this.page2.updateTagListAndCheckboxes();
}
}
delete this._dealBeforeSave;
try{
delete this.page2._tagsBeforeSave;
}
catch(e){
}
try{
delete this.page1.page1._templateFieldsBeforeSave;
}
catch(e){
}
if(!_17&&_14){
_14();
}
},onDone:function(){
this.savePage(dojo.hitch(this,function(){
this.onExecute();
}));
},validateCurrentPage:function(){
this.validateAndShow();
var p=this.master.selectedChildWidget;
if(p===this.page1){
if(!this.validateWidgets(p)){
return false;
}
if(p._selectedTab==2){
p.page2.validatePastePixel();
}
var lst=this.PROGRESS_LIST;
return lst[this.DEAL_DETAILS_I].progress+lst[this.DATES_I].progress+lst[this.PRICING_I].progress+lst[this.DEFINE_PIXEL_I].progress==4;
}else{
if(p===this.page2){
if(!this.validateWidgets(p)){
return false;
}
var lst=this.PROGRESS_LIST;
return lst[this.DEAL_DETAILS_I].progress+lst[this.DATES_I].progress+lst[this.PRICING_I].progress+lst[this.DEFINE_PIXEL_I].progress+lst[this.DELIVERY_I].progress+lst[this.SITES_I].progress==6;
}
}
return false;
},showNextPage:function(e){
this.clearXhrError();
if(!this._lastPage){
if(this.viewOnly){
this.master.forward();
}else{
this.savePage(dojo.hitch(this,function(){
this.master.forward();
}));
}
}
},showPrevPage:function(e){
this.clearXhrError();
if(!this._firstPage){
if(this.viewOnly){
this.master.back();
}else{
this.savePage(dojo.hitch(this,function(){
this.master.back();
}));
}
}
},setProgressItemState:function(i,_18){
var _19=this.PROGRESS_LIST[i];
if(!_19){
return;
}
var div=this.PROGRESS_LIST[i].div;
if(dojo.hasClass(div,_18)){
return;
}
dojo.removeClass(div,"closed");
dojo.removeClass(div,"opened");
dojo.removeClass(div,"default");
dojo.addClass(div,_18);
if(_18=="opened"){
_19.progress=0;
}else{
_19.progress=1;
}
this.showProgress();
},showProgress:function(){
var p=0;
dojo.forEach(this.PROGRESS_LIST,function(v){
p+=v.progress;
});
this.progressBar.showProgress(p);
},pageChanged:function(_1a){
this._lastPage=(_1a===this.page2);
this._firstPage=(_1a===this.page1);
if(_1a===this.page2){
if(!this.viewOnly){
dojo.forEach([this.buttons.done_disabled,this.buttons.save1],function(v){
dojo.style(v,"display","none");
});
dojo.forEach([this.buttons.done,this.buttons.save2],function(v){
dojo.style(v,"display","");
});
dojo.forEach([this.buttons.advanced],function(v){
dojo.style(v,"visibility","visible");
});
}else{
dojo.forEach([this.buttons.advanced],function(v){
dojo.style(v,"display","");
});
}
dojo.forEach([this.buttons.next],function(v){
dojo.style(v,"display","none");
});
dojo.forEach([this.buttons.prev],function(v){
dojo.style(v,"display","");
});
if(!this.__page2created){
_1a.createContent();
_1a.prepareTagsTable();
this.__page2created=true;
dijit.byId("page2dealStatusId").focus();
}
}else{
if(_1a===this.page1){
if(!this.viewOnly){
dojo.forEach([this.buttons.save1],function(v){
dojo.style(v,"display","");
});
dojo.forEach([this.buttons.save2],function(v){
dojo.style(v,"display","none");
});
dojo.forEach([this.buttons.advanced],function(v){
dojo.style(v,"visibility","hidden");
});
}else{
dojo.forEach([this.buttons.advanced],function(v){
dojo.style(v,"display","none");
});
}
dojo.forEach([this.buttons.next],function(v){
dojo.style(v,"display","");
});
dojo.forEach([this.buttons.prev],function(v){
dojo.style(v,"display","none");
});
}
}
},beforeDestroy:function(){
if(this._dealSaved&&this.closeCallback){
if(isDefined(this.dealCode)&&(this.dealCode>0)){
theDealCode=this.dealCode;
}else{
if(isDefined(this.deal.dealCode)&&(this.deal.dealCode>0)){
theDealCode=this.deal.dealCode;
}
}
this.closeCallback(this._dealWasArchived,this.previousDealStatus,this._savedDealStatus,theDealCode);
}
},destroy:function(){
this.stopValidating();
this.cancelXhr();
dojo.forEach(this._subscribtions,dojo.unsubscribe,this);
dojo.forEach(this._connections,dojo.disconnect,this);
this.clearXhrError();
this.inherited(arguments);
}});
dojo.declare("Px.Ex.DealDialog.Page1",[dijit.layout.ContentPane],{CPM_ID:3,MONTHLY_ID:2,REVSHARE_ID:1,PRICE_TYPE_DATA:undefined,BUYERS_DATA:undefined,TEMPLATES_DATA:undefined,NOW:undefined,viewOnly:false,deal:undefined,messages:undefined,xhr:undefined,stopClosing:undefined,showRotation:undefined,_restoreKeys:undefined,_clearKeys:undefined,isDirty:undefined,resetWidgets:undefined,_connections:[],constructor:function(){
this.PRICE_TYPE_DATA={identifier:"id",label:"name",items:[{id:this.CPM_ID,name:"CPM"},{id:this.MONTHLY_ID,name:"Monthly"},{id:this.REVSHARE_ID,name:"Revshare"}]};
this._resetValue=2;
},startup:function(){
this.inherited(arguments);
this.createContent();
},createContent:function(){
var m=this.messages;
var _1b,div,_1c,_1d,tr,td,c=dojo.create;
_1b=c("div",{className:"page1-container"});
this.attr("content",_1b);
_1c=c("table",{style:{width:"100%",borderCollapse:"collapse"}},_1b);
_1d=c("tbody",{},_1c);
tr=c("tr",{},_1d);
td=c("td",{},tr);
c("label",{className:"label-bold",innerHTML:m.dealName||"Deal Name","for":"page1dealNameId"},td);
td=c("td",{},tr);
c("label",{className:"label-bold",innerHTML:m.buyerName||"Buyer Name","for":"page1buyerNameId"},td);
tr=c("tr",{},_1d);
td=c("td",{},tr);
removeWidget("page1dealNameId");
this.dealName=new Px.Ex.ValidationTextBox({id:"page1dealNameId",name:"dealName",required:!this.viewOnly,trim:true,readOnly:this.viewOnly,value:this.deal?this.deal.dealName:"",invalidMessage:m.invalidDealName||"$_unset_$",emptyMessage:m.emptyDealName||"$_unset_$",promptMessage:m.promptDealName||""});
this.dealName.placeAt(td);
td=c("td",{},tr);
this.buyersStore=new dojo.data.ItemFileReadStore({data:this.BUYERS_DATA});
removeWidget("page1buyerNameId");
this.buyerName=new Px.Ex.FilteringSelect({store:this.buyersStore,id:"page1buyerNameId",name:"buyerCode",searchAttr:"buyerName",required:!this.viewOnly,trim:true,readOnly:this.viewOnly,value:this.deal?this.deal.buyerCode:null,invalidMessage:m.invalidBuyerName||"$_unset_$",emptyMessage:m.emptyBuyerName||"$_unset_$",promptMessage:m.promptBuyerName||""});
this.buyerName.placeAt(td);
var _1e=dojo.hitch(this.buyerName.reset);
this.buyerName.reset=dojo.hitch(this,function(){
this._doNotConfirm=true;
_1e.call(this.buyerName);
delete this._doNotConfirm;
});
this._oldBuyerCode=this.buyerName.attr("value");
this.connect(this.buyerName,"onChange",function(val){
if(val==this._oldBuyerCode){
return;
}
if(!this._doNotConfirm&&this._selectedTab==1&&this.page1._is_need_confirmation()){
this._clearKeys();
var _1f={message:m.confirmChangeBuyer||"Changing the buyer will discard buyer templates data. Proceed anyway?",okCallback:dojo.hitch(this,function(){
this._restoreKeys();
this.page1._resetStore();
this._oldBuyerCode=val;
}),cancelCallback:dojo.hitch(this,function(){
this._restoreKeys();
this.buyerName.attr("value",this._oldBuyerCode);
})};
var d=new Px.Ex.MessageDialog(_1f);
d.show();
}else{
this.page1._resetStore();
this._oldBuyerCode=val;
}
});
tr=c("tr",{},_1d);
td=c("td",{style:{verticalAlign:"top"}},tr);
var _20=this.deal?this.deal.datesDefined:false;
removeWidget("page1TitlePaneDates");
var _21=this.panelDates=new Px.Ex.TitlePane({title:m.setDates||"Set Dates",open:_20,content:this.createDates(_20),id:"page1TitlePaneDates",name:"datesDefined","class":"dates-title-pane",readOnly:this.viewOnly});
_21.placeAt(td);
td=c("td",{style:{verticalAlign:"top"}},tr);
var _22=this.deal?this.deal.priceDefined:false;
removeWidget("page1TitlePanePrice");
var _23=this.panelPrices=new Px.Ex.TitlePane({title:m.setPricing||"Set Pricing",open:_22,content:this.createPricing(_22),id:"page1TitlePanePrice",name:"priceDefined","class":"pricing-title-pane",readOnly:this.viewOnly});
_23.placeAt(td);
this.connect(_21,"toggle",dojo.hitch(this,function(){
var _24=dijit.byId("page1TitlePanePrice");
var _25=dijit.byId("page1TitlePaneDates");
if(!_25.open&&!_24.open){
setTimeout(dojo.hitch(this.page1,"reduceHeight",false),250);
setTimeout(dojo.hitch(this.page2,"reduceHeight",false),250);
}else{
if(_25.open){
this.page1.reduceHeight(true);
this.page2.reduceHeight(true);
}
}
var _26=dijit.byId("page1startDateId");
_26.attr("required",_25.open);
if(!_25.open&&!_26.attr("disabled")&&!_26.attr("readOnly")&&!_26.isValid()){
_26.attr("value",this.NOW);
}
_26._hasBeenBlurred=true;
_26.validate();
var _27=dijit.byId("page1endDateId");
if(!_25.open&&!_27.attr("disabled")&&!_27.attr("readOnly")&&!_27.isValid()){
_27.attr("value",null);
}
_27._hasBeenBlurred=true;
_27.validate();
}));
this.connect(_23,"toggle",dojo.hitch(this,function(){
var _28=dijit.byId("page1TitlePaneDates");
var _29=dijit.byId("page1TitlePanePrice");
if(!_29.open&&!_28.open){
setTimeout(dojo.hitch(this.page1,"reduceHeight",false),100);
setTimeout(dojo.hitch(this.page2,"reduceHeight",false),100);
}else{
if(_29.open){
this.page1.reduceHeight(true);
this.page2.reduceHeight(true);
}
}
var _2a=dijit.byId("page1priceTypeId");
_2a.attr("required",_29.open);
if(!_29.open&&!_2a.attr("disabled")&&!_2a.attr("readOnly")&&!_2a.isValid()){
_2a.attr("value",null);
}
_2a._hasBeenBlurred=true;
_2a.validate();
var _2b=dijit.byId("page1priceId");
_2b.attr("required",_29.open);
if(!_29.open&&!_2b.attr("disabled")&&!_2b.attr("readOnly")&&!_2b.isValid()){
_2b.attr("value",null);
}
_2b._hasBeenBlurred=true;
_2b.validate();
}));
var s=m.definePixelTitle||"Define your data deal pixel by using a template or by pasting the pixel directly";
c("div",{className:"label-bold define-pixel-title",innerHTML:s},_1b);
this.createInnerTabs(_1b);
if(!_21.open&&!_23.open){
this.page1.reduceHeight(false);
this.page2.reduceHeight(false);
}
return _1b;
},createDates:function(_2c){
var m=this.messages;
var _2d,_2e,tr,td,c=dojo.create;
_2d=c("table",{className:"teble-dates"});
_2e=c("tbody",{},_2d);
tr=c("tr",{},_2e);
td=c("td",{style:{width:"100%"}},tr);
c("label",{innerHTML:m.startDate||"Start Date",className:"label","for":"page1startDateId"},td);
td=c("td",{},tr);
removeWidget("page1startDateId");
var _2f=this.dateStart=new Px.Ex.DateTextBoxWithIcon({required:!this.viewOnly,value:this.deal?this.deal.start:this.NOW,readOnly:this.viewOnly,disabled:!!(this.deal&&this.deal.dealCode&&this.deal.start&&(this.deal.start<this.NOW)),constraints:this.viewOnly?{}:{min:this.NOW},invalidMessage:m.invalidStart||"$_unset_$",emptyMessage:m.emptyStart||"$_unset_$",promptMessage:m.promptStart||"","class":"start-date",name:"start",id:"page1startDateId"});
_2f.placeAt(td);
_2f.startup();
if(!_2c){
_2f.attr("required",false);
}
tr=c("tr",{},_2e);
td=c("td",{style:{width:"100%"}},tr);
c("label",{innerHTML:m.endDate||"End Date",className:"label","for":"page1endDateId"},td);
td=c("td",{},tr);
var fn=function(){
var d=_2f.attr("value");
if(!d){
d=this.NOW;
}
return d;
};
removeWidget("page1endDateId");
var _30=this.dateEnd=new Px.Ex.CustomizedDateTextBox({required:false,getEmptyDate:fn,value:this.deal?this.deal.end:null,readOnly:this.viewOnly,constraints:this.viewOnly?{}:{min:this.deal?this.deal.start:this.NOW},invalidMessage:m.invalidEnd||"$_unset_$",emptyMessage:m.emptyEnd||"$_unset_$",promptMessage:m.promptEnd||"","class":"end-date",name:"end",id:"page1endDateId"});
_30.placeAt(td);
_30.startup();
_2f.onChange=function(val){
_30.constraints.min=val;
_30.validate();
};
return _2d;
},createPricing:function(_31){
var m=this.messages;
var _32,_33,tr,td,c=dojo.create;
_32=c("table",{className:"teble-pricing"});
_33=c("tbody",{},_32);
tr=c("tr",{},_33);
td=c("td",{style:{width:"100%"}},tr);
c("label",{innerHTML:m.type||"Type",className:"label","for":"page1priceTypeId"},td);
td=c("td",{},tr);
this.priceTypeStore=new dojo.data.ItemFileReadStore({data:this.PRICE_TYPE_DATA});
removeWidget("page1priceTypeId");
this.priceType=new Px.Ex.FilteringSelect({store:this.priceTypeStore,required:!this.viewOnly,value:this.deal?this.deal.priceTypeCode:null,readOnly:this.viewOnly,invalidMessage:m.invalidPriceType||"$_unset_$",emptyMessage:m.emptyPriceType||"$_unset_$",promptMessage:m.promptPriceType||"","class":"price-type",searchAttr:"name",id:"page1priceTypeId",name:"priceTypeCode"});
this.priceType.placeAt(td);
this.priceType.startup();
if(!_31){
this.priceType.attr("required",false);
}
this.connect(this.priceType,"onChange",function(v){
var _34=dijit.byId("page1priceId");
var dis=(v==this.REVSHARE_ID);
if(dis){
_34.attr("value",null);
}
_34.attr("disabled",dis);
});
tr=c("tr",{},_33);
td=c("td",{style:{width:"100%"}},tr);
c("label",{innerHTML:m.price||"Price ($)",className:"label","for":"page1priceId"},td);
td=c("td",{},tr);
removeWidget("page1priceId");
this.priceValue=new Px.Ex.NumberTextBox({intermediateChanges:true,"class":"price",required:!this.viewOnly,value:this.deal?this.deal.dealRate:null,readOnly:this.viewOnly,invalidMessage:m.invalidDealRate||"$_unset_$",emptyMessage:m.emptyDealRate||"$_unset_$",promptMessage:m.promptDealRate||"",id:"page1priceId",name:"dealRate",constraints:this.viewOnly?{pattern:"#,###,###,###,##0.######"}:{min:0,pattern:"#,###,###,###,##0.######"}});
this.priceValue.placeAt(td);
this.priceValue.startup();
if(!_31){
this.priceValue.attr("required",false);
}
if(this.deal&&(this.deal.priceTypeCode==this.REVSHARE_ID)){
this.priceValue.attr("disabled",true);
}
return _32;
},createTabButton2:function(_35){
var m=this.messages;
var fn=dojo.hitch(this,function(){
if(this._selectedTab==2){
return;
}
if(!this.getTemplateCode()){
this.selectTab2();
return;
}
this._clearKeys();
var _36={message:m.toPastePixel||"Switching to Paste Pixel tab will discard any data entered in this tab. Switch anyway?",okCallback:dojo.hitch(this,function(){
this._restoreKeys();
this.selectTab2();
}),cancelCallback:dojo.hitch(this,"_restoreKeys")};
var d=new Px.Ex.MessageDialog(_36);
d.show();
});
this.createTabButton("page1_btn_tab2_id",m.pastePixel||"Paste Pixel",_35,"btn_tab2",fn);
if(_35){
this._selectedTab=2;
}
},createTabButton1:function(_37,_38){
var m=this.messages;
var fn=dojo.hitch(this,function(){
if(this._selectedTab==1){
return;
}
if(!this.getPixelData().length){
this.selectTab1();
return;
}
this._clearKeys();
var _39={message:m.toUseTemplate||"Switching to Use Template tab will discard any data entered in this tab. Switch anyway?",okCallback:dojo.hitch(this,function(){
this._restoreKeys();
this.selectTab1();
}),cancelCallback:dojo.hitch(this,"_restoreKeys")};
var d=new Px.Ex.MessageDialog(_39);
d.show();
});
this.createTabButton("page1_btn_tab1_id",m.useTemplate||"Use Template",_37,"btn_tab1",fn,_38);
if(_37){
this._selectedTab=1;
}
},selectTab1:function(){
if(this._selectedTab==1){
return;
}
this.page2.clear();
this.createTabButton2(false);
this.createTabButton1(true);
this.tabs.selectChild(this.page1);
this.page2.pastePixelValid=false;
this.page1.requireTemplate(true);
},selectTab2:function(){
if(this._selectedTab==2){
return;
}
this.page1.clear();
this.createTabButton1(false,!(this.TEMPLATES_DATA&&this.TEMPLATES_DATA.items&&this.TEMPLATES_DATA.items.length));
this.createTabButton2(true);
this.tabs.selectChild(this.page2);
this.page1.requireTemplate(false);
},_selectTab1:function(){
return this.TEMPLATES_DATA&&this.TEMPLATES_DATA.items&&this.TEMPLATES_DATA.items.length&&this.deal&&this.deal.templateCode;
},createInnerTabs:function(_3a){
var _3b,_3c,tr,td,div,c=dojo.create;
this._selectedColor=dojo.getComputedStyle(dojo.query(".texi-logo-text")[0]).color;
_3b=c("table",{style:{borderCollapse:"collapse"}},_3a);
_3c=c("tbody",{},_3b);
tr=c("tr",{},_3c);
td=c("td",{},tr);
c("div",{id:"page1_btn_tab1_id",className:"btn-tab1"},td);
td=c("td",{},tr);
c("div",{id:"page1_btn_tab2_id",className:"btn-tab2"},td);
div=c("div",{className:"page1-tabs-spacer-v"},_3a);
this.errorDiv=c("div",{className:"editor-error-icon texi-hidden"},div);
this.connect(this.errorDiv,"onmouseenter","showErrorTooltip");
this.connect(this.errorDiv,"onmouseleave","hideErrorTooltip");
removeWidget("page1tabs");
this.tabs=new dijit.layout.StackContainer({id:"page1tabs"}).placeAt(_3a);
if(this._selectTab1()){
if(this.deal){
this.deal.pixelData="";
}
}else{
if(this.deal){
this.deal.templateCode=null;
}
}
this.page1=new Px.Ex.DealDialog.Page1Page1({parentContainer:this.tabs,TEMPLATES_DATA:this.TEMPLATES_DATA,buyerCtrl:this.buyerName,viewOnly:this.viewOnly,deal:this.deal,messages:this.messages,xhr:this.xhr,stopClosing:this.stopClosing,showRotation:this.showRotation});
this.page2=new Px.Ex.DealDialog.Page1Page2({parentContainer:this.tabs,viewOnly:this.viewOnly,deal:this.deal,messages:this.messages,showError:dojo.hitch(this,"showError"),allowShowError:dojo.hitch(this,"allowShowError")});
this.tabs.addChild(this.page1);
this.tabs.addChild(this.page2);
this.tabs.startup();
if(this._selectTab1()){
this.selectTab1();
}else{
this.selectTab2();
}
this._resetValue=this._selectedTab;
},detectIEVersion:function(){
var _3d={init:function(){
this.browser=this.searchString(this.dataBrowser)||"An unknown browser";
this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";
this.OS=this.searchString(this.dataOS)||"an unknown OS";
},searchString:function(_3e){
for(var i=0;i<_3e.length;i++){
var _3f=_3e[i].string;
var _40=_3e[i].prop;
this.versionSearchString=_3e[i].versionSearch||_3e[i].identity;
if(_3f){
if(_3f.indexOf(_3e[i].subString)!=-1){
return _3e[i].identity;
}
}else{
if(_40){
return _3e[i].identity;
}
}
}
},searchVersion:function(_41){
var _42=_41.indexOf(this.versionSearchString);
if(_42==-1){
return;
}
return parseFloat(_41.substring(_42+this.versionSearchString.length+1));
},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};
_3d.init();
return _3d.version;
},createTabButton:function(_43,_44,_45,key,_46,_47){
if(dojo.isIE){
if((this.detectIEVersion()==7)||(this.detectIEVersion()==8)){
switch(_44){
case "Paste Pixel":
if(_45){
dojo.toggleClass(dojo.byId(_43),"PastePixelOn",true);
dojo.toggleClass(dojo.byId(_43),"PastePixelOff",false);
}else{
dojo.toggleClass(dojo.byId(_43),"PastePixelOn",false);
dojo.toggleClass(dojo.byId(_43),"PastePixelOff",true);
}
break;
case "Use Template":
if(_45){
dojo.toggleClass(dojo.byId(_43),"UseTemplateOn",true);
dojo.toggleClass(dojo.byId(_43),"UseTemplateOff",false);
}else{
dojo.toggleClass(dojo.byId(_43),"UseTemplateOn",false);
dojo.toggleClass(dojo.byId(_43),"UseTemplateOff",true);
}
break;
}
if(!this.viewOnly&&!_47){
this._connections.push(dojo.connect(dojo.byId(_43),"onclick",dojo.hitch(this,_46)));
}
if(!_47){
dojo.style(dojo.byId(_43),"cursor","pointer");
}
return;
}
}
var _48="12px",H=20,W=100;
var h=H;
var _49=_45?this._selectedColor||"green":"white";
var _4a=_45?_49:(_47?"#C0C0C0":"#D7E5F2");
var _4b=_45?"white":(_47?"#C0C0C0":"gray");
var _4c=_45?"bold":"normal";
var w=W;
if(this[key]){
this[key].destroy();
}
var _4d=this[key]=dojox.gfx.createSurface(_43,w,h);
var t=_4d.createText({x:0,y:0,text:_44,align:"middle"});
t.setFont({family:"Arial",size:_48,weight:_4c,rotated:false});
var tw=t.getTextWidth();
_4d.remove(t);
var _4e=20;
if(tw+_4e>w){
w=tw+_4e;
_4d.setDimensions(w,h);
}
var _4f=_4d.createPath("");
var r=8;
var _50=_45?0:2;
_4f.moveTo(w-1,h).vLineTo(r+1+_50).arcTo(r,r,0,false,false,w-r-1,1+_50).hLineTo(r+1).arcTo(r,r,0,false,false,1,r+1+_50).vLineTo(h).closePath();
_4f.setFill(_49).setStroke(_4a);
var c={x:parseInt(w/2),y:parseInt(h/2)};
var t=_4d.createText({x:c.x,y:c.y+6,text:_44,align:"middle"});
t.setFill(_4b);
t.setFont({family:"Arial",size:_48,weight:_4c,rotated:false});
if(!this.viewOnly&&!_47){
_4d.connect("onclick",dojo.hitch(this,_46));
}
if(dojox.gfx.renderer=="silverlight"){
_4d.rawNode["Cursor"]="Hand";
}else{
dojo.style(_4d.rawNode,"cursor","pointer");
}
},_getValueAttr:function(){
return this._selectedTab;
},reset:function(){
this["selectTab"+this._resetValue]();
},getPixelData:function(){
if(this._selectedTab!=2){
return null;
}
return dojo.trim(this.page2.attr("value"));
},getTemplateCode:function(){
if(this._selectedTab!=1){
return null;
}
return this.page1.getTemplateCode();
},isValid:function(){
if(this.viewOnly){
return true;
}
var p=this["page"+this._selectedTab];
return p?p.isValid():true;
},showErrorTooltip:function(){
dijit.showTooltip(this.getErrorMessage(),this.errorDiv);
},hideErrorTooltip:function(){
dijit.hideTooltip(this.errorDiv);
},allowShowError:function(_51){
_51?this._allowShowError=true:delete this._allowShowError;
},showError:function(_52){
if(this.viewOnly||!this.errorDiv){
return;
}
if(_52&&(this._selectedTab==1||!this._allowShowError)){
this.showError(false);
return;
}
dojo.toggleClass(this.errorDiv,"texi-hidden",!_52);
},getErrorMessage:function(){
var p=this["page"+this._selectedTab];
return p?p.getErrorMessage():"";
},destroy:function(){
this.hideErrorTooltip();
dojo.forEach(this._connections,dojo.disconnect,this);
dojo.forEach(["btn_tab1","btn_tab2"],function(v){
try{
if(this[v]){
this[v].destroy();
}
}
catch(e){
}
},this);
this.inherited(arguments);
}});
dojo.declare("Px.Ex.DealDialog.Page1Page1",[dijit.layout.ContentPane],{parentContainer:undefined,TEMPLATES_DATA:undefined,buyerCtrl:undefined,viewOnly:false,deal:undefined,messages:undefined,xhr:undefined,stopClosing:undefined,showRotation:undefined,templateFields:undefined,EXELATE_BUYER_ID:1,startup:function(){
this.inherited(arguments);
this.createContent();
},createContent:function(){
var m=this.messages;
var c=dojo.create;
var _53=c("div",{className:"use-template-container"});
this.attr("content",_53);
var div=c("div",{},_53);
c("label",{className:"label",innerHTML:m.chooseTemplate||"Choose Template:","for":"page1page1templateNameId"},div);
var _54=this._getStoreData();
this.templatesStore=new dojo.data.ItemFileReadStore({data:_54,clearOnClose:true});
removeWidget("page1page1templateNameId");
this.templateName=new Px.Ex.FilteringSelect({store:this.templatesStore,id:"page1page1templateNameId",name:"templateCode",searchAttr:"pixelTemplateName",onChange:dojo.hitch(this,"templateChanged"),required:!this.viewOnly,value:this.deal?this.deal.templateCode:null,readOnly:this.viewOnly,invalidMessage:m.invalidTemplateName||"$_unset_$",emptyMessage:m.emptyTemplateName||"$_unset_$",promptMessage:m.promptTemplateName||""});
this.templateName.startup();
this.templateName.attr("required",false);
this.templateName.placeAt(div);
this.templateFieldsDiv=c("div",{className:"template-fields-container reduced"},_53);
if(this.deal&&this.deal.templateCode){
this.templateChanged(this.deal.templateCode);
}
},_getStoreData:function(){
if(this.TEMPLATES_DATA&&this.TEMPLATES_DATA.items){
var _55=this.buyerCtrl.attr("value");
var _56=this.EXELATE_BUYER_ID;
var _57=dojo.clone(dojo.filter(this.TEMPLATES_DATA.items,function(v){
return v.buyerCode==_56||(_55&&v.buyerCode==_55);
}));
}else{
var _57=[];
}
return {identifier:"pixelTemplateCode",label:"pixelTemplateName",items:_57};
},_is_need_confirmation:function(){
var _58=this.templatesStore._getItemByIdentity(this.templateName.attr("value"));
if(_58){
var _59=this.templatesStore.getValue(_58,"buyerCode");
return _59&&(_59!=this.EXELATE_BUYER_ID);
}
return false;
},_resetStore:function(){
var _5a=this.templatesStore._getItemByIdentity(this.templateName.attr("value"));
var val=null;
if(_5a){
if(this.templatesStore.getValue(_5a,"buyerCode")==this.EXELATE_BUYER_ID){
val=this.templatesStore.getIdentity(_5a);
}
}
var _5b=this._getStoreData();
var _5c=this.templatesStore;
_5c.close();
_5c._jsonData=_5b;
this.templateName.attr("value",val);
},isValid:function(){
return this.viewOnly||this.templateName.isValid();
},reduceHeight:function(_5d){
dojo.toggleClass(this.templateFieldsDiv,"reduced",_5d);
},templateChanged:function(val){
this.showTemplateFields(val);
},showTemplateFields:function(_5e){
this.clearTemplateFieldsTable();
if(typeof _5e=="number"){
this.stopClosing(true);
this.showRotation(true);
this.xhr({url:"/direct-data-deals/template-fields",handleAs:"json",content:{templateCode:_5e,dealCode:this.deal?this.deal.dealCode:null},load:dojo.hitch(this,"loadTemplateFields"),error:dojo.hitch(this,"loadTemplateFieldsError")});
}
},loadTemplateFields:function(_5f){
this.stopClosing(false);
this.showRotation(false);
if(_5f!="no fields"){
this.templateFields=_5f;
this.makeTemplateFieldsTable();
}else{
this.templateFields=[];
}
},loadTemplateFieldsError:function(_60){
this.stopClosing(false);
this.showRotation(false);
this.templateFieldsDiv.innerHTML=_60.message;
},_getTFId:function(_61){
return "templateField"+_61.fieldCode+"Id";
},clearTemplateFieldsTable:function(){
var _62=this.templateFieldsDiv;
dojo.forEach(this.templateFields,function(v){
var id=this._getTFId(v);
var d=dijit.byId(id);
if(d){
d.destroyRecursive();
}
},this);
this.templateFields=[];
dojo.empty(_62);
},updateTemplateFieldData:function(){
dojo.forEach(this.templateFields,function(v){
var id=this._getTFId(v);
var d=dijit.byId(id);
if(d){
v.fieldValue=d.attr("value");
}
},this);
},updateTemplateFields:function(){
dojo.forEach(this.templateFields,function(v){
var id=this._getTFId(v);
var d=dijit.byId(id);
if(d){
d.attr("value",v.fieldValue);
}
},this);
},makeTemplateFieldsTable:function(){
var _63=this.templateFieldsDiv;
var _64,_65,tr,td,c=dojo.create;
_64=c("table",{},_63);
_65=c("tbody",{},_64);
dojo.forEach(this.templateFields,function(v,i){
if(i%2==0){
tr=c("tr",{},_65);
}
var id=this._getTFId(v);
td=c("td",{},tr);
c("label",{innerHTML:v.fieldName,"for":id,className:"label template-field-label"},td);
td=c("td",{},tr);
removeWidget(id);
var t=new dijit.form.TextBox({id:id,value:v.fieldValue,style:{width:"100px"},readOnly:this.viewOnly,trim:true});
t.startup();
t.placeAt(td);
td=c("td",{className:"template-field-spacer"},tr);
},this);
},requireTemplate:function(_66){
if(this.viewOnly){
return;
}
var _67=dijit.byId("page1page1templateNameId");
_67.attr("required",_66);
_67._hasBeenBlurred=true;
_67.validate();
},getTemplateCode:function(){
return this.templateName.attr("value");
},clear:function(){
this.templateName.attr("value",null);
}});
dojo.declare("Px.Ex.DealDialog.Page1Page2",[dijit.layout.ContentPane,Px.Ex.EmptyMessageMixin],{pastePixelValid:false,invalidMessage:"The value entered is not valid",emptyMessage:"The value can not be empty",viewOnly:false,deal:undefined,messages:undefined,initialCode:"",showError:undefined,allowShowError:undefined,startup:function(){
this.inherited(arguments);
this.invalidMessage=this.messages.invalidPastePixel||this.invalidMessage;
this.emptyMessage=this.messages.emptyPastePixel||this.emptyMessage;
if(this.deal){
this.initialCode=this.deal.pixelData;
}
this._resetValue=this.initialCode;
this.createContent();
},createContent:function(){
var c=dojo.create;
var _68=c("div",{});
this.attr("content",_68);
var div=this.editorContainerDiv=c("div",{className:"editor-container reduced"},_68);
var _69=this._editor=new CodeMirror(div,{readOnly:this.viewOnly,path:"/codemirror/js/",parserfile:["parsexml.js","parsecss.js","tokenizejavascript.js","parsejavascript.js","parsehtmlmixed.js"],stylesheet:["/codemirror/css/xmlcolors.css","/codemirror/css/jscolors.css","/codemirror/css/csscolors.css"],width:"100%",height:"100%",content:this.initialCode,initCallback:dojo.hitch(this,function(){
if(dojo.isIE){
this.connect(this._editor.frame,"onblur","onEditorBlur");
this.connect(this._editor.frame,"onfocus",dojo.hitch(this,function(e){
this._editor.focus();
}));
}else{
if(dojo.isChrome){
this.connect(this._editor.frame.contentDocument.documentElement,"onblur","onEditorBlur");
}else{
this.connect(this._editor.frame.contentDocument,"onblur","onEditorBlur");
}
}
if(!dojo.isFF&&this.initialCode==""){
this._editor.setCode("");
}
})});
div=c("div",{style:{textAlign:"center"}},_68);
table=c("table",{style:{borderCollapse:"collapse",margin:"auto"}},div);
tbody=c("tbody",{},table);
tr=c("tr",{},tbody);
if(dojo.isIE){
td=c("td",{},tr);
div=c("div",{className:"btn-paste"},td);
this.connect(div,"onclick",dojo.hitch(this,function(){
var s=window.clipboardData.getData("Text");
try{
_69.replaceSelection(s);
}
catch(e){
}
}));
}
td=c("td",{},tr);
div=c("div",{className:"btn-validate"},td);
this.connect(div,"onclick","validatePastePixel");
},onEditorBlur:function(){
if(!this.viewOnly&&this.allowShowError){
this.allowShowError(true);
}
},reduceHeight:function(_6a){
dojo.toggleClass(this.editorContainerDiv,"reduced",_6a);
},validatePastePixel:function(){
if(this.viewOnly){
return;
}
this.isValid();
if(!this.pastePixelValid){
if(this.allowShowError){
this.allowShowError(true);
}
if(this.showError){
this.showError(true);
}
}
},_getValueAttr:function(){
try{
return dojo.trim(this._editor.getCode());
}
catch(e){
}
return "";
},isValid:function(){
var s="";
try{
var s=this._editor.getCode();
}
catch(e){
}
s=dojo.trim(s);
this.pastePixelValid=this.viewOnly||(s!="");
return this.pastePixelValid;
},reset:function(){
try{
if(dojo.isFF&&this._resetValue==""){
this._editor.setCode(" ");
this._editor.selectLines(null,0);
}else{
this._editor.setCode(this._resetValue);
}
}
catch(e){
}
},clear:function(){
try{
if(dojo.isFF){
this._editor.setCode(" ");
this._editor.selectLines(null,0);
}else{
this._editor.setCode("");
}
}
catch(e){
}
}});
dojo.declare("Px.Ex.DealDialog.Page2",[dijit.layout.ContentPane],{viewOnly:false,deal:undefined,messages:undefined,noneTagsSelected:"At least one tag must be selected",tags:[],startup:function(){
this.inherited(arguments);
},createContent:function(){
var m=this.messages;
if(m.noneTagsSelected){
this.noneTagsSelected=m.noneTagsSelected;
}
var _6b,_6c,tr,td,_6d,div,c=dojo.create;
var _6e=c("div",{className:"page2-container"});
this.attr("content",_6e);
_6b=c("table",{style:{width:"100%"},borderCollapse:"collapse"},_6e);
_6c=c("tbody",{},_6b);
tr=c("tr",{},_6c);
td=c("td",{colSpan:2},tr);
c("div",{className:"label-bold",innerHTML:m.distributeOptions||"Distribute Options"},td);
tr=c("tr",{},_6c);
td=c("td",{colSpan:2},tr);
removeWidget("page2dealStatusId");
new dijit.form.CheckBox({id:"page2dealStatusId",name:"dealStatus",checked:this.deal.dealStatus==1,readOnly:this.viewOnly}).placeAt(td);
c("label",{className:"label",innerHTML:m.setToActive||"Set deal to active","for":"page2dealStatusId"},td);
tr=c("tr",{},_6c);
td=c("td",{colSpan:2,className:"delivery-container"},tr);
c("span",{className:"label",innerHTML:m.deliver||"Deliver"},td);
removeWidget("page2deliveryId");
this.deliveryValue=new Px.Ex.NumberTextBox({intermediateChanges:true,id:"page2deliveryId",name:"uniqueUsers","class":"delivery",required:false,readOnly:this.viewOnly,invalidMessage:m.invalidUniqueUsers||"$_unset_$",emptyMessage:m.emptyUniqueUsers||"$_unset_$",promptMessage:m.promptUniqueUsers||"",constraints:this.viewOnly?{pattern:"#,###,###,###,##0"}:{min:0,pattern:"#,###,###,###,##0"},value:this.deal.uniqueUsers});
this.deliveryValue.placeAt(td);
c("span",{className:"label",innerHTML:m.uniqueUsers||"Unique Users"},td);
tr=c("tr",{},_6c);
td=c("td",{},tr);
removeWidget("page2monthlyId");
new dijit.form.CheckBox({id:"page2monthlyId",name:"monthlyDeliveryIndication",checked:this.deal.monthlyDeliveryIndication,readOnly:this.viewOnly}).placeAt(td);
c("label",{className:"label",innerHTML:m.monthly||"Monthly","for":"page2monthlyId"},td);
td=c("td",{},tr);
removeWidget("page2highestPriorityId");
new dijit.form.CheckBox({id:"page2highestPriorityId",name:"dealPriority",checked:this.deal.dealPriority==2,readOnly:this.viewOnly}).placeAt(td);
c("label",{className:"label",innerHTML:m.setToHighest||"Set to Highest Delivery Priority","for":"page2highestPriorityId"},td);
tr=c("tr",{},_6c);
td=c("td",{},tr);
removeWidget("page2countUniquesId");
new dijit.form.CheckBox({id:"page2countUniquesId",name:"uniques30Days",checked:this.deal.uniques30Days,readOnly:this.viewOnly}).placeAt(td);
c("label",{className:"label",innerHTML:m.countOn30||"Count Uniques on 30 Days Basis","for":"page2countUniquesId"},td);
td=c("td",{},tr);
removeWidget("page2USOnlyId");
new dijit.form.CheckBox({id:"page2USOnlyId",name:"usOnly",checked:this.deal.usOnly,readOnly:this.viewOnly}).placeAt(td);
c("label",{className:"label",innerHTML:m.usOnly||"US Users Only","for":"page2USOnlyId"},td);
removeWidget("page2TitlePaneTags");
this.tpTags=new Px.Ex.TitlePane({title:m.chooseTags||"Choose Tags",open:true,content:this.createTagsPanel(),id:"page2TitlePaneTags",_notIncludeInDirty:true,"class":"all-tags-title-pane"});
this.tpTags.placeAt(_6e);
this.errorDiv=c("div",{className:"tags-error-icon texi-hidden"},this.tpTags.titleBarNode);
this.connect(this.errorDiv,"onmouseenter","showErrorTooltip");
this.connect(this.errorDiv,"onmouseleave","hideErrorTooltip");
},showErrorTooltip:function(){
dijit.showTooltip(this.getErrorMessage(),this.errorDiv);
},hideErrorTooltip:function(){
dijit.hideTooltip(this.errorDiv);
},showError:function(_6f){
if(this.viewOnly||!this.errorDiv){
return;
}
dojo.toggleClass(this.errorDiv,"texi-hidden",!_6f);
},makeTagsPanelOpened:function(){
var tp=dijit.byId("page2TitlePaneTags");
tp.expand();
tp._resetValue=true;
},clearAndDisableSearchControl:function(_70){
var _71=dijit.byId("dddDialogAllTagsSearchId");
_71.attr("value","");
_71.attr("readOnly",_70);
_71.clearValue();
},disableTagsAndSearch:function(_72){
this.clearAndDisableSearchControl(_72);
this.disableAllTags(_72);
dojo.style("dddDialogPage2BtnClearId","display",_72?"none":"");
dojo.style("dddDialogPage2BtnSelectAllId","display",_72?"none":"");
dojo.style("dddDialogPage2BtnClearDisabledId","display",_72?"":"none");
dojo.style("dddDialogPage2BtnSelectAllDisabledId","display",_72?"":"none");
},disableAllTags:function(_73){
this._notReactOnTagChange=true;
dojo.forEach(this.tagList,function(v){
var d=dijit.byId("page2tag"+v.i+"Id");
v.checked=_73;
if(d){
d.attr("checked",v.checked);
d.attr("disabled",_73);
}
});
delete this._notReactOnTagChange;
},checkAllTags:function(_74){
this._notReactOnTagChange=true;
dojo.forEach(this.tagList,function(v){
var d=dijit.byId("page2tag"+v.i+"Id");
if(d){
v.checked=_74;
d.attr("checked",v.checked);
}
});
delete this._notReactOnTagChange;
},updateAllTags:function(_75){
if(!this.tagList){
return;
}
dojo.forEach(this.tagList,function(v){
var d=dijit.byId("page2tag"+v.i+"Id");
if(d){
v.checked=d.attr("checked");
if(_75){
d.destroyRecursive();
}
}
});
},createTagsPanel:function(){
var m=this.messages;
var _76,_77,tr,td,c=dojo.create;
var _78=c("div",{});
_76=c("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:"10px"}},_78);
_77=c("tbody",{},_76);
tr=c("tr",{},_77);
td=c("td",{style:{width:"100%"}},tr);
removeWidget("page2allTagsId");
new dijit.form.CheckBox({id:"page2allTagsId",name:"targetOnAllSites",checked:this.tags.length?this.deal.targetOnAllSites:true,onChange:dojo.hitch(this,"disableTagsAndSearch"),readOnly:this.viewOnly}).placeAt(td);
c("label",{className:"label-bold",innerHTML:m.allTags||"Always Target on all Tags","for":"page2allTagsId"},td);
td=c("td",{},tr);
removeWidget("dddDialogAllTagsSearchId");
var _79=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true,emptyText:m.searchTags||"Search Tags",id:"dddDialogAllTagsSearchId",readOnly:this.deal.targetOnAllSites,style:{visibility:this.viewOnly?"hidden":"visible"}}).placeAt(td);
this.tagsDiv=c("div",{className:"all-tags-container"},_78);
_79.connect(_79,"onChange",dojo.hitch(this,"onChangeSearchText"));
div=c("div",{style:{textAlign:"center"}},_78);
_76=c("table",{style:{borderCollapse:"collapse",margin:"auto"}},div);
_77=c("tbody",{},_76);
tr=c("tr",{},_77);
td=c("td",{},tr);
div=c("div",{className:"btn-clear",style:{display:"none"},id:"dddDialogPage2BtnClearId"},td);
this.connect(div,"onclick",dojo.hitch(this,"checkAllTags",false));
c("div",{className:"btn-clear-disabled",id:"dddDialogPage2BtnClearDisabledId"},td);
td=c("td",{},tr);
div=c("div",{className:"btn-select-all",style:{display:"none"},id:"dddDialogPage2BtnSelectAllId"},td);
this.connect(div,"onclick",dojo.hitch(this,"checkAllTags",true));
c("div",{className:"btn-select-all-disabled",id:"dddDialogPage2BtnSelectAllDisabledId"},td);
return _78;
},prepareTagsTable:function(){
var _7a=this.deal.targetOnAllSites;
var t=[];
dojo.forEach(this.tags,function(v){
v.targeted=_7a||v.targeted;
t.push({label:v.tagName,checked:v.targeted,reset:v.targeted,i:v.tagCode});
});
this.tagList=t;
this.createTagsTable(this.tagList);
if(_7a){
this.disableAllTags(true);
}
},updateTagsData:function(){
this._tagsBeforeSave=dojo.clone(this.tags);
dojo.forEach(this.tagList,function(v,i){
this.tags[i].targeted=v.checked;
},this);
},updateTagListAndCheckboxes:function(){
if(!this.tags||!this.tagList){
return;
}
this._notReactOnTagChange=true;
dojo.forEach(this.tags,function(v,i){
var _7b=this.tagList[i];
_7b.checked=_7b.reset=v.targeted;
var d=dijit.byId("page2tag"+_7b.i+"Id");
if(d){
d.attr("checked",_7b.checked);
d.params.checked=_7b.reset;
}
},this);
delete this._notReactOnTagChange;
},createTagsTable:function(_7c){
this.updateAllTags(true);
dojo.empty(this.tagsDiv);
var _7d,_7e,tr,td,c=dojo.create;
_7d=c("table",{className:"all-tags-table"},this.tagsDiv);
_7e=c("tbody",{},_7d);
dojo.forEach(_7c,function(v,i){
if(i%2==0){
tr=c("tr",{},_7e);
}
td=c("td",{className:"main"},tr);
var id="page2tag"+v.i+"Id";
removeWidget(id);
var ch=new dijit.form.CheckBox({id:id,checked:v.reset,onChange:dojo.hitch(this,"updateAllTags",false),readOnly:this.viewOnly});
ch.placeAt(td);
ch.attr("checked",v.checked);
c("label",{className:"label",innerHTML:v.label,"for":id},td);
if(i%2==0){
td=c("td",{className:"spacer"},tr);
}
},this);
},getTagsState:function(){
var all=dijit.byId("page2allTagsId");
var _7f;
if(all.attr("checked")){
_7f="default";
}else{
_7f="opened";
dojo.some(this.tagList,function(v){
if(v.checked){
_7f="closed";
}
return v.checked;
},this);
}
return _7f;
},getErrorMessage:function(){
return this.noneTagsSelected;
},onChangeSearchText:function(_80){
var _81;
if(_80!=""){
var val=_80.toLowerCase();
_81=dojo.filter(this.tagList,function(v){
return v.label.toLowerCase().indexOf(val)>=0;
},this);
}else{
_81=this.tagList;
}
this.createTagsTable(_81);
},destroy:function(){
try{
this.hideErrorTooltip();
}
catch(e){
}
this.inherited(arguments);
}});
dojo.declare("Px.Ex.DealSettingsScreen",[Px.Ex.XhrMixin],{NUMBER:1,STRING:2,BOOL:3,standby:undefined,rotationImage:"",draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/deal-settings/screen",load:dojo.hitch(this,"createScreen"),error:function(_1){
dojo.byId("divContent").innerHTML=_1;
},handleAs:"json"});
},createScreen:function(_2){
this.data=_2;
dojo.empty("divContent");
this._c=new dijit.layout.ContentPane({"class":"deal-settings"}).placeAt("divContent");
this._createStandBy(this._c.containerNode);
var _3,_4,tr,td,_5,c=dojo.create;
this.form=new Px.Ex.Form();
this.form.placeAt(this._c.containerNode);
_3=c("table",{className:"layout"},this.form.containerNode);
_4=c("tbody",{},_3);
var _6,_7=!_2.allow.all_editable,_8=!_2.allow.save;
this._map={};
dojo.forEach(_2.data,function(v,i){
var _9=""+v.attributeId;
this._map[_9]=v;
var _a=_8||(_7&&!v.allowPublisherUpdate);
if(v.attributeSection!=_6){
_6=v.attributeSection;
tr=c("tr",{className:"vspacer"},_4);
}
tr=c("tr",{},_4);
td=c("td",{className:"vmiddle"},tr);
_5=c("div",{className:"label-container"},td);
if(v.attributeType==this.BOOL){
var _b=new dijit.form.CheckBox({checked:!!v.attributeNumericValue,id:"ctrlId"+v.attributeId,name:_9,readOnly:_a});
_b.placeAt(_5);
}
(function(){
var _c=c("label",{innerHTML:v.attributeName,className:"label unselectable",unselectable:true,"for":"ctrlId"+v.attributeId},_5);
if(_a){
dojo.addClass(_c,"readonly");
}
var _d=v.attributeNotes;
this._c.connect(_c,"onmouseenter",dojo.hitch(this,function(){
if(!_d){
return;
}
dijit.showTooltip(v.attributeNotes,_c,["above","below"]);
}));
this._c.connect(_c,"onmouseleave",dojo.hitch(this,function(){
if(!_d){
return;
}
dijit.hideTooltip(_c);
}));
}).call(this);
td=c("td",{className:"vmiddle"},tr);
if(v.attributeType==this.NUMBER){
dojo.addClass(td,"right");
if(v.attributeSelectionListIndication&&(v.numericMinValue!=""||v.numericMaxValue!="")){
var _e=[];
for(var n=v.numericMinValue,j=v.numericMaxValue;n<=j;++n){
_e.push({n:n});
}
var _b=new Px.Ex.FilteringSelect({store:new dojo.data.ItemFileReadStore({data:{identifier:"n",items:_e}}),required:!_a,searchAttr:"n",id:"ctrlId"+v.attributeId,value:v.attributeNumericValue,valueType:"number","class":"number-control",name:_9,readOnly:_a});
}else{
var _f;
if(v.numericMinValue!=""){
_f={min:v.numericMinValue};
}
if(v.numericMaxValue!=""){
if(!_f){
_f={};
}
_f.max=v.numericMaxValue;
}
var _b=new Px.Ex.NumberTextBox({value:v.attributeNumericValue,id:"ctrlId"+v.attributeId,constraints:_f,"class":"number-control",name:_9,readOnly:_a});
}
_b.placeAt(td);
if(_a){
dojo.addClass(_b.focusNode,"readonly");
}
}else{
if(v.attributeType==this.STRING){
if(v.attributeSelectionListIndication){
var _e=dojo.map(v.selectionList.split(","),function(v){
return {id:v};
});
var _b=new Px.Ex.FilteringSelect({store:new dojo.data.ItemFileReadStore({data:{identifier:"id",items:_e}}),required:!_a,searchAttr:"id",id:"ctrlId"+v.attributeId,value:v.attributeStringValue,name:_9,readOnly:_a});
}else{
var _b=new Px.Ex.ValidationTextBox({value:v.attributeStringValue,regExp:Px.Ex.Application.Patterns.NAME_STR,id:"ctrlId"+v.attributeId,name:_9,readOnly:_a});
}
_b.placeAt(td);
if(_a){
dojo.addClass(_b.focusNode,"readonly");
}
}
}
td=c("td",{className:"vmiddle",style:{width:"100%"}},tr);
_5=c("div",{className:"save-error hidden",id:this._getSaveErrorId(v.attributeId)},td);
},this);
if(_2.allow.save){
_5=c("div",{className:"buttons"},this._c.containerNode);
_3=c("table",{className:"layout"},_5);
_4=c("tbody",{},_3);
tr=c("tr",{},_4);
td=c("td",{},tr);
_5=c("div",{className:"button-reset"},td);
this._c.connect(_5,"onclick",dojo.hitch(this,"reset"));
td=c("td",{},tr);
_5=c("div",{className:"button-save"},td);
this._c.connect(_5,"onclick",dojo.hitch(this,"save"));
}
},_getSaveErrorId:function(_10){
return "seId"+_10;
},_hideAllSaveErrors:function(){
dojo.forEach(this.data.data,function(v){
dojo.addClass(this._getSaveErrorId(v.attributeId),"hidden");
},this);
},_showSaveError:function(_11,_12){
var id=this._getSaveErrorId(_11);
dojo.removeClass(id,"hidden");
dojo.attr(id,"title",_12);
},_createStandBy:function(_13){
var _14={target:dojo.body(),image:Px.Ex.Application.getWaitImageUrl()};
this.standby=new Px.Ex.Standby(_14,dojo.create("div",{},_13));
this.standby.startup();
},reset:function(){
this._hideAllSaveErrors();
this.form.reset();
},save:function(){
this._save();
},showRotation:function(_15){
if(!this.standby){
return;
}
if(_15){
this.standby.show();
}else{
this.standby.hide();
}
},_showErrDialog:function(_16,_17,_18){
var msg=Px.Ex.Application._extractError(_16,_17);
var cls=_18?"error-dialog-deal-settings":undefined;
return Px.Ex.Application.showMsgDialog(msg,undefined,cls);
},_getFormData:function(){
var o=this.form.attr("value");
for(var p in o){
var v=this._map[p];
if(v.attributeType==this.BOOL){
if(!!v.attributeNumericValue==!!o[p]){
delete o[p];
}
}else{
if(v.attributeType==this.NUMBER){
if(v.attributeNumericValue==o[p]){
delete o[p];
}
}else{
if(v.attributeType==this.STRING){
if(v.attributeStringValue==o[p]){
delete o[p];
}
}else{
delete o[p];
}
}
}
}
return o;
},_changeResetValue:function(v){
this.form.updateWidgetsForReset(dijit.byId("ctrlId"+v.attributeId));
},_save:function(_19){
this._hideAllSaveErrors();
if(!this.form.validate()){
return;
}
if(this.form.isDirty()){
this.showRotation(true);
var o=this._getFormData();
this.xhr({url:"/deal-settings/save",content:{attr:dojo.toJson(o)},load:dojo.hitch(this,function(_1a,_1b){
this.showRotation(false);
var _1c={};
if(_1a.length!=0){
_1a=dojo.map(_1a,function(v){
_1c[v[0]]=1;
var err=Px.Ex.Application._extractError(v[1]);
this._showSaveError(v[0],err);
return "<span class=\"error-name\">"+this._map[v[0]].attributeName+":</span> "+err;
},this);
this._showErrDialog(_1a.join("<BR>"),_1b,true);
for(var p in o){
if(p in _1c){
continue;
}
var v=this._map[p];
if(v.attributeType==this.BOOL){
v.attributeNumericValue=o[p]?1:0;
}else{
if(v.attributeType==this.NUMBER){
v.attributeNumericValue=o[p];
}else{
if(v.attributeType==this.STRING){
v.attributeStringValue=o[p];
}
}
}
this._changeResetValue(v);
}
}
for(var p in o){
if(p in _1c){
continue;
}
var v=this._map[p];
if(v.attributeType==this.BOOL){
v.attributeNumericValue=o[p]?1:0;
}else{
if(v.attributeType==this.NUMBER){
v.attributeNumericValue=o[p];
}else{
if(v.attributeType==this.STRING){
v.attributeStringValue=o[p];
}
}
}
this._changeResetValue(v);
}
}),error:dojo.hitch(this,function(err,_1d){
this.showRotation(false);
this._showErrDialog(err,_1d);
}),handleAs:"json"});
if(_19){
_19();
}
}
},beforeClose:function(_1e){
if(this.data.allow.save&&this.form.isDirty()){
var m=this.data.messages;
var dlg=new Px.Ex.MessageDialog({okCallback:_1e,message:m.confirmLeaveScreen||"The settings have been changed. Leave anyway?"});
dlg.show();
}else{
_1e();
}
},destroy:function(){
if(this._c){
this._c.destroyRecursive();
}
}});
dojo.declare("Px.Ex.DataTagsScreen",[Px.Ex.XhrMixin],{draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/data-tags/screen-data",load:dojo.hitch(this,"createScreen"),handleAs:"json"});
},createScreen:function(_1){
var _2,_3,tr,td,c=dojo.create;
dojo.empty("divContent");
if(_1.access_denied){
dojo.byId("divContent").innerHTML=_1.access_denied;
return;
}
var _4=this._connections=[];
var _5=c("div",{className:"data-tags-screen"},"divContent");
c("div",{innerHTML:_1.text,className:"top-text"},_5);
var _6=c("div",{className:"search-control-container"},_5);
this.searchControl=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true,id:"dataTagsScreenSearchId"}).placeAt(_6);
this.searchControl.connect(this.searchControl,"onChange",dojo.hitch(this,"onChangeSearchText"));
var _7=c("div",{className:"groups-main-container"},_5);
this.groupsContainer=c("div",{className:"groups-container"},_7);
if(_1.groups["return"]&&_1.groups["return"].groupDetails){
_1.groups=_1.groups["return"].groupDetails;
if(!dojo.isArray(_1.groups)){
_1.groups=[_1.groups];
}
this.groups=dojo.filter(_1.groups,"return item.active;");
this.createGroupsTable(this.groups);
_6=c("div",{style:{textAlign:"center"}},_7);
_2=c("table",{style:{borderCollapse:"collapse",margin:"auto"}},_6);
_3=c("tbody",{},_2);
tr=c("tr",{},_3);
td=c("td",{},tr);
_6=c("div",{className:"btn-clear"},td);
_4.push(dojo.connect(_6,"onclick",null,dojo.hitch(this,"checkAllGroups",false)));
td=c("td",{},tr);
_6=c("div",{className:"btn-select-all"},td);
_4.push(dojo.connect(_6,"onclick",null,dojo.hitch(this,"checkAllGroups",true)));
_6=c("div",{style:{textAlign:"center"}},_5);
_6=c("div",{className:"btn-get-tags"},_6);
_4.push(dojo.connect(_6,"onclick",null,dojo.hitch(this,"showTagsDialog",true)));
}else{
this.groupsContainer.innerHTML=dojo.toJson(_1.groups);
}
},clearGroupsTable:function(){
if(!this.groupsTable){
return;
}
dojo.forEach(this.groupsTable,function(v){
v.destroyRecursive();
},this);
delete this.groupsTable;
},createGroupsTable:function(_8){
this.updateAllGroups();
this.clearGroupsTable();
dojo.empty(this.groupsContainer);
var _9,_a,tr,td,c=dojo.create;
_9=c("table",{className:"groups-table"},this.groupsContainer);
_a=c("tbody",{},_9);
this.groupsTable=[];
dojo.forEach(_8,function(v,i){
if(i%2==0){
tr=c("tr",{},_a);
}
td=c("td",{className:"main"},tr);
var id=this.getGroupCheckBoxId(v);
var ch=new dijit.form.CheckBox({id:id,checked:v.active});
ch.placeAt(td);
if(v.label===undefined){
v.label=this.getGroupLabel(v);
}
c("label",{className:"label",innerHTML:v.label,"for":id},td);
if(i%2==0){
td=c("td",{className:"spacer"},tr);
}
this.groupsTable.push(ch);
},this);
},getGroupLabel:function(v){
return dojo.string.substitute("${groupName} (${groupDisplayCode})",{groupName:v.groupName,groupDisplayCode:dojo.number.format(v.groupDisplayCode,{pattern:"000"})});
},getGroupCheckBoxId:function(v){
return "dataTagsGroup"+v.groupCode+"Id";
},updateAllGroups:function(){
if(!this.groups||!this.groupsTable){
return;
}
dojo.forEach(this.groups,function(v){
var id=this.getGroupCheckBoxId(v);
var ch=dijit.byId(id);
if(ch){
v.active=ch.attr("checked");
}
},this);
},onChangeSearchText:function(_b){
if(!this.groups){
return;
}
var s=_b.toLowerCase();
var _c=dojo.filter(this.groups,function(v){
if(v.label===undefined){
v.label=this.getGroupLabel(v);
}
return v.label.toLowerCase().indexOf(s)>=0;
});
this.createGroupsTable(_c);
},checkAllGroups:function(_d){
_d=!!_d;
if(!this.groups||!this.groupsTable){
return;
}
dojo.forEach(this.groupsTable,function(v){
v.attr("checked",_d);
},this);
},getGroupDisplayCodes:function(){
this.updateAllGroups();
var _e=dojo.filter(dojo.map(this.groups,function(v){
return v.active?v.groupDisplayCode:null;
}),function(v){
return v!==null;
}).join(",");
return _e;
},showTagsDialog:function(){
var cc=this.getGroupDisplayCodes();
if(cc==""){
return;
}
var _f=new Px.Ex.DataTagsDialog({groupDisplayCodes:cc});
_f.show();
},destroy:function(){
dojo.forEach(this._connections,dojo.disconnect,this);
this.clearGroupsTable();
try{
this.searchControl.destroyRecursive();
}
catch(e){
}
}});
(function(){
dojo.declare("Px.Ex.DataTagsDialog",[Px.Ex.Dialog],{"class":"data-tags-dialog",groupDisplayCodes:"",startup:function(){
this.inherited(arguments);
var _1=Px.Ex.Application.Titles.DATA_TAGS;
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(_1);
this.attr("content",Px.Ex.Application.getWaitHtml());
this.xhr({url:"/data-tags/dialog-data",content:{groupDisplayCodes:this.groupDisplayCodes},load:dojo.hitch(this,"createContent"),handleAs:"json"});
},createContent:function(_2){
var _3,_4,tr,td,c=dojo.create;
var _5=c("div",{});
this.attr("content",_5);
c("div",{innerHTML:_2.text,className:"top-text"},_5);
var _6=c("div",{className:"editor-container"},_5);
var _7=this._editor=new CodeMirror(_6,{readOnly:true,path:"/codemirror/js/",parserfile:["parsexml.js","parsecss.js","tokenizejavascript.js","parsejavascript.js","parsehtmlmixed.js"],stylesheet:["/codemirror/css/xmlcolors.css","/codemirror/css/jscolors.css","/codemirror/css/csscolors.css"],width:"100%",height:"100%",content:_2.tags});
_6=c("div",{style:{textAlign:"center"}},_5);
_3=c("table",{style:{borderCollapse:"collapse",margin:"auto"}},_6);
_4=c("tbody",{},_3);
tr=c("tr",{},_4);
if(dojo.isIE){
td=c("td",{},tr);
_6=c("div",{className:"btn-copy"},td);
this.connect(_6,"onclick","copy");
}
td=c("td",{},tr);
_6=c("div",{className:"btn-download"},td);
this.connect(_6,"onclick","download");
this.layout();
},copy:function(){
try{
window.clipboardData.setData("Text",this._editor.getCode());
}
catch(e){
}
},download:function(){
window.open("/data-tags/download-tags?groupDisplayCodes="+this.groupDisplayCodes);
}});
})();
dojo.declare("Px.Ex.BuyerDashboardScreen",[Px.Ex.XhrMixin],{cookieName:"buyerDashboardLastVisitedTab",allow:{},draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/buyer-dashboard/screen",load:dojo.hitch(this,"createScreen"),error:function(_1){
dojo.byId("divContent").innerHTML=Px.Ex.Application._extractError(_1);
},handleAs:"json"});
},onBuyerChanged:function(_2,_3,_4,_5){
if(_5&&_4){
this._cleanup();
this.draw();
}
},editSettings:function(){
var _6=new Px.Ex.SettingsDialog({callback:dojo.hitch(this,"onBuyerChanged"),withMessage:false,requireBuyer:true});
_6.show();
},_findBarControlWidths:function(){
var _7=dojo.create("div",{className:"buyer-dashboard"},"divContent");
div=dojo.create("div",{className:"segment-container",style:{top:"10000px"},innerHTML:"&nbsp"},_7);
this._segmentContainerWidth=parseInt(dojo.getComputedStyle(div).width)||200;
div=dojo.create("div",{className:"buyer-container",style:{top:"10000px"},innerHTML:"&nbsp"},_7);
this._buyerContainerWidth=parseInt(dojo.getComputedStyle(div).width)||100;
dojo.destroy(_7);
},getSelectedTabFromCookie:function(){
if(dojo.cookie.isSupported()){
return dojo.cookie(this.cookieName);
}else{
return undefined;
}
},setSelectedTabToCookie:function(_8){
if(dojo.cookie.isSupported()){
dojo.cookie(this.cookieName,_8);
}
},createScreen:function(_9){
this._connections=[];
this.__selectedTab=this.getSelectedTabFromCookie();
dojo.empty("divContent");
this._findBarControlWidths();
if(_9.no_buyer){
var _a=new Px.Ex.SettingsDialog({callback:dojo.hitch(this,"draw"),withMessage:true,requireBuyer:true});
_a.show();
return;
}
if(!_9.buyer){
dojo.byId("divContent").innerHTML="Buyer ["+_9.buyer_name+"] does not exist (please, contact with system administrator)";
return;
}
this.allow=_9.allow;
this.data=_9;
if(_9.access_denied){
dojo.byId("divContent").innerHTML=_9.access_denied;
return;
}
this._c=new dijit.layout.ContentPane({"class":"buyer-dashboard"}).placeAt("divContent");
this.createWelcome();
this.createSystemNotifications();
this.createSegmentsCategoryTree();
},createWelcome:function(){
if(!this.allow.welcome){
return;
}
var _b="";
try{
_b="$"+dojo.number.format(this.data.buyer.mtdDataCost,{pattern:"#,##0.00"});
}
catch(e){
}
var _c,_d,c=dojo.create,m=this.data.messages;
_c=c("div",{className:"welcome-container"},this._c.containerNode);
_d=c("div",{innerHTML:(m.labelWelcome||"Welcome")+" "+this.data.firstName+"! ",className:"bold"},_c);
c("span",{innerHTML:this.data.buyer.buyerName,className:"reg_green"},_d);
_d=c("div",{className:"welcome-data"},_c);
c("span",{innerHTML:">",className:"string-start-pointer"},_d);
c("span",{innerHTML:(m.labelDataCost||"Month to date data cost")+", "+this.data.welcomeDate+": "+_b},_d);
},createSystemNotifications:function(){
if(!this.allow.system_notifications||this.data.system_notifications.length==0){
return;
}
var _e,d,c=dojo.create,m=this.data.messages;
_e=c("div",{className:"notifications-container"},this._c.containerNode);
c("div",{innerHTML:m.labelNotifications||"System Notifications",className:"bold"},_e);
_e=c("div",{className:"notifications-list"},_e);
dojo.forEach(this.data.system_notifications,function(v){
d=c("div",{className:"notification"},_e);
c("span",{innerHTML:">",className:"string-start-pointer"},d);
c("span",{innerHTML:v},d);
});
},createSegmentsCategoryTree:function(){
this.createToolbar();
this.createTabButtons();
},createToolbar:function(){
var m=this.data.messages;
var _f,_10,tr,td,div,_11,c=dojo.create;
_f=c("table",{className:"toolbar"},this._c.containerNode);
_10=c("tbody",{},_f);
tr=c("tr",{},_10);
var _12={verticalAlign:"middle"};
td=c("td",{style:dojo.mixin({width:"100%"},_12)},tr);
div=c("div",{},td);
c("span",{innerHTML:m.labelSegments||"Segments availability in the ",className:"label"},div);
c("span",{innerHTML:m.labelLast30||"Last 30 days",className:"label-bold"},div);
td=c("td",{style:_12},tr);
var _13=c("div",{innerHTML:m.labelRefresh||"Refresh",className:"refresh unselectable",unselectable:true},td);
this._c.connect(_13,"onclick",dojo.hitch(this,"onRefresh"));
this._c.connect(_13,"onmouseover",function(){
dojo.addClass(_13,"ready");
});
this._c.connect(_13,"onmouseout",function(){
dojo.removeClass(_13,"ready");
});
td=c("td",{style:_12},tr);
div=c("div",{className:"active-container"},td);
var ch=new dijit.form.CheckBox({"class":"check-active",onChange:dojo.hitch(this,"onActiveOnly")}).placeAt(div);
c("label",{innerHTML:m.labelActiveOnly||"Active Deals Only",className:"label unselectable","for":ch.id,unselectable:true},div);
td=c("td",{style:_12},tr);
var _14=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true,emptyText:m.search||"Search"}).placeAt(td);
_14.connect(_14,"onChange",dojo.hitch(this,"onSearch"));
this.searchControl=_14;
},shouldEnableScrollArrow:function(_15){
var div=dojo.byId("TabsScroller");
switch(_15){
case "left":
return (div.scrollLeft>0);
break;
case "right":
return (this.getScrollWidth()>div.clientWidth+div.scrollLeft);
break;
}
return false;
},isScrollerRequired:function(){
return (this.getScrollWidth()>dojo.style("TabsScroller","maxWidth"));
},createTabButtons:function(){
var m=this.data.messages;
var c=dojo.create;
this._selectedColor=dojo.getComputedStyle(dojo.query(".texi-logo-text")[0]).color;
if(dojo.isIE){
table=c("table",{},this._c.containerNode);
dojo.style(table,"marginLeft","20px");
table.cellSpacing="0";
tbody=c("tbody",{},table);
tr=c("tr",{},tbody);
td=c("td",{id:"ScrollingArrows_Left",className:"LeftArrow IE"},tr);
dojo.style(td,"display","none");
this._connections.push(dojo.connect(dojo.byId("ScrollingArrows_Left"),"onclick",dojo.hitch(this,"onScrollLeftClick")));
td=c("td",{},tr);
dojo.style(td,"padding-left: 0px; padding-right: 0px;");
span=c("span",{},td);
div=c("div",{id:"TabsScroller",className:"IE TabsOuterDiv Full"},span);
table=c("table",{},div);
table.cellSpacing="0";
td=c("td",{id:"ScrollingArrows_Right",className:"RightArrow IE"},tr);
dojo.style(td,"display","none");
this._connections.push(dojo.connect(dojo.byId("ScrollingArrows_Right"),"onclick",dojo.hitch(this,"onScrollRightClick")));
tbody=c("tbody",{},table);
tr=c("tr",{},tbody);
this.tabs=new dijit.layout.StackContainer({}).placeAt(this._c.containerNode);
}else{
table=c("table",{className:"tab-buttons-container"},this._c.containerNode);
tbody=c("tbody",{},table);
tr=c("tr",{},tbody);
tdLeftArrow=c("td",{id:"ScrollingArrows_Left",className:"LeftArrow"},tr);
dojo.style(tdLeftArrow,"display","none");
this._connections.push(dojo.connect(dojo.byId("ScrollingArrows_Left"),"onclick",dojo.hitch(this,"onScrollLeftClick")));
tdTabsScroller=c("td",{},tr);
divTabsScroller=c("div",{id:"TabsScroller"},tdTabsScroller);
dojo.style(divTabsScroller,"overflow","hidden");
dojo.style(divTabsScroller,"maxWidth","830px");
tdRightArrow=c("td",{id:"ScrollingArrows_Right",className:"RightArrow"},tr);
dojo.style(tdRightArrow,"display","none");
this._connections.push(dojo.connect(dojo.byId("ScrollingArrows_Right"),"onclick",dojo.hitch(this,"onScrollRightClick")));
dojo.style(tdRightArrow,"display","none");
divTabsScrollerSon=c("div",{id:"TabsScrollerSon"},divTabsScroller);
dojo.style(divTabsScrollerSon,"width","2000px");
table=c("table",{},divTabsScrollerSon);
tbody=c("tbody",{},table);
tr=c("tr",{},tbody);
this.tabs=new dijit.layout.StackContainer().placeAt(this._c.containerNode);
}
this.refreshIndicator=c("div",{},this._c.containerNode);
var _16=dojo.hitch(this,"reloadCurrentTab");
var _17=dojo.hitch(this,"doNotChangeTab");
this.categories=this.data.categories["return"]["categories"];
if((this.categories)&&(this.categories.length>0)){
this.categories.sort(function(a,b){
if(a["categoryCode"]==3){
return -1;
}
if(b["categoryCode"]==3){
return 1;
}
if(a["categoryCode"]==2){
return -1;
}
if(b["categoryCode"]==2){
return 1;
}
if(a["categoryCode"]==1){
return -1;
}
if(b["categoryCode"]==1){
return 1;
}
if(dojo.isChrome){
return -1;
}else{
return 0;
}
});
}
if((this.categories)&&(this.categories.length>0)){
this.pages=new Array();
this.pagesData=new Array();
for(category in this.categories){
var _18=this.categories[category]["categoryCode"];
this.pages[_18]=new Px.Ex.BuyerDashboardPage({data:this.data,parentContainer:this.tabs,pageType:_18,pageTypeName:this.categories[category]["categoryName"],pageData:this.pagesData[_18],segmentContainerWidth:this._segmentContainerWidth,buyerContainerWidth:this._buyerContainerWidth,reloadFn:_16,doNotChangeTabFn:_17,xhr:dojo.hitch(this,"xhr")});
this.tabs.addChild(this.pages[_18]);
td=c("td",{},tr);
c("div",{id:"btn_id_"+_18,className:"btn_tab_"+_18},td);
}
this.ajaxIndicator=c("div",{className:"ajax-indicator texi-hidden",innerHTML:m.ajaxIndicator||""},td);
this.tabs.startup();
if(this.__selectedTab){
this.selectTab(this.__selectedTab);
}else{
var _19=this.tabs.getChildren();
if((_19)&&(_19.length>0)){
this.selectTab(_19[0].pageType);
}
}
if(!this.isScrollerRequired()){
dojo.style(dojo.byId("ScrollingArrows_Left"),"display","none");
dojo.style(dojo.byId("ScrollingArrows_Right"),"display","none");
}else{
dojo.style(dojo.byId("TabsScroller"),"maxWidth","805px");
dojo.style(dojo.byId("TabsScroller"),"width","805px");
dojo.style(dojo.byId("ScrollingArrows_Left"),"display","table-cell");
dojo.style(dojo.byId("ScrollingArrows_Right"),"display","table-cell");
this.myScrollIntoView(this._selectedTab);
this.refreshScroller();
}
}
},createTabButton:function(id,_1a){
var m=this.data.messages;
var fn=dojo.hitch(this,"selectTab",id);
this.createTabButton_draw("btn_id_"+id,this.getCategoryObjectByCode(id),_1a,"btn_tab_"+id,fn);
if(_1a){
this._selectedTab=id;
}
},getCategoryObjectByCode:function(_1b){
for(category in this.categories){
if(_1b==this.categories[category]["categoryCode"]){
return this.categories[category];
}
}
},doNotChangeTab:function(_1c){
if(_1c){
if(!this.__do_not_change_tab){
this.__do_not_change_tab=[];
}
this.__do_not_change_tab.push(1);
}else{
if(this.__do_not_change_tab&&this.__do_not_change_tab.length>0){
this.__do_not_change_tab.pop();
}
if(this.__do_not_change_tab&&this.__do_not_change_tab.length==0){
delete this.__do_not_change_tab;
}
}
},selectTab:function(num){
if(this.__do_not_change_tab||this.__reloading||this._selectedTab==num){
return;
}
for(category in this.categories){
var _1d=this.categories[category]["categoryCode"];
this.pages[_1d].setActive(parseInt(num)==_1d);
this.createTabButton(_1d,(parseInt(num)==_1d));
if(parseInt(num)==_1d){
this.tabs.selectChild(this.pages[_1d]);
this.setSelectedTabToCookie(_1d);
this._selectedTab=_1d;
}
}
this.myScrollIntoView(this._selectedTab);
if(this.pages[num].needReload){
this._reloadTab();
}
},getScrollWidth:function(){
var sum=0;
for(var i=0;i<this.categories.length;i++){
sum+=dojo.coords(dojo.byId("btn_id_"+this.categories[i]["categoryCode"])).w;
}
return sum;
},refreshScroller:function(){
this.showScrollArrow("left",this.shouldEnableScrollArrow("left"));
this.showScrollArrow("right",this.shouldEnableScrollArrow("right"));
},showScrollArrow:function(_1e,_1f){
switch(_1e){
case "left":
switch(_1f){
case true:
dojo.toggleClass("ScrollingArrows_Left","disabled",false);
break;
case false:
dojo.toggleClass("ScrollingArrows_Left","disabled",true);
break;
}
break;
case "right":
switch(_1f){
case true:
dojo.toggleClass("ScrollingArrows_Right","disabled",false);
break;
case false:
dojo.toggleClass("ScrollingArrows_Right","disabled",true);
break;
}
break;
}
},myScrollIntoView:function(_20){
dojo.require("dojox.fx.scroll");
var _21=0;
var _22=dojo.byId("TabsScroller").scrollLeft;
var _23=dojo.style("TabsScroller","maxWidth");
var _24=this.getScrollWidthUntilTab(_20);
var _25=dojo.coords(dojo.byId("btn_id_"+_20)).w;
var _26=0;
var _27=false;
if(_24<_22){
_21=_24;
_27=true;
}else{
if((_26=(_24+_25)-(_22+_23))>0){
_21=_22+_26;
_27=true;
}
}
if(_27){
dojox.fx.smoothScroll({node:dojo.byId("TabsScroller"),win:dojo.byId("TabsScroller"),duration:500,target:{x:_21},onEnd:dojo.hitch(this,function(){
this.refreshScroller();
})}).play();
}
},getScrollWidthUntilTab:function(_28){
var sum=0;
for(var i=0;i<this.categories.length;i++){
if(_28==this.categories[i]["categoryCode"]){
break;
}else{
sum+=dojo.coords(dojo.byId("btn_id_"+this.categories[i]["categoryCode"])).w;
}
}
return sum;
},onScrollRightClick:function(){
var _29=this.getNextToLastVisibleCategoryCode();
if(_29!=-1){
this.myScrollIntoView(_29);
}
},onScrollLeftClick:function(){
var _2a=this.getPreviousToFirstVisibleCategoryCode();
if(_2a!=-1){
this.myScrollIntoView(_2a);
}
},getNextToLastVisibleCategoryCode:function(){
var sum=0;
var _2b;
var _2c=dojo.style("TabsScroller","maxWidth");
var _2d=dojo.byId("TabsScroller").scrollLeft;
for(var i=0;i<this.categories.length;i++){
var _2e=sum+dojo.coords(dojo.byId("btn_id_"+this.categories[i]["categoryCode"])).w;
if(_2e>(_2d+_2c)){
_2b=i-1;
break;
}else{
sum=_2e;
_2b=i;
}
}
if(_2b<(this.categories.length-1)){
return (this.categories[_2b+1]["categoryCode"]);
}else{
return -1;
}
},getPreviousToFirstVisibleCategoryCode:function(){
var sum=0;
var _2f;
var _30=dojo.byId("TabsScroller").scrollLeft;
for(var i=0;i<this.categories.length;i++){
if(sum>=_30){
_2f=i;
break;
}else{
sum+=dojo.coords(dojo.byId("btn_id_"+this.categories[i]["categoryCode"])).w;
}
}
if(_2f==0){
return -1;
}else{
return (this.categories[_2f-1]["categoryCode"]);
}
},createTabButton_draw:function(_31,_32,_33,key,_34){
var _35=60;
var _36="12px",H=20,W=130;
var m=this.data.messages;
var h=H;
var _37=_33?this._selectedColor||"#F26A22":"#898D90";
var _38=_33?_37:_37;
var _39=_33?"white":"white";
var _3a=_33?"bold":"normal";
var w=W;
if(this[key]){
this[key].destroy();
}
var _3b=this[key]=dojox.gfx.createSurface(_31,w,h);
var t=_3b.createText({x:0,y:0,text:_32["categoryName"],align:"middle"});
t.setFont({family:"Arial",size:_36,weight:_3a,rotated:true});
var tw=t.getTextWidth();
_3b.remove(t);
if(tw+_35>w){
w=tw+_35;
_3b.setDimensions(w,h);
}
var _3c=_3b.createPath("");
var r=8;
var _3d=_33?0:2;
_3c.moveTo(w-1,h).vLineTo(r+1+_3d).arcTo(r,r,0,false,false,w-r-1,1+_3d).hLineTo(r+1).arcTo(r,r,0,false,false,1,r+1+_3d).vLineTo(h).closePath();
_3c.setFill(_37).setStroke(_38);
var c={x:parseInt(w/2),y:parseInt(h/2)};
var t=_3b.createText({x:c.x,y:c.y+6,text:_32["categoryName"],align:"middle"});
if(_32["newCategory"]){
var img=_3b.createImage({x:w-20,y:3+_3d,src:m.ImgNewCategory,height:14,width:14});
if((dojo.isFF)&&(dojo.isFF=="3.5")){
img.rawNode.attributes[0].nodeValue="1";
}
this._connections.push(img.connect("onmouseover",dojo.hitch(this,function(){
this.categoryStarTooltipOn=true;
dijit.showTooltip(this.getNewCategoryTooltipHtml(_32),dojo.byId(_31));
})));
this._connections.push(img.connect("onmouseout",dojo.hitch(this,function(){
this.categoryStarTooltipOn=false;
dijit.hideTooltip(dojo.byId(_31));
})));
}
if((!_32["newCategory"])&&(_32["activeNewSegments"]>0)){
var img=_3b.createImage({x:w-20,y:3+_3d,src:m.ImgCategoryWithNewSegments,height:14,width:14});
if((dojo.isFF)&&(dojo.isFF=="3.5")){
img.rawNode.attributes[0].nodeValue="1";
}
this._connections.push(img.connect("onmouseover",dojo.hitch(this,function(){
this.categoryStarTooltipOn=true;
dijit.showTooltip(this.getNewSegmentsTooltipHtml(_32),dojo.byId(_31));
})));
this._connections.push(img.connect("onmouseout",dojo.hitch(this,function(){
this.categoryStarTooltipOn=false;
dijit.hideTooltip(dojo.byId(_31));
})));
}
t.setFill(_39);
t.setFont({family:"Arial",size:_36,weight:_3a,rotated:false});
if(!this.viewOnly){
this._connections.push(_3b.connect("onclick",dojo.hitch(this,_34)));
}
this._connections.push(_3b.connect("onmouseover",dojo.hitch(this,function(){
this.categorySurfaceTooltipOn=true;
if(!this.categoryStarTooltipOn){
dijit.showTooltip(this.getMainTooltipHtml(_32),dojo.byId(_31),["above","below"]);
}
})));
this._connections.push(_3b.connect("onmouseout",dojo.hitch(this,function(){
this.categorySurfaceTooltipOn=false;
dijit.hideTooltip(dojo.byId(_31));
})));
if(dojox.gfx.renderer=="silverlight"){
_3b.rawNode["Cursor"]="Hand";
}else{
dojo.style(_3b.rawNode,"cursor","pointer");
}
},getMainTooltipHtml:function(_3e){
var m=this.data.messages;
var _3f="";
var _40=_3e["categoryInfo"]?true:false;
var _41=_3e["categoryOwner"]?true:false;
var _42=_3e["providerLogo"]?true:false;
if(_40){
_3f+="<p class=\"categoryTooltipHeader\">"+_3e["categoryName"]+"</p>";
_3f+="<p class=\"categoryTooltipBody\">"+_3e["categoryInfo"]+"</p>";
}else{
_3f+="<p class=\"categoryTooltipHeader\">"+_3e["categoryName"]+"</p>";
}
if(_41&&_42){
_3f+="<p class=\"categoryTooltipOwnerText\">";
_3f+="Powered by&nbsp;";
_3f+="<img src=\""+m.LogosFolder+"/"+m.LogosPrefix+_3e["providerLogo"]+m.LogosSuffix+"\" class=\"categoryTooltipOwnerLogo\"/>";
_3f+="</p>";
}
return _3f;
},getNewSegmentsTooltipHtml:function(_43){
var _44="";
_44+="<p class=\"categoryNewSegmentsTooltip\">"+_43["activeNewSegments"]+" New Segments</p>";
return _44;
},getNewCategoryTooltipHtml:function(_45){
var _46="";
_46+="<p class=\"categoryNewCategoryToolti\">";
_46+="<span class=\"categoryNewCategoryNewTooltip\">New!&nbsp;</span>";
_46+="The "+_45["categoryName"]+" category<BR>with "+_45["activeSegments"]+" new segments";
_46+="</p>";
return _46;
},_reloadTab:function(){
this.__reloading=true;
dojo.empty(this.refreshIndicator);
this.refreshIndicator.innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/buyer-dashboard/main-data",content:{segment:this.pages[this._selectedTab].pageType},load:dojo.hitch(this,function(_47){
this.pages[this._selectedTab].refresh(_47);
delete this.__reloading;
dojo.empty(this.refreshIndicator);
}),error:dojo.hitch(this,function(err){
delete this.__reloading;
dojo.empty(this.refreshIndicator);
this.refreshIndicator=err.message;
}),handleAs:"json"});
},reloadCurrentTab:function(){
if(this.__reloading){
return;
}
this.__reloading=true;
this.pages[this._selectedTab].clearGrid();
this._reloadTab();
},onRefresh:function(){
if(this.__reloading){
return;
}
this.__reloading=true;
for(page in this.pages){
if(this.pages[page]){
this.pages[page].clearGrid();
}
}
this._reloadTab();
},onActiveOnly:function(val){
for(page in this.pages){
if(this.pages[page]){
this.pages[page].setActiveOnly(val);
}
}
},onSearch:function(val){
clearTimeout(this.timer);
this.timer=setTimeout(dojo.hitch(this,function(){
val=val.toLowerCase();
for(page in this.pages){
if(this.pages[page]){
this.pages[page].setFilter(val);
}
}
this.searchControl.focus();
}),250);
},_cleanup:function(){
clearTimeout(this.timer);
this.cancelXhr();
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
delete this._connections;
}
for(page in this.pages){
this.pages[page].clearGrid();
dojo.destroy(this.pages[page]);
}
for(pageData in this.pagesData){
delete this.pagesData[pageData];
}
for(category in this.categories){
var _48=this.categories[category]["categoryCode"];
dojo.destroy(dojo.byId("btn_id_"+_48));
}
dojo.destroy(this.tabs);
delete this._selectedTab;
delete this.__selectedTab;
if(this._c){
this._c.destroyRecursive();
}
dojo.empty("divContent");
},destroy:function(){
this._cleanup();
}});
dojo.declare("Px.Ex.BuyerDashboardPage",dijit.layout.ContentPane,{ACTIVE:1,INACTIVE:2,ARCHIVED:3,NOTE_INDICATION_FIELD:"numOfNotes",_VIEW_AFTER_ROW:10,parentContainer:undefined,data:undefined,xhr:undefined,pageType:0,pageTypeName:undefined,active:false,pageData:undefined,_expanded:false,_gridEar:undefined,segmentContainerWidth:200,buyerContainerWidth:100,reloadFn:undefined,doNotChangeTabFn:undefined,constructor:function(_49){
dojo.mixin(this,_49);
this.needReload=true;
this.DEAL_STATUSES=[this.ACTIVE,this.INACTIVE,this.ARCHIVED];
this._animate=true;
this.prepareData();
},getEmptyData:function(){
return {identifier:"segmentId",items:[]};
},prepareData:function(){
if(!this.pageData){
return;
}
var pd=this.pageData;
var pm=this._parentMap={};
var m=this._map={};
var _4a=0;
dojo.forEach(pd,function(v){
if(v.segmentUniqueUsers>_4a){
_4a=v.segmentUniqueUsers;
}
});
_4a=_4a||1;
this.segmentUniqueUsersMax=_4a;
var scw=this.segmentContainerWidth;
var bcw=this.buyerContainerWidth;
var _4b=dojo.hitch(this,"getSegmentCategoryName");
dojo.forEach(pd,function(v){
v.segmentName=v.segmentName||"";
v.segmentCategoryName=_4b(v.segmentCategory);
v.buyerUniqueUsers=v.buyerUniqueUsers||0;
v.last24HoursBuyersShare=(v.last24HoursBuyersShare||0)*100;
v.nameLower=v.segmentName.toLowerCase();
v.segmentBarWidth=Math.round(v.segmentUniqueUsers/_4a*scw);
v.buyerBarWidth=Math.round(v.last24HoursBuyersShare/100*bcw);
var pId=v.segmentParentId;
if(!pm[pId]){
pm[pId]=[];
}
pm[pId].push(v);
m[v.segmentId]=v;
});
var _4c=function(a,b){
return a.nameLower.localeCompare(b.nameLower);
};
if(pm[0]){
this._tree=pm[0];
this._tree.sort(_4c);
}else{
this._tree=[];
}
var x=0;
var _4d=function(a,_4e){
x+=a.length;
var fn=arguments.callee;
dojo.forEach(a,function(v){
v.level=_4e;
var _4f=pm[v.segmentId];
if(_4f){
v.children=_4f;
_4f.sort(_4c);
v.expanded=false;
fn(_4f,_4e+1);
}
});
};
_4d(this._tree,0);
if(x<pd.length){
var a=[];
var f=function(id){
var _50=arguments.callee;
if(!pm[id]){
return;
}
dojo.forEach(pm[id],function(v){
a.push(v.segmentId);
_50(v.segmentId);
});
};
dojo.forEach(pd,function(v){
if(v.segmentParentId!=0&&!m[v.segmentParentId]){
a.push(v.segmentId);
f(v.segmentId);
}
});
a.sort(function(a,b){
return a-b;
});
var ap=dojo.map(a,function(v){
return v+" (parent:"+m[v].segmentParentId+")";
});
var s="[Buyer Dashboard] Wrong "+this.pageTypeName+" data: only "+x+" from "+pd.length+" segments have been used. Orphan segments: "+ap.join(", ");
Px.Ex.Application.showGlobalError(s);
dojo.forEach(a,function(v){
delete pm[v];
delete m[v];
});
}
},startup:function(){
this.inherited(arguments);
this.createContent();
},createContent:function(){
var _51,_52,tr,td,div,c=dojo.create;
_51=c("table",{className:"grid-layout"});
_52=c("tbody",{},_51);
tr=c("tr",{},_52);
td=c("td",{style:{verticalAlign:"top"}},tr);
this._gridEar=c("div",{className:"grid-ear"},td);
this.connect(this._gridEar,"onclick","onExpand");
td=c("td",{style:{verticalAlign:"top",width:"100%"}},tr);
div1=c("div",{},td);
div2=c("div",{id:"underGrid"+this.pageType,className:"under-grid",style:"display:none;"},td);
this.attr("content",_51);
this.createGrid(div1);
},createGrid:function(_53){
this.store=new dojo.data.ItemFileReadStore({clearOnClose:true,data:this.getEmptyData()});
var _54=this._makeGridStructure();
this.grid=new dojox.grid.DataGrid({store:this.store,query:{segmentId:"*"},queryOptions:{ignoreCase:true},clientSort:true,onFetchError:dojo.hitch(this,function(_55,req){
if(!req){
return;
}
this.grid._pending_requests[req.start]=false;
}),"class":"grid",autoHeight:1000,rowsPerPage:1000,selectionMode:"none",canSort:function(_56){
return false;
},onStyleRow:function(_57){
this.edit.styleRow(_57);
},structure:_54},_53);
this.connect(this.grid,"onCellClick",function(e){
if(e.cell.field=="segmentName"){
if(e.target.className=="notesIndicationDBDASH"){
var _58=e.grid.getItem(e.rowIndex);
if(!_58){
return;
}
var _59=e.grid.store.getValue(_58,"dataBuyId");
if(_59){
this.onNotesIndicationClick(_59);
}
}else{
delete this._rowToView;
var _58=e.grid.getItem(e.rowIndex);
if(!_58){
return;
}
var _5a=e.grid.store.getValue(_58,"expanded");
if(_5a!==undefined){
var id=e.grid.store.getIdentity(_58);
if(!_5a){
var chs=this._parentMap[id];
var _5b=(chs&&(chs.length>=this._VIEW_AFTER_ROW)?this._VIEW_AFTER_ROW:chs.length);
this._rowToView=e.rowIndex+_5b;
}else{
this._rowToView=e.rowIndex;
}
this.expandNode(id,!_5a);
}
}
}else{
if(e.cell.field=="dealStatus"){
var _58=e.grid.getItem(e.rowIndex);
if(!_58){
return;
}
if((_58.adminBuyOnly!=undefined)&&(this.data.allow.admin_buy_only!=undefined)&&(_58.adminBuyOnly!=null)&&(this.data.allow.admin_buy_only!=null)){
if((_58.adminBuyOnly[0]==true)&&(this.data.allow.admin_buy_only==false)){
return;
}
}
var suu=e.grid.store.getValue(_58,"segmentUniqueUsers");
if(!suu){
return;
}
var _59=e.grid.store.getValue(_58,"dataBuyId");
if(!_59){
var _5c=e.grid.store.getValue(_58,"segmentId");
this.onBuy(_5c);
}
}
}
});
this.connect(this.grid,"onMouseOverRow",function(e){
var m=this.data.messages;
if(e.cellNode&&e.cell.field=="segmentName"){
this.hideTooltip(e.cellNode);
if(dojo.hasClass(e.target,"new-tooltip")){
dijit.showTooltip(m.tooltipNewSegment||"New Segment",e.cellNode);
}else{
var _5d=e.grid.getItem(e.rowIndex);
if(!_5d){
return;
}
dijit.showTooltip(this.getPriceTooltipMessage(e.grid.store,_5d),e.cellNode);
}
this._tooltipTimer=setTimeout(dojo.hitch(this,"hideTooltip",e.cellNode),2000);
}else{
if(e.cellNode&&e.cell.field=="dealStatus"){
this.hideTooltip(e.cellNode);
var _5d=e.grid.getItem(e.rowIndex);
if(!_5d){
return;
}
var suu=e.grid.store.getValue(_5d,"segmentUniqueUsers");
if(!suu){
return;
}
var _5e=e.grid.store.getValue(_5d,"dataBuyId");
var _5f=e.grid.store.getValue(_5d,"dealStatus");
var msg="";
if(_5e&&(dojo.indexOf(this.DEAL_STATUSES,_5f)>=0)){
msg=(_5f==this.ACTIVE?(m.tooltipActive||"Active Data Buy"):(_5f==this.INACTIVE?(m.tooltipInactive||"Inactive Data Buy"):(m.tooltipArchived||"Archived Data Buy")))+"<br>";
}
msg+=this.getPriceTooltipMessage(e.grid.store,_5d);
dijit.showTooltip(msg,e.cellNode);
this._tooltipTimer=setTimeout(dojo.hitch(this,"hideTooltip",e.cellNode),2000);
}else{
if(e.cellNode&&e.cell.field=="buyerUniqueUsers"){
this.hideTooltip(e.cellNode);
if(dojo.hasClass(e.target,"buyer-text")){
var _5d=e.grid.getItem(e.rowIndex);
if(!_5d){
return;
}
var _60=e.grid.store.getValue(_5d,"lastDeliveryDate");
try{
var d=dojo.date.stamp.fromISOString(_60);
if(d){
_60=dojo.date.locale.format(d,{selector:"date",datePattern:"yyyy-MM-dd"});
}
}
catch(e){
}
var msg=m.tooltipLastDelivered||"Data Buyer uniques during the last 30 days.<br>Last pixel delivered on: ";
msg+=_60?_60:"";
dijit.showTooltip(msg,e.cellNode);
}else{
if(dojo.hasClass(e.target,"buyer-bar")||dojo.hasClass(e.target,"buyer-container")){
var _5d=e.grid.getItem(e.rowIndex);
if(!_5d){
return;
}
var _61=e.grid.store.getValue(_5d,"last24HoursBuyersShare");
var msg=m.tooltipLast24Before||"Buyer share during the last 24 hours<br>was <b>";
msg+=dojo.number.format(_61,{places:2});
msg+=m.tooltipLast24After||"</b>% of the segment inventory";
dijit.showTooltip(msg,e.cellNode);
}
}
this._tooltipTimer=setTimeout(dojo.hitch(this,"hideTooltip",e.cellNode),3000);
}
}
}
});
this.connect(this.grid,"onMouseOutRow",function(e){
if(e.cellNode&&(e.cell.field=="segmentName"||e.cell.field=="dealStatus"||e.cell.field=="buyerUniqueUsers")){
this.hideTooltip(e.cellNode);
}
});
this._addPopupMenu(this.grid);
this.grid.startup();
},_addPopupMenu:function(_62){
_62.connect(_62,"onCellContextMenu",dojo.hitch(this,"showPopupMenu"));
if(!this._handlers){
this._handlers=[];
}
this._handlers.push(dojo.connect(_62.domNode,"onmousemove",this,function(e){
this._pageX=e.pageX;
this._pageY=e.pageY;
}));
_62.connect(_62,"onMouseOverRow",dojo.hitch(this,function(e){
if(e.cellNode&&e.cell.field=="segmentName"){
clearTimeout(this._popupMenuTimer);
if(e.target.nodeName=="SPAN"){
this._popupMenuTimer=setTimeout(dojo.hitch(this,"showPopupMenu",false,e.grid,e.rowIndex),2000);
}
}
}));
_62.connect(_62,"onMouseOutRow",dojo.hitch(this,function(e){
if(e.cellNode&&e.cell.field=="dealName"){
clearTimeout(this._popupMenuTimer);
}
}));
this.popupMenu=new dijit.PopupMenuDialog({"class":"texi-popup-menu-dialog"});
this.popupMenu.startup();
if(dojo.isChrome){
this.popupMenu._openIn(-1000,-1000);
this.popupMenu.close();
}
this.popupMenu.connect(this.popupMenu,"onClose",dojo.hitch(this,function(){
dojo.forEach(this._menuConnections,dojo.disconnect,this);
delete this._menuConnections;
}));
},showPopupMenu:function(e,_63,_64){
clearTimeout(this._popupMenuTimer);
if(e){
_63=e.grid;
_64=e.rowIndex;
dojo.stopEvent(e);
}
if(!this.popupMenu){
return;
}
var _65=_63.getItem(_64);
if(!_65){
return;
}
var _66=_63.store;
var suu=_66.getValue(_65,"segmentUniqueUsers");
if(!suu){
return;
}
var _67=_66.getValue(_65,"dataBuyId");
if(_67===null){
return;
}
var _68=_66.getValue(_65,"dealStatus");
if(dojo.indexOf(this.DEAL_STATUSES,_68)<0){
return;
}
this._selectedSegmentId=_66.getIdentity(_65);
var _69=this.createPopupMenu(_63,_64);
this.popupMenu.attr("content",_69);
if(e&&e.type=="contextmenu"){
this.popupMenu._openMyself(e);
}else{
this.popupMenu._openIn(this._pageX,this._pageY);
}
},createPopupMenu:function(_6a,_6b){
var m=this.data.messages;
var _6c=[{id:"view-buy",title:m.menuViewBuy||"View Data Buy",allow:this.data.allow.data_buy_view},{id:"edit-buy",title:m.menuEditBuy||"Edit Data Buy",allow:this.data.allow.data_buy_edit}];
var row=_6a.getItem(_6b);
var _6d=_6a.store.getValue(row,this.NOTE_INDICATION_FIELD);
var _6e=_6a.store.getValue(row,"dealStatus");
if(_6e==this.INACTIVE||_6e==this.ARCHIVED){
_6c.push({id:"activate",title:m.menuActivate||"Activate",allow:this.data.allow.activate});
}else{
if(_6e==this.ACTIVE){
_6c.push({id:"deactivate",title:m.menuDeactivate||"Deactivate",allow:this.data.allow.deactivate});
}
}
if((_6d!=undefined)&&(_6d!=null)&&(_6d>0)){
_6c.push({id:"notes_show",title:"View Notes",allow:this.data.allow["notes_show"]});
}else{
_6c.push({id:"notes_add",title:"Add A Note",allow:this.data.allow["notes_add"]});
}
var _6f=dojo.create("ul",{className:"texi-popup-menu"});
this._menuConnections=[];
dojo.forEach(_6c,function(v){
var li=dojo.create("li",{innerHTML:v.title,id:v.id,className:v.allow?"":"grayed"},_6f);
if(v.allow){
this._menuConnections.push(dojo.connect(li,"onmouseenter",this,function(e){
dojo.addClass(li,"active");
}));
this._menuConnections.push(dojo.connect(li,"onmouseleave",this,function(e){
dojo.removeClass(li,"active");
}));
this._menuConnections.push(dojo.connect(li,"onclick",this,dojo.hitch(this,"onMenuItemClick")));
}
},this);
return _6f;
},getPriceTooltipMessage:function(_70,_71){
if(!_71){
return "";
}
var m=this.data.messages;
var _72=_70.getValue(_71,"dataBuyId");
var _73=_70.getValue(_71,"priceRate");
var _74=_70.getValue(_71,"priceIncrease");
var _75=_70.getValue(_71,"priceDecrease");
msg=(m.tooltipBeforeRate||"$")+_73+(m.tooltipAfterRate||" CPM");
if(!_72){
if(_74){
msg+=" "+(m.tooltipPriceIncrease||"Price was increased due to high demand");
}else{
if(_75){
msg+=" "+(m.tooltipPriceDecrease||"Special price reduction");
}
}
}
return msg;
},hideTooltip:function(_76){
clearTimeout(this._tooltipTimer);
dijit.hideTooltip(_76);
},_makeGridStructure:function(_77){
var m=this.data.messages;
var _78=this.data.allow.admin_buy_only;
var _79=this.data.allow.notes_show;
var _7a=dojo.hitch(this,function(_7b,_7c){
var _7d=this.grid.getItem(_7c);
if(!_7d){
return "";
}
var _7e=this.grid.store.getValue(_7d,"level");
var _7f=this.grid.store.getValue(_7d,"expanded");
var _80=this.grid.store.getValue(_7d,"dataBuyId");
var _81=this.grid.store.getValue(_7d,"dealStatus");
var _82=this.grid.store.getValue(_7d,"newSegment");
var suu=this.grid.store.getValue(_7d,"segmentUniqueUsers");
var cls="segment-name "+(_7f===undefined?"leaf":(_7f?"expanded":"collapsed"));
if(_80){
cls+=_81==this.ACTIVE?" active":(_81==this.INACTIVE?" inactive":(_81==this.ARCHIVED?" archived":""));
}else{
cls+=" buy";
}
if(this._rowToView!==undefined&&this._rowToView==_7c){
cls+=" to-view";
}
var _83=_7e*15;
_7b==""?_7b="<pre>                                     </pre>":_7b;
retval="<table "+(_80?"id=\"deal_name_"+_80+"\"":"")+">";
retval+="<tbody>";
retval+="<tr>";
retval+="<td style=\"width: 100%;\">";
retval+="<div class=\""+cls+"\" style=\"margin-left:"+_83+"px\">";
retval+="<span>"+_7b+"</span>";
retval+="</div>";
retval+="</td>";
if(this.grid.store.getValue(_7d,this.NOTE_INDICATION_FIELD)&&(this.grid.store.getValue(_7d,this.NOTE_INDICATION_FIELD)>0)&&_79){
retval+="<td>";
retval+="<div class=\"notesIndicationDBDASH\">";
retval+="</div>";
retval+="</td>";
}
if(_82){
retval+="<td>";
retval+="<div class=\"new new-tooltip\">";
retval+="</div>";
retval+="</td>";
}
retval+="</tr>";
retval+="</tbody>";
retval+="</table>";
return retval;
});
var _84=dojo.hitch(this,function(_85,_86){
var _87=this.grid.getItem(_86);
if(!_87){
return "";
}
var suu=this.grid.store.getValue(_87,"segmentUniqueUsers");
if(!suu){
return " ";
}
var _88=this.grid.store.getValue(_87,"adminBuyOnly");
if(_88&&!_78){
return " ";
}
var _89=this.grid.store.getValue(_87,"dataBuyId");
var _8a=this.grid.store.getValue(_87,"dealStatus");
var _8b=this.grid.store.getValue(_87,"priceIncrease");
var _8c=this.grid.store.getValue(_87,"priceDecrease");
var cls="deal-status";
var _8d="price";
if(_89){
cls+=_8a==this.ACTIVE?" active":(_8a==this.INACTIVE?" inactive":(_8a==this.ARCHIVED?" archived":""));
}else{
cls+=" buy";
if(!this.data.allow.data_buy_new){
cls+=" disabled";
}
_8d+=(_8b?" increase":(_8c?" decrease":""));
}
return "<div class=\""+cls+"\">&nbsp;<div class=\""+_8d+"\"></div></div>";
});
var _8e=dojo.hitch(this,function(_8f,_90){
var _91=this.grid.getItem(_90);
if(!_91){
return "";
}
var suu=this.grid.store.getValue(_91,"segmentUniqueUsers");
if(!suu){
return " ";
}
var id=this.grid.store.getIdentity(_91);
var n=_8f;
if(!n){
return "";
}
try{
n=dojo.number.format(n,{pattern:"#,##0"});
}
catch(e){
}
var len=this._animate?0:this._map[id].segmentBarWidth;
return "<div class=\"segment-container\"><div id=\""+id+"\" class=\"segment-bar\" style=\"width:"+len+"px;\">&nbsp;</div></div><div class=\"segment-text\">"+n+"</div>";
});
var _92=dojo.hitch(this,function(_93,_94){
var _95=this.grid.getItem(_94);
if(!_95){
return "";
}
var suu=this.grid.store.getValue(_95,"segmentUniqueUsers");
if(!suu){
return " ";
}
var id=this.grid.store.getIdentity(_95);
var n=_93;
if(!n){
return "";
}
try{
n=dojo.number.format(n,{pattern:"#,##0"});
}
catch(e){
}
var len=this._animate?0:this._map[id].buyerBarWidth;
return "<div class=\"buyer-container\"><div id=\""+id+"\" class=\"buyer-bar\" style=\"width:"+len+"px;\">&nbsp;</div></div><div class=\"buyer-text\">"+n+"</div>";
});
var _96=[{defaultCell:{styles:"white-space:nowrap;",headerStyles:"text-align:center;cursor:pointer;",noresize:true},cells:[{name:m.headerSegment||"Segment",field:"segmentName",formatter:_7a,width:"100%"},{name:m.headerStatus||"Status",field:"dealStatus",formatter:_84,width:"60px",cellStyles:"text-align:center;vertical-align:middle;"},{name:m.headerUniqueUsers||"Unique Users on eXelate eXchange",field:"segmentUniqueUsers",formatter:_8e,width:"300px",cellStyles:"vertical-align:middle;"},{name:m.headerBuyerShare||"Buyer Share",field:"buyerUniqueUsers",formatter:_92,width:"150px",cellStyles:"vertical-align:middle;"}]}];
return _96;
},makeGridData:function(){
if(!this._tree||!this._map){
return this.getEmptyData();
}
var _97=[];
if(this._filteredMap){
var m=this._filteredMap;
var fn=function(a){
var f=arguments.callee;
dojo.forEach(a,function(v){
if(v.segmentId in m){
var ch=v.children;
delete v.children;
_97.push(v);
if(v.expanded){
f(ch);
}
}
});
};
}else{
var fn=function(a){
var f=arguments.callee;
dojo.forEach(a,function(v){
var ch=v.children;
delete v.children;
_97.push(v);
if(v.expanded){
f(ch);
}
});
};
}
fn(dojo.clone(this._tree));
return {identifier:"segmentId",items:_97};
},updateGrid:function(){
var _98=dijit._curFocus;
this.store.close();
this.store._jsonData=this.makeGridData();
this.store.fetch();
this.updateGridEar();
setTimeout(dojo.hitch(this,function(){
try{
this.grid._refresh.call(this.grid,true);
if(this.grid.domNode.clientHeight<223){
var _99=223-this.grid.domNode.clientHeight;
dojo.style(dojo.byId("underGrid"+this.pageType),"display","block");
dojo.style(dojo.byId("underGrid"+this.pageType),"height",_99+"px");
}else{
dojo.style(dojo.byId("underGrid"+this.pageType),"display","none");
}
var nl=dojo.query(".to-view",this.grid.domNode);
if(nl[0]){
dojo.removeClass(nl[0],"to-view");
setTimeout(function(){
dijit.scrollIntoView(nl[0]);
},20);
}
}
catch(e){
}
}),10);
if(this._animate){
setTimeout(dojo.hitch(this,function(){
(dojo.hitch(this.grid,"_refresh",true))();
setTimeout(dojo.hitch(this,function(){
this._animateBars("segment-bar","segmentBarWidth");
this._animateBars("buyer-bar","buyerBarWidth");
this._animate=false;
dijit.focus(_98);
}),20);
}),20);
}
},_animateBars:function(_9a,_9b){
var _9c=this._animate;
var m=this._map;
dojo.query("."+_9a,this.grid.domNode).forEach(function(v){
var _9d=m[v.id];
if(!_9d){
return;
}
var len=_9d[_9b];
if(_9c){
dojo.anim(v,{width:len},1500);
}else{
dojo.style(v,{width:len+"px"});
}
},this);
},isNeedUpdateGrid:function(){
if(this._oldFilter&&!!this._oldFilter.activeOnly==!!this._activeOnly&&this._oldFilter.searchString==this._searchString){
return false;
}
return true;
},setActive:function(_9e){
if(this.active&&!_9e){
this._oldFilter={activeOnly:!!this._activeOnly,searchString:this._searchString};
}
this.active=_9e;
if(this.active){
if(this.isNeedUpdateGrid()){
this._doFilter();
}else{
if(parseInt(dojo.getComputedStyle(this.grid.viewsHeaderNode).height)==0){
this._doFilter();
}
}
}
},clearGrid:function(){
delete this._tree;
delete this._filteredMap;
delete this._oldFilter;
this.updateGrid();
this._expanded=false;
dojo.toggleClass(this._gridEar,"collapse",this._expanded);
this.needReload=true;
},refresh:function(_9f){
this.needReload=false;
this._animate=true;
if(_9f.messages){
this.data.messages=_9f.messages;
}
this.data[this.pageType]=_9f[this.pageType];
this.pageData=this.data[this.pageType];
delete this._oldFilter;
delete this._tree;
delete this._filteredMap;
this.prepareData();
this._doFilter();
},setActiveOnly:function(_a0){
this._activeOnly=_a0;
this._doFilter();
},setFilter:function(val){
if(!val.length){
delete this._searchString;
}else{
this._searchString=val;
}
this._doFilter();
},_doFilter:function(){
if(this.active){
delete this._oldFilter;
if(this._activeOnly||this._searchString){
this.makeFilteredMap();
}else{
delete this._filteredMap;
}
setTimeout(dojo.hitch(this,"updateGrid"),20);
}
},expandNode:function(id,_a1){
this._map[id].expanded=_a1;
setTimeout(dojo.hitch(this,"updateGrid"),20);
},makeFilteredMap:function(){
var m=this._map;
var _a2={};
var _a3=this._activeOnly;
var str=(this._searchString!==undefined?this._searchString:"");
for(var id in m){
if(id in _a2){
continue;
}
var _a4=m[id];
if((_a3&&_a4.dataBuyId&&_a4.dealStatus==this.ACTIVE)||!_a3){
if(!str.length||(_a4.nameLower.indexOf(str)>=0)){
_a2[id]=_a4;
if(_a4.children&&!_a4.expanded){
_a4.expanded=true;
}
var _a5=_a4.segmentParentId;
while(_a5&&(!(_a5 in _a2))){
_a4=m[_a5];
_a2[_a5]=_a4;
if(!_a4.expanded){
_a4.expanded=true;
}
_a5=_a4.segmentParentId;
}
}
}
}
this._filteredMap=_a2;
},_expandTree:function(_a6){
for(var id in this._map){
var _a7=this._map[id];
if(_a7.children&&_a7.expanded!=_a6){
_a7.expanded=_a6;
}
}
},_allTopCollapsed:function(){
return dojo.every(this._parentMap[0],function(v){
return !v.expanded;
});
},_allExpanded:function(){
for(var id in this._parentMap){
if(id==0){
continue;
}
var _a8=this._map[id];
if(!_a8.expanded){
return false;
}
}
return true;
},updateGridEar:function(){
try{
if(this._allTopCollapsed()){
this._expanded=false;
}else{
if(this._allExpanded()){
this._expanded=true;
}
}
dojo.toggleClass(this._gridEar,"collapse",this._expanded);
}
catch(e){
}
},onExpand:function(){
this._expanded=!this._expanded;
dojo.toggleClass(this._gridEar,"collapse",this._expanded);
this._expandTree(this._expanded);
setTimeout(dojo.hitch(this,"updateGrid"),20);
},onBuy:function(_a9){
if(!this.data.allow.data_buy_new){
return;
}
var dlg=new Px.Ex.BuyDialog({buyer:dojo.clone(this.data.buyer),data:dojo.clone(this._map[_a9]),messages:this.data.dialogMessages,templates:dojo.clone(this.data.templates),allow:this.data.allow,closeCallback:dojo.hitch(this,function(_aa,_ab,_ac){
this.reloadFn();
if(_ab==this.ACTIVE){
this.sendConfirmationEmail(_ac);
}
})});
dlg.show();
},onMenuItemClick:function(e){
var _ad=e.target.id;
this.popupMenu.close();
dojo.removeClass(e.target,"active");
if(_ad=="view-buy"||_ad=="edit-buy"){
var _ae={buyer:dojo.clone(this.data.buyer),data:dojo.clone(this._map[this._selectedSegmentId]),messages:this.data.dialogMessages,templates:dojo.clone(this.data.templates),allow:this.data.allow,closeCallback:dojo.hitch(this,function(_af,_b0,_b1){
this.reloadFn();
if((_b0==this.ACTIVE)&&(_af>0)&&(_af!=_b0)){
this.sendConfirmationEmail(_b1);
}
})};
if(_ad=="view-buy"){
_ae.viewOnly=true;
}else{
if(_ad=="edit-buy"){
}
}
var dlg=new Px.Ex.BuyDialog(_ae);
dlg.show();
}else{
if(_ad=="activate"||_ad=="deactivate"){
this.doNotChangeTabFn(true);
var _b2=(_ad=="activate"?this.ACTIVE:this.INACTIVE);
var _b3=this._map[this._selectedSegmentId].dataBuyId;
this.xhr({url:"/buyer-dashboard/set-data-deal-status",content:{dealCode:_b3,status:_b2},load:dojo.hitch(this,"setStatusResponse",_ad),error:dojo.hitch(this,"doNotChangeTabFn",false),handleAs:"json"});
}else{
if(_ad=="notes_show"||_ad=="notes_add"){
this.onNotesIndicationClick(this._map[this._selectedSegmentId].dataBuyId);
}
}
}
},onNotesIndicationClick:function(_b4){
if(_b4){
var _b5;
dojo.xhrGet({sync:true,url:"/notes/get-data-deal-notes",content:{dataDealCode:_b4},load:dojo.hitch(this,function(_b6){
_b5=_b6;
}),error:dojo.hitch(this,function(_b7){
_b5=_b7;
}),handleAs:"json"});
if(_b5.notes){
var _b8=dojo.coords(dojo.byId("deal_name_"+_b4).parentNode);
new Px.Ex.DataDealNotes.NotesWidgetDialog({teXiServerResponse:_b5,addPermission:this.data.allow["notes_add"],x:_b8.x+_b8.w,y:_b8.y}).show();
}
}
},setStatusResponse:function(_b9,_ba){
this.doNotChangeTabFn(false);
if(_ba["return"]&&_ba["return"].success){
this.reloadFn();
}else{
var msg=_b9+": ";
msg+=(_ba["return"]&&_ba["return"].errorMessage)?_ba["return"].errorMessage:dojo.toJson(_ba);
this._showMsgDialog(msg);
}
},_showMsgDialog:function(msg,_bb){
return Px.Ex.Application.showMsgDialog(msg,_bb);
},sendConfirmationEmail:function(_bc){
this.xhr({url:"/direct-data-deals/send-confirmation-email",content:{dealCode:_bc},handleAs:"json"});
},getSegmentCategoryName:function(_bd){
try{
var _be=this.data.categories["return"]["categories"];
for(category in _be){
if(_be[category]["categoryCode"]==_bd){
return (_be[category]["categoryName"]);
}
}
return "undefined";
}
catch(e){
return "undefined";
}
},destroy:function(){
clearTimeout(this._popupMenuTimer);
if(this._menuConnections){
dojo.forEach(this._menuConnections,dojo.disconnect,this);
}
if(this.popupMenu){
try{
this.popupMenu.destroyRecursive();
}
catch(e){
}
}
this.inherited(arguments);
}});
dojo.declare("Px.Ex.BuyDialog",[Px.Ex.Dialog],{VALIDATION_INTERVAL:1000,CPM_ID:3,BUY_NAME_I:0,DATES_I:1,DELIVERY_I:2,DEFINE_PIXEL_I:3,APPROVAL_I:4,"class":"buy-dialog",viewOnly:false,masterDiv:undefined,indicatorDiv:undefined,errorDiv:undefined,buttons:undefined,data:undefined,buyer:undefined,messages:{},templates:undefined,defaultTemplates:undefined,closeCallback:undefined,_connections:[],previousBuyStatus:-1,_savedBuyStatus:-1,isCreate:false,dbStartDate:undefined,dbEndDate:undefined,shouldSaveStartDate:false,shouldSaveEndDate:false,constructor:function(_1){
dojo.mixin(this,_1);
this.defaultTemplates=this.templates;
var m=this.messages;
this.buttonClose=m.buttonClose||this.buttonClose;
this.rotationImage=Px.Ex.Application.getWaitImageUrl();
this.PROGRESS_LIST_SHORT=[{label:m.listBuyName||"Data Buy Name",className:"opened",progress:0,div:undefined},{label:m.listDates||"Dates",className:"closed",progress:1,div:undefined},{label:m.listDelivery||"Delivery",className:"closed",progress:1,div:undefined},{label:m.listDefinePixel||"Define Pixel",className:"opened",progress:0,div:undefined}];
this.PROGRESS_LIST=this.PROGRESS_LIST_SHORT.concat({label:m.listApproval||"Approval",className:"opened",progress:0,div:undefined});
this.EMPTY_BUY={asapDelivery:true,billingPrice:this.data.priceRate,billingType:this.CPM_ID,buyerCode:this.buyer.buyerID,dataBuyCode:null,dataBuyName:null,dataBuyPixel:null,dataBuyStatus:2,end:null,monthlyDelivery:false,segmentId:this.data.segmentId,start:null,uniqueUsersTarget:0,usOnly:false,dataBuyTemplateCode:this.buyer.templateCode};
this.buy=undefined;
this.NOW=new Date();
this.NOW.setHours(0,0,0,0);
},dealToBuy:function(_2){
if(!_2){
return {};
}
var _3={asapDelivery:true,billingPrice:this.data.priceRate,billingType:_2.priceTypeCode,buyerCode:_2.buyerCode,dataBuyCode:_2.dealCode,dataBuyName:_2.dealName,dataBuyPixel:_2.pixelData,dataBuyStatus:_2.dealStatus,end:_2.end,monthlyDelivery:_2.monthlyDeliveryIndication,segmentId:this.data.segmentId,start:_2.start,uniqueUsersTarget:_2.uniqueUsers,usOnly:_2.usOnly,dataBuyTemplateCode:_2.templateCode};
return _3;
},startup:function(){
this.inherited(arguments);
var _4=(this.data&&this.data.dataBuyId)?(this.viewOnly?Px.Ex.Application.Titles.BUY_DETAILS:Px.Ex.Application.Titles.EDIT_BUY):Px.Ex.Application.Titles.NEW_BUY;
if(_4==Px.Ex.Application.Titles.NEW_BUY){
this.isCreate=true;
this.shouldSaveStartDate=true;
this.shouldSaveEndDate=true;
}else{
this.isCreate=false;
}
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(_4);
this._createLayout();
removeWidget("buyMaster");
this.master=new dijit.layout.StackContainer({id:"buyMaster"},this.masterDiv);
this.progressBar=new Px.Ex.ProgressBar({width:100,maximum:this.PROGRESS_LIST_SHORT.length,progress:0}).placeAt(this.indicatorDiv);
dojo.forEach(this.PROGRESS_LIST_SHORT,function(v,i){
this.PROGRESS_LIST[i].div=dojo.create("div",{className:"progress-list-item "+v.className,innerHTML:v.label},this.indicatorDiv);
},this);
this.showProgress();
this.showRotation(true);
this.xhr({content:{dataBuyId:this.data.dataBuyId},url:"/buyer-dashboard/dialog",load:dojo.hitch(this,"createContent"),error:dojo.hitch(this,"showXhrError"),handleAs:"json"});
},_createLayout:function(){
var m=this.messages;
var _5,_6,tr,td,_7,c=dojo.create;
_5=c("table",{className:"buy-dialog-layout"},this.containerNode);
_6=c("tbody",{},_5);
tr=c("tr",{},_6);
td=c("td",{className:"border-right border-bottom",innerHTML:"&nbsp;"},tr);
td=c("td",{className:"border-bottom"},tr);
_7=c("div",{className:"progress-label",innerHTML:m.labelPrecessCompletion||"Process completion"},td);
tr=c("tr",{},_6);
td=c("td",{className:"border-right border-bottom main-layout"},tr);
this.masterDiv=c("div",{className:"master-div"},td);
td=c("td",{className:"border-bottom indicator-layout"},tr);
this.indicatorDiv=c("div",{},td);
this.errorDiv=c("div",{className:"centre texi-error-text texi-dialog-error-text"},this.containerNode);
_7=c("div",{className:"centre"},this.containerNode);
this.buttons={};
_5=c("table",{className:"buttons-layout"},this.containerNode);
_6=c("tbody",{},_5);
tr=c("tr",{},_6);
if(this.viewOnly){
td=c("td",{},tr);
this.buttons.next=c("div",{className:"button-next",tabindex:-1},td);
this.buttons.prev=c("div",{className:"button-prev",style:{display:"none"},tabindex:-1},td);
}else{
td=c("td",{},tr);
this.buttons.reset=c("div",{className:"button-reset",tabindex:-1},td);
td=c("td",{},tr);
c("div",{className:"spacer-h-big"},td);
td=c("td",{},tr);
this.buttons.save1=c("div",{className:"button-save",style:{display:"none"},tabindex:-1},td);
this.buttons.save1_disabled=c("div",{className:"button-save-disabled",tabindex:-1},td);
this.buttons.prev=c("div",{className:"button-prev",style:{display:"none"},tabindex:-1},td);
td=c("td",{},tr);
c("div",{className:"spacer-h-small"},td);
td=c("td",{},tr);
this.buttons.next=c("div",{className:"button-next",tabindex:-1},td);
this.buttons.save2=c("div",{className:"button-save",style:{display:"none"},tabindex:-1},td);
this.buttons.save2_disabled=c("div",{className:"button-save-disabled",style:{display:"none"},tabindex:-1},td);
td=c("td",{},tr);
c("div",{className:"spacer-h-big"},td);
td=c("td",{},tr);
this.buttons.done_disabled=c("div",{className:"button-done-disabled",tabindex:-1},td);
this.buttons.done=c("div",{className:"button-done",style:{display:"none"},tabindex:-1},td);
}
},createContent:function(_8){
if(_8.notes&&_8.notes.notes){
if(this.allow["notes_show"]){
this._notesButton=dojo.create("div",{className:"notesButtonDataBuy"},this.indicatorDiv);
if(_8.notes.notes.length==0){
dojo.toggleClass(this._notesButton,"notesButtonNone");
}
this._connections.push(dojo.connect(this._notesButton,"onclick",dojo.hitch(this,function(){
if(!this._notesWidgetDiv){
this._notesWidgetDiv=dojo.create("div",{className:"notesWidgetDataBuy"},this.indicatorDiv);
this._notesWidget=new Px.Ex.DataDealNotes.NotesWidgetWizard({addPermission:this.allow["notes_add"],teXiServerResponse:_8.notes,Height:448,onBeforeCloseCallback:dojo.hitch(this,function(){
if(this._notesWidget.getNotesScrollableArea().countNotes()>1){
dojo.toggleClass(this._notesButton,"notesButtonNone",false);
}
return true;
}),onAfterCloseCallback:dojo.hitch(this,function(){
delete this._notesWidgetDiv;
})});
this._notesWidget.placeAt(this._notesWidgetDiv);
this._notesWidget.startup();
}
})));
}
}
this.NOW=dojo.date.stamp.fromISOString(_8.now);
this.NOW.setHours(0,0,0,0);
this.showRotation(false);
if(_8.dataBuy){
this.buy=this.dealToBuy(_8.dataBuy);
if(this.buy.start){
this.buy.start=dojo.date.stamp.fromISOString(this.buy.start);
this.buy.start.setHours(0,0,0,0);
}
if(this.buy.end){
this.buy.end=dojo.date.stamp.fromISOString(this.buy.end);
this.buy.end.setHours(0,0,0,0);
}
if(_8.templates&&_8.templates.length>0){
this.templates=_8.templates;
}
}
this.page1=new Px.Ex.BuyDialog.Page1({dialog:this});
this.page2=new Px.Ex.BuyDialog.Page2({dialog:this});
this.master.addChild(this.page1);
this.master.addChild(this.page2);
this.master.startup();
this._position();
this._subscribtions=[];
this._subscribtions.push(dojo.subscribe("buyMaster-selectChild",this,"pageChanged"));
this.connect(this.buttons.next,"onclick","showNextPage");
this.connect(this.buttons.prev,"onclick","showPrevPage");
if(!this.viewOnly){
this.connect(this.buttons.reset,"onclick","resetPage");
var _9=dojo.hitch(this,function(e){
this.savePage();
});
this.connect(this.buttons.save1,"onclick",_9);
this.connect(this.buttons.save2,"onclick",_9);
this.connect(this.buttons.done,"onclick","onDone");
}
this.firstFocus();
this.startValidating();
if(!this.isCreate){
this.dbStartDate=this.buy.start;
this.dbEndDate=this.buy.end;
}
},startValidating:function(){
this._validationTimer=setInterval(dojo.hitch(this,"validateAndShow"),this.VALIDATION_INTERVAL);
},stopValidating:function(){
clearInterval(this._validationTimer);
},validateAndShow:function(){
var n=0,_a;
_a=this.isValidArray([this.page1.buyName]);
if(_a){
++n;
}
this.setProgressItemState(this.BUY_NAME_I,_a?"closed":"opened");
_a=this.isValidArray([this.page1.startDate,this.page1.endDate]);
if(_a){
++n;
}
this.setProgressItemState(this.DATES_I,_a?"closed":"opened");
_a=this.isValidArray([this.page1.uniqueUsers,this.page1.deliveryPeriod]);
if(_a){
++n;
}
this.setProgressItemState(this.DELIVERY_I,_a?"closed":"opened");
_a=this.isValidArray([this.page2]);
if((this.buyer.templateCode)&&((!this.templates)||(this.templates.length==0))){
_a=true;
}
if(_a){
++n;
}
this.page2.showError(!_a);
this.setProgressItemState(this.DEFINE_PIXEL_I,_a?"closed":"opened");
_a=this.page2.isValidApproval();
if(_a){
++n;
}
this.setProgressItemState(this.APPROVAL_I,_a?"closed":"opened");
this.enableSaveAndDone(n==this.PROGRESS_LIST.length);
},showXhrError:function(_b,_c){
this.showRotation(false);
this.stopClosing(false);
this._showErrorMessage(_b,_c);
},_showErrorMessage:function(_d,_e){
var _f=Px.Ex.Application._extractError(_d,_e);
_f=_f.replace(/\<br\>/ig,"&nbsp;");
this.errorDiv.innerHTML=_f;
this._xhrErrorTimer=setTimeout(dojo.hitch(this,"clearXhrError"),5000);
},clearXhrError:function(){
dojo.empty(this.errorDiv);
clearTimeout(this._xhrErrorTimer);
delete this._xhrErrorTimer;
},setProgressItemState:function(i,_10){
var _11=this.PROGRESS_LIST[i];
if(!_11){
return;
}
if(_10=="opened"){
_11.progress=0;
}else{
_11.progress=1;
}
var div=this.PROGRESS_LIST[i].div;
if(!div||dojo.hasClass(div,_10)){
return;
}
dojo.removeClass(div,"closed");
dojo.removeClass(div,"opened");
dojo.removeClass(div,"default");
dojo.addClass(div,_10);
this.showProgress();
},showProgress:function(){
var p=0;
dojo.forEach(this.PROGRESS_LIST_SHORT,function(v){
p+=v.progress;
});
this.progressBar.showProgress(p);
},showNextPage:function(e){
this.clearXhrError();
if(!this._lastPage){
if(this.viewOnly){
this.master.forward();
}else{
if(!this.validateWidgets(this.page1)){
return;
}
this.master.forward();
}
}
},showPrevPage:function(e){
this.clearXhrError();
if(!this._firstPage){
if(this.viewOnly){
this.master.back();
}else{
this.master.back();
}
}
},enableSaveAndDone:function(_12){
if(this.viewOnly){
return;
}
var p=this.master.selectedChildWidget;
var _13=(p==this.page1?this.buttons.save1:this.buttons.save2);
var _14=(p==this.page1?this.buttons.save1_disabled:this.buttons.save2_disabled);
dojo.forEach([this.buttons.done_disabled,_14],function(v){
dojo.style(v,"display",_12?"none":"");
});
dojo.forEach([this.buttons.done,_13],function(v){
dojo.style(v,"display",_12?"":"none");
});
},pageChanged:function(_15){
this._lastPage=(_15===this.page2);
this._firstPage=(_15===this.page1);
if(_15===this.page2){
if(!_15._innerTabsCreated){
_15.createInnerTabs();
_15._innerTabsCreated=true;
}
if(!this.viewOnly){
dojo.forEach([this.buttons.save1_disabled,this.buttons.save1,this.buttons.save2],function(v){
dojo.style(v,"display","none");
});
dojo.forEach([this.buttons.save2_disabled],function(v){
dojo.style(v,"display","");
});
}
dojo.forEach([this.buttons.next],function(v){
dojo.style(v,"display","none");
});
dojo.forEach([this.buttons.prev],function(v){
dojo.style(v,"display","");
});
}else{
if(_15===this.page1){
if(!this.viewOnly){
dojo.forEach([this.buttons.save1_disabled],function(v){
dojo.style(v,"display","");
});
dojo.forEach([this.buttons.save2_disabled,this.buttons.save1,this.buttons.save2],function(v){
dojo.style(v,"display","none");
});
}
dojo.forEach([this.buttons.next],function(v){
dojo.style(v,"display","");
});
dojo.forEach([this.buttons.prev],function(v){
dojo.style(v,"display","none");
});
}
}
this.validateAndShow();
},resetPage:function(){
this.clearXhrError();
var p=this.master.selectedChildWidget;
this.resetWidgets(p);
},_getDirtyAttr:function(){
if(this.viewOnly||!this.master){
return false;
}
return this.isDirty(this.page1)||this.isDirty(this.page2);
},validateAll:function(){
this.validateAndShow();
var s=0;
dojo.forEach(this.PROGRESS_LIST,function(v){
s+=v.progress;
});
return s==this.PROGRESS_LIST.length;
},savePage:function(_16,_17){
this.clearXhrError();
if(!this.validateAll()){
return;
}
if(!this.attr("dirty")){
if(_16){
_16();
}
return;
}
var o=this.getValueObject(this);
var _18=null;
if(o.start){
this.dbStartDate=new Date(o.start);
o.start=dojo.date.stamp.toISOString(o.start,{zulu:false,milliseconds:false}).slice(0,19);
}
if(o.end){
this.dbEndDate=new Date(o.end);
o.end=dojo.date.stamp.toISOString(o.end,{zulu:false,milliseconds:false}).slice(0,19);
o.end=o.end.replace("00:00:00","23:59:59");
}
o.dataBuyPixel=this.page2.getPixelData();
if(o.dataBuyPixel){
o.dataBuyTemplateCode=null;
}else{
this._templatesBeforeSave=dojo.clone(this.templates);
this.page2.page1.updateTemplatesData();
_18=this.templates;
}
if(o.uniqueUsersMax||!o.uniqueUsersTarget){
o.uniqueUsersTarget=0;
}
if(!o.uniqueUsersMax&&o.deliveryPeriod=="monthly"){
o.monthlyDelivery=true;
}else{
if(!o.uniqueUsersMax&&o.deliveryPeriod=="total"){
o.monthlyDelivery=false;
}
}
delete o.uniqueUsersMax;
delete o.deliveryPeriod;
if(o.activate){
o.dataBuyStatus=1;
}else{
o.dataBuyStatus=2;
}
delete o.activate;
if(!this.buy||!this.buy.dataBuyCode){
o=dojo.mixin({},this.EMPTY_BUY,o);
this.buy=o;
}else{
this._buyBeforeSave=dojo.clone(this.buy);
o=dojo.mixin(this.buy,o);
}
if(!this.shouldSaveStartDate){
o.start=null;
}
if(!this.shouldSaveEndDate){
o.end=null;
}
this.stopClosing(true);
this.showRotation(true);
this.xhr({url:"/buyer-dashboard/edit-buy",content:{buy:dojo.toJson(o),templates:dojo.toJson(_18)},load:dojo.hitch(this,"buySaved",_16),error:dojo.hitch(this,"showXhrError"),handleAs:"json"});
if(_16){
_16();
}
this.isCreate=false;
this.shouldSaveEndDate=false;
this.shouldSaveStartDate=false;
},buySaved:function(_19,_1a,_1b){
this._buySaved=true;
this.showRotation(false);
this.stopClosing(false);
var _1c=false;
if(_1a.dataBuyCode!==undefined){
if(!_1a.dataBuyCode){
_1c=true;
_1a=_1a.buyResult;
this._showErrorMessage(_1a,_1b);
this.buy=this._buyBeforeSave;
this.templates=this._templatesBeforeSave;
this.page2.page1.updateTemplateFields();
}
if(_1a.dataBuyCode&&this.buy){
this.buy.dataBuyCode=_1a.dataBuyCode;
var tr=_1a.templatesResult;
if(tr){
if(tr["return"]){
tr=tr["return"];
}
if(!tr.success){
_1c=true;
this._showErrorMessage(_1a,_1b);
this.templates=this._templatesBeforeSave;
this.page2.page1.updateTemplateFields();
}
}
this._savedBuyStatus=this.buy.dataBuyStatus;
this._updateWidgetsForReset();
}
}else{
var msg;
var d=_1a;
_1a=d["buyResult"];
if(_1a["return"]){
_1a=_1a["return"];
}
if(!_1a.success){
_1c=true;
this._showErrorMessage(_1a,_1b);
this.buy=this._buyBeforeSave;
}
if(_1a.success){
this._savedBuyStatus=this.buy.dataBuyStatus;
_1a=d["templatesResult"];
if(_1a){
if(_1a["return"]){
_1a=_1a["return"];
}
if(!_1a.success){
_1c=true;
this._showErrorMessage(_1a,_1b);
this.templates=this._templatesBeforeSave;
this.page2.page1.updateTemplateFields();
}
}
this._updateWidgetsForReset();
}
}
delete this._buyBeforeSave;
try{
delete this._templatesBeforeSave;
}
catch(e){
}
if(!_1c&&_19){
_19();
}
},_updateWidgetsForReset:function(){
this.updateWidgetsForReset(this);
},onDone:function(){
this.savePage(dojo.hitch(this,function(){
this.onExecute();
}));
},beforeDestroy:function(){
if(this._buySaved&&this.closeCallback){
this.closeCallback(this.data.dealStatus,this._savedBuyStatus,this.buy.dataBuyCode);
}
},destroy:function(){
this.stopValidating();
this.cancelXhr();
dojo.forEach(this._subscribtions,dojo.unsubscribe,this);
dojo.forEach(this._connections,dojo.disconnect,this);
this.clearXhrError();
this.inherited(arguments);
}});
dojo.declare("Px.Ex.BuyDialog.Page1",[dijit.layout.ContentPane],{"class":"page1",dialog:undefined,startup:function(){
this.inherited(arguments);
this.createContent();
},createContent:function(){
var m=this.dialog.messages,_1d=this.dialog.data,_1e=this.dialog.buyer,buy=this.dialog.buy,NOW=this.dialog.NOW,_1f=this.dialog.viewOnly,_20,_21,tr,td,div,s,c=dojo.create;
_20=c("table",{className:"page1-layout"});
this.attr("content",_20);
_21=c("tbody",{},_20);
tr=c("tr",{},_21);
td=c("td",{className:"layout"},tr);
div=c("div",{className:"label",innerHTML:m.labelBuyerName||"Buyer Name"},td);
td=c("td",{style:{width:"100%"},className:"layout"},tr);
div=c("div",{className:"data",innerHTML:_1e.buyerName},td);
tr=c("tr",{},_21);
td=c("td",{colSpan:2},tr);
div=c("div",{className:"spacer-v"},td);
tr=c("tr",{},_21);
td=c("td",{className:"layout"},tr);
div=c("div",{className:"label",innerHTML:m.labelCategoryName||"Category Name"},td);
td=c("td",{style:{width:"100%"},className:"layout"},tr);
div=c("div",{className:"data",innerHTML:_1d.segmentCategoryName},td);
tr=c("tr",{},_21);
td=c("td",{colSpan:2},tr);
div=c("div",{className:"spacer-v"},td);
tr=c("tr",{},_21);
td=c("td",{className:"layout"},tr);
div=c("div",{className:"label",innerHTML:m.labelSegmentName||"Segment Name"},td);
td=c("td",{style:{width:"100%"},className:"layout"},tr);
div=c("div",{className:"data",innerHTML:_1d.segmentName},td);
tr=c("tr",{},_21);
td=c("td",{colSpan:2},tr);
div=c("div",{className:"spacer-v"},td);
tr=c("tr",{},_21);
td=c("td",{className:"layout"},tr);
div=c("div",{className:"label",innerHTML:m.labelCPMRate||"CPM Rate"},td);
td=c("td",{style:{width:"100%"},className:"layout"},tr);
c("span",{className:"data",innerHTML:m.beforeCPMRate||"$ "+dojo.number.format(_1d.priceRate,{places:2})},td);
var _22=(_1d.segmentUniqueUsers||0)/1000,_23="K";
if(_22>=1000){
_22=_22/1000;
_23="M";
}
s=(m.beforeEstimatedUniques||" (Estimated Monthly Volume: ")+dojo.number.format(_22,{places:1})+_23+(m.afterEstimatedUniques||" Unique Users)");
c("span",{className:"label-normal",innerHTML:s},td);
tr=c("tr",{},_21);
td=c("td",{colSpan:2},tr);
div=c("div",{className:"spacer-v"},td);
div=c("div",{className:"border-bottom"},td);
div=c("div",{className:"spacer-v"},td);
tr=c("tr",{},_21);
td=c("td",{className:"layout"},tr);
c("label",{className:"label","for":"buyDialogBuyNameId",innerHTML:m.labelBuyName||"Data Buy Name"},td);
td=c("td",{style:{width:"100%"},className:"layout"},tr);
removeWidget("buyDialogBuyNameId");
this.buyName=new Px.Ex.ValidationTextBox({maxLength:50,required:true,trim:true,readOnly:_1f,value:buy?buy.dataBuyName:"",regExp:Px.Ex.Application.Patterns.NAME_STR,invalidMessage:m.invalidByName||"$_unset_$",emptyMessage:m.emptyByName||"$_unset_$",promptMessage:m.promptByName||"","class":"field-buy-name",name:"dataBuyName",id:"buyDialogBuyNameId"});
this.buyName.placeAt(td);
tr=c("tr",{},_21);
td=c("td",{colSpan:2},tr);
div=c("div",{className:"spacer-v"},td);
tr=c("tr",{},_21);
td=c("td",{className:"layout"},tr);
div=c("div",{className:"label",innerHTML:m.labelDeliveryDates||"Delivery Dates"},td);
td=c("td",{style:{width:"100%"}},tr);
tr=c("tr",{},_21);
td=c("td",{colSpan:2,className:"layout"},tr);
c("label",{className:"label-normal","for":"buyDialogStartDateId",innerHTML:m.labelStartDate||"Start Date"},td);
var _24=true;
retries=0;
while(_24&&retries<100){
try{
removeWidget("buyDialogStartDateId");
this.startDate=new Px.Ex.DateTextBoxWithIcon({required:true,value:buy?buy.start:NOW,readOnly:_1f,disabled:!!(buy&&buy.dataBuyCode&&buy.start&&(buy.start<NOW)),constraints:{min:NOW},invalidMessage:m.invalidStart||"$_unset_$",emptyMessage:m.emptyStart||"$_unset_$",promptMessage:m.promptStart||"","class":"field-start-date",name:"start",id:"buyDialogStartDateId",onChange:dojo.hitch(this,function(val){
this.endDate.constraints.min=val;
this.endDate.validate();
if(!this.dialog.isCreate){
if((val)&&(typeof val=="object")){
if(this.dialog.dbStartDate){
this.dialog.shouldSaveStartDate=(val-this.dialog.dbStartDate==0?false:true);
}else{
this.dialog.shouldSaveStartDate=true;
}
}else{
if(val==null){
if(this.dialog.dbStartDate==null){
this.dialog.shouldSaveStartDate=false;
}else{
this.dialog.shouldSaveStartDate=true;
}
}
}
}
})});
_24=false;
}
catch(e){
_24=true;
retries++;
}
}
this.startDate.placeAt(td);
c("label",{className:"label-normal","for":"buyDialogEndDateId",innerHTML:m.labelEndDate||"End Date"},td);
var fn=dojo.hitch(this,function(){
var d=this.startDate.attr("value");
if(!d){
d=NOW;
}
return d;
});
_24=true;
retries=0;
while(_24&&retries<100){
try{
removeWidget("buyDialogEndDateId");
this.endDate=new Px.Ex.CustomizedDateTextBox({required:false,getEmptyDate:fn,value:buy?buy.end:null,readOnly:_1f,constraints:{min:buy?buy.start:NOW},invalidMessage:m.invalidEnd||"$_unset_$",emptyMessage:m.emptyEnd||"$_unset_$",promptMessage:m.promptEnd||"","class":"field-end-date",name:"end",id:"buyDialogEndDateId",onChange:dojo.hitch(this,function(val){
if(!this.dialog.isCreate){
if((val)&&(typeof val=="object")){
if(this.dialog.dbEndDate){
this.dialog.shouldSaveEndDate=(val-this.dialog.dbEndDate==0?false:true);
}else{
this.dialog.shouldSaveEndDate=true;
}
}else{
if(val==null){
if(this.dialog.dbEndDate==null){
this.dialog.shouldSaveEndDate=false;
}else{
this.dialog.shouldSaveEndDate=true;
}
}
}
}
})});
_24=false;
}
catch(e){
_24=true;
retries++;
}
}
this.endDate.placeAt(td);
tr=c("tr",{},_21);
td=c("td",{colSpan:2},tr);
div=c("div",{className:"spacer-v"},td);
tr=c("tr",{},_21);
td=c("td",{className:"layout"},tr);
div=c("div",{className:"label",innerHTML:m.labelDeliveryOptions||"Delivery Options"},td);
td=c("td",{style:{width:"100%"}},tr);
tr=c("tr",{},_21);
td=c("td",{colSpan:2,className:"layout"},tr);
this.maxVolume=new dijit.form.CheckBox({onChange:dojo.hitch(this,function(val){
this.disableDeliveryOptions(val);
if(!val){
this.dialog.componentFocus.call(this.dialog,this.uniqueUsers);
}
}),readOnly:_1f,checked:!(buy&&buy.uniqueUsersTarget),name:"uniqueUsersMax",id:"buyDialogMaxVolumeId"});
this.maxVolume.placeAt(td);
c("label",{className:"label-normal unselectable","for":"buyDialogMaxVolumeId",unselectable:true,innerHTML:m.labelMaxVolume||"Maximum Volume"},td);
tr=c("tr",{},_21);
td=c("td",{colSpan:2,className:"layout"},tr);
div=c("div",{className:"delivery-options-container"},td);
this.beforeUniqueUsers=c("label",{className:"label-normal","for":"buyDialogUniqueUsersId",innerHTML:m.beforeUniqueUsers||"Deliver Only"},div);
removeWidget("buyDialogUniqueUsersId");
this.uniqueUsers=new Px.Ex.NumberTextBox({required:true,value:buy?buy.uniqueUsersTarget:null,constraints:{min:0},invalidMessage:m.invalidUniqueUsers||"$_unset_$",rangeMessage:m.invalidUniqueUsers||"$_unset_$",emptyMessage:m.emptyUniqueUsers||"$_unset_$",promptMessage:m.promptUniqueUsers||"","class":"field-unique-users",readOnly:_1f,name:"uniqueUsersTarget",id:"buyDialogUniqueUsersId",intermediateChanges:true,onChange:dojo.hitch(this,function(){
this.showUniqueUsersWarning();
})});
this.uniqueUsers.placeAt(div);
this.afterUniqueUsers=c("label",{className:"label-normal","for":"buyDialogDeliveryPeriodId",innerHTML:m.afterUniqueUsers||"Unique Users"},div);
this.deliveryPeriodStore=new dojo.data.ItemFileReadStore({data:{identifier:"id",label:"name",items:[{id:"total",name:m.comboItemTotal||"Total"},{id:"monthly",name:m.comboItemMonthly||"Monthly"}]}});
removeWidget("buyDialogDeliveryPeriodId");
this.deliveryPeriod=new Px.Ex.FilteringSelect({store:this.deliveryPeriodStore,id:"buyDialogDeliveryPeriodId","class":"field-delivery-period",searchAttr:"name",required:true,trim:true,readOnly:_1f,value:(buy&&buy.monthlyDelivery)?"monthly":"total",invalidMessage:m.invalidDeliveryPeriod||"$_unset_$",emptyMessage:m.emptyDeliveryPeriod||"$_unset_$",promptMessage:m.promptDeliveryPeriod||"",name:"deliveryPeriod"});
this.deliveryPeriod.placeAt(div);
tr=c("tr",{},_21);
td=c("td",{colSpan:2,className:"layout"},tr);
this.uniqueUsersWarning=c("div",{className:"unique-users-warning"},td);
this.disableDeliveryOptions(this.maxVolume.attr("checked"));
},showUniqueUsersWarning:function(){
if(this.uniqueUsers.attr("disabled")){
dojo.empty(this.uniqueUsersWarning);
}else{
var uu=this.dialog.data.segmentUniqueUsers;
var v=this.uniqueUsers.attr("value");
if(v&&uu<v){
var m=this.dialog.messages;
this.uniqueUsersWarning.innerHTML=m.warningUniqueUsers||"Delivery volume exceeds the estimated monthly volume";
}else{
dojo.empty(this.uniqueUsersWarning);
}
}
},disableDeliveryOptions:function(_25){
this.uniqueUsers.attr("disabled",_25);
this.deliveryPeriod.attr("disabled",_25);
dojo.toggleClass(this.beforeUniqueUsers,"disabled",_25);
dojo.toggleClass(this.afterUniqueUsers,"disabled",_25);
this.showUniqueUsersWarning();
}});
dojo.declare("Px.Ex.BuyDialog.Page2",[dijit.layout.ContentPane],{"class":"page2",dialog:undefined,startup:function(){
this.inherited(arguments);
this.createContent();
},createContent:function(){
var m=this.dialog.messages,_26=this.dialog.data,_27=this.dialog.buyer,buy=this.dialog.buy,_28=this.dialog.viewOnly,_29,_2a,tr,td,div,s,c=dojo.create;
_29=c("table",{className:"page2-layout"});
this.attr("content",_29);
_2a=c("tbody",{},_29);
tr=c("tr",{},_2a);
td=c("td",{className:"layout",colSpan:2},tr);
div=c("div",{className:"title",innerHTML:m.titleDefinePixel||"Define your data buy pixel by settings the pixel values or by pasting the pixel directly."},td);
tr=c("tr",{},_2a);
td=c("td",{colSpan:2},tr);
div=c("div",{className:"spacer-v"},td);
tr=c("tr",{},_2a);
td=c("td",{className:"layout",colSpan:2},tr);
div=c("div",{className:"label",innerHTML:m.labelSamplePixel||"The sample pixel defined on your account:"},td);
tr=c("tr",{},_2a);
td=c("td",{colSpan:2},tr);
div=c("div",{className:"sample-pixel-container"},td);
this._editor=new CodeMirror(div,{readOnly:true,path:"/codemirror/js/",parserfile:["parsexml.js","parsecss.js","tokenizejavascript.js","parsejavascript.js","parsehtmlmixed.js"],stylesheet:["/codemirror/css/xmlcolors.css","/codemirror/css/jscolors.css","/codemirror/css/csscolors.css"],width:"100%",height:"100%",content:_27.pixelTemplateSample||"",initCallback:dojo.hitch(this,function(){
if(!dojo.isFF&&this.initialCode==""){
this._editor.setCode("");
}
})});
tr=c("tr",{},_2a);
this.innerTabsNode=td=c("td",{colSpan:2},tr);
tr=c("tr",{},_2a);
td=c("td",{className:"layout-top"},tr);
removeWidget("buyDialogActiveId");
this.active=new dijit.form.CheckBox({checked:!buy||buy&&buy.dataBuyStatus==1,id:"buyDialogActiveId",readOnly:_28,name:"activate"});
this.active.placeAt(td);
td=c("td",{className:"layout-top"},tr);
c("label",{className:"label-normal unselectable","for":"buyDialogActiveId",unselectable:true,innerHTML:m.active||"Set Data Buy to Active"},td);
tr=c("tr",{},_2a);
td=c("td",{className:"layout-top"},tr);
removeWidget("buyDialogApprovalId");
this.approval=new dijit.form.CheckBox({checked:!!buy,id:"buyDialogApprovalId",readOnly:_28,onChange:dojo.hitch(this,function(){
this._allowShowError=true;
})});
this.approval.placeAt(td);
td=c("td",{className:"layout-top"},tr);
c("label",{className:"label-normal unselectable","for":"buyDialogApprovalId",unselectable:true,innerHTML:m.approval||"I agree to the previously executed Terms and Conditions."},td);
},createTabButton2:function(_2b){
var m=this.dialog.messages;
var fn=dojo.hitch(this,function(){
if(this._selectedTab==2){
return;
}
if(!this.templatesHaveData()){
this.selectTab2();
return;
}
(dojo.hitch(this.dialog,"_clearKeys"))();
var _2c={message:m.toPastePixel||"Switching to Paste Pixel tab will discard any data entered in this tab. Switch anyway?",okCallback:dojo.hitch(this,function(){
(dojo.hitch(this.dialog,"_restoreKeys"))();
this.selectTab2();
}),cancelCallback:dojo.hitch(this.dialog,"_restoreKeys")};
var d=new Px.Ex.MessageDialog(_2c);
d.show();
});
this.createTabButton("page2_btn_tab2_id",m.pastePixel||"Paste Pixel",_2b,"btn_tab2",fn);
if(_2b){
this._selectedTab=2;
}
},createTabButton1:function(_2d,_2e){
var m=this.dialog.messages;
var fn=dojo.hitch(this,function(){
if(this._selectedTab==1){
return;
}
if(!this.getPixelData().length){
this.selectTab1();
return;
}
(dojo.hitch(this.dialog,"_clearKeys"))();
var _2f={message:m.toSetPixelValues||"Switching to Pixel Values tab will discard any data entered in this tab. Switch anyway?",okCallback:dojo.hitch(this,function(){
(dojo.hitch(this.dialog,"_restoreKeys"))();
this.selectTab1();
}),cancelCallback:dojo.hitch(this.dialog,"_restoreKeys")};
var d=new Px.Ex.MessageDialog(_2f);
d.show();
});
this.createTabButton("page2_btn_tab1_id",m.setPixelValues||"Set Pixel Values",_2d,"btn_tab1",fn,_2e);
if(_2d){
this._selectedTab=1;
}
},selectTab1:function(){
if(this._selectedTab==1){
return;
}
this.page2.clear();
this.createTabButton2(false);
this.createTabButton1(true);
this.tabs.selectChild(this.page1);
this.page2.pastePixelValid=false;
},selectTab2:function(){
if(this._selectedTab==2){
return;
}
this.page1.clear();
this.createTabButton1(false,!(this.dialog.buy&&this.dialog.buy.dataBuyTemplateCode||this.dialog.buyer.templateCode));
this.createTabButton2(true);
this.tabs.selectChild(this.page2);
},createInnerTabs:function(){
var _30,_31,tr,td,div,c=dojo.create,_32=this.innerTabsNode;
this._selectedColor=dojo.getComputedStyle(dojo.query(".texi-logo-text")[0]).color;
_30=c("table",{style:{borderCollapse:"collapse"}},_32);
_31=c("tbody",{},_30);
tr=c("tr",{},_31);
td=c("td",{},tr);
c("div",{id:"page2_btn_tab1_id",className:"btn-tab1"},td);
td=c("td",{},tr);
c("div",{id:"page2_btn_tab2_id",className:"btn-tab2"},td);
div=c("div",{className:"page2-tabs-spacer-v"},_32);
this.errorDiv=c("div",{className:"editor-error-icon texi-hidden"},div);
this.connect(this.errorDiv,"onmouseenter","showErrorTooltip");
this.connect(this.errorDiv,"onmouseleave","hideErrorTooltip");
this.tabs=new dijit.layout.StackContainer().placeAt(_32);
this.page1=new Px.Ex.BuyDialog.Page2Page1({dialog:this.dialog});
this.page2=new Px.Ex.BuyDialog.Page2Page2({dialog:this.dialog});
this.tabs.addChild(this.page1);
this.tabs.addChild(this.page2);
this.tabs.selectChild(this.page2);
this.tabs.startup();
if(this.dialog.buy&&this.dialog.buy.dataBuyTemplateCode||!this.dialog.buy&&this.dialog.buyer.templateCode){
this.selectTab1();
}else{
this.selectTab2();
}
this._resetValue=this._selectedTab;
},createTabButton:function(_33,_34,_35,key,_36,_37){
var _38="12px",H=20,W=100;
var h=H;
var _39=_35?this._selectedColor||"green":"white";
var _3a=_35?_39:(_37?"#C0C0C0":"#D7E5F2");
var _3b=_35?"white":(_37?"#C0C0C0":"gray");
var _3c=_35?"bold":"normal";
var w=W;
if(this[key]){
this[key].destroy();
}
var _3d=this[key]=dojox.gfx.createSurface(_33,w,h);
var t=_3d.createText({x:0,y:0,text:_34,align:"middle"});
t.setFont({family:"Arial",size:_38,weight:_3c,rotated:false});
var tw=t.getTextWidth();
_3d.remove(t);
var _3e=20;
if(tw+_3e>w){
w=tw+_3e;
_3d.setDimensions(w,h);
}
var _3f=_3d.createPath("");
var r=8;
var _40=_35?0:2;
_3f.moveTo(w-1,h).vLineTo(r+1+_40).arcTo(r,r,0,false,false,w-r-1,1+_40).hLineTo(r+1).arcTo(r,r,0,false,false,1,r+1+_40).vLineTo(h).closePath();
_3f.setFill(_39).setStroke(_3a);
var c={x:parseInt(w/2),y:parseInt(h/2)};
var t=_3d.createText({x:c.x,y:c.y+6,text:_34,align:"middle"});
t.setFill(_3b);
t.setFont({family:"Arial",size:_38,weight:_3c,rotated:false});
if(!this.dialog.viewOnly&&!_37){
_3d.connect("onclick",dojo.hitch(this,_36));
}
if(dojox.gfx.renderer=="silverlight"){
_3d.rawNode["Cursor"]="Hand";
}else{
dojo.style(_3d.rawNode,"cursor","pointer");
}
},_getValueAttr:function(){
return this._selectedTab;
},reset:function(){
this["selectTab"+this._resetValue]();
},getPixelData:function(){
if(this._selectedTab==1){
return "";
}else{
if(this._selectedTab==2){
return dojo.trim(this.page2.attr("value"));
}else{
return null;
}
}
},templatesHaveData:function(){
if(this._selectedTab==1){
return this.page1.attr("data").length;
}else{
return false;
}
},isValidApproval:function(){
return this.approval.attr("checked");
},isValid:function(){
var p=this["page"+this._selectedTab];
return p?p.isValid():false;
},validate:function(){
return this.isValid();
},showErrorTooltip:function(){
dijit.showTooltip(this.getErrorMessage(),this.errorDiv);
},hideErrorTooltip:function(){
dijit.hideTooltip(this.errorDiv);
},showError:function(_41){
if(!this.errorDiv){
return;
}
if(_41&&(this._selectedTab!=2||!this._allowShowError)){
this.showError(false);
return;
}
dojo.toggleClass(this.errorDiv,"texi-hidden",!_41);
},getErrorMessage:function(){
var p=this["page"+this._selectedTab];
return p?p.getErrorMessage():"";
},destroy:function(){
this.hideErrorTooltip();
dojo.forEach(["btn_tab1","btn_tab2"],function(v){
try{
if(this[v]){
this[v].destroy();
}
}
catch(e){
}
},this);
this.inherited(arguments);
}});
dojo.declare("Px.Ex.BuyDialog.Page2Page1",[dijit.layout.ContentPane],{invalidMessage:"",dialog:undefined,startup:function(){
this.inherited(arguments);
this.createContent();
},createContent:function(){
var div,_42,_43,tr,td,c=dojo.create;
div=c("div",{className:"pixel-values-container"});
this.attr("content",div);
var _44=c("div",{},div);
_42=c("table",{},_44);
_43=c("tbody",{},_42);
if(!this.dialog.templates){
return;
}
dojo.forEach(this.dialog.templates,function(v,i){
tr=c("tr",{},_43);
var id=this._getTFId(v);
td=c("td",{className:"pixel-value-spacer-h"},tr);
td=c("td",{},tr);
c("label",{innerHTML:v.fieldName,"for":id,className:"label-normal pixel-value-label"},td);
td=c("td",{},tr);
removeWidget(id);
var t=new dijit.form.TextBox({id:id,value:v.fieldValue,"class":"pixel-value-text",readOnly:this.dialog.viewOnly,trim:true});
t.startup();
t.placeAt(td);
},this);
},_getTFId:function(_45){
return "templateField"+_45.fieldCode+"Id";
},_getValueAttr:function(){
if(this.dialog.templates&&this.dialog.templates.length){
return this.dialog.templates.length;
}else{
return "";
}
},_getDataAttr:function(){
var a=[];
if(this.dialog.templates&&this.dialog.templates.length){
dojo.forEach(this.dialog.templates,function(v){
var id=this._getTFId(v);
var d=dijit.byId(id);
if(d){
var val=dojo.trim(d.attr("value"));
if(val.length){
a.push(val);
}
}
},this);
return a;
}
return a;
},updateTemplatesData:function(){
if(!this.dialog.templates){
return;
}
dojo.forEach(this.dialog.templates,function(v){
var id=this._getTFId(v);
var d=dijit.byId(id);
if(d){
v.fieldValue=d.attr("value");
}
},this);
},updateTemplateFields:function(){
if(!this.dialog.templates){
return;
}
dojo.forEach(this.dialog.templates,function(v){
var id=this._getTFId(v);
var d=dijit.byId(id);
if(d){
d.attr("value",v.fieldValue);
}
},this);
},trim:function(_46){
return _46.replace(/^\s+|\s+$/g,"");
},isValid:function(){
var _47=this.dialog.templates&&this.dialog.templates.length;
if(_47){
var _48=-1;
for(var i in this.dialog.templates){
if(this.trim(this.dialog.templates[i]["fieldName"]).toLowerCase()=="pixel id"){
_48=this.dialog.templates[i]["fieldCode"];
break;
}
}
if(_48!=-1){
return (dijit.byId("templateField"+_48+"Id").attr("displayedValue")!="");
}else{
return true;
}
}else{
return false;
}
},clear:function(){
if(!this.dialog.templates){
return;
}
dojo.forEach(this.dialog.templates,function(v){
var id=this._getTFId(v);
var d=dijit.byId(id);
if(d){
d.attr("value","");
}
},this);
}});
dojo.declare("Px.Ex.BuyDialog.Page2Page2",[dijit.layout.ContentPane,Px.Ex.EmptyMessageMixin],{dialog:undefined,initialCode:"",invalidMessage:"The value entered is not valid",emptyMessage:"The value can not be empty",pastePixelValid:false,startup:function(){
this.inherited(arguments);
this.invalidMessage=this.dialog.messages.invalidPastePixel||this.invalidMessage;
this.emptyMessage=this.dialog.messages.emptyPastePixel||this.emptyMessage;
if(this.dialog.buy){
this.initialCode=this.dialog.buy.dataBuyPixel;
}
this._resetValue=this.initialCode;
this.createContent();
},createContent:function(){
var div,c=dojo.create;
div=c("div",{className:"editor-container"},this.containerNode);
this._editor=new CodeMirror(div,{readOnly:this.dialog.viewOnly,path:"/codemirror/js/",parserfile:["parsexml.js","parsecss.js","tokenizejavascript.js","parsejavascript.js","parsehtmlmixed.js"],stylesheet:["/codemirror/css/xmlcolors.css","/codemirror/css/jscolors.css","/codemirror/css/csscolors.css"],width:"100%",height:"100%",content:this.initialCode,initCallback:dojo.hitch(this,function(){
if(dojo.isIE){
this.connect(this._editor.frame,"onblur","onEditorBlur");
}else{
if(dojo.isChrome){
this.connect(this._editor.frame.contentDocument.documentElement,"onblur","onEditorBlur");
}else{
this.connect(this._editor.frame.contentDocument,"onblur","onEditorBlur");
}
}
if(!dojo.isFF&&this.initialCode==""){
this._editor.setCode("");
}
})});
},onEditorBlur:function(){
this.dialog.page2._allowShowError=true;
},isValid:function(){
var s="";
try{
var s=this._editor.getCode();
}
catch(e){
}
s=dojo.trim(s);
this.pastePixelValid=(s!="");
return this.pastePixelValid;
},_getValueAttr:function(){
try{
return dojo.trim(this._editor.getCode());
}
catch(e){
}
return "";
},reset:function(){
try{
if(dojo.isFF&&this._resetValue==""){
this._editor.setCode(" ");
this._editor.selectLines(null,0);
}else{
this._editor.setCode(this._resetValue);
}
}
catch(e){
}
},clear:function(){
try{
if(dojo.isFF){
this._editor.setCode(" ");
this._editor.selectLines(null,0);
}else{
this._editor.setCode("");
}
}
catch(e){
}
}});
dojo.declare("Px.Ex.Menu",[Px.Ex.XhrMixin],{constructor:function(){
this.subMenuScrollIntervalValue=1;
this.subMenuScrollIntervalDiff=3;
this.subMenuScrollIntervalTime=10;
this.currentPageId=Px.Ex.Application.Ids.PAGE_DASHBOARD_ID;
this.menuIdItemMap=[];
this.menuLoaded=false;
this.logoutMenuLoaded=false;
this.userName;
this._connections=[];
},draw:function(_1,_2){
if(this.menuLoaded){
return;
}
if(_1){
this.currentPageId=_1;
}
this.buildMenu(Px.Ex.Application.__menuMap);
_2?_2():null;
this.menuLoaded=true;
this.xhr({url:"/settings/active-names"});
},getCurrentScreenIdTitle:function(){
var id=this.currentPageId;
if(this.idTitleObj&&this.idTitleObj.id==id){
return this.idTitleObj;
}
var _3="";
for(var i in this.menuIdItemMap){
var _4=this.menuIdItemMap[i];
if(_4.screenId==id){
_3=_4.menuEntryName;
break;
}
}
var o={id:id,title:_3};
this.idTitleObj=_3.length?o:undefined;
return o;
},getScreenIdTitle:function(id){
if(this.idTitleObj&&this.idTitleObj.id==id){
return this.idTitleObj;
}
var _5="";
var _6=false;
for(var i in this.menuIdItemMap){
var _7=this.menuIdItemMap[i];
if(_7.screenId==id){
_5=_7.menuEntryName;
_6=true;
break;
}
}
var o={id:id,title:_5};
return _6?o:null;
},showLogout:function(){
dojo.query("#divLogout").html("<a id=\"aLogout\" class=\"greylink_bold\" href=\"javascript:;\">Logout</a>");
this.bindLogout();
},bindLogout:function(){
this._logout_connect=dojo.connect(dojo.byId("aLogout"),"onclick",this,"onLogout");
},unbindLogout:function(){
dojo.disconnect(this._logout_connect);
},addUserIdToLogout:function(_8){
if(this.logoutMenuLoaded){
return;
}
this.showLogout();
if(!_8){
return;
}
var _9=dojo.query("#divLogout span")[0];
if(!_9){
dojo.create("span",{innerHTML:"|"},"divLogout","first");
this._userIdNode=dojo.create("span",{innerHTML:_8,className:"menu-userid"},"divLogout","first");
this._connections.push(dojo.connect(this._userIdNode,"onmouseenter",this,"onUserMouseEnter"));
this._connections.push(dojo.connect(this._userIdNode,"onmouseleave",this,"onUserMouseLeave"));
this._connections.push(dojo.connect(this._userIdNode,"contextmenu",this,"onUserContextmenu"));
this.popupMenu=new dijit.PopupMenuDialog({"class":"texi-popup-menu-dialog",content:this.createPopupMenu()});
this.popupMenu.startup();
if(dojo.isChrome){
this.popupMenu._openIn(-1000,-1000);
this.popupMenu.close();
}
}
this.logoutMenuLoaded=true;
},createPopupMenu:function(){
var mm=Px.Ex.Application.UserMenu;
items=[{id:"edit-settings",title:mm.editSettings||"Edit Settings",allow:true}];
var _a=dojo.create("ul",{className:"texi-popup-menu"});
this._menuConnections=[];
dojo.forEach(items,function(v){
var li=dojo.create("li",{innerHTML:v.title,id:v.id,className:v.allow?"":"grayed"},_a);
if(v.allow){
this._menuConnections.push(dojo.connect(li,"onmouseenter",this,function(e){
dojo.addClass(li,"active");
}));
this._menuConnections.push(dojo.connect(li,"onmouseleave",this,function(e){
dojo.removeClass(li,"active");
}));
this._menuConnections.push(dojo.connect(li,"onclick",this,"onMenuItemClick"));
}
},this);
return _a;
},onUserMouseEnter:function(){
if(!Px.Ex.Application.allowEditSettings()){
return;
}
this._useridTooltipTimer=setTimeout(dojo.hitch(this,"showUseridTooltip"),1500);
},onUserMouseLeave:function(){
if(this._tooltipDeferred){
this._tooltipDeferred.cancel();
delete this._tooltipDeferred;
}
clearTimeout(this._useridTooltipTimer);
dijit.hideTooltip(this._userIdNode);
},onUserContextmenu:function(e){
if(!Px.Ex.Application.allowEditSettings()){
return;
}
this.onUserMouseLeave();
this.popupMenu._openMyself(e);
dojo.stopEvent(e);
},onMenuItemClick:function(e){
var _b=e.target.id;
this.popupMenu.close();
dojo.removeClass(e.target,"active");
if(_b=="edit-settings"){
if(Px.Ex.Application.currentScreen.editSettings){
(dojo.hitch(Px.Ex.Application.currentScreen,"editSettings"))();
}else{
var _c=new Px.Ex.SettingsDialog();
_c.show();
}
}
},showUseridTooltip:function(){
dijit.hideTooltip(this._userIdNode);
dijit.showTooltip(Px.Ex.Application.getNiceWaitHtml(),this._userIdNode,["below"]);
this._tooltipDeferred=this.xhr({url:"/settings/active-names",load:dojo.hitch(this,function(_d){
if(dijit._masterTT){
dijit._masterTT.containerNode.innerHTML=this.makeUseridTooltip(_d);
}
}),handleAs:"json"});
},makeUseridTooltip:function(_e){
_e.labelPublisher=_e.labelPublisher||"Active T-Pub:";
_e.labelBuyer=_e.labelBuyer||"Active Data Buyer:";
var d=dojo.string.substitute;
var a=["<div>"];
a.push(d("<div class=\"menu-user-tooltip label\">${labelPublisher}</div>",_e));
if(_e["publisher"]){
a.push(d("<div class=\"menu-user-tooltip data\">${publisher}</div>",_e));
}else{
a.push("<div class=\"menu-user-tooltip data\"></div>");
}
a.push(d("<div class=\"menu-user-tooltip label\">${labelBuyer}</div>",_e));
if(_e["buyer"]){
a.push(d("<div class=\"menu-user-tooltip data\">${buyer}</div>",_e));
}else{
a.push("<div class=\"menu-user-tooltip data\"></div>");
}
a.push("</div>");
return a.join("\n");
},isMainMenuActive:function(_f){
var _10=this.currentPageId;
if(_f.screenId==_10){
return true;
}
var len=_f.subitems.length;
if(len){
for(var i=0;i<len;++i){
var sub=_f.subitems[i];
if(sub.screenId==_10){
return true;
}
}
}
return false;
},buildMenu:function(_11){
var _12=false;
if(dojo.isArray(_11.menues)){
_11=_11.menues;
var _13=$("<ul id=\"nav\"></ul>");
ids=[];
var _14=this.makeMenuTree(_11);
var _15=false;
var _16;
for(var i=0,len=_14.codes.length;i<len;++i){
var _17=_14[_14.codes[i]];
var li=$("<li id=\""+_17.menuCode+"\"><a class=\"top\" href=\"#"+(_17.subitems[0]?_17.subitems[0].screenId:"")+"\"><span>"+_17.menuEntryName+"</span><span class=\"pointer\"></span></a></li>");
$(li).click(dojo.hitch(this,"onMenu",_17.menuCode));
if(i==0){
li.addClass("start");
}else{
if(i==len-1){
li.addClass("finish");
}else{
li.addClass("middle");
}
}
if(!_15&&this.isMainMenuActive(_17)){
li.addClass("active");
_15=true;
_16=_17.subitems;
}
var _18=this.makeDropDownMenu(_17);
if(_18){
li.append(_18);
}
_13.append(li);
_12=true;
}
_13.addClass("menu");
$("#divMenu").empty();
if(_12){
$("#divMenu").append(_13);
$("#nav").droppy();
}
if(_16){
this.buildSubMenu(_16);
}
}
},makeDropDownMenu:function(_19){
if(!_19.subitems.length){
return "";
}
var _1a=$("<ul></ul>");
for(var k=0,_1b=_19.subitems.length;k<_1b;++k){
var sub=_19.subitems[k];
var li=$("<li id=\""+sub.menuCode+"\"><a href=\"#"+sub.screenId+"\">&nbsp;"+sub.menuEntryName+"&nbsp;</a></li>");
$(li).click(dojo.hitch(this,"onMenu",sub.menuCode));
_1a.append(li);
}
return _1a;
},makeMenuTree:function(_1c){
var _1d={"codes":[]};
for(var i=0,len=_1c.length;i<len;++i){
var _1e=_1c[i];
if(_1e.parentEntryCode==0){
_1d[_1e.menuCode]=_1e;
_1e.subitems=[];
_1d.codes.push(_1e.menuCode);
}else{
if(_1e.parentEntryCode in _1d){
_1d[_1e.parentEntryCode].subitems.push(_1e);
}
}
this.menuIdItemMap[_1e.menuCode]=_1e;
}
return _1d;
},buildSubMenu:function(_1f){
var _20=$("<span id=\"mainSubMenu\"></span>");
_20.addClass("texi_main_sub_menu");
for(var i=0,len=_1f.length;i<len;++i){
var _21=_1f[i];
var li=$("<span><span><span></span></span></span>");
if(i==0){
li.addClass("first");
}
if(i==len-1){
li.addClass("last");
}
var _22=li.find("span > span");
if(_21.screenId==this.currentPageId){
li.children("span").addClass("active");
_22.text(_21.menuEntryName);
}else{
var _23=this;
$("<a href=\"#"+_21.screenId+"\"></a>").text(_21.menuEntryName).click(dojo.hitch(_23,"onMenu",_21.menuCode)).appendTo(_22);
}
_20.append(li);
}
$("#divSubMenu").empty();
$("#divSubMenu").append(_20);
subMenuWrapperContentBox=dojo.contentBox("divSubMenu");
if(subMenuWrapperContentBox){
subMenuWrapperWidth=subMenuWrapperContentBox.w;
subMenuWidth=dojo.byId("mainSubMenu").scrollWidth;
if(subMenuWidth>=subMenuWrapperWidth){
_20.addClass("texi_main_sub_menu_shrunk");
var _24=dojo.create("span",{innerHTML:"<span id='sub_menu_scroll_right' class='texi_main_sub_menu_arrow'>&lt;</span>&nbsp;<span id='sub_menu_scroll_left' class='texi_main_sub_menu_arrow'>&gt;</span>"},"mainSubMenu","after");
dojo.addClass(_24,"texi_main_sub_menu_arrows");
this._connections.push(dojo.connect(dojo.byId("sub_menu_scroll_left"),"onmouseover",dojo.hitch(this,"subMenuScrollLeftStart")));
this._connections.push(dojo.connect(dojo.byId("sub_menu_scroll_left"),"onmouseout",dojo.hitch(this,"subMenuScrollLeftStop",true)));
this._connections.push(dojo.connect(dojo.byId("sub_menu_scroll_left"),"onclick",this,"subMenuScrollLeftSpeedup"));
this._connections.push(dojo.connect(dojo.byId("sub_menu_scroll_right"),"onmouseover",dojo.hitch(this,"subMenuScrollRightStart")));
this._connections.push(dojo.connect(dojo.byId("sub_menu_scroll_right"),"onmouseout",dojo.hitch(this,"subMenuScrollRightStop",true)));
this._connections.push(dojo.connect(dojo.byId("sub_menu_scroll_right"),"onclick",this,"subMenuScrollRightSpeedup"));
var _25=dojo.query("#mainSubMenu span.active")[0];
if(_25){
dijit.scrollIntoView(_25);
}
}
}
},subMenuScrollLeftStart:function(){
this.subMenuScrollInterval=setInterval("dojo.byId('mainSubMenu').scrollLeft += "+this.subMenuScrollIntervalValue+";",this.subMenuScrollIntervalTime);
},subMenuScrollLeftStop:function(_26){
if(this.subMenuScrollInterval){
clearInterval(this.subMenuScrollInterval);
if(_26){
this.subMenuScrollIntervalValue=1;
}
}
},subMenuScrollRightStart:function(){
this.subMenuScrollInterval=setInterval("dojo.byId('mainSubMenu').scrollLeft -= "+this.subMenuScrollIntervalValue+";",this.subMenuScrollIntervalTime);
},subMenuScrollRightStop:function(_27){
if(this.subMenuScrollInterval){
clearInterval(this.subMenuScrollInterval);
if(_27){
this.subMenuScrollIntervalValue=1;
}
}
},subMenuScrollLeftSpeedup:function(){
this.subMenuScrollLeftStop(false);
this.subMenuScrollIntervalValue+=this.subMenuScrollIntervalDiff;
this.subMenuScrollLeftStart();
},subMenuScrollRightSpeedup:function(){
this.subMenuScrollRightStop(false);
this.subMenuScrollIntervalValue+=this.subMenuScrollIntervalDiff;
this.subMenuScrollRightStart();
},buildSubTitle:function(_28){
dojo.query("#divSubMenu").html("<ul class=\"texi_sub_menu\"><li class=\"first last\"><span class=\"active\"><span>"+_28+"</span></span></li></ul>");
},buildDialogSubTitle:function(_29){
dojo.query("#divDialogSubMenu").html("<ul class=\"texi_sub_menu\"><li class=\"first last\"><span class=\"active\"><span>"+_29+"</span></span></li></ul>");
},getSubTitleHtml:function(_2a){
return "<ul class=\"texi_sub_menu\"><li class=\"first last\"><span class=\"active\"><span>"+_2a+"</span></span></li></ul>";
},onLogout:function(e){
dojo.stopEvent(e);
this.unbindLogout();
Px.Ex.Application.showScreen(Px.Ex.Application.Ids.PAGE_LOGIN);
},onMenu:function(id,_2b){
_2b.stopPropagation();
var _2c=this.menuIdItemMap[id];
screenId=_2c.screenId;
if(!screenId&&_2c.parentEntryCode==0&&_2c.subitems.length){
screenId=_2c.subitems[0].screenId;
if(!screenId){
return;
}
}
if(screenId==this.currentPageId){
return;
}
Px.Ex.Application.showScreen(screenId);
if(Px.Ex.Application.screenShown){
this.currentPageId=screenId;
this._showActiveMenu(_2c);
}
},_showActiveMenu:function(_2d){
while(_2d.parentEntryCode!=0){
_2d=this.menuIdItemMap[_2d.parentEntryCode];
if(!_2d){
return;
}
}
this.buildSubMenu(_2d.subitems);
var li=dojo.query("#nav #"+_2d.menuCode)[0];
if(li){
if(dojo.hasClass(li,"active")){
return;
}
dojo.query("#nav li.active").removeClass("active");
dojo.addClass(li,"active");
}
},redrawMenu:function(_2e){
var _2f;
for(var i in this.menuIdItemMap){
_2f=this.menuIdItemMap[i];
if(!_2f){
continue;
}
if(_2f.screenId==_2e){
break;
}
}
if(!_2f){
return;
}
this.currentPageId=_2e;
this._showActiveMenu(_2f);
},destroy:function(){
this.onUserMouseLeave();
this.unbindLogout();
if(this._menuConnections){
dojo.forEach(this._menuConnections,dojo.disconnect,this);
}
dojo.forEach(this._connections,dojo.disconnect,this);
this.cancelXhr();
if(dijit._masterTT){
dijit._masterTT._onDeck=null;
if(dijit._masterTT.aroundNode){
dijit.hideTooltip(dijit._masterTT.aroundNode);
}
}
}});
dojo.declare("dijit.PopupMenuDialog",[dijit.layout.ContentPane,dijit._Templated,dijit.form._FormMixin,dijit._DialogMixin],{title:"",doLayout:false,autofocus:true,baseClass:"dijitPopupDialog",_firstFocusItem:null,_lastFocusItem:null,templateString:null,templateString:"<div waiRole=\"presentation\">\r\n\t<div class=\"dijitTooltipContainer\" waiRole=\"presentation\">\r\n\t\t<div class =\"dijitTooltipContents dijitTooltipFocusNode\" dojoAttachPoint=\"containerNode\" tabindex=\"-1\" waiRole=\"dialog\"></div>\r\n\t</div>\r\n\t<div class=\"dijitTooltipConnector\" waiRole=\"presentation\"></div>\r\n</div>\r\n",targetNodeIds:[],contextMenuForWindow:false,leftClickToOpen:false,constructor:function(){
this._bindings=[];
},postCreate:function(){
this.inherited(arguments);
this.connect(this.containerNode,"onkeypress","_onKey");
this.connect(this.containerNode,"onkeyup","_onKeyUp");
this.containerNode.title=this.title;
if(this.contextMenuForWindow){
this.bindDomNode(dojo.body());
}else{
dojo.forEach(this.targetNodeIds,this.bindDomNode,this);
}
},bindDomNode:function(_1){
_1=dojo.byId(_1);
var cn=(_1==dojo.body()?dojo.doc:_1);
_1[this.id]=this._bindings.push([dojo.connect(cn,(this.leftClickToOpen)?"onclick":"oncontextmenu",this,"_openMyself"),]);
},unBindDomNode:function(_2){
var _3=dojo.byId(_2);
if(_3){
var _4=_3[this.id]-1,b=this._bindings[_4];
dojo.forEach(b,dojo.disconnect);
delete this._bindings[_4];
}
},orient:function(_5,_6,_7){
var c=this._currentOrientClass;
if(c){
dojo.removeClass(this.domNode,c);
}
c="dijitPopupDialogRight";
dojo.addClass(this.domNode,c);
this._currentOrientClass=c;
},onOpen:function(_8){
this.orient(this.domNode,_8.aroundCorner,_8.corner);
this._onShow();
if(this.autofocus){
this._getFocusItems(this.containerNode);
dijit.focus(this._firstFocusItem);
}
if(!this._rounded_corners){
var mb=dojo.marginBox(this.domNode);
dojo.style(this.domNode,{width:mb.w+"px"});
this._rounded_corners=true;
var _9={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _a=new curvyCorners(_9,dojo.query(".dijitTooltipContainer",this.domNode)[0]);
_a.applyCornersToAll();
}
},_openIn:function(x,y){
y-=17;
var _b=this;
dijit.popup.open({popup:this,x:x,y:y,orient:"L",onExecute:function(){
this.close();
},onCancel:function(){
this.close();
}});
dojo.style(this.domNode.parentNode,{left:x+"px",top:y+"px"});
this._onBlur=function(){
this.inherited("_onBlur",arguments);
setTimeout(dojo.hitch(this,"close"),10);
};
},_openMyself:function(e){
if(this.leftClickToOpen&&e.button>0){
return;
}
dojo.stopEvent(e);
var x,y;
x=e.pageX;
y=e.pageY;
this._openIn(x,y);
},close:function(){
dijit.popup.close(this);
},_onKeyUp:function(_c){
if(_c.keyCode==dojo.keys.ESCAPE){
this.onCancel();
dojo.stopEvent(_c);
}
},_onKey:function(_d){
var _e=_d.target;
var dk=dojo.keys;
if(_d.charOrCode===dk.TAB){
this._getFocusItems(this.containerNode);
}
var _f=(this._firstFocusItem==this._lastFocusItem);
if(_d.charOrCode==dk.ESCAPE){
this.onCancel();
dojo.stopEvent(_d);
}else{
if(_e==this._firstFocusItem&&_d.shiftKey&&_d.charOrCode===dk.TAB){
if(!_f){
dijit.focus(this._lastFocusItem);
}
dojo.stopEvent(_d);
}else{
if(_e==this._lastFocusItem&&_d.charOrCode===dk.TAB&&!_d.shiftKey){
if(!_f){
dijit.focus(this._firstFocusItem);
}
dojo.stopEvent(_d);
}else{
if(_d.charOrCode===dk.TAB){
_d.stopPropagation();
}
}
}
}
},uninitialize:function(){
dojo.forEach(this.targetNodeIds,this.unBindDomNode,this);
this.inherited(arguments);
}});
dojo.declare("Px.Ex.RateCardScreen",[Px.Ex.XhrMixin],{allow:{},draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/rate-card/screen",load:dojo.hitch(this,"createScreen"),error:function(_1){
dojo.byId("divContent").innerHTML=Px.Ex.Application._extractError(_1);
},handleAs:"json"});
},createScreen:function(_2){
dojo.empty("divContent");
this.data=_2;
if(_2.access_denied){
dojo.byId("divContent").innerHTML=_2.access_denied;
return;
}
this._c=new dijit.layout.ContentPane({"class":"rate-card"}).placeAt("divContent");
var _3,_4,tr,td,_5,c=dojo.create;
_3=c("table",{className:"rate-card-layout"},this._c.containerNode);
_4=c("tbody",{},_3);
tr=c("tr",{},_4);
td=c("td",{},tr);
td=c("td",{className:"toolbar-layout"},tr);
this.createToolbar(td);
tr=c("tr",{},_4);
td=c("td",{className:"text-layout"},tr);
this.createText(td);
td=c("td",{className:"tree-layout"},tr);
this.createTree(td);
},createText:function(_6){
var m=this.data.messages,_7,c=dojo.create;
c("div",{className:"text",innerHTML:m.text||"rate card explanation"},_6);
},createTree:function(_8){
if(!this.data.allow.demographic&&!this.data.allow.intent&&!this.data.allow.interest){
return;
}
this.createTabButtons(_8);
},createToolbar:function(_9){
if(!this.data.allow.demographic&&!this.data.allow.intent&&!this.data.allow.interest){
return;
}
var m=this.data.messages;
var _a,_b,tr,td,_c,_d,c=dojo.create;
this.searchControl=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true,emptyText:m.search||"Search"}).placeAt(_9);
this.searchControl.connect(this.searchControl,"onChange",dojo.hitch(this,"onSearch"));
},createTabButtons:function(_e){
var _f,_10,tr,td,div,c=dojo.create;
this._selectedColor=dojo.getComputedStyle(dojo.query(".texi-logo-text")[0]).color;
_f=c("table",{className:"tab-buttons-container"},_e);
_10=c("tbody",{},_f);
tr=c("tr",{},_10);
td=c("td",{},tr);
c("div",{id:"btn_demographic_id",className:"btn-tab1"},td);
td=c("td",{},tr);
c("div",{id:"btn_interest_id",className:"btn-tab2"},td);
td=c("td",{},tr);
c("div",{id:"btn_intent_id",className:"btn-tab3"},td);
this.tabs=new dijit.layout.StackContainer().placeAt(_e);
this.refreshIndicator=c("div",{},_e);
var _11=dojo.hitch(this,"reloadCurrentTab");
this.page1=this.data.allow.demographic?new Px.Ex.RateCardPage({screen:this,data:this.data,pageType:3,pageTypeName:"demographic",pageData:this.data.demographic,reloadFn:_11,xhr:this.xhr}):undefined;
this.page2=this.data.allow.interest?new Px.Ex.RateCardPage({screen:this,data:this.data,pageType:2,pageTypeName:"interest",pageData:this.data.interest,reloadFn:_11,xhr:this.xhr}):undefined;
this.page3=this.data.allow.intent?new Px.Ex.RateCardPage({screen:this,data:this.data,pageType:1,pageTypeName:"intent",pageData:this.data.intent,reloadFn:_11,xhr:this.xhr}):undefined;
dojo.forEach([1,2,3],function(v){
if(this["page"+v]){
this.tabs.addChild(this["page"+v]);
}
},this);
this.tabs.startup();
var n=0;
dojo.some(["demographic","interest","intent"],function(v,i){
if(this.data.allow[v]){
n=i+1;
return true;
}
return false;
},this);
if(n){
this.selectTab(n);
}
},createTabButton1:function(_12){
var m=this.data.messages;
var fn=dojo.hitch(this,"selectTab",1);
this.createTabButton("btn_demographic_id",m.tabDemgraphic||"Demographic",_12,"btn_tab1",fn);
if(_12){
this._selectedTab=1;
}
},createTabButton2:function(_13){
var m=this.data.messages;
var fn=dojo.hitch(this,"selectTab",2);
this.createTabButton("btn_interest_id",m.tabInterest||"Interest",_13,"btn_tab2",fn);
if(_13){
this._selectedTab=2;
}
},createTabButton3:function(_14){
var m=this.data.messages;
var fn=dojo.hitch(this,"selectTab",3);
this.createTabButton("btn_intent_id",m.tabIntent||"Intent",_14,"btn_tab3",fn);
if(_14){
this._selectedTab=3;
}
},selectTab:function(num){
if(this.__reloading||this._selectedTab==num){
return;
}
dojo.forEach(["demographic","interest","intent"],function(v,i){
if(this.data.allow[v]){
var n=i+1;
this["page"+n].setActive(num==n);
this["createTabButton"+n](num==n);
if(num==n){
this.tabs.selectChild(this["page"+num]);
}
}
},this);
if(this["page"+num].needReload){
this._reloadTab();
}
},createTabButton:function(_15,_16,_17,key,_18){
var _19="12px",H=20,W=120;
var h=H;
var _1a=_17?this._selectedColor||"#F26A22":"#898D90";
var _1b=_17?_1a:_1a;
var _1c=_17?"white":"white";
var _1d=_17?"bold":"normal";
var w=W;
if(this[key]){
this[key].destroy();
}
var _1e=this[key]=dojox.gfx.createSurface(_15,w,h);
var t=_1e.createText({x:0,y:0,text:_16,align:"middle"});
t.setFont({family:"Arial",size:_19,weight:_1d,rotated:true});
var tw=t.getTextWidth();
_1e.remove(t);
var _1f=20;
if(tw+_1f>w){
w=tw+_1f;
_1e.setDimensions(w,h);
}
var _20=_1e.createPath("");
var r=8;
var _21=_17?0:2;
_20.moveTo(w-1,h).vLineTo(r+1+_21).arcTo(r,r,0,false,false,w-r-1,1+_21).hLineTo(r+1).arcTo(r,r,0,false,false,1,r+1+_21).vLineTo(h).closePath();
_20.setFill(_1a).setStroke(_1b);
var c={x:parseInt(w/2),y:parseInt(h/2)};
var t=_1e.createText({x:c.x,y:c.y+6,text:_16,align:"middle"});
t.setFill(_1c);
t.setFont({family:"Arial",size:_19,weight:_1d,rotated:false});
if(!this.viewOnly){
_1e.connect("onclick",dojo.hitch(this,_18));
}
if(dojox.gfx.renderer=="silverlight"){
_1e.rawNode["Cursor"]="Hand";
}else{
dojo.style(_1e.rawNode,"cursor","pointer");
}
},_reloadTab:function(){
this.__reloading=true;
dojo.empty(this.refreshIndicator);
this.refreshIndicator.innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/rate-card/main-data",content:{segment:this["page"+this._selectedTab].pageTypeName},load:dojo.hitch(this,function(_22){
this["page"+this._selectedTab].refresh(_22);
delete this.__reloading;
dojo.empty(this.refreshIndicator);
}),error:dojo.hitch(this,function(err){
delete this.__reloading;
dojo.empty(this.refreshIndicator);
this.refreshIndicator=err.message;
}),handleAs:"json"});
},reloadCurrentTab:function(){
if(this.__reloading){
return;
}
this.__reloading=true;
this["page"+this._selectedTab].clearGrid();
this._reloadTab();
},onRefresh:function(){
if(this.__reloading){
return;
}
this.__reloading=true;
dojo.forEach([1,2,3],function(v){
if(this["page"+v]){
this["page"+v].clearGrid();
}
},this);
this._reloadTab();
},onSearch:function(val){
clearTimeout(this.timer);
this.timer=setTimeout(dojo.hitch(this,function(){
val=val.toLowerCase();
dojo.forEach([1,2,3],function(v){
if(this["page"+v]){
this["page"+v].setFilter(val);
}
},this);
this.searchControl.focus();
}),250);
},_cleanup:function(){
clearTimeout(this.timer);
this.cancelXhr();
dojo.forEach([1,2,3],function(v){
var key="btn_tab"+v;
try{
if(this[key]){
this[key].destroy();
}
}
catch(e){
}
delete this[key];
},this);
delete this._selectedTab;
if(this._c){
this._c.destroyRecursive();
}
dojo.empty("divContent");
},destroy:function(){
this._cleanup();
}});
dojo.declare("Px.Ex.RateCardPage",dijit.layout.ContentPane,{screen:undefined,data:undefined,xhr:undefined,pageType:0,pageTypeName:undefined,active:false,pageData:undefined,_expanded:false,_gridEar:undefined,reloadFn:undefined,constructor:function(_23){
dojo.mixin(this,_23);
this.needReload=true;
this.prepareData();
},getEmptyData:function(){
return {identifier:"segmentID",items:[]};
},prepareData:function(){
if(!this.pageData){
return;
}
var pd=this.pageData;
var pm=this._parentMap={};
var m=this._map={};
dojo.forEach(pd,function(v){
v.segmentName=v.segmentName||"";
v.nameLower=v.segmentName.toLowerCase();
var pId=v.segmentParentID;
if(!pm[pId]){
pm[pId]=[];
}
pm[pId].push(v);
m[v.segmentID]=v;
});
var _24=function(a,b){
return a.nameLower.localeCompare(b.nameLower);
};
if(pm[0]){
this._tree=pm[0];
this._tree.sort(_24);
}else{
this._tree=[];
}
var x=0;
var _25=function(a,_26){
x+=a.length;
var fn=arguments.callee;
dojo.forEach(a,function(v){
v.level=_26;
var _27=pm[v.segmentID];
if(_27){
v.children=_27;
_27.sort(_24);
v.expanded=false;
fn(_27,_26+1);
}
});
};
_25(this._tree,0);
if(x<pd.length){
var a=[];
var f=function(id){
var _28=arguments.callee;
if(!pm[id]){
return;
}
dojo.forEach(pm[id],function(v){
a.push(v.segmentID);
_28(v.segmentID);
});
};
dojo.forEach(pd,function(v){
if(v.segmentParentID!=0&&!m[v.segmentParentID]){
a.push(v.segmentID);
f(v.segmentID);
}
});
a.sort(function(a,b){
return a-b;
});
var ap=dojo.map(a,function(v){
return v+" (parent:"+m[v].segmentParentID+")";
});
var s="[Rate Card] Wrong "+this.pageTypeName+" data: only "+x+" from "+pd.length+" segments have been used. Orphan segments: "+ap.join(", ");
Px.Ex.Application.showMsgDialog(s);
Px.Ex.Application.showGlobalError(s);
dojo.forEach(a,function(v){
delete pm[v];
delete m[v];
});
}
},startup:function(){
this.inherited(arguments);
this.createContent();
},createContent:function(){
var _29,_2a,tr,td,div,c=dojo.create;
_29=c("table",{className:"grid-layout"});
_2a=c("tbody",{},_29);
tr=c("tr",{},_2a);
td=c("td",{style:{verticalAlign:"top"}},tr);
this._gridEar=c("div",{className:"grid-ear"},td);
this.connect(this._gridEar,"onclick","onExpand");
td=c("td",{style:{verticalAlign:"top",width:"100%"}},tr);
div=c("div",{},td);
this.attr("content",_29);
this.createGrid(div);
},createGrid:function(_2b){
this.store=new dojo.data.ItemFileReadStore({clearOnClose:true,data:this.getEmptyData()});
var _2c=this._makeGridStructure();
this.grid=new dojox.grid.DataGrid({store:this.store,query:{segmentID:"*"},queryOptions:{ignoreCase:true},clientSort:true,onFetchError:dojo.hitch(this,function(_2d,req){
if(!req){
return;
}
this.grid._pending_requests[req.start]=false;
}),"class":"grid",autoHeight:1000,rowsPerPage:1000,selectionMode:"none",canSort:function(_2e){
return false;
},onStyleRow:function(_2f){
this.edit.styleRow(_2f);
},structure:_2c},_2b);
this.connect(this.grid,"onCellClick",function(e){
if(e.cell.field=="segmentName"){
var _30=e.grid.getItem(e.rowIndex);
if(!_30){
return;
}
var _31=e.grid.store.getValue(_30,"expanded");
if(_31!==undefined){
this.expandNode(e.grid.store.getIdentity(_30),!_31);
}
}
});
this.grid.startup();
},_makeGridStructure:function(_32){
var m=this.data.messages;
var _33=dojo.hitch(this,function(_34,_35){
var _36=this.grid.getItem(_35);
if(!_36){
return "";
}
var _37=this.grid.store.getValue(_36,"level");
var _38=this.grid.store.getValue(_36,"expanded");
var cls="segment-name "+(_38===undefined?"leaf":(_38?"expanded":"collapsed"));
var _39=_37*15;
_34==""?_34="<pre>                                     </pre>":_34;
return "<div class=\""+cls+"\" style=\"margin-left:"+_39+"px\">"+_34+"</div>";
});
var _3a=dojo.hitch(this,function(_3b,_3c){
try{
_3b=dojo.currency.format(_3b,{places:2,currency:"USD"});
}
catch(e){
}
return "<div class=\"price-rate\">"+_3b+"</div>";
});
var _3d=m.headerPrice||"Price";
_3d+="<span class=\"header-price-tail\">"+(m.headerPriceTail||" (per 1000 Unique Users)")+"</span>";
var _3e=[{defaultCell:{styles:"white-space:nowrap;",headerStyles:"text-align:center;cursor:pointer;",noresize:true},cells:[{name:m.headerSegment||"Segment",field:"segmentName",formatter:_33,width:"100%"},{name:_3d,field:"priceRate",formatter:_3a,width:"190px",cellStyles:"text-align:right;vertical-align:middle;"}]}];
return _3e;
},makeGridData:function(){
if(!this._tree||!this._map){
return this.getEmptyData();
}
var _3f=[];
if(this._filteredMap){
var m=this._filteredMap;
var fn=function(a){
var f=arguments.callee;
dojo.forEach(a,function(v){
if(v.segmentID in m){
var ch=v.children;
delete v.children;
_3f.push(v);
if(v.expanded){
f(ch);
}
}
});
};
}else{
var fn=function(a){
var f=arguments.callee;
dojo.forEach(a,function(v){
var ch=v.children;
delete v.children;
_3f.push(v);
if(v.expanded){
f(ch);
}
});
};
}
fn(dojo.clone(this._tree));
return {identifier:"segmentID",items:_3f};
},updateGrid:function(){
var _40=dijit._curFocus;
this.store.close();
this.store._jsonData=this.makeGridData();
this.store.fetch();
setTimeout(dojo.hitch(this.grid,"_refresh",true),10);
},isNeedUpdateGrid:function(){
if(this._oldFilter&&this._oldFilter.searchString==this._searchString){
return false;
}
return true;
},setActive:function(_41){
if(this.active&&!_41){
this._oldFilter={activeOnly:!!this._activeOnly,searchString:this._searchString};
}
this.active=_41;
if(this.active){
if(this.isNeedUpdateGrid()){
this._doFilter();
}else{
if(parseInt(dojo.getComputedStyle(this.grid.viewsHeaderNode).height)==0){
this._doFilter();
}
}
}
},clearGrid:function(){
delete this._tree;
delete this._filteredMap;
delete this._oldFilter;
this.updateGrid();
this._expanded=false;
dojo.toggleClass(this._gridEar,"collapse",this._expanded);
this.needReload=true;
},refresh:function(_42){
this.needReload=false;
if(_42.messages){
this.data.messages=_42.messages;
}
this.data[this.pageTypeName]=_42[this.pageTypeName];
this.pageData=this.data[this.pageTypeName];
delete this._oldFilter;
delete this._tree;
delete this._filteredMap;
this.prepareData();
this._doFilter();
},setFilter:function(val){
if(!val.length){
delete this._searchString;
}else{
this._searchString=val;
}
this._doFilter();
},_doFilter:function(){
if(this.active){
delete this._oldFilter;
if(this._searchString){
this.makeFilteredMap();
}else{
delete this._filteredMap;
}
setTimeout(dojo.hitch(this,"updateGrid"),20);
}
},expandNode:function(id,_43){
this._map[id].expanded=_43;
setTimeout(dojo.hitch(this,"updateGrid"),20);
},makeFilteredMap:function(){
var m=this._map;
var _44={};
var _45=this._activeOnly;
var str=(this._searchString!==undefined?this._searchString:"");
for(var id in m){
if(id in _44){
continue;
}
var _46=m[id];
if(!str.length||(_46.nameLower.indexOf(str)>=0)){
_44[id]=_46;
if(_46.children&&!_46.expanded){
_46.expanded=true;
}
var _47=_46.segmentParentID;
while(_47&&(!(_47 in _44))){
_46=m[_47];
_44[_47]=_46;
if(!_46.expanded){
_46.expanded=true;
}
_47=_46.segmentParentID;
}
}
}
this._filteredMap=_44;
},_expandTree:function(_48){
for(var id in this._map){
var _49=this._map[id];
if(_49.children&&_49.expanded!=_48){
_49.expanded=_48;
}
}
},onExpand:function(){
this._expanded=!this._expanded;
dojo.toggleClass(this._gridEar,"collapse",this._expanded);
this._expandTree(this._expanded);
setTimeout(dojo.hitch(this,"updateGrid"),20);
}});
dojo.declare("Px.Ex.HelpDialog",[Px.Ex.Dialog],{"class":"help-dialog",duration:250,modal:false,startup:function(){
this.inherited(arguments);
this._hist=[];
this._i=-1;
this._links=[];
this.main=dojo.create("div",{className:"main-content"},this.containerNode);
var _1=dojo.create("div",{className:"navigation-layout"},this.titleBar,"before");
this.back=dojo.create("div",{className:"back dijitInline"},_1);
this.next=dojo.create("div",{className:"next dijitInline"},_1);
this.connect(this.back,"onclick","onBack");
this.connect(this.next,"onclick","onNext");
this._showButton(this.back,false);
this._showButton(this.next,false);
this.current=Px.Ex.Application.getCurrentScreenIdTitle();
setTimeout(dojo.hitch(this,"showHelp"),100);
},_showButton:function(_2,_3){
dojo.style(_2,"visibility",_3?"visible":"hidden");
},showHelp:function(){
this._loading=true;
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(this.current.title);
this.showRotation(true);
if(!this.current.lang){
this.current.lang=dojo.locale;
}
this.xhr({url:"/help/help",content:this.current,load:dojo.hitch(this,"onLoad"),error:dojo.hitch(this,"onError")});
},onLoad:function(_4,_5){
this.addToHistory();
this.showRotation(false);
this.disconnectLinks();
dojo.empty(this.main);
this.main.innerHTML=_4;
this.connectLinks();
delete this._do_not_add_to_history;
delete this._loading;
},onError:function(_6,_7){
this.showRotation(false);
this.showError(_6);
delete this._do_not_add_to_history;
delete this._loading;
},disconnectLinks:function(){
dojo.forEach(this._links,dojo.disconnect,this);
this._links.length=0;
},connectLinks:function(){
dojo.query(".help-dialog .main-content a").forEach(function(v){
var _8=dojo.attr(v,"href");
dojo.attr(v,"href","javascript:");
this._links.push(dojo.connect(v,"onclick",null,dojo.hitch(this,"onLink",_8)));
},this);
},onLink:function(_9,e){
var a=_9.split(/\./);
var o=Px.Ex.Application.getScreenIdTitle(a[0]);
o.lang=a[1];
this.current=o;
this.showHelp();
return false;
},addToHistory:function(_a){
if(this._do_not_add_to_history){
return;
}
++this._i;
this._hist.splice(this._i);
this._hist.push(this.current);
this._showButton(this.back,this._i>0);
this._showButton(this.next,false);
},onBack:function(){
if(this._loading){
return;
}
this._do_not_add_to_history=true;
--this._i;
this.current=this._hist[this._i];
this._showButton(this.back,this._i>0);
this._showButton(this.next,true);
this.showHelp();
},onNext:function(){
if(this._loading){
return;
}
this._do_not_add_to_history=true;
++this._i;
this.current=this._hist[this._i];
this._showButton(this.back,true);
this._showButton(this.next,this._i<(this._hist.length-1));
this.showHelp();
},destroy:function(){
this.disconnectLinks();
this.inherited(arguments);
}});
dojo.declare("Px.Ex.BuyersUsersScreen",[Px.Ex.XhrMixin],{buyerId:0,buyerName:"",allowSetUserStatus:false,allowEditUser:false,messages:undefined,ALL_REGEXP:".*",EMAIL_REGEXP:"[^@]+@[^@]+\\.\\w{2,}",PWD_REGEXP:".*\\d+.*",NAME_REGEXP:"[a-zA-Z. -]*",constructor:function(_1){
dojo.mixin(this,_1);
if(this.buyerId==undefined){
this.buyerId=0;
}
},draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhrLoad({selector:"#divContent",url:"/buyers/users",content:{buyerId:this.buyerId,buyerName:this.buyerName},load:dojo.hitch(this,"createScreen")});
},createScreen:function(_2){
this.buyerId=dojo.byId("buyerId").value;
this.allowSetUserStatus=dojo.byId("allowSetUserStatusId").value;
this.allowEditUser=dojo.byId("allowEditUserId").value;
this.messages=dojo.fromJson(dojo.byId("div-messages-id").innerHTML);
if(dojo.byId("buyerComboId")){
this.createBuyerCombo("buyerComboId");
}
if(dojo.byId("usersListId")){
this.createUsersGrid("usersListId");
}
if(dojo.byId("roundedFormBorderId")){
this.prepareCreateUserForm();
this.showBuyerName();
}
},decorateCreateUserForm:function(){
var _3={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _4=new curvyCorners(_3,dojo.byId("roundedFormBorderId"));
_4.applyCornersToAll();
var _5=dojo.byId("createUserHeaderId");
var _6="<ul><li class=\"first last\"><span class=\"active\"><span>"+_5.innerHTML+"</span></span></li></ul>";
_5.innerHTML=_6;
},showCreateUserError:function(_7){
dojo.byId("createUserErrorId").innerHTML=_7;
},showCreateMessage:function(_8){
var _9=[];
if(_8){
_9.push(dojo.string.substitute("User <span class=\"bold\">${userName}</span> was created successfully!",_8));
if(_8.sendWelcomeEmail){
_9.push(dojo.string.substitute("A welcome email was sent to <span class=\"bold\">${email}</span>.",_8));
}
if((_8.generateNewPassword)&&(_8.sendWelcomeEmail)){
_9.push(dojo.string.substitute("Password was sent to <span class=\"bold\">${email}</span>.",_8));
}
if((_8.generateNewPassword)&&(!_8.sendWelcomeEmail)){
_9.push(dojo.string.substitute("Password was sent to <span class=\"bold\">${secondEmail}</span>.",_8));
}
}
dojo.byId("createUserMessageId").innerHTML=_9.join("<br>");
},updatePasswordConstraints:function(){
var p=dijit.byId("initialPasswordId");
if(!dijit.byId("sendWelcomeEmailId").checked&&!dijit.byId("generateNewPasswordId").checked&&!dijit.byId("initialPasswordId").required){
p.required=true;
p.regExp=this.PWD_REGEXP;
}else{
p.required=false;
p.regExp=this.ALL_REGEXP;
}
},updateSecondEmailConstraints:function(){
if(!dijit.byId("sendWelcomeEmailId").checked&&dijit.byId("generateNewPasswordId").checked){
dijit.byId("sendToId").regExp=this.EMAIL_REGEXP;
}else{
dijit.byId("sendToId").regExp=this.ALL_REGEXP;
}
},prepareCreateUserForm:function(){
this.decorateCreateUserForm();
var f=this._form=new dijit.form.Form({"class":"create-user-form",onSubmit:function(){
return false;
}},"createUserFormId");
if(dojo.byId("T4E-BUYERUSR-CREATE")){
f.connect(dojo.byId("T4E-BUYERUSR-CREATE"),"onclick",dojo.hitch(this,"onCreateUser"));
f.connect(f.domNode,"onkeydown",dojo.hitch(this,function(e){
if((e.keyCode==dojo.keys.ENTER||e.keyCode==dojo.keys.NUMPAD_ENTER)&&e.target.type!="textarea"){
setTimeout(dojo.hitch(this,this.onCreateUser),10);
}
}));
}
var m=this.messages;
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"email",trim:true,regExp:this.EMAIL_REGEXP,required:true,promptMessage:m.promptEmail||"",invalidMessage:m.invalidEmail||"$_unset_$",emptyMessage:m.emptyEmail||"$_unset_$","class":"form-input"},"emailId");
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"firstName",trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptFirstName||"",invalidMessage:m.invalidFirstName||"$_unset_$",emptyMessage:m.emptyFirstName||"$_unset_$","class":"form-input"},"firstNameId");
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"lastName",trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptLastName||"",invalidMessage:m.invalidLastName||"$_unset_$",emptyMessage:m.emptyLastName||"$_unset_$","class":"form-input"},"lastNameId");
this.userRolesStore=new dojo.data.ItemFileReadStore({data:dojo.fromJson(dojo.byId("userRolesDataId").value)});
this.userRolesCombo=new Px.Ex.FilteringSelect({name:"roleCode",store:this.userRolesStore,value:10,promptMessage:m.promptUserRoles||"",invalidMessage:m.invalidUserRoles||"$_unset_$",emptyMessage:m.emptyUserRoles||"$_unset_$",searchAttr:"name","class":"form-input"},"roleId");
new dijit.form.CheckBox({name:"sendWelcomeEmail",checked:true},"sendWelcomeEmailId");
new dijit.form.CheckBox({name:"generateNewPassword",style:{display:"none"},checked:true},"generateNewPasswordId");
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"password",style:{display:"none"},trim:true,type:"password",regExp:this.ALL_REGEXP,promptMessage:m.promptPassword||"",invalidMessage:m.invalidPassword||"$_unset_$",emptyMessage:m.emptyPassword||"$_unset_$","class":"form-input"},"initialPasswordId");
var _a=dojo.byId("sendToId").innerHTML;
new Px.Ex.ValidationTextBox({intermediateChanges:true,name:"secondEmail",style:{display:"none"},trim:true,regExp:this.ALL_REGEXP,promptMessage:m.promptSecondEmail||"",invalidMessage:m.invalidSecondEmail||"$_unset_$",emptyMessage:m.emptySecondEmail||"$_unset_$","class":"form-input",value:_a},"sendToId");
f.connect(dijit.byId("sendWelcomeEmailId"),"onClick",dojo.hitch(this,"onSendWelcomeEmail"));
f.connect(dijit.byId("generateNewPasswordId"),"onClick",dojo.hitch(this,"onGenerateNewPassword"));
},showLabel:function(_b,_c){
dojo.query("label[for='"+_b+"']").style("display",_c?"inline":"none");
},showDijit:function(id,_d){
dijit.byId(id).attr("style",{display:_d?"":"none"});
},onUsersStoreSet:function(_e,_f,_10,_11){
if(_f!="active"||_10==_11){
this.usersStore.save();
return;
}
if(this.allowSetUserStatus){
this.standBy.show();
this.xhr({url:"/buyers/activate-user",content:{user:dojo.toJson(this.itemToObject(this.usersStore,_e))},handle:dojo.hitch(this,function(_12){
this.standBy.hide();
if(_12 instanceof Error||!_12["return"]||!_12["return"].success){
this.disconnectUsersStore();
this.usersStore.setValue(_e,_f,_10);
this.usersStore.save();
this.connectUsersStore();
}
}),handleAs:"json"});
this.usersStore.save();
}else{
this.disconnectUsersStore();
this.usersStore.setValue(_e,_f,_10);
this.usersStore.save();
this.connectUsersStore();
}
},onCreateUser:function(){
if(isDefined(this.usersStore)){
if(this.usersStore._loadInProgress){
return;
}
}
this.showCreateUserError("");
this.showCreateMessage();
if(!this._form.validate()){
return;
}
o=this._form.attr("value");
o.entityCode=this.buyerId;
o.sendWelcomeEmail=o.sendWelcomeEmail[0]||"";
o.generateNewPassword=o.generateNewPassword[0]||"";
o.passwordExpiration=true;
if(o.sendWelcomeEmail||o.generateNewPassword){
o.password="";
}
o.password=$.base64Encode(o.password);
if(!o.sendWelcomeEmail&&!o.generateNewPassword){
o.secondEmail="";
o.passwordExpiration=false;
}
o.userName=o.email;
var _13=dojo.clone(o);
delete o.generateNewPassword;
var _14=dojo.hitch(this,function(_15,_16){
dojo.fx.chain([dojo.fx.wipeOut({node:dojo.byId("divXhrIndicator")}),dojo.fx.wipeIn({node:dojo.byId("createUserFormId"),onEnd:dojo.hitch(this,function(){
if(_15["return"]){
if(!_15["return"].success){
this.showCreateUserError("Error: "+_15["return"].errorMessage);
}else{
this._form.reset();
this.showDijit("generateNewPasswordId",false);
this.showLabel("generateNewPasswordId",false);
this.showDijit("initialPasswordId",false);
this.showLabel("initialPasswordId",false);
this.showDijit("sendToId",false);
this.showLabel("sendToId",false);
this.updatePasswordConstraints();
this.updateSecondEmailConstraints();
this.reloadUsersGrid();
this.showCreateMessage(_13);
dijit.byId("emailId").focus();
}
}else{
this.showCreateUserError("Error: "+_15.faultstring+"<br>Code: "+_15.faultcode);
}
})})]).play();
});
var fn=dojo.hitch(this,"xhr",{url:"/buyers/create-user",content:{user:dojo.toJson(o)},handleAs:"json",load:_14});
dojo.fx.chain([dojo.fx.wipeOut({node:dojo.byId("createUserFormId"),onEnd:function(){
dojo.byId("divXhrIndicator").innerHTML=Px.Ex.Application.getWaitHtml();
}}),dojo.fx.wipeIn({node:dojo.byId("divXhrIndicator"),onEnd:fn})]).play();
},onGenerateNewPassword:function(e){
var _17=e.target.checked;
this.showDijit("sendToId",_17);
this.showLabel("sendToId",_17);
this.showDijit("initialPasswordId",!_17);
this.showLabel("initialPasswordId",!_17);
this.updatePasswordConstraints();
this.updateSecondEmailConstraints();
},onSendWelcomeEmail:function(e){
var _18=e.target.checked;
this.showDijit("generateNewPasswordId",!_18);
this.showLabel("generateNewPasswordId",!_18);
var _19=dijit.byId("generateNewPasswordId").checked;
var id=_19?"sendToId":"initialPasswordId";
this.showDijit(id,!_18);
this.showLabel(id,!_18);
this.updatePasswordConstraints();
this.updateSecondEmailConstraints();
},onChangeBuyer:function(_1a){
if(this.usersStore){
if(this.usersStore._loadInProgress){
this.buyerCombo.attr("value",this.buyerId);
return;
}
}
if(this.buyerId==0){
this.buyerId=_1a;
this.buyerCombo.destroy(true);
this.xhrLoad({selector:"#divContent",url:"/buyers/users",content:{buyerId:this.buyerId,buyerName:this.buyerName},load:dojo.hitch(this,"createScreen")});
}else{
this.buyerId=_1a;
this.reloadUsersGrid();
}
},createBuyerCombo:function(div){
this.buyerStore=new dojo.data.ItemFileReadStore({data:dojo.fromJson(dojo.byId("buyerComboDataId").value)});
this.buyerCombo=new dijit.form.FilteringSelect({store:this.buyerStore,value:dojo.byId("buyerId").value,searchAttr:"name",onChange:dojo.hitch(this,"onChangeBuyer")},div);
this.buyerCombo.startup();
},createUsersGrid:function(div){
this.standBy=new dojox.widget.Standby({target:dojo.body()},dojo.create("div",{},dojo.body()));
this.standBy.startup();
this.usersStore=new dojo.data.ItemFileWriteStore({clearOnClose:true,url:this.getUsersUrl()});
this.connectUsersStore();
var _1b=dojo.hitch(this,function(_1c){
return "";
});
var _1d=dojo.hitch(this,function(_1e,_1f){
var _20=this.usersGrid.getItem(_1f);
if(!_20){
return "";
}
return "<a class=\"a-in-grid\" href=\"javascript:\">Edit</a>";
});
var _21=dojo.hitch(this,function(_22,_23){
if(_22!=null){
return dojo.string.substitute("<div class=\"dojoxEllipsis\" title=\"${0}\">${1}</div>",[_22,_22]);
}else{
return ("<div class=\"dojoxEllipsis\" style=\"white-space:nowrap;\">N/A</div>");
}
});
var _24=[{defaultCell:{styles:"white-space:nowrap;"},cells:[{name:"",get:_1b,formatter:_1d,styles:"text-align:center;",width:"30px",noresize:true,hidden:!this.allowEditUser},{name:"Active",field:"active",width:"40px",noresize:true,editable:true,type:dojox.grid.cells.Bool,styles:"text-align:center;vertical-align:bottom;padding-bottom:2px;"},{name:"First name",field:"firstName",formatter:_21,width:"60px",noresize:true},{name:"Last name",field:"lastName",formatter:_21,width:"83px",noresize:true},{name:"Email",field:"email",formatter:_21,width:"115px",noresize:true},{name:"Role",field:"role",formatter:_21,width:"73px",noresize:true},{name:"Last login",field:"lastLogin",formatter:_21,width:"100%",noresize:true},{name:"contact code",field:"contactCode",hidden:true}]}];
var _25=dojo.hitch(this,function(){
var _26={loadingMessage:Px.Ex.Application.getWaitHtml(),store:this.usersStore,query:{email:"*"},queryOptions:{ignoreCase:true},clientSort:true,onFetchError:dojo.hitch(this,function(_27,req){
if(!req){
return;
}
this.usersGrid._pending_requests[req.start]=false;
}),autoHeight:20,height:"35em",selectionMode:"single",canSort:function(_28){
return Math.abs(_28)!=1;
},structure:_24};
_26.onRowContextMenu=function(){
};
_26.selectable=true;
this.usersGrid=new dojox.grid.DataGrid(_26,div);
this.usersGrid.startup();
this.usersGrid.connect(this.usersGrid,"onRowClick",dojo.hitch(this,function(e){
if(e.cellIndex!=0||e.target.nodeName.toUpperCase()!="A"){
return;
}
var _29=this.itemToObject(e.grid.store,e.grid.getItem(e.rowIndex));
var dlg=new Px.Ex.BuyerUserDialog({user:_29,messages:this.messages,EMAIL_REGEXP:this.EMAIL_REGEXP,NAME_REGEXP:this.NAME_REGEXP,reloadUsersGrid:dojo.hitch(this,"reloadUsersGrid")});
dlg.show();
}));
this.usersGrid.connect(this.usersGrid,"onStyleRow",dojo.hitch(this,function(e){
try{
var _2a=this.usersGrid.getItem(e.index);
if(_2a){
var _2b=this.usersGrid.store.getValue(_2a,"active");
if(!_2b){
e.customClasses+=" user-not-active-class";
}
}
}
catch(e){
}
}));
});
dojo.addOnLoad(_25);
},reloadUsersGrid:function(){
if(!this.usersGrid){
return;
}
this.usersStore.save();
this.usersStore.close();
this.usersStore._jsonFileUrl=this.getUsersUrl();
this.usersGrid.selection.deselectAll();
this.usersGrid._refresh();
this.showBuyerName();
},showBuyerName:function(){
try{
var _2c=this.buyerStore.getLabel(this.buyerStore._getItemByIdentity(this.buyerId));
dojo.byId("usersForId").innerHTML=_2c;
dojo.byId("buyernameId").innerHTML=_2c;
}
catch(e){
}
},connectUsersStore:function(){
this.usersStoreConnection=dojo.connect(this.usersStore,"onSet",this,"onUsersStoreSet");
},disconnectUsersStore:function(){
if(this.usersStoreConnection){
dojo.disconnect(this.usersStoreConnection);
}
},itemToObject:function(_2d,_2e){
var _2f={};
for(var key in _2e){
if(key!==_2d._storeRefPropName&&key!==_2d._itemNumPropName&&key!==_2d._reverseRefMap&&key!==_2d._rootItemPropName){
var _30=key;
var _31=_2d.getValues(_2e,_30);
if(_31.length==1){
_2f[_30]=_2d._flatten(_31[0]);
}else{
var _32=[];
for(var j=0;j<_31.length;++j){
_32.push(_2d._flatten(_31[j]));
_2f[_30]=_32;
}
}
}
}
return _2f;
},getUsersUrl:function(){
return "/buyers/users-list"+"?entityCode="+this.buyerId;
},destroy:function(){
try{
this.buyerCombo.destroyRecursive();
}
catch(e){
}
try{
this.standBy.destroyRecursive();
}
catch(e){
}
this.disconnectUsersStore();
try{
this.usersGrid.destroyRecursive();
}
catch(e){
}
try{
this._form.destroyRecursive();
}
catch(e){
}
}});
(function(){
dojo.declare("Px.Ex.BuyerUserDialog",[Px.Ex.ModalDialogMixin,Px.Ex.XhrMixin],{user:undefined,messages:undefined,EMAIL_REGEXP:".*",NAME_REGEXP:".*",reloadUsersGrid:undefined,constructor:function(_1){
dojo.mixin(this,_1);
},show:function(){
var _2=dojo.hitch(this,"loadDialog");
this.modalDialog(_2);
},loadDialog:function(){
this.setTopCss(50);
var _3=Px.Ex.Application.Titles.EDIT_BUYER_USER;
Px.Ex.Application.menu.buildDialogSubTitle(_3);
this.xhrLoad({selector:"#divModalDialogContent",content:{user:dojo.toJson(this.user)},url:"/buyers/buyer-user-dialog",load:dojo.hitch(this,"bindDialogEvents")});
},cleanupForm:function(){
if(this._form){
this._form.destroyRecursive();
delete this._form;
}
},bindDialogEvents:function(){
var u=this.user=dojo.fromJson(dojo.byId("userDataId").innerHTML);
$("#divModalDialog #cancel").click(dojo.hitch(this,function(){
$.modal.impl.close();
this.cleanupForm();
}));
if(!this.readOnly){
$("#divModalDialog #submit").click(dojo.hitch(this,"validateAndSend"));
}
var f=this._form=new dijit.form.Form({onSubmit:function(){
return false;
}},"editUserFormId");
f.connect(f.domNode,"onkeydown",dojo.hitch(this,function(e){
if((e.keyCode==dojo.keys.ENTER||e.keyCode==dojo.keys.NUMPAD_ENTER)&&e.target.type!="textarea"){
setTimeout(dojo.hitch(this,this.validateAndSend),10);
}
}));
var m=this.messages;
dojo.byId("usernameId2").innerHTML=u.userName;
dojo.byId("emailId2").innerHTML=u.email;
new Px.Ex.ValidationTextBox({name:"firstName",value:u.firstName,trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptFirstName||"",invalidMessage:m.invalidFirstName||"$_unset_$",emptyMessage:m.emptyFirstName||"$_unset_$","class":"form-input"},"firstNameId2");
new Px.Ex.ValidationTextBox({name:"lastName",value:u.lastName,trim:true,regExp:this.NAME_REGEXP,required:true,maxLength:50,promptMessage:m.promptLastName||"",invalidMessage:m.invalidLastName||"$_unset_$",emptyMessage:m.emptyLastName||"$_unset_$","class":"form-input"},"lastNameId2");
new dijit.form.CheckBox({name:"active",checked:u.active},"activeId2");
new dijit.form.CheckBox({name:"sendWelcomeEmail",checked:u.sendWelcomeEmail},"sendWelcomeEmailId2");
new dijit.form.CheckBox({name:"passwordExpiration",checked:u.passwordExpiration},"passwordExpirationId2");
this.userRolesStore=new dojo.data.ItemFileReadStore({data:dojo.fromJson(dojo.byId("userRolesDataId").value)});
this.userRolesCombo=new Px.Ex.FilteringSelect({name:"roleCode",store:this.userRolesStore,value:u.roleCode,promptMessage:m.promptUserRoles||"",invalidMessage:m.invalidUserRoles||"$_unset_$",emptyMessage:m.emptyUserRoles||"$_unset_$",searchAttr:"name","class":"form-input"},"roleId2");
},validateAndSend:function(){
if(!this._form.validate()){
return;
}
var o=this._form.attr("value");
o.active=o.active[0]||"";
o.sendWelcomeEmail=o.sendWelcomeEmail[0]||"";
o.passwordExpiration=o.passwordExpiration[0]||"";
o=dojo.mixin({},this.user,o);
this._newUser=o;
this.clearError();
this.hideDialogContentAndWait(dojo.hitch(this,function(){
this.xhr({url:"/sellers/save-user",content:{user:dojo.toJson(o)},handleAs:"json",load:dojo.hitch(this,"saveUserResponse")});
}));
},saveUserResponse:function(_4){
if(_4["return"]){
ret=_4["return"];
if(ret.success!==undefined&&!ret.success){
this.showDialogContentOnError(_4);
}else{
this.cleanupForm();
this.showDialogContentOnSuccess("User "+this._newUser.userName+" was saved successfully!");
this.reloadUsersGrid();
}
}else{
this.showDialogContentOnError(_4);
}
},destroy:function(){
this.cleanupForm();
}});
})();
dojo.declare("Px.Ex.BillingNetAdjScreen",[Px.Ex.XhrMixin],{DIV_CAMPAIGNS_REPORTED:"reportedCampaigns",DIV_CAMPAIGNS_APPROVED:"approvedCampaigns",DIV_CAMPAIGNS_APPROVED_PERC:"approvedCampaignsPerc",DIV_REVENUE_REPORTED:"reportedRevenue",DIV_REVENUE_ADJUSTED:"adjustedRevenue",DIV_REVENUE_APPROVED:"approvedRevenue",DIV_REVENUE_APPROVED_PERC:"approvedRevenuePerc",DIV_IMPRESSIONS_REPORTED:"reportedImpressions",DIV_IMPRESSIONS_ADJUSTED:"adjustedImpressions",DIV_IMPRESSIONS_APPROVED:"approvedImpressions",DIV_IMPRESSIONS_APPROVED_PERC:"approvedImpressionsPerc",DIV_CONTENT:"divContent",DIV_MONTH_SELECT:"billingNetAdjMonth",DIV_PLATFORM_SELECT:"billingNetAdjPlatform",DIV_PLATFORM_LIST:"platformList",DIV_NETWORK_SELECT:"billingNetAdjNetwork",DIV_CONSTANTS:"div-constants-id",DIV_INPUTS:"inputs",DIV_BUTTONS:"buttons",DIV_INFO:"info",DIV_GRID:"gridTable",DIV_ERROR_MESSAGE:"errorMessage",DIV_INFO_WAITING:"info_waiting",DIV_INFO_CONTENT:"info_content",DIV_GRID_WAITING:"gridTable_waiting",DIV_GRID_CONTENT:"gridTable_content",FIELD_CAMPAIGN_NAME:"campaignName",FIELD_CAMPAIGN_CODE:"campaignCode",FIELD_REVENUE_REPORTED:"sumOfRevenue",FIELD_REVENUE_APPROVED:"approvedRevenue",FIELD_IMPRESSIONS_REPORTED:"sumOfImprs",FIELD_IMPRESSIONS_APPROVED:"approvedImprs",FIELD_NETWORK_NAME:"networkName",FIELD_APPROVAL_STATUS:"approvalStatus",FIELD_FEE_CREDIT:"feeCredit",FIELD_IMPRESSIONS_FACTOR:"imprsFactor",FIELD_LEAD_SEGMENT_CODE:"leadSegmentCode",FIELD_REVENUE_FACTOR:"revenueFactor",FIELD_CAMPAIGN_DIRTY_STATUS:"dirtyStatus",FIELD_REVENUE_APPROVED_RESET:"approvedRevenueForReset",FIELD_IMPRESSIONS_APPROVED_RESET:"approvedImprsForReset",FIELD_APPROVAL_STATUS_RESET:"approvalStatusForReset",APPROVAL_STATUS_NOTAPPROVED:0,APPROVAL_STATUS_FIXED:1,APPROVAL_STATUS_DELETED:2,APPROVAL_STATUS_SEGMENT:3,APPROVAL_STATUS_DATABUY:4,APPROVAL_STATUS_NOTCHANGED:5,CAMPAIGN_NONDIRTY_FLAG:0,CAMPAIGN_DIRTY_FLAG:1,CAMPAIGN_INDATABASE_FALSE:0,CAMPAIGN_INDATABASE_TRUE:1,PERMISSION_SCREEN:"screen",PERMISSION_FUNC_RESET:"func-reset",PERMISSION_FUNC_APPROVE:"func-approve",PERMISSION_FUNC_REMOVE:"func-remove",PERMISSION_FUNC_APPLYMINPAYMENT:"func-apply-min-payment",PERMISSION_FUNC_APPLYCREDIT:"func-apply-credit",PERMISSION_FUNC_ADD:"func-add",PERMISSION_FUNC_EXPORT:"func-export",CURRENCY:"USD",RIGHTMEDIA_EXCHANGE_ID:2,_platformWithNoNetwork:false,draw:function(){
dojo.byId(this.DIV_CONTENT).innerHTML=Px.Ex.Application.getWaitHtml();
this._outerConnections=[];
this._innerConnections=[];
this.xhrLoad({selector:"#"+this.DIV_CONTENT,url:"/billing/network-adjustments-screen",load:dojo.hitch(this,"createScreen"),error:dojo.hitch(this,"showXhrError")});
},createScreen:function(){
dojo.parser.parse(dojo.byId(this.DIV_INPUTS));
this.constants=dojo.fromJson(dojo.byId(this.DIV_CONSTANTS).innerHTML);
dojo.byId(this.DIV_INFO_WAITING).innerHTML=Px.Ex.Application.getWaitHtml();
dojo.byId(this.DIV_GRID_WAITING).innerHTML=Px.Ex.Application.getWaitHtml();
this.monthSelect=dijit.byId(this.DIV_MONTH_SELECT);
this.monthSelect.onChange=dojo.hitch(this,"onMonthChange");
this.networkSelect=dijit.byId(this.DIV_NETWORK_SELECT);
this.networkSelect.searchAttr=this.FIELD_NETWORK_NAME;
this.networkSelect.attr("disabled",true);
this.platformSelectStore=new dojo.data.ItemFileReadStore({data:dojo.fromJson(dojo.byId(this.DIV_PLATFORM_LIST).value)});
this.platformSelect=dijit.byId(this.DIV_PLATFORM_SELECT);
this.platformSelect.store=this.platformSelectStore;
this.platformSelect.searchAttr=this.FIELD_NETWORK_NAME;
this.platformSelect.onChange=dojo.hitch(this,"onPlatformChange");
this.gridStore=new dojo.data.ItemFileWriteStore({clearOnClose:true,data:{identifier:this.FIELD_CAMPAIGN_CODE,label:this.FIELD_CAMPAIGN_NAME,items:[]}});
var _1=this.getGridStructure();
this.grid=new dojox.grid.DataGrid({loadingMessage:Px.Ex.Application.getWaitHtml(),store:this.gridStore,query:{campaignCode:"*"},queryOptions:{ignoreCase:true},clientSort:true,style:{width:"100%"},autoHeight:true,rowsPerPage:1000,selectionMode:"single",selectable:true,canSort:function(_2){
return true;
},onStyleRow:dojo.hitch(this,"onStyleRow"),singleClickEdit:true,structure:_1,canEdit:dojo.hitch(this,function(_3,_4){
var _5=this.gridStore.getValue(this.grid.getItem(_4),this.FIELD_APPROVAL_STATUS);
if(_5==this.APPROVAL_STATUS_NOTAPPROVED){
return true;
}else{
return false;
}
})},this.DIV_GRID_CONTENT);
this.grid.startup();
this.grid._refresh();
},getGridStructure:function(){
var _6=dojo.hitch(this,function(_7,_8){
var _9=this.grid.store.getValue(this.grid.getItem(_8),this.FIELD_CAMPAIGN_CODE);
return "<div title='Code = "+_9+" ; Name = "+_7+"' class='dojoxEllipsis'>"+_7+"</div>";
});
var _a=dojo.hitch(this,function(_b,_c){
return isNaN(_b)?"...":dojo.number.format(_b);
});
var _d=dojo.hitch(this,function(_e,_f){
return isNaN(_e)?"...":dojo.currency.format(_e,{currency:this.CURRENCY});
});
var _10=dojo.hitch(this,function(_11,_12){
var _13=this.gridStore.getValue(this.grid.getItem(_12),this.FIELD_IMPRESSIONS_REPORTED);
var _14=isNaN(_11)?NaN:_11;
return isNaN(_14)||(_14==_13)?"...":dojo.currency.format(_11,{places:0});
});
var _15=dojo.hitch(this,function(_16,_17){
var _18=dojo.currency.format(this.gridStore.getValue(this.grid.getItem(_17),this.FIELD_REVENUE_REPORTED),{currency:this.CURRENCY});
var _19=isNaN(_16)?-1:dojo.currency.format(_16,{currency:this.CURRENCY});
return (_19==-1)||(_19==_18)?"...":_19;
});
var _1a=dojo.hitch(this,function(_1b,_1c){
return this.formatRowLevel(_1b,_1c);
});
var _1d=[{cells:[[{name:this.constants["BillNetAdj_HeaderCampaign"],field:this.FIELD_CAMPAIGN_NAME,noresize:true,width:"250px",headerStyles:"text-align: center;",formatter:_6},{name:this.constants["BillNetAdj_HeaderReportedImpressions"],field:this.FIELD_IMPRESSIONS_REPORTED,noresize:true,width:"122px",cellStyles:"text-align: right;",headerStyles:"text-align: center;",formatter:_a},{name:this.constants["BillNetAdj_HeaderReportedRevenue"],field:this.FIELD_REVENUE_REPORTED,noresize:true,width:"122px",cellStyles:"text-align: right; border-right-style: solid; border-right-width: 6px;",constraint:{currency:this.CURRENCY},headerStyles:"text-align: center; border-right-style: solid; border-right-width: 6px;",formatter:_d},{name:this.constants["BillNetAdj_HeaderApprovedImpressions"],field:this.FIELD_IMPRESSIONS_APPROVED,noresize:true,width:"122px",editable:true,type:dojox.grid.cells._Widget,widgetClass:"dijit.form.NumberTextBox",cellStyles:"text-align: right;border-left-style: solid; border-left-width: 6px;",headerStyles:"text-align: center;border-left-style: solid; border-left-width: 6px;",constraint:{min:0,places:0},formatter:_10},{name:"Initial Load Value of impressions",field:this.FIELD_IMPRESSIONS_APPROVED_RESET,hidden:true},{name:this.constants["BillNetAdj_HeaderApprovedRevenue"],field:this.FIELD_REVENUE_APPROVED,noresize:true,width:"122px",editable:true,type:dojox.grid.cells._Widget,widgetClass:"dijit.form.CurrencyTextBox",cellStyles:"text-align: right;",headerStyles:"text-align: center;",constraint:{min:0,places:2,currency:this.CURRENCY},formatter:_15},{name:"Initial load value Value of revenue",field:this.FIELD_REVENUE_APPROVED_RESET,hidden:true},{name:"Initial Load Status of approval",field:this.FIELD_APPROVAL_STATUS_RESET,hidden:true},{name:"Campaign Approval Status",field:this.FIELD_APPROVAL_STATUS,hidden:true},{name:"Campaign Dirty Status",field:this.FIELD_CAMPAIGN_DIRTY_STATUS,hidden:true},{name:"",noresize:true,width:"100%",editable:false,formatter:_1a}]]}];
return _1d;
},loadGridContent:function(){
this.killInnerConnections();
this.showGrid(true,true);
this.showPanels(true);
this._monthValue=this.monthSelect.value;
this._platformValue=this.platformSelect.value;
if(dojo.attr(this.networkSelect,"disabled")!=true){
this._networkValue=this.networkSelect.value;
}else{
this._networkValue=this._platformValue;
}
this.xhr({url:"/billing/network-adjustments-table-data",content:{month:this.monthSelect.value,networkCode:this._networkValue},load:dojo.hitch(this,"loadGridContent_callback"),error:dojo.hitch(this,"showXhrError"),handleAs:"json"});
},blurFunction:function(){
this._blurFunctionConnection=null;
this._innerConnections.push(dojo.connect(this.grid.domNode,"onmouseleave",dojo.hitch(this,function(e){
this._blurFunctionConnection=dojo.connect(window,"onclick",this.grid.edit,"apply");
})));
this._innerConnections.push(dojo.connect(this.grid.domNode,"onmouseenter",dojo.hitch(this,function(e){
dojo.disconnect(this._blurFunctionConnection);
})));
},showXhrError:function(_1e,_1f){
this.grid.loadingMessage="";
var msg=Px.Ex.Application._extractError(_1e,_1f);
msg=msg.replace(/\<br\>/ig,"&nbsp;");
this.showError(msg);
},showError:function(msg){
dojo.byId(this.DIV_ERROR_MESSAGE).innerHTML=msg;
dojo.style(this.DIV_ERROR_MESSAGE,"opacity",0);
var _20=dojo.fadeIn({node:this.DIV_ERROR_MESSAGE,duration:1000});
_20.play();
this._errorTimer=setTimeout(dojo.hitch(this,"clearError"),8000);
},clearError:function(){
var _21=dojo.fadeOut({node:this.DIV_ERROR_MESSAGE,duration:1000});
_21.play();
clearTimeout(this._errorTimer);
delete this._errorTimer;
},loadGridContent_callback:function(_22){
if(_22["faultstring"]){
this.showError(_22["faultstring"]);
}else{
if(this.gridStore.isDirty){
this.gridStore.revert();
}
this.gridStore.close();
this.processReportData(_22);
this.gridStore._jsonData=_22;
this.gridStore.fetch();
this.grid._refresh();
this.handleUpperButtons();
this._innerConnections.push(dojo.connect(this.grid,"onApplyCellEdit",dojo.hitch(this,function(_23,_24,_25){
this.onAfterCellEdit(_24,_25,this._tempValue,this.gridStore.getValue(this.grid.getItem(_24),_25));
})));
this._innerConnections.push(dojo.connect(this.grid,"onStartEdit",dojo.hitch(this,function(_26,_27){
console.log("onStartEdit");
this._tempValue=this.gridStore.getValue(this.grid.getItem(_27),_26._props["field"]);
})));
this._innerConnections.push(dojo.connect(this.grid,"onCellClick",dojo.hitch(this,function(e){
this.onWidgetClick(e);
})));
this.blurFunction();
this.showGrid(true,false);
this.updateInfoPanel();
}
},handleUpperButtons:function(){
if(dojo.byId("btnApproveAll")){
dojo.byId("btnApproveAll").title=this.constants["BillNetAdj_ApproveAllButtonTooltip"];
this._innerConnections.push(dojo.connect(dojo.byId("btnApproveAll"),"onclick",dojo.hitch(this,"onApproveAllClick")));
}
if(dojo.byId("btnApplyMinPayment")){
dojo.byId("btnApplyMinPayment").title=this.constants["BillNetAdj_ApplyMinPaymentButtonTooltip"];
this._innerConnections.push(dojo.connect(dojo.byId("btnApplyMinPayment"),"onclick",dojo.hitch(this,"onApplyMinPaymentClick")));
}
if(dojo.byId("btnApplyCredit")){
dojo.byId("btnApplyCredit").title=this.constants["BillNetAdj_ApplyCreditButtonTooltip"];
this._innerConnections.push(dojo.connect(dojo.byId("btnApplyCredit"),"onclick",dojo.hitch(this,"onApplyCreditClick")));
}
if(dojo.byId("btnReset")){
dojo.byId("btnReset").title=this.constants["BillNetAdj_ResetAllButtonTooltip"];
this._innerConnections.push(dojo.connect(dojo.byId("btnReset"),"onclick",dojo.hitch(this,"onResetAllClick")));
}
if(dojo.byId("btnAdd")){
dojo.byId("btnAdd").title=this.constants["BillNetAdj_AddCampaignButtonTooltip"];
this._innerConnections.push(dojo.connect(dojo.byId("btnAdd"),"onclick",dojo.hitch(this,"onAddClick")));
}
if(dojo.byId("btnExport")){
dojo.byId("btnExport").title=this.constants["BillNetAdj_ExportToExcelButtonTooltip"];
this._innerConnections.push(dojo.connect(dojo.byId("btnExport"),"onclick",dojo.hitch(this,"onExportClick")));
}
if(dojo.byId("btnRefresh")){
this._innerConnections.push(dojo.connect(dojo.byId("btnRefresh"),"onclick",dojo.hitch(this,"onRefresh")));
}
},onRefresh:function(){
var _28=this.computeValidationState();
if(_28&&this.isDirty()){
this.showDiscardMessage();
}
if(_28&&!this.isDirty()){
this.loadGridContent();
}
},onApproveAllClick:function(){
for(var _29 in this.gridStore._arrayOfAllItems){
this.approveCampaign(parseInt(_29));
}
this.updateInfoPanel();
},onApplyMinPaymentClick:function(){
},onApplyCreditClick:function(){
},onResetAllClick:function(){
for(var _2a in this.gridStore._arrayOfAllItems){
if(this.canCampaignBeReset(_2a)){
this.resetCampaign(parseInt(_2a));
}
}
this.updateInfoPanel();
},onAddClick:function(){
if(this.platformSelect.value==this.RIGHTMEDIA_EXCHANGE_ID){
var dlg=new Px.Ex.BillingNetAdjScreen.BillingNewCampaignRMX({parentObject:this});
}else{
var dlg=new Px.Ex.BillingNetAdjScreen.BillingNewCampaignNonRMX({parentObject:this});
}
dlg.show();
},onExportClick:function(){
var _2b=this.constants["BillNetAdj_HeaderCampaign"]+","+this.constants["BillNetAdj_HeaderReportedImpressions"]+","+this.constants["BillNetAdj_HeaderReportedRevenue"]+","+this.constants["BillNetAdj_HeaderApprovedImpressions"]+","+this.constants["BillNetAdj_HeaderApprovedRevenue"]+","+this.constants["BillNetAdj_HeaderCampaignApprovalStatus"];
var _2c="";
dojo.forEach(this.gridStore._arrayOfAllItems,dojo.hitch(this,function(v){
_2c+=v[this.FIELD_CAMPAIGN_NAME][0]+String.fromCharCode(30)+(isNaN(v[this.FIELD_IMPRESSIONS_REPORTED][0])?0:v[this.FIELD_IMPRESSIONS_REPORTED][0])+String.fromCharCode(30)+(isNaN(v[this.FIELD_REVENUE_REPORTED][0])?0:v[this.FIELD_REVENUE_REPORTED][0])+String.fromCharCode(30)+(isNaN(v[this.FIELD_IMPRESSIONS_APPROVED][0])?0:v[this.FIELD_IMPRESSIONS_APPROVED][0])+String.fromCharCode(30)+(isNaN(v[this.FIELD_REVENUE_APPROVED][0])?0:v[this.FIELD_REVENUE_APPROVED][0])+String.fromCharCode(30)+this.constants["BillNetAdj_ApprovalStatus"+v[this.FIELD_APPROVAL_STATUS]]+String.fromCharCode(29);
}));
if(_2c!=""){
_2c=_2c.substr(0,_2c.length-1);
}
var _2d=document.createElement("form");
dojo.attr(_2d,"method","post");
document.body.appendChild(_2d);
var _2e=this.platformSelectStore._itemsByIdentity[this._platformValue]["networkName"][0];
if(this._platformWithNoNetwork){
var _2f=_2e;
}else{
var _2f=this.networkSelectStore._itemsByIdentity[this._networkValue]["networkName"][0];
}
var _30=this.monthSelect.value;
var _31=this.monthSelect.store.root.children[this.monthSelect.value]["text"];
var _32=new Date();
var _33=(_32.getFullYear())+"_"+(_32.getMonth()+1<10?"0"+(_32.getMonth()+1):_32.getMonth()+1)+"_"+(_32.getDate())+"_"+_32.getHours()+"_"+(_32.getMinutes()<10?("0"+_32.getMinutes()):_32.getMinutes())+"_"+(_32.getSeconds()<10?"0"+_32.getSeconds():_32.getSeconds());
var _34="Billing_"+_2e.replace(" ","_")+"_"+_2f.replace(" ","_")+"_"+_31.replace(" ","_")+"."+_33;
dojo.io.iframe.send({form:_2d,content:{format:"excel",file:_34,activityMonth:_30,platform:_2e,network:_2f,tableHeader:_2b,tableContent:_2c},url:"/billing/network-adjustments-export-to-excel",error:dojo.hitch(this,function(_35){
}),preventCache:true,timeout:10});
document.body.removeChild(_2d);
},dirtyCampaignIfNeeded:function(_36){
var _37=this.grid.store.getValue(this.grid.getItem(_36),this.FIELD_IMPRESSIONS_REPORTED);
var _38=this.gridStore.getValue(this.grid.getItem(_36),this.FIELD_IMPRESSIONS_APPROVED);
var _39=this.grid.store.getValue(this.grid.getItem(_36),this.FIELD_REVENUE_REPORTED);
var _3a=this.gridStore.getValue(this.grid.getItem(_36),this.FIELD_REVENUE_APPROVED);
if(((!isNaN(_38)&&(_38!=_37)))||((!isNaN(_3a)&&(_3a!=_39)))){
this.gridStore.setValue(this.grid.getItem(_36),this.FIELD_CAMPAIGN_DIRTY_STATUS,this.CAMPAIGN_DIRTY_FLAG);
}else{
this.gridStore.setValue(this.grid.getItem(_36),this.FIELD_CAMPAIGN_DIRTY_STATUS,this.CAMPAIGN_NONDIRTY_FLAG);
}
},onWidgetClick:function(e){
var _3b=e.target.className;
if(_3b.indexOf("campaign_approval")>=0){
this.onCampaignApprovalClick(e.target,e.rowIndex);
}
if(_3b.indexOf("campaign_reset")>=0){
this.onCampaignResetClick(e.target,e.rowIndex);
}
if(_3b.indexOf("campaign_removal")>=0){
this.onCampaignRemovalClick(e.target,e.rowIndex);
}
},processReportData:function(_3c){
for(var _3d in _3c["items"]){
if(isNaN(_3c["items"][_3d][this.FIELD_IMPRESSIONS_REPORTED])){
_3c["items"][_3d][this.FIELD_IMPRESSIONS_REPORTED]=0;
}
if(isNaN(_3c["items"][_3d][this.FIELD_REVENUE_REPORTED])){
_3c["items"][_3d][this.FIELD_REVENUE_REPORTED]=0;
}
if(_3c["items"][_3d][this.FIELD_APPROVAL_STATUS]==this.APPROVAL_STATUS_NOTAPPROVED){
_3c["items"][_3d][this.FIELD_REVENUE_APPROVED]=_3c["items"][_3d][this.FIELD_REVENUE_REPORTED];
_3c["items"][_3d][this.FIELD_IMPRESSIONS_APPROVED]=_3c["items"][_3d][this.FIELD_IMPRESSIONS_REPORTED];
}
if(!isNaN(_3c["items"][_3d][this.FIELD_REVENUE_REPORTED])){
_3c["items"][_3d][this.FIELD_REVENUE_REPORTED]=parseFloat(_3c["items"][_3d][this.FIELD_REVENUE_REPORTED]).toFixed(2);
}
if(!isNaN(_3c["items"][_3d][this.FIELD_REVENUE_APPROVED])){
_3c["items"][_3d][this.FIELD_REVENUE_APPROVED]=parseFloat(_3c["items"][_3d][this.FIELD_REVENUE_APPROVED]).toFixed(2);
}
_3c["items"][_3d][this.FIELD_CAMPAIGN_DIRTY_STATUS]=this.CAMPAIGN_NONDIRTY_FLAG;
_3c["items"][_3d][this.FIELD_REVENUE_APPROVED_RESET]=_3c["items"][_3d][this.FIELD_REVENUE_APPROVED];
_3c["items"][_3d][this.FIELD_IMPRESSIONS_APPROVED_RESET]=_3c["items"][_3d][this.FIELD_IMPRESSIONS_APPROVED];
_3c["items"][_3d][this.FIELD_APPROVAL_STATUS_RESET]=_3c["items"][_3d][this.FIELD_APPROVAL_STATUS];
}
},onCampaignApprovalClick:function(_3e,_3f){
if(_3e.className.indexOf("campaign_approve")>=0){
if(this.approveCampaign(_3f)){
this.updateInfoPanel();
}else{
}
}else{
if(this.unapproveCampaign(_3f)){
this.updateInfoPanel();
}else{
}
}
},onCampaignResetClick:function(_40,_41){
if(_40.className.indexOf("campaign_reset_on")>=0){
if(this.resetCampaign(_41)){
this.updateInfoPanel();
}else{
}
}
},onCampaignRemovalClick:function(_42,_43){
if(_42.className.indexOf("campaign_remove")>=0){
if(this.removeCampaign(_43)){
this.updateInfoPanel();
}else{
}
}else{
if(this.unremoveCampaign(_43)){
this.updateInfoPanel();
}else{
}
}
},approveCampaign:function(_44){
var _45=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_APPROVAL_STATUS_RESET);
var _46=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_APPROVAL_STATUS);
var _47=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_CAMPAIGN_DIRTY_STATUS);
var _48=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_CAMPAIGN_CODE);
var _49=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_REVENUE_REPORTED);
var _4a=isNaN(this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_REVENUE_APPROVED))?_49:this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_REVENUE_APPROVED);
var _4b=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_IMPRESSIONS_REPORTED);
var _4c=isNaN(this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_IMPRESSIONS_APPROVED))?_4b:this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_IMPRESSIONS_APPROVED);
var _4d=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_FEE_CREDIT);
var _4e=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_IMPRESSIONS_FACTOR);
var _4f=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_LEAD_SEGMENT_CODE);
var _50=this.grid.store.getValue(this.grid.getItem(_44),this.FIELD_REVENUE_FACTOR);
var _51=false;
if(_46==this.APPROVAL_STATUS_NOTAPPROVED){
if(_45==this.APPROVAL_STATUS_SEGMENT){
_51=this.xhrCreateCampaignApproval(this.monthSelect.value,this.APPROVAL_STATUS_SEGMENT,_4c,_4a,_48,_4d,_4e,_4f,_50);
if(_51){
this.grid.store.setValue(this.grid.getItem(_44),this.FIELD_APPROVAL_STATUS,this.APPROVAL_STATUS_SEGMENT);
}
}else{
switch(_47){
case this.CAMPAIGN_NONDIRTY_FLAG:
if(_46==this.APPROVAL_STATUS_NOTAPPROVED){
_51=this.xhrCreateCampaignApproval(this.monthSelect.value,this.APPROVAL_STATUS_NOTCHANGED,_4c,_4a,_48,_4d,_4e,_4f,_50);
}else{
_51=this.xhrEditCampaignApproval(this.monthSelect.value,this.APPROVAL_STATUS_NOTCHANGED,_4c,_4a,_48,_4d,_4e,_4f,_50);
}
if(_51){
this.grid.store.setValue(this.grid.getItem(_44),this.FIELD_APPROVAL_STATUS,this.APPROVAL_STATUS_NOTCHANGED);
}
break;
case this.CAMPAIGN_DIRTY_FLAG:
if(_46==this.APPROVAL_STATUS_NOTAPPROVED){
_51=this.xhrCreateCampaignApproval(this.monthSelect.value,this.APPROVAL_STATUS_FIXED,_4c,_4a,_48,_4d,_4e,_4f,_50);
}else{
_51=this.xhrEditCampaignApproval(this.monthSelect.value,this.APPROVAL_STATUS_FIXED,_4c,_4a,_48,_4d,_4e,_4f,_50);
}
if(_51){
this.grid.store.setValue(this.grid.getItem(_44),this.FIELD_APPROVAL_STATUS,this.APPROVAL_STATUS_FIXED);
}
break;
}
}
if(_51){
this.grid.store.setValue(this.grid.getItem(_44),this.FIELD_CAMPAIGN_DIRTY_STATUS,this.CAMPAIGN_NONDIRTY_FLAG);
}
return _51;
}else{
return false;
}
},unapproveCampaign:function(_52){
var _53=false;
var _54=this.grid.store.getValue(this.grid.getItem(_52),this.FIELD_CAMPAIGN_CODE);
var _55=this.grid.store.getValue(this.grid.getItem(_52),this.FIELD_APPROVAL_STATUS);
if((_55!=this.APPROVAL_STATUS_NOTAPPROVED)&&(_55!=this.APPROVAL_STATUS_DELETED)){
_53=this.xhrDeleteCampaignApproval(this.monthSelect.value,_54);
if(_53){
this.grid.store.setValue(this.grid.getItem(_52),this.FIELD_APPROVAL_STATUS,this.APPROVAL_STATUS_NOTAPPROVED);
var _56=false;
var _57=this.grid.store.getValue(this.grid.getItem(_52),this.FIELD_IMPRESSIONS_APPROVED);
var _58=this.grid.store.getValue(this.grid.getItem(_52),this.FIELD_IMPRESSIONS_APPROVED_RESET);
var _59=this.grid.store.getValue(this.grid.getItem(_52),this.FIELD_REVENUE_APPROVED);
var _5a=this.grid.store.getValue(this.grid.getItem(_52),this.FIELD_REVENUE_APPROVED_RESET);
if(_57!=_58){
_56=true;
}
if(_59!=_5a){
_56=true;
}
if(_56){
this.grid.store.setValue(this.grid.getItem(_52),this.FIELD_CAMPAIGN_DIRTY_STATUS,this.CAMPAIGN_DIRTY_FLAG);
}
}
}
return _53;
},resetCampaign:function(_5b){
var _5c=this.grid.store.getValue(this.grid.getItem(_5b),this.FIELD_CAMPAIGN_CODE);
var _5d=this.grid.store.getValue(this.grid.getItem(_5b),this.FIELD_APPROVAL_STATUS);
var _5e=this.grid.store.getValue(this.grid.getItem(_5b),this.FIELD_APPROVAL_STATUS_RESET);
var _5f=this.grid.store.getValue(this.grid.getItem(_5b),this.FIELD_IMPRESSIONS_APPROVED_RESET);
var _60=this.grid.store.getValue(this.grid.getItem(_5b),this.FIELD_REVENUE_APPROVED_RESET);
var _61=this.grid.store.getValue(this.grid.getItem(_5b),this.FIELD_FEE_CREDIT);
var _62=this.grid.store.getValue(this.grid.getItem(_5b),this.FIELD_IMPRESSIONS_FACTOR);
var _63=this.grid.store.getValue(this.grid.getItem(_5b),this.FIELD_LEAD_SEGMENT_CODE);
var _64=this.grid.store.getValue(this.grid.getItem(_5b),this.FIELD_REVENUE_FACTOR);
var _65=false;
if((_5d==this.APPROVAL_STATUS_NOTAPPROVED)&&(_5e!=this.APPROVAL_STATUS_NOTAPPROVED)){
_65=this.xhrCreateCampaignApproval(this.monthSelect.value,_5e,_5f,_60,_5c,_61,_62,_63,_64);
}else{
if((_5d!=this.APPROVAL_STATUS_NOTAPPROVED)&&(_5e==this.APPROVAL_STATUS_NOTAPPROVED)){
_65=this.xhrDeleteCampaignApproval(this.monthSelect.value,_5c);
}else{
if((_5d!=this.APPROVAL_STATUS_NOTAPPROVED)&&(_5e!=this.APPROVAL_STATUS_NOTAPPROVED)){
_65=this.xhrEditCampaignApproval(this.monthSelect.value,_5e,_5f,_60,_5c,_61,_62,_63,_64);
}else{
_65=true;
}
}
}
if(_65){
this.grid.store.setValue(this.grid.getItem(_5b),this.FIELD_IMPRESSIONS_APPROVED,_5f);
this.grid.store.setValue(this.grid.getItem(_5b),this.FIELD_REVENUE_APPROVED,_60);
this.grid.store.setValue(this.grid.getItem(_5b),this.FIELD_APPROVAL_STATUS,_5e);
this.grid.store.setValue(this.grid.getItem(_5b),this.FIELD_CAMPAIGN_DIRTY_STATUS,this.CAMPAIGN_NONDIRTY_FLAG);
}
return _65;
},removeCampaign:function(_66){
var _67=false;
var _68=this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_CAMPAIGN_CODE);
var _69=this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_REVENUE_REPORTED);
var _6a=isNaN(this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_REVENUE_APPROVED))?_69:this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_REVENUE_APPROVED);
var _6b=this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_IMPRESSIONS_REPORTED);
var _6c=isNaN(this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_IMPRESSIONS_APPROVED))?_6b:this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_IMPRESSIONS_APPROVED);
var _6d=this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_FEE_CREDIT);
var _6e=this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_IMPRESSIONS_FACTOR);
var _6f=this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_LEAD_SEGMENT_CODE);
var _70=this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_REVENUE_FACTOR);
var _71=this.grid.store.getValue(this.grid.getItem(_66),this.FIELD_APPROVAL_STATUS);
if(_71!=this.APPROVAL_STATUS_DELETED){
if(_71==this.APPROVAL_STATUS_NOTAPPROVED){
_67=this.xhrCreateCampaignApproval(this.monthSelect.value,this.APPROVAL_STATUS_DELETED,0,0,_68,0,0,0,0);
}else{
_67=this.xhrEditCampaignApproval(this.monthSelect.value,this.APPROVAL_STATUS_DELETED,0,0,_68,0,0,0,0);
}
if(_67){
this.grid.store.setValue(this.grid.getItem(_66),this.FIELD_APPROVAL_STATUS,this.APPROVAL_STATUS_DELETED);
}
}
return _67;
},unremoveCampaign:function(_72){
var _73=false;
var _74=this.grid.store.getValue(this.grid.getItem(_72),this.FIELD_CAMPAIGN_CODE);
var _75=this.grid.store.getValue(this.grid.getItem(_72),this.FIELD_APPROVAL_STATUS);
if(_75==this.APPROVAL_STATUS_DELETED){
_73=this.xhrDeleteCampaignApproval(this.monthSelect.value,_74);
if(_73){
this.grid.store.setValue(this.grid.getItem(_72),this.FIELD_APPROVAL_STATUS,this.APPROVAL_STATUS_NOTAPPROVED);
}
}
return _73;
},onAfterCellEdit:function(_76,_77,_78,_79){
if(_78!=_79){
this.dirtyCampaignIfNeeded(_76);
this.updateInfoPanel();
}
},onMonthChange:function(_7a){
if(!isDefined(this.inCancel)){
var _7b=this.computeValidationState();
if(this.validationState["month"]){
this.lastInputChanged="month";
}
if(_7b&&this.isDirty()){
this.showDiscardMessage();
}
if(_7b&&!this.isDirty()){
this.loadGridContent();
}
}
},onPlatformChange:function(_7c){
if(!isDefined(this.inCancel)){
var _7d=this.computeValidationState();
if(this.validationState["platform"]){
this.lastInputChanged="platform";
}
if(this.validationState["platform"]&&this.isDirty()){
this.showDiscardMessage();
}
if(this.validationState["platform"]&&!this.isDirty()){
if(this.reloadNetworks(_7c)==true){
this._platformWithNoNetwork=false;
this.killInnerConnections();
this.showPanels(false);
this.showGrid(false);
this.emptyGrid();
}else{
this._platformWithNoNetwork=true;
this.loadGridContent();
}
}
}
},showPanels:function(_7e){
if(_7e){
dojo.byId(this.DIV_INFO).style.visibility="visible";
dojo.byId(this.DIV_BUTTONS).style.visibility="visible";
}else{
dojo.byId(this.DIV_INFO).style.visibility="hidden";
dojo.byId(this.DIV_BUTTONS).style.visibility="hidden";
}
},showGrid:function(_7f,_80){
if(_7f){
dojo.style(dojo.byId(this.DIV_GRID),"display","");
if(_80){
dojo.style(this.DIV_GRID_CONTENT,"display","none");
dojo.style(this.DIV_GRID_WAITING,"display","");
}else{
dojo.style(this.DIV_GRID_WAITING,"display","none");
dojo.style(this.DIV_GRID_CONTENT,"display","");
this.grid._refresh();
}
}else{
dojo.style(dojo.byId(this.DIV_GRID),"display","none");
}
},isDirty:function(){
if(this.grid){
for(var i=0;i<this.grid.rowCount;i++){
var _81=this.gridStore.getValue(this.grid.getItem(i),this.FIELD_CAMPAIGN_DIRTY_STATUS);
if(_81==this.CAMPAIGN_DIRTY_FLAG){
return true;
}
}
}
return false;
},emptyGrid:function(){
if(this.gridStore.isDirty){
this.gridStore.revert();
}
this.gridStore.close();
this.gridStore._jsonData={identifier:this.FIELD_CAMPAIGN_CODE,label:this.FIELD_CAMPAIGN_NAME,items:[]};
this.gridStore.fetch();
this.grid._refresh();
},onNetworkChange:function(_82){
if(!isDefined(this.inCancel)){
var _83=this.computeValidationState();
if(this.validationState["network"]){
this.lastInputChanged="network";
}
if(_83&&this.isDirty()){
this.showDiscardMessage();
}
if(_83&&!this.isDirty()){
this.loadGridContent();
}
}
},showDiscardMessage:function(){
var _84={message:this.constants["BillNetAdj_DiscardMessage"],okLabel:"Ok",cancelLabel:"Cancel",okCallback:dojo.hitch(this,"okCallback"),cancelCallback:dojo.hitch(this,"cancelCallback")};
var _85=new Px.Ex.MessageDialog(_84);
_85.show();
},okCallback:function(){
if(this.lastInputChanged!="platform"){
this.loadGridContent();
}else{
this.reloadNetworks(this.platformSelect.value);
this.showPanels(false);
this.showGrid(false);
this.emptyGrid();
}
},cancelCallback:function(){
this.inCancel=true;
this.monthSelect.attr("value",this._monthValue);
this.platformSelect.attr("value",this._platformValue);
this.networkSelect.attr("value",this._networkValue);
delete this.inCancel;
},reloadNetworks:function(_86){
if(this.networkSelect){
this.networkSelect.attr("disabled",true);
this.networkSelect.onChange=dojo.hitch(this,function(){
});
this.networkSelect.reset();
}
var _87=false;
dojo.xhrGet({sync:true,content:{platformCode:_86},url:"/billing/network-adjustments-network-list",load:dojo.hitch(this,function(_88){
var _89=_88.items.length;
if(_89>0){
_88.items.splice(0,0,{networkCode:_86,networkName:this.platformSelect.item.networkName[0]});
}
if(!this.networkSelectStore){
this.networkSelectStore=new dojo.data.ItemFileReadStore({clearOnClose:true,data:_88});
this.networkSelect.store=this.networkSelectStore;
}else{
this.networkSelectStore.close();
this.networkSelectStore._jsonData=_88;
this.networkSelectStore.fetch();
}
if(_89>0){
this.networkSelect.onChange=dojo.hitch(this,"onNetworkChange");
this.networkSelect.attr("disabled",false);
_87=true;
}else{
this.networkSelect.attr("disabled",true);
_87=false;
}
}),handleAs:"json"});
return _87;
},computeValidationState:function(){
this.validationState=new Array();
this.validationState["month"]=this.monthSelect.isValid(true)&&(this.monthSelect.value!="");
this.validationState["platform"]=this.platformSelect.isValid(true)&&(this.platformSelect.value!="");
if(this._platformWithNoNetwork){
this.validationState["network"]=true;
}else{
this.validationState["network"]=this.networkSelect.isValid(true)&&(this.networkSelect.value!="");
}
retval=true;
for(var i in this.validationState){
retval=retval&&this.validationState[i];
}
return retval;
},updateInfoPanel:function(div,_8a){
if(isDefined(div)&&isDefined(_8a)){
switch(div){
case this.DIV_CAMPAIGNS_REPORTED:
this.reportedCampaigns=_8a;
dojo.byId(div).innerHTML=dojo.number.format(this.reportedCampaigns,{min:0,places:0});
break;
case this.DIV_CAMPAIGNS_APPROVED:
this.approvedCampaigns=_8a;
dojo.byId(div).innerHTML=dojo.number.format(this.approvedCampaigns,{min:0,places:0});
var _8b=(this.approvedCampaigns/this.reportedCampaigns)*100;
dojo.byId(this.DIV_CAMPAIGNS_APPROVED_PERC).innerHTML=dojo.number.format(_8b,{min:0,places:0});
break;
case this.DIV_REVENUE_REPORTED:
this.reportedRevenue=_8a;
dojo.byId(div).innerHTML=dojo.currency.format(this.reportedRevenue,{currency:this.CURRENCY});
break;
case this.DIV_REVENUE_ADJUSTED:
this.adjustedRevenue=_8a;
dojo.byId(div).innerHTML=dojo.currency.format(this.adjustedRevenue,{currency:this.CURRENCY});
break;
case this.DIV_REVENUE_APPROVED:
this.approvedRevenue=_8a;
dojo.byId(div).innerHTML=dojo.currency.format(this.approvedRevenue,{currency:this.CURRENCY});
var _8b=(this.approvedRevenue/this.reportedRevenue)*100;
dojo.byId(this.DIV_REVENUE_APPROVED_PERC).innerHTML=dojo.number.format(_8b,{min:0,places:0});
break;
case this.DIV_IMPRESSIONS_REPORTED:
this.reportedImpressions=_8a;
dojo.byId(div).innerHTML=dojo.number.format(this.reportedImpressions,{min:0,places:0});
break;
case this.DIV_IMPRESSIONS_ADJUSTED:
this.adjustedImpressions=_8a;
dojo.byId(div).innerHTML=dojo.number.format(this.adjustedImpressions,{min:0,places:0});
break;
case this.DIV_IMPRESSIONS_APPROVED:
this.approvedImpressions=_8a;
dojo.byId(div).innerHTML=dojo.number.format(this.approvedImpressions,{min:0,places:0});
var _8b=(this.approvedImpressions/this.reportedImpressions)*100;
dojo.byId(this.DIV_IMPRESSIONS_APPROVED_PERC).innerHTML=dojo.number.format(_8b,{min:0,places:0});
break;
}
}else{
if(this.grid){
document.getElementById(this.DIV_INFO_CONTENT).style.display="none";
document.getElementById(this.DIV_INFO_WAITING).style.display="";
this.reportedCampaigns=0;
this.reportedRevenue=0;
this.reportedImpressions=0;
this.adjustedRevenue=0;
this.adjustedImpressions=0;
this.approvedRevenue=0;
this.approvedImpressions=0;
this.approvedCampaigns=0;
for(var i=0;i<this.grid.rowCount;i++){
var _8c=this.gridStore.getValue(this.grid.getItem(i),this.FIELD_APPROVAL_STATUS);
if(_8c!=this.APPROVAL_STATUS_DELETED){
this.reportedCampaigns++;
this.reportedRevenue+=this.customParseFloat(this.gridStore.getValue(this.grid.getItem(i),this.FIELD_REVENUE_REPORTED));
this.reportedImpressions+=this.customParseInt(this.gridStore.getValue(this.grid.getItem(i),this.FIELD_IMPRESSIONS_REPORTED));
if(_8c==this.APPROVAL_STATUS_NOTAPPROVED){
this.adjustedRevenue+=this.customParseFloat(this.gridStore.getValue(this.grid.getItem(i),this.FIELD_REVENUE_APPROVED));
this.adjustedImpressions+=this.customParseInt(this.gridStore.getValue(this.grid.getItem(i),this.FIELD_IMPRESSIONS_APPROVED));
}else{
this.approvedCampaigns++;
this.approvedRevenue+=this.customParseFloat(this.gridStore.getValue(this.grid.getItem(i),this.FIELD_REVENUE_APPROVED));
this.approvedImpressions+=this.customParseInt(this.gridStore.getValue(this.grid.getItem(i),this.FIELD_IMPRESSIONS_APPROVED));
}
}
}
this.updateInfoPanel(this.DIV_CAMPAIGNS_REPORTED,this.reportedCampaigns);
this.updateInfoPanel(this.DIV_CAMPAIGNS_APPROVED,this.approvedCampaigns);
this.updateInfoPanel(this.DIV_REVENUE_REPORTED,this.reportedRevenue);
this.updateInfoPanel(this.DIV_REVENUE_ADJUSTED,this.adjustedRevenue);
this.updateInfoPanel(this.DIV_REVENUE_APPROVED,this.approvedRevenue);
this.updateInfoPanel(this.DIV_IMPRESSIONS_REPORTED,this.reportedImpressions);
this.updateInfoPanel(this.DIV_IMPRESSIONS_ADJUSTED,this.adjustedImpressions);
this.updateInfoPanel(this.DIV_IMPRESSIONS_APPROVED,this.approvedImpressions);
document.getElementById(this.DIV_INFO_WAITING).style.display="none";
document.getElementById(this.DIV_INFO_CONTENT).style.display="";
}
}
},formatRowLevel:function(_8d,_8e){
var _8f=this.grid.store.getValue(this.grid.getItem(_8e),this.FIELD_CAMPAIGN_CODE);
var _90=this.grid.store.getValue(this.grid.getItem(_8e),this.FIELD_APPROVAL_STATUS);
var _91=this.grid.store.getValue(this.grid.getItem(_8e),this.FIELD_APPROVAL_STATUS_RESET);
var _92="<div style=\"text-align: center;\"><table style=\"margin-left: auto; margin-right: auto;\"><tbody><tr>";
if(_90!=this.APPROVAL_STATUS_DELETED){
if(this.constants["BillNetAdj_Permissions"][this.PERMISSION_FUNC_APPROVE]){
if(_90==this.APPROVAL_STATUS_NOTAPPROVED){
var _93=this.constants["BillNetAdj_ApproveWidgetTooltip"];
var _94="campaign_approve";
}else{
var _93=this.constants["BillNetAdj_UnapproveWidgetTooltip"];
var _94="campaign_unapprove";
}
_92+="<td style=\"padding-left: 5px;\"><div class=\"campaign_approval "+_94+" campaign_approval_clickable\" title=\""+_93+"\">"+"&nbsp;</div></td>";
}
if((this.constants["BillNetAdj_Permissions"][this.PERMISSION_FUNC_RESET])&&this.canCampaignBeReset(_8e)){
_92+="<td style=\"padding-left: 5px;\"><div class=\"campaign_reset_on\" title=\""+this.constants["BillNetAdj_ResetWidgetTooltip"]+"\">"+"&nbsp;</div></td>";
}else{
_92+="<td style=\"padding-left: 5px;\"><div class=\"campaign_reset_off\" title=\""+this.constants["BillNetAdj_ResetWidgetTooltip"]+"\">"+"&nbsp;</div></td>";
}
}
if((this.constants["BillNetAdj_Permissions"][this.PERMISSION_FUNC_REMOVE])&&(_90!=this.APPROVAL_STATUS_SEGMENT)&&(_91!=this.APPROVAL_STATUS_SEGMENT)){
if(_90!=this.APPROVAL_STATUS_DELETED){
var _93=this.constants["BillNetAdj_RemoveWidgetTooltip"];
var _94="campaign_remove";
}else{
var _93=this.constants["BillNetAdj_UnremoveWidgetTooltip"];
var _94="campaign_unremove";
}
_92+="<td style=\"padding-left: 5px;\"><div class=\"campaign_removal "+_94+" campaign_removal_on\" title=\""+_93+"\">"+"&nbsp;</div></td>";
}
_92+="</tr></tbody></table></div>";
return _92;
},onStyleRow:function(_95){
try{
var _96=_95.index;
var _97=this.grid.store.getValue(this.grid.getItem(_96),this.FIELD_CAMPAIGN_DIRTY_STATUS);
var _98=this.grid.store.getValue(this.grid.getItem(_96),this.FIELD_APPROVAL_STATUS);
if(_97==1){
_95.customClasses="campaign_dirty";
}else{
_95.customClasses="dojoxGridRow";
}
if(_98==this.APPROVAL_STATUS_DELETED){
_95.customClasses="campaign_deleted";
}else{
if(_95.customClasses!="campaign_dirty"){
_95.customClasses="dojoxGridRow";
}
}
}
catch(e){
}
},addToClasses:function(_99,_9a){
var _9b=_99.split(" ");
var _9c=false;
for(aClass in _9b){
if(_9b[aClass]==_9a){
_9c=true;
}
}
if(!_9c){
return (_9a+" "+_99);
}else{
return _99;
}
},removeFromClasses:function(_9d,_9e){
var _9f=_9d.split(" ");
var _a0=-1;
for(aClass in _9f){
if(_9f[aClass]==_9e){
_a0=aClass;
}
}
if(_a0==-1){
return _9d;
}else{
var _a1="";
for(aClass in _9f){
if(aClass!=_a0){
_a1+=_9f[aClass]+" ";
}
}
return _a1;
}
},xhrCreateCampaignApproval:function(_a2,_a3,_a4,_a5,_a6,_a7,_a8,_a9,_aa){
var _ab=false;
dojo.xhrGet({url:"/billing/network-adjustments-create-campaign-approval",content:{activityMonth:_a2,approvalStatus:_a3,approvedImprs:_a4,approvedRevenue:_a5,campaignCode:_a6,feeCredit:_a7,imprsFactor:_a8,leadSegmentCode:_a9,revenueFactor:_aa},sync:true,load:dojo.hitch(this,function(_ac){
if(_ac["return"]["success"]){
_ab=true;
}
}),error:dojo.hitch(this,function(){
_ab=false;
}),handleAs:"json"});
return _ab;
},xhrEditCampaignApproval:function(_ad,_ae,_af,_b0,_b1,_b2,_b3,_b4,_b5){
var _b6=false;
dojo.xhrGet({url:"/billing/network-adjustments-edit-campaign-approval",content:{activityMonth:_ad,approvalStatus:_ae,approvedImprs:_af,approvedRevenue:_b0,campaignCode:_b1,feeCredit:_b2,imprsFactor:_b3,leadSegmentCode:_b4,revenueFactor:_b5},sync:true,load:dojo.hitch(this,function(_b7){
if(_b7["return"]["success"]){
_b6=true;
}
}),error:dojo.hitch(this,function(){
_b6=false;
}),handleAs:"json"});
return _b6;
},xhrDeleteCampaignApproval:function(_b8,_b9){
var _ba=false;
dojo.xhrGet({url:"/billing/network-adjustments-delete-campaign-approval",content:{activityMonth:_b8,campaignCode:_b9},sync:true,load:dojo.hitch(this,function(_bb){
if(_bb["return"]["success"]){
_ba=true;
}
}),error:dojo.hitch(this,function(){
_ba=false;
}),handleAs:"json"});
return _ba;
},xhrCreateCampaign:function(_bc,_bd,_be,_bf,_c0,_c1,_c2,_c3,_c4){
var _c5=false;
dojo.xhrGet({sync:true,url:"/billing/network-adjustments-create-new-campaign",content:{campaignName:_bc,externalId2:_bd,networkCode:_be,platformCode:_bf,leadSegmentCode:_c0,approvedImprs:_c1,approvedRevenue:_c2,activityMonth:_c3,campaignCode:_c4},load:dojo.hitch(this,function(_c6){
if(_c6["return"]["success"]){
_c5=true;
}
}),error:dojo.hitch(this,function(){
_c5=false;
}),handleAs:"json"});
return _c5;
},canCampaignBeReset:function(_c7){
var _c8=this.grid.store.getValue(this.grid.getItem(_c7),this.FIELD_APPROVAL_STATUS);
var _c9=this.grid.store.getValue(this.grid.getItem(_c7),this.FIELD_IMPRESSIONS_APPROVED);
var _ca=this.grid.store.getValue(this.grid.getItem(_c7),this.FIELD_REVENUE_APPROVED);
var _cb=this.grid.store.getValue(this.grid.getItem(_c7),this.FIELD_APPROVAL_STATUS_RESET);
var _cc=this.grid.store.getValue(this.grid.getItem(_c7),this.FIELD_IMPRESSIONS_APPROVED_RESET);
var _cd=this.grid.store.getValue(this.grid.getItem(_c7),this.FIELD_REVENUE_APPROVED_RESET);
if((_c8!=_cb)||(_c9!=_cc)||(_ca!=_cd)){
return true;
}else{
return false;
}
},killInnerConnections:function(){
try{
if(this._innerConnections){
dojo.forEach(this._innerConnections,dojo.disconnect,this);
}
if(this._blurFunctionConnection){
dojo.disconnect(this._blurFunctionConnection);
}
}
catch(e){
}
},customParseFloat:function(_ce){
var _cf=parseFloat(_ce);
if(isNaN(_cf)){
return 0;
}else{
return _cf;
}
},customParseInt:function(_d0){
var _d1=parseInt(_d0);
if(isNaN(_d1)){
return 0;
}else{
return _d1;
}
},destroy:function(){
try{
this.cancelXhr();
}
catch(e){
}
try{
if(this._outerConnections){
dojo.forEach(this._outerConnections,dojo.disconnect,this);
}
}
catch(e){
}
try{
if(this._innerConnections){
dojo.forEach(this._innerConnections,dojo.disconnect,this);
}
}
catch(e){
}
try{
this.monthSelect.destroyRecursive(true);
}
catch(e){
}
try{
this.platformSelect.destroyRecursive(true);
}
catch(e){
}
try{
this.networkSelect.destroyRecursive(true);
}
catch(e){
}
try{
this.grid.destroyRecursive(true);
}
catch(e){
}
}});
dojo.declare("Px.Ex.BillingNetAdjScreen.BillingNewCampaignNonRMX",[Px.Ex.Dialog],{"class":"billing-new-campaign-dialog",parentObject:undefined,TooltipDialog_Type_Segment:1,TooltipDialog_Type_Copy:2,_connections:[],constructor:function(_d2){
dojo.mixin(this,_d2);
this.rotationImage=Px.Ex.Application.getWaitImageUrl();
},destroy:function(){
try{
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
}
}
catch(e){
}
},startup:function(){
this.inherited(arguments);
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(this.parentObject.constants["BillNetAdj_NewCampaignDialog_Title"]);
this.attr("content",Px.Ex.Application.getWaitHtml());
this.xhr({url:"/billing/network-adjustments-new-campaign-dialog",content:{networkCode:this.parentObject._networkValue},load:dojo.hitch(this,"createLayout"),handleAs:"json"});
},setLeadSegment:function(_d3){
if(this._activeSegment){
this._previousSegment=dojo.clone(this._activeSegment);
}
this._activeSegment=_d3;
dojo.attr(this._form_activeSegment,"displayedValue",_d3.channelName);
},setExistingCampaign:function(_d4,_d5){
this._campaignCode=_d4;
dojo.style(dojo.byId("campaignCode"),"visibility","visible");
dojo.byId("campaignCodeValue").innerHTML=_d4+"";
if(_d5){
dojo.attr(this._form_campaignName,"value",_d5);
this._form_campaignName.attr("readOnly",true);
}
},clearExistingCampaign:function(){
if(this._campaignCode){
delete this._campaignCode;
}
this._form_campaignName.attr("readOnly",false);
this._form_campaignName.attr("value","");
this._campaignNameChanged=false;
dojo.byId("campaignCodeValue").innerHTML="";
dojo.style(dojo.byId("campaignCode"),"visibility","hidden");
},createLayout:function(_d6){
var _d7=this.parentObject.constants;
this.data=_d6;
var _d8=dojo.create("div",{});
dojo.style(_d8,"marginLeft","18px");
dojo.style(_d8,"marginRight","18px");
var _d9=dojo.create("div",{},_d8);
var _da=dojo.create("span",{},_d9);
_da.innerHTML=this.parentObject.constants["BillNetAdj_NewCampaignDialog_Title_Platform"];
dojo.style(_da,"fontWeight","bold");
var _db=dojo.create("span",{},_d9);
_db.innerHTML=this.parentObject.platformSelectStore._itemsByIdentity[this.parentObject._platformValue]["networkName"][0];
dojo.style(_db,"marginLeft","10px");
if((!this.parentObject._platformWithNoNetwork)&&(this.parentObject._platformValue!=this.parentObject._networkValue)){
var _dc=dojo.create("div",{},_d8);
var _dd=dojo.create("span",{},_dc);
_dd.innerHTML=this.parentObject.constants["BillNetAdj_NewCampaignDialog_Title_Network"];
dojo.style(_dd,"fontWeight","bold");
var _de=dojo.create("span",{},_dc);
_de.innerHTML=this.parentObject.networkSelectStore._itemsByIdentity[this.parentObject._networkValue]["networkName"][0];
dojo.style(_de,"marginLeft","10px");
}
var _df=dojo.create("div",{},_d8);
this._form=new dijit.form.Form({"class":"newBuyerRequestForm",onSubmit:function(){
return false;
}},_df);
topFieldsDiv=dojo.create("div",{},_d8);
topFieldsTbl=dojo.create("table",{},topFieldsDiv);
dojo.style(topFieldsTbl,"marginLeft","auto");
dojo.style(topFieldsTbl,"marginRight","auto");
dojo.style(topFieldsTbl,"borderSpacing","0px 10px");
topFieldsTbody=dojo.create("tbody",{},topFieldsTbl);
topFieldsRow=dojo.create("tr",{},topFieldsTbody);
topFieldsRowCell=dojo.create("td",{innerHTML:_d7["BillNetAdj_NewCampaignDialog_Field_ActiveSegment_Caption"]},topFieldsRow);
dojo.style(topFieldsRowCell,"width","120px");
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRowCellDiv=dojo.create("div",{},topFieldsRowCell);
this._form_activeSegment=new Px.Ex.ValidationTextBox({"class":"form-input",style:"width: 250px;",intermediateChanges:true,name:"activeSegment",tabIndex:1,trim:true,required:true,maxLength:50,readOnly:true,promptMessage:_d7.BillNetAdj_NewCampaignDialog_Field_ActiveSegment_Prompt||"",invalidMessage:_d7.BillNetAdj_NewCampaignDialog_Field_ActiveSegment_Invalid||"$_unset_$",emptyMessage:_d7.BillNetAdj_NewCampaignDialog_Field_ActiveSegment_Empty||"$_unset_$",onChange:dojo.hitch(this,"onRewriteCampaignName")},topFieldsRowCellDiv);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
this.activeSegmentSelect=new dijit.form.DropDownButton({"class":"billing_newCampaign_load_segment",dropDown:this._createDropDown(this.TooltipDialog_Type_Segment)});
this.activeSegmentSelect.placeAt(topFieldsRowCell);
topFieldsRow=dojo.create("tr",{},topFieldsTbody);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
_e0=dojo.create("div",{},topFieldsRowCell);
table=dojo.create("table",{},_e0);
dojo.style(table,"borderSpacing","5px 0px");
tbody=dojo.create("tbody",{},table);
tr=dojo.create("tr",{},tbody);
td=dojo.create("td",{},tr);
tdDiv=dojo.create("div",{title:_d7["BillNetAdj_NewCampaignDialog_Button_Choose_Campaign"]},td);
this.campaignSelect=new dijit.form.DropDownButton({"class":"billing_newCampaign_choose_campaign",dropDown:this._createDropDown(this.TooltipDialog_Type_Copy)});
this.campaignSelect.placeAt(tdDiv);
td=dojo.create("td",{},tr);
dojo.style(td,"verticalAlign","middle");
tdDiv=dojo.create("div",{className:"billing_newCampaign_unchoose_campaign",title:_d7["BillNetAdj_NewCampaignDialog_Button_Clear_Campaign"]},td);
this._connections.push(dojo.connect(tdDiv,"onclick",dojo.hitch(this,"clearExistingCampaign")));
td=dojo.create("td",{},tr);
tdDiv=dojo.create("div",{id:"campaignCode"},td);
dojo.style(tdDiv,"visibility","hidden");
tdDivSpan=dojo.create("span",{innerHTML:_d7["BillNetAdj_NewCampaignDialog_Title_Campaign_Code"]},tdDiv);
tdDivSpan=dojo.create("span",{id:"campaignCodeValue"},tdDiv);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRow=dojo.create("tr",{},topFieldsTbody);
topFieldsRowCell=dojo.create("td",{innerHTML:_d7["BillNetAdj_NewCampaignDialog_Field_CampaignName_Caption"]},topFieldsRow);
dojo.style(topFieldsRowCell,"width","120px");
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRowCellDiv=dojo.create("div",{},topFieldsRowCell);
this._campaignNameChanged=false;
this._form_campaignName=new Px.Ex.ValidationTextBox({"class":"form-input",style:"width: 250px;",intermediateChanges:true,name:"campaignName",tabIndex:3,trim:true,required:true,maxLength:255,promptMessage:_d7.BillNetAdj_NewCampaignDialog_Field_CampaignName_Prompt||"",invalidMessage:_d7.BillNetAdj_NewCampaignDialog_Field_CampaignName_Invalid||"$_unset_$",emptyMessage:_d7.BillNetAdj_NewCampaignDialog_Field_CampaignName_Empty||"$_unset_$",onChange:dojo.hitch(this,function(val){
if(val!=""){
this._campaignNameChanged=true;
}else{
this._campaignNameChanged=false;
}
})},topFieldsRowCellDiv);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
dojo.style(topFieldsRowCell,"width","35px");
var _e1=dojo.create("div",{className:"billing_newCampaign_separator",innerHTML:"&nbsp;"},_d8);
middleFieldsDiv=dojo.create("div",{},_d8);
middleFieldsTbl=dojo.create("table",{},middleFieldsDiv);
dojo.style(middleFieldsTbl,"marginLeft","auto");
dojo.style(middleFieldsTbl,"marginRight","auto");
dojo.style(middleFieldsTbl,"borderSpacing","0px 10px");
middleFieldsTbody=dojo.create("tbody",{},middleFieldsTbl);
middleFieldsRow=dojo.create("tr",{},middleFieldsTbody);
middleFieldsRowCell=dojo.create("td",{innerHTML:_d7["BillNetAdj_NewCampaignDialog_Field_Impressions_Caption"]},middleFieldsRow);
dojo.style(middleFieldsRowCell,"width","120px");
middleFieldsRowCell=dojo.create("td",{},middleFieldsRow);
middleFieldsRowCellDiv=dojo.create("div",{},middleFieldsRowCell);
this._form_impressions=new Px.Ex.ValidationTextBox({"class":"form-input",style:"width: 250px;",intermediateChanges:true,name:"impressions",tabIndex:4,trim:true,required:true,maxLength:20,regExp:"[0-9]*",promptMessage:_d7.BillNetAdj_NewCampaignDialog_Field_Impressions_Prompt||"",invalidMessage:_d7.BillNetAdj_NewCampaignDialog_Field_Impressions_Invalid||"$_unset_$",emptyMessage:_d7.BillNetAdj_NewCampaignDialog_Field_Impressions_Empty||"$_unset_$"},middleFieldsRowCellDiv);
middleFieldsRowCell=dojo.create("td",{},middleFieldsRow);
middleFieldsRow=dojo.create("tr",{},middleFieldsTbody);
middleFieldsRowCell=dojo.create("td",{innerHTML:_d7["BillNetAdj_NewCampaignDialog_Field_Revenue_Caption"]},middleFieldsRow);
middleFieldsRowCell=dojo.create("td",{},middleFieldsRow);
middleFieldsRowCellDiv=dojo.create("div",{},middleFieldsRowCell);
this._form_revenue=new Px.Ex.ValidationTextBox({"class":"form-input",style:"width: 250px;",intermediateChanges:true,name:"revenue",tabIndex:5,trim:true,required:true,regExp:"^([0-9]){0,14}(\\.([0-9]){1,6})?$",promptMessage:_d7.BillNetAdj_NewCampaignDialog_Field_Revenue_Prompt||"",invalidMessage:_d7.BillNetAdj_NewCampaignDialog_Field_Revenue_Invalid||"$_unset_$",emptyMessage:_d7.BillNetAdj_NewCampaignDialog_Field_Revenue_Empty||"$_unset_$"},middleFieldsRowCellDiv);
middleFieldsRowCell=dojo.create("td",{innerHTML:"&nbsp;"},middleFieldsRow);
dojo.style(middleFieldsRowCell,"width","35px");
var _e1=dojo.create("div",{className:"billing_newCampaign_separator",innerHTML:"&nbsp;"},_d8);
var _e2=dojo.create("div",{id:"errorMessageDiv"},_d8);
dojo.style(_e2,"marginLeft","auto");
dojo.style(_e2,"marginRight","auto");
dojo.style(_e2,"display","none");
var _e0=dojo.create("div",{},_d8);
dojo.style(_e0,"marginTop","10px");
var _e3=dojo.create("table",{},_e0);
dojo.style(_e3,"marginLeft","auto");
dojo.style(_e3,"marginRight","auto");
var _e4=dojo.create("tbody",{},_e3);
var _e5=dojo.create("tr",{},_e4);
var _e6=dojo.create("td",{},_e5);
dojo.style(_e6,"paddingRight","10px");
var _e7=dojo.create("div",{className:"billing_newCampaign_cancel"},_e6);
dojo.attr(_e7,"title",_d7["BillNetAdj_NewCampaignDialog_Button_Cancel"]);
this.connect(_e7,"onclick","onCancel");
var _e8=dojo.create("td",{},_e5);
var _e9=dojo.create("dIV",{className:"billing_newCampaign_ok"},_e8);
dojo.attr(_e9,"title",_d7["BillNetAdj_NewCampaignDialog_Button_OK"]);
this.connect(_e9,"onclick","onSave");
this.attr("content",_d8);
},onRewriteCampaignName:function(){
if((this._form_activeSegment.value!="")&&(this._form_activeSegment.validate(false)==true)){
if(!this._campaignNameChanged){
if((this._form_campaignName.value!="")&&(this._previousSegment)&&(this._previousSegment.segmentCode!=this._activeSegment.segmentCode)){
dojo.attr(this._form_campaignName,"value",this._form_campaignName.value.replace(this._previousSegment.channelName,this._activeSegment.channelName));
}else{
if(this._form_campaignName.value==""){
if(!this.parentObject._platformWithNoNetwork){
dojo.attr(this._form_campaignName,"value",this.parentObject.networkSelectStore._itemsByIdentity[this.parentObject.networkSelect.value]["networkName"][0]+" - "+this._activeSegment.channelName);
}else{
dojo.attr(this._form_campaignName,"value",this.parentObject.platformSelectStore._itemsByIdentity[this.parentObject.platformSelect.value]["networkName"][0]+" - "+this._activeSegment.channelName);
}
}
}
this._campaignNameChanged=false;
}
}
},showError:function(_ea){
errorMessageDiv=dojo.byId("errorMessageDiv");
dojo.style("errorMessageDiv","display","block");
dojo.style("errorMessageDiv","opacity","1");
dojo.style("errorMessageDiv","textAlign","center");
dojo.style("errorMessageDiv","color","red");
dojo.style("errorMessageDiv","fontWeight","bold");
errorMessageDiv.innerHTML=_ea;
var _eb=dojo.fadeOut({node:errorMessageDiv,duration:5000,onEnd:function(){
dojo.style("errorMessageDiv","display","none");
}});
_eb.play();
},_createDropDown:function(_ec){
var fn=null;
if(_ec==this.TooltipDialog_Type_Segment){
fn=Px.Ex.BillingNetAdjScreen.BillingNewCampaignRMX.ActiveSegmentSelect;
}else{
if(_ec==this.TooltipDialog_Type_Copy){
fn=Px.Ex.BillingNetAdjScreen.BillingNewCampaignRMX.ExistingCampaignSelect;
}
}
var dlg=new fn({parent:this,data:this.data});
dlg.startup();
return dlg;
},onCancel:function(){
this.stopClosing(false);
this.onExecute();
},onSave:function(){
this._form_campaignName._hasBeenBlurred=true;
this._form_activeSegment._hasBeenBlurred=true;
this._form_impressions._hasBeenBlurred=true;
this._form_revenue._hasBeenBlurred=true;
var _ed=this._form_campaignName.validate(false);
var _ee=this._form_activeSegment.validate(false);
var _ef=this._form_impressions.validate(false);
var _f0=this._form_revenue.validate(false);
if(_ed&&_ee&&_ef&&_f0){
this.showRotation(true);
var _f1=this.parentObject.xhrCreateCampaign(this._form_campaignName.value,null,this.parentObject._platformWithNoNetwork?this.parentObject.platformSelect.value:this.parentObject.networkSelect.value,this.parentObject.platformSelect.value,this._activeSegment.segmentCode,this._form_impressions.value,this._form_revenue.value,this.parentObject.monthSelect.value,this._campaignCode?this._campaignCode:null);
if(_f1){
this.parentObject.loadGridContent();
this.showRotation(false);
this.stopClosing(false);
this.onExecute();
}else{
this.showRotation(false);
this.stopClosing(true);
this.showError(this.parentObject.constants["BillNetAdj_NewCampaignDialog_Error_Save"]);
}
}else{
this.showRotation(false);
this.stopClosing(true);
}
}});
dojo.declare("Px.Ex.BillingNetAdjScreen.BillingNewCampaignRMX",[Px.Ex.Dialog],{"class":"billing-new-campaign-dialog",parentObject:undefined,TooltipDialog_Type_Segment:1,TooltipDialog_Type_Copy:2,_connections:[],constructor:function(_f2){
dojo.mixin(this,_f2);
this.rotationImage=Px.Ex.Application.getWaitImageUrl();
},destroy:function(){
try{
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
}
}
catch(e){
}
},startup:function(){
this.inherited(arguments);
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(this.parentObject.constants["BillNetAdj_NewCampaignDialog_Title"]);
this.attr("content",Px.Ex.Application.getWaitHtml());
this.xhr({url:"/billing/network-adjustments-new-campaign-dialog",content:{networkCode:this.parentObject._networkValue},load:dojo.hitch(this,"createLayout"),handleAs:"json"});
},setLeadSegment:function(_f3){
if(this._activeSegment){
this._previousSegment=dojo.clone(this._activeSegment);
}
this._activeSegment=_f3;
dojo.attr(this._form_activeSegment,"displayedValue",_f3.channelName);
},setExistingCampaign:function(_f4,_f5){
this._campaignCode=_f4;
dojo.style(dojo.byId("campaignCode"),"visibility","visible");
dojo.byId("campaignCodeValue").innerHTML=_f4+"";
if(_f5){
dojo.attr(this._form_campaignName,"value",_f5);
this._form_campaignName.attr("readOnly",true);
var _f6=this.getRMXLineItemIDFromCampaignName(_f5);
if(_f6!=""){
this._form_RMXLineItemID.attr("value",_f6);
this._form_RMXLineItemID.attr("readOnly",true);
}else{
this._form_RMXLineItemID.attr("readOnly",false);
}
}
},getRMXLineItemIDFromCampaignName:function(_f7){
var re=new RegExp("^Line id: ([0-9]+) .*$");
var m=re.exec(_f7);
if(m==null){
return "";
}else{
return m[1];
}
},clearExistingCampaign:function(){
if(this._campaignCode){
delete this._campaignCode;
}
this._form_campaignName.attr("readOnly",false);
this._form_campaignName.attr("value","");
this._campaignNameChanged=false;
if(this._form_RMXLineItemID.attr("readOnly")){
this._form_RMXLineItemID.attr("value","");
}
this._form_RMXLineItemID.attr("readOnly",false);
dojo.byId("campaignCodeValue").innerHTML="";
dojo.style(dojo.byId("campaignCode"),"visibility","hidden");
},createLayout:function(_f8){
var _f9=this.parentObject.constants;
this.data=_f8;
var _fa=dojo.create("div",{});
dojo.style(_fa,"marginLeft","18px");
dojo.style(_fa,"marginRight","18px");
var _fb=dojo.create("div",{},_fa);
var _fc=dojo.create("span",{},_fb);
_fc.innerHTML=this.parentObject.constants["BillNetAdj_NewCampaignDialog_Title_Platform"];
dojo.style(_fc,"fontWeight","bold");
var _fd=dojo.create("span",{},_fb);
_fd.innerHTML=this.parentObject.platformSelectStore._itemsByIdentity[this.parentObject.platformSelect.value]["networkName"][0];
dojo.style(_fd,"marginLeft","10px");
if((!this.parentObject._platformWithNoNetwork)&&(this.parentObject._platformValue!=this.parentObject._networkValue)){
var _fe=dojo.create("div",{},_fa);
var _ff=dojo.create("span",{},_fe);
_ff.innerHTML=this.parentObject.constants["BillNetAdj_NewCampaignDialog_Title_Network"];
dojo.style(_ff,"fontWeight","bold");
var _100=dojo.create("span",{},_fe);
_100.innerHTML=this.parentObject.networkSelectStore._itemsByIdentity[this.parentObject.networkSelect.value]["networkName"][0];
dojo.style(_100,"marginLeft","10px");
}
var _101=dojo.create("div",{},_fa);
this._form=new dijit.form.Form({"class":"newBuyerRequestForm",onSubmit:function(){
return false;
}},_101);
topFieldsDiv=dojo.create("div",{},_fa);
topFieldsTbl=dojo.create("table",{},topFieldsDiv);
dojo.style(topFieldsTbl,"marginLeft","auto");
dojo.style(topFieldsTbl,"marginRight","auto");
dojo.style(topFieldsTbl,"borderSpacing","0px 10px");
topFieldsTbody=dojo.create("tbody",{},topFieldsTbl);
topFieldsRow=dojo.create("tr",{},topFieldsTbody);
topFieldsRowCell=dojo.create("td",{innerHTML:_f9["BillNetAdj_NewCampaignDialog_Field_ActiveSegment_Caption"]},topFieldsRow);
dojo.style(topFieldsRowCell,"width","120px");
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRowCellDiv=dojo.create("div",{},topFieldsRowCell);
this._form_activeSegment=new Px.Ex.ValidationTextBox({"class":"form-input",style:"width: 250px;",intermediateChanges:true,name:"activeSegment",tabIndex:1,trim:true,required:true,maxLength:50,readOnly:true,promptMessage:_f9.BillNetAdj_NewCampaignDialog_Field_ActiveSegment_Prompt||"",invalidMessage:_f9.BillNetAdj_NewCampaignDialog_Field_ActiveSegment_Invalid||"$_unset_$",emptyMessage:_f9.BillNetAdj_NewCampaignDialog_Field_ActiveSegment_Empty||"$_unset_$",onChange:dojo.hitch(this,"onRewriteCampaignName")},topFieldsRowCellDiv);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
this.activeSegmentSelect=new dijit.form.DropDownButton({"class":"billing_newCampaign_load_segment",dropDown:this._createDropDown(this.TooltipDialog_Type_Segment)});
this.activeSegmentSelect.placeAt(topFieldsRowCell);
topFieldsRow=dojo.create("tr",{},topFieldsTbody);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
_102=dojo.create("div",{},topFieldsRowCell);
table=dojo.create("table",{},_102);
dojo.style(table,"borderSpacing","5px 0px");
tbody=dojo.create("tbody",{},table);
tr=dojo.create("tr",{},tbody);
td=dojo.create("td",{},tr);
tdDiv=dojo.create("div",{title:_f9["BillNetAdj_NewCampaignDialog_Button_Choose_Campaign"]},td);
this.campaignSelect=new dijit.form.DropDownButton({"class":"billing_newCampaign_choose_campaign",dropDown:this._createDropDown(this.TooltipDialog_Type_Copy)});
this.campaignSelect.placeAt(tdDiv);
td=dojo.create("td",{},tr);
dojo.style(td,"verticalAlign","middle");
tdDiv=dojo.create("div",{className:"billing_newCampaign_unchoose_campaign",title:_f9["BillNetAdj_NewCampaignDialog_Button_Clear_Campaign"]},td);
this._connections.push(dojo.connect(tdDiv,"onclick",dojo.hitch(this,"clearExistingCampaign")));
td=dojo.create("td",{},tr);
tdDiv=dojo.create("div",{id:"campaignCode"},td);
dojo.style(tdDiv,"visibility","hidden");
tdDivSpan=dojo.create("span",{innerHTML:_f9["BillNetAdj_NewCampaignDialog_Title_Campaign_Code"]},tdDiv);
tdDivSpan=dojo.create("span",{id:"campaignCodeValue"},tdDiv);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRow=dojo.create("tr",{},topFieldsTbody);
topFieldsRowCell=dojo.create("td",{innerHTML:_f9["BillNetAdj_NewCampaignDialog_Field_LineItemID_Caption"]},topFieldsRow);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRowCellDiv=dojo.create("div",{},topFieldsRowCell);
this._form_RMXLineItemID=new Px.Ex.ValidationTextBox({"class":"form-input",style:"width: 250px;",intermediateChanges:true,name:"lineItemId",tabIndex:2,trim:true,required:true,maxLength:20,regExp:"[0-9]*",promptMessage:_f9.BillNetAdj_NewCampaignDialog_Field_LineItemID_Prompt||"",invalidMessage:_f9.BillNetAdj_NewCampaignDialog_Field_LineItemID_Invalid||"$_unset_$",emptyMessage:_f9.BillNetAdj_NewCampaignDialog_Field_LineItemID_Empty||"$_unset_$",onFocus:dojo.hitch(this,function(){
this._previousRMXLineItemID=this._form_RMXLineItemID.value;
}),onBlur:dojo.hitch(this,function(){
this.onRewriteCampaignName();
})},topFieldsRowCellDiv);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRow=dojo.create("tr",{},topFieldsTbody);
topFieldsRowCell=dojo.create("td",{innerHTML:_f9["BillNetAdj_NewCampaignDialog_Field_CampaignName_Caption"]},topFieldsRow);
dojo.style(topFieldsRowCell,"width","120px");
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
topFieldsRowCellDiv=dojo.create("div",{},topFieldsRowCell);
this._campaignNameChanged=false;
this._form_campaignName=new Px.Ex.ValidationTextBox({"class":"form-input",style:"width: 250px;",intermediateChanges:true,name:"campaignName",tabIndex:3,trim:true,required:true,maxLength:255,promptMessage:_f9.BillNetAdj_NewCampaignDialog_Field_CampaignName_Prompt||"",invalidMessage:_f9.BillNetAdj_NewCampaignDialog_Field_CampaignName_Invalid||"$_unset_$",emptyMessage:_f9.BillNetAdj_NewCampaignDialog_Field_CampaignName_Empty||"$_unset_$",onChange:dojo.hitch(this,function(val){
if(val!=""){
this._campaignNameChanged=true;
}else{
this._campaignNameChanged=false;
}
})},topFieldsRowCellDiv);
topFieldsRowCell=dojo.create("td",{},topFieldsRow);
dojo.style(topFieldsRowCell,"width","35px");
var _103=dojo.create("div",{className:"billing_newCampaign_separator",innerHTML:"&nbsp;"},_fa);
middleFieldsDiv=dojo.create("div",{},_fa);
middleFieldsTbl=dojo.create("table",{},middleFieldsDiv);
dojo.style(middleFieldsTbl,"marginLeft","auto");
dojo.style(middleFieldsTbl,"marginRight","auto");
dojo.style(middleFieldsTbl,"borderSpacing","0px 10px");
middleFieldsTbody=dojo.create("tbody",{},middleFieldsTbl);
middleFieldsRow=dojo.create("tr",{},middleFieldsTbody);
middleFieldsRowCell=dojo.create("td",{innerHTML:_f9["BillNetAdj_NewCampaignDialog_Field_Impressions_Caption"]},middleFieldsRow);
dojo.style(middleFieldsRowCell,"width","120px");
middleFieldsRowCell=dojo.create("td",{},middleFieldsRow);
middleFieldsRowCellDiv=dojo.create("div",{},middleFieldsRowCell);
this._form_impressions=new Px.Ex.ValidationTextBox({"class":"form-input",style:"width: 250px;",intermediateChanges:true,name:"impressions",tabIndex:4,trim:true,required:true,maxLength:20,regExp:"[0-9]*",promptMessage:_f9.BillNetAdj_NewCampaignDialog_Field_Impressions_Prompt||"",invalidMessage:_f9.BillNetAdj_NewCampaignDialog_Field_Impressions_Invalid||"$_unset_$",emptyMessage:_f9.BillNetAdj_NewCampaignDialog_Field_Impressions_Empty||"$_unset_$"},middleFieldsRowCellDiv);
middleFieldsRowCell=dojo.create("td",{},middleFieldsRow);
middleFieldsRow=dojo.create("tr",{},middleFieldsTbody);
middleFieldsRowCell=dojo.create("td",{innerHTML:_f9["BillNetAdj_NewCampaignDialog_Field_Revenue_Caption"]},middleFieldsRow);
middleFieldsRowCell=dojo.create("td",{},middleFieldsRow);
middleFieldsRowCellDiv=dojo.create("div",{},middleFieldsRowCell);
this._form_revenue=new Px.Ex.ValidationTextBox({"class":"form-input",style:"width: 250px;",intermediateChanges:true,name:"revenue",tabIndex:5,trim:true,required:true,regExp:"^([0-9]){0,14}(\\.([0-9]){1,6})?$",promptMessage:_f9.BillNetAdj_NewCampaignDialog_Field_Revenue_Prompt||"",invalidMessage:_f9.BillNetAdj_NewCampaignDialog_Field_Revenue_Invalid||"$_unset_$",emptyMessage:_f9.BillNetAdj_NewCampaignDialog_Field_Revenue_Empty||"$_unset_$"},middleFieldsRowCellDiv);
middleFieldsRowCell=dojo.create("td",{innerHTML:"&nbsp;"},middleFieldsRow);
dojo.style(middleFieldsRowCell,"width","35px");
var _103=dojo.create("div",{className:"billing_newCampaign_separator",innerHTML:"&nbsp;"},_fa);
var _104=dojo.create("div",{id:"errorMessageDiv"},_fa);
dojo.style(_104,"marginLeft","auto");
dojo.style(_104,"marginRight","auto");
dojo.style(_104,"display","none");
var _102=dojo.create("div",{},_fa);
dojo.style(_102,"marginTop","10px");
var _105=dojo.create("table",{},_102);
dojo.style(_105,"marginLeft","auto");
dojo.style(_105,"marginRight","auto");
var _106=dojo.create("tbody",{},_105);
var _107=dojo.create("tr",{},_106);
var _108=dojo.create("td",{},_107);
dojo.style(_108,"paddingRight","10px");
var _109=dojo.create("div",{className:"billing_newCampaign_cancel"},_108);
dojo.attr(_109,"title",_f9["BillNetAdj_NewCampaignDialog_Button_Cancel"]);
this.connect(_109,"onclick","onCancel");
var _10a=dojo.create("td",{},_107);
var _10b=dojo.create("dIV",{className:"billing_newCampaign_ok"},_10a);
dojo.attr(_10b,"title",_f9["BillNetAdj_NewCampaignDialog_Button_OK"]);
this.connect(_10b,"onclick","onSave");
this.attr("content",_fa);
},onRewriteCampaignName:function(){
if((this._form_RMXLineItemID.value!="")&&(this._form_RMXLineItemID.validate(false)==true)&&(this._form_activeSegment.value!="")&&(this._form_activeSegment.validate(false)==true)){
if(!this._campaignNameChanged){
if((this._form_campaignName!="")&&(this._previousSegment)&&(this._previousSegment.segmentCode!=this._activeSegment.segmentCode)){
dojo.attr(this._form_campaignName,"value",this._form_campaignName.value.replace(this._previousSegment.channelName,this._activeSegment.channelName));
}else{
if((this._form_campaignName!="")&&(this._previousRMXLineItemID)&&(this._previousRMXLineItemID!=this._form_RMXLineItemID.value)){
dojo.attr(this._form_campaignName,"value",this._form_campaignName.value.replace(this._previousRMXLineItemID,this._form_RMXLineItemID.value));
}else{
if(this._form_campaignName.value==""){
dojo.attr(this._form_campaignName,"value","Line id: "+this._form_RMXLineItemID.value+" ("+this._form_activeSegment.value+")");
}
}
}
this._campaignNameChanged=false;
}
}
},showError:function(_10c){
errorMessageDiv=dojo.byId("errorMessageDiv");
dojo.style("errorMessageDiv","display","block");
dojo.style("errorMessageDiv","opacity","1");
dojo.style("errorMessageDiv","textAlign","center");
dojo.style("errorMessageDiv","color","red");
dojo.style("errorMessageDiv","fontWeight","bold");
errorMessageDiv.innerHTML=_10c;
var _10d=dojo.fadeOut({node:errorMessageDiv,duration:5000,onEnd:function(){
dojo.style("errorMessageDiv","display","none");
}});
_10d.play();
},_createDropDown:function(type){
var fn=null;
if(type==this.TooltipDialog_Type_Segment){
fn=Px.Ex.BillingNetAdjScreen.BillingNewCampaignRMX.ActiveSegmentSelect;
}else{
if(type==this.TooltipDialog_Type_Copy){
fn=Px.Ex.BillingNetAdjScreen.BillingNewCampaignRMX.ExistingCampaignSelect;
}
}
var dlg=new fn({parent:this,data:this.data});
dlg.startup();
return dlg;
},onCancel:function(){
this.stopClosing(false);
this.onExecute();
},onSave:function(){
this._form_campaignName._hasBeenBlurred=true;
this._form_activeSegment._hasBeenBlurred=true;
this._form_RMXLineItemID._hasBeenBlurred=true;
this._form_impressions._hasBeenBlurred=true;
this._form_revenue._hasBeenBlurred=true;
var _10e=this._form_campaignName.validate(false);
var _10f=this._form_activeSegment.validate(false);
var _110=this._form_RMXLineItemID.validate(false);
var _111=this._form_impressions.validate(false);
var _112=this._form_revenue.validate(false);
if(_10e&&_10f&&_110&&_111&&_112){
this.showRotation(true);
var _113=this.parentObject.xhrCreateCampaign(this._form_campaignName.value,(this._form_RMXLineItemID.value==0)?null:this._form_RMXLineItemID.value,this.parentObject._platformWithNoNetwork?this.parentObject.platformSelect.value:this.parentObject.networkSelect.value,this.parentObject.platformSelect.value,this._activeSegment.segmentCode,this._form_impressions.value,this._form_revenue.value,this.parentObject.monthSelect.value,this._campaignCode?this._campaignCode:null);
if(_113){
this.parentObject.loadGridContent();
this.showRotation(false);
this.stopClosing(false);
this.onExecute();
}else{
this.showRotation(false);
this.stopClosing(true);
this.showError(this.parentObject.constants["BillNetAdj_NewCampaignDialog_Error_Save"]);
}
}else{
this.showRotation(false);
this.stopClosing(true);
}
}});
dojo.declare("Px.Ex.BillingNetAdjScreen.BillingNewCampaignRMX.ActiveSegmentSelect",[dijit.TooltipDialog,Px.Ex.SingleSelectDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.segments){
var b=this.data.segments;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,function(v){
return {value:v.segmentCode+"",label:v.channelName,o:v};
});
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.setSelectedSegment();
},onCancel:function(){
this.inherited(arguments);
this.setSelectedSegment();
},onBlur:function(){
this.inherited(arguments);
this.setSelectedSegment();
},setSelectedSegment:function(){
var _114=this.getSelected();
if(_114!=null){
var _115=_114.length-1;
if(_114[_115]){
this.parent.setLeadSegment(_114[_115]);
}
}
}});
dojo.declare("Px.Ex.BillingNetAdjScreen.BillingNewCampaignRMX.ExistingCampaignSelect",[dijit.TooltipDialog,Px.Ex.SingleSelectDialogMixin],{parent:undefined,data:undefined,"class":"filter-popup-dialog",startup:function(){
this.inherited(arguments);
var ops=[];
if(this.data.campaigns){
var b=this.data.campaigns;
if(!dojo.isArray(b)){
b=[b];
}
ops=dojo.map(b,dojo.hitch(this,function(v){
return {value:v.campaignCode+"",label:v.campaignName+" ["+this.convertLastActivityMonth(v.lastActivityMonth)+"]",o:v};
}));
}
this.filteredOps=this.ops=ops;
this.createContent();
},onChange:function(val){
if(this.searching){
return;
}
this.setSelectedCampaign();
},onCancel:function(){
this.inherited(arguments);
this.setSelectedCampaign();
},onBlur:function(){
this.inherited(arguments);
this.setSelectedCampaign();
},convertLastActivityMonth:function(_116){
return _116.substr(0,7).replace("-","/");
},setSelectedCampaign:function(){
var _117=this.getSelected();
if(_117!=null){
var _118=_117.length-1;
if(_117[_118]){
this.parent.setExistingCampaign(_117[_118].campaignCode,_117[_118].campaignName);
}
}
}});
dojo.declare("Px.Ex.BuyerRequestScreen",[Px.Ex.XhrMixin],{BUYERNAME_REGEXP:"[a-zA-Z0-9\\x20\\x2e\\x5f\\x2d\\x2b\\x3d\\x2d\\x24\\x23\\x40\\x2a\\x2c\\x28\\x29\\x5b\\x5d\\x7b\\x7d\\x7c\\x21]*",BUYERURL_REGEXP:"^([A-Za-z]+://)?[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&?/.=]+$",REQUESTSTATUS_NEW:1,REQUESTSTATUS_APPROVED:2,REQUESTSTATUS_REJECTED:3,FIELD_API_APPROVALDATE:"approvalDate",FIELD_API_APPROVALNOTES:"approvalNotes",FIELD_API_BUYERCONTACTDETAILS:"buyerContactDetails",FIELD_API_BUYERNAME:"buyerName",FIELD_API_BUYERURL:"buyerUrl",FIELD_API_REMARKS:"remarks",FIELD_API_REQUESTCODE:"requestCode",FIELD_API_REQUESTDATE:"requestDate",FIELD_API_REQUESTSTATUS:"requestStatus",_connections:[],_data:undefined,_fixedTooltip:false,_form:undefined,_form_buyerContactDetails:undefined,_form_buyerName:undefined,_form_buyerURL:undefined,_form_remarks:undefined,_isFirstLoad:true,_isGridExpanded:true,_messages:undefined,_requestsGrid:undefined,_requestsStore:undefined,_searchControl:undefined,_searchItems:[],_searchTerm:undefined,_searchTimer:undefined,_shownData:undefined,draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhrLoad({selector:"#divContent",url:"/buyers/buyer-request-screen",load:dojo.hitch(this,"createScreen")});
},createScreen:function(){
this._messages=dojo.fromJson(dojo.byId("div-messages-id").innerHTML);
if(dojo.byId("newBuyerRequestForm")){
this.prepareNewBuyerRequestForm();
}
if(dojo.byId("requestsLog")){
this.prepareRequestsLog();
}
},prepareRequestsLog:function(){
var _1=this._messages;
this._requestsStore=new dojo.data.ItemFileReadStore({clearOnClose:true,data:{identifier:"requestCode",items:[]}});
var _2=this.getGridStructure();
this._requestsGrid=new dojox.grid.DataGrid({loadingMessage:Px.Ex.Application.getWaitHtml(),store:this._requestsStore,query:{requestCode:"*"},queryOptions:{ignoreCase:true},clientSort:true,"class":"newBuyerRequestsLog_Grid",autoHeight:true,rowsPerPage:1000,selectionMode:"single",selectable:true,canSort:function(_3){
return true;
},onStyleRow:dojo.hitch(this,"onStyleRow"),structure:_2},"requestsLog_Grid");
this._requestsGrid.startup();
this._requestsGrid.setSortIndex(0,false);
this._requestsGrid._refresh();
this._connections.push(dojo.connect(this._requestsGrid,"onCellMouseOver",dojo.hitch(this,function(e){
if((e.cellNode)&&(e.cell.field==this.FIELD_API_BUYERNAME)){
this.showRequestBuyerTooltip(e,true);
}else{
if((e.cellNode)&&(e.cell.field==this.FIELD_API_APPROVALNOTES)){
this.showRequestNotesTooltip(e,true);
}
}
})));
this._connections.push(dojo.connect(this._requestsGrid,"onCellMouseOut",dojo.hitch(this,function(e){
if((e.cellNode)&&(e.cell.field==this.FIELD_API_BUYERNAME)){
this.showRequestBuyerTooltip(e,false);
}else{
if((e.cellNode)&&(e.cell.field==this.FIELD_API_APPROVALNOTES)){
this.showRequestNotesTooltip(e,false);
}
}
})));
this._connections.push(dojo.connect(this._requestsGrid,"onCellClick",dojo.hitch(this,function(e){
if((e.cellNode)&&(e.cell.field==this.FIELD_API_BUYERNAME)){
this._fixedTooltip=!(this._fixedTooltip);
}else{
if((e.cellNode)&&(e.cell.field==this.FIELD_API_APPROVALNOTES)){
this._fixedTooltip=!(this._fixedTooltip);
}
}
})));
this._connections.push(dojo.connect(dojo.byId("requestsLog_ExpandGrid"),"onclick",dojo.hitch(this,"onExpandCollapseGrid")));
this._searchControl=new Px.Ex.SearchTextBox({"class":"search-control",intermediateChanges:true,emptyText:_1.BuyerReq_RequestsLog_Search},"requestsLog_Search");
this._searchControl.startup();
this._searchControl.connect(this._searchControl,"onChange",dojo.hitch(this,"onChangeSearchText"));
this.fetchRequestsLog();
},drawLeftPane:function(_4){
if(!_4){
dojo.style(dojo.byId("requestsLog_LeftPane"),"display","none");
return;
}else{
dojo.style(dojo.byId("requestsLog_LeftPane"),"display","block");
}
var _5=this._messages;
var _6=true;
var _7="requestsLog_LeftPane_Surface";
var _8="14px";
var h=dojo.marginBox(dojo.query(".dojoxGridScrollbox",this._requestsGrid.domNode)[0]).h;
var w=20;
h=parseInt(h);
if(this[_7]){
this[_7].destroy();
}
if(h<10){
delete this[_7];
return;
}
var _9=this[_7]=dojox.gfx.createSurface("requestsLog_LeftPane",w,h);
var t=_9.createText({x:0,y:0,text:_5.BuyerReq_RequestsLog_TableLeftPane,align:"middle"});
t.setFont({family:"Arial",size:_8,weight:"bold",rotated:true});
var tw=t.getTextWidth();
_9.remove(t);
var _a=10;
if(tw>h-_a){
_6=false;
}
var _b=_9.createPath("");
var r=8;
var _c=dojo.isIE?0:1;
_b.moveTo(w,h-1).hLineTo(r+1).arcTo(r,r,0,false,true,1,h-r-1).vLineTo(r+_c).arcTo(r,r,0,false,true,r+1,_c).hLineTo(w).closePath();
var _d=dojo.getComputedStyle(dojo.query(".texi-logo-text")[0]).color;
_b.setFill(_d).setStroke(_d);
var c={x:parseInt(w/2),y:parseInt(h/2)};
if(_6){
t=_9.createText({x:c.x,y:c.y+6,text:_5.BuyerReq_RequestsLog_TableLeftPane,align:"middle"});
t.setFill("white");
t.setFont({family:"Arial",size:_8,weight:"bold",rotated:true});
}
var m=dojox.gfx.matrix;
t.setTransform(m.rotategAt(-90,c.x,c.y));
},onExpandCollapseGrid:function(){
if(this._isGridExpanded){
var _e={identifier:this._data.identifier,label:this._data.label,items:[]};
this.updateStoreWithData(_e,true);
}else{
if(this._shownData){
this.updateStoreWithData(this._shownData,true);
}else{
this._shownData=this._data;
this.updateStoreWithData(this._data,true);
}
}
this._isGridExpanded=!this._isGridExpanded;
this.drawLeftPane(this._isGridExpanded);
this.changeExpandButton();
},changeExpandButton:function(){
var _f=dojo.byId("requestsLog_ExpandGrid");
if(dojo.hasClass(_f,"expand-grid")){
dojo.removeClass(_f,"expand-grid");
dojo.addClass(_f,"collapse-grid");
}else{
if(dojo.hasClass(_f,"collapse-grid")){
dojo.removeClass(_f,"collapse-grid");
dojo.addClass(_f,"expand-grid");
}
}
},onChangeSearchText:function(_10){
this._searchTerm=_10;
if((!this._data)||(this._requestsGrid._isLoading)){
return;
}
clearTimeout(this._searchTimer);
this._searchTimer=setTimeout(dojo.hitch(this,"searchRequests",_10),250);
},searchRequests:function(_11){
this._shownData=this.filterRequests();
this.updateStoreWithData(this._shownData,this._isGridExpanded);
this.drawLeftPane(this._isGridExpanded);
},filterRequests:function(_12){
if(this._searchTerm==undefined||!this._searchTerm.length){
return this._data;
}
this._searchItems=[];
dojo.forEach(this._data.items,dojo.hitch(this,function(v){
var val=this._searchTerm.toLowerCase();
if(((v.approvalNotes[0]!="")&&(v.approvalNotes[0].toLowerCase().indexOf(val)>=0))||((v.buyerContactDetails[0]!="")&&(v.buyerContactDetails[0].toLowerCase().indexOf(val)>=0))||((v.buyerName[0]!="")&&(v.buyerName[0].toLowerCase().indexOf(val)>=0))||((v.buyerUrl[0]!="")&&(v.buyerUrl[0].toLowerCase().indexOf(val)>=0))||((v.remarks[0]!="")&&(v.remarks[0].toLowerCase().indexOf(val)>=0))||((v.requestStatus==this.REQUESTSTATUS_NEW)&&(this._messages.BuyerReq_RequestsLog_Status_WaitingForApproval.toLowerCase().indexOf(val)>=0))||((v.requestStatus==this.REQUESTSTATUS_APPROVED)&&(this._messages.BuyerReq_RequestsLog_Status_Approved.toLowerCase().indexOf(val)>=0))||((v.requestStatus==this.REQUESTSTATUS_REJECTED)&&(this._messages.BuyerReq_RequestsLog_Status_Rejected.toLowerCase().indexOf(val)>=0))){
this._searchItems.push(v);
}
}));
return {identifier:this._data.identifier,label:this._data.label,items:this._searchItems};
},showRequestBuyerTooltip:function(evt,_13){
if(_13){
if(this._fixedTooltip){
return;
}
var _14=this._messages;
var _15="";
var _16=this._requestsGrid.getItem(evt.rowIndex);
var _17=this._requestsStore.getValue(_16,this.FIELD_API_BUYERNAME);
var _18=this._requestsStore.getValue(_16,this.FIELD_API_BUYERURL);
var _19=this._requestsStore.getValue(_16,this.FIELD_API_BUYERCONTACTDETAILS);
var _1a=this._requestsStore.getValue(_16,this.FIELD_API_REMARKS);
if(dojo.isIE){
var _1b="newBuyerRequestsLog_requestTooltip_LongValue_IE";
}else{
var _1b="newBuyerRequestsLog_requestTooltip_LongValue_FFChrome";
}
if(_1a==""){
_1a="&nbsp;";
}
_15+="<div class=\"newBuyerRequestsLog_requestTooltip\">";
_15+="<div class=\"newBuyerRequestsLog_requestTooltip_Title\">";
_15+=_14.BuyerReq_RequestsLog_RequestTooltip_Title;
_15+="</div>";
_15+="<table class=\"newBuyerRequestsLog_requestTooltip_Table\">";
_15+="<tr>";
_15+="<td>";
_15+=_14.BuyerReq_NewBuyerRequestForm_BuyerName+":&nbsp;";
_15+="</td>";
_15+="<td>";
_15+="<div class=\"newBuyerRequestsLog_requestTooltip_Value\">";
_15+=_17;
_15+="</div>";
_15+="</td>";
_15+="</tr>";
_15+="<tr>";
_15+="<td>";
_15+=_14.BuyerReq_NewBuyerRequestForm_BuyerURL+":&nbsp;";
_15+="</td>";
_15+="<td>";
_15+="<div class=\"newBuyerRequestsLog_requestTooltip_Value\">";
_15+="<a href=\""+_18+"\" target=\"_blank\">"+_18+"</a>";
_15+="</div>";
_15+="</td>";
_15+="</tr>";
_15+="<tr>";
_15+="<td>";
_15+=_14.BuyerReq_NewBuyerRequestForm_BuyerContactDetails+":&nbsp;";
_15+="</td>";
_15+="<td>";
_15+="<div class=\"newBuyerRequestsLog_requestTooltip_Value "+_1b+"\">";
_15+=this.convertNewLineToBR(_19);
_15+="</div>";
_15+="</td>";
_15+="</tr>";
_15+="<tr>";
_15+="<td>";
_15+=_14.BuyerReq_NewBuyerRequestForm_Remarks+":&nbsp;";
_15+="</td>";
_15+="<td>";
_15+="<div class=\"newBuyerRequestsLog_requestTooltip_Value "+_1b+"\">";
_15+=this.convertNewLineToBR(_1a);
_15+="</div>";
_15+="</td>";
_15+="</tr>";
_15+="</table>";
_15+="</div>";
dijit.showTooltip(_15,evt.cellNode,"above");
}else{
if(!this._fixedTooltip){
dijit.hideTooltip(evt.cellNode);
}
}
},showRequestNotesTooltip:function(evt,_1c){
if(!this._fixedTooltip){
if(_1c){
if(this._fixedTooltip){
return;
}
var _1d=this._requestsGrid.getItem(evt.rowIndex);
var _1e=this._requestsStore.getValue(_1d,this.FIELD_API_APPROVALNOTES);
_1e=this.convertNewLineToBR(_1e);
if(_1e!=""){
dijit.showTooltip(_1e,evt.cellNode,"above");
}
}else{
if(!this._fixedTooltip){
dijit.hideTooltip(evt.cellNode);
}
}
}
},onStyleRow:function(_1f){
},getGridStructure:function(){
var _20=this._messages;
var _21=dojo.hitch(this,function(_22,_23){
var d=_22;
try{
d=dojo.date.locale.format(dojo.date.stamp.fromISOString(_22),{selector:"date",datePattern:"yyyy-MM-dd"});
}
catch(e){
}
return d;
});
var _24=dojo.hitch(this,function(_25,_26){
switch(_25){
case this.REQUESTSTATUS_NEW:
return "<div class=\"newBuyerRequestsLog_waitingStatusIcon\">"+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+_20.BuyerReq_RequestsLog_Status_WaitingForApproval;
+"</div>";
break;
case this.REQUESTSTATUS_APPROVED:
return "<div class=\"newBuyerRequestsLog_approvedStatusIcon\">"+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+_20.BuyerReq_RequestsLog_Status_Approved;
+"</div>";
break;
case this.REQUESTSTATUS_REJECTED:
return "<div class=\"newBuyerRequestsLog_rejectedStatusIcon\">"+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+_20.BuyerReq_RequestsLog_Status_Rejected;
+"</div>";
break;
default:
return "";
break;
}
});
var _27=dojo.hitch(this,function(_28,_29){
_2a=_28;
_2a=this.convertNewLineToBR(_2a);
var _2b=_28.indexOf("\r\n");
if(_2b!=-1){
var _2a=_28.substring(0,_2b)+"...";
}
return "<div class=\"dojoxEllipsis\">"+_2a+"</div>";
});
var _2c=dojo.hitch(this,function(_2d,_2e){
return "<u>"+_2d+"</u>";
});
var _2f=[{cells:[[{name:_20.BuyerReq_RequestsLog_Column_Date,field:this.FIELD_API_REQUESTDATE,width:"13%",noresize:true,formatter:_21,headerClasses:"newBuyerRequestsLog_columnHeader",cellClasses:"newBuyerRequestsLog_dateColumn"},{name:_20.BuyerReq_RequestsLog_Column_BuyerName,field:this.FIELD_API_BUYERNAME,width:"35%",noresize:true,formatter:_2c,headerClasses:"newBuyerRequestsLog_columnHeader"},{name:_20.BuyerReq_RequestsLog_Column_Status,field:this.FIELD_API_REQUESTSTATUS,width:"18%",noresize:true,formatter:_24,headerClasses:"newBuyerRequestsLog_columnHeader"},{name:_20.BuyerReq_RequestsLog_Column_Notes,field:this.FIELD_API_APPROVALNOTES,width:"34%",noresize:true,formatter:_27,headerClasses:"newBuyerRequestsLog_columnHeader"},{name:this.FIELD_API_APPROVALDATE,field:this.FIELD_API_APPROVALDATE,hidden:true},{name:this.FIELD_API_BUYERCONTACTDETAILS,field:this.FIELD_API_BUYERCONTACTDETAILS,hidden:true},{name:this.FIELD_API_BUYERURL,field:this.FIELD_API_BUYERURL,hidden:true},{name:this.FIELD_API_REMARKS,field:this.FIELD_API_REMARKS,hidden:true},{name:this.FIELD_API_REQUESTCODE,field:this.FIELD_API_REQUESTCODE,hidden:true}]]}];
return _2f;
},fetchRequestsLog:function(){
dojo.query("#requestsLog_GridIndicator").empty().html(Px.Ex.Application.getWaitHtml());
this._searchTerm="";
this._searchControl.clearValue();
this.xhr({url:"/buyers/get-requests-log",load:dojo.hitch(this,"onRequestsLogFetchEnd"),error:dojo.hitch(this,"onRequestsLogFetchFailure"),handleAs:"json"});
},updateRequestCounters:function(){
var _30=this._messages;
var _31="";
var _32=0;
var _33=0;
var _34=this._data.items;
for(buyer in _34){
if(_34[buyer]["requestStatus"]==this.REQUESTSTATUS_NEW){
_32++;
}else{
if(_34[buyer]["requestStatus"]==this.REQUESTSTATUS_APPROVED){
var _35=new Date();
var _36=dojo.date.stamp.fromISOString(_34[buyer]["approvalDate"]);
var _37=1000*60*60;
var _38=(_35.getTime()-_36.getTime())/_37;
if((_38>=0)&&(_38<=72)){
_33++;
}
}
}
}
var _39="<span class=\"newBuyerRequestsLog_numberWaitingForApproval\">"+_32+"</span>";
var _3a="<span class=\"newBuyerRequestsLog_numberNewApproval\">"+_33+"</span>";
var _3b;
var _3c;
switch(_32){
case 1:
_3b="<span class=\"newBuyerRequestsLog_textWaitingForApproval\">"+_30.BuyerReq_RequestsLog_Title_SingleWaitingForApproval+"</span>";
break;
default:
_3b="<span class=\"newBuyerRequestsLog_textWaitingForApproval\">"+_30.BuyerReq_RequestsLog_Title_MultiWaitingForApproval+"</span>";
break;
}
switch(_33){
case 1:
_3c="<span class=\"newBuyerRequestsLog_textNewApproval\">"+_30.BuyerReq_RequestsLog_Title_SingleNewApproval+"</span>";
break;
default:
_3c="<span class=\"newBuyerRequestsLog_textNewApproval\">"+_30.BuyerReq_RequestsLog_Title_MultiNewApproval+"</span>";
break;
}
if((_32==0)&&(_33==0)){
document.getElementById("requestsLog_Title").innerHTML=_30.BuyerReq_RequestsLog_Title_DoubleZeroValue;
}else{
if(_32==0){
document.getElementById("requestsLog_Title").innerHTML=dojo.string.substitute(_30.BuyerReq_RequestsLog_Title_SingleZeroValue,[_3a,_3c]);
}else{
if(_33==0){
document.getElementById("requestsLog_Title").innerHTML=dojo.string.substitute(_30.BuyerReq_RequestsLog_Title_SingleZeroValue,[_39,_3b]);
}else{
document.getElementById("requestsLog_Title").innerHTML=dojo.string.substitute(_30.BuyerReq_RequestsLog_Title,[_39,_3b,_3a,_3c]);
}
}
}
},updateStoreWithData:function(_3d,_3e){
if(this._requestsStore.isDirty){
this._requestsStore.revert();
}
this._requestsStore.close();
this._requestsStore._jsonData=_3d;
this._requestsStore.fetch();
if(_3e){
this._requestsGrid._refresh();
}
},onRequestsLogFetchEnd:function(_3f){
dojo.query("#requestsLog_GridIndicator").empty();
if(_3f.faultstring){
this.onRequestsLogFetchFailure(_3f);
}else{
this.updateStoreWithData(_3f,this._isGridExpanded);
if(this._isGridExpanded){
this.drawLeftPane(true);
}
this._data=_3f;
delete this._shownData;
if(this._isFirstLoad){
this.onExpandCollapseGrid();
this._isFirstLoad=false;
}
this.updateRequestCounters();
}
},onRequestsLogFetchFailure:function(_40){
dojo.query("#requestsLog_GridIndicator").empty();
var dlg=new Px.Ex.OKMessageDialog({message:msgs.BuyerReq_NewBuyerRequestForm_FailureSubmit_Dialog_Content+"<br>"+_40.faultstring});
dlg.show();
},prepareNewBuyerRequestForm:function(){
var _41=this._messages;
this.decorateNewBuyerRequestForm();
this._form=new dijit.form.Form({"class":"newBuyerRequestForm",onSubmit:function(){
return false;
}},"newBuyerRequestForm_Form");
this._form_buyerName=new Px.Ex.ValidationTextBox({"class":"form-input",intermediateChanges:true,name:"buyerName",tabIndex:1,trim:true,regExp:this.BUYERNAME_REGEXP,required:true,maxLength:49,promptMessage:_41.BuyerReq_NewBuyerRequestForm_BuyerName_Prompt||"",invalidMessage:_41.BuyerReq_NewBuyerRequestForm_BuyerName_Invalid||"$_unset_$",emptyMessage:_41.BuyerReq_NewBuyerRequestForm_BuyerName_Empty||"$_unset_$"},"newBuyerRequestForm_Form_BuyerName");
this._form_buyerURL=new Px.Ex.ValidationTextBox({"class":"form-input",intermediateChanges:false,name:"buyerURL",tabIndex:2,trim:true,lowercase:true,regExp:this.BUYERURL_REGEXP,required:true,promptMessage:_41.BuyerReq_NewBuyerRequestForm_BuyerURL_Prompt||"",invalidMessage:_41.BuyerReq_NewBuyerRequestForm_BuyerURL_Invalid||"$_unset_$",emptyMessage:_41.BuyerReq_NewBuyerRequestForm_BuyerURL_Empty||"$_unset_$"},"newBuyerRequestForm_Form_BuyerURL");
this._form_buyerContactDetails=new Px.Ex.ValidationTextarea({"class":"newBuyerRequestForm_BuyerContactDetails",intermediateChanges:true,name:"buyerContactDetails",tabIndex:3,required:true,emptyMessage:_41.BuyerReq_NewBuyerRequestForm_BuyerContactDetails_Empty},"newBuyerRequestForm_Form_BuyerContactDetails");
this._form_remarks=new dijit.form.SimpleTextarea({"class":"newBuyerRequestForm_Remarks",name:"Remarks",tabIndex:4,required:true},"newBuyerRequestForm_Form_Remarks");
this._connections.push(dojo.connect(dojo.byId("newBuyerRequestForm_Form_Clear"),"onclick",dojo.hitch(this,"onClear")));
this._connections.push(dojo.connect(dojo.byId("newBuyerRequestForm_Form_Submit"),"onclick",dojo.hitch(this,"onSubmit")));
this._connections.push(dojo.connect(this._form,"onKeyUp",dojo.hitch(this,"onFormKeyUp")));
},decorateNewBuyerRequestForm:function(){
var _42={tl:false,tr:{radius:17},bl:{radius:17},br:{radius:17},antiAlias:true,autoPad:false,validTags:["div"]};
var _43=new curvyCorners(_42,dojo.byId("newBuyerRequestForm"));
_43.applyCornersToAll();
var _44=dojo.byId("newBuyerRequestForm_Title");
var _45="<ul><li class=\"first last\"><span class=\"active\"><span>"+_44.innerHTML+"</span></span></li></ul>";
_44.innerHTML=_45;
},onFormKeyUp:function(_46){
this.validateForm();
},validateForm:function(){
var _47=this._form_buyerName.isValid();
var _48=this._form_buyerURL.isValid();
var _49=this._form_buyerContactDetails.isValid2();
if(_47&&_48&&_49){
dojo.addClass(dojo.byId("newBuyerRequestForm_Form_SubmitWrapper"),"newBuyerRequestForm_ButtonEnabled");
}else{
dojo.removeClass(dojo.byId("newBuyerRequestForm_Form_SubmitWrapper"),"newBuyerRequestForm_ButtonEnabled");
}
},onClear:function(){
this._form.reset();
},onSubmit:function(){
var _4a=dojo.hasClass(dojo.byId("newBuyerRequestForm_Form_SubmitWrapper"),"newBuyerRequestForm_ButtonEnabled");
if(_4a){
this.submitForm(this._form_buyerName.attr("value"),this._form_buyerURL.attr("value"),this._form_buyerContactDetails.attr("value"),this._form_remarks.attr("value"));
}
},submitForm:function(_4b,_4c,_4d,_4e){
this.xhr({url:"/buyers/submit-new-buyer-request",content:{buyerName:_4b,buyerURL:_4c,buyerContactDetails:_4d,remarks:_4e},load:dojo.hitch(this,"onSubmissionEnd"),error:dojo.hitch(this,"onSubmissionFailure"),handleAs:"json"});
},onSubmissionEnd:function(_4f){
if(_4f.faultstring){
this.onSubmissionFailure(_4f);
}else{
var _50=this._messages;
var dlg=new Px.Ex.OKMessageDialog({message:_50.BuyerReq_NewBuyerRequestForm_SuccessfulSubmit_Dialog_Content,okCallback:dojo.hitch(this,"onSubmissionEndSuccess")});
dlg.show();
}
},onSubmissionEndSuccess:function(){
this._form.reset();
dojo.removeClass(dojo.byId("newBuyerRequestForm_Form_SubmitWrapper"),"newBuyerRequestForm_ButtonEnabled");
this.fetchRequestsLog();
},onSubmissionFailure:function(_51){
var _52=this._messages;
var _53=_52.BuyerReq_NewBuyerRequestForm_FailureSubmit_Dialog_Content+_51.faultstring;
var dlg=new Px.Ex.OKMessageDialog({message:_53});
dlg.show();
},convertNewLineToBR:function(_54){
var res;
res=_54.replace(/\r\n/gi,"<br>");
res=res.replace(/\n/gi,"<br>");
return res;
},destroy:function(){
try{
clearTimeout(this._searchTimer);
}
catch(e){
}
try{
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
delete this._connections;
}
}
catch(e){
}
try{
if(this._requestsStore){
if(this._requestsStore.isDirty){
this._requestsStore.revert();
}
this._requestsStore.close();
}
}
catch(e){
}
try{
if(this._requestsGrid){
this._requestsGrid.destroyRecursive();
}
}
catch(e){
}
try{
if(this._searchControl){
this._searchControl.destroyRecursive();
}
}
catch(e){
}
try{
if(this._form){
this._form.destroyRecursive();
delete this._form;
}
}
catch(e){
}
}});
dojo.declare("Px.Ex.SegmentsScreen",[Px.Ex.XhrMixin],{_categoryBackgroundColor:undefined,_connections:[],_contentPane:undefined,_cookieName:"state_SegmentsScreen",_categoryInfoEditMode:false,_lastTabConnections:[],_selectedTab:undefined,_serverData:undefined,_shouldPreventMultipleOnShow:false,draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/branded-tabs/segments-management-screen",load:dojo.hitch(this,"createScreen"),error:function(_1){
dojo.byId("divContent").innerHTML=Px.Ex.Application._extractError(_1);
},handleAs:"json"});
},createScreen:function(_2){
dojo.empty("divContent");
if(_2.accessDenied){
dojo.byId("divContent").innerHTML=_2.accessDenied;
return;
}
this._serverData=_2;
if(_2.publisherNotExists){
dojo.byId("divContent").innerHTML=this._serverData.messages["SegMng_NoPublisher"];
return;
}
if((this._serverData.segmentCategories==null)||(this._serverData.segmentCategories.length==0)){
dojo.byId("divContent").innerHTML=this._serverData.messages["SegMng_NoContent"];
return;
}
this.__selectedTab=this.getCookieSelectedTab();
this.sortCategories();
this.findBarControlWidths();
this._contentPane=new dijit.layout.ContentPane({"class":"SegMng"}).placeAt("divContent");
this.createTopLevel();
this.createTabButtons();
this.createBottomLevel();
},getCookie:function(){
if(dojo.cookie.isSupported()){
return dojo.cookie(this._cookieName);
}else{
return null;
}
},setCookie:function(_3){
if(dojo.cookie.isSupported()){
dojo.cookie(this._cookieName,_3);
}
},getCookieSelectedTab:function(){
var _4=null;
var _5=this.getCookie();
if(_5){
parts=_5.split(";");
if((parts)&&(parts.length>0)){
_4=parts[0];
}
}
return _4;
},setCookieSelectedTab:function(_6){
var _7=_6;
var _8=this.getCookie();
if(_8){
parts=_8.split(";");
if((parts)&&(parts.length>0)){
parts[0]=_6;
_7=parts.join(";");
}
}
this.setCookie(_7);
},getCookieExpansionState:function(_9){
var _a=[];
var _b=this.getCookie();
if(_b){
parts=_b.split(";");
if((parts)&&(parts.length>1)){
for(index in parts){
if(parts[index].indexOf(_9+":")==0){
innerParts=parts[index].substr(parts[index].indexOf(":")+1).split(",");
if((innerParts)&&(innerParts.length>0)){
_a=innerParts;
}
break;
}
}
}
}
return _a;
},setCookieExpansionState:function(_c,_d){
var _e=this.getCookie();
if(_e){
parts=_e.split(";");
if((parts)&&(parts.length>0)){
var _f=null;
for(index in parts){
if(parts[index].indexOf(_c+":")==0){
_f=index;
break;
}
}
if(_f){
parts[_f]=_c+":"+_d.join(",");
_e=parts.join(";");
}else{
_e+=";"+_c+":"+_d.join(",");
}
}
this.setCookie(_e);
}
},sortCategories:function(){
if((this._serverData.segmentCategories!=null)&&(this._serverData.segmentCategories.length>0)){
this._serverData.segmentCategories.sort(function(a,b){
if(a["categoryCode"]==3){
return -1;
}
if(b["categoryCode"]==3){
return 1;
}
if(a["categoryCode"]==2){
return -1;
}
if(b["categoryCode"]==2){
return 1;
}
if(a["categoryCode"]==1){
return -1;
}
if(b["categoryCode"]==1){
return 1;
}
if(dojo.isChrome){
return -1;
}else{
return 0;
}
});
}
},findBarControlWidths:function(){
var _10=dojo.create("div",{className:"SegMng"},"divContent");
div=dojo.create("div",{className:"segment-container",style:{top:"10000px"},innerHTML:"&nbsp"},_10);
this._segmentContainerWidth=parseInt(dojo.getComputedStyle(div).width)||200;
dojo.destroy(_10);
},createBottomLevel:function(){
var _11,_12,tr,td,div;
_11=dojo.create("table",{style:"width: 100%; padding-left: 20px;"},this._contentPane.containerNode);
_12=dojo.create("tbody",{},_11);
tr=dojo.create("tr",{},_12);
td=dojo.create("td",{},tr);
this._bottomMessage=dojo.create("div",{className:"BottomMessage"},td);
tr=dojo.create("tr",{},_12);
td=dojo.create("td",{},tr);
if(this._serverData.permissions["segmentTreeDraftPublish"]){
button=dojo.create("div",{className:"PublishButton",title:this._serverData.messages["SegMng_TooltipPublishDraft"]},td);
button.innerHTML="&nbsp;";
this._connections.push(dojo.connect(button,"onclick",dojo.hitch(this,"onPublishButton")));
}
if(this._serverData.permissions["segmentTreeDraftCancel"]){
button=dojo.create("div",{className:"CancelButton",title:this._serverData.messages["SegMng_TooltipCancelDraft"]},td);
button.innerHTML="&nbsp;";
this._connections.push(dojo.connect(button,"onclick",dojo.hitch(this,"onCancelButton")));
}
},onPublishButton:function(){
var _13=[];
for(var _14 in this._pages){
if(this._pages[_14]._isDirty){
_13.push(this._pages[_14]._categoryCode);
}
}
this.onRefreshDiscardDialogPublishAction(_13,true);
},onCancelButton:function(){
var _15=[];
for(var _16 in this._pages){
if(this._pages[_16]._isDirty){
_15.push(this._pages[_16]._categoryCode);
}
}
if(_15.length>0){
var dlg=new Px.Ex.MessageDialog({message:this._serverData.messages["SegMng_DiscardMessage"],okCallback:dojo.hitch(this,"onCancelButtonOK",_15),cancelCallback:dojo.hitch(this,"onCancelButtonCancel")});
dlg.show();
}else{
this.onRefreshDiscardDialogDiscardAction(_15);
}
},onCancelButtonOK:function(_17){
this.onRefreshDiscardDialogDiscardAction(_17);
},onCancelButtonCancel:function(){
},createTopLevel:function(){
var _18,_19,tr,td,_1a,_1b;
_18=dojo.create("table",{},this._contentPane.containerNode);
_19=dojo.create("tbody",{},_18);
tr=dojo.create("tr",{},_19);
td=dojo.create("td",{},tr);
dojo.style(td,"width","100%");
td=dojo.create("td",{},tr);
_1a=dojo.create("div",{id:"SegMng_Refresh",innerHTML:this._serverData.messages["SegMng_Grid_Refresh"],className:"SegMng_Refresh unselectable",unselectable:true,title:this._serverData.messages["SegMng_TooltipRefresh"]},td);
_1b=dojo.create("div",{id:"SegMng_TabsContainer"},this._contentPane.containerNode);
this._connections.push(dojo.connect(_1a,"onclick",dojo.hitch(this,"onRefresh")));
this._connections.push(dojo.connect(_1a,"onmouseover",function(){
dojo.addClass(div,"Ready");
}));
this._connections.push(dojo.connect(_1a,"onmouseout",function(){
dojo.removeClass(div,"Ready");
}));
},onRefresh:function(e){
var _1c=[];
if(this._pages&&this._pages.length>0){
for(var _1d in this._pages){
if(this._pages[_1d].refresh()==true){
_1c.push(this._pages[_1d]._categoryCode);
}
}
if(_1c.length>0){
this.showRefreshDiscardMessageDialog(_1c);
}
}
},showRefreshDiscardMessageDialog:function(_1e){
var dlg=new Px.Ex.EmptyMessageDialog({message:this._serverData.messages["SegMng_RefreshMessage"],buttonsClasses:["message-box-publish","message-box-discard","message-box-cancel"],buttonsTooltips:[this._serverData.messages["SegMng_TooltipPublishDraft"],this._serverData.messages["SegMng_TooltipCancelDraft"],this._serverData.messages["SegMng_TooltipCancel"]],buttonsCallbacks:[dojo.hitch(this,"onRefreshDiscardDialogPublishAction",_1e,true),dojo.hitch(this,"onRefreshDiscardDialogDiscardAction",_1e),dojo.hitch(this,"onRefreshDiscardDialogCancelAction")]});
dlg.show();
},onRefreshDiscardDialogPublishAction:function(_1f,_20,_21){
dojo.forEach(_1f,dojo.hitch(this,function(v){
this.xhr({url:"branded-tabs/segments-management-publish-segment-tree-draft",content:{segmentCategory:v},load:dojo.hitch(this,"onPublishDraftSuccess",v,_20,_21),error:dojo.hitch(this,"onPublishDraftFailure",v,_20,_21),handleAs:"json"});
}));
},onPublishDraftSuccess:function(_22,_23,_24,_25){
if(_25.success==true){
if(_23){
for(var _26 in this._pages){
if(this._pages[_26]._categoryCode==_22){
this._pages[_26].forceRefresh(dojo.hitch(this,function(){
var _27=this._serverData.messages["SegMng_LastPublishMessage"];
_27=dojo.string.substitute(_27,[_25.time]);
this.WriteMessageAtBottom(_27);
}));
}
}
}
if(_24){
_24();
}
}else{
this.onPublishDraftFailure(_22,_23,_24,_25);
}
},onPublishDraftFailure:function(_28,_29,_2a,_2b){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_PublishDraftFailure"]});
dlg.show();
if(_2a){
_2a();
}
},onRefreshDiscardDialogDiscardAction:function(_2c){
dojo.forEach(_2c,dojo.hitch(this,function(v){
this.xhr({url:"branded-tabs/segments-management-cancel-segment-tree-draft",content:{segmentCategory:v},load:dojo.hitch(this,"onCancelDraftSuccess",v),error:dojo.hitch(this,"onCancelDraftFailure",v),handleAs:"json"});
}));
},onCancelDraftSuccess:function(_2d,_2e){
if(_2e.success==true){
for(var _2f in this._pages){
if(this._pages[_2f]._categoryCode==_2d){
this._pages[_2f].forceRefresh(dojo.hitch(this,function(){
var _30=this._serverData.messages["SegMng_LastDiscardMessage"];
_30=dojo.string.substitute(_30,[_2e.time]);
this.WriteMessageAtBottom(_30);
}));
}
}
}else{
this.onCancelDraftFailure(_2d,_2e);
}
},onCancelDraftFailure:function(_31,_32){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_CancelDraftFailure"]});
dlg.show();
},onRefreshDiscardDialogCancelAction:function(){
},createTabButtons:function(){
var _33,_34,tr,td,td1,td2,div,_35,_36,_37,_38;
this._categoryBackgroundColor=dojo.getComputedStyle(dojo.query(".texi-logo-text")[0]).color;
_38=dojo.byId("SegMng_TabsContainer");
dojo.style(_38,"marginLeft","20px");
var c=dojo.create;
if(dojo.isIE){
_33=c("table",{},_38);
_33.cellSpacing="0";
_34=c("tbody",{},_33);
tr=c("tr",{},_34);
td=c("td",{id:"ScrollingArrows_Left",className:"LeftArrow IE"},tr);
dojo.style(td,"display","none");
this._connections.push(dojo.connect(dojo.byId("ScrollingArrows_Left"),"onclick",dojo.hitch(this,"onScrollLeftClick")));
td=c("td",{},tr);
dojo.style(td,"padding-left: 0px; padding-right: 0px;");
_35=c("span",{},td);
div=c("div",{id:"TabsScroller",className:"IE TabsOuterDiv Full"},_35);
_33=c("table",{},div);
_33.cellSpacing="0";
td=c("td",{id:"ScrollingArrows_Right",className:"RightArrow IE"},tr);
dojo.style(td,"display","none");
this._connections.push(dojo.connect(dojo.byId("ScrollingArrows_Right"),"onclick",dojo.hitch(this,"onScrollRightClick")));
_34=c("tbody",{},_33);
tr=c("tr",{},_34);
this._tabs=new dijit.layout.StackContainer({}).placeAt(this._contentPane.containerNode);
}else{
var x="Gennady";
_33=c("table",{className:"tab-buttons-container"},_38);
dojo.style(_33,"marginLeft","0px");
dojo.style(_33,"marginBottom","-4px");
_34=c("tbody",{},_33);
tr=c("tr",{},_34);
tdLeftArrow=c("td",{id:"ScrollingArrows_Left",className:"LeftArrow"},tr);
dojo.style(tdLeftArrow,"display","none");
this._connections.push(dojo.connect(dojo.byId("ScrollingArrows_Left"),"onclick",dojo.hitch(this,"onScrollLeftClick")));
tdTabsScroller=c("td",{},tr);
divTabsScroller=c("div",{id:"TabsScroller"},tdTabsScroller);
dojo.style(divTabsScroller,"overflow","hidden");
dojo.style(divTabsScroller,"maxWidth","830px");
tdRightArrow=c("td",{id:"ScrollingArrows_Right",className:"RightArrow"},tr);
dojo.style(tdRightArrow,"display","none");
this._connections.push(dojo.connect(dojo.byId("ScrollingArrows_Right"),"onclick",dojo.hitch(this,"onScrollRightClick")));
dojo.style(tdRightArrow,"display","none");
divTabsScrollerSon=c("div",{id:"TabsScrollerSon"},divTabsScroller);
dojo.style(divTabsScrollerSon,"width","2000px");
_33=c("table",{},divTabsScrollerSon);
_34=c("tbody",{},_33);
tr=c("tr",{},_34);
this._tabs=new dijit.layout.StackContainer().placeAt(this._contentPane.containerNode);
}
this._refreshIndicator=dojo.create("div",{},dojo.byId("divContent"));
this._pages=new Array();
for(category in this._serverData.segmentCategories){
var _39=this._serverData.segmentCategories[category]["categoryCode"];
this._pages[_39]=new Px.Ex.SegmentsCategoryPage({categoryCode:_39,getCategoryObjectFn:dojo.hitch(this,"getCategoryObjectByCode"),parentContainer:this._tabs,parentObject:this,segmentContainerWidth:this._segmentContainerWidth,serverData:this._serverData,expansionState:this.getCookieExpansionState(_39),xhr:dojo.hitch(this,"xhr")});
this._tabs.addChild(this._pages[_39]);
td=dojo.create("td",{},tr);
dojo.create("div",{id:"btn_id_"+_39,className:"btn_tab_"+_39},td);
}
this._ajaxIndicator=dojo.create("div",{className:"ajax-indicator texi-hidden",innerHTML:this._serverData.messages["SegMng_PleaseWait"]},td);
this._tabs.startup();
if(this.__selectedTab){
this.selectTab(this.__selectedTab);
}else{
this.selectTab(this._serverData.segmentCategories[0]["categoryCode"]);
}
if(!this.isScrollerRequired()){
dojo.style(dojo.byId("ScrollingArrows_Left"),"display","none");
dojo.style(dojo.byId("ScrollingArrows_Right"),"display","none");
}else{
dojo.style(dojo.byId("TabsScroller"),"maxWidth","806px");
dojo.style(dojo.byId("TabsScroller"),"width","806px");
dojo.style(dojo.byId("ScrollingArrows_Left"),"display","table-cell");
dojo.style(dojo.byId("ScrollingArrows_Right"),"display","table-cell");
this.myScrollIntoView(this._selectedTab);
this.refreshScroller();
}
},isScrollerRequired:function(){
return (this.getScrollWidth()>dojo.style("TabsScroller","maxWidth"));
},getScrollWidth:function(){
var sum=0;
for(var i=0;i<this._serverData.segmentCategories.length;i++){
sum+=dojo.coords(dojo.byId("btn_id_"+this._serverData.segmentCategories[i]["categoryCode"])).w;
}
return sum;
},refreshScroller:function(){
this.showScrollArrow("left",this.shouldEnableScrollArrow("left"));
this.showScrollArrow("right",this.shouldEnableScrollArrow("right"));
},getNextToLastVisibleCategoryCode:function(){
var sum=0;
var _3a;
var _3b=dojo.style("TabsScroller","maxWidth");
var _3c=dojo.byId("TabsScroller").scrollLeft;
var _3d;
for(var i=0;i<this._serverData.segmentCategories.length;i++){
var _3e=dojo.coords(dojo.byId("btn_id_"+this._serverData.segmentCategories[i]["categoryCode"])).w;
var _3f=sum+_3e;
if((_3d=_3f-(_3c+_3b))>0){
var _40=((_3e-_3d)/_3e)*100;
if(_40>=parseFloat(Px.Ex.Application._scroller_tab_percent)){
_3a=i;
}else{
_3a=i-1;
}
break;
}else{
sum=_3f;
_3a=i;
}
}
if(_3a<(this._serverData.segmentCategories.length-1)){
return (this._serverData.segmentCategories[_3a+1]["categoryCode"]);
}else{
return -1;
}
},getPreviousToFirstVisibleCategoryCode:function(){
var sum=0;
var _41;
var _42=dojo.byId("TabsScroller").scrollLeft;
var _43;
for(var i=0;i<this._serverData.segmentCategories.length;i++){
var _44=dojo.coords(dojo.byId("btn_id_"+this._serverData.segmentCategories[i]["categoryCode"])).w;
if((_43=sum-_42)>=0){
var _45=dojo.coords(dojo.byId("btn_id_"+this._serverData.segmentCategories[i-1]["categoryCode"])).w;
var _46=((sum-_42)/_45)*100;
if(_46>=parseFloat(Px.Ex.Application._scroller_tab_percent)){
_41=i-1;
}else{
_41=i;
}
break;
}else{
sum+=_44;
}
}
if(_41==0){
return -1;
}else{
return (this._serverData.segmentCategories[_41-1]["categoryCode"]);
}
},shouldEnableScrollArrow:function(_47){
var div=dojo.byId("TabsScroller");
switch(_47){
case "left":
return (div.scrollLeft>0);
break;
case "right":
return (this.getScrollWidth()>div.clientWidth+div.scrollLeft);
break;
}
return false;
},showScrollArrow:function(_48,_49){
switch(_48){
case "left":
switch(_49){
case true:
dojo.toggleClass("ScrollingArrows_Left","disabled",false);
break;
case false:
dojo.toggleClass("ScrollingArrows_Left","disabled",true);
break;
}
break;
case "right":
switch(_49){
case true:
dojo.toggleClass("ScrollingArrows_Right","disabled",false);
break;
case false:
dojo.toggleClass("ScrollingArrows_Right","disabled",true);
break;
}
break;
}
},myScrollIntoView:function(_4a){
dojo.require("dojox.fx.scroll");
var _4b=0;
var _4c=dojo.byId("TabsScroller").scrollLeft;
var _4d=dojo.style("TabsScroller","maxWidth");
var _4e=this.getScrollWidthUntilTab(_4a);
var _4f=dojo.coords(dojo.byId("btn_id_"+_4a)).w;
var _50=0;
var _51=false;
if(_4e<_4c){
_4b=_4e;
_51=true;
}else{
if((_50=(_4e+_4f)-(_4c+_4d))>0){
_4b=_4c+_50;
_51=true;
}
}
if(_51){
dojox.fx.smoothScroll({node:dojo.byId("TabsScroller"),win:dojo.byId("TabsScroller"),duration:500,target:{x:_4b},onEnd:dojo.hitch(this,function(){
this.refreshScroller();
})}).play();
}
},getScrollWidthUntilTab:function(_52){
var sum=0;
for(var i=0;i<this._serverData.segmentCategories.length;i++){
if(_52==this._serverData.segmentCategories[i]["categoryCode"]){
break;
}else{
sum+=dojo.coords(dojo.byId("btn_id_"+this._serverData.segmentCategories[i]["categoryCode"])).w;
}
}
return sum;
},selectTab:function(num){
if(this._selectedTab==num){
return;
}
for(category in this._serverData.segmentCategories){
var _53=this._serverData.segmentCategories[category]["categoryCode"];
if(this._selectedTab==undefined){
this.createTabButton(_53,(parseInt(num)==_53));
}else{
this.createTabButton(_53,(parseInt(num)==_53));
}
if((parseInt(num)==_53)){
this._tabs.selectChild(this._pages[_53]);
this.setCookieSelectedTab(_53);
this._selectedTab=_53;
}
}
this.myScrollIntoView(this._selectedTab);
},switchNewCategory:function(num){
var _54=this._serverData.constants;
var _55=this.getCategoryObjectByCode(num);
var _56="";
if(this["btn_tab_"+num]){
if(!this.changeTabIcon(num,_54["SegMng_Const_IconNewCategoryOff"],_56)){
this.changeTabIcon(num,_54["SegMng_Const_IconNewCategoryOn"],_56);
}
}
this.xhr({url:"/branded-tabs/segments-management-mark-as-new",content:{categoryCode:num,toNew:(_55["newCategory"]==false)},load:dojo.hitch(this,function(_57){
if(_57.success==true){
_55["newCategory"]=!_55["newCategory"];
if(_55["newCategory"]){
this.changeTabIcon(num,_56,_54["SegMng_Const_IconNewCategoryOn"]);
}else{
this.changeTabIcon(num,_56,_54["SegMng_Const_IconNewCategoryOff"]);
}
}else{
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_Category_New_Failure"]});
dlg.show();
if(_55["newCategory"]){
this.changeTabIcon(num,_56,_54["SegMng_Const_IconNewCategoryOn"]);
}else{
this.changeTabIcon(num,_56,_54["SegMng_Const_IconNewCategoryOff"]);
}
}
}),error:function(err){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_Category_New_Failure"]});
dlg.show();
if(_55["newCategory"]){
this.changeTabIcon(num,_56,_54["SegMng_Const_IconNewCategoryOn"]);
}else{
this.changeTabIcon(num,_56,_54["SegMng_Const_IconNewCategoryOff"]);
}
},handleAs:"json"});
},changeTabIcon:function(num,_58,_59){
try{
if(this["btn_tab_"+num]){
var _5a=this["btn_tab_"+num].children[2].rawNode.href.baseVal;
if(_5a.indexOf(_58)!=-1){
this["btn_tab_"+num].children[2].rawNode.href.baseVal=_5a.replace(_58,_59);
return true;
}
}
return false;
}
catch(e){
return false;
}
},createTabButton:function(id,_5b){
var _5c=dojo.hitch(this,"selectTab",id);
var _5d=dojo.hitch(this,"editCategoryInfo",id);
var _5e=dojo.hitch(this,"switchNewCategory",id);
this.createTabButton_draw("btn_id_"+id,this.getCategoryObjectByCode(id),_5b,"btn_tab_"+id,_5c,_5d,_5e);
if(_5b){
this._selectedTab=id;
this._pages[id].activate();
}
},onScrollRightClick:function(){
var _5f=this.getNextToLastVisibleCategoryCode();
if(_5f!=-1){
this.myScrollIntoView(_5f);
}
},onScrollLeftClick:function(){
var _60=this.getPreviousToFirstVisibleCategoryCode();
if(_60!=-1){
this.myScrollIntoView(_60);
}
},createTabButton_draw:function(_61,_62,_63,key,_64,_65,_66){
var _67=60;
var _68="12px",H=20,W=130;
var _69=this._serverData.constants;
var h=H;
var _6a=_63?this._categoryBackgroundColor||"#F26A22":"#898D90";
var _6b=_63?_6a:_6a;
var _6c=_63?"white":"white";
var _6d=_63?"bold":"normal";
var w=W;
if(this[key]){
this[key].destroy();
}
var _6e=this[key]=dojox.gfx.createSurface(_61,w,h);
var t=_6e.createText({x:0,y:0,text:_62["categoryName"],align:"middle"});
t.setFont({family:"Arial",size:_68,weight:_6d,rotated:true});
var tw=t.getTextWidth();
_6e.remove(t);
if(tw+_67>w){
w=tw+_67;
_6e.setDimensions(w,h);
}
var _6f=_6e.createPath("");
var r=8;
var _70=_63?0:2;
_6f.moveTo(w-1,h).vLineTo(r+1+_70).arcTo(r,r,0,false,false,w-r-1,1+_70).hLineTo(r+1).arcTo(r,r,0,false,false,1,r+1+_70).vLineTo(h).closePath();
_6f.setFill(_6a).setStroke(_6b);
var c={x:parseInt(w/2),y:parseInt(h/2)};
var t=_6e.createText({x:c.x,y:c.y+6,text:_62["categoryName"],align:"middle"});
if(_62["newCategory"]){
var _71=_69.SegMng_Const_IconNewCategoryOn;
}else{
var _71=_69.SegMng_Const_IconNewCategoryOff;
}
var img=_6e.createImage({x:w-20,y:3+_70,src:_71,height:14,width:14});
if((dojo.isFF)&&(dojo.isFF=="3.5")){
img.rawNode.attributes[0].nodeValue="1";
}
if(this._serverData.permissions["segmentCategoryNewIndication"]){
this._connections.push(img.connect("onclick",dojo.hitch(this,function(evt){
if(!this._categoryInfoEditMode){
this.removeTooltip(dojo.byId(_61));
_66();
}
dojo.stopEvent(evt);
})));
}
this._connections.push(img.connect("onmouseover",dojo.hitch(this,function(evt){
if(!this._categoryInfoEditMode){
this.showNewCategoryTooltip(_62,dojo.byId(_61));
}
dojo.stopEvent(evt);
})));
this._connections.push(img.connect("onmouseout",dojo.hitch(this,function(evt){
if(!this._categoryInfoEditMode){
this.removeTooltip(dojo.byId(_61));
}
dojo.stopEvent(evt);
})));
t.setFill(_6c);
t.setFont({family:"Arial",size:_68,weight:_6d,rotated:false});
this._connections.push(_6e.connect("onclick",dojo.hitch(this,function(){
if((this._selectedTab==_62["categoryCode"])&&(this._serverData.permissions["segmentCategoryEdit"])){
_65();
}else{
if(!this._categoryInfoEditMode){
_64();
}
}
})));
this._connections.push(_6e.connect("onmouseover",dojo.hitch(this,function(){
if(!this._categoryInfoEditMode){
this.showCategoryInformationTooltip(_62,dojo.byId(_61));
}
})));
this._connections.push(_6e.connect("onmouseout",dojo.hitch(this,function(){
if(!this._categoryInfoEditMode){
this.removeTooltip(dojo.byId(_61));
}
})));
if(dojox.gfx.renderer=="silverlight"){
_6e.rawNode["Cursor"]="Hand";
}else{
dojo.style(_6e.rawNode,"cursor","pointer");
}
},editCategoryInfo:function(num){
if(!this._categoryInfoEditMode){
this._categoryInfoEditMode=true;
}else{
this._categoryInfoEditMode=false;
}
},removeTooltip:function(div){
this._shouldPreventMultipleOnShow=false;
this.destroyLastTabConnections();
dijit.hideTooltip(div);
},getCategoryObjectByCode:function(_72){
for(category in this._serverData.segmentCategories){
if(_72==this._serverData.segmentCategories[category]["categoryCode"]){
return this._serverData.segmentCategories[category];
}
}
},showCategoryInformationTooltip:function(_73,div){
switch(this._serverData.permissions["segmentCategoryEdit"]){
case true:
this.showEditableCategoryInfo(_73,div);
break;
case false:
this.showNonEditableCategoryInfo(_73,div);
break;
}
},showEditableCategoryInfo:function(_74,div){
var _75=this._serverData.constants;
var _76="";
var _77=_74["categoryInfo"]?true:false;
var _78=_74["categoryOwner"]?true:false;
var _79=_74["providerLogo"]?true:false;
var _7a=this._serverData.categoryLogos[_74["categoryCode"]]?true:false;
_76+="<p class=\"categoryTooltipHeader\">"+_74["categoryName"]+"</p>";
_76+="<p class=\"categoryTooltipBody\">";
_76+="<div id=\"SegMng_EditTab_TextAreaContainer_"+_74["categoryCode"]+"\">";
_76+=this.showNonEditableCategoryTooltipContent(_74,true);
_76+="</div>";
_76+="</div>";
if(_7a){
_76+="<p id=\"SegMng_EditTab_PoweredBy_"+_74["categoryCode"]+"\" class=\"categoryTooltipOwnerText\" style=\"visibility:"+(_79?"visible":"hidden")+";\">";
_76+="Powered by&nbsp;";
_76+="<img src=\""+_75.SegMng_Const_LogoFolder+"/"+_75.SegMng_Const_LogoPrefix+this._serverData.categoryLogos[_74["categoryCode"]]+_75.SegMng_Const_LogoSuffix+"\" class=\"categoryTooltipOwnerLogo\"/>";
_76+="</p>";
}
_76+="<hr class=\"SegMng_EditTab_HR\">";
_76+="<div id=\"SegMng_EditTab_Buttons_"+_74["categoryCode"]+"\">";
_76+="<input id=\"SegMng_EditTab_Checkbox_"+_74["categoryCode"]+"\" "+(_79?"checked":"")+" type=\"checkbox\""+(_7a?"":"disabled")+">Show Logo";
_76+="<div id=\"SegMng_EditTab_Edit_"+_74["categoryCode"]+"\" class=\"SegMng_EditTab_Edit\">&nbsp;";
_76+="</div>";
_76+="</div>";
_76+="</p>";
dijit.showTooltip(_76,div,["above","below"]);
this._lastTabConnections.push(dojo.connect(dijit._masterTT,"_onShow",dojo.hitch(this,"onTooltipShow",_74)));
},showNonEditableCategoryTooltipContent:function(_7b,_7c){
if(!_7c){
var _7d=dojo.byId("SegMng_EditTab_TextAreaContainer_"+_7b["categoryCode"]);
}
var _7e="";
_7e+="<div id=\"SegMng_EditTab_TextArea_"+_7b["categoryCode"]+"\" class=\"SegMng_EditTab_TextArea\">";
_7e+=_7b["categoryInfo"]?this.handleCategoryTooltipHTML(_7b["categoryInfo"]):"";
_7e+="</div>";
if(!_7c){
_7d.innerHTML=_7e;
}else{
return _7e;
}
},showEditableCategoryTooltipContent:function(_7f,_80){
var _81;
if(!_80){
_81=dojo.byId("SegMng_EditTab_TextAreaContainer_"+_7f["categoryCode"]);
}
var _82="";
_82+="<textarea id=\"SegMng_EditTab_TextArea_"+_7f["categoryCode"]+"\" class=\"SegMng_EditTab_TextArea\">";
_82+=_7f["categoryInfo"]?this.handleCategoryTooltipHTML(_7f["categoryInfo"]):"";
_82+="</textarea>";
if(!_80){
_81.innerHTML=_82;
}else{
return _82;
}
},handleCategoryTooltipHTML:function(_83){
var _84=_83;
_84=_84.replace(/&lt;b&gt;/gi,"<b>");
_84=_84.replace(/&lt;\/b&gt;/gi,"</b>");
_84=_84.replace(/&lt;br&gt;/gi,"<br>");
_84=_84.replace(/&lt;br\/&gt;/gi,"<br/>");
return _84;
},onTooltipShow:function(_85){
if(!this._shouldPreventMultipleOnShow){
this._shouldPreventMultipleOnShow=true;
this._lastTabConnections.push(dojo.connect(dojo.byId("SegMng_EditTab_Edit_"+_85["categoryCode"]),"onclick",dojo.hitch(this,"onEditCategoryInfo",_85)));
this._lastTabConnections.push(dojo.connect(dojo.byId("SegMng_EditTab_Checkbox_"+_85["categoryCode"]),"onclick",dojo.hitch(this,"onCheckShowCategoryLogo",_85)));
}
},showNonEditableCategoryInfo:function(_86,div){
var _87=this._serverData.constants;
var _88="";
var _89=_86["categoryInfo"]?true:false;
var _8a=_86["categoryOwner"]?true:false;
var _8b=_86["providerLogo"]?true:false;
if(_89){
_88+="<p class=\"categoryTooltipHeader\">"+_86["categoryName"]+"</p>";
_88+="<p class=\"categoryTooltipBody\">"+this.handleCategoryTooltipHTML(_86["categoryInfo"])+"</p>";
}else{
_88+="<p class=\"categoryTooltipHeader\">"+_86["categoryName"]+"</p>";
}
if(_8a&&_8b){
_88+="<p class=\"categoryTooltipOwnerText\">";
_88+="Powered by&nbsp;";
_88+="<img src=\""+_87.SegMng_Const_LogoFolder+"/"+_87.SegMng_Const_LogoPrefix+_86["providerLogo"]+_87.SegMng_Const_LogoSuffix+"\" class=\"categoryTooltipOwnerLogo\"/>";
_88+="</p>";
}
dijit.showTooltip(_88,div,["above","below"]);
},showNewCategoryTooltip:function(_8c,div){
var _8d="";
_8d+="<p class=\"categoryNewSegmentsTooltip\">";
if(_8c["newCategory"]){
_8d+="<span class=\"categoryNewCategoryNewTooltip\">New!&nbsp;</span><br>";
}
if(this._serverData.permissions["segmentCategoryNewIndication"]){
if(_8c["newCategory"]){
_8d+=this._serverData.messages["SegMng_Tooltip_Category_New_On"];
}else{
_8d+=this._serverData.messages["SegMng_Tooltip_Category_New_Off"];
}
}
if(!_8c["newCategory"]&&!this._serverData.permissions["segmentCategoryNewIndication"]){
_8d+=this._serverData.messages["SegMng_Category_New_Off_NoPerm_Tooltip"];
}
_8d+="</p>";
dijit.showTooltip(_8d,div);
},onEditCategoryInfo:function(_8e){
this.destroyLastTabConnections();
var _8f=this._serverData.constants;
this.showEditableCategoryTooltipContent(_8e,false);
var _90="<div style=\"width: 300px;\"><table style=\"margin-left: auto; padding-top: 5px;\"><tbody><tr>";
_90+="<td><div id=\"SegMng_EditTab_Cancel_"+_8e["categoryCode"]+"\" class=\"SegMng_EditTab_Cancel\">&nbsp;";
_90+="</div></td>";
_90+="<td><div id=\"SegMng_EditTab_Save_"+_8e["categoryCode"]+"\" class=\"SegMng_EditTab_Save\">&nbsp;";
_90+="</div></td></tr></tbody></table></div>";
dojo.byId("SegMng_EditTab_Buttons_"+_8e["categoryCode"]).innerHTML=_90;
this._lastTabConnections.push(dojo.connect(dojo.byId("SegMng_EditTab_Save_"+_8e["categoryCode"]),"onclick",dojo.hitch(this,"onSaveCategoryInfo",_8e)));
this._lastTabConnections.push(dojo.connect(dojo.byId("SegMng_EditTab_Cancel_"+_8e["categoryCode"]),"onclick",dojo.hitch(this,"onCancelCategoryInfo",_8e)));
},onSaveCategoryInfo:function(_91){
this.xhr({url:"/branded-tabs/segments-management-save-category-info",content:{categoryCode:_91["categoryCode"],categoryInfo:dojo.byId("SegMng_EditTab_TextArea_"+_91["categoryCode"]).value},load:dojo.hitch(this,"onSaveCategoryInfoSuccess",_91),error:dojo.hitch(this,"onSaveCategoryInfoFailure",_91),handleAs:"json"});
},onSaveCategoryInfoSuccess:function(_92,_93){
if(_93.success==true){
var _94=this._serverData.constants;
var _95=this._serverData.categoryLogos[_92["categoryCode"]]?true:false;
var _96="";
_92["categoryInfo"]=dojo.byId("SegMng_EditTab_TextArea_"+_92["categoryCode"]).value;
this.showNonEditableCategoryTooltipContent(_92,false);
this.destroyLastTabConnections();
_96+="<input id=\"SegMng_EditTab_Checkbox_"+_92["categoryCode"]+"\" type=\"checkbox\" "+(_92["providerLogo"]!=""?"checked=\"checked\"":"")+(_95?"":" disabled")+">Show Logo";
_96+="<div id=\"SegMng_EditTab_Edit_"+_92["categoryCode"]+"\" class=\"SegMng_EditTab_Edit\">&nbsp;";
_96+="</div>";
dojo.byId("SegMng_EditTab_Buttons_"+_92["categoryCode"]).innerHTML=_96;
this._lastTabConnections.push(dojo.connect(dojo.byId("SegMng_EditTab_Edit_"+_92["categoryCode"]),"onclick",dojo.hitch(this,"onEditCategoryInfo",_92)));
this._lastTabConnections.push(dojo.connect(dojo.byId("SegMng_EditTab_Checkbox_"+_92["categoryCode"]),"onclick",dojo.hitch(this,"onCheckShowCategoryLogo",_92)));
}else{
this.onSaveCategoryInfoFailure(_92,_93);
}
},onSaveCategoryInfoFailure:function(_97,_98){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_Category_Tooltip_Failure"]});
dlg.show();
this.onCancelCategoryInfo(_97);
},onCancelCategoryInfo:function(_99){
var _9a=this._serverData.constants;
var _9b=this._serverData.categoryLogos[_99["categoryCode"]]?true:false;
var _9c="";
this.showNonEditableCategoryTooltipContent(_99,false);
this.destroyLastTabConnections();
_9c+="<input id=\"SegMng_EditTab_Checkbox_"+_99["categoryCode"]+"\" type=\"checkbox\" "+(_99["providerLogo"]!=""?"checked=\"checked\"":"")+(_9b?"":" disabled")+">Show Logo";
_9c+="<div id=\"SegMng_EditTab_Edit_"+_99["categoryCode"]+"\" class=\"SegMng_EditTab_Edit\">&nbsp;";
_9c+="</div>";
dojo.byId("SegMng_EditTab_Buttons_"+_99["categoryCode"]).innerHTML=_9c;
this._lastTabConnections.push(dojo.connect(dojo.byId("SegMng_EditTab_Edit_"+_99["categoryCode"]),"onclick",dojo.hitch(this,"onEditCategoryInfo",_99)));
this._lastTabConnections.push(dojo.connect(dojo.byId("SegMng_EditTab_Checkbox_"+_99["categoryCode"]),"onclick",dojo.hitch(this,"onCheckShowCategoryLogo",_99)));
},onCheckShowCategoryLogo:function(_9d){
var _9e;
if((_9d["providerLogo"])&&(_9d["providerLogo"]!="")){
_9e="";
}else{
_9e=this._serverData.categoryLogos[_9d["categoryCode"]];
}
this.xhr({url:"/branded-tabs/segments-management-set-category-provider-logo",content:{categoryCode:_9d["categoryCode"],providerLogo:_9e},load:dojo.hitch(this,"onCheckShowCategoryLogoSuccess",_9d),error:dojo.hitch(this,"onCheckShowCategoryLogoFailure",_9d),handleAs:"json"});
},onCheckShowCategoryLogoSuccess:function(_9f,_a0){
if(_a0.success==true){
if((_9f["providerLogo"])&&(_9f["providerLogo"]!="")){
dojo.style(dojo.byId("SegMng_EditTab_PoweredBy_"+_9f["categoryCode"]),"visibility","hidden");
_9f["providerLogo"]="";
}else{
dojo.style(dojo.byId("SegMng_EditTab_PoweredBy_"+_9f["categoryCode"]),"visibility","visible");
_9f["providerLogo"]=this._serverData.categoryLogos[_9f["categoryCode"]];
}
}else{
this.onCheckShowCategoryLogoFailure(_9f,_a0);
}
},onCheckShowCategoryLogoFailure:function(_a1,_a2){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_Category_Tooltip_Failure"]});
dlg.show();
var _a3=(_a1["providerLogo"]?true:false);
dojo.attr(dojo.byId("SegMng_EditTab_Checkbox_"+_a1["categoryCode"]),"checked",_a3);
},destroyLastTabConnections:function(){
try{
if(this._lastTabConnections){
dojo.forEach(this._lastTabConnections,dojo.disconnect);
}
delete this._lastTabConnections;
this._lastTabConnections=[];
}
catch(e){
}
},WriteMessageAtBottom:function(_a4){
if(this._bottomMessage){
this._bottomMessage.innerHTML=_a4;
return true;
}else{
return false;
}
},beforeClose:function(_a5){
var _a6=[];
if(this._pages&&this._pages.length>0){
for(var _a7 in this._pages){
if(this._pages[_a7].refresh()==true){
_a6.push(this._pages[_a7]._categoryCode);
}
}
if(_a6.length>0){
this.showLeaveScreenDiscardMessageDialog(_a6,_a5);
}else{
_a5();
}
}else{
_a5();
}
},showLeaveScreenDiscardMessageDialog:function(_a8,_a9){
var dlg=new Px.Ex.EmptyMessageDialog({message:this._serverData.messages["SegMng_RefreshMessage"],buttonsClasses:["message-box-publish","message-box-continue","message-box-back"],buttonsTooltips:[this._serverData.messages["SegMng_TooltipLeavePublish"],this._serverData.messages["SegMng_TooltipLeaveContinue"],this._serverData.messages["SegMng_TooltipLeaveBack"]],buttonsCallbacks:[dojo.hitch(this,"onRefreshDiscardDialogPublishAction",_a8,false,_a9),_a9,function(){
}]});
dlg.show();
},destroy:function(){
try{
this.cancelXhr();
}
catch(e){
}
try{
if(this._lastTabConnections){
dojo.forEach(this._lastTabConnections,dojo.disconnect,this);
delete this._lastTabConnections;
}
}
catch(e){
}
try{
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
delete this._connections;
}
}
catch(e){
}
try{
for(page in this._pages){
this._pages[page].destroy();
}
}
catch(e){
}
try{
if(this._serverData){
for(category in this._serverData.segmentCategories){
var _aa=this._serverData.segmentCategories[category]["categoryCode"];
dojo.destroy(dojo.byId("btn_id_"+_aa));
}
}
}
catch(e){
}
try{
dojo.destroy(this._tabs);
}
catch(e){
}
try{
delete this._selectedTab;
}
catch(e){
}
try{
dojo.empty("divContent");
}
catch(e){
}
}});
dojo.declare("Px.Ex.SegmentsCategoryPage",dijit.layout.ContentPane,{_activated:false,_categoryCode:undefined,_connections:[],_lastEditActions:[],_isDirty:false,_isProcessing:false,_hasCache:false,_pageData:undefined,_parentObject:undefined,_parentContainer:undefined,_segmentContainerWidth:undefined,_serverData:undefined,_xhr:undefined,constructor:function(_ab){
this._categoryCode=_ab.categoryCode;
this._parentObject=_ab.parentObject;
this._parentContainer=_ab.parentContainer;
this._segmentContainerWidth=_ab.segmentContainerWidth;
this._serverData=_ab.serverData;
this._expansionState=_ab.expansionState;
this._xhr=_ab.xhr;
},blurFunction:function(){
this._listen=null;
this._connections.push(dojo.connect(this._grid.domNode,"onmouseleave",dojo.hitch(this,function(e){
this._listen=dojo.connect(window,"onclick",this._grid.edit,"apply");
})));
this._connections.push(dojo.connect(this._grid.domNode,"onmouseenter",dojo.hitch(this,function(e){
dojo.disconnect(this._listen);
})));
},addEditAction:function(_ac){
this._lastEditActions.push(_ac);
},removeEditAction:function(_ad){
for(index in this._lastEditActions){
if((_ad.row!=undefined)&&(_ad.column!=undefined)){
if((this._lastEditActions[index].row==_ad.row)&&(this._lastEditActions[index].column==_ad.column)){
this._lastEditActions.splice(index,1);
}
}else{
if(_ad.row!=undefined){
if(this._lastEditActions[index].row==_ad.row){
this._lastEditActions.splice(index,1);
}
}
}
}
},isExistEditAction:function(_ae){
for(index in this._lastEditActions){
if((this._lastEditActions[index].row==_ae.row)&&(this._lastEditActions[index].column==_ae.column)){
return true;
}
}
return false;
},manipulateData:function(){
var _af=this._serverData.constants;
var _b0=this._serverData.messages;
if(this._pageData){
var _b1=0;
for(segment in this._pageData){
if(!this._pageData[segment].daylyUniques){
this._pageData[segment].daylyUniques=0;
}
if(this._pageData[segment].daylyUniques>_b1){
_b1=this._pageData[segment].daylyUniques;
}
}
for(segment in this._pageData){
this._pageData[segment].segmentBarWidth=(this._pageData[segment].daylyUniques/_b1)*this._segmentContainerWidth;
this._pageData[segment].resetRate=false;
if(this._pageData[segment].demandIndex){
if(this._pageData[segment].demandIndex==0){
this._pageData[segment].demandLevel=0;
this._pageData[segment].demandLevelIcon="";
}else{
if((this._pageData[segment].demandIndex>=1)&&(this._pageData[segment].demandIndex<=2)){
this._pageData[segment].demandLevel=1;
this._pageData[segment].demandLevelIcon=_af["SegMng_Const_IconBottomDemand"];
}else{
if((this._pageData[segment].demandIndex>=3)&&(this._pageData[segment].demandIndex<=5)){
this._pageData[segment].demandLevel=2;
this._pageData[segment].demandLevelIcon=_af["SegMng_Const_IconSecondDemand"];
}else{
if((this._pageData[segment].demandIndex>=6)&&(this._pageData[segment].demandIndex<=8)){
this._pageData[segment].demandLevel=3;
this._pageData[segment].demandLevelIcon=_af["SegMng_Const_IconThirdDemand"];
}else{
if((this._pageData[segment].demandIndex>=9)&&(this._pageData[segment].demandIndex<=10)){
this._pageData[segment].demandLevel=4;
this._pageData[segment].demandLevelIcon=_af["SegMng_Const_IconTopDemand"];
}
}
}
}
}
}
if(this._pageData[segment].activeDeals){
if(this._pageData[segment].activeDeals!=1){
this._pageData[segment].activeDealsText=this._pageData[segment].activeDeals+" "+_b0["SegMng_Grid_Column_Content_Demand_Multi"];
}else{
this._pageData[segment].activeDealsText=this._pageData[segment].activeDeals+" "+_b0["SegMng_Grid_Column_Content_Demand_Single"];
}
}else{
this._pageData[segment].activeDealsText="";
}
if(this._pageData[segment].daylyUniques){
this._pageData[segment].dailyUniquesText=dojo.number.format(this._pageData[segment].daylyUniques);
}else{
this._pageData[segment].dailyUniquesText="";
}
}
}
},countUnpublishedSegments:function(){
var _b2=0;
this.recursiveTreeWalk(this._tree,dojo.hitch(this,function(v){
if(v.draftUsed==true){
_b2++;
}
return true;
}));
return _b2;
},convertDataToTree:function(){
var _b3=[];
if(this._pageData){
for(segment in this._pageData){
var _b4=this._pageData[segment].parentSegment;
if(!_b3[_b4]){
_b3[_b4]=[];
}
_b3[_b4].push(this._pageData[segment]);
}
var _b5=function(a,b){
return a.segmentShortName.toLowerCase().localeCompare(b.segmentShortName.toLowerCase());
};
var _b6=function(_b7,_b8,_b9){
var fn=arguments.callee;
dojo.forEach(_b7,function(v){
v.level=_b8;
var _ba=_b3[v.segmentCode];
if(_ba){
if(isInArray(v.segmentCode,_b9)){
v.expanded=true;
}else{
v.expanded=false;
}
v.children=_ba;
v.children.sort(_b5);
fn(_ba,_b8+1,_b9);
}else{
v.children=[];
v.expanded=undefined;
}
});
};
if(_b3[0]){
this._tree=_b3[0];
this._tree.sort(_b5);
}else{
this._tree=[];
}
_b6(this._tree,0,this._expansionState);
}
},createGridStoreFromTree:function(_bb){
if(this._tree){
var _bc=[];
var _bd=function(_be){
var _bf=arguments.callee;
dojo.forEach(_be,function(v){
var ch=v.children;
delete v.children;
_bc.push(v);
if(ch&&ch.length>0&&v.expanded==true){
_bf(ch);
}
});
};
_bd(dojo.clone(this._tree));
if(_bb){
this._gridStore=new dojo.data.ItemFileWriteStore({clearOnClose:true,data:{identifier:"segmentCode",items:_bc}});
}else{
return {identifier:"segmentCode",items:_bc};
}
}
},createGridStructure:function(){
var _c0=this._serverData.messages;
var _c1;
if(dojo.isChrome){
_c1="30px";
}else{
_c1="20px";
}
this._gridStructure=[{defaultCell:{styles:"white-space:nowrap;",headerStyles:"text-align:center;cursor:pointer;",noresize:true},cells:[{name:"resetRate",field:"resetRate",hidden:true},{name:"activeDeals",field:"activeDeals",hidden:true},{name:"daylyUniques",field:"daylyUniques",hidden:true},{name:"demandIndex",field:"demandIndex",hidden:true},{name:"draftUsed",field:"draftUsed",hidden:true},{name:"inheritedRateIndication",field:"inheritedRateIndication",hidden:true},{name:"notes",field:"notes",hidden:true},{name:"parentSegment",field:"parentSegment",hidden:true},{name:"priceDecrease",field:"priceDecrease",hidden:true},{name:"priceIncrease",field:"priceIncrease",hidden:true},{name:"segmentCode",field:"segmentCode",hidden:true},{name:"segmentDisplayCode",field:"segmentDisplayCode",hidden:true},{name:"segmentName",field:"segmentName",hidden:true},{name:"segmentType",field:"segmentType",hidden:true},{name:"segmentBarWidth",field:"segmentBarWidth",hidden:true},{name:"demandLevel",field:"demandLevel",hidden:true},{name:"demandLevelIcon",field:"demandLevelIcon",hidden:true},{name:"activeDealsText",field:"activeDealsText",hidden:true},{name:"dailyUniquesText",field:"dailyUniquesText",hidden:true},{name:"level",field:"level",hidden:true},{name:"expanded",field:"expanded",hidden:true},{name:_c0["SegMng_Grid_Column_Header_Segment"],field:"segmentShortName",noresize:true,formatter:dojo.hitch(this,"columnFormatterSegment"),editable:true,type:dojox.grid.cells._Widget,widgetClass:"dijit.form.TextBox",width:"280px",cellStyles:"border-right-style: none;",headerStyles:"border-right-style: none; text-indent: 220px;",extraField:"shortName"},{noresize:true,formatter:dojo.hitch(this,"columnFormatterRename"),width:"13px",cellStyles:"border-right-style: none; border-left-style: none;",headerStyles:"border-right-style: none; border-left-style: none;",hidden:!(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentRename")),extraField:"rename"},{name:" ",noresize:true,field:"uniquesCPMRate",formatter:dojo.hitch(this,"columnFormatterRate"),editable:true,type:dojox.grid.cells._Widget,widgetClass:"dijit.form.NumberTextBox",width:"55px",cellStyles:"border-right-style: none; border-left-style: none;",headerStyles:"border-right-style: none; border-left-style: none;",extraField:"rate"},{name:" ",noresize:true,field:"active",formatter:dojo.hitch(this,"columnFormatterActivityIndication"),width:"20px",cellStyles:"border-right-style: none; border-left-style: none;",headerStyles:"border-right-style: none; border-left-style: none;",extraField:"active"},{name:" ",noresize:true,field:"newSegment",formatter:dojo.hitch(this,"columnFormatterNewIndication"),width:"20px",cellStyles:"border-right-style: none; border-left-style: none;",headerStyles:"border-right-style: none; border-left-style: none;",extraField:"newSegment"},{noresize:true,formatter:dojo.hitch(this,"columnFormatterPriceIndication"),width:"20px",cellStyles:"border-right-style: none; border-left-style: none;",headerStyles:"border-right-style: none; border-left-style: none;",extraField:"priceIndication"},{name:" ",noresize:true,formatter:dojo.hitch(this,"columnFormatterAdminBuy"),field:"adminBuyOnly",width:_c1,cellStyles:"border-left-style: none;",headerStyles:"border-left-style: none;",extraField:"adminBuyOnly"},{name:_c0["SegMng_Grid_Column_Header_UniqueUsers"],noresize:true,formatter:dojo.hitch(this,"columnFormatterUniqueUsers"),width:"250px"},{name:_c0["SegMng_Grid_Column_Header_Demand"],noresize:true,width:"100%"}]}];
},hasPermissions:function(_c2){
return this._serverData.permissions[_c2];
},columnFormatterRename:function(_c3,_c4){
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentRename")){
var _c5=this._serverData.messages["SegMng_TooltipRename"];
var _c6="";
_c6+="<div id=\"rename_"+_c4+"\" class=\"rename allowedIcon\" title=\""+_c5+"\">";
_c6+="&nbsp;";
_c6+="</div>";
return _c6;
}
},columnFormatterRate:function(_c7,_c8){
var _c9="";
var _ca="uniquesCPMRate ";
var _cb="";
if((_c7==null)||(_c7==undefined)||(isNaN(_c7))){
_c9="$?.??";
_ca+="novalue ";
_cb=this._serverData.messages["SegMng_SegmentRate_NotDefined"];
}else{
_c9=dojo.currency.format(_c7,{currency:"USD"});
var _cc=this.getGridValue(_c8,"inheritedRateIndication");
if(_cc==true){
_ca+="inherited ";
_cb=this._serverData.messages["SegMng_SegmentRate_Inherited"];
}else{
if(_cc==false){
_ca+="manual ";
_cb=this._serverData.messages["SegMng_SegmentRate_Manual"];
}
}
}
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentChangeRate")){
_ca+="allowedIcon";
}else{
_ca+="notAllowedIcon";
}
var _cd="";
_cd+="<div id=\"uniquesCPMRate_"+_c8+"\" class=\""+_ca+"\" title=\""+_cb+"\">";
_cd+=_c9;
_cd+="</div>";
return _cd;
},columnFormatterActivityIndication:function(_ce,_cf){
var _d0="active ";
var _d1="";
if(_ce==true){
_d0+="on ";
_d1=this._serverData.messages["SegMng_TooltipActive_On"];
}else{
_d0+="off ";
_d1=this._serverData.messages["SegMng_TooltipActive_Off"];
}
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentVisibleIndication")){
_d0+="allowedIcon";
}else{
_d0+="notAllowedIcon";
}
var _d2="";
_d2+="<div id=\"active_"+_cf+"\" class=\""+_d0+"\" title=\""+_d1+"\">";
_d2+="&nbsp;";
_d2+="</div>";
return _d2;
},columnFormatterNewIndication:function(_d3,_d4){
var _d5="newSegment ";
var _d6="";
if(_d3==true){
_d5+="on ";
_d6=this._serverData.messages["SegMng_TooltipNew_On"];
}else{
_d5+="off ";
_d6=this._serverData.messages["SegMng_TooltipNew_Off"];
}
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentNewIndication")){
_d5+="allowedIcon";
}else{
_d5+="notAllowedIcon";
}
var _d7="";
_d7+="<div id=\"newSegment_"+_d4+"\" class=\""+_d5+"\" title=\""+_d6+"\">";
_d7+="&nbsp;";
_d7+="</div>";
return _d7;
},columnFormatterPriceIndication:function(_d8,_d9){
var _da="priceIndication ";
var _db="";
var _dc=this.getGridValue(_d9,"priceIncrease");
var _dd=this.getGridValue(_d9,"priceDecrease");
if(_dc&&!_dd){
_da+="increase ";
_db=this._serverData.messages["SegMng_TooltipPriceIndicator_Increase"];
}else{
if(!_dc&&_dd){
_da+="decrease ";
_db=this._serverData.messages["SegMng_TooltipPriceIndicator_Decrease"];
}else{
_da+="off ";
_db=this._serverData.messages["SegMng_TooltipPriceIndicator_Off"];
}
}
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentPriceChangeIndication")){
_da+="allowedIcon";
}else{
_da+="notAllowedIcon";
}
var _de="";
_de+="<div id=\"priceIndication_"+_d9+"\" class=\""+_da+"\" title=\""+_db+"\">";
_de+="&nbsp;";
_de+="</div>";
return _de;
},columnFormatterAdminBuy:function(_df,_e0){
var _e1="adminBuyOnly ";
var _e2="";
if(_df==true){
_e1+="on ";
_e2=this._serverData.messages["SegMng_TooltipAdminBuy_On"];
}else{
_e1+="off ";
_e2=this._serverData.messages["SegMng_TooltipAdminBuy_Off"];
}
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentAdminBuyIndication")){
_e1+="allowedIcon";
}else{
_e1+="notAllowedIcon";
}
var _e3="";
_e3+="<div id=\"adminBuyOnly_"+_e0+"\" class=\""+_e1+"\" title=\""+_e2+"\">";
_e3+="&nbsp;";
_e3+="</div>";
return _e3;
},getGridValue:function(_e4,_e5){
return this._gridStore.getValue(this._grid.getItem(_e4),_e5);
},getCategoryObjectByCode:function(_e6){
for(category in this._serverData.segmentCategories){
if(_e6==this._serverData.segmentCategories[category]["categoryCode"]){
return this._serverData.segmentCategories[category];
}
}
},setGridValue:function(_e7,_e8,_e9){
this._gridStore.setValue(this._grid.getItem(_e7),_e8,_e9);
var _ea=this.getGridValue(_e7,"segmentCode");
this.recursiveTreeWalk(this._tree,dojo.hitch(this,function(v){
if(v.segmentCode==_ea){
v[_e8]=_e9;
return false;
}else{
return true;
}
}));
},columnFormatterSegment:function(_eb,_ec){
var _ed=this.getGridValue(_ec,"expanded");
var _ee=this.getGridValue(_ec,"draftUsed");
var _ef="";
var _f0="segment-name ";
if(_ed==undefined){
_f0+="leaf ";
}else{
if(_ed==false){
_f0+="collapsed ";
_ef=this._serverData.messages["SegMng_TooltipExpandLevel"];
}else{
if(_ed==true){
_f0+="expanded ";
_ef=this._serverData.messages["SegMng_TooltipCollapseLevel"];
}
}
}
if(_ee==true){
_f0+="draft ";
}
var _f1=15*this.getGridValue(_ec,"level");
var _f2="";
_f2+="<div id=\"tree_drawing_"+_ec+"\" style=\"margin-left: "+_f1+"px;\" class=\""+_f0+"\" title=\""+_ef+"\">";
_f2+="\t \t<span>";
_f2+=(_eb!=""?_eb:"&nbsp;");
_f2+="\t\t</span>";
_f2+="</div>";
return _f2;
},columnFormatterUniqueUsers:function(_f3,_f4){
var _f5=this.getGridValue(_f4,"segmentBarWidth");
var _f6=this.getGridValue(_f4,"dailyUniquesText");
retval="";
if(_f5){
retval+="<div class=\"segment-container\">";
retval+="\t<div class=\"segment-bar\" style=\"width:"+_f5+"px;\">";
retval+="\t\t&nbsp;";
retval+=" </div>";
retval+="</div>";
retval+="<div class=\"segment-text\">";
retval+=_f6;
retval+="</div>";
}
return retval;
},columnFormatterDemand:function(_f7,_f8){
var _f9=this.getGridValue(_f8,"activeDealsText");
var _fa=this.getGridValue(_f8,"demandLevelIcon");
var _fb="";
if(_f9!=""){
_fb+="<img src=\""+_fa+"\" class=\"demangGauge\">";
_fb+=_f9;
}
return _fb;
},createGrid:function(){
this._grid=new dojox.grid.DataGrid({loadingMessage:Px.Ex.Application.getWaitHtml(),store:this._gridStore,query:{segmentCode:"*"},queryOptions:{ignoreCase:true},clientSort:false,autoHeight:true,rowsPerPage:1000,selectionMode:"none",selectable:false,canSort:function(_fc){
return false;
},onStyleRow:dojo.hitch(this,"onGridStyleRow"),structure:this._gridStructure,singleClickEdit:true,canEdit:dojo.hitch(this,"onGridCanEdit")},dojo.byId("GridNode_"+this._categoryCode));
this._grid.startup();
this._grid._refresh();
this._connections.push(dojo.connect(this._grid,"onCellClick",dojo.hitch(this,"onGridCellClick")));
this._connections.push(dojo.connect(this._grid,"onStartEdit",dojo.hitch(this,"onGridStartEdit")));
this._connections.push(dojo.connect(this._grid,"onApplyCellEdit",dojo.hitch(this,"onGridApplyCellEdit")));
this._connections.push(dojo.connect(this._grid,"onCancelEdit",dojo.hitch(this,"onGridCancelEdit")));
this._connections.push(dojo.connect(this._grid,"onCellContextMenu",dojo.hitch(this,"onGridCellContextMenu")));
this.blurFunction();
},hasChildren:function(_fd){
var _fe=this.getGridValue(_fd,"expanded");
if(_fe==undefined){
return false;
}else{
return true;
}
},onGridCellContextMenu:function(e){
if(!this._isProcessing){
if(e.cell.field=="segmentShortName"){
if(this.hasPermissions("segmentEdit")){
if(!this._popupMenu){
this._popupMenu=new dijit.PopupMenuDialog({"class":"texi-popup-menu-dialog"});
}
var _ff=[{id:"add-level",title:this._serverData.messages["SegMng_Action_AddLevel"],tooltip:this._serverData.messages["SegMng_TooltipAddLevel"],enabled:true,shown:this.hasPermissions("segmentLevelCreate")},{id:"remove-level",title:this._serverData.messages["SegMng_Action_RemoveLevel"],tooltip:this._serverData.messages["SegMng_TooltipRemoveLevel"],enabled:!this.hasChildren(e.rowIndex),shown:(this.hasPermissions("segmentLevelRemove")&&(this.getGridValue(e.rowIndex,"segmentType")==2))},{id:"move",title:this._serverData.messages["SegMng_Action_Move"],tooltip:this._serverData.messages["SegMng_TooltipMove"],enabled:true,shown:this.hasPermissions("segmentMove")},{id:"set-permissions",title:this._serverData.messages["SegMng_Action_SetPermissions"],tooltip:this._serverData.messages["SegMng_TooltipSetPermissions"],enabled:true,shown:this.hasPermissions("segmentPermissionsSet")},{id:"set-priorities",title:this._serverData.messages["SegMng_Action_SetPriorities"],tooltip:this._serverData.messages["SegMng_TooltipSetPriorities"],enabled:true,shown:(this.hasPermissions("segmentPrioritiesSet")&&((this.getGridValue(e.rowIndex,"segmentType")==1)||(this.getGridValue(e.rowIndex,"segmentType")==3)))},{id:"reset-rate",title:this._serverData.messages["SegMng_Action_ResetRate"],tooltip:this._serverData.messages["SegMng_TooltipResetRate"],enabled:true,shown:this.hasPermissions("segmentRateReset")}];
var _100=dojo.create("ul",{className:"texi-popup-menu"});
this._popupMenuConnections=[];
dojo.forEach(_ff,function(v){
if(v.shown){
var li=dojo.create("li",{innerHTML:v.title,id:v.id,className:v.enabled?"":"grayed",title:v.tooltip},_100);
if(v.enabled){
this._popupMenuConnections.push(dojo.connect(li,"onmouseenter",this,function(e){
dojo.addClass(li,"active");
}));
this._popupMenuConnections.push(dojo.connect(li,"onmouseleave",this,function(e){
dojo.removeClass(li,"active");
}));
this._popupMenuConnections.push(dojo.connect(li,"onclick",this,dojo.hitch(this,"onPopupMenuItemClick",e.rowIndex)));
}
}
},this);
this._popupMenu.startup();
this._popupMenu.attr("content",_100);
this._popupMenu.connect(this._popupMenu,"onClose",dojo.hitch(this,function(){
dojo.forEach(this._popupMenuConnections,dojo.disconnect,this);
delete this._popupMenuConnections;
this._popupMenu.close();
}));
this._popupMenu._openMyself(e);
}
}
}
},onPopupMenuItemClick:function(_101,e){
var _102=e.target.id;
this._popupMenu.close();
dojo.removeClass(e.target,"active");
switch(_102){
case "add-level":
this.onSegmentAddLevel(_101);
break;
case "remove-level":
this.onSegmentRemoveLevel(_101);
break;
case "move":
this.onSegmentMove(_101);
break;
case "set-permissions":
this.onSegmentSetPermissions(_101);
break;
case "set-priorities":
this.onSegmentSetPriorities(_101);
break;
case "reset-rate":
this.onSegmentResetRate(_101);
break;
}
},onSegmentAddLevel:function(_103){
var dlg=new Px.Ex.SegMngAddLevelDialog({segmentCode:this.getGridValue(_103,"segmentCode"),segmentResetRate:this.getGridValue(_103,"resetRate"),segmentFullName:this.getGridValue(_103,"segmentName"),segmentShortName:this.getGridValue(_103,"segmentShortName"),segmentNotes:(this.getGridValue(_103,"notes")==null)||(this.getGridValue(_103,"notes")=="")?" ":this.getGridValue(_103,"notes"),parentSegmentCode:this.getGridValue(_103,"parentSegment"),categoryCode:this._categoryCode,parentObject:this});
dlg.show();
},onSegmentRemoveLevel:function(_104){
var _105=null;
var _106=null;
var _107=null;
var _108=null;
var _109=null;
var _10a=false;
var _10b=this.getGridValue(_104,"resetRate");
var _10c=this.getGridValue(_104,"segmentCode");
var _10d=this.getGridValue(_104,"segmentName")?this.getGridValue(_104,"segmentName"):"";
var _10e=this.getGridValue(_104,"notes")?this.getGridValue(_104,"notes"):" ";
var _10f=null;
var _110=this.getGridValue(_104,"segmentShortName")?this.getGridValue(_104,"segmentShortName"):"";
var _111=null;
this.saveSegmentToDraft(_105,_106,_107,_108,_109,_10a,_10b,_10c,_10d,_10e,_10f,_110,_111,_104,dojo.hitch(this,"onSegmentRemoveLevelSuccess"),dojo.hitch(this,"onSegmentRemoveLevelFailure"));
},onSegmentRemoveLevelSuccess:function(data){
this.forceRefresh(dojo.hitch(this,function(){
this._isDirty=true;
}));
},onSegmentRemoveLevelFailure:function(data){
},onSegmentMove:function(_112){
var _113=this.getGridValue(_112,"segmentCode");
var _114=this.getGridValue(_112,"segmentShortName");
var dlg=new Px.Ex.SegMngMoveDialog({parentObject:this,currentSegmentCode:_113,currentSegmentRowIndex:_112,currentSegmentName:_114,currentCategoryCode:this._categoryCode,currentCategoryName:this._parentObject.getCategoryObjectByCode(this._categoryCode)["categoryName"],tree:dojo.clone(this._tree)});
dlg.show();
},onSegmentSetPermissions:function(_115){
},onSegmentSetPriorities:function(_116){
var _117=this.getGridValue(_116,"segmentCode");
var _118=this.getGridValue(_116,"segmentShortName");
var dlg=new Px.Ex.SegMngSetPrioritiesDialog({parentObject:this,messages:this._serverData.messages,currentSegmentCode:_117,currentSegmentName:_118,currentCategoryCode:this._categoryCode});
dlg.show();
},onSegmentResetRate:function(_119){
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentRateReset")){
var _11a=null;
var _11b=null;
var _11c=null;
var _11d=null;
var _11e=null;
var _11f=null;
var _120=true;
var _121=this.getGridValue(_119,"segmentCode");
var _122=this.getGridValue(_119,"segmentName")?this.getGridValue(_119,"segmentName"):"";
var _123=this.getGridValue(_119,"notes")?this.getGridValue(_119,"notes"):" ";
var _124=null;
var _125=this.getGridValue(_119,"segmentShortName")?this.getGridValue(_119,"segmentShortName"):"";
var _126=null;
this.saveSegmentToDraft(_11a,_11b,_11c,_11d,_11e,_11f,_120,_121,_122,_123,_124,_125,_126,_119,dojo.hitch(this,"onSegmentResetRateSuccess"),dojo.hitch(this,"onSegmentResetRateFailure"));
}
},onSegmentResetRateSuccess:function(data){
this.setGridValue(data.param,"resetRate",true);
},onSegmentResetRateFailure:function(data){
},onGridCancelEdit:function(_127){
this.removeEditAction({row:_127});
this._isProcessing=false;
},onGridStyleRow:function(_128){
},onGridApplyCellEdit:function(_129,_12a,_12b){
this.removeEditAction({row:_12a,column:_12b});
switch(_12b){
case "segmentShortName":
if(_129!=""){
if(_129!=this._tempValue){
var _12c=null;
var _12d=null;
var _12e=null;
var _12f=null;
var _130=null;
var _131=null;
var _132=this.getGridValue(_12a,"resetRate");
var _133=this.getGridValue(_12a,"segmentCode");
var _134=this.getGridValue(_12a,"segmentName")?this.getGridValue(_12a,"segmentName"):"";
var _135=this.getGridValue(_12a,"notes")?this.getGridValue(_12a,"notes"):" ";
var _136=null;
var _137=_129;
var _138=null;
this.saveSegmentToDraft(_12c,_12d,_12e,_12f,_130,_131,_132,_133,_134,_135,_136,_137,_138,_12a,dojo.hitch(this,"onSegmentRenameSuccess"),dojo.hitch(this,"onSegmentRenameFailure"));
}else{
this._isProcessing=false;
}
}else{
this.setGridValue(_12a,"segmentShortName",this._tempValue);
this._isProcessing=false;
}
break;
case "uniquesCPMRate":
if(!isNaN(_129)){
if((_129!=this._tempValue)||(this.getGridValue(_12a,"inheritedRateIndication")&&(_129==this._tempValue))){
var _12c=null;
var _12d=null;
var _12e=null;
var _12f=null;
var _130=null;
var _131=null;
var _132=this.getGridValue(_12a,"resetRate");
var _133=this.getGridValue(_12a,"segmentCode");
var _134=this.getGridValue(_12a,"segmentName")?this.getGridValue(_12a,"segmentName"):"";
var _135=this.getGridValue(_12a,"notes")?this.getGridValue(_12a,"notes"):" ";
var _136=null;
var _137=this.getGridValue(_12a,"segmentShortName")?this.getGridValue(_12a,"segmentShortName"):"";
var _138=this.getGridValue(_12a,"uniquesCPMRate");
this.saveSegmentToDraft(_12c,_12d,_12e,_12f,_130,_131,_132,_133,_134,_135,_136,_137,_138,_12a,dojo.hitch(this,"onSegmentRateSuccess"),dojo.hitch(this,"onSegmentRateFailure"));
}else{
this._isProcessing=false;
}
}else{
this.setGridValue(_12a,"uniquesCPMRate",this._tempValue);
this._isProcessing=false;
}
break;
}
},onSegmentRenameSuccess:function(data){
var _139=this.getGridValue(data.param,"segmentShortName");
this.setGridValue(data.param,"segmentShortName",_139);
},onSegmentRenameFailure:function(data){
},onSegmentRateSuccess:function(data){
var _13a=this.getGridValue(data.param,"uniquesCPMRate");
if(isNaN(_13a)){
this.setGridValue(data.param,"uniquesCPMRate",null);
}else{
this.setGridValue(data.param,"uniquesCPMRate",_13a);
}
this.setGridValue(data.param,"inheritedRateIndication",false);
if(this.shouldRefreshSubTree(data.param)){
this.refreshSubTree(data.param);
}
},onSegmentRateFailure:function(data){
this.setGridValue(data.param,"uniquesCPMRate",this._tempValue);
},onGridStartEdit:function(_13b,_13c){
if(_13b._props["field"]=="uniquesCPMRate"){
this._isProcessing=true;
}
try{
this._tempValue=this.getGridValue(_13c,_13b._props["field"]);
}
catch(e){
this._tempValue=null;
this._isProcessing=false;
}
},onGridCanEdit:function(_13d,_13e){
switch(_13d.extraField){
case "rate":
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentChangeRate")){
return true;
}
break;
case "shortName":
if(this.isExistEditAction({row:_13e,column:"segmentShortName"})){
this.removeEditAction({row:_13e,column:"segmentShortName"});
return true;
}else{
return false;
}
break;
case "rename":
if(!this.isExistEditAction({row:_13e,column:"segmentShortName"})){
this.addEditAction({row:_13e,column:"segmentShortName"});
return true;
}else{
return false;
}
break;
}
},onGridCellClick:function(e){
if(!this._isProcessing){
var _13f=e.target.className;
if((e.cell.extraField=="rename")&&(_13f.indexOf("rename")>=0)){
this._isProcessing=true;
this.onSegmentRename(e);
}else{
if((e.cell.extraField=="active")&&(_13f.indexOf("active")>=0)){
this._isProcessing=true;
this.onSegmentActive(e);
}else{
if((e.cell.extraField=="newSegment")&&(_13f.indexOf("newSegment")>=0)){
this._isProcessing=true;
this.onSegmentNew(e);
}else{
if((e.cell.extraField=="priceIndication")&&(_13f.indexOf("priceIndication")>=0)){
this._isProcessing=true;
this.onSegmentPriceIndication(e);
}else{
if((e.cell.extraField=="adminBuyOnly")&&(_13f.indexOf("adminBuyOnly")>=0)){
this._isProcessing=true;
this.onSegmentAdminBuyOnly(e);
}else{
if(e.cell.extraField=="shortName"){
if(e.target.className.indexOf("collapsed")>0){
this.onGridSegmentExpand(e,true);
}else{
if(e.target.className.indexOf("expanded")>0){
this.onGridSegmentExpand(e,false);
}
}
}
}
}
}
}
}
}
},onGridSegmentExpand:function(e,_140){
if(!this._isProcessing){
this._isProcessing=true;
var _141=this.getGridValue(e.rowIndex,"segmentCode");
this.recursiveTreeWalk(this._tree,dojo.hitch(this,function(v){
if(v.segmentCode==_141){
if(_140){
this._expansionState.push(v.segmentCode);
}else{
removeFromArray(v.segmentCode,this._expansionState);
}
this._parentObject.setCookieExpansionState(this._categoryCode,this._expansionState);
v.expanded=_140;
return false;
}else{
return true;
}
}));
this.updateGridWithoutRefresh(e);
this._isProcessing=false;
}
},onSegmentRename:function(e){
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentRename")){
this._grid.edit.start(this._grid.getCell(21),e.rowIndex,true);
}
},onSegmentActive:function(e){
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentVisibleIndication")){
var _142=!this.getGridValue(e.rowIndex,"active");
var _143=null;
var _144=null;
var _145=null;
var _146=null;
var _147=null;
var _148=this.getGridValue(e.rowIndex,"resetRate");
var _149=this.getGridValue(e.rowIndex,"segmentCode");
var _14a=this.getGridValue(e.rowIndex,"segmentName")?this.getGridValue(e.rowIndex,"segmentName"):"";
var _14b=this.getGridValue(e.rowIndex,"notes")?this.getGridValue(e.rowIndex,"notes"):" ";
var _14c=null;
var _14d=this.getGridValue(e.rowIndex,"segmentShortName")?this.getGridValue(e.rowIndex,"segmentShortName"):"";
var _14e=null;
this.saveSegmentToDraft(_142,_143,_144,_145,_146,_147,_148,_149,_14a,_14b,_14c,_14d,_14e,e,dojo.hitch(this,"onSegmentActiveSuccess"),dojo.hitch(this,"onSegmentActiveFailure"));
}
},onSegmentActiveSuccess:function(data){
if(data.param){
if(this.getGridValue(data.param.rowIndex,"active")==true){
this.setGridValue(data.param.rowIndex,"active",false);
}else{
this.setGridValue(data.param.rowIndex,"active",true);
}
}
},onSegmentActiveFailure:function(data){
},onSegmentNew:function(e){
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentNewIndication")){
var _14f=null;
var _150=!this.getGridValue(e.rowIndex,"newSegment");
var _151=null;
var _152=null;
var _153=null;
var _154=null;
var _155=this.getGridValue(e.rowIndex,"resetRate");
var _156=this.getGridValue(e.rowIndex,"segmentCode");
var _157=this.getGridValue(e.rowIndex,"segmentName")?this.getGridValue(e.rowIndex,"segmentName"):"";
var _158=this.getGridValue(e.rowIndex,"notes")?this.getGridValue(e.rowIndex,"notes"):" ";
var _159=null;
var _15a=this.getGridValue(e.rowIndex,"segmentShortName")?this.getGridValue(e.rowIndex,"segmentShortName"):"";
var _15b=null;
this.saveSegmentToDraft(_14f,_150,_151,_152,_153,_154,_155,_156,_157,_158,_159,_15a,_15b,e,dojo.hitch(this,"onSegmentNewSuccess"),dojo.hitch(this,"onSegmentNewFailure"));
}
},onSegmentNewSuccess:function(data){
if(data.param){
if(this.getGridValue(data.param.rowIndex,"newSegment")==true){
this.setGridValue(data.param.rowIndex,"newSegment",false);
}else{
this.setGridValue(data.param.rowIndex,"newSegment",true);
}
}
},onSegmentNewFailure:function(data){
},onSegmentPriceIndication:function(e){
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentPriceChangeIndication")){
var _15c=this.getGridValue(e.rowIndex,"priceIncrease");
var _15d=this.getGridValue(e.rowIndex,"priceDecrease");
var _15e=null;
var _15f=null;
var _160=null;
var _161=null;
var _162=null;
var _163=null;
var _164=this.getGridValue(e.rowIndex,"resetRate");
var _165=this.getGridValue(e.rowIndex,"segmentCode");
var _166=this.getGridValue(e.rowIndex,"segmentName")?this.getGridValue(e.rowIndex,"segmentName"):"";
var _167=this.getGridValue(e.rowIndex,"notes")?this.getGridValue(e.rowIndex,"notes"):" ";
var _168=null;
var _169=this.getGridValue(e.rowIndex,"segmentShortName")?this.getGridValue(e.rowIndex,"segmentShortName"):"";
var _16a=null;
if(!_15c&&!_15d){
_160=false;
_161=true;
}else{
if(_15c&&!_15d){
_160=true;
_161=false;
}else{
if(!_15c&&_15d){
_160=false;
_161=false;
}
}
}
this.saveSegmentToDraft(_15e,_15f,_160,_161,_162,_163,_164,_165,_166,_167,_168,_169,_16a,e,dojo.hitch(this,"onSegmentPriceIndicationSuccess"),dojo.hitch(this,"onSegmentPriceIndicationFailure"));
}
},onSegmentPriceIndicationSuccess:function(data){
if(data.param){
var _16b=this.getGridValue(data.param.rowIndex,"priceIncrease");
var _16c=this.getGridValue(data.param.rowIndex,"priceDecrease");
if(!_16b&&!_16c){
this.setGridValue(data.param.rowIndex,"priceIncrease",true);
this.setGridValue(data.param.rowIndex,"priceDecrease",false);
}else{
if(_16b&&!_16c){
this.setGridValue(data.param.rowIndex,"priceIncrease",false);
this.setGridValue(data.param.rowIndex,"priceDecrease",true);
}else{
if(!_16b&&_16c){
this.setGridValue(data.param.rowIndex,"priceIncrease",false);
this.setGridValue(data.param.rowIndex,"priceDecrease",false);
}
}
}
}
},onSegmentPriceIndicationFailure:function(data){
},onSegmentAdminBuyOnly:function(e){
if(this.hasPermissions("segmentEdit")&&this.hasPermissions("segmentAdminBuyIndication")){
var _16d=null;
var _16e=null;
var _16f=null;
var _170=null;
var _171=!this.getGridValue(e.rowIndex,"adminBuyOnly");
var _172=null;
var _173=this.getGridValue(e.rowIndex,"resetRate");
var _174=this.getGridValue(e.rowIndex,"segmentCode");
var _175=this.getGridValue(e.rowIndex,"segmentName")?this.getGridValue(e.rowIndex,"segmentName"):"";
var _176=this.getGridValue(e.rowIndex,"notes")?this.getGridValue(e.rowIndex,"notes"):" ";
var _177=null;
var _178=this.getGridValue(e.rowIndex,"segmentShortName")?this.getGridValue(e.rowIndex,"segmentShortName"):"";
var _179=null;
this.saveSegmentToDraft(_16d,_16e,_16f,_170,_171,_172,_173,_174,_175,_176,_177,_178,_179,e,dojo.hitch(this,"onSegmentAdminBuyOnlySuccess"),dojo.hitch(this,"onSegmentAdminBuyOnlyFailure"));
}
},onSegmentAdminBuyOnlySuccess:function(data){
if(data.param){
if(this.getGridValue(data.param.rowIndex,"adminBuyOnly")==true){
this.setGridValue(data.param.rowIndex,"adminBuyOnly",false);
}else{
this.setGridValue(data.param.rowIndex,"adminBuyOnly",true);
}
}
},onSegmentAdminBuyOnlyFailure:function(data){
},createPageLayout:function(){
var _17a,_17b,tr,td,div;
_17a=dojo.create("table",{className:"grid-layout"});
_17b=dojo.create("tbody",{},_17a);
tr=dojo.create("tr",{},_17b);
td=dojo.create("td",{style:{verticalAlign:"top"}},tr);
this._gridEar=dojo.create("div",{className:"grid-ear",title:this._serverData.messages["SegMng_TooltipExpandAll"]},td);
this._connections.push(this.connect(this._gridEar,"onclick","onTreeExpand"));
td=dojo.create("td",{style:{verticalAlign:"top",width:"100%"}},tr);
div=dojo.create("div",{id:"GridNode_"+this._categoryCode},td);
this.attr("content",_17a);
},recursiveTreeWalk:function(tree,_17c){
var _17d=dojo.hitch(this,function(_17e){
var func=arguments.callee;
for(var _17f in _17e){
var item=_17e[_17f];
if(_17c(item)){
if((item.children)&&(item.children.length>0)){
func(item.children);
}
}else{
break;
}
}
});
_17d(tree);
},getTreeNode:function(_180){
var _181=this.getGridValue(_180,"segmentCode");
return this.getTreeNodeBySegmentCode(_181);
},getTreeNodeBySegmentCode:function(_182){
var _183=null;
this.recursiveTreeWalk(this._tree,dojo.hitch(this,function(v){
if(v.segmentCode==_182){
_183=v;
return false;
}else{
return true;
}
}));
return _183;
},onTreeExpand:function(e){
if(!this._isProcessing){
this._isProcessing=true;
var _184=true;
if(e.target.className.indexOf("collapse")>0){
_184=false;
}
this._expansionState=[];
this.recursiveTreeWalk(this._tree,dojo.hitch(this,function(v){
if(v.children&&v.children.length>0){
v.expanded=_184;
if(_184){
this._expansionState.push(v.segmentCode);
}
}
return true;
}));
this._parentObject.setCookieExpansionState(this._categoryCode,this._expansionState);
this.updateGridWithoutRefresh(e);
dojo.toggleClass(this._gridEar,"collapse",_184);
if(_184){
dojo.attr(this._gridEar,"title",this._serverData.messages["SegMng_TooltipCollapseAll"]);
}else{
dojo.attr(this._gridEar,"title",this._serverData.messages["SegMng_TooltipExpandAll"]);
}
this._isProcessing=false;
}
},startup:function(){
this.inherited(arguments);
this.forceRefresh();
},selfDraw:function(){
if(this._pageData){
this.manipulateData();
this.convertDataToTree();
this.updateIsDirtyState();
this.createGridStoreFromTree(true);
this.createGridStructure();
this.createGrid();
}
},updateIsDirtyState:function(){
if(this.countUnpublishedSegments()>0){
this._isDirty=true;
}else{
this._isDirty=false;
}
},updateGridWithoutRefresh:function(e){
try{
this._gridStore.revert();
this._gridStore.close();
this._gridStore._jsonData=this.createGridStoreFromTree(false);
this._gridStore.fetch();
this._grid._refresh.call(this._grid,true);
}
catch(e){
}
},saveSegmentToDraft:function(_185,_186,_187,_188,_189,_18a,_18b,_18c,_18d,_18e,_18f,_190,_191,_192,_193,_194){
this.xhr({url:"/branded-tabs/segments-management-save-segment-to-draft",content:{active:this.returnXhrBool(_185),newSegment:this.returnXhrBool(_186),priceDecrease:this.returnXhrBool(_187),priceIncrease:this.returnXhrBool(_188),adminBuyOnly:this.returnXhrBool(_189),showOnSelectionList:this.returnXhrBool(_18a),resetRate:this.returnXhrBool(_18b),segmentCode:_18c,segmentFullName:_18d,segmentNotes:_18e,segmentParentID:_18f,segmentShortName:_190,uniquesCPMRate:_191},load:dojo.hitch(this,"onSaveSegmentSuccess",_192,_193),error:dojo.hitch(this,"onSaveSegmentFailure",_192,_194),handleAs:"json"});
},activate:function(){
if(!this._activated){
var _195=this._parentObject.getCategoryObjectByCode(this._categoryCode)["categoryName"];
this.doActionUnderCondition(dojo.hitch(this,function(){
if(this._tree){
return true;
}else{
return false;
}
}),dojo.hitch(this,function(){
this._activated=true;
var _196=this.countUnpublishedSegments();
var _197="";
if(_196>0){
_197=this._serverData.messages["SegMng_LastSaveMessageUnpublishedChanges"];
_197=dojo.string.substitute(_197,[_196,_195]);
}else{
_197=this._serverData.messages["SegMng_LastSaveMessageNoUnpublishedChanges"];
_197=dojo.string.substitute(_197,[_195]);
}
this._parentObject.WriteMessageAtBottom(_197);
}),500,20);
}else{
this._parentObject.WriteMessageAtBottom("");
}
},doActionUnderCondition:function(_198,_199,_19a,_19b){
var _19c=_198();
var _19d=(_19a?_19a:500);
var _19e=(_19b?_19b:0);
if(_19c==true){
if(this._interval){
clearInterval(this._interval);
try{
delete this._interval;
delete this._intervalCounter;
}
catch(e){
}
}
_199();
}else{
if(!this._intervalCounter){
this._intervalCounter=0;
}
this._intervalCounter++;
if(this._intervalCounter==_19e){
if(this._interval){
clearInterval(this._interval);
try{
delete this._interval;
delete this._intervalCounter;
}
catch(e){
}
}
}else{
if(!this._interval){
this._interval=setInterval(dojo.hitch(this,"doActionUnderCondition",_198,_199,_19a,_19e),_19d);
}
}
}
},shouldRefreshSubTree:function(_19f){
var _1a0=this.getTreeNode(_19f);
var _1a1=false;
if(_1a0){
var _1a2=[];
_1a2.push(_1a0);
this.recursiveTreeWalk(_1a2,dojo.hitch(this,function(v){
if((v.segmentCode!=_1a0.segmentCode)&&((v.inheritedRateIndication)||(v.uniquesCPMRate==null))){
_1a1=true;
return false;
}else{
return true;
}
}));
}
return _1a1;
},getSubTreeSegmentCodes:function(_1a3){
var _1a4=this.getTreeNode(_1a3);
var _1a5=[];
if(_1a4){
var _1a6=[];
_1a6.push(_1a4);
this.recursiveTreeWalk(_1a6,dojo.hitch(this,function(v){
_1a5.push(v.segmentCode);
return true;
}));
}
return _1a5;
},refreshSubTree:function(_1a7){
var _1a8=this.getSubTreeSegmentCodes(_1a7);
this.xhr({url:"/branded-tabs/segments-management-get-category-content",content:{categoryCode:this._categoryCode},load:dojo.hitch(this,"onRefreshSubTreeSuccess",_1a8),error:dojo.hitch(this,"onRefreshSubTreeFailure",_1a8),handleAs:"json"});
},onRefreshSubTreeSuccess:function(_1a9,data){
if(data&&data["faultstring"]){
this.onRefreshSubTreeFailure(_1a9,data);
}else{
for(index in data){
if(isInArray(data[index].segmentCode,_1a9)){
this.updateGridStoreRow(data[index].segmentCode,data[index]);
this.updateTreeRow(data[index].segmentCode,data[index]);
}
}
}
},updateGridStoreRow:function(_1aa,_1ab){
var _1ac=this._gridStore._itemsByIdentity[_1aa];
if(_1ac!=null){
_1ac.active[0]=_1ab.active;
_1ac.activeDeals[0]=_1ab.activeDeals;
_1ac.adminBuyOnly[0]=_1ab.adminBuyOnly;
_1ac.daylyUniques[0]=_1ab.daylyUniques;
_1ac.demandIndex[0]=_1ab.demandIndex;
_1ac.draftUsed[0]=_1ab.draftUsed;
_1ac.inheritedRateIndication[0]=_1ab.inheritedRateIndication;
_1ac.newSegment[0]=_1ab.newSegment;
_1ac.notes[0]=_1ab.notes;
_1ac.parentSegment[0]=_1ab.parentSegment;
_1ac.priceDecrease[0]=_1ab.priceDecrease;
_1ac.priceIncrease[0]=_1ab.priceIncrease;
_1ac.segmentDisplayCode[0]=_1ab.segmentDisplayCode;
_1ac.segmentName[0]=_1ab.segmentName;
_1ac.segmentShortName[0]=_1ab.segmentShortName;
_1ac.segmentType[0]=_1ab.segmentType;
_1ac.showOnSelection[0]=_1ab.showOnSelection;
_1ac.uniquesCPMRate[0]=_1ab.uniquesCPMRate;
this._grid.updateRow(_1ac._0);
}
},updateTreeRow:function(_1ad,_1ae){
var _1af=this.getTreeNodeBySegmentCode(_1ad);
if(_1af!=null){
_1af.active=_1ae.active;
_1af.activeDeals=_1ae.activeDeals;
_1af.adminBuyOnly=_1ae.adminBuyOnly;
_1af.daylyUniques=_1ae.daylyUniques;
_1af.demandIndex=_1ae.demandIndex;
_1af.draftUsed=_1ae.draftUsed;
_1af.inheritedRateIndication=_1ae.inheritedRateIndication;
_1af.newSegment=_1ae.newSegment;
_1af.notes=_1ae.notes;
_1af.parentSegment=_1ae.parentSegment;
_1af.priceDecrease=_1ae.priceDecrease;
_1af.priceIncrease=_1ae.priceIncrease;
_1af.segmentDisplayCode=_1ae.segmentDisplayCode;
_1af.segmentName=_1ae.segmentName;
_1af.segmentShortName=_1ae.segmentShortName;
_1af.segmentType=_1ae.segmentType;
_1af.showOnSelection=_1ae.showOnSelection;
_1af.uniquesCPMRate=_1ae.uniquesCPMRate;
}
},onRefreshSubTreeFailure:function(_1b0,data){
this.refresh();
},refresh:function(){
if(this._hasCache){
var _1b1=(this._isDirty==true);
if(!this._isDirty){
this.forceRefresh();
}
return (_1b1);
}
},forceRefresh:function(_1b2){
this.attr("content",Px.Ex.Application.getWaitHtml());
this.xhr({url:"/branded-tabs/segments-management-get-category-content",content:{categoryCode:this._categoryCode},load:dojo.hitch(this,"onRefreshSuccess",_1b2),error:dojo.hitch(this,"onRefreshFailure",_1b2),handleAs:"json"});
},onRefreshSuccess:function(_1b3,data){
if(data&&data["faultstring"]){
this.onRefreshFailure(data);
}else{
this._pageData=dojo.filter(data,function(item){
return item.showOnSelection;
});
this.clear();
this.createPageLayout();
this.selfDraw();
this._hasCache=true;
if(_1b3){
_1b3();
}
}
},onRefreshFailure:function(_1b4,data){
if(_1b4){
_1b4();
}
},returnXhrBool:function(_1b5){
if((_1b5==null)||(_1b5==undefined)){
return null;
}else{
if(_1b5==true){
return 1;
}else{
return 0;
}
}
},onSaveSegmentSuccess:function(_1b6,_1b7,data){
data.param=_1b6;
if(data.success==true){
_1b7(data);
}else{
failureCallback(data);
}
this._isProcessing=false;
this._isDirty=true;
var _1b8=this._serverData.messages["SegMng_LastSaveMessage"];
_1b8=dojo.string.substitute(_1b8,[data.time,this._serverData.messages["SegMng_LastSaveMessage_Publish"]]);
this._parentObject.WriteMessageAtBottom(_1b8);
if(_1b6.rowIndex!=undefined){
this.setGridValue(_1b6.rowIndex,"draftUsed",true);
}else{
this.setGridValue(_1b6,"draftUsed",true);
}
},onSaveSegmentFailure:function(_1b9,_1ba,data){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_SegmentChange_Failure"]});
dlg.show();
data.param=_1b9;
_1ba(data);
this._isProcessing=false;
},clear:function(){
try{
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
}
delete this._connections;
}
catch(e){
}
try{
dojo.forEach(this._popupMenuConnections,dojo.disconnect,this);
delete this._popupMenuConnections;
}
catch(e){
}
try{
if(this._popupMenu){
this._popupMenu.close();
}
delete this._popupMenu;
}
catch(e){
}
try{
if(this._gridStore){
if(this._gridStore.isDirty){
this._gridStore.revert();
}
this._gridStore.close();
delete this._gridStore;
}
}
catch(e){
}
try{
if(this._grid){
this._grid.destroyRecursive();
}
delete this._grid;
}
catch(e){
}
},destroy:function(){
this.clear();
try{
this.inherited(arguments);
}
catch(e){
}
}});
dojo.declare("Px.Ex.SegMngMoveDialog",[Px.Ex.Dialog],{"class":"segment-move-segment-dialog",currentSegmentCode:undefined,currentSegmentRowIndex:undefined,currentSegmentName:undefined,currentCategoryName:undefined,currentCategoryCode:undefined,parentObject:undefined,previousParentSegmentCode:undefined,tree:undefined,selectedNodeId:undefined,_connections:[],constructor:function(conf){
dojo.mixin(this,conf);
this.rotationImage=Px.Ex.Application.getWaitImageUrl();
},startup:function(){
this.inherited(arguments);
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(this.parentObject._serverData.messages["SegMng_MoveDialogTitle"]);
this.attr("content",Px.Ex.Application.getWaitHtml());
this.createLayout();
this.createTree();
},createLayout:function(){
var _1bb=dojo.create("div",{});
var div=dojo.create("div",{},_1bb);
div.innerHTML=dojo.string.substitute(this.parentObject._serverData.messages["SegMng_MoveDialogMessage"],[this.currentSegmentName]);
var div=dojo.create("div",{id:"CategoryTree"},_1bb);
var _1bc=dojo.create("table",{},_1bb);
var _1bd=dojo.create("tbody",{},_1bc);
var tr=dojo.create("tr",{},_1bd);
var td=dojo.create("td",{},tr);
var div=dojo.create("div",{className:"SegMng MoveCancelButton"},td);
div.innerHTML="&nbsp;";
this.connect(div,"onclick","onCancel");
var div=dojo.create("div",{className:"SegMng MoveOKButton"},td);
div.innerHTML="&nbsp;";
this.connect(div,"onclick","onSave");
this.attr("content",_1bb);
},onSave:function(){
this.showRotation(true);
this.saveSegment(this.currentSegmentCode,this.selectedNodeId);
},onCancel:function(){
},createTree:function(){
var _1be=[];
var _1bf=-1;
var _1c0=dojo.hitch(this,function(_1c1,_1c2,_1c3){
var func=arguments.callee;
dojo.forEach(_1c1,dojo.hitch(this,function(v){
if((_1c2==0)&&(v.segmentCode==_1c3)){
_1bf=0;
}
var ch=v.children;
delete v.children;
if(!ch||ch.length<=0){
if(v.segmentCode!=_1c3){
_1be.push({id:v.segmentCode,name:v.segmentShortName,type:(_1c2==0)?"show":"hide"});
}
}else{
var _1c4=[];
var _1c5=-1;
dojo.forEach(ch,dojo.hitch(this,function(c){
if(c.segmentCode!=_1c3){
_1c4.push({_reference:c.segmentCode});
}else{
_1c5=v.segmentCode;
}
}));
if(_1c5!=-1){
_1bf=_1c5;
}
if(v.segmentCode!=_1c3){
_1be.push({id:v.segmentCode,name:v.segmentShortName,children:_1c4,type:(_1c2==0)?"show":"hide"});
}
}
if(v.segmentCode!=_1c3){
if(ch&&ch.length>0){
func(ch,_1c2+1,_1c3);
}
}
}));
});
_1c0(this.tree,0,this.currentSegmentCode);
delete this.tree;
this._store=new dojo.data.ItemFileReadStore({clearOnClose:true,data:{identifier:"id",label:"name",items:_1be}});
this._treeModel=new dijit.tree.ForestStoreModel({store:this._store,query:{"type":"show"},rootId:0,rootLabel:this.currentCategoryName,childrenAttrs:["children"]});
this._tree=new dijit.Tree({model:this._treeModel,"class":"CategoryTree"},"CategoryTree");
var _1c6=this.getItemFromNodeMap(0);
var _1c7=this.getItemFromNodeMap(_1bf);
_1c6.setSelected(false);
_1c7.setSelected(true);
this.selectedNode=_1c7;
while(this.getTreeNodeId(_1c7)!=0){
this._tree._expandNode(_1c7);
_1c7=this.getItemFromNodeMap(this.getTreeNodeId(_1c7.getParent()));
}
this._connections.push(dojo.connect(this._tree,"onClick",dojo.hitch(this,"onTreeNodeClick")));
},getItemFromNodeMap:function(id){
var _1c8=null;
var _1c9=dojo.hitch(this,"getTreeNodeId");
var tree=this._tree;
var _1ca=dojo.hitch(this,function(node,id){
var func=arguments.callee;
var _1cb=_1c9(node);
if(_1cb==id){
_1c8=node;
}else{
tree._expandNode(node);
var _1cc=node.getChildren();
if((_1cc)&&(_1cc.length>0)){
dojo.forEach(_1cc,dojo.hitch(this,function(v){
func(v,id);
}));
}
}
});
_1ca(this._tree._itemNodeMap[0],id);
return _1c8;
},getTreeNodeId:function(_1cd){
if(_1cd.item!=undefined){
if(_1cd.item.id[0]!=undefined){
return _1cd.item.id[0];
}else{
return _1cd.item.id;
}
}else{
if(_1cd.id[0]!=undefined){
return _1cd.id[0];
}else{
return _1cd.id;
}
}
},onTreeNodeClick:function(item,node){
this.selectedNodeId=this.getTreeNodeId(node);
},saveSegment:function(_1ce,_1cf){
var _1d0=this.parentObject.getGridValue(this.currentSegmentRowIndex,"notes");
if((_1d0==null)||(_1d0="")){
_1d0=" ";
}
this.xhr({url:"/branded-tabs/segments-management-save-segment-to-draft",content:{segmentCode:_1ce,segmentParentID:_1cf,resetRate:this.parentObject.returnXhrBool(this.parentObject.getGridValue(this.currentSegmentRowIndex,"resetRate")),segmentFullName:this.parentObject.getGridValue(this.currentSegmentRowIndex,"segmentName"),segmentNotes:_1d0,segmentShortName:this.parentObject.getGridValue(this.currentSegmentRowIndex,"segmentShortName")},load:dojo.hitch(this,"onSaveSegmentSuccess"),error:dojo.hitch(this,"onSaveSegmentFailure"),handleAs:"json"});
},onSaveSegmentSuccess:function(data){
if(data.success==true){
this.parentObject.forceRefresh(dojo.hitch(this,function(){
var _1d1=this.parentObject._serverData.messages["SegMng_LastSaveMessage"];
_1d1=dojo.string.substitute(_1d1,[data.time,this.parentObject._serverData.messages["SegMng_LastSaveMessage_Publish"]]);
this.parentObject._parentObject.WriteMessageAtBottom(_1d1);
}));
this.showRotation(false);
this.stopClosing(false);
this.onExecute();
}else{
this.onSaveSegmentFailure(data);
}
},onSaveSegmentFailure:function(data){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_SegmentChange_Failure"]});
dlg.show();
},destroy:function(){
try{
this.cancelXhr();
}
catch(e){
}
try{
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
delete this._connections;
}
}
catch(e){
}
try{
if(this._store){
if(this._store.isDirty){
this._store.revert();
}
this._store.close();
delete this._store;
}
}
catch(e){
}
try{
if(this._treeModel){
this._treeModel.destroy();
delete this._treeModel;
}
}
catch(e){
}
try{
if(this._tree){
this._tree.destroyRecursive();
}
delete this._tree;
}
catch(e){
}
try{
this.inherited(arguments);
}
catch(e){
}
}});
dojo.declare("Px.Ex.SegMngAddLevelDialog",[Px.Ex.Dialog],{"class":"segment-add-level-dialog SegMng",_connections:[],categoryCode:undefined,parentObject:undefined,parentSegmentCode:undefined,segmentCode:undefined,segmentResetRate:undefined,segmentFullName:undefined,segmentShortName:undefined,segmentNotes:undefined,constructor:function(conf){
dojo.mixin(this,conf);
this.rotationImage=Px.Ex.Application.getWaitImageUrl();
},startup:function(){
this.inherited(arguments);
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(this.parentObject._serverData.messages["SegMng_AddLevelDialogTitle"]);
this.attr("content",Px.Ex.Application.getWaitHtml());
this.createLayout();
},createLayout:function(){
var _1d2,_1d3,tr,td,div;
var _1d4,_1d5,_1d6,_1d7;
main=dojo.create("div",{});
_1d2=dojo.create("table",{},main);
_1d3=dojo.create("tbody",{},_1d2);
tr=dojo.create("tr",{},_1d3);
td=dojo.create("td",{style:"width: 150px;"},tr);
td.innerHTML=this.parentObject._serverData.messages["SegMng_AddLevelDialog_LevelName"];
td=dojo.create("td",{},tr);
this._nameTextBox=new Px.Ex.ValidationTextBox({name:"nameTextBox",trim:true,required:true,emptyMessage:this.parentObject._serverData.messages["SegMng_AddLevelDialog_LevelNameEmptyWarning"]});
this._nameTextBox.placeAt(td);
tr=dojo.create("tr",{},_1d3);
td=dojo.create("td",{},tr);
td.innerHTML=this.parentObject._serverData.messages["SegMng_AddLevelDialog_Relative"];
td=dojo.create("td",{},tr);
_1d4=dojo.create("table",{},td);
_1d5=dojo.create("tbody",{},_1d4);
_1d6=dojo.create("tr",{},_1d5);
_1d7=dojo.create("td",{},_1d6);
this._aboveRadioButton=new dijit.form.RadioButton({checked:true,value:"above",name:"relative"});
this._aboveRadioButton.placeAt(_1d7);
_1d7=dojo.create("td",{style:"padding-right: 20px;"},_1d6);
dojo.create("label",{innerHTML:this.parentObject._serverData.messages["SegMng_AddLevelDialog_RelativeAbove"]},_1d7);
_1d7=dojo.create("td",{},_1d6);
this._belowRadioButton=new dijit.form.RadioButton({checked:false,value:"below",name:"relative"});
this._belowRadioButton.placeAt(_1d7);
_1d7=dojo.create("td",{},_1d6);
dojo.create("label",{innerHTML:this.parentObject._serverData.messages["SegMng_AddLevelDialog_RelativeBelow"]},_1d7);
tr=dojo.create("tr",{},_1d3);
td=dojo.create("td",{innerHTML:this.parentObject._serverData.messages["SegMng_AddLevelDialog_RelativeSegment"]},tr);
td=dojo.create("td",{innerHTML:this.segmentShortName},tr);
buttondiv=dojo.create("div",{},main);
div=dojo.create("div",{innerHTML:"&nbsp;",className:"SegMng MoveCancelButton"},buttondiv);
this.connect(div,"onclick","onCancel");
div=dojo.create("div",{innerHTML:"&nbsp;",className:"SegMng MoveOKButton"},buttondiv);
this.connect(div,"onclick","onSave");
this.attr("content",main);
},onSave:function(){
var _1d8=this._aboveRadioButton.checked;
if(this._nameTextBox.isValid()){
this.showRotation(true);
if(_1d8){
this.turnCurrentToParent();
}else{
this.turnCurrentToChild();
}
}
},turnCurrentToParent:function(){
this.xhr({url:"/branded-tabs/segments-management-add-level-above",content:{categoryCode:this.categoryCode,segmentCode:this.segmentCode,segmentResetRate:this.parentObject.returnXhrBool(this.segmentResetRate),segmentShortName:this.segmentShortName,segmentFullName:this.segmentFullName,segmentNotes:this.segmentNotes,parentSegmentCode:this.parentSegmentCode,newLevelName:this._nameTextBox.value},load:dojo.hitch(this,"onTurnCurrentToParentSuccess"),error:dojo.hitch(this,"onTurnCurrentToParentFailure"),handleAs:"json"});
},onTurnCurrentToParentSuccess:function(data){
if(data.success){
this.parentObject.forceRefresh(dojo.hitch(this,function(){
var _1d9=this.parentObject._serverData.messages["SegMng_LastSaveMessage"];
_1d9=dojo.string.substitute(_1d9,[data.time,this.parentObject._serverData.messages["SegMng_LastSaveMessage_Publish"]]);
this.parentObject._parentObject.WriteMessageAtBottom(_1d9);
}));
this.showRotation(false);
this.stopClosing(false);
this.onExecute();
}else{
this.onTurnCurrentToParentFailure(data);
}
},onTurnCurrentToParentFailure:function(data){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_SegmentChange_Failure"]});
dlg.show();
},turnCurrentToChild:function(){
this.xhr({url:"/branded-tabs/segments-management-create-tree-level",content:{segmentName:this._nameTextBox.value,segmentShortName:null,isActive:true,allowSelection:true,parentSegment:this.segmentCode,segmentCategory:this.categoryCode,notes:" "},load:dojo.hitch(this,"onTurnCurrentToChildSuccess"),error:dojo.hitch(this,"onTurnCurrentToChildFailure"),handleAs:"json"});
},onTurnCurrentToChildSuccess:function(data){
if(data.success==true){
this.parentObject.forceRefresh(dojo.hitch(this,function(){
var _1da=this.parentObject._serverData.messages["SegMng_LastSaveMessage"];
_1da=dojo.string.substitute(_1da,[data.time,this.parentObject._serverData.messages["SegMng_LastSaveMessage_Publish"]]);
this.parentObject._parentObject.WriteMessageAtBottom(_1da);
}));
this.showRotation(false);
this.stopClosing(false);
this.onExecute();
}else{
this.onTurnCurrentToChildFailure(data);
}
},onTurnCurrentToChildFailure:function(data){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["SegMng_SegmentChange_Failure"]});
dlg.show();
},onCancel:function(){
}});
dojo.declare("Px.Ex.SegMngSetPrioritiesDialog",[Px.Ex.Dialog],{"class":"segment-set-priorities-dialog SegMng",FIRST:1,NEXT:2,PREVIOUS:3,LAST:4,UNBUCKETED:9999,SEPARATOR:-1,_connections:[],isDirty:false,parentObject:undefined,serverData:undefined,messages:undefined,currentSegmentCode:undefined,currentSegmentName:undefined,currentCategoryCode:undefined,constructor:function(conf){
dojo.mixin(this,conf);
this.rotationImage=Px.Ex.Application.getWaitImageUrl();
},startup:function(){
this.inherited(arguments);
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(this.parentObject._serverData.messages["SegMng_BuyerPrioritiesDialog_Title"]);
this.attr("content",Px.Ex.Application.getWaitHtml());
this.xhr({url:"/branded-tabs/segments-management-buyer-priorities-dialog",content:{categoryCode:this.currentCategoryCode,segmentCode:this.currentSegmentCode},load:dojo.hitch(this,"onScreenLoadSuccess"),error:dojo.hitch(this,"onScreenLoadFailure"),handleAs:"json"});
},onScreenLoadSuccess:function(data){
this.attr("content","");
if(data.accessDenied){
this.attr("content",data.accessDenied);
}else{
this.serverData=data;
this.serverData.messages=this.messages;
this.createScreen();
}
},onScreenLoadFailure:function(data){
this.attr("content",this.messages["SegMng_BuyerPrioritiesDialog_ErrorLoading"]);
},createScreen:function(){
maindiv=dojo.create("div",{className:"mainContent setPrioritiesDialog"});
subTitleDiv=dojo.create("div",{},maindiv);
subTitleDiv.innerHTML=dojo.string.substitute(this.serverData.messages["SegMng_BuyerPrioritiesDialog_SubTitle"],[this.currentSegmentName]);
arrowsWrapper=dojo.create("div",{},maindiv);
dojo.style(arrowsWrapper,"textAlign","right");
arrowsDiv=dojo.create("div",{},arrowsWrapper);
div=dojo.create("div",{className:"dijitInline btn-first unselectable",unselectable:true},arrowsDiv);
this.connect(div,"onclick","onButtonFirst");
div=dojo.create("div",{className:"dijitInline btn-up unselectable",unselectable:true},arrowsDiv);
this.connect(div,"onclick","onButtonPrev");
div=dojo.create("div",{className:"dijitInline btn-down unselectable",unselectable:true},arrowsDiv);
this.connect(div,"onclick","onButtonNext");
div=dojo.create("div",{className:"dijitInline btn-last unselectable",unselectable:true},arrowsDiv);
this.connect(div,"onclick","onButtonLast");
div=dojo.create("div",{id:"hint",className:"hint unselectable",unselectable:true},maindiv);
div=dojo.create("div",{className:"innerHint unselectable",unselectabe:true},div);
div.innerHTML=this.serverData.messages["SegMng_BuyerPrioritiesDialog_Hint"];
grid=dojo.create("div",{id:"grid",className:"grid"},maindiv);
buttonsSpan=dojo.create("div",{className:"buttons"},maindiv);
div=dojo.create("div",{className:"dijitInline cancel unselectable",innerHTML:"&nbsp;",unselectable:true},buttonsSpan);
this.connect(div,"onclick","onCancel");
div=dojo.create("div",{className:"dijitInline save unselectable",innerHTML:"&nbsp;",unselectable:true},buttonsSpan);
this.connect(div,"onclick","onSave");
this.attr("content",maindiv);
this.createGrid();
},onCancel:function(){
},onSave:function(){
var _1db=[];
var _1dc=1;
if(this.isDirty){
this.showRotation(true);
for(index in this._gridStore._arrayOfAllItems){
if(this._gridStore._arrayOfAllItems[index].buyerCode[0]==-1){
break;
}else{
_1db.push({buyerCode:this._gridStore._arrayOfAllItems[index].buyerCode[0],buyerName:this._gridStore._arrayOfAllItems[index].buyerName[0],priorityBucket:_1dc++});
}
}
this.xhr({url:"/branded-tabs/segments-management-save-buyer-priorities",content:{priorities:this.convertItemsToString(_1db),segmentCode:this.currentSegmentCode},load:dojo.hitch(this,"onSaveSuccess"),error:dojo.hitch(this,"onSaveFailure"),handleAs:"json"});
}else{
this.stopClosing(false);
this.onExecute();
}
},convertItemsToString:function(_1dd){
var res="";
dojo.forEach(_1dd,function(v){
res+=v.buyerCode+"\n"+v.buyerName+"\n"+v.priorityBucket+"\n";
});
res=res.substring(0,res.length-1);
return res;
},onSaveSuccess:function(data){
if(data&&data.success){
this.showRotation(false);
this.stopClosing(false);
this.onExecute();
}else{
this.onSaveFailure(data);
}
},onSaveFailure:function(data){
var dlg=new Px.Ex.OKMessageDialog({message:this.serverData.messages["SegMng_SegmentChange_Failure"]});
dlg.show();
this.showRotation(false);
this.stopClosing(false);
this.onExecute();
},getSeparatorRowIndex:function(){
for(index in this._gridStore._arrayOfAllItems){
if(this._gridStore._arrayOfAllItems[index].buyerCode[0]==-1){
return parseInt(index);
}
}
return -1;
},getStoreData:function(){
var _1de=[];
var _1df=true;
dojo.forEach(this.serverData.buyers,dojo.hitch(this,function(v){
if((v.priorityBucket==9999)&&(_1df==true)){
_1de.push({buyerCode:-1,buyerName:"",priorityBucket:-1,buyerUniquesShare:-1,todayUniques:-1});
_1df=false;
}
_1de.push(v);
}));
if(_1df==true){
_1de.push({buyerCode:-1,buyerName:"",priorityBucket:-1,buyerUniquesShare:-1,todayUniques:-1});
}
this.enforceOrder(_1de);
return {identifier:"buyerCode",items:_1de};
},enforceOrder:function(_1e0){
var _1e1=1;
var _1e2=true;
for(index in _1e0){
if(_1e0[index].buyerCode==this.SEPARATOR){
_1e2=false;
}else{
if(_1e2){
_1e0[index].priorityBucket=_1e1++;
}else{
_1e0[index].priorityBucket=this.UNBUCKETED;
}
}
}
_1e0.sort(dojo.hitch(this,function(a,b){
if((a.priorityBucket==this.UNBUCKETED)&&(b.priorityBucket==this.UNBUCKETED)){
if(a.buyerName>b.buyerName){
return 1;
}
if(b.buyerName>a.buyerName){
return -1;
}
return 0;
}
if((a.priorityBucket==-1)&&(b.priorityBucket==this.UNBUCKETED)){
return -1;
}
if((b.priorityBucket==-1)&&(a.priorityBucket==this.UNBUCKETED)){
return 1;
}
if((a.priorityBucket==-1)&&(b.priorityBucket!=this.UNBUCKETED)){
return 1;
}
if((b.priorityBucket==-1)&&(a.priorityBucket!=this.UNBUCKETED)){
return -1;
}
if(a.priorityBucket<b.priorityBucket){
return -1;
}
if(a.priorityBucket>b.priorityBucket){
return 1;
}
return 0;
}));
if((_1e0.length>0)&&(_1e0[0].buyerCode==-1)){
dojo.style(dojo.byId("hint"),"display","block");
}else{
dojo.style(dojo.byId("hint"),"display","none");
}
},getGridValue:function(_1e3,_1e4){
return this._gridStore.getValue(this._grid.getItem(_1e3),_1e4);
},getGridStructure:function(){
var _1e5=[{defaultCell:{styles:"white-space:nowrap;",headerStyles:"display: none;",noresize:true},cells:[{name:"buyerCode",field:"buyerCode",hidden:true},{name:"buyerName",field:"buyerName",hidden:false,formatter:dojo.hitch(this,"formatBuyerName"),width:"300px",styles:"border-right-style: none;"},{name:"priorityBucket",field:"priorityBucket",hidden:true},{name:"buyerUniquesShare",field:"buyerUniquesShare",hidden:true},{name:"todayUniques",field:"todayUniques",hidden:false,formatter:dojo.hitch(this,"formatTodayUniques"),cellStyles:"text-align: right;",styles:"border-left-style: none;",width:"100%"}]}];
return _1e5;
},formatBuyerName:function(data,_1e6){
var _1e7=this.getGridValue(_1e6,"buyerCode");
if(_1e7!=-1){
return data;
}else{
return "<div style=\"text-align: center; margin-top: -6px;\">"+this.serverData.messages["SegMng_BuyerPrioritiesDialog_Separator"]+"</div>";
}
},formatTodayUniques:function(data,_1e8){
var _1e9=this.getGridValue(_1e8,"buyerCode");
if(_1e9!=-1){
var _1ea;
if(dojo.isChrome){
_1ea="45px";
}else{
_1ea="40px";
}
return "<div style=\"margin-right: 30px; width: "+_1ea+"; text-align: right;\">"+dojo.number.format(data)+"</div>";
}else{
return "";
}
},getGridItems:function(){
var _1eb=[];
dojo.forEach(this._gridStore._arrayOfAllItems,dojo.hitch(this,function(v){
_1eb.push({buyerCode:v.buyerCode[0],buyerName:v.buyerName[0],buyerUniquesShare:v.buyerUniquesShare[0],priorityBucket:v.priorityBucket[0],todayUniques:v.todayUniques[0]});
}));
return _1eb;
},moveBuyer:function(_1ec,_1ed){
var _1ee=this.getGridItems();
var _1ef=this.getBuyer(_1ed);
var _1f0=this.getSeparatorRowIndex();
switch(_1ec){
case this.FIRST:
if(_1ed==0){
return;
}
_1ee.splice(0,0,_1ee.splice(_1ed,1)[0]);
break;
case this.LAST:
if(_1ef.priorityBucket==this.UNBUCKETED){
return;
}
if(_1ed<(_1f0-1)){
_1ee.splice(_1f0-1,0,_1ee.splice(_1ed,1)[0]);
}else{
_1ee.splice(_1ee.length,0,_1ee.splice(_1ed,1)[0]);
}
break;
case this.NEXT:
if(_1ef.priorityBucket==this.UNBUCKETED){
return;
}
_1ee.splice(_1ed+1,0,_1ee.splice(_1ed,1)[0]);
break;
case this.PREVIOUS:
if(_1ed==0){
return;
}
if(_1ef.priorityBucket==this.UNBUCKETED){
_1ee.splice(_1f0,0,_1ee.splice(_1ed,1)[0]);
}else{
_1ee.splice(_1ed-1,0,_1ee.splice(_1ed,1)[0]);
}
break;
}
this.isDirty=true;
this._gridStore.close();
this.enforceOrder(_1ee);
this._gridStore._jsonData={identifier:"buyerCode",items:_1ee};
this._gridStore.fetch();
this._grid._refresh.call(this._grid,false);
this.selectBuyer(_1ef.buyerCode);
var _1f1=this._grid.selection.selectedIndex;
var _1f2=this._grid.scroller.firstVisibleRow;
var _1f3=this._grid.scroller.lastVisibleRow;
if((_1f1>_1f3)||(_1f1<_1f2)){
this._grid.scrollToRow(this._grid.selection.selectedIndex);
}
},getBuyer:function(_1f4){
var _1f5=this.getGridValue(_1f4,"buyerCode");
var _1f6=this._gridStore._itemsByIdentity[_1f5];
return {buyerCode:_1f6.buyerCode[0],buyerName:_1f6.buyerName[0],buyerUniquesShare:_1f6.buyerUniquesShare[0],priorityBucket:_1f6.priorityBucket[0],todayUniques:_1f6.todayUniques[0]};
},selectBuyer:function(_1f7){
for(var i=0;i<this._gridStore._arrayOfAllItems.length;i++){
var _1f8=this.getGridValue(i,"buyerCode");
if(_1f8==_1f7){
this._grid.selection.select(i);
break;
}
}
},createGrid:function(){
this._gridStore=new dojo.data.ItemFileReadStore({clearOnClose:true,data:this.getStoreData()});
this._grid=new dojox.grid.DataGrid({store:this._gridStore,query:{buyerCode:"*"},queryOptions:{ignoreCase:true},height:"250px",style:"border-top: 1px solid rgb(233,233,233); border-right: 1px solid rgb(233,233,233); border-bottom: 1px solid rgb(233,233,233);",selectionMode:"single",onStyleRow:dojo.hitch(this,"onGridStyleRow"),structure:this.getGridStructure()});
this._grid.placeAt(dojo.byId("grid"));
this._grid.startup();
this._grid._refresh();
this._connections.push(dojo.connect(this._grid,"onSelected",dojo.hitch(this,"onGridSelected")));
this._connections.push(dojo.connect(this._grid,"onCellMouseOver",dojo.hitch(this,"onGridCellMouseOver")));
this._connections.push(dojo.connect(this._grid,"onCellMouseOut",dojo.hitch(this,"onGridCellMouseOut")));
},onGridCellMouseOver:function(e){
var _1f9=this.getGridValue(e.rowIndex,"buyerCode");
if((_1f9!=-1)&&(e.cell._props["field"]=="todayUniques")){
var _1fa=this.getGridValue(e.rowIndex,"buyerUniquesShare");
var _1fb=this.serverData.messages["SegMng_BuyerPrioritiesDialog_Tooltip"];
_1fb=dojo.string.substitute(_1fb,[_1fa*100]);
dijit.showTooltip(_1fb,e.cellNode,["after","above"]);
}
},onGridCellMouseOut:function(e){
var _1fc=this.getGridValue(e.rowIndex,"buyerCode");
if((_1fc!=-1)&&(e.cell._props["field"]=="todayUniques")){
dijit.hideTooltip(e.cellNode);
}
},onGridStyleRow:function(_1fd){
try{
if(_1fd.index==0){
_1fd.customClasses="firstRow";
}
var id=this.getGridValue(_1fd.index,"buyerCode");
if(id==-1){
_1fd.customClasses="separator";
}else{
if(_1fd.selected){
_1fd.customClasses="selectedRow";
}
if(_1fd.over){
_1fd.customClasses="overRow";
}
}
}
catch(e){
}
},onGridSelected:function(_1fe){
var _1ff=this.getGridValue(_1fe,"buyerCode");
if(_1ff==-1){
this._grid.selection.clear();
}
},onButtonFirst:function(){
var _200=this._grid.selection.selectedIndex;
if(_200!=-1){
this.moveBuyer(this.FIRST,_200);
}
},onButtonPrev:function(){
var _201=this._grid.selection.selectedIndex;
if(_201!=-1){
this.moveBuyer(this.PREVIOUS,_201);
}
},onButtonNext:function(){
var _202=this._grid.selection.selectedIndex;
if(_202!=-1){
this.moveBuyer(this.NEXT,_202);
}
},onButtonLast:function(){
var _203=this._grid.selection.selectedIndex;
if(_203!=-1){
this.moveBuyer(this.LAST,_203);
}
},destroy:function(){
try{
this.cancelXhr();
}
catch(e){
}
try{
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
delete this._connections;
}
}
catch(e){
}
try{
if(this._gridStore){
if(this._gridStore.isDirty){
this._gridStore.revert();
}
this._gridStore.close();
delete this._gridStore;
}
}
catch(e){
}
try{
if(this._grid){
this._grid.destroyRecursive();
}
delete this._grid;
}
catch(e){
}
try{
this.inherited(arguments);
}
catch(e){
}
}});
dojo.declare("Px.Ex.BuyerCategoryPermissionsScreen",[Px.Ex.XhrMixin],{_gridConnections:[],_otherConnections:[],draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhrLoad({selector:"#divContent",url:"/branded-tabs/buyer-category-permissions-screen",content:{},load:dojo.hitch(this,"createScreen")});
},createScreen:function(){
dojo.parser.parse(dojo.byId("mainDiv"));
this.parseServerDataFromHtml();
this.bindOtherEvents();
this.refreshGridData();
},refreshGridData:function(){
dojo.empty(dojo.byId("GridDiv"));
dojo.byId("GridDiv").innerHTML=Px.Ex.Application.getWaitHtml();
this.xhr({url:"/branded-tabs/buyer-category-permissions-grid",content:{},load:dojo.hitch(this,"refreshGridDataSuccess"),error:dojo.hitch(this,"refreshGridDataFailure"),handleAs:"json"});
},refreshGridDataSuccess:function(_1){
dojo.empty(dojo.byId("GridDiv"));
this._serverData.categories=_1["categories"];
this._serverData.privateBuyers=_1["privateBuyers"];
this._serverData.publicBuyers=_1["publicBuyers"];
if(this._serverData.categories&&this._serverData.categories.length>0){
this._serverData.categories.sort(function(a,b){
if(a["categoryCode"]==3){
return -1;
}
if(b["categoryCode"]==3){
return 1;
}
if(a["categoryCode"]==2){
return -1;
}
if(b["categoryCode"]==2){
return 1;
}
if(a["categoryCode"]==1){
return -1;
}
if(b["categoryCode"]==1){
return 1;
}
if(dojo.isChrome){
return -1;
}else{
return 0;
}
});
}
this.selfDraw(true);
this.bindGridEvents();
},refreshGridDataFailure:function(_2){
var _3=new Px.Ex.OKMessageDialog({message:this._serverData.messages["BUYERCATPERM_Message_LoadFailure"]});
_3.show();
},createGrid:function(_4){
if(_4==true){
this._grid=new dojox.grid.DataGrid({store:this._gridStore,query:{id:"*"},queryOptions:{ignoreCase:true},clientSort:false,height:"349px",width:"872px",selectionMode:"none",selectable:true,canSort:function(_5){
return false;
},onStyleRow:dojo.hitch(this,"onGridStyleRow"),structure:this.getGridStructure()});
this._grid.placeAt(dojo.byId("GridDiv"));
this._grid.startup();
this._grid._refresh();
}else{
this._grid._refresh.call(this._grid,true);
}
},bindGridEvents:function(){
try{
dojo.forEach(this._gridConnections,dojo.disconnect,this);
}
catch(e){
}
this._gridConnections.push(dojo.connect(this._grid,"onCellClick",dojo.hitch(this,"onGridCellClick")));
this._gridConnections.push(dojo.connect(this._grid,"onHeaderCellMouseOver",dojo.hitch(this,"onGridHeaderCellMouseOver")));
this._gridConnections.push(dojo.connect(this._grid,"onHeaderCellMouseOut",dojo.hitch(this,"onGridHeaderCellMouseOut")));
this._grid.resize();
},bindOtherEvents:function(){
try{
dojo.forEach(this._otherConnections,dojo.disconnect,this);
}
catch(e){
}
this._otherConnections.push(dojo.connect(dojo.byId("RefreshButton"),"onclick",dojo.hitch(this,function(){
this.refresh();
})));
this._otherConnections.push(dojo.connect(AllowedBuyersCheckboxId,"onChange",dojo.hitch(this,"onCheckboxChange")));
this._otherConnections.push(dojo.connect(SearchTextBox,"onChange",dojo.hitch(this,"onSearchChange")));
},onGridHeaderCellMouseOver:function(e){
if(e.cellIndex>3){
var _6=e.cell._props["name"];
var _7=_6.indexOf(">");
var _8=_6.lastIndexOf("<");
dijit.showTooltip(_6.substring(_7+1,_8),e.cellNode,["above","below"]);
}
},onGridHeaderCellMouseOut:function(e){
if(e.cellIndex>3){
dijit.hideTooltip(e.cellNode);
}
},onSearchChange:function(_9){
clearTimeout(this._timer);
this._timer=setTimeout(dojo.hitch(this,"selfDraw",false),250);
SearchTextBox.focus();
},onCheckboxChange:function(_a){
this.selfDraw(false);
},getTooltip:function(_b){
if(_b["activeBuysCount"]>0){
return dojo.string.substitute(this._serverData.messages["BUYERCATPERM_Tooltip_BuyerStatus_CurrentActivity"],[_b["activeBuysCount"]]);
}else{
return this._serverData.messages["BUYERCATPERM_Tooltip_BuyerStatus_PastActivity"]+"\r\n"+this._serverData.messages["BUYERCATPERM_Tooltip_BuyerStatus_NoCurrentActivity"];
}
},onGridCellClick:function(e){
var _c=e.target;
if((_c.id.indexOf("perm_action")==0)&&(_c.className.indexOf("canBePressed")>=0)){
var _d=this.getGridValue(e.rowIndex,"id");
var _e=e.cell.extraField;
var _f;
if(_c.src.indexOf(this._serverData.constants["BuyerCatPerm_Const_IconPermitted"])>=0){
_f=0;
}else{
_f=1;
}
this.setBuyerCategoryPermission(e.rowIndex,_d,_e,_f);
}
},setBuyerCategoryPermission:function(_10,_11,_12,_13){
this.xhr({url:"/branded-tabs/buyer-category-permissions-set-permission",content:{buyerCode:_11,categoryCode:_12,status:_13},load:dojo.hitch(this,"onSetBuyerCategoryPermissionSuccess",_10,_11,_12,_13),error:dojo.hitch(this,"onSetBuyerCategoryPermissionFailure",_10,_11,_12,_13),handleAs:"json"});
},onSetBuyerCategoryPermissionSuccess:function(_14,_15,_16,_17,_18){
if(_18["return"]["success"]==true){
var _19=this.getItemFromArray(this.getRowBuyer(_14)["categories"],"categoryCode",_16);
switch(_17){
case 0:
_19["permitted"]=false;
this._grid.updateRow(_14);
break;
case 1:
_19["permitted"]=true;
this._grid.updateRow(_14);
break;
}
}else{
this.onSetBuyerCategoryPermissionFailure(_14,_15,_16,_17,_18);
}
},onSetBuyerCategoryPermissionFailure:function(_1a,_1b,_1c,_1d,_1e){
var dlg=new Px.Ex.OKMessageDialog({message:this._serverData.messages["BUYERCATPERM_Message_SetPermissionFailure"]});
dlg.show();
},refresh:function(){
this.gridCleanup();
this.refreshGridData();
},onGridStyleRow:function(_1f){
try{
var id=this.getGridValue(_1f.index,"id");
if(id<0){
_1f.customStyles="background-color: rgb(236,238,241); color: rgb(17,73,128);";
}
}
catch(e){
}
},parseServerDataFromHtml:function(){
this._serverData={};
this._serverData.messages=dojo.fromJson(dojo.byId("server_messages").innerHTML);
this._serverData.constants=dojo.fromJson(dojo.byId("server_constants").innerHTML);
this._serverData.permissions=dojo.fromJson(dojo.byId("server_permissions").innerHTML);
},selfDraw:function(_20){
var _21=3;
var _22=1;
var _23=AllowedBuyersCheckboxId.checked;
var _24=SearchTextBox._lastValue.toLowerCase();
this.createGridStore(_20,_23,_24);
this.createGrid(_20);
var _25=new TabsContainer(document.getElementById("tabsContainerDiv"),"ctgs",Px.Ex.Application.__contactRole.displayVersion);
var _26=this._serverData.categories.length;
if(dojo.isIE){
var _27=dojo.byId("tabsContainerDiv");
dojo.style(_27,"marginLeft",dojo.coords(dojo.query(".dojoxGridCell[idx='"+_21+"']")[_22]).w);
var _28=0;
for(category in this._serverData.categories){
_28++;
var _29=dojo.coords(dojo.query(".dojoxGridCell[idx='"+(_28+_21)+"']")[_22]).w;
if((_28==_26)&&(this.hasGridScroll())){
_29=dojo.coords(dojo.query(".dojoxGridCell[idx='"+(_28+_21)+"']")[_22]).w-17;
}
var _2a=_25.addTab(this._serverData.categories[category]["categoryName"],_29);
var _2b=_2a._tabId;
var _2c=dojo.byId(_2b).children[1];
dojo.addClass(_2c,"dojoxEllipsis");
dojo.attr(_2c,"title",_2a._tabText);
}
}else{
if(dojo.isChrome){
var _27=document.getElementById("tabsContainerDiv");
_27.outerHTML="<div id='tabsContainerDiv' style='margin-left:"+(dojo.coords(dojo.query(".dojoxGridCell[idx='"+_21+"']")[_22]).w)+"px'>"+_27.innerHTML+"</div>";
var _28=0;
for(category in this._serverData.categories){
_28++;
var _29=dojo.coords(dojo.query(".dojoxGridCell[idx='"+(_28+_21)+"']")[_22]).w;
if((_28==_26)&&(this.hasGridScroll())){
_29-=16;
}
var _2a=_25.addTab(this._serverData.categories[category]["categoryName"],_29);
var _2b=_2a._tabId;
var _2c=dojo.byId(_2b).children[1];
dojo.addClass(_2c,"dojoxEllipsis");
dojo.attr(_2c,"title",_2a._tabText);
}
}else{
dojo.style(dojo.byId("tabsContainerDiv"),"marginLeft",(dojo.coords(dojo.query(".dojoxGridCell[idx='"+_21+"']")[_22]).w)+"px");
var _28=0;
for(category in this._serverData.categories){
_28++;
if(_28!=_26){
var _2a=_25.addTab(this._serverData.categories[category]["categoryName"],this._categoryWidth+8);
}else{
if(this.hasGridScroll()){
var _2a=_25.addTab(this._serverData.categories[category]["categoryName"],this._grid.domNode.clientWidth-this._buyerNameWidth-((_28-1)*(this._categoryWidth+8))-24);
}else{
var _2a=_25.addTab(this._serverData.categories[category]["categoryName"],this._grid.domNode.clientWidth-this._buyerNameWidth-((_28-1)*(this._categoryWidth+8))-8);
}
}
var _2b=_2a._tabId;
var _2c=dojo.byId(_2b).children[1];
dojo.addClass(_2c,"dojoxEllipsis");
dojo.attr(_2c,"title",_2a._tabText);
}
}
}
},hasGridScroll:function(){
return this._grid.views.views[0]._hasVScroll;
},isFilteredOut:function(_2d,_2e,_2f){
if(_2e==true){
var _30=this.getItemFromArray(_2d.categories,"permitted",true);
if(_30==null){
return true;
}
}
if(_2f!=""){
var id;
if(_2d.id!=null){
id=_2d.id+"";
}else{
id=null;
}
if((_2d.displayCode!=null)&&(_2d.displayCode.toLowerCase()==_2f)){
return false;
}
if((_2d.name!=null)&&(_2d.name.toLowerCase().indexOf(_2f)>=0)){
return false;
}
return true;
}
return false;
},createGridStore:function(_31,_32,_33){
var _34=[];
var _35=0;
if(this._serverData.privateBuyers.length>0){
dojo.forEach(this._serverData.privateBuyers,dojo.hitch(this,function(v){
if(this.isFilteredOut(v,_32,_33)==false){
_34.push({"private":true,"id":v.id,"displayCode":v.displayCode,"name":v.name});
}
}));
if(_34.length>0){
_34.splice(0,0,{"id":-2,"name":this._serverData.messages["BUYERCATPERM_Title_privateBuyers"]});
}
_35=_34.length;
}
if(this._serverData.publicBuyers.length>0){
dojo.forEach(this._serverData.publicBuyers,dojo.hitch(this,function(v){
if(this.isFilteredOut(v,_32,_33)==false){
_34.push({"private":false,"id":v.id,"displayCode":v.displayCode,"name":v.name});
}
}));
if(_34.length>_35){
_34.splice(_35,0,{"id":-1,"name":this._serverData.messages["BUYERCATPERM_Title_publicBuyers"]});
}
}
var _36={identifier:"id",items:_34};
if(_31==true){
this._gridStore=new dojo.data.ItemFileWriteStore({clearOnClose:true,data:_36});
}else{
this._gridStore.revert();
this._gridStore.close();
this._gridStore._jsonData=_36;
this._gridStore.fetch();
}
},getGridValue:function(_37,_38){
var val=this._gridStore.getValue(this._grid.getItem(_37),_38);
return val;
},formatBuyerName:function(_39,_3a){
var id=this.getGridValue(_3a,"id");
if(id>=0){
return "<div>"+_39+"</div>";
}else{
return "<div style=\"text-align: center;\">"+_39+"</div>";
}
},getRowBuyer:function(_3b){
var _3c=null;
var _3d=this.getGridValue(_3b,"id");
var _3e=this.getGridValue(_3b,"private");
switch(_3e){
case true:
_3c=this.getItemFromArray(this._serverData.privateBuyers,"id",_3d);
break;
case false:
_3c=this.getItemFromArray(this._serverData.publicBuyers,"id",_3d);
break;
}
return _3c;
},formatCategoryPermissions:function(_3f,_40,_41){
var id=this.getGridValue(_41,"id");
if(id>=0){
var _42=this.getItemFromArray(this.getRowBuyer(_41)["categories"],"categoryCode",_3f);
var _43="<div style=\"text-align: center;\">";
var _44=this.getTooltip(_42);
if(_42["permitted"]){
var _45="";
var _46=true;
if((_42["anyBuys"]==true)&&(_42["activeBuysCount"]==0)){
_45=this._serverData.constants["BuyerCatPerm_Const_IconStatusYesNo"];
}else{
if((_42["anyBuys"]==true)&&(_42["activeBuysCount"]>0)){
_45=this._serverData.constants["BuyerCatPerm_Const_IconStatusYesYes"];
var _46=false;
}else{
_45=this._serverData.constants["BuyerCatPerm_Const_IconStatusNoNo"];
}
}
_43+="<img src=\""+_45+"\" "+(_45!=this._serverData.constants["BuyerCatPerm_Const_IconStatusNoNo"]?("title=\""+_44+"\""):"")+">&nbsp;<img "+(_46?"class=\"canBePressed\" style=\"cursor: pointer;\"":"")+" id=\"perm_action_"+_41+"\" src=\""+this._serverData.constants["BuyerCatPerm_Const_IconPermitted"]+"\">";
}else{
_43+="<img src=\""+this._serverData.constants["BuyerCatPerm_Const_IconStatusNoNo"]+"\">&nbsp;<img class=\"canBePressed\" style=\"cursor: pointer;\" id=\"perm_action_"+_41+"\" src=\""+this._serverData.constants["BuyerCatPerm_Const_IconNotPermitted"]+"\">";
}
_43+="</div>";
return _43;
}else{
return "";
}
},getItemFromArray:function(_47,_48,_49){
var _4a=null;
for(i in _47){
var _4b=_47[i];
if(_4b[_48]==_49){
_4a=_4b;
break;
}
}
return _4a;
},getGridStructure:function(){
var _4c=this._serverData.categories.length;
var _4d=dojo.style(dojo.byId("mainDiv"),"width");
if(dojo.isChrome){
_4d-=18;
}else{
_4d-=66;
}
this._buyerNameWidth=250;
this._categoryWidth=130;
if(this._buyerNameWidth+(this._categoryWidth*_4c)>_4d){
this._categoryWidth=(_4d-250)/_4c;
}else{
this._buyerNameWidth=_4d-(this._categoryWidth*_4c);
}
var _4e=[{defaultCell:{styles:"white-space:nowrap;",headerStyles:"display: none;",noresize:true},cells:[{name:"id",field:"id",hidden:true},{name:"displayCode",field:"displayCode",hidden:true},{name:"private",field:"private",hidden:true},{name:" ",field:"name",formatter:dojo.hitch(this,"formatBuyerName"),noresize:true,width:this._buyerNameWidth+"px",hidden:false,headerStyles:"display:none;"}]}];
var _4f=0;
for(category in this._serverData.categories){
_4f++;
var _50=this._serverData.categories[category]["categoryName"];
var _51=this._serverData.categories[category]["categoryCode"];
_4e[0].cells.push({name:"<div class=\"dojoxEllipsis\">"+_50+"</div>",extraField:_51,width:(_4f==_4c)?"100%":(this._categoryWidth+"px"),formatter:dojo.hitch(this,"formatCategoryPermissions",_51),noresize:true,hidden:false});
}
return _4e;
},gridCleanup:function(){
try{
dojo.forEach(this._gridConnections,dojo.disconnect,this);
}
catch(e){
}
try{
if(this._gridStore){
if(this._gridStore.isDirty){
this._gridStore.revert();
}
this._gridStore.close();
delete this._gridStore;
}
}
catch(e){
}
try{
if(this._grid){
this._grid.destroyRecursive(false);
delete this._grid;
}
}
catch(e){
}
},cleanup:function(){
try{
clearTimeout(this._timer);
}
catch(e){
}
try{
if(this._otherConnections){
dojo.forEach(this._connections,dojo.disconnect,this);
delete this._otherConnections;
}
}
catch(e){
}
this.gridCleanup();
},destroy:function(){
this.cleanup();
}});
dojo.declare("Px.Ex.DirectBuyerDialog",[Px.Ex.Dialog],{"class":"set-direct-buyers-permissions",_connections:[],_tpubId:0,_tpubName:"",constructor:function(_1){
this._tpubId=_1.tpubId;
this._tpubName=_1.tpubName;
this.rotationImage=Px.Ex.Application.getWaitImageUrl();
},startup:function(){
this.inherited(arguments);
this.titleBar.innerHTML=Px.Ex.Application.menu.getSubTitleHtml(Px.Ex.Application.Titles.DIRECT_BUYERS_PERMISSIONS);
this.attr("content",Px.Ex.Application.getWaitHtml());
this.xhr({url:"/sellers/get-direct-buyer-dialog",content:{tpubId:this._tpubId,tpubName:this._tpubName},load:dojo.hitch(this,"onScreenLoadSuccess"),error:dojo.hitch(this,"onScreenLoadFailure"),handleAs:"text"});
},onScreenLoadFailure:function(_2){
},onScreenLoadSuccess:function(_3){
this.attr("content",_3);
dojo.parser.parse(dojo.byId("mainDiv"));
this.fetchServerData();
this.selfDraw(true);
this.bindEvents();
},selfDraw:function(_4){
var _5=AllowedBuyersCheckboxId.checked;
var _6=SearchTextBox._lastValue.toLowerCase();
this.createGridStore(_4,_5,_6);
this.createGrid(_4);
},createGrid:function(_7){
if(_7==true){
this._grid=new dojox.grid.DataGrid({store:this._gridStore,query:{code:"*"},clientSort:false,queryOptions:{ignoreCase:true},height:"260px",selectionMode:"single",onStyleRow:function(){
},structure:this.getGridStructure()});
this._grid.placeAt(dojo.byId("grid"));
this._grid.startup();
this._grid._refresh();
}else{
this._grid._refresh.call(this._grid,true);
}
},createGridStore:function(_8,_9,_a){
var _b=[];
if(_8){
this.allDirectBuyers=dojo.fromJson(dojo.byId("directBuyerPermissions").innerHTML);
}
if(this.allDirectBuyers.length>0){
dojo.forEach(this.allDirectBuyers,dojo.hitch(this,function(v){
if(!this.isFilteredOut(v,_9,_a)){
_b.push({"code":v.code,"displayCode":v.displayCode,"name":v.name,"allowed":v.allowed});
}
}),this);
}
var _c={identifier:"code",items:_b};
if(_8==true){
this._gridStore=new dojo.data.ItemFileWriteStore({clearOnClose:true,data:_c});
}else{
this._gridStore.revert();
this._gridStore.close();
this._gridStore._jsonData=_c;
this._gridStore.fetch();
}
},updatePermOperation:function(_d,_e){
var _f=dojo.filter(this.allDirectBuyers,dojo.hitch(this,function(v){
return (v.code==_d);
}));
dojo.forEach(_f,dojo.hitch(this,function(v){
v.allowed=_e;
}));
},getGridStructure:function(){
var _10=[{defaultCell:{styles:"white-space:nowrap;",headerStyles:"text-align: center;",noresize:true},cells:[{name:"code",field:"code",hidden:true},{name:"displayCode",field:"displayCode",hidden:true},{name:this._messages["GetDirectBuyers_Column_BuyerName"],field:"name",formatter:dojo.hitch(this,"formatBuyerName"),noresize:true,width:"300px",hidden:false},{name:this._messages["GetDirectBuyers_Column_Permission"],field:"allowed",formatter:dojo.hitch(this,"formatBuyerPermissions"),noresize:true,width:"100%",hidden:false}]}];
return _10;
},formatBuyerName:function(_11,_12){
console.log("here");
return _11;
},formatBuyerPermissions:function(_13,_14){
if(_13==true){
return "<div><div class=\"allowed\">&nbsp;</div></div>";
}else{
return "<div><div class=\"notAllowed\">&nbsp;</div></div>";
}
},isFilteredOut:function(_15,_16,_17){
if(_16==true){
if(_15.allowed==false){
return true;
}
}
if(_17!=""){
if((_15.code+"").toLowerCase()==_17){
return false;
}
if((_15.displayCode!=null)&&((_15.displayCode+"").toLowerCase()==_17)){
return false;
}
if((_15.name!=null)&&(_15.name.toLowerCase().indexOf(_17)>=0)){
return false;
}
return true;
}
return false;
},bindEvents:function(){
this._connections.push(dojo.connect(AllowedBuyersCheckboxId,"onChange",dojo.hitch(this,"onCheckboxChange")));
this._connections.push(dojo.connect(SearchTextBox,"onChange",dojo.hitch(this,"onSearchChange")));
this._connections.push(dojo.connect(this._grid,"onCellClick",dojo.hitch(this,"onGridCellClick")));
},getGridValue:function(_18,_19){
var val=this._gridStore.getValue(this._grid.getItem(_18),_19);
return val;
},onGridCellClick:function(e){
var _1a=e.target;
var _1b=this.getGridValue(e.rowIndex,"code");
if(_1a.className.indexOf("allowed")>=0){
var _1c=this.xhrChangeDirectBuyerPermission(this._tpubId,_1b,false);
if(_1c){
dojo.removeClass(_1a,"allowed");
dojo.addClass(_1a,"notAllowed");
this.updatePermOperation(_1b,false);
}
}else{
if(_1a.className.indexOf("notAllowed")>=0){
var _1c=this.xhrChangeDirectBuyerPermission(this._tpubId,_1b,true);
if(_1c){
dojo.removeClass(_1a,"notAllowed");
dojo.addClass(_1a,"allowed");
this.updatePermOperation(_1b,true);
}
}
}
},xhrChangeDirectBuyerPermission:function(_1d,_1e,_1f){
var _20=false;
dojo.xhrGet({sync:true,url:"/sellers/change-direct-buyer-permission",content:{publisherCode:_1d,buyerCode:_1e,on:_1f?1:0},load:dojo.hitch(this,function(_21){
if(_21.success){
_20=true;
}
}),handleAs:"json"});
return _20;
},onCheckboxChange:function(_22){
this.selfDraw(false);
},onSearchChange:function(val){
clearTimeout(this._timer);
this._timer=setTimeout(dojo.hitch(this,"selfDraw",false),250);
SearchTextBox.focus();
},fetchServerData:function(){
this._messages=dojo.fromJson(dojo.byId("messages").innerHTML);
},destroy:function(){
try{
if(this._connections){
dojo.forEach(this._connections,dojo.disconnect,this);
}
}
catch(e){
}
try{
if(this._gridStore.isDirty){
this._gridStore.revert();
}
this._gridStore.close();
delete this._gridStore;
}
catch(e){
}
try{
if(this._grid){
this._grid.destroyRecursive(false);
delete this._grid;
}
}
catch(e){
}
try{
if(AllowedBuyersCheckboxId){
AllowedBuyersCheckboxId.destroyRecursive(false);
delete AllowedBuyersCheckboxIds;
}
}
catch(e){
}
try{
if(SearchTextBox){
SearchTextBox.destroyRecursive(false);
delete SearchTextBox;
}
}
catch(e){
}
}});
dojo.require("dijit.layout.LayoutContainer");
dojo.declare("Px.Ex.DataDealNotes.NotesWidget",[dijit.layout.ContentPane],{Width:350,Height:422,SpaceFromBorders:5,BorderThickness:3,BorderColor:"#AFAFAF",BorderStyle:"solid",onBeforeScrollUpCallback:undefined,onAfterScrollUpCallback:undefined,onBeforeScrollDownCallback:undefined,onAfterScrollDownCallback:undefined,OnBeforeCloseCallback:undefined,onAfterCloseCallback:undefined,_connections:[],constructor:function(_1){
dojo.mixin(this,_1);
},startup:function(){
this._createLayout();
this._bindEvents();
dojo.style(this.containerNode,"overflow","hidden");
this.inherited(arguments);
},_createLayout:function(){
dojo.style(this.containerNode,"height",this.Height+"px");
dojo.style(this.containerNode,"width",this.Width+"px");
this._closeButton=dojo.create("div",{className:"noteCloseButton"},this.containerNode);
dojo.style(this._closeButton,"marginLeft","auto");
this._scrollerUp=dojo.create("div",{className:"noteScrollerUp_on"},this.containerNode);
dojo.style(this._scrollerUp,"marginLeft","auto");
dojo.style(this._scrollerUp,"marginRight","auto");
dojo.style(this._scrollerUp,"marginTop",(0-dojo.style(this._scrollerUp,"height"))+"px");
this._scrollerTop=dojo.create("div",{className:"noteScrollerTop_on"},this.containerNode);
dojo.style(this._scrollerTop,"marginRight","auto");
dojo.style(this._scrollerTop,"marginTop",(0-dojo.style(this._scrollerTop,"height"))+"px");
var _2=(dojo.style(this._scrollerUp,"height")>dojo.style(this._closeButton,"height")?dojo.style(this._scrollerUp,"height"):dojo.style(this._closeButton,"height"));
this._scrollableAreaEnvelope=dojo.create("div",{},this.containerNode);
dojo.style(this._scrollableAreaEnvelope,"backgroundColor","white");
this._scrollerDown=dojo.create("div",{className:"noteScrollerDown_on"},this.containerNode);
dojo.style(this._scrollerDown,"marginLeft","auto");
dojo.style(this._scrollerDown,"marginRight","auto");
this._scrollerBottom=dojo.create("div",{className:"noteScrollerBottom_on"},this.containerNode);
dojo.style(this._scrollerBottom,"marginRight","auto");
dojo.style(this._scrollerBottom,"marginTop",(0-dojo.style(this._scrollerBottom,"height"))+"px");
this._scrollableAreaDiv=dojo.create("div",{},this._scrollableAreaEnvelope);
var _3=this.BorderThickness+"px "+this.BorderStyle+" "+this.BorderColor;
dojo.style(this._scrollableAreaEnvelope,"borderTop",_3);
dojo.style(this._scrollableAreaEnvelope,"borderBottom",_3);
dojo.style(this._scrollableAreaEnvelope,"paddingTop",this.SpaceFromBorders+"px");
dojo.style(this._scrollableAreaEnvelope,"paddingBottom",this.SpaceFromBorders+"px");
var _4=this.Height-(2*this.SpaceFromBorders)-(2*this.BorderThickness)-_2-dojo.style(this._scrollerDown,"height");
dojo.style(this._scrollableAreaDiv,"height",_4+"px");
dojo.style(this._scrollableAreaDiv,"maxHeight",_4+"px");
dojo.style(this._scrollableAreaDiv,"overflow","hidden");
this._notesScrollableArea=new Px.Ex.DataDealNotes.NotesScrollableArea({Height:_4,Width:this.Width});
this._notesScrollableArea.placeAt(this._scrollableAreaDiv);
this._notesScrollableArea.startup();
},_bindEvents:function(){
this._connections.push(dojo.connect(this._scrollerTop,"onclick",dojo.hitch(this,function(){
this._notesScrollableArea.scrollToTop(this.onBeforeScrollUpCallback,this.onAfterScrollUpCallback);
})));
this._connections.push(dojo.connect(this._scrollerBottom,"onclick",dojo.hitch(this,function(){
this._notesScrollableArea.scrollToBottom(this.onBeforeScrollDownCallback,this.onAfterScrollDownCallback);
})));
this._connections.push(dojo.connect(this._scrollerUp,"onclick",dojo.hitch(this,function(){
this._notesScrollableArea.advanceUp(this.onBeforeScrollUpCallback,this.onAfterScrollUpCallback);
})));
this._connections.push(dojo.connect(this._scrollerDown,"onclick",dojo.hitch(this,function(){
this._notesScrollableArea.advanceDown(this.onBeforeScrollDownCallback,this.onAfterScrollDownCallback);
})));
this._connections.push(dojo.connect(this._closeButton,"onclick",dojo.hitch(this,"closeWidget",this.onBeforeCloseCallback,this.onAfterCloseCallback)));
this._connections.push(dojo.connect(this._notesScrollableArea,"onEnableScrollerUp",dojo.hitch(this,function(){
dojo.toggleClass(this._scrollerUp,"noteScrollerUp_on",true);
dojo.toggleClass(this._scrollerUp,"noteScrollerUp_off",false);
dojo.toggleClass(this._scrollerTop,"noteScrollerTop_on",true);
dojo.toggleClass(this._scrollerTop,"noteScrollerTop_off",false);
})));
this._connections.push(dojo.connect(this._notesScrollableArea,"onDisableScrollerUp",dojo.hitch(this,function(){
dojo.toggleClass(this._scrollerUp,"noteScrollerUp_off",true);
dojo.toggleClass(this._scrollerUp,"noteScrollerUp_on",false);
dojo.toggleClass(this._scrollerTop,"noteScrollerTop_off",true);
dojo.toggleClass(this._scrollerTop,"noteScrollerTop_on",false);
})));
this._connections.push(dojo.connect(this._notesScrollableArea,"onEnableScrollerDown",dojo.hitch(this,function(){
dojo.toggleClass(this._scrollerDown,"noteScrollerDown_on",true);
dojo.toggleClass(this._scrollerDown,"noteScrollerDown_off",false);
dojo.toggleClass(this._scrollerBottom,"noteScrollerBottom_on",true);
dojo.toggleClass(this._scrollerBottom,"noteScrollerBottom_off",false);
})));
this._connections.push(dojo.connect(this._notesScrollableArea,"onDisableScrollerDown",dojo.hitch(this,function(){
dojo.toggleClass(this._scrollerDown,"noteScrollerDown_off",true);
dojo.toggleClass(this._scrollerDown,"noteScrollerDown_on",false);
dojo.toggleClass(this._scrollerBottom,"noteScrollerBottom_off",true);
dojo.toggleClass(this._scrollerBottom,"noteScrollerBottom_on",false);
})));
},closeWidget:function(_5,_6){
var _7=true;
if(_5){
_7=_5();
}
if(_7){
this._innerCloseWidget(_6);
}
},_innerCloseWidget:function(_8){
this.destroyRecursive(false);
if(_8){
_8();
}
},getNotesScrollableArea:function(){
return this._notesScrollableArea;
},destroy:function(){
dojo.forEach(this._connections,dojo.disconnect,this);
this.inherited(arguments);
}});
dojo.declare("Px.Ex.DataDealNotes.NotesScrollableArea",[dijit.layout.LayoutContainer],{Height:390,ScrollInterval:500,_maxHeight:100000,_spaceFromBottom:0,_fullyVisibleNoteIndices:undefined,constructor:function(_9){
dojo.mixin(this,_9);
},startup:function(){
dojo.style(this.containerNode,"minHeight",this.Height+"px");
dojo.style(this.containerNode,"maxHeight",this._maxHeight+"px");
this.inherited(arguments);
},getNode:function(){
return this.containerNode;
},addNote:function(_a){
if(dojo.isIE){
try{
this.addChild(_a);
}
catch(e){
}
}else{
this.addChild(_a);
}
},addNoteToBottom:function(_b){
if(dojo.isIE){
try{
this.addChild(_b,0);
}
catch(e){
}
}else{
this.addChild(_b,0);
}
dojo.style(_b.getNode(),"overflow","hidden");
dojo.style(_b.getNode(),"position","absolute");
var _c=this.countNotes();
if(_c>1){
var _d=this.getChildren()[1];
dojo.style(_b.getNode(),"top",(dojo.style(_d.getNode(),"top")+dojo.style(_d.getNode(),"height"))+"px");
if(_b.declaredClass!="Px.Ex.DataDealNotes.EmptyNote"){
_b.setFooter("1/"+_c);
}
}else{
if(_c==1){
dojo.style(_b.getNode(),"top",(this._maxHeight-dojo.style(_b.getNode(),"height"))+"px");
}
}
this.scrollToBottom();
},countNotes:function(){
return this.getChildren().length;
},alignNotesToBottom:function(){
this._spaceFromBottom=0;
var _e=this.getChildren();
for(i=0;i<_e.length;i++){
var _f=dojo.style(_e[i].getNode(),"height");
this._spaceFromBottom+=_f;
dojo.style(_e[i].getNode(),"position","absolute");
dojo.style(_e[i].getNode(),"top",(this._maxHeight-this._spaceFromBottom)+"px");
dojo.style(_e[i].getNode(),"overflow","hidden");
}
},_updateScrollerState:function(){
this._fullyVisibleNoteIndices=this.getFullyVisibleNoteIndices();
var _10=this.getChildren();
if(this._fullyVisibleNoteIndices.length>0){
if(this._fullyVisibleNoteIndices[this._fullyVisibleNoteIndices.length-1]==(_10.length-1)){
this.onDisableScrollerUp();
}else{
this.onEnableScrollerUp();
}
if(this._fullyVisibleNoteIndices[0]==0){
this.onDisableScrollerDown();
}else{
this.onEnableScrollerDown();
}
}
},onEnableScrollerUp:function(){
},onDisableScrollerUp:function(){
},onEnableScrollerDown:function(){
},onDisableScrollerDown:function(){
},onPostCreate:function(){
var _11=this.getChildren();
if(this.hasChildren()){
dojo.forEach(_11,dojo.hitch(this,function(v){
dojo.style(v.getNode(),"display","block");
dojo.style(v.getNode(),"visibility","visible");
dojo.style(v.getNode(),"opacity","1");
}));
}
},resetToStart:function(){
var _12=this.getChildren();
if(this.hasChildren()){
this.alignNotesToBottom();
dijit.scrollIntoView(_12[0].getNode());
var _13=false;
dojo.forEach(_12,dojo.hitch(this,function(v){
if(v.shrinkToHeight){
if(v.shrinkToHeight(dojo.style(this.getNode(),"height"))){
_13=true;
}
}
}));
if(dojo.isFF||_13){
this.alignNotesToBottom();
dijit.scrollIntoView(_12[0].getNode());
}
this._updateScrollerState();
this.onPostCreate();
}
},getFullyVisibleNoteIndices:function(){
retval=[];
var _14=this.getChildren();
var _15=this.containerNode.scrollTop;
var _16=_15+this.Height;
for(var i=0;i<_14.length;i++){
var _17=_14[i].getNode();
var _18=dojo.style(_17,"top");
var _19=_18+dojo.style(_17,"height");
var _1a=0;
if(dojo.isFF){
_1a=1;
}
if((_18>=_15-_1a)&&(_19<=_16+_1a)){
retval.push(i);
}else{
if(retval.length>0){
break;
}
}
}
return retval;
},scrollToBottom:function(_1b,_1c){
var _1d=this.getChildren();
if(_1d.length){
var _1e=true;
if(_1b){
_1e=_1b();
}
if(_1e){
var _1f=this.containerNode.scrollTop;
dijit.scrollIntoView(_1d[0].getNode());
var _20=this.containerNode.scrollTop;
this.containerNode.scrollTop=_1f;
$("#"+this.containerNode.id).animate({scrollTop:_20},this.ScrollInterval,dojo.hitch(this,function(){
this._updateScrollerState();
if(_1c){
_1c();
}
}));
}
}
},scrollToTop:function(_21,_22){
var _23=this.getChildren();
if(_23.length){
var _24=true;
if(_21){
_24=_21();
}
if(_24){
$("#"+this.containerNode.id).animate({scrollTop:dojo.style(_23[_23.length-1].getNode(),"top")},this.ScrollInterval,dojo.hitch(this,function(){
this._updateScrollerState();
if(_22){
_22();
}
}));
}
}
},advanceUp:function(_25,_26){
var _27=true;
if(_25){
_27=_25();
}
if(_27){
var _28=this.getChildren();
var _29=_28.length;
if(this._fullyVisibleNoteIndices.length>0){
var _2a=this._fullyVisibleNoteIndices[this._fullyVisibleNoteIndices.length-1];
if(_2a<(_29-1)){
$("#"+this.containerNode.id).animate({scrollTop:dojo.style(_28[_2a+1].getNode(),"top")},this.ScrollInterval,dojo.hitch(this,function(){
this._updateScrollerState();
if(_26){
_26();
}
}));
}
}
}
},advanceDown:function(_2b,_2c){
var _2d=true;
if(_2b){
_2d=_2b();
}
if(_2d){
var _2e=this.getChildren();
var _2f=this.getFullyVisibleNoteIndices();
var _30=_2e.length;
if(_2f.length>0){
var _31=_2f[0];
if(_31>0){
var _32=this.containerNode.scrollTop;
dijit.scrollIntoView(_2e[_31-1].getNode());
var _33=this.containerNode.scrollTop;
this.containerNode.scrollTop=_32;
$("#"+this.containerNode.id).animate({scrollTop:_33},this.ScrollInterval,dojo.hitch(this,function(){
this._updateScrollerState();
if(_2c){
_2c();
}
}));
}
}
}
},destroy:function(){
this.inherited(arguments);
}});
dojo.declare("Px.Ex.DataDealNotes.NoteBaseClass",[dijit.layout.ContentPane],{NoteIcon:undefined,NoteIconTooltip:undefined,NoteUserFullName:"",NoteDate:"",NoteContent:"",MarginTop:5,Width:350,_CornerRadius:15,_PaddingLeft:5,_PaddingRight:5,_PaddingTop:5,_PaddingBottom:5,_BorderStyle:"solid",_BorderWidth:3,_BorderColor:"#e9e9eb",_UserNameColor:"#42daf1",_NoteIconWidth:47,_NoteIconHeight:47,_SpaceBetweenIconAndContent:5,_numberOfSpacesBetweenUserNameAndDate:2,_FooterColor:"#c1c1c6",_FooterFontSize:"80%",_FooterTextAlign:"Right",_Opacity:1,DataDealCode:0,constructor:function(_34){
dojo.mixin(this,_34);
},startup:function(){
this.inherited(arguments);
dojo.style(this.containerNode,"maxWidth",this.Width+"px");
dojo.style(this.containerNode,"opacity",this._Opacity);
this._noteDiv=dojo.create("div",{},this.containerNode);
dojo.style(this._noteDiv,"borderStyle",this._BorderStyle);
dojo.style(this._noteDiv,"borderColor",this._BorderColor);
dojo.style(this._noteDiv,"borderWidth",this._BorderWidth+"px");
this.createNoteLayout();
this.decorateNote();
this.styleNote();
this.addEnvelopeStyle();
this.addFooter();
},addEnvelopeStyle:function(){
this._noteBottomRight=dojo.create("div",{className:"noteBottomRight"},this._noteDiv);
dojo.style(this._noteBottomRight,"left",(this.Width-dojo.style(this._noteBottomRight,"width")-this._PaddingRight-this._PaddingLeft+this._BorderWidth)+"px");
},addFooter:function(){
this._noteFooter=dojo.create("div",{},this._noteDiv);
dojo.style(this._noteFooter,"position","relative");
dojo.style(this._noteFooter,"top","-33px");
dojo.style(this._noteFooter,"width",(this.Width-dojo.style(this._noteBottomRight,"width")-this._PaddingRight-this._PaddingLeft+this._BorderWidth)+"px");
dojo.style(this._noteFooter,"textAlign",this._FooterTextAlign);
dojo.style(this._noteFooter,"left",(this.Width-dojo.style(this._noteBottomRight,"width")-dojo.style(this._noteFooter,"width")-this._PaddingRight-this._PaddingLeft+this._BorderWidth)+"px");
dojo.style(this._noteFooter,"fontSize",this._FooterFontSize);
dojo.style(this._noteFooter,"color",this._FooterColor);
},setFooter:function(_35){
if(this._noteFooter&&_35){
this._noteFooter.innerHTML=_35;
}
},getFooter:function(){
return this._noteFooter.innerHTML;
},styleNote:function(){
dojo.style(this._noteDiv,"width",(this.Width-this._PaddingLeft-this._PaddingRight-(2*this._BorderWidth))+"px");
dojo.style(this._noteDiv,"marginTop",this.MarginTop+"px");
dojo.style(this._noteDiv,"marginBottom",this._CornerRadius+"px");
dojo.style(this._noteDiv,"paddingLeft",this._PaddingLeft+"px");
dojo.style(this._noteDiv,"paddingRight",this._PaddingRight+"px");
dojo.style(this._noteDiv,"paddingTop",this._PaddingTop+"px");
dojo.style(this._noteDiv,"height",dojo.style(this._table,"height")+"px");
},decorateNote:function(){
var _36=new curvyCorners({tl:false,tr:false,bl:{radius:this._CornerRadius},br:false,antiAlias:true,autoPad:false,validTags:["div"]},this._noteDiv);
_36.applyCornersToAll();
},getNode:function(){
return this.containerNode;
},createNoteLayout:function(){
this._table=dojo.create("table",{},this._noteDiv);
this._tbody=dojo.create("tbody",{},this._table);
this._tr=dojo.create("tr",{},this._tbody);
this._leftTd=dojo.create("td",{},this._tr);
this._rightTd=dojo.create("td",{},this._tr);
dojo.style(this._leftTd,"verticalAlign","Top");
this._iconDiv=dojo.create("div",{},this._leftTd);
dojo.style(this._iconDiv,"background","url(\""+this.NoteIcon+"\") center center no-repeat");
dojo.style(this._iconDiv,"width",this._NoteIconWidth+"px");
dojo.style(this._iconDiv,"height",this._NoteIconHeight+"px");
this._iconDiv.title=this.NoteIconTooltip;
dojo.style(this._rightTd,"verticalAlign","top");
dojo.style(this._rightTd,"paddingLeft",this._SpaceBetweenIconAndContent+"px");
dojo.style(this._rightTd,"width","100%");
this._restDiv=dojo.create("div",{},this._rightTd);
dojo.style(this._restDiv,"marginTop","-4px");
this.drawRightSide(this._restDiv);
},drawRightSide:function(_37){
},destroy:function(){
this.inherited(arguments);
}});
dojo.declare("Px.Ex.DataDealNotes.EmptyNote",[Px.Ex.DataDealNotes.NoteBaseClass],{_NoteIconHeight:10,_EndHeight:51,_NewBorderColor:"#def6f4",_NewNoteIconHeight:47,_connections:[],_hex2rgb:function(hex){
if(hex.charAt(0)=="#"){
hex=hex.slice(1);
}
hex=hex.toUpperCase();
var _38="0123456789ABCDEF";
var _39=new Array(3);
var k=0;
var _3a,_3b;
for(var i=0;i<6;i+=2){
_3a=_38.indexOf(hex.charAt(i));
_3b=_38.indexOf(hex.charAt(i+1));
_39[k]=(_3a*16)+_3b;
k++;
}
return "rgb("+_39[0]+", "+_39[1]+", "+_39[2]+")";
},drawRightSide:function(_3c){
dojo.style(this._iconDiv,"visibility","hidden");
_3c.innerHTML=this.Messages["NOTESWIDGET_NewNote_Message_InitialMessage"];
_3c.title=this.Messages["NOTESWIDGET_NewNote_Tooltip_ClickToCreate"];
dojo.style(_3c,"cursor","pointer");
this._noteOriginalHeight=dojo.style(this._noteDiv,"height");
this._iconOriginalHeight=dojo.style(this._iconDiv,"height");
this._connections.push(dojo.connect(_3c,"onclick",dojo.hitch(this,"makeEditable")));
},makeEditable:function(){
var _3d=this.getNode().parentNode;
var _3e=dojo.query(".noteBottomRight",this.containerNode)[0];
var _3f=_3d.scrollTop;
var _40=dojo.style(_3e,"top");
var _41=dojo.animateProperty({node:this._noteDiv,properties:{height:{end:this._EndHeight}},onAnimate:dojo.hitch(this,function(){
var _42=dojo.style(this.containerNode,"height")-this._noteOriginalHeight;
_3d.scrollTop=_3f+_42;
_3e.top=_40+_42;
}),onBegin:dojo.hitch(this,function(){
try{
dojo.forEach(this._connections,dojo.disconnect,this);
dojo.style(this._restDiv,"cursor","default");
dojo.style(this._iconDiv,"height",this._NewNoteIconHeight+"px");
dojo.style(this._iconDiv,"backgroundUrl",this.NoteIcon+"px");
dojo.style(this._iconDiv,"visibility","visible");
}
catch(e){
}
}),onEnd:dojo.hitch(this,function(){
var _43=dojo.style(this.containerNode,"height")-this._noteOriginalHeight;
_3d.scrollTop=_3f+_43;
_3e.top=_40+_43;
dojo.toggleClass(_3e,"noteBottomRight_edited");
dojo.style(this._noteDiv,"borderColor",this._NewBorderColor);
var _44=dojo.query("div > div > div > div",this.containerNode);
dojo.forEach(_44,dojo.hitch(this,function(v){
if(dojo.isIE){
if(dojo.style(v,"backgroundColor")==this._BorderColor){
dojo.style(v,"backgroundColor",this._NewBorderColor);
}
}else{
if(dojo.style(v,"backgroundColor")==this._hex2rgb(this._BorderColor)){
dojo.style(v,"backgroundColor",this._NewBorderColor);
}
}
}));
dojo.style(dojo.query("div > div > div:first-child",this.containerNode)[0],"borderBottomColor",this._NewBorderColor);
dojo.style(dojo.query("div > div > div:first-child",this.containerNode)[0],"borderRightColor",this._NewBorderColor);
var _45=dojo.style(this._restDiv,"width");
var _46=this._NewNoteIconHeight-5;
this._restDiv.innerHTML="";
dojo.require("dijit.form.SimpleTextarea");
this._textArea=new dijit.form.SimpleTextarea({name:"Here",style:"min-width:"+_45+"px;width:"+_45+"px;max-width:"+_45+"px;min-height:"+_46+"px;height:"+_46+"px;max-height:"+_46+"px;border-style:none;"});
this._textArea.placeAt(this._restDiv);
this._textArea.startup();
this._textArea.focus();
this._buttonsTable=dojo.create("table",{},this._noteFooter);
dojo.style(this._buttonsTable,"marginLeft","auto");
if(dojo.isIE){
dojo.style(this._buttonsTable,"marginTop","6px");
}else{
dojo.style(this._buttonsTable,"marginTop","8px");
}
this._buttonsTbody=dojo.create("tbody",{},this._buttonsTable);
this._buttonsTr=dojo.create("tr",{},this._buttonsTbody);
this._cancelButtonTd=dojo.create("td",{},this._buttonsTr);
this._cancelButton=dojo.create("div",{className:"noteCancelButton"},this._cancelButtonTd);
this._cancelButton.title=this.Messages["NOTESWIDGET_NewNote_Tooltip_Cancel"];
this._saveButtonTd=dojo.create("td",{},this._buttonsTr);
this._saveButton=dojo.create("div",{className:"noteSaveButton"},this._saveButtonTd);
this._saveButton.title=this.Messages["NOTESWIDGET_NewNote_Tooltip_Save"];
this._connections.push(dojo.connect(this._cancelButton,"onclick",dojo.hitch(this,"onCancel",null,null)));
this._connections.push(dojo.connect(this._saveButton,"onclick",dojo.hitch(this,"onSave")));
})});
_41.play();
},onSave:function(){
var _47;
this._lastDisplayedValue=this._textArea.attr("displayedValue");
dojo.xhrGet({sync:true,url:"/notes/create-data-deal-note",content:{dataDealCode:this.DataDealCode,note:this._manipulateNoteContent(this._lastDisplayedValue)},load:dojo.hitch(this,function(_48){
_47=_48;
}),error:dojo.hitch(this,function(_49){
_47=_49;
}),handleAs:"json"});
if(_47!=null){
this.onSaveSuccess(_47);
}else{
this.onSaveFailure();
}
},_manipulateNoteContent:function(_4a){
return _4a.replace(/\n/g,"<br>");
},onSaveSuccess:function(_4b){
var _4c=null;
var _4d=dojo.hitch(this,function(){
var _4e=new Px.Ex.DataDealNotes.Note({DataDealCode:this.DataDealCode,NoteIcon:this.NoteIcon,NoteIconTooltip:this.NoteIconTooltip,NoteContent:this._manipulateNoteContent(this._lastDisplayedValue),NoteDate:this._getCurrentDateTime(),NoteUserFullName:Px.Ex.Application.__contactRole.firstName+" "+Px.Ex.Application.__contactRole.lastName,Width:this.Width});
delete this.lastDisplayedValue;
var _4f=dijit.byId(this.getNode().parentNode.id);
try{
_4f.removeChild(this);
}
catch(e){
}
var _50=_4f.getChildren();
var i=1;
dojo.forEach(_50,dojo.hitch(this,function(v){
v.setFooter(++i+"/"+(_50.length+1));
}));
_4f.addNoteToBottom(_4e);
_4f.addNoteToBottom(this);
var _51=dijit.byId(_4e.getNode().parentNode.parentNode.parentNode.parentNode.id);
var _52=_51.teXiServerResponse.notes;
var app=Px.Ex.Application;
_52.splice(0,0,{contactCode:-1,created:_4e.NoteDate,firstName:app.__contactRole.firstName,lastName:app.__contactRole.lastName,noteCode:_4b,noteContent:_4e.NoteContent,userName:app.__userId,userType:1});
});
this.onCancel(_4c,_4d);
},_getCurrentDateTime:function(){
var _53;
dojo.xhrGet({sync:true,url:"/notes/get-current-date-time",content:{},load:dojo.hitch(this,function(_54){
_53=_54;
}),error:dojo.hitch(this,function(){
_53="N/A";
}),handleAs:"json"});
return _53;
},onSaveFailure:function(){
var dlg=new Px.Ex.OKMessageDialog({message:this.Messages["NOTESWIDGET_NewNote_Message_ErrorCreating"]});
dlg.show();
},onCancel:function(_55,_56){
var _57=true;
if(_55){
_57=_55();
}
if(!_57){
return;
}
var _58=dojo.query(".noteBottomRight",this.containerNode)[0];
dojo.toggleClass(_58,"noteBottomRight_edited");
dojo.style(this._noteDiv,"borderColor",this._BorderColor);
var _59=dojo.query("div > div > div > div",this.containerNode);
dojo.forEach(_59,dojo.hitch(this,function(v){
if(dojo.isIE){
if(dojo.style(v,"backgroundColor")==this._NewBorderColor){
dojo.style(v,"backgroundColor",this._BorderColor);
}
}else{
if(dojo.style(v,"backgroundColor")==this._hex2rgb(this._NewBorderColor)){
dojo.style(v,"backgroundColor",this._BorderColor);
}
}
}));
dojo.style(dojo.query("div > div > div:first-child",this.containerNode)[0],"borderBottomColor",this._BorderColor);
dojo.style(dojo.query("div > div > div:first-child",this.containerNode)[0],"borderRightColor",this._BorderColor);
var _5a=this.getNode().parentNode;
var _58=dojo.query(".noteBottomRight",this.containerNode)[0];
var _5b=_5a.scrollTop;
var _5c=dojo.style(_58,"top");
var _5d=dojo.animateProperty({node:this._noteDiv,properties:{height:{end:this._noteOriginalHeight}},onAnimate:dojo.hitch(this,function(){
var _5e=dojo.style(this._noteDiv,"height")-this._noteOriginalHeight;
_5a.scrollTop=_5b-_5e;
_58.top=_5c-_5e;
}),onEnd:dojo.hitch(this,function(){
var _5f=dojo.style(this._noteDiv,"height")-this._noteOriginalHeight;
_5a.scrollTop=_5b-(dojo.style(this._noteDiv,"height")-this._noteOriginalHeight);
_58.top=_5c-_5f;
dojo.style(this._iconDiv,"visibility","hidden");
dojo.style(this._iconDiv,"opacity",1);
dojo.style(this._iconDiv,"height",this._iconOriginalHeight+"px");
this._restDiv.innerHTML="................................................................";
this._restDiv.title="Click to create a new note";
dojo.style(this._restDiv,"cursor","pointer");
dojo.forEach(this._connections,dojo.disconnect,this);
this._noteFooter.innerHTML="";
this._connections.push(dojo.connect(this._restDiv,"onclick",dojo.hitch(this,"makeEditable")));
if(_56){
_56();
}
})});
_5d.play();
},destroy:function(){
dojo.forEach(this._connections,dojo.disconnect,this);
}});
dojo.declare("Px.Ex.DataDealNotes.Note",[Px.Ex.DataDealNotes.NoteBaseClass],{_connections:[],EllipsisOrientation:"before",drawRightSide:function(_60){
this._divTop=dojo.create("div",{id:"divTop"},_60);
var _61=dojo.style(this._divTop,"width");
dojo.style(this._divTop,"maxWidth",_61-5+"px");
dojo.style(this._divTop,"wordWrap","break-word");
this._divTop.innerHTML=this.NoteContent;
this._divBottom=dojo.create("div",{},_60);
dojo.style(this._divBottom,"wordWrap","break-word");
dojo.style(this._divBottom,"color",this._UserNameColor);
this._divBottom.innerHTML="<b>"+this.NoteUserFullName+"</b>";
for(i=0;i<this._numberOfSpacesBetweenUserNameAndDate;i++){
this._divBottom.innerHTML+="&nbsp;";
}
this._divBottom.innerHTML+="<span style=\"font-size: 80%\">"+this.NoteDate+"</span>";
},shrinkToHeight:function(_62){
if(dojo.style(this.getNode(),"height")>_62){
dojo.style(this._divTop,"overflow","hidden");
dojo.style(this._divTop,"maxHeight",(_62-43)+"px");
dojo.style(this._noteDiv,"height",(_62-28)+"px");
var _63=Math.random();
this.setFooter("<img id=\""+_63+"\" src=\"/media/styles/img/ellipsis.png\"></img>&nbsp;&nbsp;"+this.getFooter());
this._connections.push(dojo.connect(dojo.byId(_63+""),"onmouseover",dojo.hitch(this,function(){
dijit.showTooltip(this._divTop.innerHTML,dojo.byId(_63+""),this.EllipsisOrientation);
})));
this._connections.push(dojo.connect(dojo.byId(_63+""),"onmouseout",dojo.hitch(this,function(){
dijit.hideTooltip(dojo.byId(_63+""));
})));
return true;
}else{
return false;
}
},destroy:function(){
dojo.forEach(this._connections,dojo.disconnect,this);
}});
dojo.declare("Px.Ex.DataDealNotes.NotesWidgetWizard",[Px.Ex.DataDealNotes.NotesWidget],{HeightDirection:1,MinHeight:300,MaxHeight:450,MinWidth:150,MaxWidth:400,Margin:5,WithConnector:true,teXiServerResponse:undefined,addPermission:false,constructor:function(_64){
dojo.mixin(this,_64);
},onAfterWidthHeightManipulation:function(_65,_66,_67){
},manipulateWidthHeight:function(){
var _68=dojo.coords(this.containerNode);
var _69=dijit.getViewport();
var _6a=1;
if(this.teXiServerResponse.minHeight!=undefined){
this.MinHeight=this.teXiServerResponse.minHeight;
}
if(this.teXiServerResponse.maxHeight!=undefined){
this.MaxHeight=this.teXiServerResponse.maxHeight;
}
if(this.teXiServerResponse.minWidth!=undefined){
this.MinWidth=this.teXiServerResponse.minWidth;
}
if(this.teXiServerResponse.maxWidth!=undefined){
this.MaxWidth=this.teXiServerResponse.maxWidth;
}
if(this.teXiServerResponse.margin!=undefined){
this.Margin=this.teXiServerResponse.margin;
}
if((_68.y+31>=this.MinHeight)&&(_68.y<=this.MaxHeight)){
this.Height=_68.y;
this.HeightDirection=1;
}else{
if(_68.y>this.MaxHeight){
this.Height=this.MaxHeight;
this.HeightDirection=1;
}else{
if(((_69.h-_68.y)>=this.MinHeight)&&((_69.h-_68.y)<=this.MaxHeight)){
this.Height=_69.h-_68.y;
this.HeightDirection=-1;
}else{
if((_69.h-_68.y)>this.MaxHeight){
this.Height=this.MaxHeight;
this.HeightDirection=-1;
}else{
_6a=-1;
}
}
}
}
this.Height-=this.Margin;
var _6b=_69.w-_68.x;
if((_6b>=this.MinWidth)&&(_6b<=this.MaxWidth)){
this.Width=_6b;
}else{
if(_6b>this.MaxWidth){
this.Width=this.MaxWidth;
}else{
_6a=-1;
}
}
this.Width-=this.Margin;
this.onAfterWidthHeightManipulation(this.Width,this.Height,_6a);
},destroy:function(){
this.inherited(arguments);
if(this._connector){
dojo.fadeOut({node:this._connector,duration:500,onEnd:dojo.hitch(this,function(){
dojo.destroy(this._connector);
})}).play();
}
},startup:function(){
this.manipulateWidthHeight();
this.inherited(arguments);
if(this.WithConnector){
this._connector=dojo.create("div",{className:"noteWidgetDataBuyConnector"},this.containerNode,"after");
dojo.style(this._connector,"opacity","0");
dojo.style(this._connector,"top",dojo.style(this._scrollerUp,"height")+dojo.style(this._scrollableAreaDiv,"height")-(2*this.BorderThickness)-5+"px");
dojo.fadeIn({node:this._connector,duration:500}).play();
}
this.getNotesScrollableArea().onPostCreate=dojo.hitch(this.getNotesScrollableArea(),function(){
var _6c=dojo.hitch(this,function(_6d,_6e){
var fn=arguments.callee;
if(_6d<_6f.length){
var _70=_6f[_6d].getNode();
if(dojo.isFF){
var _71=dojo.style(_70,"top");
}else{
var _71=dojo.style(_70,"top");
}
dojo.style(_70,"zIndex",_6f.length-_6d);
var _72=dojo.animateProperty({node:_70,properties:{top:{start:_6e,end:_71},opacity:{start:0,end:1}},duration:200});
dojo.connect(_72,"onEnd",dojo.hitch(this,function(){
fn(_6d+1,_71);
}));
_72.play();
}
});
var _6f=this.getChildren();
if(_6f.length){
dojo.animateProperty({node:_6f[0].getNode(),properties:{left:{start:-350,end:0},opacity:{start:1,end:1}},duration:500,onEnd:dojo.hitch(this,function(){
if(_6f.length>1){
_6c(1,dojo.style(_6f[0].getNode(),"top"));
}
})}).play();
}
});
this._innerCloseWidget=dojo.hitch(this,function(_73){
dojo.style(this.containerNode,"position","absolute");
dojo.style(this.containerNode,"overflow","hidden");
var _74=dojo.animateProperty({node:this.containerNode,properties:{top:{end:this.Height-dojo.style(this._scrollerDown,"height")},width:{end:0},height:{end:0}},duration:2000,onEnd:dojo.hitch(this,function(){
this.destroyRecursive(false);
if(_73){
_73();
}
})});
_74.play();
});
if(this.teXiServerResponse&&this.teXiServerResponse.notes){
var _75=this.teXiServerResponse.notes.length;
if(this.addPermission){
tempNotePane=new Px.Ex.DataDealNotes.EmptyNote({NoteIcon:this._getUserTypeIcon(1),NoteIconTooltip:this._getUserTypeTitle(1),_Opacity:0,Width:this.Width,DataDealCode:this.teXiServerResponse.dataDealCode,Messages:this.teXiServerResponse.messages});
this.getNotesScrollableArea().addNote(tempNotePane);
}
var i=1;
dojo.forEach(this.teXiServerResponse.notes,dojo.hitch(this,function(v){
tempNotePane=new Px.Ex.DataDealNotes.Note({NoteUserFullName:v["firstName"]+" "+v["lastName"],NoteContent:v["noteContent"],NoteDate:v["created"],NoteIcon:this._getUserTypeIcon(v["userType"]),NoteIconTooltip:this._getUserTypeTitle(v["userType"]),_Opacity:0,Width:this.Width,DataDealCode:this.teXiServerResponse.dataDealCode,Messages:this.teXiServerResponse.messages});
this.getNotesScrollableArea().addNote(tempNotePane);
tempNotePane.setFooter(i+"/"+_75);
i++;
}));
this.getNotesScrollableArea().resetToStart();
}
},_getUserTypeTitle:function(_76){
for(var i in this.teXiServerResponse.userTypes){
if(this.teXiServerResponse.userTypes[i]["id"]==_76){
return this.teXiServerResponse.userTypes[i]["title"];
}
}
return "";
},_getUserTypeIcon:function(_77){
for(var i in this.teXiServerResponse.userTypes){
if(this.teXiServerResponse.userTypes[i]["id"]==_77){
return this.teXiServerResponse.urlPrefix+this.teXiServerResponse.userTypes[i]["icon"]+this.teXiServerResponse.urlSuffix;
}
}
return "";
}});
dojo.declare("Px.Ex.DataDealNotes.NotesWidgetDialog",[dijit.Dialog],{templateString:"<div class=\"dijitDialog\" tabindex=\"-1\" waiRole=\"dialog\" waiState=\"labelledby-${id}_title\" style=\"border-color: transparent; border: none; background-color: transparent;\">"+"<div dojoAttachPoint=\"containerNode\" class=\"dijitDialogPaneContent\" style=\"border: none; background-color: transparent; padding: 0px 0px;\"></div>"+"</div>",teXiServerResponse:undefined,addPermission:false,y:0,x:0,show:function(){
this.inherited(arguments);
dojo.style(this.containerNode.parentNode,"position","absolute");
dojo.style(this.containerNode.parentNode,"top",this.y+"px");
dojo.style(this.containerNode.parentNode,"left",this.x+"px");
var _78=dojo.create("table",{id:"myTable"},this.containerNode);
var _79=dojo.create("tbody",{},_78);
var tr=dojo.create("tr",{},_79);
var _7a=dojo.create("td",{},tr);
dojo.style(_7a,"paddingRight","5px");
var _7b=dojo.create("td",{},tr);
this._notesWidgetWizard=new Px.Ex.DataDealNotes.NotesWidgetWizard({teXiServerResponse:this.teXiServerResponse,addPermission:this.addPermission,onAfterCloseCallback:dojo.hitch(this,function(){
this.hide();
this.destroyRecursive(false);
}),WithConnector:false});
dojo.connect(this._notesWidgetWizard,"onAfterWidthHeightManipulation",dojo.hitch(this,function(_7c,_7d,_7e){
if(_7e==-1){
var _7f=dijit.byId(this.containerNode.parentNode.id);
_7f.hide();
_7f.destroyRecursive(false);
}else{
this._connector=dojo.create("div",{className:"noteWidgetConnector"},_7a);
dojo.style(this._connector,"opacity","0");
dojo.fadeIn({node:this._connector,duration:2000}).play();
if(this._notesWidgetWizard.HeightDirection==-1){
dojo.style(_7a,"verticalAlign","top");
}else{
if(this._notesWidgetWizard.HeightDirection==1){
dojo.style(_7a,"verticalAlign","bottom");
dojo.style(this.containerNode.parentNode,"top",(this.y-_7d+dojo.style(this._connector,"height"))+"px");
}
}
}
}));
this._notesWidgetWizard.placeAt(_7b);
this._notesWidgetWizard.startup();
this._notesWidgetWizard._innerCloseWidget=dojo.hitch(this._notesWidgetWizard,function(_80){
var _81=this.HeightDirection;
dojo.style(this.containerNode,"overflow","hidden");
if(_81==-1){
var _82=dojo.animateProperty({node:this.containerNode,properties:{top:{end:this.Height-dojo.style(this._scrollerDown,"height")},width:{end:0},height:{end:0}},duration:2000,onEnd:dojo.hitch(this,function(){
this.destroyRecursive(false);
if(_80){
_80();
}
})});
_82.play();
}else{
var _83=dojo.byId("myTable");
dojo.style(_83,"position","fixed");
var _84=dojo.style(this.containerNode,"height");
var _85=dojo.animateProperty({node:this.containerNode,properties:{width:{end:0},height:{end:0}},duration:2000,onAnimate:dojo.hitch(this,function(){
var _86=_84-this.containerNode.style.height;
this.containerNode.scrollTop=_86;
}),onEnd:dojo.hitch(this,function(){
var _87=_84-this.containerNode.style.height;
this.containerNode.scrollTop=_87;
this.destroyRecursive(false);
if(_80){
_80();
}
})});
var _88=dojo.animateProperty({node:_83,properties:{top:{end:this.Height}},duration:2000});
dojox.fx.combine([_85,_88]).play();
}
});
},destroy:function(){
this._notesWidgetWizard.destroyRecursive(true);
this.inherited(arguments);
}});
dojo.declare("Px.Ex.ConfigMetaViewerScreen",[Px.Ex.XhrMixin],{DIV_CONTENT:"divContent",_mostUpdatedMetaTags:undefined,_serverMonitorViews:undefined,_displayVersionColor:undefined,_connections:[],draw:function(){
this.createScreen();
this.getMostUpdatedMetaTags();
this.getServerMonitorViews();
},createScreen:function(){
this._displayVersionColor=dojo.getComputedStyle(dojo.query(".texi-logo-text")[0]).color;
var _1=dojo.byId(this.DIV_CONTENT);
var _2=dojo.create("div",{id:"infoPanelDiv"},_1);
var _3=dojo.create("div",{id:"serversPanelDiv",innerHTML:Px.Ex.Application.getWaitHtml()},_1);
dojo.style(_3,"marginTop","10px");
},getMostUpdatedMetaTags:function(){
dojo.xhrGet({url:"/exelate/get-most-updated-meta-tags",preventCache:true,load:dojo.hitch(this,function(_4){
this._mostUpdatedMetaTags=_4;
this.createInfoPanel();
}),error:dojo.hitch(this,"showInfoPanelError"),handleAs:"json"});
},showInfoPanelError:function(_5){
alert("An error prevented the screen from loading correctly. Please refresh.");
},getServerMonitorViews:function(){
dojo.xhrGet({url:"/exelate/get-server-monitor-views",preventCache:true,load:dojo.hitch(this,function(_6){
this._serverMonitorViews=_6;
this.waitForMostUpdatedMetaTags();
}),handleAs:"json"});
},waitForMostUpdatedMetaTags:function(){
if(this._interval){
if(this._mostUpdatedMetaTags){
try{
clearInterval(this._interval);
delete this._interval;
}
catch(e){
}
this.updateMostUpdatedCodeVersion();
this.createServersPanel();
}
}else{
if(this._mostUpdatedMetaTags){
this.updateMostUpdatedCodeVersion();
this.createServersPanel();
}else{
this._interval=setInterval(dojo.hitch(this,"waitForMostUpdatedMetaTags"),500);
}
}
},createServersPanel:function(){
var _7=dojo.byId("serversPanelDiv");
_7.innerHTML="";
var _8=dojo.create("div",{id:"serversPanelDivHeader",innerHTML:"Current Data"},_7);
dojo.style(_8,"color","#114980");
dojo.style(_8,"fontWeight","bold");
var _9=dojo.create("div",{id:"serversGridDiv"},_7);
var _a=this.getServersGridData();
var _b=this.getServersGridStructure();
this._serversGridStore=new dojo.data.ItemFileReadStore({clearOnClose:true,data:_a});
this._serversGrid=new dojox.grid.DataGrid({loadingMessage:Px.Ex.Application.getWaitHtml(),store:this._serversGridStore,query:{host:"*"},queryOptions:{ignoreCase:true},clientSort:true,style:{width:"100%"},autoHeight:true,selectionMode:"none",selectable:true,onStyleRow:function(){
},canSort:function(_c){
return true;
},structure:_b},_9);
this._serversGrid.startup();
this._serversGrid._refresh();
this._serversGrid.setSortIndex(0,true);
this._connections.push(dojo.connect(this._serversGrid,"onCellMouseOver",dojo.hitch(this,function(e){
if(e.cell.index>=2){
var _d=this._serversGridStore.getValue(this._serversGrid.getItem(e.rowIndex),e.cell._props.field);
if(_d&&(_d.charAt(0)=="F")){
var _e=this.parseTooltip(_d.substring(1));
dijit.showTooltip(_e,e.cellNode.firstChild);
}
}else{
if(e.cell.index==1){
var _d=this._serversGridStore.getValue(this._serversGrid.getItem(e.rowIndex),e.cell._props.field);
if(_d&&(_d.charAt(0)=="F")){
var _e=_d.substring(1);
dijit.showTooltip(_e,e.cellNode.firstChild);
}
}
}
})));
this._connections.push(dojo.connect(this._serversGrid,"onCellMouseOut",dojo.hitch(this,function(e){
if(e.cell.index>=1){
dijit.hideTooltip(e.cellNode.firstChild);
}
})));
},createInfoPanel:function(){
var _f=dojo.byId("infoPanelDiv");
var _10=dojo.create("div",{id:"infoPanelDivHeader",innerHTML:"Most Updated Data"},_f);
dojo.style(_10,"color","#114980");
dojo.style(_10,"fontWeight","bold");
var _11=dojo.create("div",{id:"highestCodeVersionDiv"},_f);
var _12=dojo.create("div",{id:"infoGridDiv"},_f);
var _13=this.getInfoGridData();
var _14=this.getInfoGridStructure();
this._infoGridStore=new dojo.data.ItemFileReadStore({clearOnClose:true,data:_13});
this._infoGrid=new dojox.grid.DataGrid({loadingMessage:Px.Ex.Application.getWaitHtml(),store:this._infoGridStore,query:{FILE:"*"},queryOptions:{ignoreCase:true},clientSort:true,style:{width:"100%"},autoHeight:true,selectionMode:"none",selectable:true,onStyleRow:function(){
},canSort:function(_15){
return true;
},structure:_14},_12);
this._infoGrid.startup();
this._infoGrid._refresh();
this._infoGrid.setSortIndex(0,true);
},countMetaTagFields:function(){
var _16=0;
for(var i in this._mostUpdatedMetaTags){
if(this._mostUpdatedMetaTags[i]["meta"][0]){
for(var _17 in this._mostUpdatedMetaTags[i]["meta"][0]){
_16++;
}
return _16;
}
}
return 0;
},countContentFields:function(){
for(var i in this._serverMonitorViews){
var _18=0;
for(var _19 in this._serverMonitorViews[i]["content"]){
_18++;
}
if(_18>0){
return _18;
}
}
return 0;
},parseTooltip:function(_1a){
var _1b="";
var _1c=_1a.split("=");
for(var i in _1c){
var _1d=_1c[i].split("~");
_1b+=_1d[0]+" = "+_1d[1]+"<br>";
}
return _1b;
},getServersGridStructure:function(){
formatterComparisonStatus=dojo.hitch(this,function(_1e,_1f){
if(_1e.charAt(0)=="T"){
return "<div class=\"configMetaViewer_infoPanel_success\"></div>";
}else{
if(_1e.charAt(0)=="F"){
return "<div class=\"configMetaViewer_infoPanel_error\"></div>";
}
}
});
var _20=[{cells:[[{name:"Host",field:"host",noresize:true,width:"120px",headerStyles:"text-align: center;"},{name:"Ver.",field:"CODE-VERSION",width:"40px",noresize:true,cellStyles:"text-align: center;",headerStyles:"text-align: center;",formatter:formatterComparisonStatus}]]}];
var _21=this.countContentFields();
if(_21!=0){
var _22=(872-160)/_21;
for(var _23 in this._serverMonitorViews[0]["content"]){
if(_23!="CODE-VERSION"){
_21--;
var _24;
if(_21>1){
_24=_22+"px";
}else{
_24="100%";
}
_20[0]["cells"][0].push({name:_23,field:_23,noresize:true,width:_24,cellStyles:"text-align: center;",headerStyles:"text-align: center;",formatter:formatterComparisonStatus});
}
}
}
return _20;
},getInfoGridStructure:function(){
formatterMetaTagField=dojo.hitch(this,function(_25,_26){
if(_25==undefined){
return "<div class=\"configMetaViewer_infoPanel_error\" title=\"Error reading the file from S3\"></div>";
}else{
return _25;
}
});
var _27=[{cells:[[{name:"FILE",field:"FILE",noresize:true,width:"200px",headerStyles:"text-align: center;"}]]}];
var _28=this.countMetaTagFields();
if(_28!=0){
var _29=((872-200)/_28);
for(var i in this._mostUpdatedMetaTags){
if(this._mostUpdatedMetaTags[i]["meta"][0]){
for(var _2a in this._mostUpdatedMetaTags[i]["meta"][0]){
_28--;
_27[0]["cells"][0].push({name:_2a,field:_2a,noresize:true,width:((_28!=0)?(_29+"px"):"100%"),cellStyles:"text-align: center;",formatter:formatterMetaTagField,headerStyles:"text-align: center;"});
}
return _27;
}
}
}
return _27;
},updateMostUpdatedCodeVersion:function(){
var _2b=0;
dojo.forEach(this._serverMonitorViews,dojo.hitch(this,function(v){
if(v["content"]&&(v["content"]["CODE-VERSION"]!="")){
if(v["content"]["CODE-VERSION"]>_2b){
_2b=v["content"]["CODE-VERSION"];
}
}
}));
dojo.byId("highestCodeVersionDiv").innerHTML="eXelate version: <span id=\"highestVersionCode\">"+_2b+"</span>";
},getServersGridData:function(){
var _2c=[];
dojo.forEach(this._serverMonitorViews,dojo.hitch(this,function(v){
var obj={};
obj["host"]=v["name"];
for(var _2d in v["content"]){
obj[_2d]=this.compareCurrentToMostUpdated(_2d,v["content"][_2d]);
}
_2c.push(obj);
}));
return {identifier:"host",label:"host",items:_2c};
},compareCurrentToMostUpdated:function(_2e,_2f){
var _30=true;
for(var _31 in _2f){
var _32=this.getInfoGridValue(_2e,_31);
if(_32!=null){
if(_2f[_31]!=_32){
_30=false;
break;
}
}
}
if(_30){
return "T";
}else{
return "F"+this.serializeData(_2f);
}
},serializeData:function(_33){
var _34="";
var _35=0;
for(var _36 in _33){
_35++;
_34+=_36+"~"+_33[_36]+"=";
}
if(_35>0){
_34=_34.substring(0,_34.length-1);
}else{
_34=_33;
}
return _34;
},getInfoGridValue:function(_37,_38){
for(var _39 in this._infoGridStore._itemsByIdentity[_37]){
if(_39==_38){
return this._infoGridStore._itemsByIdentity[_37][_39][0];
}
}
return null;
},getInfoGridData:function(){
var _3a=[];
dojo.forEach(this._mostUpdatedMetaTags,dojo.hitch(this,function(v){
var obj={};
obj["FILE"]=v["name"];
if(v["meta"].length>0){
for(var _3b in this._mostUpdatedMetaTags[0]["meta"][0]){
obj[_3b]=v["meta"][0][_3b];
}
}
_3a.push(obj);
}));
return {identifier:"FILE",label:"FILE",items:_3a};
},destroy:function(){
try{
dojo.forEach(this,_connections,dojo.disconnect,this);
}
catch(e){
}
try{
this._infoGridStore.close();
}
catch(e){
}
try{
this._infoGrid.destroyRecursive(false);
}
catch(e){
}
try{
this._serversGridStore.close();
}
catch(e){
}
try{
this._serversGrid.destroyRecursive(false);
}
catch(e){
}
}});
dojo.declare("Px.Ex.TestBedScreen",[Px.Ex.XhrMixin],{draw:function(){
dojo.byId("divContent").innerHTML=Px.Ex.Application.getWaitHtml();
this.createContent(dojo.byId("divContent"));
},createContent:function(_1){
},destroy:function(){
}});

