-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheduler-el.html
149 lines (126 loc) · 4.78 KB
/
scheduler-el.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<link rel="import" href="../polymer/polymer.html">
<link rel="stylesheet" href="scheduler_8.css">
<script src="../jquery/dist/jquery.slim.min.js"></script>
<script src='daypilot-all.min.js'></script>
<!--
`scheduler-el`
Simple scheduler element using DayPilot library
@demo demo/index.html
-->
<dom-module id="scheduler-el">
<template>
<style>
:host {
display: block;
}
</style>
<h2>Hello There [[prop1]]</h2>
<div id="dp"></div>
</template>
<script>
Polymer({
is: 'scheduler-el',
properties: {
prop1: {
type: String,
value: 'scheduler-el',
},
},
attached: function() {
// `attached` fires once the element and its parents have been inserted
// into a document.
//
// This is a good place to perform any work related to your element's
// visual state or active behavior (measuring sizes, beginning animations,
// loading resources, etc).
var dp = $(this.shadowRoot).find("#dp").daypilotScheduler({
// behavior and appearance
theme : "scheduler_8",
// view
startDate : new DayPilot.Date("2013-01-01"), // or just startDate : "2013-03-25";
cellGroupBy : "Month",
days : 365,
cellDuration : 1440, // one day
moveBy : 'Full',
// bubble, sync loading
// see also DayPilot.Event.data.staticBubbleHTML property
bubble : new DayPilot.Bubble({
onLoad: function(args) {
var ev = args.source;
args.html = "testing bubble for: " + ev.text();
}
}),
contextMenu : new DayPilot.Menu({items: [
{text:"Show event ID", onclick: function() {alert("Event value: " + this.source.value());} },
{text:"Show event text", onclick: function() {alert("Event text: " + this.source.text());} },
{text:"Show event start", onclick: function() {alert("Event start: " + this.source.start().toStringSortable());} },
{text:"Go to google.com", href: "http://www.google.com/?q={0}"},
{text:"CallBack: Delete this event", command: "delete"} ,
{text:"submenu", items: [
{text:"Show event ID", onclick: function() {alert("Event value: " + this.source.value());} },
{text:"Show event text", onclick: function() {alert("Event text: " + this.source.text());} }
]
}
]}),
treeEnabled : true,
rowHeaderWidth : 200,
resources : [
{ name: "Room A", id: "A", expanded: true, children:[
{ name : "Room A.1", id : "A.1" },
{ name : "Room A.2", id : "A.2" }
]
},
{ name: "Room B", id: "B" },
{ name: "Room C", id: "C" }
],
});
// generate and load events
for (var i = 0; i < 10; i++) {
var duration = Math.floor(Math.random() * 6) + 1; // 1 to 6
var start = Math.floor(Math.random() * 6) - 3; // -3 to 3
var e = new DayPilot.Event({
start: new DayPilot.Date("2013-03-25T00:00:00").addHours(start),
end: new DayPilot.Date("2013-03-25T12:00:00").addHours(start).addHours(duration),
id: DayPilot.guid(),
resource: "B",
text: "Event",
bubbleHtml: "Testing bubble"
});
dp.events.add(e);
}
dp.eventHoverHandling = "Bubble";
// event moving
dp.onEventMoved = function (args) {
dp.message("Moved: " + args.e.text());
};
// event resizing
dp.onEventResized = function (args) {
dp.message("Resized: " + args.e.text());
};
// event creating
dp.onTimeRangeSelected = function (args) {
var name = prompt("New event name:", "Event");
dp.clearSelection();
if (!name) return;
var e = new DayPilot.Event({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: name
});
dp.events.add(e);
dp.message("Created");
};
dp.onEventClicked = function(args) {
alert("clicked: " + args.e.id());
};
dp.onTimeHeaderClick = function(args) {
alert("clicked: " + args.header.start);
};
dp.init();
dp.scrollTo("2013-03-25");
},
});
</script>
</dom-module>