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:
Ralf Becker 2013-11-05 18:08:07 +00:00
parent eba4b8cee3
commit aeb6ebd84c
3 changed files with 100 additions and 87 deletions

View File

@ -225,6 +225,18 @@ class calendar_ui
*/
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
$GLOBALS['egw_info']['flags']['include_wz_tooltip'] = true;
common::egw_header();

View File

@ -9,6 +9,10 @@
* @version $Id$
*/
/*egw:uses
/etemplate/js/etemplate2.js
*/
/**
* UI for calendar
*
@ -20,15 +24,7 @@ app.classes.calendar = AppJS.extend(
* application name
*/
appname: 'calendar',
/**
* et2 widget container
*/
et2: null,
/**
* edit_series vars
*/
calendar_edit_id: null,
calendar_edit_date: null,
/**
* Constructor
*
@ -45,10 +41,8 @@ app.classes.calendar = AppJS.extend(
*/
destroy: function()
{
delete this.et2;
// call parent
this._super.apply(this, arguments);
},
/**
@ -99,6 +93,7 @@ app.classes.calendar = AppJS.extend(
/**
* open the freetime search popup
*
* @param {string} _link
*/
freetime_search_popup: function(_link)
{
@ -153,9 +148,10 @@ app.classes.calendar = AppJS.extend(
/**
* 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;
if (widget)
@ -184,20 +180,22 @@ app.classes.calendar = AppJS.extend(
}
}
},
/**
* open mail compose popup window
*
* @param {Array} vars,
* @param {Array} vars
* @todo need to provide right mail compose from server to custom_mail function
*/
custom_mail: function (vars)
{
this.egw.open_link('mail.mail_compose.compose&','_blank','700x700');
},
/**
* 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)
@ -206,7 +204,6 @@ app.classes.calendar = AppJS.extend(
if (exceptions)
{
$j(document.getElementById('calendar-edit_calendar-delete_series')).show();
}
else if (content['recur_type'] !== 0)
@ -223,10 +220,11 @@ app.classes.calendar = AppJS.extend(
* print_participants_status(egw,widget)
* 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)
{
@ -252,10 +250,11 @@ app.classes.calendar = AppJS.extend(
* Handles to select freetime, and replace the selected one on Start,
* 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)
{
@ -312,6 +311,8 @@ app.classes.calendar = AppJS.extend(
/**
* 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)
{
@ -322,7 +323,7 @@ app.classes.calendar = AppJS.extend(
{
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];
id = matches[2];
@ -357,7 +358,7 @@ app.classes.calendar = AppJS.extend(
this.edit_series(matches[1],matches[2]);
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];
_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])+"&";
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.height = matches[2];
@ -420,7 +421,8 @@ app.classes.calendar = AppJS.extend(
{
return;
}
if (row = jQuery("#"+id+"\\:"+date)) {
if ((row = jQuery("#"+id+"\\:"+date)))
{
// Open at row
popup.css({
position: "absolute",
@ -447,13 +449,12 @@ app.classes.calendar = AppJS.extend(
/**
* Create edit exception dialog for recurrence entries
*
* @param {timestamp} date
* @param {string} id, cal_id
* @param {type} name description
* @param {object} event
* @param {string} id cal_id
* @param {integer} date timestamp
*/
edit_series: function(event,id,date)
{
// Coming from list, there is no event
if(arguments.length == 2)
{
@ -461,40 +462,31 @@ app.classes.calendar = AppJS.extend(
id = event;
event = null;
}
calendar_edit_id = id;
calendar_edit_date = date;
var edit_id = id;
var edit_date = date;
var that = this;
var buttons = [
{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("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':
that.open_edit(false);
that.egw.open(edit_id, 'calendar', 'edit', '&date='+edit_date);
that.open_edit.call(that, false);
break;
case 'series':
that.open_edit(true);
that.egw.open(edit_id, 'calendar', 'edit', '&date='+edit_date+'&exception=1');
break;
case 'cancel':
default:
break;
}
},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);
}
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);
},
/**
* 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':''));
},
});

View File

@ -133,7 +133,8 @@
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
if((popup || window.opener) && window.name != '')
{
@ -143,6 +144,14 @@
}, 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');
if (data)
{