Last active
August 29, 2015 14:07
-
-
Save Toilal/5871680f0e5f2fa54412 to your computer and use it in GitHub Desktop.
angular-gantt TimeFrames Proposal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// timeFrames defines named ranges of hours in a day. | |
// Each timeFrame can be marked as working or non-working, and have a css class attached. | |
var timeFrames = { | |
'day': {'start': '09:00', 'end': '18:00', 'working': true, 'css-class': 'gantt-range-day'}, | |
'noon': {'start': '12:00', 'end': '13:30', 'working': false, 'css-class': 'gantt-range-noon'}, | |
'morning': {'start': '09:00', 'end': '12:00', 'working': true, 'css-class': 'gantt-range-morning'}, | |
'afternoon': {'start': '13:30', 'end': '18:00', 'working': true, 'css-class': 'gantt-range-afternoon'}, | |
'closed': {'working': false, 'css-class': 'closed'} // If no start nor end is defined, consider this as full day. | |
}; | |
// timeFramesMappings defines how those timeFrames will be placed for each days. | |
var timeFramesMappings = { | |
// The default mapping. | |
'default': function(date) { | |
// This function is called for each distinct days. | |
if (date.weekday() < 5) { | |
return ['day', 'noon']; // From monday to friday, use day and noon timeFrame. | |
} else { | |
return ['closed']; // We are closed at weekend. | |
} | |
}, | |
// Another mapping, named closed. Will be used later with dateFrames. | |
'closed': function(date) { | |
return ['closed']; | |
} | |
}; | |
// dateFrames defines name ranges of days in the calendar. | |
// For each dateFrame, a specific mapping can be applied. | |
var dateFrames = { | |
'default': {'mapping': 'default'}, // Define default mapping. (faculative, if a mapping is named | |
//'default', it will be used as default without this line) | |
'holidays': {'start': '2013/08/01', 'end': '2013/08/15', 'mapping' : 'closed'}, // Define holidays to use closed mapping. | |
'christmas': {'date': '2013/12/25', 'mapping': 'closed'}, // A single date can be used. | |
'special-dates': {'date': ['2013/12/06', '2013/10/08'], 'mapping': 'closed'}, // Or an array | |
'free-afternoons': {'date': ['2013/09/06', '2013/10/05'], 'frame': 'morning'} // A timeFrame can be specified directly. | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment