This time I will share jQuery Plugin and tutorial about Dynamic Weekly Scheduler With jQuery – Schedule.js, hope it will help you in programming stack.
Schedule.js is small jQuery plugin for rendering a dynamic weekly scheduler that allows setting schedules (time periods) for recurring weekly tasks. You’re able to select multiple time slots via mouse drag and move when in the ‘Edition’ mode.
Install it:
2 |
yarn add jquery-schedule |
5 |
$ npm install jquery-schedule |
How to use it:
1. To get started, you need to load jQuery library and the jQuery Schedule.js plugin’s files in the html file.
1 |
< link rel = "stylesheet" href = "dist/jquery.schedule.css" > |
2 |
< script src = "jquery.min.js" ></ script > |
3 |
< script src = "dist/jquery.schedule.js" ></ script > |
2. Load the jQuery UI library for the ‘Edition’ mode:
1 |
< link rel = "stylesheet" href = "jquery-ui.css" > |
2 |
< script src = "jquery-ui.min.js" ></ script > |
3. Create a container for the Weekly Scheduler.
1 |
< div id = "schedule-demo" ></ div > |
4. Initialize the plugin and add your custom schedules (time periods) to the Weekly Scheduler:
01 |
$( "#schedule-demo" ).jqs({ |
5. Set the Weekly Scheduler to the ‘Edition’ mode that allows the users to create custom schedules via mouse drag and move.
1 |
$( "#schedule-demo" ).jqs({ |
6 |
$( "#schedule-demo" ).jqs(); |
6. Import the custom schedules into a data array.
1 |
< input type = "button" value = "Export" id = "export" /> |
1 |
< textarea id = "result" ></ textarea > |
1 |
$( "#export" ).click( function () { |
2 |
$( "#result" ).val($( "#schedule" ).jqs( 'export' )); |
7. More default plugin options.
01 |
$( "#schedule-demo" ).jqs({ |
10 |
periodBackgroundColor: "rgba(82, 155, 255, 0.5)" , |
11 |
periodBorderColor: "#2a3cff" , |
12 |
periodTextColor: "#000" , |
13 |
periodRemoveButton: "Remove" , |
14 |
periodDuplicateButton: 'Duplicate' , |
15 |
periodTitlePlaceholder: "Title" , |
25 |
onInit: function () {}, |
26 |
onAddPeriod: function () {}, |
27 |
onRemovePeriod: function () {}, |
28 |
onClickPeriod: function () {}, |
29 |
onDuplicatePeriod: function () {}, |
8. Import/export schedule data:
02 |
var data = $( "#schedule" ).jqs( 'export' ); |
05 |
$( "#schedule" ).jqs( 'import' , [ |
Change logs:
v2.1.0 (2018-04-26)
- Add a duplicate button for periods. This feature allows to copy the selected period to all days if space is available. Periods already placed are not overwritten
- Add a duplicate button for days. This feature allows to copy all periods in a day to all other days if space is available. Periods already placed are not overwritten
source : jquery.net