forked from extern/egroupware
instanciate app.js object from egw.js, so non et2 apps can use it too, get et2_dialog working from app.calendar outside listview
This commit is contained in:
parent
eba4b8cee3
commit
aeb6ebd84c
@ -225,6 +225,18 @@ class calendar_ui
|
|||||||
*/
|
*/
|
||||||
function do_header()
|
function do_header()
|
||||||
{
|
{
|
||||||
|
// Include the jQuery-UI CSS - many more complex widgets use it
|
||||||
|
$theme = 'redmond';
|
||||||
|
egw_framework::includeCSS("/phpgwapi/js/jquery/jquery-ui/$theme/jquery-ui-1.10.3.custom.css");
|
||||||
|
// Load our CSS after jQuery-UI, so we can override it
|
||||||
|
egw_framework::includeCSS('/etemplate/templates/default/etemplate2.css');
|
||||||
|
|
||||||
|
// load etemplate2
|
||||||
|
egw_framework::validate_file('/etemplate/js/etemplate2.js');
|
||||||
|
|
||||||
|
// load our app.js file
|
||||||
|
egw_framework::validate_file('/calendar/js/app.js');
|
||||||
|
|
||||||
// tell egw_framework to include wz_tooltip
|
// tell egw_framework to include wz_tooltip
|
||||||
$GLOBALS['egw_info']['flags']['include_wz_tooltip'] = true;
|
$GLOBALS['egw_info']['flags']['include_wz_tooltip'] = true;
|
||||||
common::egw_header();
|
common::egw_header();
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*egw:uses
|
||||||
|
/etemplate/js/etemplate2.js
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UI for calendar
|
* UI for calendar
|
||||||
*
|
*
|
||||||
@ -20,15 +24,7 @@ app.classes.calendar = AppJS.extend(
|
|||||||
* application name
|
* application name
|
||||||
*/
|
*/
|
||||||
appname: 'calendar',
|
appname: 'calendar',
|
||||||
/**
|
|
||||||
* et2 widget container
|
|
||||||
*/
|
|
||||||
et2: null,
|
|
||||||
/**
|
|
||||||
* edit_series vars
|
|
||||||
*/
|
|
||||||
calendar_edit_id: null,
|
|
||||||
calendar_edit_date: null,
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -45,10 +41,8 @@ app.classes.calendar = AppJS.extend(
|
|||||||
*/
|
*/
|
||||||
destroy: function()
|
destroy: function()
|
||||||
{
|
{
|
||||||
delete this.et2;
|
|
||||||
// call parent
|
// call parent
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,11 +93,12 @@ app.classes.calendar = AppJS.extend(
|
|||||||
/**
|
/**
|
||||||
* open the freetime search popup
|
* open the freetime search popup
|
||||||
*
|
*
|
||||||
|
* @param {string} _link
|
||||||
*/
|
*/
|
||||||
freetime_search_popup: function(_link)
|
freetime_search_popup: function(_link)
|
||||||
{
|
{
|
||||||
this.egw.open_link(_link,'ft_search','700x500') ;
|
this.egw.open_link(_link,'ft_search','700x500') ;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* send an ajax request to server to set the freetimesearch window content
|
* send an ajax request to server to set the freetimesearch window content
|
||||||
@ -153,10 +148,11 @@ app.classes.calendar = AppJS.extend(
|
|||||||
/**
|
/**
|
||||||
* handles actions selectbox in calendar edit popup
|
* handles actions selectbox in calendar edit popup
|
||||||
*
|
*
|
||||||
* @param {widget object} widget, widget "actions selectBox" in edit popup window
|
* @param {mixed} _event
|
||||||
|
* @param {et2_base_widget} widget, widget "actions selectBox" in edit popup window
|
||||||
*/
|
*/
|
||||||
actions_change: function(egw,widget)
|
actions_change: function(_event, widget)
|
||||||
{
|
{
|
||||||
var event = this.et2.getArrayMgr('content').data;
|
var event = this.et2.getArrayMgr('content').data;
|
||||||
if (widget)
|
if (widget)
|
||||||
{
|
{
|
||||||
@ -183,51 +179,53 @@ app.classes.calendar = AppJS.extend(
|
|||||||
this.et2._inst.submit();
|
this.et2._inst.submit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* open mail compose popup window
|
* open mail compose popup window
|
||||||
*
|
*
|
||||||
* @param {Array} vars,
|
* @param {Array} vars
|
||||||
* @todo need to provide right mail compose from server to custom_mail function
|
* @todo need to provide right mail compose from server to custom_mail function
|
||||||
*/
|
*/
|
||||||
custom_mail: function (vars)
|
custom_mail: function (vars)
|
||||||
{
|
{
|
||||||
this.egw.open_link('mail.mail_compose.compose&','_blank','700x700');
|
this.egw.open_link('mail.mail_compose.compose&','_blank','700x700');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* control delete_series popup visibility
|
* control delete_series popup visibility
|
||||||
*
|
*
|
||||||
* @param {Array} exceptions, an array contains number of exception entries
|
* @param {Array} exceptions an array contains number of exception entries
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
delete_btn: function(exceptions)
|
delete_btn: function(exceptions)
|
||||||
{
|
{
|
||||||
var content = this.et2.getArrayMgr('content').data;
|
var content = this.et2.getArrayMgr('content').data;
|
||||||
|
|
||||||
if (exceptions)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
if (exceptions)
|
||||||
|
{
|
||||||
$j(document.getElementById('calendar-edit_calendar-delete_series')).show();
|
$j(document.getElementById('calendar-edit_calendar-delete_series')).show();
|
||||||
}
|
}
|
||||||
else if (content['recur_type'] !== 0)
|
else if (content['recur_type'] !== 0)
|
||||||
{
|
{
|
||||||
return confirm('Delete this series of recuring events');
|
return confirm('Delete this series of recuring events');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return confirm('Delete this event');
|
return confirm('Delete this event');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print_participants_status(egw,widget)
|
* print_participants_status(egw,widget)
|
||||||
* Handle to apply changes from status in print popup
|
* Handle to apply changes from status in print popup
|
||||||
*
|
*
|
||||||
* @param {widget object} widget, widget "status" in print popup window
|
* @param {mixed} _event
|
||||||
|
* @param {et2_base_widget} widget widget "status" in print popup window
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
print_participants_status: function(egw,widget)
|
print_participants_status: function(_event, widget)
|
||||||
{
|
{
|
||||||
if (widget && window.opener)
|
if (widget && window.opener)
|
||||||
{
|
{
|
||||||
//Parent popup window
|
//Parent popup window
|
||||||
@ -246,17 +244,18 @@ app.classes.calendar = AppJS.extend(
|
|||||||
{
|
{
|
||||||
window.egw_refresh(this.egw.lang('The original popup edit window is closed! You need to close the print window and reopen the entry again.'),'calendar');
|
window.egw_refresh(this.egw.lang('The original popup edit window is closed! You need to close the print window and reopen the entry again.'),'calendar');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles to select freetime, and replace the selected one on Start,
|
* Handles to select freetime, and replace the selected one on Start,
|
||||||
* and End date&time in edit calendar entry popup.
|
* and End date&time in edit calendar entry popup.
|
||||||
*
|
*
|
||||||
* @param {widget object} _widget, widget "select button" in freetime search popup window
|
* @param {mixed} _event
|
||||||
|
* @param {et2_base_widget} _widget widget "select button" in freetime search popup window
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
freetime_select: function(_egw,_widget)
|
freetime_select: function(_event, _widget)
|
||||||
{
|
{
|
||||||
if (_widget)
|
if (_widget)
|
||||||
{
|
{
|
||||||
var content = this.et2._inst.widgetContainer.getArrayMgr('content').data;
|
var content = this.et2._inst.widgetContainer.getArrayMgr('content').data;
|
||||||
@ -292,7 +291,7 @@ app.classes.calendar = AppJS.extend(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.close();
|
window.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show/hide the filter of nm list in calendar listview
|
* show/hide the filter of nm list in calendar listview
|
||||||
@ -312,6 +311,8 @@ app.classes.calendar = AppJS.extend(
|
|||||||
/**
|
/**
|
||||||
* this function try to fix ids which are from integrated apps
|
* this function try to fix ids which are from integrated apps
|
||||||
*
|
*
|
||||||
|
* @param {egw_action} _action
|
||||||
|
* @param {Array} _senders
|
||||||
*/
|
*/
|
||||||
cal_fix_app_id: function(_action, _senders)
|
cal_fix_app_id: function(_action, _senders)
|
||||||
{
|
{
|
||||||
@ -322,7 +323,7 @@ app.classes.calendar = AppJS.extend(
|
|||||||
{
|
{
|
||||||
id = matches[1];
|
id = matches[1];
|
||||||
}
|
}
|
||||||
else if (matches = id.match(/^([a-z_-]+)([0-9]+)/i))
|
else if ((matches = id.match(/^([a-z_-]+)([0-9]+)/i)))
|
||||||
{
|
{
|
||||||
app = matches[1];
|
app = matches[1];
|
||||||
id = matches[2];
|
id = matches[2];
|
||||||
@ -357,7 +358,7 @@ app.classes.calendar = AppJS.extend(
|
|||||||
this.edit_series(matches[1],matches[2]);
|
this.edit_series(matches[1],matches[2]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (matches = id.match(/^([a-z_-]+)([0-9]+)/i))
|
else if ((matches = id.match(/^([a-z_-]+)([0-9]+)/i)))
|
||||||
{
|
{
|
||||||
var app = matches[1];
|
var app = matches[1];
|
||||||
_action.data.url = window.egw_webserverUrl+'/index.php?';
|
_action.data.url = window.egw_webserverUrl+'/index.php?';
|
||||||
@ -367,7 +368,7 @@ app.classes.calendar = AppJS.extend(
|
|||||||
_action.data.url += name+"="+encodeURIComponent(get_params[name])+"&";
|
_action.data.url += name+"="+encodeURIComponent(get_params[name])+"&";
|
||||||
|
|
||||||
if (js_integration_data[app].edit_popup &&
|
if (js_integration_data[app].edit_popup &&
|
||||||
(matches = js_integration_data[app].edit_popup.match(/^(.*)x(.*)$/)))
|
((matches = js_integration_data[app].edit_popup.match(/^(.*)x(.*)$/))))
|
||||||
{
|
{
|
||||||
_action.data.width = matches[1];
|
_action.data.width = matches[1];
|
||||||
_action.data.height = matches[2];
|
_action.data.height = matches[2];
|
||||||
@ -420,7 +421,8 @@ app.classes.calendar = AppJS.extend(
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (row = jQuery("#"+id+"\\:"+date)) {
|
if ((row = jQuery("#"+id+"\\:"+date)))
|
||||||
|
{
|
||||||
// Open at row
|
// Open at row
|
||||||
popup.css({
|
popup.css({
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
@ -447,13 +449,12 @@ app.classes.calendar = AppJS.extend(
|
|||||||
/**
|
/**
|
||||||
* Create edit exception dialog for recurrence entries
|
* Create edit exception dialog for recurrence entries
|
||||||
*
|
*
|
||||||
* @param {timestamp} date
|
* @param {object} event
|
||||||
* @param {string} id, cal_id
|
* @param {string} id cal_id
|
||||||
* @param {type} name description
|
* @param {integer} date timestamp
|
||||||
*/
|
*/
|
||||||
edit_series: function(event,id,date)
|
edit_series: function(event,id,date)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Coming from list, there is no event
|
// Coming from list, there is no event
|
||||||
if(arguments.length == 2)
|
if(arguments.length == 2)
|
||||||
{
|
{
|
||||||
@ -461,40 +462,31 @@ app.classes.calendar = AppJS.extend(
|
|||||||
id = event;
|
id = event;
|
||||||
event = null;
|
event = null;
|
||||||
}
|
}
|
||||||
calendar_edit_id = id;
|
var edit_id = id;
|
||||||
calendar_edit_date = date;
|
var edit_date = date;
|
||||||
var that = this;
|
var that = this;
|
||||||
var buttons = [
|
var buttons = [
|
||||||
{text: this.egw.lang("Edit exception"), id: "exception", class: "ui-priority-primary", "default": true},
|
{text: this.egw.lang("Edit exception"), id: "exception", class: "ui-priority-primary", "default": true},
|
||||||
{text: this.egw.lang("Edit series"), id:"series"},
|
{text: this.egw.lang("Edit series"), id:"series"},
|
||||||
{text: this.egw.lang("Cancel"), id:"cancel"},
|
{text: this.egw.lang("Cancel"), id:"cancel"}
|
||||||
];
|
];
|
||||||
var callbackExceptionDialog = function (button_id)
|
et2_dialog.show_dialog(function(_button_id)
|
||||||
{
|
{
|
||||||
switch(button_id)
|
switch(_button_id)
|
||||||
{
|
{
|
||||||
case 'exception':
|
case 'exception':
|
||||||
that.open_edit(false);
|
that.egw.open(edit_id, 'calendar', 'edit', '&date='+edit_date);
|
||||||
|
that.open_edit.call(that, false);
|
||||||
break;
|
break;
|
||||||
case 'series':
|
case 'series':
|
||||||
that.open_edit(true);
|
that.egw.open(edit_id, 'calendar', 'edit', '&date='+edit_date+'&exception=1');
|
||||||
break;
|
break;
|
||||||
case 'cancel':
|
case 'cancel':
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
},this.egw.lang("Do you want to edit this event as an exception or the whole series?"),
|
||||||
var confirmExcDialog = et2_dialog.show_dialog(callbackExceptionDialog, this.egw.lang("Do you want to edit this event as an exception or the whole series?"),this.egw.lang("This event is part of a series"), {},buttons, et2_dialog.WARNING_MESSAGE);
|
this.egw.lang("This event is part of a series"), {}, buttons, et2_dialog.WARNING_MESSAGE);
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* open calendar entry with the proper url either as series modifiction or exception modification
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
open_edit: function(series)
|
|
||||||
{
|
|
||||||
this.egw.open(calendar_edit_id,'calendar','edit','&date='+calendar_edit_date
|
|
||||||
+(!series?'&exception=1':''));
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
@ -39,10 +39,10 @@
|
|||||||
(function(){
|
(function(){
|
||||||
var debug = false;
|
var debug = false;
|
||||||
var egw_script = document.getElementById('egw_script_id');
|
var egw_script = document.getElementById('egw_script_id');
|
||||||
|
|
||||||
// Flag for if this is opened in a popup
|
// Flag for if this is opened in a popup
|
||||||
var popup = false;
|
var popup = false;
|
||||||
|
|
||||||
window.egw_webserverUrl = egw_script.getAttribute('data-url');
|
window.egw_webserverUrl = egw_script.getAttribute('data-url');
|
||||||
window.egw_appName = egw_script.getAttribute('data-app');
|
window.egw_appName = egw_script.getAttribute('data-app');
|
||||||
|
|
||||||
@ -73,7 +73,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (debug) console.log('found injected egw object');
|
else if (debug) console.log('found injected egw object');
|
||||||
|
|
||||||
// check for a framework object
|
// check for a framework object
|
||||||
if (typeof window.framework == 'undefined')
|
if (typeof window.framework == 'undefined')
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@
|
|||||||
window.location.search += window.location.search ? "&cd=yes" : "?cd=yes";
|
window.location.search += window.location.search ? "&cd=yes" : "?cd=yes";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// call egw_refresh on opener, if attr specified
|
// call egw_refresh on opener, if attr specified
|
||||||
var refresh_opener = egw_script.getAttribute('data-refresh-opener');
|
var refresh_opener = egw_script.getAttribute('data-refresh-opener');
|
||||||
if (refresh_opener && window.opener)
|
if (refresh_opener && window.opener)
|
||||||
@ -102,7 +102,7 @@
|
|||||||
refresh_opener = JSON.parse(refresh_opener) || {};
|
refresh_opener = JSON.parse(refresh_opener) || {};
|
||||||
window.opener.egw_refresh.apply(window.opener, refresh_opener);
|
window.opener.egw_refresh.apply(window.opener, refresh_opener);
|
||||||
}
|
}
|
||||||
|
|
||||||
// close window / call window.close(), if data-window-close is specified
|
// close window / call window.close(), if data-window-close is specified
|
||||||
var window_close = egw_script.getAttribute('data-window-close');
|
var window_close = egw_script.getAttribute('data-window-close');
|
||||||
if (window_close)
|
if (window_close)
|
||||||
@ -110,7 +110,7 @@
|
|||||||
if (typeof window_close == 'string' && window_close !== '1')
|
if (typeof window_close == 'string' && window_close !== '1')
|
||||||
{
|
{
|
||||||
alert(window_close);
|
alert(window_close);
|
||||||
}
|
}
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@
|
|||||||
|
|
||||||
window.egw_LAB = $LAB.setOptions({AlwaysPreserveOrder:true,BasePath:window.egw_webserverUrl+'/'});
|
window.egw_LAB = $LAB.setOptions({AlwaysPreserveOrder:true,BasePath:window.egw_webserverUrl+'/'});
|
||||||
var include = JSON.parse(egw_script.getAttribute('data-include'));
|
var include = JSON.parse(egw_script.getAttribute('data-include'));
|
||||||
|
|
||||||
// remove this script from include, until server-side no longer requires it
|
// remove this script from include, until server-side no longer requires it
|
||||||
for(var i=0; i < include.length; ++i)
|
for(var i=0; i < include.length; ++i)
|
||||||
{
|
{
|
||||||
@ -133,7 +133,8 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.egw_LAB.script(include).wait(function(){
|
window.egw_LAB.script(include).wait(function()
|
||||||
|
{
|
||||||
// Make sure opener knows when we close - start a heartbeat
|
// Make sure opener knows when we close - start a heartbeat
|
||||||
if((popup || window.opener) && window.name != '')
|
if((popup || window.opener) && window.name != '')
|
||||||
{
|
{
|
||||||
@ -142,7 +143,15 @@
|
|||||||
egw().storeWindow(this.egw_appName, this);
|
egw().storeWindow(this.egw_appName, this);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// instanciate app object
|
||||||
|
var appname = window.egw_appName;
|
||||||
|
if (window.app && window.app[appname] != 'object' && typeof window.app.classes[appname] == 'function')
|
||||||
|
{
|
||||||
|
window.app[appname] = new window.app.classes[appname]();
|
||||||
|
}
|
||||||
|
|
||||||
|
// load et2
|
||||||
var data = egw_script.getAttribute('data-etemplate');
|
var data = egw_script.getAttribute('data-etemplate');
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
@ -156,7 +165,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
egw.debug("warn", "Did not load '%s' JS object",window.egw_appName);
|
egw.debug("warn", "Did not load '%s' JS object",window.egw_appName);
|
||||||
}
|
}
|
||||||
if(typeof app[window.egw_appName] == "object")
|
if(typeof app[window.egw_appName] == "object")
|
||||||
{
|
{
|
||||||
@ -184,9 +193,9 @@
|
|||||||
window.egw_message.apply(window, data);
|
window.egw_message.apply(window, data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
window.callManual = function()
|
window.callManual = function()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user