fixing scope of "use strict", so we do not need to remove it when concatinating our scripts like we do now with minjs, also enabled "use strict" for calendar/js/app.js and fixed a reference error found by it

This commit is contained in:
Ralf Becker 2016-03-01 16:27:45 +00:00
parent 4c37f90cc1
commit 3a9c0c237b
10 changed files with 255 additions and 223 deletions

View File

@ -40,7 +40,7 @@
*
* @augments AppJS
*/
app.classes.calendar = AppJS.extend(
app.classes.calendar = (function(){ "use strict"; return AppJS.extend(
{
/**
* application name
@ -2060,7 +2060,7 @@ app.classes.calendar = AppJS.extend(
// caching keys, otherwise they'll fetch & cache consolidated
if(state.state.view == 'day' && state.state.owner.length < parseInt(this.egw.preference('day_consolidate','calendar')))
{
day_value = [];
var day_value = [];
for(var i = 0; i < state.state.owner.length; i++)
{
day_value.push({
@ -2748,7 +2748,7 @@ app.classes.calendar = AppJS.extend(
this._queries_in_progress.splice(idx,1);
}
//console.log(data);
// Look for any updated select options
if(data.rows && data.rows.sel_options && this.sidebox_et2)
{
@ -3501,7 +3501,7 @@ app.classes.calendar = AppJS.extend(
return d;
}
}
});
});}).call(this);
jQuery.extend(app.classes.calendar,{

9
calendar/js/app.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*
/*
* Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
@ -9,8 +9,6 @@
*/
"use strict";
/*egw:uses
et2_core_valueWidget;
/calendar/js/et2_widget_event.js;
@ -23,7 +21,7 @@
*
* @augments et2_valueWidget
*/
var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizeable],
var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizeable],
{
attributes: {
@ -78,7 +76,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
this.event_wrapper = $j(document.createElement('div'))
.addClass("event_wrapper")
.appendTo(this.div);
this.setDOMNode(this.div[0]);
// Used for its date calculations - note this is a datetime, parent
@ -95,14 +93,14 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
rowHeight: 20,
// Percentage; not yet available
titleHeight: 2.0
}
};
this.registeredUID = null;
},
doLoadingFinished: function() {
this._super.apply(this, arguments);
// Parent will have everything we need, just load it from there
if(this._parent && this._parent.options.owner)
@ -127,7 +125,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
this.div = null;
this.header = null;
this.title = null;
// date_helper has no parent, so we must explicitly remove it
this.date_helper.destroy();
this.date_helper = null;
@ -170,7 +168,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
// Figure out insert index
var idx = 0;
var siblings = this._parent.getDOMNode(this).childNodes
var siblings = this._parent.getDOMNode(this).childNodes;
while(idx < siblings.length && siblings[idx] != this.getDOMNode())
{
idx++;
@ -193,9 +191,9 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
* Set the date
*
* @param {string|Date} _date New date
* @param {Object[]} events=false List of event data to be displayed, or false to
* @param {Object[]} events =false List of event data to be displayed, or false to
* automatically fetch data from content array
* @param {boolean} force_redraw=false Redraw even if the date is the same.
* @param {boolean} force_redraw =false Redraw even if the date is the same.
* Used for when new data is available.
*/
set_date: function(_date, events, force_redraw)
@ -257,7 +255,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
}
var cache_id = app.classes.calendar._daywise_cache_id(new_date,this.options.owner);
if(this.options.date && this.registeredUID &&
if(this.options.date && this.registeredUID &&
cache_id !== this.registeredUID)
{
egw.dataUnregisterUID(this.registeredUID,false,this);
@ -297,7 +295,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
* combination of both.
*/
set_owner: function(_owner) {
this.title
.attr("data-owner", _owner);
this.header.attr('data-owner',_owner);
@ -311,10 +309,10 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
{
return;
}
this.options.owner = typeof _owner !== 'object' ? [_owner] : _owner;
var cache_id = app.classes.calendar._daywise_cache_id(this.options.date,_owner)
var cache_id = app.classes.calendar._daywise_cache_id(this.options.date,_owner);
if(this.options.date && this.registeredUID &&
cache_id !== this.registeredUID)
{
@ -339,7 +337,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
*
* Events should update themselves when their data changes, here we are
* dealing with a change in which events are displayed on this day.
*
*
* @param {String[]} event_ids
* @returns {undefined}
*/
@ -376,7 +374,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
},
set_width: function(width) {
this.options.width = width;
if(this.div)
{
this.div.outerWidth(this.options.width);
@ -398,7 +396,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
// Set today class - note +1 when dealing with today, as months in JS are 0-11
var today = new Date();
today.setUTCMinutes(today.getUTCMinutes() - today.getTimezoneOffset());
this.title.toggleClass("calendar_calToday", this.options.date === ''+today.getUTCFullYear()+
sprintf("%02d",today.getUTCMonth()+1)+
sprintf("%02d",today.getUTCDate())
@ -458,7 +456,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
this.removeChild(node);
node.free();
}
// Make sure children are in cronological order, or columns are backwards
events.sort(function(a,b) {
var start = new Date(a.start) - new Date(b.start);
@ -503,7 +501,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
* Apply styles for out-of-view and partially hidden events
*
* There are 3 different states or modes of display:
*
*
* - 'Normal' - When showing events positioned by time, the indicator is just
* a bar colored by the last category color. On hover it shows either the
* title of a single event or "x event(s)" if more than one are hidden.
@ -514,7 +512,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
* week (not auto-sized to fit screen) the indicator is the same as sized.
* On hover it shows the titles of the hidden events, clicking changes
* the view to the selected day.
*
*
* - GridList - When showing just a list, the indicator shows "x event(s)",
* and on hover shows the category color, title & time. Clicking changes
* the view to the selected day, and opens the event for editing.
@ -533,7 +531,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
// elem is jquery div of event
function isHidden(elem) {
var docViewTop = timegrid.scrolling.scrollTop(),
docViewBottom = docViewTop + (
docViewBottom = docViewTop + (
this.display_settings.granularity === 0 ?
this.event_wrapper.height() :
timegrid.scrolling.height()
@ -563,10 +561,10 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
}
}
// Check all day overflow
this.all_day.toggleClass('overflown',
this.all_day.toggleClass('overflown',
this.all_day[0].scrollHeight - this.all_day.height() > 5
);
// Check each event
this.iterateOver(function(event) {
// Skip whole day events and events missing value
@ -707,7 +705,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
});
}
}
var count = parseInt(indicator.attr('data-hidden_count')) + 1
var count = parseInt(indicator.attr('data-hidden_count')) + 1;
indicator.attr('data-hidden_count', count);
if(this.display_settings.granularity === 0)
{
@ -746,13 +744,13 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
/**
* Sort a day's events into minimally overlapping columns
*
*
* @returns {Array[]} Events sorted into columns
*/
_spread_events: function()
{
if(!this.date) return [];
var day_start = this.date.valueOf() / 1000;
var dst_check = new Date(this.date);
dst_check.setUTCHours(12);
@ -775,7 +773,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
if(a.options.value.whole_day && b.options.value.whole_day)
{
// Longer duration comes first so we have nicer bars across the top
var duration =
var duration =
(new Date(b.options.value.end) - new Date(b.options.value.start)) -
(new Date(a.options.value.end) - new Date(a.options.value.start));
@ -787,12 +785,12 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
}
return start ? start : end;
});
for(var i = 0; i < this._children.length; i++)
{
var event = this._children[i].options.value || false;
if(!event) continue;
if(event.date && event.date != this.options.date &&
if(event.date && event.date != this.options.date &&
// Multi-day events date may be different
(new Date(event.start) >= this.date || new Date(event.end) <= this.date )
)
@ -942,7 +940,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
}
}
},
/**
* Calculates the vertical position based on the time
*
@ -954,10 +952,10 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
_time_to_position: function(time)
{
var pos = 0.0;
// 24h
pos = ((time / 60) / 24) * 100;
pos = pos.toFixed(1);
return pos;
@ -1035,7 +1033,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
* @param {array} _attrs array to add further attributes to
*/
getDetachedAttributes: function(_attrs) {
},
getDetachedNodes: function() {
@ -1043,9 +1041,9 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
},
setDetachedAttributes: function(_nodes, _values) {
},
// Resizable interface
/**
* Resize
@ -1070,6 +1068,6 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
this._out_of_view();
}
});
});}).call(this);
et2_register_widget(et2_calendar_daycol, ["calendar-daycol"]);

View File

@ -9,8 +9,6 @@
*/
"use strict";
/*egw:uses
/etemplate/js/et2_core_valueWidget;
*/
@ -42,7 +40,7 @@
*
* @augments et2_valueWidget
*/
var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
var et2_calendar_event = (function(){ "use strict"; return et2_valueWidget.extend([et2_IDetachedDOM],
{
attributes: {
@ -66,7 +64,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
this._super.apply(this, arguments);
var event = this;
// Main container
this.div = $j(document.createElement("div"))
.addClass("calendar_calEvent")
@ -137,7 +135,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
this._actionObject.remove();
this._actionObject = null;
}
this.div.off();
this.title.remove();
this.title = null;
@ -148,7 +146,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
this.div = null;
$j('body.egw_tooltip').remove();
// Unregister, or we'll continue to be notified...
if(this.options.value)
{
@ -224,7 +222,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
// Update to reflect new information
var event = this.options.value;
var id = event.row_id ? event.row_id : event.id + (event.recur_type ? ':'+event.recur_date : '');
var formatted_start = event.start.toJSON();
@ -273,10 +271,10 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
this.div
// Let timegrid always get the drag
.droppable('option','greedy',false)
// Set full day flag
.attr('data-full_day', event.whole_day)
// Put everything we need for basic interaction here, so it's available immediately
.attr('data-id', event.id)
.attr('data-app', event.app || 'calendar')
@ -314,14 +312,14 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
this.title.toggle(!event.whole_day_on_top);
this.body.toggleClass('calendar_calEventBodySmall', event.whole_day_on_top || false);
// Header
var title = !event.is_private ? event['title'] : egw.lang('private');
this.title
.html('<span class="calendar_calTimespan">'+this._get_timespan(event) + '<br /></span>')
.append('<span class="calendar_calEventTitle">'+title+'</span>')
// Colors - don't make them transparent if there is no color
if(jQuery.Color("rgba(0,0,0,0)").toRgbaString() != jQuery.Color(this.div,'background-color').toRgbaString())
{
@ -331,7 +329,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
this.icons.appendTo(this.title)
.html(this._icons());
// Body
if(event.whole_day_on_top)
{
@ -373,7 +371,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
/**
* Calculate display variants for when event is too short for full display
*
*
* Display is based on the number of visible lines, calculated off the header
* height:
* 1 - show just the event title, with ellipsis
@ -415,7 +413,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
/**
* Examines the participants & returns CSS classname for status
*
*
* @returns {String}
*/
_status_class: function() {
@ -449,7 +447,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
*/
_tooltip: function() {
if(!this.div) return '';
var border = this.div.css('borderTopColor');
var bg_color = this.div.css('background-color');
var header_color = this.title.css('color');
@ -479,7 +477,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
}
cat.destroy();
}
return '<div class="calendar_calEventTooltip ' + this._status_class() + '" style="border-color: '+border+'; background-color: '+bg_color+';">'+
'<div class="calendar_calEventHeaderSmall">'+
'<font style="color:'+header_color+'">'+timespan+'</font>'+
@ -614,7 +612,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
}
else
{
var duration = event.multiday ?
var duration = event.multiday ?
(event.end - event.start) / 60000 :
(event.end_m - event.start_m);
if (event.end_m === 24*60-1) ++duration;
@ -635,7 +633,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
}
return timespan;
},
/**
* Make sure event data has all proper values, and format them as expected
* @param {Object} event
@ -659,7 +657,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
this._parent.date_helper.set_value(event.end);
event.end = new Date(this._parent.date_helper.getValue());
}
// We need minutes for durations
if(typeof event.start_m === 'undefined')
{
@ -771,14 +769,14 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
{
old_cache_id = app.classes.calendar._daywise_cache_id(this.options.value.date,this._parent.options.owner);
}
if(new_cache_id != old_cache_id)
{
var old_daywise = egw.dataGetUIDdata(old_cache_id);
old_daywise = old_daywise && old_daywise.data ? old_daywise.data : [];
old_daywise.splice(old_daywise.indexOf(this.options.value.id),1);
egw.dataStoreUID(old_cache_id,old_daywise);
if (new_daywise.indexOf(event.id) < 0)
{
new_daywise.push(event.id);
@ -888,7 +886,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
action_links.push('egw_link_drop');
this._actionObject.updateActionLinks(action_links);
},
/**
* Code for implementing et2_IDetachedDOM
*
@ -905,7 +903,7 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
setDetachedAttributes: function(_nodes, _values) {
},
});
});}).call(this);
et2_register_widget(et2_calendar_event, ["calendar-event"]);
// Static class stuff
@ -918,7 +916,7 @@ et2_register_widget(et2_calendar_event, ["calendar-event"]);
*/
/**
* Recur prompt
* If the event is recurring, asks the user if they want to edit the event as
* If the event is recurring, asks the user if they want to edit the event as
* an exception, or change the whole series. Then the callback is called.
*
* If callback is not provided, egw.open() will be used to open an edit dialog.
@ -936,7 +934,7 @@ et2_register_widget(et2_calendar_event, ["calendar-event"]);
* data.
* @param {Object} [extra_data] - Additional data passed to the callback, used
* as extra parameters for default callback
*
*
* @augments {et2_calendar_event}
*/
et2_calendar_event.recur_prompt = function(event_data, callback, extra_data)
@ -1039,7 +1037,7 @@ et2_calendar_event.drag_helper = function(event,ui) {
*
* @param {string} status - combined value, O: status letter: U, T, A, R
* @param {int} [quantity] - quantity
* @param {string} [role]
* @param {string} [role]
* @return string status U, T, A or R, same as $status parameter on return
*/
et2_calendar_event.split_status = function(status,quantity,role)

View File

@ -1,16 +1,14 @@
/*
/*
* Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package
* @subpackage
* @package
* @subpackage
* @link http://www.egroupware.org
* @author Nathan Gray
* @version $Id$
*/
"use strict";
/*egw:uses
et2_widget_taglist;
*/
@ -25,7 +23,7 @@
* @see http://nicolasbize.github.io/magicsuggest/
* @augments et2_selectbox
*/
var et2_calendar_owner = et2_taglist_email.extend(
var et2_calendar_owner = (function(){ "use strict"; return et2_taglist_email.extend(
{
attributes: {
"autocomplete_url": {
@ -47,7 +45,7 @@ var et2_calendar_owner = et2_taglist_email.extend(
// Set to empty object to use selectbox's option finding
"default": {},
"description": "Internally used to hold the select options."
},
}
},
// Allows sub-widgets to override options to the library
@ -81,9 +79,9 @@ var et2_calendar_owner = et2_taglist_email.extend(
.removeClass('ms-res-item-active');
}
},1);
})
});
return true;
},
@ -92,5 +90,5 @@ var et2_calendar_owner = et2_taglist_email.extend(
if(this.taglist == null) return null;
return this.taglist.getValue();
}
});
});}).call(this);
et2_register_widget(et2_calendar_owner, ["calendar-owner"]);

View File

@ -1,4 +1,4 @@
/*
/*
* Egroupware Calendar timegrid
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
@ -9,8 +9,6 @@
*/
"use strict";
/*egw:uses
/calendar/js/et2_widget_view.js;
/calendar/js/et2_widget_planner_row.js;
@ -25,10 +23,10 @@
*
* @augments et2_calendar_view
*/
var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResizeable],
var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.extend([et2_IDetachedDOM, et2_IResizeable],
{
createNamespace: true,
attributes: {
group_by: {
name: "Group by",
@ -118,7 +116,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
doLoadingFinished: function() {
this._super.apply(this, arguments);
// Don't bother to draw anything if there's no date yet
if(this.options.start_date)
{
@ -282,7 +280,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
});
return true;
},
/**
* These handle the differences between the different group types.
* They provide the different titles, labels and grouping
@ -375,7 +373,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
}
else // users
{
user = parseInt(user)
user = parseInt(user);
for(var j = 0; j < accounts.length && already_added.indexOf(''+user) < 0; j++)
{
if(accounts[j].value === user)
@ -433,7 +431,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
}
rows[label_index].push(event);
}
}
};
for(var user in participants)
{
var participant = participants[user];
@ -611,7 +609,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
break;
}
}
// Get its children immediately
egw.json(
this.getInstanceManager().app+'.etemplate_widget_menupopup.ajax_get_options.etemplate',
@ -692,7 +690,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
* Something changed, and the planner needs to be re-drawn. We wait a bit to
* avoid re-drawing twice if start and end date both changed, then recreate.
*
* @param {boolean} trigger=false Trigger an event once things are done.
* @param {boolean} trigger =false Trigger an event once things are done.
* Waiting until invalidate completes prevents 2 updates when changing the date range.
* @returns {undefined}
*/
@ -703,7 +701,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
// Not yet ready
if(!this.options.start_date || !this.options.end_date) return;
// Wait a bit to see if anything else changes, then re-draw the days
if(this.update_timer !== null)
{
@ -797,7 +795,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
this._children[delete_index].free();
this.removeChild(this._children[delete_index--]);
}
// Clear old rows
this.rows.empty()
.append(this.grid);
@ -813,10 +811,10 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
this.grid.find('*').contents().filter(function(){
return this.nodeType === 3;
}).remove();
// Get the rows / labels
var labels = grouper.row_labels.call(this);
// Group the events
var events = {};
for(var i = 0; i < this.value.length; i++)
@ -882,7 +880,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
{
row.doLoadingFinished();
}
// Add actual events
row._update_events(events);
@ -938,16 +936,16 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
for(var left = 0,i = 0; i < days;t.setUTCDate(1),t.setUTCMonth(t.getUTCMonth()+1),left += days_in_month*day_width,i += days_in_month)
{
var u = new Date(t.getUTCFullYear(),t.getUTCMonth()+1,0,-t.getTimezoneOffset()/60);
days_in_month = 1+ ((u-t) / (24*3600*1000))
days_in_month = 1+ ((u-t) / (24*3600*1000));
var first = new Date(t.getUTCFullYear(),t.getUTCMonth(),1,-t.getTimezoneOffset()/60);
if(days_in_month <= 0) break;
if (i + days_in_month > days)
{
days_in_month = days - i;
}
var title = app.calendar.egw.lang(date('F',new Date(t.valueOf() + t.getTimezoneOffset() * 60 * 1000)))
var title = app.calendar.egw.lang(date('F',new Date(t.valueOf() + t.getTimezoneOffset() * 60 * 1000)));
if (days_in_month > 10)
{
title += ' '+t.getUTCFullYear();
@ -967,7 +965,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
/**
* Make a header showing the week numbers
*
*
* @param {Date} start
* @param {number} days
* @returns {string} HTML snippet
@ -976,7 +974,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
{
var content = '<div class="calendar_plannerScale" data-planner_view="week">';
var state = ''
var state = '';
// we're not using UTC so date() formatting function works
var t = new Date(start.valueOf());
@ -998,7 +996,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
// Gets the right week # east of GMT. West does not need it(?)
usertime.setUTCMinutes(usertime.getUTCMinutes() - start.getTimezoneOffset());
}
week_width = 100 / days * Math.min(days, days_in_week);
var title = app.calendar.egw.lang('Week')+' '+app.calendar.date.week_number(usertime);
@ -1006,7 +1004,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
if(start.getTimezoneOffset() > 0)
{
// Gets the right week start west of GMT
usertime.setUTCMinutes(usertime.getUTCMinutes() +start.getTimezoneOffset())
usertime.setUTCMinutes(usertime.getUTCMinutes() +start.getTimezoneOffset());
}
state = app.calendar.date.start_of_week(usertime);
state.setUTCHours(0);
@ -1077,7 +1075,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
/**
* Create a header with hours
*
*
* @param {Date} start
* @param {number} days
* @returns {string} HTML snippet for the header
@ -1104,7 +1102,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
var cell_width = 100 / hours * decr;
var content = '<div class="calendar_plannerScale" data-planner_view="day">';
// we're not using UTC so date() formatting function works
var t = new Date(start.valueOf() + start.getTimezoneOffset() * 60 * 1000);
for(var left = 0,i = 0; i < hours; left += cell_width,i += decr)
@ -1132,7 +1130,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
if(!date) return '';
var day_class = '';
// Holidays and birthdays
var holidays = et2_calendar_view.get_holidays(this,date.getUTCFullYear());
@ -1192,7 +1190,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
if(!parent)
{
debugger;
egw.debug('error','No parent objectManager found')
egw.debug('error','No parent objectManager found');
return;
}
@ -1214,7 +1212,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
var aoi = new et2_action_object_impl(this,this.getDOMNode());
aoi.doTriggerEvent = function(_event, _data) {
// Determine target node
var event = _data.event || false;
if(!event) return;
@ -1298,6 +1296,9 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
/**
* Automatically add dnd support for linking
*
* @param {type} mgr
* @param {type} actionLinks
*/
_init_links_dnd: function(mgr,actionLinks) {
var self = this;
@ -1421,6 +1422,10 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
/**
* Show the current time while dragging
* Used for resizing as well as drag & drop
*
* @param {type} element
* @param {type} position
* @param {type} height
*/
_drag_helper: function(element, position ,height)
{
@ -1441,9 +1446,13 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
//$j(element).width($j(helper).width());
},
/**
* Handler for dropping an event on the timegrid
*
* @param {type} planner
* @param {type} event
* @param {type} ui
*/
_event_drop: function(planner, event,ui) {
var e = new jQuery.Event('change');
@ -1495,7 +1504,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
/**
* Use the egw.data system to get data from the calendar list for the
* selected time span.
*
*
*/
_fetch_data: function()
{
@ -1563,11 +1572,11 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
egw.includeCSS('/phpgwapi/categories.php?app='+event.data.app);
}
}
this.invalidate(false);
}
}, this, this.getInstanceManager().execId,this.id);
t.setUTCDate(t.getUTCDate() + 1);
}
while(t < end);
@ -1641,7 +1650,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
/**
* Change how the planner is grouped
*
*
* @param {string|number} group_by 'user', 'month', or an integer category ID
* @returns {undefined}
*/
@ -1662,6 +1671,8 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
/**
* Call change handler, if set
*
* @param {type} event
*/
change: function(event) {
if (this.onchange)
@ -1681,6 +1692,9 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
/**
* Call event change handler, if set
*
* @param {type} event
* @param {type} dom_node
*/
event_change: function(event, dom_node) {
if (this.onevent_change)
@ -1723,7 +1737,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
click: function(_ev)
{
var result = true;
// Is this click in the event stuff, or in the header?
if(this.gridHeader.has(_ev.target).length === 0 && !$j(_ev.target).hasClass('calendar_plannerRowHeader'))
{
@ -1792,17 +1806,17 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
return false;
}
},
/**
* Get time from position
*
*
* @param {number} x
* @param {number} y
* @returns {Date|Boolean} A time for the given position, or false if one
* could not be determined.
*/
_get_time_from_position: function(x,y) {
x = Math.round(x);
y = Math.round(y);
@ -1840,13 +1854,13 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
}
}
if(rel_time < 0) return false;
var interval = egw.preference('interval','calendar') || 30;
this.date_helper.set_minutes(Math.round(rel_time / (60 * interval))*interval);
return new Date(this.date_helper.getValue());
},
/**
* Code for implementing et2_IDetachedDOM
*
@ -1887,5 +1901,5 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
// Set height for rows
this.rows.height(this.div.height() - this.headers.outerHeight());
}
});
});}).call(this);
et2_register_widget(et2_calendar_planner, ["calendar-planner"]);

View File

@ -1,13 +1,18 @@
/*
/*
* Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package
* @subpackage
* @package
* @subpackage
* @link http://www.egroupware.org
* @author Nathan Gray
* @version $Id$
*/
/*egw:uses
/calendar/js/et2_widget_view.js;
/calendar/js/et2_widget_daycol.js;
/calendar/js/et2_widget_event.js;
*/
/**
@ -17,7 +22,7 @@
*
* @augments et2_valueWidget
*/
var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
var et2_calendar_planner_row = (function(){ "use strict"; return et2_valueWidget.extend([et2_IDetachedDOM],
{
attributes: {
start_date: {
@ -57,7 +62,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
// Used for its date calculations
this.date_helper = et2_createWidget('date-time',{},null);
this.date_helper.loadingFinished();
this.set_start_date(this.options.start_date);
this.set_end_date(this.options.end_date);
@ -73,7 +78,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
destroy: function() {
this._super.apply(this, arguments);
// date_helper has no parent, so we must explicitly remove it
this.date_helper.destroy();
this.date_helper = null;
@ -90,7 +95,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
return this.rows[0];
}
},
/**
* Draw the individual divs for weekends and events
*/
@ -176,7 +181,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
this.options.end_date.setUTCMinutes(59);
this.options.end_date.setUTCSeconds(59);
},
/**
* Mark special days (birthdays, holidays) on the planner
*
@ -201,7 +206,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
(holidays ? ' title="'+holidays.join(',')+'"' : '')+
' ></div>';
}
t.setUTCDate(t.getUTCDate()+1)
t.setUTCDate(t.getUTCDate()+1);
}
return content;
},
@ -231,7 +236,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
value: events[c]
},this);
}
// Seperate loop so column sorting finds all children in the right place
for(var c = 0; c < events.length && c < this._children.length; c++)
{
@ -306,7 +311,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
var end = new Date(a.options.value.end) - new Date(b.options.value.end);
return start ? start : end;
});
for(var n = 0; n < this._children.length; n++)
{
var event = this._children[n].options.value || false;
@ -333,7 +338,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
{
day_start -= daylight_diff;
}
event['start_m'] = parseInt((event.start.valueOf()/1000 - day_start) / 60);
if (event['start_m'] < 0)
{
@ -378,7 +383,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
// Handle the different value types
start = this.options.start_date;
end = this.options.end_date;
if(typeof start === 'string')
{
start = new Date(start);
@ -412,7 +417,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
var start_date = new Date(start.getUTCFullYear(), start.getUTCMonth(),start.getUTCDate());
var end_date = new Date(end.getUTCFullYear(), end.getUTCMonth(),end.getUTCDate());
var t_date = new Date(t.getUTCFullYear(), t.getUTCMonth(),t.getUTCDate());
var days = Math.round((end_date - start_date) / (24 * 3600 * 1000))+1;
pos = 1 / days * Math.round((t_date - start_date) / (24*3600 * 1000));
@ -460,8 +465,8 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
setDetachedAttributes: function(_nodes, _values) {
},
}
});
});}).call(this);
et2_register_widget(et2_calendar_planner_row, ["calendar-planner_row"]);

View File

@ -1,4 +1,4 @@
/*
/*
* Egroupware Calendar timegrid
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
@ -9,12 +9,8 @@
*/
"use strict";
/*egw:uses
/calendar/js/et2_widget_view.js;
/calendar/js/et2_widget_daycol.js;
/calendar/js/et2_widget_event.js;
*/
/**
@ -31,10 +27,10 @@
*
* @augments et2_calendar_view
*/
var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResizeable],
var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view.extend([et2_IDetachedDOM, et2_IResizeable],
{
createNamespace: true,
attributes: {
value: {
type: "any",
@ -99,7 +95,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
.appendTo(this.div);
this.dayHeader = $j(document.createElement("div"))
.appendTo(this.gridHeader);
// Contains times / rows
this.scrolling = $j(document.createElement('div'))
.addClass("calendar_calTimeGridScroll")
@ -119,7 +115,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
.appendTo(this.gridHeader);
this.gridHover = jQuery('<div style="height:5px;" class="calendar_calAddEvent drop-hover">');
// List of dates in Ymd
// The first one should be start_date, last should be end_date
this.day_list = [];
@ -134,7 +130,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.setDOMNode(this.div[0]);
},
destroy: function() {
// Stop listening to tab changes
if(framework.getApplicationByName('calendar').tab)
{
@ -204,7 +200,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.div.on('mouseover', '.calendar_calEvent:not(.ui-resizable):not(.rowNoEdit)', function() {
// Only resize in timegrid
if(timegrid.options.granularity === 0) return;
// Load the event
timegrid._get_event_info(this);
var that = this;
@ -292,10 +288,10 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
{
drop.get(0).scrollIntoView(false);
}
}
}
});
});
// Customize and override some draggable settings
this.div
.on('dragcreate','.calendar_calEvent', function(event, ui) {
@ -323,11 +319,15 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
/**
* Show the current time while dragging
* Used for resizing as well as drag & drop
*
* @param {type} element
* @param {type} helper
* @param {type} height
*/
_drag_helper: function(element, helper,height)
{
if(!element) return;
element.dropEnd = this.gridHover;
if(element.dropEnd.length)
@ -385,6 +385,11 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
/**
* Handler for dropping an event on the timegrid
*
* @param {type} timegrid
* @param {type} event
* @param {type} ui
* @param {type} dropEnd
*/
_event_drop: function(timegrid, event,ui, dropEnd) {
var e = new jQuery.Event('change');
@ -425,7 +430,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
event_widget._parent.date_helper.set_hours(dropEnd.whole_day ? 0 : dropEnd.hour||0);
event_widget._parent.date_helper.set_minutes(dropEnd.whole_day ? 0 : dropEnd.minute||0);
}
// Leave the helper there until the update is done
var loading = ui.helper.clone(true).appendTo($j('body'));
// and add a loading icon so user knows something is happening
@ -437,7 +442,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
{
$j('.calendar_timeDemo',loading).after('<div class="loading"></div>');
}
event_widget.recur_prompt(function(button_id) {
if(button_id === 'cancel' || !button_id)
{
@ -463,12 +468,12 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
else
{
//Edit calendar event
// Duration - check for whole day dropped on a time, change it to full day
var duration = event_widget.options.value.whole_day && dropEnd.hour ? 86400-1 : false;
// Event (whole day or not) dropped on whole day section, change to whole day non blocking
if(dropEnd.whole_day) duration = 'whole_day';
// Send the update
var _send = function(series_instance)
{
@ -534,7 +539,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.widget.update_timer = null;
window.clearTimeout(this.resize_timer);
this.widget.loader.hide().show();
// Update actions
if(this.widget._actionManager)
{
@ -640,13 +645,13 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
.append(this.owner.getDOMNode())
.append(this.dayHeader)
.appendTo(this.div);
// Max with 18 avoids problems when it's not shown
var header_height = Math.max(this.gridHeader.outerHeight(true), 18);
this.scrolling
.appendTo(this.div)
.off()
.off();
// No time grid - list
if(this.options.granularity === 0)
@ -666,7 +671,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
var rowsToDisplay = Math.ceil((totalDisplayMinutes+60)/granularity);
var row_count = (1440 / this.options.granularity);
this.scrolling
.on('scroll', jQuery.proxy(this._scroll, this));
@ -695,7 +700,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
};
var html = '';
var line_height = parseInt(this.div.css('line-height'));
this._top_time = 0
this._top_time = 0;
for(var t = 0,i = 0; t < 1440; t += granularity,++i)
{
html += '<div class="calendar_calTimeRow" style="height: '+(100/row_count)+'%;">';
@ -712,7 +717,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
);
if(t <= wd_start && t + granularity > wd_start)
{
this._top_time = this.rowHeight * (i+1+(wd_start - (t+granularity))/granularity)
this._top_time = this.rowHeight * (i+1+(wd_start - (t+granularity))/granularity);
}
var time_label = (typeof show[granularity] === 'undefined' ? t % 60 === 0 : show[granularity].indexOf(t % 60) !== -1) ? time : '';
@ -749,7 +754,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
}
// No point if it is just going to be redone completely
if(this.upate_timer) return;
this.resize_timer = window.setTimeout(jQuery.proxy(function() {
if(this._resizeTimes)
{
@ -775,7 +780,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
var totalDisplayMinutes = wd_end - wd_start;
var rowsToDisplay = Math.ceil((totalDisplayMinutes+60)/this.options.granularity);
var row_count = (1440 / this.options.granularity);
var new_height = this.scrolling.height() / rowsToDisplay;
var old_height = this.rowHeight;
this.rowHeight = new_height;
@ -785,7 +790,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
'100%' :
(this.rowHeight*row_count)+'px'
);
// Scroll to start of day
this._top_time = (wd_start * this.rowHeight) / this.options.granularity;
this.scrolling.scrollTop(this._top_time);
@ -806,14 +811,14 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
*/
_drawDays: function() {
this.scrolling.append(this.days);
// If day list is still empty, recalculate it from start & end date
if(this.day_list.length === 0 && this.options.start_date && this.options.end_date)
{
this.day_list = this._calculate_day_list(this.options.start_date, this.options.end_date, this.options.show_weekend);
}
// For a single day, we show each owner in their own daycol
var daily_owner = this.day_list.length === 1 &&
var daily_owner = this.day_list.length === 1 &&
this.options.owner.length > 1 &&
this.options.owner.length < (parseInt(egw.preference('day_consolidate','calendar')) || 6);
var daycols_needed = daily_owner ? this.options.owner.length : this.day_list.length;
@ -834,7 +839,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
{
var existing_index = this.day_widgets[add_index] && !daily_owner ? this.day_list.indexOf(this.day_widgets[add_index].options.date) : -1;
before = existing_index > add_index;
var day = et2_createWidget('calendar-daycol',{
owner: this.options.owner,
width: (before ? 0 : day_width) + "px"
@ -877,7 +882,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.day_widgets[delete_index].destroy();
this.day_widgets.splice(delete_index--,1);
}
// Create / update day widgets with dates and data
for(var i = 0; i < this.day_widgets.length; i++)
{
@ -916,7 +921,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
// Adjust and scroll to start of day
this.resizeTimes();
// Don't hold on to value any longer, use the data cache for best info
this.value = {};
@ -927,7 +932,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
// Handle not fully visible elements
this._scroll();
// TODO: Figure out how to do this with detached nodes
/*
var nodes = this.day_col.getDetachedNodes();
@ -944,14 +949,14 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
/**
* Update UI while scrolling within the selected time
*
*
* Toggles out of view indicators and adjusts not visible headers
* @param {Event} event Scroll event
*/
_scroll: function(event)
{
if(!this.day_widgets) return;
// Loop through days, let them deal with it
for(var day = 0; day < this.day_widgets.length; day++)
{
@ -967,13 +972,13 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
* @param {Date|string} end_date Date that et2_date widget can understand
* @param {boolean} show_weekend If not showing weekend, Saturday and Sunday
* will not be in the returned list.
*
*
* @returns {string[]} List of days in Ymd format
*/
_calculate_day_list: function(start_date, end_date, show_weekend) {
var day_list = [];
this.date_helper.set_value(end_date);
var end = this.date_helper.date.getTime();
var i = 1;
@ -1009,10 +1014,10 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
if(!parent)
{
debugger;
egw.debug('error','No parent objectManager found')
egw.debug('error','No parent objectManager found');
return;
}
for(var i = 0; i < parent.children.length; i++)
{
var parent_finder = jQuery(parent.children[i].iface.doGetDOMNode()).find(this.div);
@ -1027,13 +1032,13 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
// are handled internally using jQuery directly.
var widget_object = this._actionObject || parent.getObjectById(this.id);
var aoi = new et2_action_object_impl(this,this.getDOMNode());
aoi.doTriggerEvent = function(_event, _data) {
// Determine target node
var event = _data.event || false;
if(!event) return;
if(_data.ui.draggable.hasClass('rowNoEdit')) return;
/*
We have to handle the drop in the normal event stream instead of waiting
for the egwAction system so we can get the helper, and destination
@ -1067,7 +1072,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
// Remove formatting for out-of-view events (full day non-blocking)
$j('.calendar_calEventHeader',_data.ui.helper).css('top','');
$j('.calendar_calEventBody',_data.ui.helper).css('padding-top','');
if(time.length)
{
// The out will trigger after the over, so we count
@ -1098,7 +1103,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
break;
}
};
if (widget_object == null) {
// Add a new container to the object manager which will hold the widget
// objects
@ -1112,7 +1117,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
widget_object.setAOI(aoi);
}
this._actionObject = widget_object;
// Delete all old objects
widget_object.clear();
widget_object.unregisterActions();
@ -1122,12 +1127,15 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
var action_links = this._get_action_links(actions);
this._init_links_dnd(widget_object.manager, action_links);
widget_object.updateActionLinks(action_links);
},
/**
* Automatically add dnd support for linking
*
* @param {type} mgr
* @param {type} actionLinks
*/
_init_links_dnd: function(mgr,actionLinks) {
var self = this;
@ -1190,7 +1198,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
// Ok, stop.
return false;
}
id = source[i].id.split('::');
links.push({app: id[0] == 'filemanager' ? 'link' : id[0], id: id[1]});
}
@ -1214,7 +1222,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
{
// Get date and time
var params = jQuery.extend({},$j('.drop-hover[data-date]',target.iface.getDOMNode())[0].dataset || {});
// Add link IDs
var app_registry = egw.link_get_registry('calendar');
params[app_registry.add_app] = [];
@ -1291,16 +1299,16 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
*
* Events will be retrieved automatically from the egw.data cache, so there
* is no great need to provide them.
*
*
* @param {Object[]} events Array of events, indexed by date in Ymd format:
* {
* 20150501: [...],
* 20150502: [...]
* }
* Days should be in order.
* @param {string|number|Date} events.start_date - New start date
* @param {string|number|Date} events.end_date - New end date
* @param {number|number[]|string|string[]} event.owner - Owner ID, which can
* {string|number|Date} events.start_date - New start date
* {string|number|Date} events.end_date - New end date
* {number|number[]|string|string[]} event.owner - Owner ID, which can
* be an account ID, a resource ID (as defined in calendar_bo, not
* necessarily an entry from the resource app), or a list containing a
* combination of both.
@ -1308,7 +1316,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
set_value: function set_value(events)
{
if(typeof events !== 'object') return false;
var use_days_sent = true;
if(events.start_date)
@ -1321,7 +1329,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
}
this._super.apply(this,arguments);
if(use_days_sent)
{
var day_list = Object.keys(events);
@ -1330,7 +1338,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.set_start_date(day_list[0]);
this.set_end_date(day_list[day_list.length-1]);
}
// We need to check if we're attached already, as the datastore can cause
// conflicts across other events (especially home) if we call it too early
if(this.isAttached())
@ -1383,7 +1391,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
{
var old = this.options.owner || 0;
this._super.apply(this, arguments);
this.owner.set_label('');
this.div.removeClass('calendar_TimeGridNoLabel');
@ -1415,7 +1423,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
}
else
{
this.owner.options.application = 'home-accounts'
this.owner.options.application = 'home-accounts';
this.owner.set_value(typeof _owner == "string" || typeof _owner == "number" ? _owner : jQuery.extend([],_owner));
this.set_label('');
$j(this.getDOMNode(this.owner)).prepend(this.owner.getDOMNode());
@ -1454,21 +1462,21 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.options.owner.length > 1
);
},
/**
* Set how big the time divisions are
*
* Setting granularity to 0 will remove the time divisions and display
* each days events in a list style. This 'gridlist' is not to be confused
* with the list view, which uses a nextmatch.
*
*
* @param {number} minutes
*/
set_granularity: function(minutes)
{
// Avoid < 0
minutes = Math.max(0,minutes);
if(this.options.granularity !== minutes)
{
if(this.options.granularity === 0 || minutes === 0)
@ -1528,6 +1536,9 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
/**
* Call event change handler, if set
*
* @param {type} event
* @param {type} dom_node
*/
event_change: function(event, dom_node) {
if (this.onevent_change)
@ -1580,7 +1591,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
click: function(_ev)
{
var result = true;
// Is this click in the event stuff, or in the header?
if(_ev.target.dataset.id || $j(_ev.target).parents('.calendar_calEvent').length)
{
@ -1639,13 +1650,13 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
*
* This does not return an actual time on a clock, but finds the closest
* time node (.calendar_calAddEvent or day column) to the given position.
*
*
* @param {number} x
* @param {number} y
* @returns {DOMNode[]} time node(s) for the given position
*/
_get_time_from_position: function(x,y) {
x = Math.round(x);
y = Math.round(y);
if(this.options.granularity === 0)
@ -1660,7 +1671,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
delete this.gridHover[0].dataset[id];
}
var node = document.elementFromPoint(x,y);
while(node && node != this.node && node.tagName != 'BODY' && path.length < 10)
{
path.push(node);
@ -1716,7 +1727,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.gridHover.css('left','');
return this.gridHover;
},
/**
* Code for implementing et2_IDetachedDOM
*
@ -1745,7 +1756,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
// Resizable interface
/**
* @param {boolean} [too_small=null] Force the widget to act as if it was too small
* @param {boolean} [_too_small=null] Force the widget to act as if it was too small
*/
resize: function (_too_small)
{
@ -1773,9 +1784,9 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
// Allow for toolbar
height -= $j('#calendar-toolbar',this.div.parents('.egw_fw_ui_tab_content')).outerHeight(true);
this.options.height = Math.floor(height / rowCount);
// Allow for borders & padding
this.options.height -= 2*((this.div.outerWidth(true) - this.div.innerWidth()) + parseInt(this.div.parent().css('padding-top')));
@ -1813,7 +1824,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.div.removeClass('calendar_calTimeGridFixed');
}
this.div.css('height', this.options.height);
// Re-do time grid
if(!this.update_timer)
{
@ -1833,5 +1844,5 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
day.set_width(day_width + 'px');
}
}
});
});}).call(this);
et2_register_widget(et2_calendar_timegrid, ["calendar-timegrid"]);

View File

@ -1,15 +1,13 @@
/*
/*
* Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package
* @subpackage
* @package
* @subpackage
* @link http://www.egroupware.org
* @author Nathan Gray
* @version $Id$
*/
"use strict";
/*egw:uses
/etemplate/js/et2_core_valueWidget;
*/
@ -20,13 +18,13 @@
*
* et2_calendar_view is responsible for its own loader div, which is displayed while
* the times & days are redrawn.
*
*
* @augments et2_valueWidget
*/
var et2_calendar_view = et2_valueWidget.extend(
var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend(
{
createNamespace: true,
attributes: {
owner: {
name: "Owner",
@ -41,7 +39,7 @@ var et2_calendar_view = et2_valueWidget.extend(
end_date: {
name: "End date",
type: "any"
},
}
},
/**
@ -67,7 +65,7 @@ var et2_calendar_view = et2_valueWidget.extend(
// date_helper has no parent, so we must explicitly remove it
this.date_helper.destroy();
this.date_helper = null;
// Stop the invalidate timer
if(this.update_timer)
{
@ -89,7 +87,7 @@ var et2_calendar_view = et2_valueWidget.extend(
* @param {boolean} [trigger_event=false] Trigger an event once things are done.
* Waiting until invalidate completes prevents 2 updates when changing the date range.
* @returns {undefined}
*
*
* @memberOf et2_calendar_view
*/
invalidate: function invalidate(trigger_event) {
@ -253,9 +251,9 @@ var et2_calendar_view = et2_valueWidget.extend(
* 20150502: [...]
* }
* Days should be in order.
* @param {string|number|Date} events.start_date - New start date
* @param {string|number|Date} events.end_date - New end date
* @param {number|number[]|string|string[]} event.owner - Owner ID, which can
* {string|number|Date} events.start_date - New start date
* {string|number|Date} events.end_date - New end date
* {number|number[]|string|string[]} event.owner - Owner ID, which can
* be an account ID, a resource ID (as defined in calendar_bo, not
* necessarily an entry from the resource app), or a list containing a
* combination of both.
@ -333,7 +331,7 @@ var et2_calendar_view = et2_valueWidget.extend(
}
else // users
{
user = parseInt(user)
user = parseInt(user);
var accounts = egw.accounts('both');
for(var j = 0; j < accounts.length; j++)
{
@ -376,9 +374,9 @@ var et2_calendar_view = et2_valueWidget.extend(
result.widget_id = 'event_' + widget_id.join('');
}
return result;
},
}
});
});}).call(this);
// Static class stuff
jQuery.extend(et2_calendar_view,
@ -386,7 +384,7 @@ jQuery.extend(et2_calendar_view,
/**
* Check if the view should be consolidated into one, or listed seperately
* based on the user's preferences
*
*
* @param {string[]} owners List of owners
* @param {string} view Name of current view (day, week)
* @returns {boolean} True of only one is needed, false if each owner needs