2013-10-05 15:33:28 +02:00
|
|
|
/**
|
|
|
|
* Calendar - sidebox navigation
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Ralf Becker <RalfBecker@stylite.de>
|
|
|
|
* @package calendar
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sidebox navigation for calendar
|
2013-10-31 15:51:19 +01:00
|
|
|
*
|
2013-10-05 15:33:28 +02:00
|
|
|
*/
|
|
|
|
(function()
|
|
|
|
{
|
|
|
|
var script_tag = document.getElementById('calendar-navigation-script');
|
2014-01-10 18:31:24 +01:00
|
|
|
var current_view_url, link_day_url,link_week_url,link_month_url,flatdate, current_date;
|
2013-10-05 15:33:28 +02:00
|
|
|
if (script_tag)
|
|
|
|
{
|
|
|
|
current_view_url = script_tag.getAttribute('data-current-view-url');
|
2014-01-10 18:31:24 +01:00
|
|
|
link_day_url = script_tag.getAttribute('data-link-day-url');
|
|
|
|
link_week_url = script_tag.getAttribute('data-link-week-url');
|
2014-01-24 13:28:40 +01:00
|
|
|
link_month_url = script_tag.getAttribute('data-link-month-url');
|
2014-01-10 18:31:24 +01:00
|
|
|
flatdate = script_tag.getAttribute('data-date');
|
|
|
|
current_date = script_tag.getAttribute('data-current-date');
|
2013-10-05 15:33:28 +02:00
|
|
|
}
|
|
|
|
function load_cal(url,id,no_reset) {
|
|
|
|
var owner='';
|
|
|
|
var i = 0;
|
|
|
|
selectBox = document.getElementById(id);
|
|
|
|
for(i=0; i < selectBox.length; ++i) {
|
|
|
|
if (selectBox.options[i].selected) {
|
|
|
|
owner += (owner ? ',' : '') + selectBox.options[i].value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (owner) {
|
|
|
|
if (typeof no_reset == 'unknown') no_reset = false;
|
2013-12-13 01:09:40 +01:00
|
|
|
url += '&owner='+(no_reset?'':'0,')+owner;
|
|
|
|
if (url.match('&ajax=true')) url = url.replace('&ajax=true', '')+'&ajax=true';
|
|
|
|
egw_link_handler(url, 'calendar');
|
2013-10-05 15:33:28 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-31 15:51:19 +01:00
|
|
|
|
2013-12-12 22:59:36 +01:00
|
|
|
/**
|
|
|
|
* Load template specific app.css file in top window too as sidebox needs it
|
2013-12-13 01:09:40 +01:00
|
|
|
*
|
2013-12-12 22:59:36 +01:00
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
|
|
|
function load_top_app_css()
|
|
|
|
{
|
|
|
|
var calendar_window = egw_appWindow('calendar');
|
|
|
|
// include template specific app.css
|
|
|
|
var link_tags = calendar_window.document.getElementsByTagName('link');
|
2013-12-19 04:46:38 +01:00
|
|
|
var cal_app_css = /calendar\/templates\/[^/]+\/app.css/;
|
2013-12-12 22:59:36 +01:00
|
|
|
for(var i=0; i < link_tags.length; i++)
|
|
|
|
// include template specific app.css
|
2013-12-19 04:46:38 +01:00
|
|
|
{
|
|
|
|
var href = cal_app_css.exec(link_tags[i].href);
|
|
|
|
if (href)
|
2013-12-12 22:59:36 +01:00
|
|
|
{
|
|
|
|
//alert('loading into top window: '+href);
|
2013-12-19 04:46:38 +01:00
|
|
|
egw(calendar_window.top).includeCSS(egw_webserverUrl+'/'+href[0]);
|
2013-12-12 22:59:36 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// try loading a little later, due to async loading app.css might not already loaded
|
|
|
|
window.setTimeout(load_top_app_css, 100);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-10 18:31:24 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* @param {type} calendar
|
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
|
|
|
function dateChanged(calendar) {
|
|
|
|
|
|
|
|
if (calendar.dateClicked) {
|
2014-02-03 12:53:19 +01:00
|
|
|
egw_link_handler(link_day_url+"&date=" + calendar.date.print("%Y%m%d"),"calendar");
|
2014-01-10 18:31:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* @param {type} calendar
|
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
|
|
|
function todayClicked(calendar) {
|
2014-02-03 12:53:19 +01:00
|
|
|
egw_link_handler(current_view_url+"&date="+ current_date ,"calendar");
|
2014-01-10 18:31:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* @param {type} calendar
|
|
|
|
* @param {type} weekstart
|
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
|
|
|
function weekClicked(calendar,weekstart) {
|
|
|
|
egw_link_handler(link_week_url+"&date=" + weekstart.print("%Y%m%d"),"calendar");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* @param {type} calendar
|
|
|
|
* @param {type} monthstart
|
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
|
|
|
function monthClicked(calendar,monthstart) {
|
|
|
|
egw_link_handler(link_month_url+"&date=" + monthstart.print("%Y%m%d"),"calendar");
|
|
|
|
}
|
|
|
|
|
2013-10-05 15:33:28 +02:00
|
|
|
/**
|
|
|
|
* Initialisation after DOM *and* jQuery is loaded
|
|
|
|
*/
|
|
|
|
egw_LAB.wait(function() {
|
|
|
|
$j(function(){
|
2013-10-31 15:51:19 +01:00
|
|
|
var calendar_window = egw_appWindow('calendar');
|
2013-12-12 22:59:36 +01:00
|
|
|
// include template specific app.css
|
|
|
|
load_top_app_css();
|
2013-10-05 15:33:28 +02:00
|
|
|
// change handlers setting a certain url, eg. view
|
|
|
|
$j('#calendar_view').change(function(){
|
2013-12-13 01:09:40 +01:00
|
|
|
egw_link_handler(egw_webserverUrl+'/index.php?'+this.value, 'calendar');
|
2013-10-05 15:33:28 +02:00
|
|
|
});
|
|
|
|
// calendar owner selection change
|
|
|
|
$j('#uical_select_owner,#uical_select_resource').change(function(e){
|
|
|
|
if (this.value != 'popup')
|
|
|
|
{
|
|
|
|
load_cal(current_view_url, this.id, this.id != 'uical_select_owner');
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
// diverse change handlers appending a name=value to url
|
2015-01-19 20:32:26 +01:00
|
|
|
$j('#calendar_merge,#calendar_filter,#calendar_cat_id,#calendar_test').change(function(){
|
|
|
|
var val = this.name == 'test' ? this.checked.toString() : $j(this).val();
|
2013-10-05 15:33:28 +02:00
|
|
|
if ($j.isArray(val)) val = val.join(',');
|
2013-12-13 01:09:40 +01:00
|
|
|
var url = current_view_url+(current_view_url.search.length ? '&' : '?')+this.name+'='+val;
|
|
|
|
if (url.match('&ajax=true')) url = url.replace('&ajax=true', '')+'&ajax=true';
|
|
|
|
egw_link_handler(url, 'calendar');
|
2013-10-31 15:51:19 +01:00
|
|
|
if (this.name == 'merge') this.value='';
|
2013-10-05 15:33:28 +02:00
|
|
|
});
|
|
|
|
// click handler to switch selectbox to multiple
|
|
|
|
$j('#calendar_cat_id_multiple').click(function(){
|
|
|
|
var selectBox = document.getElementById(this.id.replace('_multiple', ''));
|
2013-10-31 15:51:19 +01:00
|
|
|
if (selectBox && !selectBox.multiple)
|
2013-10-05 15:33:28 +02:00
|
|
|
{
|
2013-10-31 15:51:19 +01:00
|
|
|
selectBox.size=4;
|
2013-10-05 15:33:28 +02:00
|
|
|
selectBox.multiple=true;
|
|
|
|
}
|
|
|
|
});
|
2014-01-24 12:24:14 +01:00
|
|
|
$j('#calendar_keywords').change(function(){
|
|
|
|
egw.open_link('calendar.calendar_uilist.listview&keywords='+encodeURIComponent(this.value)+'&ajax=true', 'calendar');
|
|
|
|
});
|
2013-10-05 15:33:28 +02:00
|
|
|
});
|
2014-01-10 18:31:24 +01:00
|
|
|
Calendar.setup({
|
|
|
|
flat : "calendar-container",
|
|
|
|
flatCallback : dateChanged,
|
|
|
|
flatWeekCallback : (link_week_url)?weekClicked:'',
|
|
|
|
flatWeekTTip : egw.lang('show this week'),
|
|
|
|
flatMonthCallback : (link_month_url)?monthClicked:'',
|
|
|
|
flatMonthTTip : egw.lang('show this month'),
|
|
|
|
flatTodayCallback : (flatdate)?todayClicked:'',
|
2014-01-24 13:28:40 +01:00
|
|
|
date : (flatdate)?flatdate:''
|
2014-01-10 18:31:24 +01:00
|
|
|
});
|
2013-10-05 15:33:28 +02:00
|
|
|
});
|
|
|
|
})();
|