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({
@ -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

@ -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: {
@ -95,7 +93,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
rowHeight: 20,
// Percentage; not yet available
titleHeight: 2.0
}
};
this.registeredUID = 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++;
@ -314,7 +312,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
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)
{
@ -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)
{
@ -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: {
@ -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

View File

@ -9,8 +9,6 @@
*/
"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,7 +79,7 @@ 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

@ -9,8 +9,6 @@
*/
"use strict";
/*egw:uses
/calendar/js/et2_widget_view.js;
/calendar/js/et2_widget_planner_row.js;
@ -25,7 +23,7 @@
*
* @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,
@ -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];
@ -938,7 +936,7 @@ 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;
@ -947,7 +945,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
{
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();
@ -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());
@ -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);
@ -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;
}
@ -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)
{
@ -1444,6 +1449,10 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
/**
* 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');
@ -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)
@ -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

@ -8,6 +8,11 @@
* @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: {
@ -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;
},
@ -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

@ -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,7 +27,7 @@
*
* @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,
@ -323,6 +319,10 @@ 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)
{
@ -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');
@ -646,7 +651,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.scrolling
.appendTo(this.div)
.off()
.off();
// No time grid - list
if(this.options.granularity === 0)
@ -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 : '';
@ -1009,7 +1014,7 @@ 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;
}
@ -1128,6 +1133,9 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
/**
* Automatically add dnd support for linking
*
* @param {type} mgr
* @param {type} actionLinks
*/
_init_links_dnd: function(mgr,actionLinks) {
var self = this;
@ -1298,9 +1306,9 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
* 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.
@ -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());
@ -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)
@ -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)
{
@ -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

@ -8,8 +8,6 @@
* @version $Id$
*/
"use strict";
/*egw:uses
/etemplate/js/et2_core_valueWidget;
*/
@ -23,7 +21,7 @@
*
* @augments et2_valueWidget
*/
var et2_calendar_view = et2_valueWidget.extend(
var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend(
{
createNamespace: true,
@ -41,7 +39,7 @@ var et2_calendar_view = et2_valueWidget.extend(
end_date: {
name: "End date",
type: "any"
},
}
},
/**
@ -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,