@ -70,7 +70,6 @@ Messages.calendar_deleteConfirm = "Are you sure you want to delete this calendar
Messages . calendar _deleteTeamConfirm = "Are you sure you want to delete this calendar from this team?" ;
Messages . calendar _deleteTeamConfirm = "Are you sure you want to delete this calendar from this team?" ;
Messages . calendar _deleteOwned = " It will still be visible for the users it has been shared with." ;
Messages . calendar _deleteOwned = " It will still be visible for the users it has been shared with." ;
Messages . calendar _errorNoCalendar = "No editable calendar selected!" ;
Messages . calendar _errorNoCalendar = "No editable calendar selected!" ;
Messages . calendar _myCalendars = "My calendars" ;
Messages . calendar _tempCalendar = "Viewing" ;
Messages . calendar _tempCalendar = "Viewing" ;
Messages . calendar _import = "Import to my calendars" ;
Messages . calendar _import = "Import to my calendars" ;
Messages . calendar _import _temp = "Import this calendar" ;
Messages . calendar _import _temp = "Import this calendar" ;
@ -78,6 +77,7 @@ Messages.calendar_newEvent = "New event";
Messages . calendar _new = "New calendar" ;
Messages . calendar _new = "New calendar" ;
Messages . calendar _dateRange = "{0} - {1}" ;
Messages . calendar _dateRange = "{0} - {1}" ;
Messages . calendar _dateTimeRange = "{0} {1} - {2}" ;
Messages . calendar _dateTimeRange = "{0} {1} - {2}" ;
Messages . calendar _weekNumber = "Week {0}" ;
Messages . calendar _update = "Update" ;
Messages . calendar _update = "Update" ;
Messages . calendar _title = "Title" ;
Messages . calendar _title = "Title" ;
Messages . calendar _loc = "Location" ;
Messages . calendar _loc = "Location" ;
@ -153,13 +153,16 @@ Messages.calendar_noNotification = "None";
return ( brightness > 125 ) ? '#424242' : '#EEEEEE' ;
return ( brightness > 125 ) ? '#424242' : '#EEEEEE' ;
} ;
} ;
var getWeekDays = function ( ) {
var getWeekDays = function ( large ) {
var baseDate = new Date ( Date . UTC ( 2017 , 0 , 1 ) ) ; // just a Sunday
var baseDate = new Date ( Date . UTC ( 2017 , 0 , 1 ) ) ; // just a Sunday
var weekDays = [ ] ;
var weekDays = [ ] ;
for ( var i = 0 ; i < 7 ; i ++ ) {
for ( var i = 0 ; i < 7 ; i ++ ) {
weekDays . push ( baseDate . toLocaleDateString ( undefined , { weekday : 'long' } ) ) ;
weekDays . push ( baseDate . toLocaleDateString ( undefined , { weekday : 'long' } ) ) ;
baseDate . setDate ( baseDate . getDate ( ) + 1 ) ;
baseDate . setDate ( baseDate . getDate ( ) + 1 ) ;
}
}
if ( ! large ) {
weekDays = weekDays . map ( function ( day ) { return day . slice ( 0 , 3 ) ; } ) ;
}
return weekDays . map ( function ( day ) { return day . replace ( /^./ , function ( str ) { return str . toUpperCase ( ) ; } ) ; } ) ;
return weekDays . map ( function ( day ) { return day . replace ( /^./ , function ( str ) { return str . toUpperCase ( ) ; } ) ; } ) ;
} ;
} ;
@ -314,7 +317,6 @@ Messages.calendar_noNotification = "None";
}
}
} ;
} ;
// XXX Note: always create calendars in your own proxy. If you want a team calendar, you can share it with the team later.
var editCalendar = function ( id ) {
var editCalendar = function ( id ) {
var isNew = ! id ;
var isNew = ! id ;
var data = APP . calendars [ id ] ;
var data = APP . calendars [ id ] ;
@ -449,7 +451,7 @@ Messages.calendar_noNotification = "None";
pathname : "/calendar/" ,
pathname : "/calendar/" ,
friends : friends ,
friends : friends ,
title : title ,
title : title ,
password : cal . password , // XXX support passwords
password : cal . password ,
calendar : {
calendar : {
title : title ,
title : title ,
color : color ,
color : color ,
@ -476,7 +478,7 @@ Messages.calendar_noNotification = "None";
var href = Hash . hashToHref ( h . editHash || h . viewHash , 'calendar' ) ;
var href = Hash . hashToHref ( h . editHash || h . viewHash , 'calendar' ) ;
Access . getAccessModal ( common , {
Access . getAccessModal ( common , {
title : title ,
title : title ,
password : cal . password , // XXX support passwords
password : cal . password ,
calendar : {
calendar : {
title : title ,
title : title ,
color : color ,
color : color ,
@ -633,7 +635,6 @@ Messages.calendar_noNotification = "None";
return UIElements . createDropdown ( dropdownConfig ) [ 0 ] ;
return UIElements . createDropdown ( dropdownConfig ) [ 0 ] ;
} ;
} ;
var makeCalendarEntry = function ( id , teamId ) {
var makeCalendarEntry = function ( id , teamId ) {
// XXX handle RESTRICTED calendars (data.restricted)
var data = APP . calendars [ id ] ;
var data = APP . calendars [ id ] ;
var edit ;
var edit ;
if ( data . loading ) {
if ( data . loading ) {
@ -686,8 +687,8 @@ Messages.calendar_noNotification = "None";
var filter = function ( teamId ) {
var filter = function ( teamId ) {
return Object . keys ( APP . calendars || { } ) . filter ( function ( id ) {
return Object . keys ( APP . calendars || { } ) . filter ( function ( id ) {
var cal = APP . calendars [ id ] || { } ;
var cal = APP . calendars [ id ] || { } ;
var teams = cal . teams || [ ] ;
var teams = ( cal . teams || [ ] ) . map ( function ( tId ) { return Number ( tId ) ; } ) ;
return teams . indexOf ( typeof ( teamId ) !== "undefined" ? teamId : 1 ) !== - 1 ;
return teams . indexOf ( typeof ( teamId ) !== "undefined" ? Number ( teamId ) : 1 ) !== - 1 ;
} ) ;
} ) ;
} ;
} ;
var tempCalendars = filter ( 0 ) ;
var tempCalendars = filter ( 0 ) ;
@ -717,8 +718,13 @@ Messages.calendar_noNotification = "None";
}
}
var myCalendars = filter ( 1 ) ;
var myCalendars = filter ( 1 ) ;
if ( myCalendars . length ) {
if ( myCalendars . length ) {
var user = metadataMgr . getUserData ( ) ;
var avatar = h ( 'span.cp-avatar' ) ;
var name = user . name || Messages . anonymous ;
common . displayAvatar ( $ ( avatar ) , user . avatar , name ) ;
APP . $calendars . append ( h ( 'div.cp-calendar-team' , [
APP . $calendars . append ( h ( 'div.cp-calendar-team' , [
h ( 'span' , Messages . calendar _myCalendars )
avatar ,
h ( 'span.cp-name' , { title : name } , name )
] ) ) ;
] ) ) ;
}
}
myCalendars . forEach ( function ( id ) {
myCalendars . forEach ( function ( id ) {
@ -754,11 +760,26 @@ Messages.calendar_noNotification = "None";
onCalendarsUpdate . fire ( ) ;
onCalendarsUpdate . fire ( ) ;
} ;
} ;
var ISO8601 _week _no = function ( dt ) {
var tdt = new Date ( dt . valueOf ( ) ) ;
var dayn = ( dt . getDay ( ) + 6 ) % 7 ;
tdt . setDate ( tdt . getDate ( ) - dayn + 3 ) ;
var firstThursday = tdt . valueOf ( ) ;
tdt . setMonth ( 0 , 1 ) ;
if ( tdt . getDay ( ) !== 4 ) {
tdt . setMonth ( 0 , 1 + ( ( 4 - tdt . getDay ( ) ) + 7 ) % 7 ) ;
}
return 1 + Math . ceil ( ( firstThursday - tdt ) / 604800000 ) ;
} ;
var updateDateRange = function ( ) {
var updateDateRange = function ( ) {
var range = APP . calendar . _renderRange ;
var range = APP . calendar . _renderRange ;
var start = range . start . _date . toLocaleDateString ( ) ;
var start = range . start . _date . toLocaleDateString ( ) ;
var end = range . end . _date . toLocaleDateString ( ) ;
var end = range . end . _date . toLocaleDateString ( ) ;
var week = ISO8601 _week _no ( range . start . _date ) ;
var date = [
var date = [
h ( 'b.cp-small' , Messages . _getKey ( 'calendar_weekNumber' , [ week ] ) ) ,
h ( 'b' , start ) ,
h ( 'b' , start ) ,
h ( 'span' , ' - ' ) ,
h ( 'span' , ' - ' ) ,
h ( 'b' , end ) ,
h ( 'b' , end ) ,
@ -791,6 +812,7 @@ Messages.calendar_noNotification = "None";
h ( 'div#cp-sidebarlayout-rightside' )
h ( 'div#cp-sidebarlayout-rightside' )
] ) ;
] ) ;
var large = $ ( window ) . width ( ) >= 800 ;
var cal = APP . calendar = new Calendar ( '#cp-sidebarlayout-rightside' , {
var cal = APP . calendar = new Calendar ( '#cp-sidebarlayout-rightside' , {
defaultView : view || 'week' , // weekly view option
defaultView : view || 'week' , // weekly view option
taskView : false ,
taskView : false ,
@ -800,19 +822,36 @@ Messages.calendar_noNotification = "None";
calendars : getCalendars ( ) ,
calendars : getCalendars ( ) ,
template : templates ,
template : templates ,
month : {
month : {
daynames : getWeekDays ( ) ,
daynames : getWeekDays ( large ) ,
startDayOfWeek : 1 ,
startDayOfWeek : 1 ,
} ,
} ,
week : {
week : {
daynames : getWeekDays ( ) ,
daynames : getWeekDays ( large ) ,
startDayOfWeek : 1 ,
startDayOfWeek : 1 ,
}
}
} ) ;
} ) ;
$ ( window ) . on ( 'resize' , function ( ) {
var _large = $ ( window ) . width ( ) >= 800 ;
if ( large !== _large ) {
large = _large ;
cal . setOptions ( {
month : {
daynames : getWeekDays ( _large ) ,
startDayOfWeek : 1 ,
} ,
week : {
daynames : getWeekDays ( _large ) ,
startDayOfWeek : 1 ,
}
} ) ;
}
} ) ;
makeLeftside ( cal , $ ( leftside ) ) ;
makeLeftside ( cal , $ ( leftside ) ) ;
cal . on ( 'beforeCreateSchedule' , function ( event ) {
cal . on ( 'beforeCreateSchedule' , function ( event ) {
// XXX Recurrence (later)
// TODO Recurrence (later)
// On creation, select a recurrence rule (daily / weekly / monthly / more weird rules)
// On creation, select a recurrence rule (daily / weekly / monthly / more weird rules)
// then mark it under recurrence rule with a uid (the same for all the recurring events)
// then mark it under recurrence rule with a uid (the same for all the recurring events)
// ie: recurrenceRule: DAILY|{uid}
// ie: recurrenceRule: DAILY|{uid}
@ -925,7 +964,7 @@ Messages.calendar_noNotification = "None";
APP . toolbar . $bottomR . append ( $block ) ;
APP . toolbar . $bottomR . append ( $block ) ;
// New event button
// New event button
var newEventBtn = h ( 'button ', [
var newEventBtn = h ( 'button .cp-calendar-newevent ', [
h ( 'i.fa.fa-plus' ) ,
h ( 'i.fa.fa-plus' ) ,
h ( 'span' , Messages . calendar _newEvent )
h ( 'span' , Messages . calendar _newEvent )
] ) ;
] ) ;
@ -974,7 +1013,7 @@ Messages.calendar_noNotification = "None";
var getNotificationDropdown = function ( ) {
var getNotificationDropdown = function ( ) {
var ev = APP . editModalData ;
var ev = APP . editModalData ;
var calId = ev . selectedCal . id ;
var calId = ev . selectedCal . id ;
// XXX DEFAULT HERE [10] ==> 10 minutes before the event
// DEFAULT HERE [10] ==> 10 minutes before the event
var oldReminders = Util . find ( APP . calendars , [ calId , 'content' , 'content' , ev . id , 'reminders' ] ) || [ 10 ] ;
var oldReminders = Util . find ( APP . calendars , [ calId , 'content' , 'content' , ev . id , 'reminders' ] ) || [ 10 ] ;
APP . notificationsEntries = [ ] ;
APP . notificationsEntries = [ ] ;
var number = h ( 'input.tui-full-calendar-content' , {
var number = h ( 'input.tui-full-calendar-content' , {