$jc = jQuery.noConflict();
function waitvisible(gridcontainer)
{
if ($jc(gridcontainer).width()==0)
setTimeout("waitvisible('"+gridcontainer+"')",100);
else
$jc(gridcontainer).reload2();
}
function fluidDialog() {
var $visible = $jc(".ui-dialog:visible");
// each open dialog
$visible.each(function () {
var $this = $jc(this);
var dialog = $this.find(".ui-dialog-content");
if (dialog.dialog("option","fluid")) {
var wWidth = $jc(window).width();
// check window width against dialog width
if (wWidth < (parseInt(dialog.dialog("option","maxWidth")) + 50)) {
// keep dialog from filling entire screen
$this.css("max-width", "90%");
} else {
// fix maxWidth bug
$this.css("max-width", dialog.dialog("option","maxWidth") + "px");
}
//reposition dialog
dialog.dialog("option","position", dialog.dialog("option","position"));
}
});
}
$jc(window).resize(function () {
fluidDialog();
});
$jc(document).on("dialogopen", ".ui-dialog", function (event, ui) {
fluidDialog();
});
window.$ = jQuery;
function initMultiViewCal(container,calendarId,config)
{
$jc(document).ready(function($jc) {
(function( $jc ) {
var def = {
numberOfMonths:6,
viewNew : config.edition,
viewToday : config.btoday,
viewDay : false,
viewWeek : false,
viewMonth : false,
viewNMonth : false,
viewRowMonth : false,
viewNDays : false,
viewList : false,
numberOfDays : 10,
list_start:"", //"","now" or string compatible with strtotime
list_end:"", //"","now" or string compatible with strtotime
list_order:"asc",//asc or desc
list_totalEvents:0, //0 = unlimited
list_eventsPerPage:10,
list_readmore_numberofwords:0, //0 = unlimited,
viewRefresh : config.brefresh,
viewNavigation : config.bnavigation,
view: config.viewdefault, //'day','week','month','nMonth','nDays'
weekstartday:config.start_weekday,
showtooltip:false,
tooltipon:1,
shownavigate:false,
navigateurl:config.url,
target:0,
cssStyle:"ui-darkness",
readonly:!config.edition,
nmonths:12,
dialogWidth:300,
dialogCloseAuto:false,
height:0,
showtooltipdwm:false,
viewWeekDays:[1,1,1,1,1,1,1],
militaryTime:true,
path:"",
hoursStart:0,
hoursEnd:23,
cellheight:42,
hourswidth:52,
rowsByCategory:"",
rowsList:"",
dayWithColumns:"",
dayWithTime:true,
thecontainer:container,
userAdd:true,
userEdit:true,
userDel:true,
userEditOwner:true,
userDelOwner:true,
userOwner:43,
columnsList:false,
rowsList:false,
palette:0,
paletteDefault:"f00"
}
if (config.rowsByCategory!="" && !config.dayWithTime)
config.dayWithTime = false;
config = $jc.extend(def, config);
if (!config.userAdd)
config.viewNew = false;
var tabs = 0;
if (config.viewNew && !config.readonly) tabs++;
if (config.viewToday) tabs++;
if (config.viewDay) tabs++;
if (config.viewWeek) tabs++;
if (config.viewMonth) tabs++;
if (config.viewRowMonth) tabs++;
if (config.viewNDays) tabs++;
if (config.viewList) tabs++;
if (config.viewNMonth) tabs++;
if (config.viewRefresh) tabs++;
if (config.viewNavigation && ((tabs==1 && config.viewList) || (tabs==1 && config.viewNMonth) || (tabs==2 && config.viewList && config.viewNMonth))) config.viewNavigation=false;
if (config.viewNavigation) tabs++;
var string = '
'+
''+
''+
'
'+
'
'+i18n.dcmvcal.loading_data+'
'+
'
'+i18n.dcmvcal.sorry_could_not_load_your_data+'
'+
'
'+
'
'+
'
';
var $container = $jc("#"+container);
if (tabs<=1 && config.viewList)
$jc("#"+container).parent().addClass("mvlist");
if (tabs<=1 && config.viewNMonth)
$jc("#"+container).parent().addClass("mvNMonth");
$container.html(string);
var DATA_FEED_URL = pathCalendar+"&f=datafeed";
var DATA_EDIT_URL = pathCalendar+"&f=edit&month_index="+i18n.dcmvcal.dateformat.month_index+"&delete="+((config.userDel)?"1":"0")+"&palette="+config.palette+"&paletteDefault="+config.paletteDefault+"&calid="+calendarId;
var op = {
numberOfMonths:config.numberOfMonths,
view: config.view,
readonly:config.readonly,
weekstartday: config.weekstartday,
showtooltip:config.showtooltip,
tooltipon:config.tooltipon,
shownavigate:config.shownavigate,
navigateurl:config.navigateurl,
target:config.target,
showday: new Date(),
EditCmdhandler:Edit,
DeleteCmdhandler:Delete,
ViewCmdhandler:View,
onWeekOrMonthToDay:wtd,
onBeforeRequestData: cal_beforerequest,
onAfterRequestData: cal_afterrequest,
onRequestDataError: cal_onerror,
autoload:true,
url: DATA_FEED_URL + "&method=list&calid="+calendarId,
quickAddUrl: DATA_FEED_URL + "&month_index="+i18n.dcmvcal.dateformat.month_index+"&method=add&calid="+calendarId,
quickUpdateUrl: DATA_FEED_URL + "&method=update&calid="+calendarId,
quickDeleteUrl: DATA_FEED_URL + "&method=remove&calid="+calendarId,
dialogWidth:config.dialogWidth,
dialogCloseAuto:config.dialogCloseAuto,
height:config.height
};
op = $jc.extend(config, op);
if (op.startdate && (op.startdate.length>=8) && (op.startdate.length<=10))
{
var i = op.startdate.split("-");
op.startdate = new Date(i[0]*1,i[1]*1-1,i[2]*1);
op.showday = op.startdate;
}
else
op.startdate = "";
if (op.mindate && (op.mindate.length>=8) && (op.mindate.length<=10))
{
var i = op.mindate.split("-");
op.mindate = new Date(i[0]*1,i[1]*1-1,i[2]*1);
}
else
op.mindate = "";
if (op.maxdate && (op.maxdate.length>=8) && (op.maxdate.length<=10))
{
var i = op.maxdate.split("-");
op.maxdate = new Date(i[0]*1,i[1]*1-1,i[2]*1);
}
else
op.maxdate = "";
var $dv = $jc("#calhead"+op.thecontainer);
var _MH = document.documentElement.clientHeight;
var dvH = $dv.height() + 2;
//op.height = _MH - dvH;
//op.height = "100%";
op.eventItems =[];
setTimeout("waitvisible('#gridcontainer"+op.thecontainer+"')",100);
var p = $jc("#gridcontainer"+op.thecontainer).bcalendar(op).BcalGetOp();
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
$jc("#caltoolbar"+op.thecontainer).noSelect();
try {
$jc("#hdtxtshow"+op.thecontainer).datepicker({ picker: "#txtdatetimeshow"+op.thecontainer, showtarget: $jc("#txtdatetimeshow"+op.thecontainer),
onReturn:function(r){
var p = $jc("#gridcontainer"+op.thecontainer).gotoDate(r).BcalGetOp();
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
}
});
} catch(e){};
function cal_beforerequest(type)
{
var t=i18n.dcmvcal.loading_data;
switch(type)
{
case 1:
t=i18n.dcmvcal.loading_data;
break;
case 2:
case 3:
case 4:
t=i18n.dcmvcal.request_processed;
break;
}
$jc("#errorpannel"+op.thecontainer).hide();
$jc("#loadingpannel"+op.thecontainer).html(t);
$jc("#loadingpannel"+op.thecontainer).show();
}
function cal_afterrequest(type)
{
switch(type)
{
case 1:
$jc("#loadingpannel"+op.thecontainer).hide();
break;
case 2:
case 3:
case 4:
$jc("#loadingpannel"+op.thecontainer).html(i18n.dcmvcal.success);
window.setTimeout(function(){ $jc("#loadingpannel"+op.thecontainer).hide();},2000);
break;
}
}
function cal_onerror(type,data)
{
if (type!=2)
$jc("#errorpannel"+op.thecontainer).show();
if (data.Msg=='OVERLAPPING')
alert(i18n.dcmvcal.error_overlapping);
//else
//alert(data.Msg);
}
function Edit(data,pos)
{
if (pos === undefined) pos = "";
var eurl=DATA_EDIT_URL+"&mt="+(config.militaryTime?"true":"false")+"&css="+config.cssStyle+"&lang="+config.language+"&weekstartday="+config.weekstartday+"&hoursStart="+config.hoursStart+"&hoursEnd="+config.hoursEnd+"&id={0}&start={2}&end={3}&isallday={4}";
if(data)
{
var url = StrFormat(eurl,data);
showEditEvent(url,pos);
}
}
function View(data)
{
var str = "";
$jc.each(data, function(i, item){
str += "[" + i + "]: " + item + "\n";
});
}
function Delete(data,callback)
{
$jc.alerts.okButton=i18n.dcmvcal.ok;
$jc.alerts.cancelButton=i18n.dcmvcal.cancel;
hiConfirm(i18n.dcmvcal.are_you_sure_delete, 'Confirm',function(r){ r && callback(0,data[0]);});
}
function wtd(p)
{
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
$jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {
$jc(this).removeClass("ui-state-active");
})
$jc("#showdaybtn"+op.thecontainer).addClass("ui-state-active");
}
//to show day view
try {
$jc("#showdaybtn"+op.thecontainer).click(function(e) {
$jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {
$jc(this).removeClass("ui-state-active");
})
$jc(this).addClass("ui-state-active");
var p = $jc("#gridcontainer"+op.thecontainer).swtichView("day").BcalGetOp();
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
});
} catch(e){};
//to show week view
try {
$jc("#showweekbtn"+op.thecontainer).click(function(e) {
$jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {
$jc(this).removeClass("ui-state-active");
})
$jc(this).addClass("ui-state-active");
var p = $jc("#gridcontainer"+op.thecontainer).swtichView("week").BcalGetOp();
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
});
} catch(e){};
//to show month view
try {
$jc("#showmonthbtn"+op.thecontainer).click(function(e) {
$jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {
$jc(this).removeClass("ui-state-active");
})
$jc(this).addClass("ui-state-active");
var p = $jc("#gridcontainer"+op.thecontainer).swtichView("month").BcalGetOp();
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
});
} catch(e){};
//to show nDays view
try {
$jc("#shownDaysbtn"+op.thecontainer).click(function(e) {
$jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {
$jc(this).removeClass("ui-state-active");
})
$jc(this).addClass("ui-state-active");
var p = $jc("#gridcontainer"+op.thecontainer).swtichView("nDays").BcalGetOp();
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
});
} catch(e){};
//to show List view
try {
$jc("#shownListbtn"+op.thecontainer).click(function(e) {
$jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {
$jc(this).removeClass("ui-state-active");
})
$jc(this).addClass("ui-state-active");
var p = $jc("#gridcontainer"+op.thecontainer).swtichView("list").BcalGetOp();
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
});
} catch(e){};
//to show rowMonth view
try {
$jc("#showrowMonthbtn"+op.thecontainer).click(function(e) {
$jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {
$jc(this).removeClass("ui-state-active");
})
$jc(this).addClass("ui-state-active");
var p = $jc("#gridcontainer"+op.thecontainer).swtichView("rowMonth").BcalGetOp();
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
});
} catch(e){};
//to show nMonth view
try {
$jc("#shownMonthbtn"+op.thecontainer).click(function(e) {
$jc("#caltoolbar"+op.thecontainer+" div.ui-state-active").each(function() {
$jc(this).removeClass("ui-state-active");
})
$jc(this).addClass("ui-state-active");
var p = $jc("#gridcontainer"+op.thecontainer).swtichView("nMonth").BcalGetOp();
if (p && p.datestrshow) {
$jc("#txtdatetimeshow"+op.thecontainer).text(p.datestrshow);
}
});
} catch(e){};
try {
$jc("#showreflashbtn"+op.thecontainer).click(function(e){
$jc("#gridcontainer"+op.thecontainer).reload();
});
} catch(e){};
try {
$jc("#shownICALbtn"+op.thecontainer).click(function(e){
window.location = DATA_FEED_URL.replace("datafeed","ical")+"&id="+calendarId;
});
} catch(e){};
function CallPrint(code)
{
var printWindow = window.open();
printWindow.document.write('\n');
printWindow.document.write('\n');
if (navigator.userAgent.toLowerCase().indexOf("chrome") > -1)
{
}
else
{
printWindow.document.write('\n');
printWindow.document.write('\n');
}
printWindow.document.write('