You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5272 lines
185 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.ns('Ext.calendar');
  16. (function() {
  17. Ext.apply(Ext.calendar, {
  18. Date: {
  19. diffDays: function(start, end) {
  20. day = 1000 * 60 * 60 * 24;
  21. diff = end.clearTime(true).getTime() - start.clearTime(true).getTime();
  22. return Math.ceil(diff / day);
  23. },
  24. copyTime: function(fromDt, toDt) {
  25. var dt = toDt.clone();
  26. dt.setHours(
  27. fromDt.getHours(),
  28. fromDt.getMinutes(),
  29. fromDt.getSeconds(),
  30. fromDt.getMilliseconds());
  31. return dt;
  32. },
  33. compare: function(dt1, dt2, precise) {
  34. if (precise !== true) {
  35. dt1 = dt1.clone();
  36. dt1.setMilliseconds(0);
  37. dt2 = dt2.clone();
  38. dt2.setMilliseconds(0);
  39. }
  40. return dt2.getTime() - dt1.getTime();
  41. },
  42. // private helper fn
  43. maxOrMin: function(max) {
  44. var dt = (max ? 0: Number.MAX_VALUE),
  45. i = 0,
  46. args = arguments[1],
  47. ln = args.length;
  48. for (; i < ln; i++) {
  49. dt = Math[max ? 'max': 'min'](dt, args[i].getTime());
  50. }
  51. return new Date(dt);
  52. },
  53. max: function() {
  54. return this.maxOrMin.apply(this, [true, arguments]);
  55. },
  56. min: function() {
  57. return this.maxOrMin.apply(this, [false, arguments]);
  58. }
  59. }
  60. });
  61. })();/**
  62. * @class Ext.calendar.DayHeaderTemplate
  63. * @extends Ext.XTemplate
  64. * <p>This is the template used to render the all-day event container used in {@link Ext.calendar.DayView DayView} and
  65. * {@link Ext.calendar.WeekView WeekView}. Internally the majority of the layout logic is deferred to an instance of
  66. * {@link Ext.calendar.BoxLayoutTemplate}.</p>
  67. * <p>This template is automatically bound to the underlying event store by the
  68. * calendar components and expects records of type {@link Ext.calendar.EventRecord}.</p>
  69. * <p>Note that this template would not normally be used directly. Instead you would use the {@link Ext.calendar.DayViewTemplate}
  70. * that internally creates an instance of this template along with a {@link Ext.calendar.DayBodyTemplate}.</p>
  71. * @constructor
  72. * @param {Object} config The config object
  73. */
  74. Ext.calendar.DayHeaderTemplate = function(config){
  75. Ext.apply(this, config);
  76. this.allDayTpl = new Ext.calendar.BoxLayoutTemplate(config);
  77. this.allDayTpl.compile();
  78. Ext.calendar.DayHeaderTemplate.superclass.constructor.call(this,
  79. '<div class="ext-cal-hd-ct">',
  80. '<table class="ext-cal-hd-days-tbl" cellspacing="0" cellpadding="0">',
  81. '<tbody>',
  82. '<tr>',
  83. '<td class="ext-cal-gutter"></td>',
  84. '<td class="ext-cal-hd-days-td"><div class="ext-cal-hd-ad-inner">{allDayTpl}</div></td>',
  85. '<td class="ext-cal-gutter-rt"></td>',
  86. '</tr>',
  87. '</tobdy>',
  88. '</table>',
  89. '</div>'
  90. );
  91. };
  92. Ext.extend(Ext.calendar.DayHeaderTemplate, Ext.XTemplate, {
  93. applyTemplate : function(o){
  94. return Ext.calendar.DayHeaderTemplate.superclass.applyTemplate.call(this, {
  95. allDayTpl: this.allDayTpl.apply(o)
  96. });
  97. }
  98. });
  99. Ext.calendar.DayHeaderTemplate.prototype.apply = Ext.calendar.DayHeaderTemplate.prototype.applyTemplate;
  100. /**
  101. * @class Ext.calendar.DayBodyTemplate
  102. * @extends Ext.XTemplate
  103. * <p>This is the template used to render the scrolling body container used in {@link Ext.calendar.DayView DayView} and
  104. * {@link Ext.calendar.WeekView WeekView}. This template is automatically bound to the underlying event store by the
  105. * calendar components and expects records of type {@link Ext.calendar.EventRecord}.</p>
  106. * <p>Note that this template would not normally be used directly. Instead you would use the {@link Ext.calendar.DayViewTemplate}
  107. * that internally creates an instance of this template along with a {@link Ext.calendar.DayHeaderTemplate}.</p>
  108. * @constructor
  109. * @param {Object} config The config object
  110. */
  111. Ext.calendar.DayBodyTemplate = function(config){
  112. Ext.apply(this, config);
  113. Ext.calendar.DayBodyTemplate.superclass.constructor.call(this,
  114. '<table class="ext-cal-bg-tbl" cellspacing="0" cellpadding="0">',
  115. '<tbody>',
  116. '<tr height="1">',
  117. '<td class="ext-cal-gutter"></td>',
  118. '<td colspan="{dayCount}">',
  119. '<div class="ext-cal-bg-rows">',
  120. '<div class="ext-cal-bg-rows-inner">',
  121. '<tpl for="times">',
  122. '<div class="ext-cal-bg-row">',
  123. '<div class="ext-cal-bg-row-div ext-row-{[xindex]}"></div>',
  124. '</div>',
  125. '</tpl>',
  126. '</div>',
  127. '</div>',
  128. '</td>',
  129. '</tr>',
  130. '<tr>',
  131. '<td class="ext-cal-day-times">',
  132. '<tpl for="times">',
  133. '<div class="ext-cal-bg-row">',
  134. '<div class="ext-cal-day-time-inner">{.}</div>',
  135. '</div>',
  136. '</tpl>',
  137. '</td>',
  138. '<tpl for="days">',
  139. '<td class="ext-cal-day-col">',
  140. '<div class="ext-cal-day-col-inner">',
  141. '<div id="{[this.id]}-day-col-{.:date("Ymd")}" class="ext-cal-day-col-gutter"></div>',
  142. '</div>',
  143. '</td>',
  144. '</tpl>',
  145. '</tr>',
  146. '</tbody>',
  147. '</table>'
  148. );
  149. };
  150. Ext.extend(Ext.calendar.DayBodyTemplate, Ext.XTemplate, {
  151. // private
  152. applyTemplate : function(o){
  153. this.today = new Date().clearTime();
  154. this.dayCount = this.dayCount || 1;
  155. var i = 0, days = [],
  156. dt = o.viewStart.clone(),
  157. times;
  158. for(; i<this.dayCount; i++){
  159. days[i] = dt.add(Date.DAY, i);
  160. }
  161. times = [];
  162. dt = new Date().clearTime();
  163. for(i=0; i<24; i++){
  164. times.push(dt.format('ga'));
  165. dt = dt.add(Date.HOUR, 1);
  166. }
  167. return Ext.calendar.DayBodyTemplate.superclass.applyTemplate.call(this, {
  168. days: days,
  169. dayCount: days.length,
  170. times: times
  171. });
  172. }
  173. });
  174. Ext.calendar.DayBodyTemplate.prototype.apply = Ext.calendar.DayBodyTemplate.prototype.applyTemplate;
  175. /**
  176. * @class Ext.calendar.DayViewTemplate
  177. * @extends Ext.XTemplate
  178. * <p>This is the template used to render the all-day event container used in {@link Ext.calendar.DayView DayView} and
  179. * {@link Ext.calendar.WeekView WeekView}. Internally this class simply defers to instances of {@link Ext.calerndar.DayHeaderTemplate}
  180. * and {@link Ext.calerndar.DayBodyTemplate} to perform the actual rendering logic, but it also provides the overall calendar view
  181. * container that contains them both. As such this is the template that should be used when rendering day or week views.</p>
  182. * <p>This template is automatically bound to the underlying event store by the
  183. * calendar components and expects records of type {@link Ext.calendar.EventRecord}.</p>
  184. * @constructor
  185. * @param {Object} config The config object
  186. */
  187. Ext.calendar.DayViewTemplate = function(config){
  188. Ext.apply(this, config);
  189. this.headerTpl = new Ext.calendar.DayHeaderTemplate(config);
  190. this.headerTpl.compile();
  191. this.bodyTpl = new Ext.calendar.DayBodyTemplate(config);
  192. this.bodyTpl.compile();
  193. Ext.calendar.DayViewTemplate.superclass.constructor.call(this,
  194. '<div class="ext-cal-inner-ct">',
  195. '{headerTpl}',
  196. '{bodyTpl}',
  197. '</div>'
  198. );
  199. };
  200. Ext.extend(Ext.calendar.DayViewTemplate, Ext.XTemplate, {
  201. // private
  202. applyTemplate : function(o){
  203. return Ext.calendar.DayViewTemplate.superclass.applyTemplate.call(this, {
  204. headerTpl: this.headerTpl.apply(o),
  205. bodyTpl: this.bodyTpl.apply(o)
  206. });
  207. }
  208. });
  209. Ext.calendar.DayViewTemplate.prototype.apply = Ext.calendar.DayViewTemplate.prototype.applyTemplate;
  210. /**
  211. * @class Ext.calendar.BoxLayoutTemplate
  212. * @extends Ext.XTemplate
  213. * <p>This is the template used to render calendar views based on small day boxes within a non-scrolling container (currently
  214. * the {@link Ext.calendar.MonthView MonthView} and the all-day headers for {@link Ext.calendar.DayView DayView} and
  215. * {@link Ext.calendar.WeekView WeekView}. This template is automatically bound to the underlying event store by the
  216. * calendar components and expects records of type {@link Ext.calendar.EventRecord}.</p>
  217. * @constructor
  218. * @param {Object} config The config object
  219. */
  220. Ext.calendar.BoxLayoutTemplate = function(config){
  221. Ext.apply(this, config);
  222. var weekLinkTpl = this.showWeekLinks ? '<div id="{weekLinkId}" class="ext-cal-week-link">{weekNum}</div>' : '';
  223. Ext.calendar.BoxLayoutTemplate.superclass.constructor.call(this,
  224. '<tpl for="weeks">',
  225. '<div id="{[this.id]}-wk-{[xindex-1]}" class="ext-cal-wk-ct" style="top:{[this.getRowTop(xindex, xcount)]}%; height:{[this.getRowHeight(xcount)]}%;">',
  226. weekLinkTpl,
  227. '<table class="ext-cal-bg-tbl" cellpadding="0" cellspacing="0">',
  228. '<tbody>',
  229. '<tr>',
  230. '<tpl for=".">',
  231. '<td id="{[this.id]}-day-{date:date("Ymd")}" class="{cellCls}">&nbsp;</td>',
  232. '</tpl>',
  233. '</tr>',
  234. '</tbody>',
  235. '</table>',
  236. '<table class="ext-cal-evt-tbl" cellpadding="0" cellspacing="0">',
  237. '<tbody>',
  238. '<tr>',
  239. '<tpl for=".">',
  240. '<td id="{[this.id]}-ev-day-{date:date("Ymd")}" class="{titleCls}"><div>{title}</div></td>',
  241. '</tpl>',
  242. '</tr>',
  243. '</tbody>',
  244. '</table>',
  245. '</div>',
  246. '</tpl>', {
  247. getRowTop: function(i, ln){
  248. return ((i-1)*(100/ln));
  249. },
  250. getRowHeight: function(ln){
  251. return 100/ln;
  252. }
  253. }
  254. );
  255. };
  256. Ext.extend(Ext.calendar.BoxLayoutTemplate, Ext.XTemplate, {
  257. // private
  258. applyTemplate : function(o){
  259. Ext.apply(this, o);
  260. var w = 0, title = '', first = true, isToday = false, showMonth = false, prevMonth = false, nextMonth = false,
  261. weeks = [[]],
  262. today = new Date().clearTime(),
  263. dt = this.viewStart.clone(),
  264. thisMonth = this.startDate.getMonth();
  265. for(; w < this.weekCount || this.weekCount == -1; w++){
  266. if(dt > this.viewEnd){
  267. break;
  268. }
  269. weeks[w] = [];
  270. for(var d = 0; d < this.dayCount; d++){
  271. isToday = dt.getTime() === today.getTime();
  272. showMonth = first || (dt.getDate() == 1);
  273. prevMonth = (dt.getMonth() < thisMonth) && this.weekCount == -1;
  274. nextMonth = (dt.getMonth() > thisMonth) && this.weekCount == -1;
  275. if(dt.getDay() == 1){
  276. // The ISO week format 'W' is relative to a Monday week start. If we
  277. // make this check on Sunday the week number will be off.
  278. weeks[w].weekNum = this.showWeekNumbers ? dt.format('W') : '&nbsp;';
  279. weeks[w].weekLinkId = 'ext-cal-week-'+dt.format('Ymd');
  280. }
  281. if(showMonth){
  282. if(isToday){
  283. title = this.getTodayText();
  284. }
  285. else{
  286. title = dt.format(this.dayCount == 1 ? 'l, F j, Y' : (first ? 'M j, Y' : 'M j'));
  287. }
  288. }
  289. else{
  290. var dayFmt = (w == 0 && this.showHeader !== true) ? 'D j' : 'j';
  291. title = isToday ? this.getTodayText() : dt.format(dayFmt);
  292. }
  293. weeks[w].push({
  294. title: title,
  295. date: dt.clone(),
  296. titleCls: 'ext-cal-dtitle ' + (isToday ? ' ext-cal-dtitle-today' : '') +
  297. (w==0 ? ' ext-cal-dtitle-first' : '') +
  298. (prevMonth ? ' ext-cal-dtitle-prev' : '') +
  299. (nextMonth ? ' ext-cal-dtitle-next' : ''),
  300. cellCls: 'ext-cal-day ' + (isToday ? ' ext-cal-day-today' : '') +
  301. (d==0 ? ' ext-cal-day-first' : '') +
  302. (prevMonth ? ' ext-cal-day-prev' : '') +
  303. (nextMonth ? ' ext-cal-day-next' : '')
  304. });
  305. dt = dt.add(Date.DAY, 1);
  306. first = false;
  307. }
  308. }
  309. return Ext.calendar.BoxLayoutTemplate.superclass.applyTemplate.call(this, {
  310. weeks: weeks
  311. });
  312. },
  313. // private
  314. getTodayText : function(){
  315. var dt = new Date().format('l, F j, Y'),
  316. todayText = this.showTodayText !== false ? this.todayText : '',
  317. timeText = this.showTime !== false ? ' <span id="'+this.id+'-clock" class="ext-cal-dtitle-time">' +
  318. new Date().format('g:i a') + '</span>' : '',
  319. separator = todayText.length > 0 || timeText.length > 0 ? ' &mdash; ' : '';
  320. if(this.dayCount == 1){
  321. return dt + separator + todayText + timeText;
  322. }
  323. fmt = this.weekCount == 1 ? 'D j' : 'j';
  324. return todayText.length > 0 ? todayText + timeText : new Date().format(fmt) + timeText;
  325. }
  326. });
  327. Ext.calendar.BoxLayoutTemplate.prototype.apply = Ext.calendar.BoxLayoutTemplate.prototype.applyTemplate;
  328. /**
  329. * @class Ext.calendar.MonthViewTemplate
  330. * @extends Ext.XTemplate
  331. * <p>This is the template used to render the {@link Ext.calendar.MonthView MonthView}. Internally this class defers to an
  332. * instance of {@link Ext.calerndar.BoxLayoutTemplate} to handle the inner layout rendering and adds containing elements around
  333. * that to form the month view.</p>
  334. * <p>This template is automatically bound to the underlying event store by the
  335. * calendar components and expects records of type {@link Ext.calendar.EventRecord}.</p>
  336. * @constructor
  337. * @param {Object} config The config object
  338. */
  339. Ext.calendar.MonthViewTemplate = function(config){
  340. Ext.apply(this, config);
  341. this.weekTpl = new Ext.calendar.BoxLayoutTemplate(config);
  342. this.weekTpl.compile();
  343. var weekLinkTpl = this.showWeekLinks ? '<div class="ext-cal-week-link-hd">&nbsp;</div>' : '';
  344. Ext.calendar.MonthViewTemplate.superclass.constructor.call(this,
  345. '<div class="ext-cal-inner-ct {extraClasses}">',
  346. '<div class="ext-cal-hd-ct ext-cal-month-hd">',
  347. weekLinkTpl,
  348. '<table class="ext-cal-hd-days-tbl" cellpadding="0" cellspacing="0">',
  349. '<tbody>',
  350. '<tr>',
  351. '<tpl for="days">',
  352. '<th class="ext-cal-hd-day{[xindex==1 ? " ext-cal-day-first" : ""]}" title="{.:date("l, F j, Y")}">{.:date("D")}</th>',
  353. '</tpl>',
  354. '</tr>',
  355. '</tbody>',
  356. '</table>',
  357. '</div>',
  358. '<div class="ext-cal-body-ct">{weeks}</div>',
  359. '</div>'
  360. );
  361. };
  362. Ext.extend(Ext.calendar.MonthViewTemplate, Ext.XTemplate, {
  363. // private
  364. applyTemplate : function(o){
  365. var days = [],
  366. weeks = this.weekTpl.apply(o),
  367. dt = o.viewStart;
  368. for(var i = 0; i < 7; i++){
  369. days.push(dt.add(Date.DAY, i));
  370. }
  371. var extraClasses = this.showHeader === true ? '' : 'ext-cal-noheader';
  372. if(this.showWeekLinks){
  373. extraClasses += ' ext-cal-week-links';
  374. }
  375. return Ext.calendar.MonthViewTemplate.superclass.applyTemplate.call(this, {
  376. days: days,
  377. weeks: weeks,
  378. extraClasses: extraClasses
  379. });
  380. }
  381. });
  382. Ext.calendar.MonthViewTemplate.prototype.apply = Ext.calendar.MonthViewTemplate.prototype.applyTemplate;
  383. /**
  384. * @class Ext.dd.ScrollManager
  385. * <p>Provides automatic scrolling of overflow regions in the page during drag operations.</p>
  386. * <p>The ScrollManager configs will be used as the defaults for any scroll container registered with it,
  387. * but you can also override most of the configs per scroll container by adding a
  388. * <tt>ddScrollConfig</tt> object to the target element that contains these properties: {@link #hthresh},
  389. * {@link #vthresh}, {@link #increment} and {@link #frequency}. Example usage:
  390. * <pre><code>
  391. var el = Ext.get('scroll-ct');
  392. el.ddScrollConfig = {
  393. vthresh: 50,
  394. hthresh: -1,
  395. frequency: 100,
  396. increment: 200
  397. };
  398. Ext.dd.ScrollManager.register(el);
  399. </code></pre>
  400. * <b>Note: This class uses "Point Mode" and is untested in "Intersect Mode".</b>
  401. * @singleton
  402. */
  403. Ext.dd.ScrollManager = function() {
  404. var ddm = Ext.dd.DragDropMgr,
  405. els = {},
  406. dragEl = null,
  407. proc = {},
  408. onStop = function(e) {
  409. dragEl = null;
  410. clearProc();
  411. },
  412. triggerRefresh = function() {
  413. if (ddm.dragCurrent) {
  414. ddm.refreshCache(ddm.dragCurrent.groups);
  415. }
  416. },
  417. doScroll = function() {
  418. if (ddm.dragCurrent) {
  419. var dds = Ext.dd.ScrollManager,
  420. inc = proc.el.ddScrollConfig ? proc.el.ddScrollConfig.increment: dds.increment;
  421. if (!dds.animate) {
  422. if (proc.el.scroll(proc.dir, inc)) {
  423. triggerRefresh();
  424. }
  425. } else {
  426. proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
  427. }
  428. }
  429. },
  430. clearProc = function() {
  431. if (proc.id) {
  432. clearInterval(proc.id);
  433. }
  434. proc.id = 0;
  435. proc.el = null;
  436. proc.dir = "";
  437. },
  438. startProc = function(el, dir) {
  439. clearProc();
  440. proc.el = el;
  441. proc.dir = dir;
  442. var freq = (el.ddScrollConfig && el.ddScrollConfig.frequency) ?
  443. el.ddScrollConfig.frequency: Ext.dd.ScrollManager.frequency,
  444. group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup: undefined;
  445. if (group === undefined || ddm.dragCurrent.ddGroup == group) {
  446. proc.id = setInterval(doScroll, freq);
  447. }
  448. },
  449. onFire = function(e, isDrop) {
  450. if (isDrop || !ddm.dragCurrent) {
  451. return;
  452. }
  453. var dds = Ext.dd.ScrollManager;
  454. if (!dragEl || dragEl != ddm.dragCurrent) {
  455. dragEl = ddm.dragCurrent;
  456. // refresh regions on drag start
  457. dds.refreshCache();
  458. }
  459. var xy = Ext.lib.Event.getXY(e),
  460. pt = new Ext.lib.Point(xy[0], xy[1]),
  461. id,
  462. el,
  463. r,
  464. c;
  465. for (id in els) {
  466. if (els.hasOwnProperty(id)) {
  467. el = els[id];
  468. r = el._region;
  469. c = el.ddScrollConfig ? el.ddScrollConfig: dds;
  470. if (r && r.contains(pt) && el.isScrollable()) {
  471. if (r.bottom - pt.y <= c.vthresh) {
  472. if (proc.el != el) {
  473. startProc(el, "down");
  474. }
  475. return;
  476. } else if (r.right - pt.x <= c.hthresh) {
  477. if (proc.el != el) {
  478. startProc(el, "left");
  479. }
  480. return;
  481. } else if (pt.y - r.top <= c.vthresh) {
  482. if (proc.el != el) {
  483. startProc(el, "up");
  484. }
  485. return;
  486. } else if (pt.x - r.left <= c.hthresh) {
  487. if (proc.el != el) {
  488. startProc(el, "right");
  489. }
  490. return;
  491. }
  492. }
  493. }
  494. }
  495. clearProc();
  496. };
  497. ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
  498. ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
  499. return {
  500. /**
  501. * Registers new overflow element(s) to auto scroll
  502. * @param {Mixed/Array} el The id of or the element to be scrolled or an array of either
  503. */
  504. register: function(el) {
  505. if (Ext.isArray(el)) {
  506. var i = 0,
  507. len = el.length;
  508. for (; i < len; i++) {
  509. this.register(el[i]);
  510. }
  511. } else {
  512. el = Ext.get(el);
  513. els[el.id] = el;
  514. }
  515. },
  516. /**
  517. * Unregisters overflow element(s) so they are no longer scrolled
  518. * @param {Mixed/Array} el The id of or the element to be removed or an array of either
  519. */
  520. unregister: function(el) {
  521. if (Ext.isArray(el)) {
  522. var i = 0,
  523. len = el.length;
  524. for (; i < len; i++) {
  525. this.unregister(el[i]);
  526. }
  527. } else {
  528. el = Ext.get(el);
  529. delete els[el.id];
  530. }
  531. },
  532. /**
  533. * The number of pixels from the top or bottom edge of a container the pointer needs to be to
  534. * trigger scrolling (defaults to 25)
  535. * @type Number
  536. */
  537. vthresh: 25,
  538. /**
  539. * The number of pixels from the right or left edge of a container the pointer needs to be to
  540. * trigger scrolling (defaults to 25)
  541. * @type Number
  542. */
  543. hthresh: 25,
  544. /**
  545. * The number of pixels to scroll in each scroll increment (defaults to 50)
  546. * @type Number
  547. */
  548. increment: 100,
  549. /**
  550. * The frequency of scrolls in milliseconds (defaults to 500)
  551. * @type Number
  552. */
  553. frequency: 500,
  554. /**
  555. * True to animate the scroll (defaults to true)
  556. * @type Boolean
  557. */
  558. animate: true,
  559. /**
  560. * The animation duration in seconds -
  561. * MUST BE less than Ext.dd.ScrollManager.frequency! (defaults to .4)
  562. * @type Number
  563. */
  564. animDuration: 0.4,
  565. /**
  566. * Manually trigger a cache refresh.
  567. */
  568. refreshCache: function() {
  569. var id;
  570. for (id in els) {
  571. if (els.hasOwnProperty(id)) {
  572. if (typeof els[id] == 'object') {
  573. // for people extending the object prototype
  574. els[id]._region = els[id].getRegion();
  575. }
  576. }
  577. }
  578. }
  579. };
  580. }();/*
  581. * @class Ext.calendar.StatusProxy
  582. * A specialized drag proxy that supports a drop status icon, {@link Ext.Layer} styles and auto-repair. It also
  583. * contains a calendar-specific drag status message containing details about the dragged event's target drop date range.
  584. * This is the default drag proxy used by all calendar views.
  585. * @constructor
  586. * @param {Object} config
  587. */
  588. Ext.calendar.StatusProxy = function(config) {
  589. Ext.apply(this, config);
  590. this.id = this.id || Ext.id();
  591. this.el = new Ext.Layer({
  592. dh: {
  593. id: this.id,
  594. cls: 'ext-dd-drag-proxy x-dd-drag-proxy ' + this.dropNotAllowed,
  595. cn: [
  596. {
  597. cls: 'x-dd-drop-icon'
  598. },
  599. {
  600. cls: 'ext-dd-ghost-ct',
  601. cn: [
  602. {
  603. cls: 'x-dd-drag-ghost'
  604. },
  605. {
  606. cls: 'ext-dd-msg'
  607. }
  608. ]
  609. }
  610. ]
  611. },
  612. shadow: !config || config.shadow !== false
  613. });
  614. this.ghost = Ext.get(this.el.dom.childNodes[1].childNodes[0]);
  615. this.message = Ext.get(this.el.dom.childNodes[1].childNodes[1]);
  616. this.dropStatus = this.dropNotAllowed;
  617. };
  618. Ext.extend(Ext.calendar.StatusProxy, Ext.dd.StatusProxy, {
  619. /**
  620. * @cfg {String} moveEventCls
  621. * The CSS class to apply to the status element when an event is being dragged (defaults to 'ext-cal-dd-move').
  622. */
  623. moveEventCls: 'ext-cal-dd-move',
  624. /**
  625. * @cfg {String} addEventCls
  626. * The CSS class to apply to the status element when drop is not allowed (defaults to 'ext-cal-dd-add').
  627. */
  628. addEventCls: 'ext-cal-dd-add',
  629. // inherit docs
  630. update: function(html) {
  631. if (typeof html == 'string') {
  632. this.ghost.update(html);
  633. } else {
  634. this.ghost.update('');
  635. html.style.margin = '0';
  636. this.ghost.dom.appendChild(html);
  637. }
  638. var el = this.ghost.dom.firstChild;
  639. if (el) {
  640. Ext.fly(el).setStyle('float', 'none').setHeight('auto');
  641. Ext.getDom(el).id += '-ddproxy';
  642. }
  643. },
  644. /**
  645. * Update the calendar-specific drag status message without altering the ghost element.
  646. * @param {String} msg The new status message
  647. */
  648. updateMsg: function(msg) {
  649. this.message.update(msg);
  650. }
  651. });/*
  652. * Internal drag zone implementation for the calendar components. This provides base functionality
  653. * and is primarily for the month view -- DayViewDD adds day/week view-specific functionality.
  654. */
  655. Ext.calendar.DragZone = Ext.extend(Ext.dd.DragZone, {
  656. ddGroup: 'CalendarDD',
  657. eventSelector: '.ext-cal-evt',
  658. constructor: function(el, config) {
  659. if (!Ext.calendar._statusProxyInstance) {
  660. Ext.calendar._statusProxyInstance = new Ext.calendar.StatusProxy();
  661. }
  662. this.proxy = Ext.calendar._statusProxyInstance;
  663. Ext.calendar.DragZone.superclass.constructor.call(this, el, config);
  664. },
  665. getDragData: function(e) {
  666. // Check whether we are dragging on an event first
  667. var t = e.getTarget(this.eventSelector, 3);
  668. if (t) {
  669. var rec = this.view.getEventRecordFromEl(t);
  670. return {
  671. type: 'eventdrag',
  672. ddel: t,
  673. eventStart: rec.data[Ext.calendar.EventMappings.StartDate.name],
  674. eventEnd: rec.data[Ext.calendar.EventMappings.EndDate.name],
  675. proxy: this.proxy
  676. };
  677. }
  678. // If not dragging an event then we are dragging on
  679. // the calendar to add a new event
  680. t = this.view.getDayAt(e.getPageX(), e.getPageY());
  681. if (t.el) {
  682. return {
  683. type: 'caldrag',
  684. start: t.date,
  685. proxy: this.proxy
  686. };
  687. }
  688. return null;
  689. },
  690. onInitDrag: function(x, y) {
  691. if (this.dragData.ddel) {
  692. var ghost = this.dragData.ddel.cloneNode(true),
  693. child = Ext.fly(ghost).child('dl');
  694. Ext.fly(ghost).setWidth('auto');
  695. if (child) {
  696. // for IE/Opera
  697. child.setHeight('auto');
  698. }
  699. this.proxy.update(ghost);
  700. this.onStartDrag(x, y);
  701. }
  702. else if (this.dragData.start) {
  703. this.onStartDrag(x, y);
  704. }
  705. this.view.onInitDrag();
  706. return true;
  707. },
  708. afterRepair: function() {
  709. if (Ext.enableFx && this.dragData.ddel) {
  710. Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || 'c3daf9');
  711. }
  712. this.dragging = false;
  713. },
  714. getRepairXY: function(e) {
  715. if (this.dragData.ddel) {
  716. return Ext.Element.fly(this.dragData.ddel).getXY();
  717. }
  718. },
  719. afterInvalidDrop: function(e, id) {
  720. Ext.select('.ext-dd-shim').hide();
  721. },
  722. destroy: function() {
  723. // The point of this override is to preserve the singleton proxy object across
  724. // instances of CalendarDD. It must not be destroyed by the superclass code.
  725. this.proxy = {};
  726. Ext.calendar.DragZone.superclass.destroy.call(this);
  727. this.proxy = Ext.calendar._statusProxyInstance;
  728. }
  729. });
  730. /*
  731. * Internal drop zone implementation for the calendar components. This provides base functionality
  732. * and is primarily for the month view -- DayViewDD adds day/week view-specific functionality.
  733. */
  734. Ext.calendar.DropZone = Ext.extend(Ext.dd.DropZone, {
  735. ddGroup: 'CalendarDD',
  736. eventSelector: '.ext-cal-evt',
  737. // private
  738. shims: [],
  739. getTargetFromEvent: function(e) {
  740. var dragOffset = this.dragOffset || 0,
  741. y = e.getPageY() - dragOffset,
  742. d = this.view.getDayAt(e.getPageX(), y);
  743. return d.el ? d: null;
  744. },
  745. onNodeOver: function(n, dd, e, data) {
  746. var D = Ext.calendar.Date,
  747. start = data.type == 'eventdrag' ? n.date: D.min(data.start, n.date),
  748. end = data.type == 'eventdrag' ? n.date.add(Date.DAY, D.diffDays(data.eventStart, data.eventEnd)) :
  749. D.max(data.start, n.date);
  750. if (!this.dragStartDate || !this.dragEndDate || (D.diffDays(start, this.dragStartDate) != 0) || (D.diffDays(end, this.dragEndDate) != 0)) {
  751. this.dragStartDate = start;
  752. this.dragEndDate = end.clearTime().add(Date.DAY, 1).add(Date.MILLI, -1);
  753. this.shim(start, end);
  754. var range = start.format('n/j');
  755. if (D.diffDays(start, end) > 0) {
  756. range += '-' + end.format('n/j');
  757. }
  758. var msg = String.format(data.type == 'eventdrag' ? this.moveText: this.createText, range);
  759. data.proxy.updateMsg(msg);
  760. }
  761. return this.dropAllowed;
  762. },
  763. shim: function(start, end) {
  764. this.currWeek = -1;
  765. var dt = start.clone(),
  766. i = 0,
  767. shim,
  768. box,
  769. cnt = Ext.calendar.Date.diffDays(dt, end) + 1;
  770. Ext.each(this.shims,
  771. function(shim) {
  772. if (shim) {
  773. shim.isActive = false;
  774. }
  775. }
  776. );
  777. while (i++<cnt) {
  778. var dayEl = this.view.getDayEl(dt);
  779. // if the date is not in the current view ignore it (this
  780. // can happen when an event is dragged to the end of the
  781. // month so that it ends outside the view)
  782. if (dayEl) {
  783. var wk = this.view.getWeekIndex(dt);
  784. shim = this.shims[wk];
  785. if (!shim) {
  786. shim = this.createShim();
  787. this.shims[wk] = shim;
  788. }
  789. if (wk != this.currWeek) {
  790. shim.boxInfo = dayEl.getBox();
  791. this.currWeek = wk;
  792. }
  793. else {
  794. box = dayEl.getBox();
  795. shim.boxInfo.right = box.right;
  796. shim.boxInfo.width = box.right - shim.boxInfo.x;
  797. }
  798. shim.isActive = true;
  799. }
  800. dt = dt.add(Date.DAY, 1);
  801. }
  802. Ext.each(this.shims,
  803. function(shim) {
  804. if (shim) {
  805. if (shim.isActive) {
  806. shim.show();
  807. shim.setBox(shim.boxInfo);
  808. }
  809. else if (shim.isVisible()) {
  810. shim.hide();
  811. }
  812. }
  813. });
  814. },
  815. createShim: function() {
  816. if (!this.shimCt) {
  817. this.shimCt = Ext.get('ext-dd-shim-ct');
  818. if (!this.shimCt) {
  819. this.shimCt = document.createElement('div');
  820. this.shimCt.id = 'ext-dd-shim-ct';
  821. Ext.getBody().appendChild(this.shimCt);
  822. }
  823. }
  824. var el = document.createElement('div');
  825. el.className = 'ext-dd-shim';
  826. this.shimCt.appendChild(el);
  827. return new Ext.Layer({
  828. shadow: false,
  829. useDisplay: true,
  830. constrain: false
  831. },
  832. el);
  833. },
  834. clearShims: function() {
  835. Ext.each(this.shims,
  836. function(shim) {
  837. if (shim) {
  838. shim.hide();
  839. }
  840. });
  841. },
  842. onContainerOver: function(dd, e, data) {
  843. return this.dropAllowed;
  844. },
  845. onCalendarDragComplete: function() {
  846. delete this.dragStartDate;
  847. delete this.dragEndDate;
  848. this.clearShims();
  849. },
  850. onNodeDrop: function(n, dd, e, data) {
  851. if (n && data) {
  852. if (data.type == 'eventdrag') {
  853. var rec = this.view.getEventRecordFromEl(data.ddel),
  854. dt = Ext.calendar.Date.copyTime(rec.data[Ext.calendar.EventMappings.StartDate.name], n.date);
  855. this.view.onEventDrop(rec, dt);
  856. this.onCalendarDragComplete();
  857. return true;
  858. }
  859. if (data.type == 'caldrag') {
  860. this.view.onCalendarEndDrag(this.dragStartDate, this.dragEndDate,
  861. this.onCalendarDragComplete.createDelegate(this));
  862. //shims are NOT cleared here -- they stay visible until the handling
  863. //code calls the onCalendarDragComplete callback which hides them.
  864. return true;
  865. }
  866. }
  867. this.onCalendarDragComplete();
  868. return false;
  869. },
  870. onContainerDrop: function(dd, e, data) {
  871. this.onCalendarDragComplete();
  872. return false;
  873. },
  874. destroy: function() {
  875. Ext.calendar.DropZone.superclass.destroy.call(this);
  876. Ext.destroy(this.shimCt);
  877. }
  878. });
  879. /*
  880. * Internal drag zone implementation for the calendar day and week views.
  881. */
  882. Ext.calendar.DayViewDragZone = Ext.extend(Ext.calendar.DragZone, {
  883. ddGroup: 'DayViewDD',
  884. resizeSelector: '.ext-evt-rsz',
  885. getDragData: function(e) {
  886. var t = e.getTarget(this.resizeSelector, 2, true),
  887. p,
  888. rec;
  889. if (t) {
  890. p = t.parent(this.eventSelector);
  891. rec = this.view.getEventRecordFromEl(p);
  892. return {
  893. type: 'eventresize',
  894. ddel: p.dom,
  895. eventStart: rec.data[Ext.calendar.EventMappings.StartDate.name],
  896. eventEnd: rec.data[Ext.calendar.EventMappings.EndDate.name],
  897. proxy: this.proxy
  898. };
  899. }
  900. t = e.getTarget(this.eventSelector, 3);
  901. if (t) {
  902. rec = this.view.getEventRecordFromEl(t);
  903. return {
  904. type: 'eventdrag',
  905. ddel: t,
  906. eventStart: rec.data[Ext.calendar.EventMappings.StartDate.name],
  907. eventEnd: rec.data[Ext.calendar.EventMappings.EndDate.name],
  908. proxy: this.proxy
  909. };
  910. }
  911. // If not dragging/resizing an event then we are dragging on
  912. // the calendar to add a new event
  913. t = this.view.getDayAt(e.getPageX(), e.getPageY());
  914. if (t.el) {
  915. return {
  916. type: 'caldrag',
  917. dayInfo: t,
  918. proxy: this.proxy
  919. };
  920. }
  921. return null;
  922. }
  923. });
  924. /*
  925. * Internal drop zone implementation for the calendar day and week views.
  926. */
  927. Ext.calendar.DayViewDropZone = Ext.extend(Ext.calendar.DropZone, {
  928. ddGroup: 'DayViewDD',
  929. onNodeOver: function(n, dd, e, data) {
  930. var dt,
  931. box,
  932. endDt,
  933. text = this.createText,
  934. curr,
  935. start,
  936. end,
  937. evtEl,
  938. dayCol;
  939. if (data.type == 'caldrag') {
  940. if (!this.dragStartMarker) {
  941. // Since the container can scroll, this gets a little tricky.
  942. // There is no el in the DOM that we can measure by default since
  943. // the box is simply calculated from the original drag start (as opposed
  944. // to dragging or resizing the event where the orig event box is present).
  945. // To work around this we add a placeholder el into the DOM and give it
  946. // the original starting time's box so that we can grab its updated
  947. // box measurements as the underlying container scrolls up or down.
  948. // This placeholder is removed in onNodeDrop.
  949. this.dragStartMarker = n.el.parent().createChild({
  950. style: 'position:absolute;'
  951. });
  952. this.dragStartMarker.setBox(n.timeBox);
  953. this.dragCreateDt = n.date;
  954. }
  955. box = this.dragStartMarker.getBox();
  956. box.height = Math.ceil(Math.abs(e.xy[1] - box.y) / n.timeBox.height) * n.timeBox.height;
  957. if (e.xy[1] < box.y) {
  958. box.height += n.timeBox.height;
  959. box.y = box.y - box.height + n.timeBox.height;
  960. endDt = this.dragCreateDt.add(Date.MINUTE, 30);
  961. }
  962. else {
  963. n.date = n.date.add(Date.MINUTE, 30);
  964. }
  965. this.shim(this.dragCreateDt, box);
  966. curr = Ext.calendar.Date.copyTime(n.date, this.dragCreateDt);
  967. this.dragStartDate = Ext.calendar.Date.min(this.dragCreateDt, curr);
  968. this.dragEndDate = endDt || Ext.calendar.Date.max(this.dragCreateDt, curr);
  969. dt = this.dragStartDate.format('g:ia-') + this.dragEndDate.format('g:ia');
  970. }
  971. else {
  972. evtEl = Ext.get(data.ddel);
  973. dayCol = evtEl.parent().parent();
  974. box = evtEl.getBox();
  975. box.width = dayCol.getWidth();
  976. if (data.type == 'eventdrag') {
  977. if (this.dragOffset === undefined) {
  978. this.dragOffset = n.timeBox.y - box.y;
  979. box.y = n.timeBox.y - this.dragOffset;
  980. }
  981. else {
  982. box.y = n.timeBox.y;
  983. }
  984. dt = n.date.format('n/j g:ia');
  985. box.x = n.el.getLeft();
  986. this.shim(n.date, box);
  987. text = this.moveText;
  988. }
  989. if (data.type == 'eventresize') {
  990. if (!this.resizeDt) {
  991. this.resizeDt = n.date;
  992. }
  993. box.x = dayCol.getLeft();
  994. box.height = Math.ceil(Math.abs(e.xy[1] - box.y) / n.timeBox.height) * n.timeBox.height;
  995. if (e.xy[1] < box.y) {
  996. box.y -= box.height;
  997. }
  998. else {
  999. n.date = n.date.add(Date.MINUTE, 30);
  1000. }
  1001. this.shim(this.resizeDt, box);
  1002. curr = Ext.calendar.Date.copyTime(n.date, this.resizeDt);
  1003. start = Ext.calendar.Date.min(data.eventStart, curr);
  1004. end = Ext.calendar.Date.max(data.eventStart, curr);
  1005. data.resizeDates = {
  1006. StartDate: start,
  1007. EndDate: end
  1008. };
  1009. dt = start.format('g:ia-') + end.format('g:ia');
  1010. text = this.resizeText;
  1011. }
  1012. }
  1013. data.proxy.updateMsg(String.format(text, dt));
  1014. return this.dropAllowed;
  1015. },
  1016. shim: function(dt, box) {
  1017. Ext.each(this.shims,
  1018. function(shim) {
  1019. if (shim) {
  1020. shim.isActive = false;
  1021. shim.hide();
  1022. }
  1023. });
  1024. var shim = this.shims[0];
  1025. if (!shim) {
  1026. shim = this.createShim();
  1027. this.shims[0] = shim;
  1028. }
  1029. shim.isActive = true;
  1030. shim.show();
  1031. shim.setBox(box);
  1032. },
  1033. onNodeDrop: function(n, dd, e, data) {
  1034. var rec;
  1035. if (n && data) {
  1036. if (data.type == 'eventdrag') {
  1037. rec = this.view.getEventRecordFromEl(data.ddel);
  1038. this.view.onEventDrop(rec, n.date);
  1039. this.onCalendarDragComplete();
  1040. delete this.dragOffset;
  1041. return true;
  1042. }
  1043. if (data.type == 'eventresize') {
  1044. rec = this.view.getEventRecordFromEl(data.ddel);
  1045. this.view.onEventResize(rec, data.resizeDates);
  1046. this.onCalendarDragComplete();
  1047. delete this.resizeDt;
  1048. return true;
  1049. }
  1050. if (data.type == 'caldrag') {
  1051. Ext.destroy(this.dragStartMarker);
  1052. delete this.dragStartMarker;
  1053. delete this.dragCreateDt;
  1054. this.view.onCalendarEndDrag(this.dragStartDate, this.dragEndDate,
  1055. this.onCalendarDragComplete.createDelegate(this));
  1056. //shims are NOT cleared here -- they stay visible until the handling
  1057. //code calls the onCalendarDragComplete callback which hides them.
  1058. return true;
  1059. }
  1060. }
  1061. this.onCalendarDragComplete();
  1062. return false;
  1063. }
  1064. });
  1065. /**
  1066. * @class Ext.calendar.EventMappings
  1067. * @extends Object
  1068. * A simple object that provides the field definitions for EventRecords so that they can be easily overridden.
  1069. */
  1070. Ext.calendar.EventMappings = {
  1071. EventId: {
  1072. name: 'EventId',
  1073. mapping: 'id',
  1074. type: 'int'
  1075. },
  1076. CalendarId: {
  1077. name: 'CalendarId',
  1078. mapping: 'cid',
  1079. type: 'int'
  1080. },
  1081. Title: {
  1082. name: 'Title',
  1083. mapping: 'title',
  1084. type: 'string'
  1085. },
  1086. StartDate: {
  1087. name: 'StartDate',
  1088. mapping: 'start',
  1089. type: 'date',
  1090. dateFormat: 'c'
  1091. },
  1092. EndDate: {
  1093. name: 'EndDate',
  1094. mapping: 'end',
  1095. type: 'date',
  1096. dateFormat: 'c'
  1097. },
  1098. Location: {
  1099. name: 'Location',
  1100. mapping: 'loc',
  1101. type: 'string'
  1102. },
  1103. Notes: {
  1104. name: 'Notes',
  1105. mapping: 'notes',
  1106. type: 'string'
  1107. },
  1108. Url: {
  1109. name: 'Url',
  1110. mapping: 'url',
  1111. type: 'string'
  1112. },
  1113. IsAllDay: {
  1114. name: 'IsAllDay',
  1115. mapping: 'ad',
  1116. type: 'boolean'
  1117. },
  1118. Reminder: {
  1119. name: 'Reminder',
  1120. mapping: 'rem',
  1121. type: 'string'
  1122. },
  1123. IsNew: {
  1124. name: 'IsNew',
  1125. mapping: 'n',
  1126. type: 'boolean'
  1127. }
  1128. };
  1129. /**
  1130. * @class Ext.calendar.EventRecord
  1131. * @extends Ext.data.Record
  1132. * <p>This is the {@link Ext.data.Record Record} specification for calendar event data used by the
  1133. * {@link Ext.calendar.CalendarPanel CalendarPanel}'s underlying store. It can be overridden as
  1134. * necessary to customize the fields supported by events, although the existing column names should
  1135. * not be altered. If your model fields are named differently you should update the <b>mapping</b>
  1136. * configs accordingly.</p>
  1137. * <p>The only required fields when creating a new event record instance are StartDate and
  1138. * EndDate. All other fields are either optional are will be defaulted if blank.</p>
  1139. * <p>Here is a basic example for how to create a new record of this type:<pre><code>
  1140. rec = new Ext.calendar.EventRecord({
  1141. StartDate: '2101-01-12 12:00:00',
  1142. EndDate: '2101-01-12 13:30:00',
  1143. Title: 'My cool event',
  1144. Notes: 'Some notes'
  1145. });
  1146. </code></pre>
  1147. * If you have overridden any of the record's data mappings via the Ext.calendar.EventMappings object
  1148. * you may need to set the values using this alternate syntax to ensure that the fields match up correctly:<pre><code>
  1149. var M = Ext.calendar.EventMappings;
  1150. rec = new Ext.calendar.EventRecord();
  1151. rec.data[M.StartDate.name] = '2101-01-12 12:00:00';
  1152. rec.data[M.EndDate.name] = '2101-01-12 13:30:00';
  1153. rec.data[M.Title.name] = 'My cool event';
  1154. rec.data[M.Notes.name] = 'Some notes';
  1155. </code></pre>
  1156. * @constructor
  1157. * @param {Object} data (Optional) An object, the properties of which provide values for the new Record's
  1158. * fields. If not specified the {@link Ext.data.Field#defaultValue defaultValue}
  1159. * for each field will be assigned.
  1160. * @param {Object} id (Optional) The id of the Record. The id is used by the
  1161. * {@link Ext.data.Store} object which owns the Record to index its collection
  1162. * of Records (therefore this id should be unique within each store). If an
  1163. * id is not specified a {@link #phantom}
  1164. * Record will be created with an {@link #Record.id automatically generated id}.
  1165. */
  1166. (function() {
  1167. var M = Ext.calendar.EventMappings;
  1168. Ext.calendar.EventRecord = Ext.data.Record.create([
  1169. M.EventId,
  1170. M.CalendarId,
  1171. M.Title,
  1172. M.StartDate,
  1173. M.EndDate,
  1174. M.Location,
  1175. M.Notes,
  1176. M.Url,
  1177. M.IsAllDay,
  1178. M.Reminder,
  1179. M.IsNew
  1180. ]);
  1181. /**
  1182. * Reconfigures the default record definition based on the current Ext.calendar.EventMappings object
  1183. */
  1184. Ext.calendar.EventRecord.reconfigure = function() {
  1185. Ext.calendar.EventRecord = Ext.data.Record.create([
  1186. M.EventId,
  1187. M.CalendarId,
  1188. M.Title,
  1189. M.StartDate,
  1190. M.EndDate,
  1191. M.Location,
  1192. M.Notes,
  1193. M.Url,
  1194. M.IsAllDay,
  1195. M.Reminder,
  1196. M.IsNew
  1197. ]);
  1198. };
  1199. })();
  1200. /*
  1201. * This is the view used internally by the panel that displays overflow events in the
  1202. * month view. Anytime a day cell cannot display all of its events, it automatically displays
  1203. * a link at the bottom to view all events for that day. When clicked, a panel pops up that
  1204. * uses this view to display the events for that day.
  1205. */
  1206. Ext.calendar.MonthDayDetailView = Ext.extend(Ext.BoxComponent, {
  1207. initComponent: function() {
  1208. Ext.calendar.CalendarView.superclass.initComponent.call(this);
  1209. this.addEvents({
  1210. eventsrendered: true
  1211. });
  1212. if (!this.el) {
  1213. this.el = document.createElement('div');
  1214. }
  1215. },
  1216. afterRender: function() {
  1217. this.tpl = this.getTemplate();
  1218. Ext.calendar.MonthDayDetailView.superclass.afterRender.call(this);
  1219. this.el.on({
  1220. 'click': this.view.onClick,
  1221. 'mouseover': this.view.onMouseOver,
  1222. 'mouseout': this.view.onMouseOut,
  1223. scope: this.view
  1224. });
  1225. },
  1226. getTemplate: function() {
  1227. if (!this.tpl) {
  1228. this.tpl = new Ext.XTemplate(
  1229. '<div class="ext-cal-mdv x-unselectable">',
  1230. '<table class="ext-cal-mvd-tbl" cellpadding="0" cellspacing="0">',
  1231. '<tbody>',
  1232. '<tpl for=".">',
  1233. '<tr><td class="ext-cal-ev">{markup}</td></tr>',
  1234. '</tpl>',
  1235. '</tbody>',
  1236. '</table>',
  1237. '</div>'
  1238. );
  1239. }
  1240. this.tpl.compile();
  1241. return this.tpl;
  1242. },
  1243. update: function(dt) {
  1244. this.date = dt;
  1245. this.refresh();
  1246. },
  1247. refresh: function() {
  1248. if (!this.rendered) {
  1249. return;
  1250. }
  1251. var eventTpl = this.view.getEventTemplate(),
  1252. templateData = [];
  1253. evts = this.store.queryBy(function(rec) {
  1254. var thisDt = this.date.clearTime(true).getTime(),
  1255. recStart = rec.data[Ext.calendar.EventMappings.StartDate.name].clearTime(true).getTime(),
  1256. startsOnDate = (thisDt == recStart),
  1257. spansDate = false;
  1258. if (!startsOnDate) {
  1259. var recEnd = rec.data[Ext.calendar.EventMappings.EndDate.name].clearTime(true).getTime();
  1260. spansDate = recStart < thisDt && recEnd >= thisDt;
  1261. }
  1262. return startsOnDate || spansDate;
  1263. },
  1264. this);
  1265. evts.each(function(evt) {
  1266. var item = evt.data,
  1267. M = Ext.calendar.EventMappings;
  1268. item._renderAsAllDay = item[M.IsAllDay.name] || Ext.calendar.Date.diffDays(item[M.StartDate.name], item[M.EndDate.name]) > 0;
  1269. item.spanLeft = Ext.calendar.Date.diffDays(item[M.StartDate.name], this.date) > 0;
  1270. item.spanRight = Ext.calendar.Date.diffDays(this.date, item[M.EndDate.name]) > 0;
  1271. item.spanCls = (item.spanLeft ? (item.spanRight ? 'ext-cal-ev-spanboth':
  1272. 'ext-cal-ev-spanleft') : (item.spanRight ? 'ext-cal-ev-spanright': ''));
  1273. templateData.push({
  1274. markup: eventTpl.apply(this.getTemplateEventData(item))
  1275. });
  1276. },
  1277. this);
  1278. this.tpl.overwrite(this.el, templateData);
  1279. this.fireEvent('eventsrendered', this, this.date, evts.getCount());
  1280. },
  1281. getTemplateEventData: function(evt) {
  1282. var data = this.view.getTemplateEventData(evt);
  1283. data._elId = 'dtl-' + data._elId;
  1284. return data;
  1285. }
  1286. });
  1287. Ext.reg('monthdaydetailview', Ext.calendar.MonthDayDetailView);
  1288. /**
  1289. * @class Ext.calendar.CalendarPicker
  1290. * @extends Ext.form.ComboBox
  1291. * <p>A custom combo used for choosing from the list of available calendars to assign an event to.</p>
  1292. * <p>This is pretty much a standard combo that is simply pre-configured for the options needed by the
  1293. * calendar components. The default configs are as follows:<pre><code>
  1294. fieldLabel: 'Calendar',
  1295. valueField: 'CalendarId',
  1296. displayField: 'Title',
  1297. triggerAction: 'all',
  1298. mode: 'local',
  1299. forceSelection: true,
  1300. width: 200
  1301. </code></pre>
  1302. * @constructor
  1303. * @param {Object} config The config object
  1304. */
  1305. Ext.calendar.CalendarPicker = Ext.extend(Ext.form.ComboBox, {
  1306. fieldLabel: 'Calendar',
  1307. valueField: 'CalendarId',
  1308. displayField: 'Title',
  1309. triggerAction: 'all',
  1310. mode: 'local',
  1311. forceSelection: true,
  1312. width: 200,
  1313. // private
  1314. initComponent: function() {
  1315. Ext.calendar.CalendarPicker.superclass.initComponent.call(this);
  1316. this.tpl = this.tpl ||
  1317. '<tpl for="."><div class="x-combo-list-item ext-color-{' + this.valueField +
  1318. '}"><div class="ext-cal-picker-icon">&nbsp;</div>{' + this.displayField + '}</div></tpl>';
  1319. },
  1320. // private
  1321. afterRender: function() {
  1322. Ext.calendar.CalendarPicker.superclass.afterRender.call(this);
  1323. this.wrap = this.el.up('.x-form-field-wrap');
  1324. this.wrap.addClass('ext-calendar-picker');
  1325. this.icon = Ext.DomHelper.append(this.wrap, {
  1326. tag: 'div',
  1327. cls: 'ext-cal-picker-icon ext-cal-picker-mainicon'
  1328. });
  1329. },
  1330. // inherited docs
  1331. setValue: function(value) {
  1332. this.wrap.removeClass('ext-color-' + this.getValue());
  1333. if (!value && this.store !== undefined) {
  1334. // always default to a valid calendar
  1335. value = this.store.getAt(0).data.CalendarId;
  1336. }
  1337. Ext.calendar.CalendarPicker.superclass.setValue.call(this, value);
  1338. this.wrap.addClass('ext-color-' + value);
  1339. }
  1340. });
  1341. Ext.reg('calendarpicker', Ext.calendar.CalendarPicker);
  1342. /*
  1343. * This is an internal helper class for the calendar views and should not be overridden.
  1344. * It is responsible for the base event rendering logic underlying all of the calendar views.
  1345. */
  1346. Ext.calendar.WeekEventRenderer = function() {
  1347. var getEventRow = function(id, week, index) {
  1348. var indexOffset = 1,
  1349. //skip row with date #'s
  1350. evtRow,
  1351. wkRow = Ext.get(id + '-wk-' + week);
  1352. if (wkRow) {
  1353. var table = wkRow.child('.ext-cal-evt-tbl', true);
  1354. evtRow = table.tBodies[0].childNodes[index + indexOffset];
  1355. if (!evtRow) {
  1356. evtRow = Ext.DomHelper.append(table.tBodies[0], '<tr></tr>');
  1357. }
  1358. }
  1359. return Ext.get(evtRow);
  1360. };
  1361. return {
  1362. render: function(o) {
  1363. var w = 0,
  1364. grid = o.eventGrid,
  1365. dt = o.viewStart.clone(),
  1366. eventTpl = o.tpl,
  1367. max = o.maxEventsPerDay != undefined ? o.maxEventsPerDay: 999,
  1368. weekCount = o.weekCount < 1 ? 6: o.weekCount,
  1369. dayCount = o.weekCount == 1 ? o.dayCount: 7,
  1370. cellCfg;
  1371. for (; w < weekCount; w++) {
  1372. if (!grid[w] || grid[w].length == 0) {
  1373. // no events or span cells for the entire week
  1374. if (weekCount == 1) {
  1375. row = getEventRow(o.id, w, 0);
  1376. cellCfg = {
  1377. tag: 'td',
  1378. cls: 'ext-cal-ev',
  1379. id: o.id + '-empty-0-day-' + dt.format('Ymd'),
  1380. html: '&nbsp;'
  1381. };
  1382. if (dayCount > 1) {
  1383. cellCfg.colspan = dayCount;
  1384. }
  1385. Ext.DomHelper.append(row, cellCfg);
  1386. }
  1387. dt = dt.add(Date.DAY, 7);
  1388. } else {
  1389. var row,
  1390. d = 0,
  1391. wk = grid[w],
  1392. startOfWeek = dt.clone(),
  1393. endOfWeek = startOfWeek.add(Date.DAY, dayCount).add(Date.MILLI, -1);
  1394. for (; d < dayCount; d++) {
  1395. if (wk[d]) {
  1396. var ev = emptyCells = skipped = 0,
  1397. day = wk[d],
  1398. ct = day.length,
  1399. evt;
  1400. for (; ev < ct; ev++) {
  1401. if (!day[ev]) {
  1402. emptyCells++;
  1403. continue;
  1404. }
  1405. if (emptyCells > 0 && ev - emptyCells < max) {
  1406. row = getEventRow(o.id, w, ev - emptyCells);
  1407. cellCfg = {
  1408. tag: 'td',
  1409. cls: 'ext-cal-ev',
  1410. id: o.id + '-empty-' + ct + '-day-' + dt.format('Ymd')
  1411. };
  1412. if (emptyCells > 1 && max - ev > emptyCells) {
  1413. cellCfg.rowspan = Math.min(emptyCells, max - ev);
  1414. }
  1415. Ext.DomHelper.append(row, cellCfg);
  1416. emptyCells = 0;
  1417. }
  1418. if (ev >= max) {
  1419. skipped++;
  1420. continue;
  1421. }
  1422. evt = day[ev];
  1423. if (!evt.isSpan || evt.isSpanStart) {
  1424. //skip non-starting span cells
  1425. var item = evt.data || evt.event.data;
  1426. item._weekIndex = w;
  1427. item._renderAsAllDay = item[Ext.calendar.EventMappings.IsAllDay.name] || evt.isSpanStart;
  1428. item.spanLeft = item[Ext.calendar.EventMappings.StartDate.name].getTime() < startOfWeek.getTime();
  1429. item.spanRight = item[Ext.calendar.EventMappings.EndDate.name].getTime() > endOfWeek.getTime();
  1430. item.spanCls = (item.spanLeft ? (item.spanRight ? 'ext-cal-ev-spanboth':
  1431. 'ext-cal-ev-spanleft') : (item.spanRight ? 'ext-cal-ev-spanright': ''));
  1432. row = getEventRow(o.id, w, ev);
  1433. cellCfg = {
  1434. tag: 'td',
  1435. cls: 'ext-cal-ev',
  1436. cn: eventTpl.apply(o.templateDataFn(item))
  1437. };
  1438. var diff = Ext.calendar.Date.diffDays(dt, item[Ext.calendar.EventMappings.EndDate.name]) + 1,
  1439. cspan = Math.min(diff, dayCount - d);
  1440. if (cspan > 1) {
  1441. cellCfg.colspan = cspan;
  1442. }
  1443. Ext.DomHelper.append(row, cellCfg);
  1444. }
  1445. }
  1446. if (ev > max) {
  1447. row = getEventRow(o.id, w, max);
  1448. Ext.DomHelper.append(row, {
  1449. tag: 'td',
  1450. cls: 'ext-cal-ev-more',
  1451. id: 'ext-cal-ev-more-' + dt.format('Ymd'),
  1452. cn: {
  1453. tag: 'a',
  1454. html: '+' + skipped + ' more...'
  1455. }
  1456. });
  1457. }
  1458. if (ct < o.evtMaxCount[w]) {
  1459. row = getEventRow(o.id, w, ct);
  1460. if (row) {
  1461. cellCfg = {
  1462. tag: 'td',
  1463. cls: 'ext-cal-ev',
  1464. id: o.id + '-empty-' + (ct + 1) + '-day-' + dt.format('Ymd')
  1465. };
  1466. var rowspan = o.evtMaxCount[w] - ct;
  1467. if (rowspan > 1) {
  1468. cellCfg.rowspan = rowspan;
  1469. }
  1470. Ext.DomHelper.append(row, cellCfg);
  1471. }
  1472. }
  1473. } else {
  1474. row = getEventRow(o.id, w, 0);
  1475. if (row) {
  1476. cellCfg = {
  1477. tag: 'td',
  1478. cls: 'ext-cal-ev',
  1479. id: o.id + '-empty-day-' + dt.format('Ymd')
  1480. };
  1481. if (o.evtMaxCount[w] > 1) {
  1482. cellCfg.rowSpan = o.evtMaxCount[w];
  1483. }
  1484. Ext.DomHelper.append(row, cellCfg);
  1485. }
  1486. }
  1487. dt = dt.add(Date.DAY, 1);
  1488. }
  1489. }
  1490. }
  1491. }
  1492. };
  1493. }();
  1494. /**
  1495. * @class Ext.calendar.CalendarView
  1496. * @extends Ext.BoxComponent
  1497. * <p>This is an abstract class that serves as the base for other calendar views. This class is not
  1498. * intended to be directly instantiated.</p>
  1499. * <p>When extending this class to create a custom calendar view, you must provide an implementation
  1500. * for the <code>renderItems</code> method, as there is no default implementation for rendering events
  1501. * The rendering logic is totally dependent on how the UI structures its data, which
  1502. * is determined by the underlying UI template (this base class does not have a template).</p>
  1503. * @constructor
  1504. * @param {Object} config The config object
  1505. */
  1506. Ext.calendar.CalendarView = Ext.extend(Ext.BoxComponent, {
  1507. /**
  1508. * @cfg {Number} startDay
  1509. * The 0-based index for the day on which the calendar week begins (0=Sunday, which is the default)
  1510. */
  1511. startDay: 0,
  1512. /**
  1513. * @cfg {Boolean} spansHavePriority
  1514. * Allows switching between two different modes of rendering events that span multiple days. When true,
  1515. * span events are always sorted first, possibly at the expense of start dates being out of order (e.g.,
  1516. * a span event that starts at 11am one day and spans into the next day would display before a non-spanning
  1517. * event that starts at 10am, even though they would not be in date order). This can lead to more compact
  1518. * layouts when there are many overlapping events. If false (the default), events will always sort by start date
  1519. * first which can result in a less compact, but chronologically consistent layout.
  1520. */
  1521. spansHavePriority: false,
  1522. /**
  1523. * @cfg {Boolean} trackMouseOver
  1524. * Whether or not the view tracks and responds to the browser mouseover event on contained elements (defaults to
  1525. * true). If you don't need mouseover event highlighting you can disable this.
  1526. */
  1527. trackMouseOver: true,
  1528. /**
  1529. * @cfg {Boolean} enableFx
  1530. * Determines whether or not visual effects for CRUD actions are enabled (defaults to true). If this is false
  1531. * it will override any values for {@link #enableAddFx}, {@link #enableUpdateFx} or {@link enableRemoveFx} and
  1532. * all animations will be disabled.
  1533. */
  1534. enableFx: true,
  1535. /**
  1536. * @cfg {Boolean} enableAddFx
  1537. * True to enable a visual effect on adding a new event (the default), false to disable it. Note that if
  1538. * {@link #enableFx} is false it will override this value. The specific effect that runs is defined in the
  1539. * {@link #doAddFx} method.
  1540. */
  1541. enableAddFx: true,
  1542. /**
  1543. * @cfg {Boolean} enableUpdateFx
  1544. * True to enable a visual effect on updating an event, false to disable it (the default). Note that if
  1545. * {@link #enableFx} is false it will override this value. The specific effect that runs is defined in the
  1546. * {@link #doUpdateFx} method.
  1547. */
  1548. enableUpdateFx: false,
  1549. /**
  1550. * @cfg {Boolean} enableRemoveFx
  1551. * True to enable a visual effect on removing an event (the default), false to disable it. Note that if
  1552. * {@link #enableFx} is false it will override this value. The specific effect that runs is defined in the
  1553. * {@link #doRemoveFx} method.
  1554. */
  1555. enableRemoveFx: true,
  1556. /**
  1557. * @cfg {Boolean} enableDD
  1558. * True to enable drag and drop in the calendar view (the default), false to disable it
  1559. */
  1560. enableDD: true,
  1561. /**
  1562. * @cfg {Boolean} monitorResize
  1563. * True to monitor the browser's resize event (the default), false to ignore it. If the calendar view is rendered
  1564. * into a fixed-size container this can be set to false. However, if the view can change dimensions (e.g., it's in
  1565. * fit layout in a viewport or some other resizable container) it is very important that this config is true so that
  1566. * any resize event propagates properly to all subcomponents and layouts get recalculated properly.
  1567. */
  1568. monitorResize: true,
  1569. /**
  1570. * @cfg {String} ddCreateEventText
  1571. * The text to display inside the drag proxy while dragging over the calendar to create a new event (defaults to
  1572. * 'Create event for {0}' where {0} is a date range supplied by the view)
  1573. */
  1574. ddCreateEventText: 'Create event for {0}',
  1575. /**
  1576. * @cfg {String} ddMoveEventText
  1577. * The text to display inside the drag proxy while dragging an event to reposition it (defaults to
  1578. * 'Move event to {0}' where {0} is the updated event start date/time supplied by the view)
  1579. */
  1580. ddMoveEventText: 'Move event to {0}',
  1581. /**
  1582. * @cfg {String} ddResizeEventText
  1583. * The string displayed to the user in the drag proxy while dragging the resize handle of an event (defaults to
  1584. * 'Update event to {0}' where {0} is the updated event start-end range supplied by the view). Note that
  1585. * this text is only used in views
  1586. * that allow resizing of events.
  1587. */
  1588. ddResizeEventText: 'Update event to {0}',
  1589. //private properties -- do not override:
  1590. weekCount: 1,
  1591. dayCount: 1,
  1592. eventSelector: '.ext-cal-evt',
  1593. eventOverClass: 'ext-evt-over',
  1594. eventElIdDelimiter: '-evt-',
  1595. dayElIdDelimiter: '-day-',
  1596. /**
  1597. * Returns a string of HTML template markup to be used as the body portion of the event template created
  1598. * by {@link #getEventTemplate}. This provdes the flexibility to customize what's in the body without
  1599. * having to override the entire XTemplate. This string can include any valid {@link Ext.Template} code, and
  1600. * any data tokens accessible to the containing event template can be referenced in this string.
  1601. * @return {String} The body template string
  1602. */
  1603. getEventBodyMarkup: Ext.emptyFn,
  1604. // must be implemented by a subclass
  1605. /**
  1606. * <p>Returns the XTemplate that is bound to the calendar's event store (it expects records of type
  1607. * {@link Ext.calendar.EventRecord}) to populate the calendar views with events. Internally this method
  1608. * by default generates different markup for browsers that support CSS border radius and those that don't.
  1609. * This method can be overridden as needed to customize the markup generated.</p>
  1610. * <p>Note that this method calls {@link #getEventBodyMarkup} to retrieve the body markup for events separately
  1611. * from the surrounding container markup. This provdes the flexibility to customize what's in the body without
  1612. * having to override the entire XTemplate. If you do override this method, you should make sure that your
  1613. * overridden version also does the same.</p>
  1614. * @return {Ext.XTemplate} The event XTemplate
  1615. */
  1616. getEventTemplate: Ext.emptyFn,
  1617. // must be implemented by a subclass
  1618. // private
  1619. initComponent: function() {
  1620. this.setStartDate(this.startDate || new Date());
  1621. Ext.calendar.CalendarView.superclass.initComponent.call(this);
  1622. this.addEvents({
  1623. /**
  1624. * @event eventsrendered
  1625. * Fires after events are finished rendering in the view
  1626. * @param {Ext.calendar.CalendarView} this
  1627. */
  1628. eventsrendered: true,
  1629. /**
  1630. * @event eventclick
  1631. * Fires after the user clicks on an event element
  1632. * @param {Ext.calendar.CalendarView} this
  1633. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was clicked on
  1634. * @param {HTMLNode} el The DOM node that was clicked on
  1635. */
  1636. eventclick: true,
  1637. /**
  1638. * @event eventover
  1639. * Fires anytime the mouse is over an event element
  1640. * @param {Ext.calendar.CalendarView} this
  1641. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that the cursor is over
  1642. * @param {HTMLNode} el The DOM node that is being moused over
  1643. */
  1644. eventover: true,
  1645. /**
  1646. * @event eventout
  1647. * Fires anytime the mouse exits an event element
  1648. * @param {Ext.calendar.CalendarView} this
  1649. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that the cursor exited
  1650. * @param {HTMLNode} el The DOM node that was exited
  1651. */
  1652. eventout: true,
  1653. /**
  1654. * @event datechange
  1655. * Fires after the start date of the view changes
  1656. * @param {Ext.calendar.CalendarView} this
  1657. * @param {Date} startDate The start date of the view (as explained in {@link #getStartDate}
  1658. * @param {Date} viewStart The first displayed date in the view
  1659. * @param {Date} viewEnd The last displayed date in the view
  1660. */
  1661. datechange: true,
  1662. /**
  1663. * @event rangeselect
  1664. * Fires after the user drags on the calendar to select a range of dates/times in which to create an event
  1665. * @param {Ext.calendar.CalendarView} this
  1666. * @param {Object} dates An object containing the start (StartDate property) and end (EndDate property) dates selected
  1667. * @param {Function} callback A callback function that MUST be called after the event handling is complete so that
  1668. * the view is properly cleaned up (shim elements are persisted in the view while the user is prompted to handle the
  1669. * range selection). The callback is already created in the proper scope, so it simply needs to be executed as a standard
  1670. * function call (e.g., callback()).
  1671. */
  1672. rangeselect: true,
  1673. /**
  1674. * @event eventmove
  1675. * Fires after an event element is dragged by the user and dropped in a new position
  1676. * @param {Ext.calendar.CalendarView} this
  1677. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was moved with
  1678. * updated start and end dates
  1679. */
  1680. eventmove: true,
  1681. /**
  1682. * @event initdrag
  1683. * Fires when a drag operation is initiated in the view
  1684. * @param {Ext.calendar.CalendarView} this
  1685. */
  1686. initdrag: true,
  1687. /**
  1688. * @event dayover
  1689. * Fires while the mouse is over a day element
  1690. * @param {Ext.calendar.CalendarView} this
  1691. * @param {Date} dt The date that is being moused over
  1692. * @param {Ext.Element} el The day Element that is being moused over
  1693. */
  1694. dayover: true,
  1695. /**
  1696. * @event dayout
  1697. * Fires when the mouse exits a day element
  1698. * @param {Ext.calendar.CalendarView} this
  1699. * @param {Date} dt The date that is exited
  1700. * @param {Ext.Element} el The day Element that is exited
  1701. */
  1702. dayout: true
  1703. /*
  1704. * @event eventdelete
  1705. * Fires after an event element is deleted by the user. Not currently implemented directly at the view level -- currently
  1706. * deletes only happen from one of the forms.
  1707. * @param {Ext.calendar.CalendarView} this
  1708. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was deleted
  1709. */
  1710. //eventdelete: true
  1711. });
  1712. },
  1713. // private
  1714. afterRender: function() {
  1715. Ext.calendar.CalendarView.superclass.afterRender.call(this);
  1716. this.renderTemplate();
  1717. if (this.store) {
  1718. this.setStore(this.store, true);
  1719. }
  1720. this.el.on({
  1721. 'mouseover': this.onMouseOver,
  1722. 'mouseout': this.onMouseOut,
  1723. 'click': this.onClick,
  1724. 'resize': this.onResize,
  1725. scope: this
  1726. });
  1727. this.el.unselectable();
  1728. if (this.enableDD && this.initDD) {
  1729. this.initDD();
  1730. }
  1731. this.on('eventsrendered', this.forceSize);
  1732. this.forceSize.defer(100, this);
  1733. },
  1734. // private
  1735. forceSize: function() {
  1736. if (this.el && this.el.child) {
  1737. var hd = this.el.child('.ext-cal-hd-ct'),
  1738. bd = this.el.child('.ext-cal-body-ct');
  1739. if (bd == null || hd == null) return;
  1740. var headerHeight = hd.getHeight(),
  1741. sz = this.el.parent().getSize();
  1742. bd.setHeight(sz.height - headerHeight);
  1743. }
  1744. },
  1745. refresh: function() {
  1746. this.prepareData();
  1747. this.renderTemplate();
  1748. this.renderItems();
  1749. },
  1750. getWeekCount: function() {
  1751. var days = Ext.calendar.Date.diffDays(this.viewStart, this.viewEnd);
  1752. return Math.ceil(days / this.dayCount);
  1753. },
  1754. // private
  1755. prepareData: function() {
  1756. var lastInMonth = this.startDate.getLastDateOfMonth(),
  1757. w = 0,
  1758. row = 0,
  1759. dt = this.viewStart.clone(),
  1760. weeks = this.weekCount < 1 ? 6: this.weekCount;
  1761. this.eventGrid = [[]];
  1762. this.allDayGrid = [[]];
  1763. this.evtMaxCount = [];
  1764. var evtsInView = this.store.queryBy(function(rec) {
  1765. return this.isEventVisible(rec.data);
  1766. },
  1767. this);
  1768. for (; w < weeks; w++) {
  1769. this.evtMaxCount[w] = 0;
  1770. if (this.weekCount == -1 && dt > lastInMonth) {
  1771. //current week is fully in next month so skip
  1772. break;
  1773. }
  1774. this.eventGrid[w] = this.eventGrid[w] || [];
  1775. this.allDayGrid[w] = this.allDayGrid[w] || [];
  1776. for (d = 0; d < this.dayCount; d++) {
  1777. if (evtsInView.getCount() > 0) {
  1778. var evts = evtsInView.filterBy(function(rec) {
  1779. var startsOnDate = (dt.getTime() == rec.data[Ext.calendar.EventMappings.StartDate.name].clearTime(true).getTime());
  1780. var spansFromPrevView = (w == 0 && d == 0 && (dt > rec.data[Ext.calendar.EventMappings.StartDate.name]));
  1781. return startsOnDate || spansFromPrevView;
  1782. },
  1783. this);
  1784. this.sortEventRecordsForDay(evts);
  1785. this.prepareEventGrid(evts, w, d);
  1786. }
  1787. dt = dt.add(Date.DAY, 1);
  1788. }
  1789. }
  1790. this.currentWeekCount = w;
  1791. },
  1792. // private
  1793. prepareEventGrid: function(evts, w, d) {
  1794. var row = 0,
  1795. dt = this.viewStart.clone(),
  1796. max = this.maxEventsPerDay ? this.maxEventsPerDay: 999;
  1797. evts.each(function(evt) {
  1798. var M = Ext.calendar.EventMappings,
  1799. days = Ext.calendar.Date.diffDays(
  1800. Ext.calendar.Date.max(this.viewStart, evt.data[M.StartDate.name]),
  1801. Ext.calendar.Date.min(this.viewEnd, evt.data[M.EndDate.name])) + 1;
  1802. if (days > 1 || Ext.calendar.Date.diffDays(evt.data[M.StartDate.name], evt.data[M.EndDate.name]) > 1) {
  1803. this.prepareEventGridSpans(evt, this.eventGrid, w, d, days);
  1804. this.prepareEventGridSpans(evt, this.allDayGrid, w, d, days, true);
  1805. } else {
  1806. row = this.findEmptyRowIndex(w, d);
  1807. this.eventGrid[w][d] = this.eventGrid[w][d] || [];
  1808. this.eventGrid[w][d][row] = evt;
  1809. if (evt.data[M.IsAllDay.name]) {
  1810. row = this.findEmptyRowIndex(w, d, true);
  1811. this.allDayGrid[w][d] = this.allDayGrid[w][d] || [];
  1812. this.allDayGrid[w][d][row] = evt;
  1813. }
  1814. }
  1815. if (this.evtMaxCount[w] < this.eventGrid[w][d].length) {
  1816. this.evtMaxCount[w] = Math.min(max + 1, this.eventGrid[w][d].length);
  1817. }
  1818. return true;
  1819. },
  1820. this);
  1821. },
  1822. // private
  1823. prepareEventGridSpans: function(evt, grid, w, d, days, allday) {
  1824. // this event spans multiple days/weeks, so we have to preprocess
  1825. // the events and store special span events as placeholders so that
  1826. // the render routine can build the necessary TD spans correctly.
  1827. var w1 = w,
  1828. d1 = d,
  1829. row = this.findEmptyRowIndex(w, d, allday),
  1830. dt = this.viewStart.clone();
  1831. var start = {
  1832. event: evt,
  1833. isSpan: true,
  1834. isSpanStart: true,
  1835. spanLeft: false,
  1836. spanRight: (d == 6)
  1837. };
  1838. grid[w][d] = grid[w][d] || [];
  1839. grid[w][d][row] = start;
  1840. while (--days) {
  1841. dt = dt.add(Date.DAY, 1);
  1842. if (dt > this.viewEnd) {
  1843. break;
  1844. }
  1845. if (++d1 > 6) {
  1846. // reset counters to the next week
  1847. d1 = 0;
  1848. w1++;
  1849. row = this.findEmptyRowIndex(w1, 0);
  1850. }
  1851. grid[w1] = grid[w1] || [];
  1852. grid[w1][d1] = grid[w1][d1] || [];
  1853. grid[w1][d1][row] = {
  1854. event: evt,
  1855. isSpan: true,
  1856. isSpanStart: (d1 == 0),
  1857. spanLeft: (w1 > w) && (d1 % 7 == 0),
  1858. spanRight: (d1 == 6) && (days > 1)
  1859. };
  1860. }
  1861. },
  1862. // private
  1863. findEmptyRowIndex: function(w, d, allday) {
  1864. var grid = allday ? this.allDayGrid: this.eventGrid,
  1865. day = grid[w] ? grid[w][d] || [] : [],
  1866. i = 0,
  1867. ln = day.length;
  1868. for (; i < ln; i++) {
  1869. if (day[i] == null) {
  1870. return i;
  1871. }
  1872. }
  1873. return ln;
  1874. },
  1875. // private
  1876. renderTemplate: function() {
  1877. if (this.tpl) {
  1878. this.tpl.overwrite(this.el, this.getParams());
  1879. this.lastRenderStart = this.viewStart.clone();
  1880. this.lastRenderEnd = this.viewEnd.clone();
  1881. }
  1882. },
  1883. disableStoreEvents: function() {
  1884. this.monitorStoreEvents = false;
  1885. },
  1886. enableStoreEvents: function(refresh) {
  1887. this.monitorStoreEvents = true;
  1888. if (refresh === true) {
  1889. this.refresh();
  1890. }
  1891. },
  1892. // private
  1893. onResize: function() {
  1894. this.refresh();
  1895. },
  1896. // private
  1897. onInitDrag: function() {
  1898. this.fireEvent('initdrag', this);
  1899. },
  1900. // private
  1901. onEventDrop: function(rec, dt) {
  1902. if (Ext.calendar.Date.compare(rec.data[Ext.calendar.EventMappings.StartDate.name], dt) === 0) {
  1903. // no changes
  1904. return;
  1905. }
  1906. var diff = dt.getTime() - rec.data[Ext.calendar.EventMappings.StartDate.name].getTime();
  1907. rec.set(Ext.calendar.EventMappings.StartDate.name, dt);
  1908. rec.set(Ext.calendar.EventMappings.EndDate.name, rec.data[Ext.calendar.EventMappings.EndDate.name].add(Date.MILLI, diff));
  1909. this.fireEvent('eventmove', this, rec);
  1910. },
  1911. // private
  1912. onCalendarEndDrag: function(start, end, onComplete) {
  1913. // set this flag for other event handlers that might conflict while we're waiting
  1914. this.dragPending = true;
  1915. // have to wait for the user to save or cancel before finalizing the dd interation
  1916. var o = {};
  1917. o[Ext.calendar.EventMappings.StartDate.name] = start;
  1918. o[Ext.calendar.EventMappings.EndDate.name] = end;
  1919. this.fireEvent('rangeselect', this, o, this.onCalendarEndDragComplete.createDelegate(this, [onComplete]));
  1920. },
  1921. // private
  1922. onCalendarEndDragComplete: function(onComplete) {
  1923. // callback for the drop zone to clean up
  1924. onComplete();
  1925. // clear flag for other events to resume normally
  1926. this.dragPending = false;
  1927. },
  1928. // private
  1929. onUpdate: function(ds, rec, operation) {
  1930. if (this.monitorStoreEvents === false) {
  1931. return;
  1932. }
  1933. if (operation == Ext.data.Record.COMMIT) {
  1934. this.refresh();
  1935. if (this.enableFx && this.enableUpdateFx) {
  1936. this.doUpdateFx(this.getEventEls(rec.data[Ext.calendar.EventMappings.EventId.name]), {
  1937. scope: this
  1938. });
  1939. }
  1940. }
  1941. },
  1942. doUpdateFx: function(els, o) {
  1943. this.highlightEvent(els, null, o);
  1944. },
  1945. // private
  1946. onAdd: function(ds, records, index) {
  1947. if (this.monitorStoreEvents === false) {
  1948. return;
  1949. }
  1950. var rec = records[0];
  1951. this.tempEventId = rec.id;
  1952. this.refresh();
  1953. if (this.enableFx && this.enableAddFx) {
  1954. this.doAddFx(this.getEventEls(rec.data[Ext.calendar.EventMappings.EventId.name]), {
  1955. scope: this
  1956. });
  1957. };
  1958. },
  1959. doAddFx: function(els, o) {
  1960. els.fadeIn(Ext.apply(o, {
  1961. duration: 2
  1962. }));
  1963. },
  1964. // private
  1965. onRemove: function(ds, rec) {
  1966. if (this.monitorStoreEvents === false) {
  1967. return;
  1968. }
  1969. if (this.enableFx && this.enableRemoveFx) {
  1970. this.doRemoveFx(this.getEventEls(rec.data[Ext.calendar.EventMappings.EventId.name]), {
  1971. remove: true,
  1972. scope: this,
  1973. callback: this.refresh
  1974. });
  1975. }
  1976. else {
  1977. this.getEventEls(rec.data[Ext.calendar.EventMappings.EventId.name]).remove();
  1978. this.refresh();
  1979. }
  1980. },
  1981. doRemoveFx: function(els, o) {
  1982. els.fadeOut(o);
  1983. },
  1984. /**
  1985. * Visually highlights an event using {@link Ext.Fx#highlight} config options.
  1986. * If {@link #highlightEventActions} is false this method will have no effect.
  1987. * @param {Ext.CompositeElement} els The element(s) to highlight
  1988. * @param {Object} color (optional) The highlight color. Should be a 6 char hex
  1989. * color without the leading # (defaults to yellow: 'ffff9c')
  1990. * @param {Object} o (optional) Object literal with any of the {@link Ext.Fx} config
  1991. * options. See {@link Ext.Fx#highlight} for usage examples.
  1992. */
  1993. highlightEvent: function(els, color, o) {
  1994. if (this.enableFx) {
  1995. var c;
  1996. ! (Ext.isIE || Ext.isOpera) ?
  1997. els.highlight(color, o) :
  1998. // Fun IE/Opera handling:
  1999. els.each(function(el) {
  2000. el.highlight(color, Ext.applyIf({
  2001. attr: 'color'
  2002. },
  2003. o));
  2004. c = el.child('.ext-cal-evm');
  2005. if (c) {
  2006. c.highlight(color, o);
  2007. }
  2008. },
  2009. this);
  2010. }
  2011. },
  2012. /**
  2013. * Retrieve an Event object's id from its corresponding node in the DOM.
  2014. * @param {String/Element/HTMLElement} el An {@link Ext.Element}, DOM node or id
  2015. */
  2016. getEventIdFromEl: function(el) {
  2017. el = Ext.get(el);
  2018. var id = el.id.split(this.eventElIdDelimiter)[1];
  2019. if (id.indexOf('-') > -1) {
  2020. //This id has the index of the week it is rendered in as the suffix.
  2021. //This allows events that span across weeks to still have reproducibly-unique DOM ids.
  2022. id = id.split('-')[0];
  2023. }
  2024. return id;
  2025. },
  2026. // private
  2027. getEventId: function(eventId) {
  2028. if (eventId === undefined && this.tempEventId) {
  2029. eventId = this.tempEventId;
  2030. }
  2031. return eventId;
  2032. },
  2033. /**
  2034. *
  2035. * @param {String} eventId
  2036. * @param {Boolean} forSelect
  2037. * @return {String} The selector class
  2038. */
  2039. getEventSelectorCls: function(eventId, forSelect) {
  2040. var prefix = forSelect ? '.': '';
  2041. return prefix + this.id + this.eventElIdDelimiter + this.getEventId(eventId);
  2042. },
  2043. /**
  2044. *
  2045. * @param {String} eventId
  2046. * @return {Ext.CompositeElement} The matching CompositeElement of nodes
  2047. * that comprise the rendered event. Any event that spans across a view
  2048. * boundary will contain more than one internal Element.
  2049. */
  2050. getEventEls: function(eventId) {
  2051. var els = Ext.select(this.getEventSelectorCls(this.getEventId(eventId), true), false, this.el.id);
  2052. return new Ext.CompositeElement(els);
  2053. },
  2054. /**
  2055. * Returns true if the view is currently displaying today's date, else false.
  2056. * @return {Boolean} True or false
  2057. */
  2058. isToday: function() {
  2059. var today = new Date().clearTime().getTime();
  2060. return this.viewStart.getTime() <= today && this.viewEnd.getTime() >= today;
  2061. },
  2062. // private
  2063. onDataChanged: function(store) {
  2064. this.refresh();
  2065. },
  2066. // private
  2067. isEventVisible: function(evt) {
  2068. var start = this.viewStart.getTime(),
  2069. end = this.viewEnd.getTime(),
  2070. M = Ext.calendar.EventMappings,
  2071. evStart = (evt.data ? evt.data[M.StartDate.name] : evt[M.StartDate.name]).getTime(),
  2072. evEnd = (evt.data ? evt.data[M.EndDate.name] : evt[M.EndDate.name]).add(Date.SECOND, -1).getTime(),
  2073. startsInRange = (evStart >= start && evStart <= end),
  2074. endsInRange = (evEnd >= start && evEnd <= end),
  2075. spansRange = (evStart < start && evEnd > end);
  2076. return (startsInRange || endsInRange || spansRange);
  2077. },
  2078. // private
  2079. isOverlapping: function(evt1, evt2) {
  2080. var ev1 = evt1.data ? evt1.data: evt1,
  2081. ev2 = evt2.data ? evt2.data: evt2,
  2082. M = Ext.calendar.EventMappings,
  2083. start1 = ev1[M.StartDate.name].getTime(),
  2084. end1 = ev1[M.EndDate.name].add(Date.SECOND, -1).getTime(),
  2085. start2 = ev2[M.StartDate.name].getTime(),
  2086. end2 = ev2[M.EndDate.name].add(Date.SECOND, -1).getTime();
  2087. if (end1 < start1) {
  2088. end1 = start1;
  2089. }
  2090. if (end2 < start2) {
  2091. end2 = start2;
  2092. }
  2093. var ev1startsInEv2 = (start1 >= start2 && start1 <= end2),
  2094. ev1EndsInEv2 = (end1 >= start2 && end1 <= end2),
  2095. ev1SpansEv2 = (start1 < start2 && end1 > end2);
  2096. return (ev1startsInEv2 || ev1EndsInEv2 || ev1SpansEv2);
  2097. },
  2098. getDayEl: function(dt) {
  2099. return Ext.get(this.getDayId(dt));
  2100. },
  2101. getDayId: function(dt) {
  2102. if (Ext.isDate(dt)) {
  2103. dt = dt.format('Ymd');
  2104. }
  2105. return this.id + this.dayElIdDelimiter + dt;
  2106. },
  2107. /**
  2108. * Returns the start date of the view, as set by {@link #setStartDate}. Note that this may not
  2109. * be the first date displayed in the rendered calendar -- to get the start and end dates displayed
  2110. * to the user use {@link #getViewBounds}.
  2111. * @return {Date} The start date
  2112. */
  2113. getStartDate: function() {
  2114. return this.startDate;
  2115. },
  2116. /**
  2117. * Sets the start date used to calculate the view boundaries to display. The displayed view will be the
  2118. * earliest and latest dates that match the view requirements and contain the date passed to this function.
  2119. * @param {Date} dt The date used to calculate the new view boundaries
  2120. */
  2121. setStartDate: function(start, refresh) {
  2122. this.startDate = start.clearTime();
  2123. this.setViewBounds(start);
  2124. this.store.load({
  2125. params: {
  2126. start: this.viewStart.format('m-d-Y'),
  2127. end: this.viewEnd.format('m-d-Y')
  2128. }
  2129. });
  2130. if (refresh === true) {
  2131. this.refresh();
  2132. }
  2133. this.fireEvent('datechange', this, this.startDate, this.viewStart, this.viewEnd);
  2134. },
  2135. // private
  2136. setViewBounds: function(startDate) {
  2137. var start = startDate || this.startDate,
  2138. offset = start.getDay() - this.startDay;
  2139. switch (this.weekCount) {
  2140. case 0:
  2141. case 1:
  2142. this.viewStart = this.dayCount < 7 ? start: start.add(Date.DAY, -offset).clearTime(true);
  2143. this.viewEnd = this.viewStart.add(Date.DAY, this.dayCount || 7).add(Date.SECOND, -1);
  2144. return;
  2145. case - 1:
  2146. // auto by month
  2147. start = start.getFirstDateOfMonth();
  2148. offset = start.getDay() - this.startDay;
  2149. if (offset < 0) {
  2150. offset += 7;
  2151. }
  2152. this.viewStart = start.add(Date.DAY, -offset).clearTime(true);
  2153. // start from current month start, not view start:
  2154. var end = start.add(Date.MONTH, 1).add(Date.SECOND, -1);
  2155. // fill out to the end of the week:
  2156. offset = this.startDay;
  2157. if (offset > end.getDay()){
  2158. // if the offset is larger than the end day index then the last row will be empty so skip it
  2159. offset -= 7;
  2160. }
  2161. this.viewEnd = end.add(Date.DAY, 6 - end.getDay() + offset);
  2162. return;
  2163. default:
  2164. this.viewStart = start.add(Date.DAY, -offset).clearTime(true);
  2165. this.viewEnd = this.viewStart.add(Date.DAY, this.weekCount * 7).add(Date.SECOND, -1);
  2166. }
  2167. },
  2168. // private
  2169. getViewBounds: function() {
  2170. return {
  2171. start: this.viewStart,
  2172. end: this.viewEnd
  2173. };
  2174. },
  2175. /* private
  2176. * Sort events for a single day for display in the calendar. This sorts allday
  2177. * events first, then non-allday events are sorted either based on event start
  2178. * priority or span priority based on the value of {@link #spansHavePriority}
  2179. * (defaults to event start priority).
  2180. * @param {MixedCollection} evts A {@link Ext.util.MixedCollection MixedCollection}
  2181. * of {@link #Ext.calendar.EventRecord EventRecord} objects
  2182. */
  2183. sortEventRecordsForDay: function(evts) {
  2184. if (evts.length < 2) {
  2185. return;
  2186. }
  2187. evts.sort('ASC',
  2188. function(evtA, evtB) {
  2189. var a = evtA.data,
  2190. b = evtB.data,
  2191. M = Ext.calendar.EventMappings;
  2192. // Always sort all day events before anything else
  2193. if (a[M.IsAllDay.name]) {
  2194. return - 1;
  2195. }
  2196. else if (b[M.IsAllDay.name]) {
  2197. return 1;
  2198. }
  2199. if (this.spansHavePriority) {
  2200. // This logic always weights span events higher than non-span events
  2201. // (at the possible expense of start time order). This seems to
  2202. // be the approach used by Google calendar and can lead to a more
  2203. // visually appealing layout in complex cases, but event order is
  2204. // not guaranteed to be consistent.
  2205. var diff = Ext.calendar.Date.diffDays;
  2206. if (diff(a[M.StartDate.name], a[M.EndDate.name]) > 0) {
  2207. if (diff(b[M.StartDate.name], b[M.EndDate.name]) > 0) {
  2208. // Both events are multi-day
  2209. if (a[M.StartDate.name].getTime() == b[M.StartDate.name].getTime()) {
  2210. // If both events start at the same time, sort the one
  2211. // that ends later (potentially longer span bar) first
  2212. return b[M.EndDate.name].getTime() - a[M.EndDate.name].getTime();
  2213. }
  2214. return a[M.StartDate.name].getTime() - b[M.StartDate.name].getTime();
  2215. }
  2216. return - 1;
  2217. }
  2218. else if (diff(b[M.StartDate.name], b[M.EndDate.name]) > 0) {
  2219. return 1;
  2220. }
  2221. return a[M.StartDate.name].getTime() - b[M.StartDate.name].getTime();
  2222. }
  2223. else {
  2224. // Doing this allows span and non-span events to intermingle but
  2225. // remain sorted sequentially by start time. This seems more proper
  2226. // but can make for a less visually-compact layout when there are
  2227. // many such events mixed together closely on the calendar.
  2228. return a[M.StartDate.name].getTime() - b[M.StartDate.name].getTime();
  2229. }
  2230. }.createDelegate(this));
  2231. },
  2232. /**
  2233. * Updates the view to contain the passed date
  2234. * @param {Date} dt The date to display
  2235. */
  2236. moveTo: function(dt, noRefresh) {
  2237. if (Ext.isDate(dt)) {
  2238. this.setStartDate(dt);
  2239. if (noRefresh !== false) {
  2240. this.refresh();
  2241. }
  2242. return this.startDate;
  2243. }
  2244. return dt;
  2245. },
  2246. /**
  2247. * Updates the view to the next consecutive date(s)
  2248. */
  2249. moveNext: function(noRefresh) {
  2250. return this.moveTo(this.viewEnd.add(Date.DAY, 1));
  2251. },
  2252. /**
  2253. * Updates the view to the previous consecutive date(s)
  2254. */
  2255. movePrev: function(noRefresh) {
  2256. var days = Ext.calendar.Date.diffDays(this.viewStart, this.viewEnd) + 1;
  2257. return this.moveDays( - days, noRefresh);
  2258. },
  2259. /**
  2260. * Shifts the view by the passed number of months relative to the currently set date
  2261. * @param {Number} value The number of months (positive or negative) by which to shift the view
  2262. */
  2263. moveMonths: function(value, noRefresh) {
  2264. return this.moveTo(this.startDate.add(Date.MONTH, value), noRefresh);
  2265. },
  2266. /**
  2267. * Shifts the view by the passed number of weeks relative to the currently set date
  2268. * @param {Number} value The number of weeks (positive or negative) by which to shift the view
  2269. */
  2270. moveWeeks: function(value, noRefresh) {
  2271. return this.moveTo(this.startDate.add(Date.DAY, value * 7), noRefresh);
  2272. },
  2273. /**
  2274. * Shifts the view by the passed number of days relative to the currently set date
  2275. * @param {Number} value The number of days (positive or negative) by which to shift the view
  2276. */
  2277. moveDays: function(value, noRefresh) {
  2278. return this.moveTo(this.startDate.add(Date.DAY, value), noRefresh);
  2279. },
  2280. /**
  2281. * Updates the view to show today
  2282. */
  2283. moveToday: function(noRefresh) {
  2284. return this.moveTo(new Date(), noRefresh);
  2285. },
  2286. /**
  2287. * Sets the event store used by the calendar to display {@link Ext.calendar.EventRecord events}.
  2288. * @param {Ext.data.Store} store
  2289. */
  2290. setStore: function(store, initial) {
  2291. if (!initial && this.store) {
  2292. this.store.un("datachanged", this.onDataChanged, this);
  2293. this.store.un("add", this.onAdd, this);
  2294. this.store.un("remove", this.onRemove, this);
  2295. this.store.un("update", this.onUpdate, this);
  2296. this.store.un("clear", this.refresh, this);
  2297. }
  2298. if (store) {
  2299. store.on("datachanged", this.onDataChanged, this);
  2300. store.on("add", this.onAdd, this);
  2301. store.on("remove", this.onRemove, this);
  2302. store.on("update", this.onUpdate, this);
  2303. store.on("clear", this.refresh, this);
  2304. }
  2305. this.store = store;
  2306. if (store && store.getCount() > 0) {
  2307. this.refresh();
  2308. }
  2309. },
  2310. getEventRecord: function(id) {
  2311. var idx = this.store.find(Ext.calendar.EventMappings.EventId.name, id);
  2312. return this.store.getAt(idx);
  2313. },
  2314. getEventRecordFromEl: function(el) {
  2315. return this.getEventRecord(this.getEventIdFromEl(el));
  2316. },
  2317. // private
  2318. getParams: function() {
  2319. return {
  2320. viewStart: this.viewStart,
  2321. viewEnd: this.viewEnd,
  2322. startDate: this.startDate,
  2323. dayCount: this.dayCount,
  2324. weekCount: this.weekCount,
  2325. title: this.getTitle()
  2326. };
  2327. },
  2328. getTitle: function() {
  2329. return this.startDate.format('F Y');
  2330. },
  2331. /*
  2332. * Shared click handling. Each specific view also provides view-specific
  2333. * click handling that calls this first. This method returns true if it
  2334. * can handle the click (and so the subclass should ignore it) else false.
  2335. */
  2336. onClick: function(e, t) {
  2337. var el = e.getTarget(this.eventSelector, 5);
  2338. if (el) {
  2339. var id = this.getEventIdFromEl(el);
  2340. this.fireEvent('eventclick', this, this.getEventRecord(id), el);
  2341. return true;
  2342. }
  2343. },
  2344. // private
  2345. onMouseOver: function(e, t) {
  2346. if (this.trackMouseOver !== false && (this.dragZone == undefined || !this.dragZone.dragging)) {
  2347. if (!this.handleEventMouseEvent(e, t, 'over')) {
  2348. this.handleDayMouseEvent(e, t, 'over');
  2349. }
  2350. }
  2351. },
  2352. // private
  2353. onMouseOut: function(e, t) {
  2354. if (this.trackMouseOver !== false && (this.dragZone == undefined || !this.dragZone.dragging)) {
  2355. if (!this.handleEventMouseEvent(e, t, 'out')) {
  2356. this.handleDayMouseEvent(e, t, 'out');
  2357. }
  2358. }
  2359. },
  2360. // private
  2361. handleEventMouseEvent: function(e, t, type) {
  2362. var el = e.getTarget(this.eventSelector, 5, true),
  2363. rel,
  2364. els,
  2365. evtId;
  2366. if (el) {
  2367. rel = Ext.get(e.getRelatedTarget());
  2368. if (el == rel || el.contains(rel)) {
  2369. return true;
  2370. }
  2371. evtId = this.getEventIdFromEl(el);
  2372. if (this.eventOverClass != '') {
  2373. els = this.getEventEls(evtId);
  2374. els[type == 'over' ? 'addClass': 'removeClass'](this.eventOverClass);
  2375. }
  2376. this.fireEvent('event' + type, this, this.getEventRecord(evtId), el);
  2377. return true;
  2378. }
  2379. return false;
  2380. },
  2381. // private
  2382. getDateFromId: function(id, delim) {
  2383. var parts = id.split(delim);
  2384. return parts[parts.length - 1];
  2385. },
  2386. // private
  2387. handleDayMouseEvent: function(e, t, type) {
  2388. t = e.getTarget('td', 3);
  2389. if (t) {
  2390. if (t.id && t.id.indexOf(this.dayElIdDelimiter) > -1) {
  2391. var dt = this.getDateFromId(t.id, this.dayElIdDelimiter),
  2392. rel = Ext.get(e.getRelatedTarget()),
  2393. relTD,
  2394. relDate;
  2395. if (rel) {
  2396. relTD = rel.is('td') ? rel: rel.up('td', 3);
  2397. relDate = relTD && relTD.id ? this.getDateFromId(relTD.id, this.dayElIdDelimiter) : '';
  2398. }
  2399. if (!rel || dt != relDate) {
  2400. var el = this.getDayEl(dt);
  2401. if (el && this.dayOverClass != '') {
  2402. el[type == 'over' ? 'addClass': 'removeClass'](this.dayOverClass);
  2403. }
  2404. this.fireEvent('day' + type, this, Date.parseDate(dt, "Ymd"), el);
  2405. }
  2406. }
  2407. }
  2408. },
  2409. // private
  2410. renderItems: function() {
  2411. throw 'This method must be implemented by a subclass';
  2412. }
  2413. });
  2414. /**
  2415. * @class Ext.calendar.MonthView
  2416. * @extends Ext.calendar.CalendarView
  2417. * <p>Displays a calendar view by month. This class does not usually need ot be used directly as you can
  2418. * use a {@link Ext.calendar.CalendarPanel CalendarPanel} to manage multiple calendar views at once including
  2419. * the month view.</p>
  2420. * @constructor
  2421. * @param {Object} config The config object
  2422. */
  2423. Ext.calendar.MonthView = Ext.extend(Ext.calendar.CalendarView, {
  2424. /**
  2425. * @cfg {Boolean} showTime
  2426. * True to display the current time in today's box in the calendar, false to not display it (defautls to true)
  2427. */
  2428. showTime: true,
  2429. /**
  2430. * @cfg {Boolean} showTodayText
  2431. * True to display the {@link #todayText} string in today's box in the calendar, false to not display it (defautls to true)
  2432. */
  2433. showTodayText: true,
  2434. /**
  2435. * @cfg {String} todayText
  2436. * The text to display in the current day's box in the calendar when {@link #showTodayText} is true (defaults to 'Today')
  2437. */
  2438. todayText: 'Today',
  2439. /**
  2440. * @cfg {Boolean} showHeader
  2441. * True to display a header beneath the navigation bar containing the week names above each week's column, false not to
  2442. * show it and instead display the week names in the first row of days in the calendar (defaults to false).
  2443. */
  2444. showHeader: false,
  2445. /**
  2446. * @cfg {Boolean} showWeekLinks
  2447. * True to display an extra column before the first day in the calendar that links to the {@link Ext.calendar.WeekView view}
  2448. * for each individual week, false to not show it (defaults to false). If true, the week links can also contain the week
  2449. * number depending on the value of {@link #showWeekNumbers}.
  2450. */
  2451. showWeekLinks: false,
  2452. /**
  2453. * @cfg {Boolean} showWeekNumbers
  2454. * True to show the week number for each week in the calendar in the week link column, false to show nothing (defaults to false).
  2455. * Note that if {@link #showWeekLinks} is false this config will have no affect even if true.
  2456. */
  2457. showWeekNumbers: false,
  2458. /**
  2459. * @cfg {String} weekLinkOverClass
  2460. * The CSS class name applied when the mouse moves over a week link element (only applies when {@link #showWeekLinks} is true,
  2461. * defaults to 'ext-week-link-over').
  2462. */
  2463. weekLinkOverClass: 'ext-week-link-over',
  2464. //private properties -- do not override:
  2465. daySelector: '.ext-cal-day',
  2466. moreSelector: '.ext-cal-ev-more',
  2467. weekLinkSelector: '.ext-cal-week-link',
  2468. weekCount: -1,
  2469. // defaults to auto by month
  2470. dayCount: 7,
  2471. moreElIdDelimiter: '-more-',
  2472. weekLinkIdDelimiter: 'ext-cal-week-',
  2473. // private
  2474. initComponent: function() {
  2475. Ext.calendar.MonthView.superclass.initComponent.call(this);
  2476. this.addEvents({
  2477. /**
  2478. * @event dayclick
  2479. * Fires after the user clicks within the view container and not on an event element
  2480. * @param {Ext.calendar.MonthView} this
  2481. * @param {Date} dt The date/time that was clicked on
  2482. * @param {Boolean} allday True if the day clicked on represents an all-day box, else false. Clicks within the
  2483. * MonthView always return true for this param.
  2484. * @param {Ext.Element} el The Element that was clicked on
  2485. */
  2486. dayclick: true,
  2487. /**
  2488. * @event weekclick
  2489. * Fires after the user clicks within a week link (when {@link #showWeekLinks is true)
  2490. * @param {Ext.calendar.MonthView} this
  2491. * @param {Date} dt The start date of the week that was clicked on
  2492. */
  2493. weekclick: true,
  2494. // inherited docs
  2495. dayover: true,
  2496. // inherited docs
  2497. dayout: true
  2498. });
  2499. },
  2500. // private
  2501. initDD: function() {
  2502. var cfg = {
  2503. view: this,
  2504. createText: this.ddCreateEventText,
  2505. moveText: this.ddMoveEventText,
  2506. ddGroup: 'MonthViewDD'
  2507. };
  2508. this.dragZone = new Ext.calendar.DragZone(this.el, cfg);
  2509. this.dropZone = new Ext.calendar.DropZone(this.el, cfg);
  2510. },
  2511. // private
  2512. onDestroy: function() {
  2513. Ext.destroy(this.ddSelector);
  2514. Ext.destroy(this.dragZone);
  2515. Ext.destroy(this.dropZone);
  2516. Ext.calendar.MonthView.superclass.onDestroy.call(this);
  2517. },
  2518. // private
  2519. afterRender: function() {
  2520. if (!this.tpl) {
  2521. this.tpl = new Ext.calendar.MonthViewTemplate({
  2522. id: this.id,
  2523. showTodayText: this.showTodayText,
  2524. todayText: this.todayText,
  2525. showTime: this.showTime,
  2526. showHeader: this.showHeader,
  2527. showWeekLinks: this.showWeekLinks,
  2528. showWeekNumbers: this.showWeekNumbers
  2529. });
  2530. }
  2531. this.tpl.compile();
  2532. this.addClass('ext-cal-monthview ext-cal-ct');
  2533. Ext.calendar.MonthView.superclass.afterRender.call(this);
  2534. },
  2535. // private
  2536. onResize: function() {
  2537. if (this.monitorResize) {
  2538. this.maxEventsPerDay = this.getMaxEventsPerDay();
  2539. this.refresh();
  2540. }
  2541. },
  2542. // private
  2543. forceSize: function() {
  2544. // Compensate for the week link gutter width if visible
  2545. if (this.showWeekLinks && this.el && this.el.child) {
  2546. var hd = this.el.select('.ext-cal-hd-days-tbl'),
  2547. bgTbl = this.el.select('.ext-cal-bg-tbl'),
  2548. evTbl = this.el.select('.ext-cal-evt-tbl'),
  2549. wkLinkW = this.el.child('.ext-cal-week-link').getWidth(),
  2550. w = this.el.getWidth() - wkLinkW;
  2551. hd.setWidth(w);
  2552. bgTbl.setWidth(w);
  2553. evTbl.setWidth(w);
  2554. }
  2555. Ext.calendar.MonthView.superclass.forceSize.call(this);
  2556. },
  2557. //private
  2558. initClock: function() {
  2559. if (Ext.fly(this.id + '-clock') !== null) {
  2560. this.prevClockDay = new Date().getDay();
  2561. if (this.clockTask) {
  2562. Ext.TaskMgr.stop(this.clockTask);
  2563. }
  2564. this.clockTask = Ext.TaskMgr.start({
  2565. run: function() {
  2566. var el = Ext.fly(this.id + '-clock'),
  2567. t = new Date();
  2568. if (t.getDay() == this.prevClockDay) {
  2569. if (el) {
  2570. el.update(t.format('g:i a'));
  2571. }
  2572. }
  2573. else {
  2574. this.prevClockDay = t.getDay();
  2575. this.moveTo(t);
  2576. }
  2577. },
  2578. scope: this,
  2579. interval: 1000
  2580. });
  2581. }
  2582. },
  2583. // inherited docs
  2584. getEventBodyMarkup: function() {
  2585. if (!this.eventBodyMarkup) {
  2586. this.eventBodyMarkup = ['{Title}',
  2587. '<tpl if="_isReminder">',
  2588. '<i class="ext-cal-ic ext-cal-ic-rem">&nbsp;</i>',
  2589. '</tpl>',
  2590. '<tpl if="_isRecurring">',
  2591. '<i class="ext-cal-ic ext-cal-ic-rcr">&nbsp;</i>',
  2592. '</tpl>',
  2593. '<tpl if="spanLeft">',
  2594. '<i class="ext-cal-spl">&nbsp;</i>',
  2595. '</tpl>',
  2596. '<tpl if="spanRight">',
  2597. '<i class="ext-cal-spr">&nbsp;</i>',
  2598. '</tpl>'
  2599. ].join('');
  2600. }
  2601. return this.eventBodyMarkup;
  2602. },
  2603. // inherited docs
  2604. getEventTemplate: function() {
  2605. if (!this.eventTpl) {
  2606. var tpl,
  2607. body = this.getEventBodyMarkup();
  2608. tpl = !(Ext.isIE || Ext.isOpera) ?
  2609. new Ext.XTemplate(
  2610. '<div id="{_elId}" class="{_selectorCls} {_colorCls} {values.spanCls} ext-cal-evt ext-cal-evr">',
  2611. body,
  2612. '</div>'
  2613. )
  2614. : new Ext.XTemplate(
  2615. '<tpl if="_renderAsAllDay">',
  2616. '<div id="{_elId}" class="{_selectorCls} {values.spanCls} {_colorCls} ext-cal-evt ext-cal-evo">',
  2617. '<div class="ext-cal-evm">',
  2618. '<div class="ext-cal-evi">',
  2619. '</tpl>',
  2620. '<tpl if="!_renderAsAllDay">',
  2621. '<div id="{_elId}" class="{_selectorCls} {_colorCls} ext-cal-evt ext-cal-evr">',
  2622. '</tpl>',
  2623. body,
  2624. '<tpl if="_renderAsAllDay">',
  2625. '</div>',
  2626. '</div>',
  2627. '</tpl>',
  2628. '</div>'
  2629. );
  2630. tpl.compile();
  2631. this.eventTpl = tpl;
  2632. }
  2633. return this.eventTpl;
  2634. },
  2635. // private
  2636. getTemplateEventData: function(evt) {
  2637. var M = Ext.calendar.EventMappings,
  2638. selector = this.getEventSelectorCls(evt[M.EventId.name]),
  2639. title = evt[M.Title.name];
  2640. return Ext.applyIf({
  2641. _selectorCls: selector,
  2642. _colorCls: 'ext-color-' + (evt[M.CalendarId.name] ?
  2643. evt[M.CalendarId.name] : 'default') + (evt._renderAsAllDay ? '-ad': ''),
  2644. _elId: selector + '-' + evt._weekIndex,
  2645. _isRecurring: evt.Recurrence && evt.Recurrence != '',
  2646. _isReminder: evt[M.Reminder.name] && evt[M.Reminder.name] != '',
  2647. Title: (evt[M.IsAllDay.name] ? '': evt[M.StartDate.name].format('g:ia ')) + (!title || title.length == 0 ? '(No title)': title)
  2648. },
  2649. evt);
  2650. },
  2651. // private
  2652. refresh: function() {
  2653. if (this.detailPanel) {
  2654. this.detailPanel.hide();
  2655. }
  2656. Ext.calendar.MonthView.superclass.refresh.call(this);
  2657. if (this.showTime !== false) {
  2658. this.initClock();
  2659. }
  2660. },
  2661. // private
  2662. renderItems: function() {
  2663. Ext.calendar.WeekEventRenderer.render({
  2664. eventGrid: this.allDayOnly ? this.allDayGrid: this.eventGrid,
  2665. viewStart: this.viewStart,
  2666. tpl: this.getEventTemplate(),
  2667. maxEventsPerDay: this.maxEventsPerDay,
  2668. id: this.id,
  2669. templateDataFn: this.getTemplateEventData.createDelegate(this),
  2670. evtMaxCount: this.evtMaxCount,
  2671. weekCount: this.weekCount,
  2672. dayCount: this.dayCount
  2673. });
  2674. this.fireEvent('eventsrendered', this);
  2675. },
  2676. // private
  2677. getDayEl: function(dt) {
  2678. return Ext.get(this.getDayId(dt));
  2679. },
  2680. // private
  2681. getDayId: function(dt) {
  2682. if (Ext.isDate(dt)) {
  2683. dt = dt.format('Ymd');
  2684. }
  2685. return this.id + this.dayElIdDelimiter + dt;
  2686. },
  2687. // private
  2688. getWeekIndex: function(dt) {
  2689. var el = this.getDayEl(dt).up('.ext-cal-wk-ct');
  2690. return parseInt(el.id.split('-wk-')[1], 10);
  2691. },
  2692. // private
  2693. getDaySize: function(contentOnly) {
  2694. var box = this.el.getBox(),
  2695. w = box.width / this.dayCount,
  2696. h = box.height / this.getWeekCount();
  2697. if (contentOnly) {
  2698. var hd = this.el.select('.ext-cal-dtitle').first().parent('tr');
  2699. h = hd ? h - hd.getHeight(true) : h;
  2700. }
  2701. return {
  2702. height: h,
  2703. width: w
  2704. };
  2705. },
  2706. // private
  2707. getEventHeight: function() {
  2708. if (!this.eventHeight) {
  2709. var evt = this.el.select('.ext-cal-evt').first();
  2710. this.eventHeight = evt ? evt.parent('tr').getHeight() : 18;
  2711. }
  2712. return this.eventHeight;
  2713. },
  2714. // private
  2715. getMaxEventsPerDay: function() {
  2716. var dayHeight = this.getDaySize(true).height,
  2717. h = this.getEventHeight(),
  2718. max = Math.max(Math.floor((dayHeight - h) / h), 0);
  2719. return max;
  2720. },
  2721. // private
  2722. getDayAt: function(x, y) {
  2723. var box = this.el.getBox(),
  2724. daySize = this.getDaySize(),
  2725. dayL = Math.floor(((x - box.x) / daySize.width)),
  2726. dayT = Math.floor(((y - box.y) / daySize.height)),
  2727. days = (dayT * 7) + dayL,
  2728. dt = this.viewStart.add(Date.DAY, days);
  2729. return {
  2730. date: dt,
  2731. el: this.getDayEl(dt)
  2732. };
  2733. },
  2734. // inherited docs
  2735. moveNext: function() {
  2736. return this.moveMonths(1);
  2737. },
  2738. // inherited docs
  2739. movePrev: function() {
  2740. return this.moveMonths( - 1);
  2741. },
  2742. // private
  2743. onInitDrag: function() {
  2744. Ext.calendar.MonthView.superclass.onInitDrag.call(this);
  2745. Ext.select(this.daySelector).removeClass(this.dayOverClass);
  2746. if (this.detailPanel) {
  2747. this.detailPanel.hide();
  2748. }
  2749. },
  2750. // private
  2751. onMoreClick: function(dt) {
  2752. if (!this.detailPanel) {
  2753. this.detailPanel = new Ext.Panel({
  2754. id: this.id + '-details-panel',
  2755. title: dt.format('F j'),
  2756. layout: 'fit',
  2757. floating: true,
  2758. renderTo: Ext.getBody(),
  2759. tools: [{
  2760. id: 'close',
  2761. handler: function(e, t, p) {
  2762. p.hide();
  2763. }
  2764. }],
  2765. items: {
  2766. xtype: 'monthdaydetailview',
  2767. id: this.id + '-details-view',
  2768. date: dt,
  2769. view: this,
  2770. store: this.store,
  2771. listeners: {
  2772. 'eventsrendered': this.onDetailViewUpdated.createDelegate(this)
  2773. }
  2774. }
  2775. });
  2776. }
  2777. else {
  2778. this.detailPanel.setTitle(dt.format('F j'));
  2779. }
  2780. this.detailPanel.getComponent(this.id + '-details-view').update(dt);
  2781. },
  2782. // private
  2783. onDetailViewUpdated: function(view, dt, numEvents) {
  2784. var p = this.detailPanel,
  2785. frameH = p.getFrameHeight(),
  2786. evtH = this.getEventHeight(),
  2787. bodyH = frameH + (numEvents * evtH) + 3,
  2788. dayEl = this.getDayEl(dt),
  2789. box = dayEl.getBox();
  2790. p.updateBox(box);
  2791. p.setHeight(bodyH);
  2792. p.setWidth(Math.max(box.width, 220));
  2793. p.show();
  2794. p.getPositionEl().alignTo(dayEl, 't-t?');
  2795. },
  2796. // private
  2797. onHide: function() {
  2798. Ext.calendar.MonthView.superclass.onHide.call(this);
  2799. if (this.detailPanel) {
  2800. this.detailPanel.hide();
  2801. }
  2802. },
  2803. // private
  2804. onClick: function(e, t) {
  2805. if (this.detailPanel) {
  2806. this.detailPanel.hide();
  2807. }
  2808. if (Ext.calendar.MonthView.superclass.onClick.apply(this, arguments)) {
  2809. // The superclass handled the click already so exit
  2810. return;
  2811. }
  2812. if (this.dropZone) {
  2813. this.dropZone.clearShims();
  2814. }
  2815. var el = e.getTarget(this.weekLinkSelector, 3),
  2816. dt,
  2817. parts;
  2818. if (el) {
  2819. dt = el.id.split(this.weekLinkIdDelimiter)[1];
  2820. this.fireEvent('weekclick', this, Date.parseDate(dt, 'Ymd'));
  2821. return;
  2822. }
  2823. el = e.getTarget(this.moreSelector, 3);
  2824. if (el) {
  2825. dt = el.id.split(this.moreElIdDelimiter)[1];
  2826. this.onMoreClick(Date.parseDate(dt, 'Ymd'));
  2827. return;
  2828. }
  2829. el = e.getTarget('td', 3);
  2830. if (el) {
  2831. if (el.id && el.id.indexOf(this.dayElIdDelimiter) > -1) {
  2832. parts = el.id.split(this.dayElIdDelimiter);
  2833. dt = parts[parts.length - 1];
  2834. this.fireEvent('dayclick', this, Date.parseDate(dt, 'Ymd'), false, Ext.get(this.getDayId(dt)));
  2835. return;
  2836. }
  2837. }
  2838. },
  2839. // private
  2840. handleDayMouseEvent: function(e, t, type) {
  2841. var el = e.getTarget(this.weekLinkSelector, 3, true);
  2842. if (el) {
  2843. el[type == 'over' ? 'addClass': 'removeClass'](this.weekLinkOverClass);
  2844. return;
  2845. }
  2846. Ext.calendar.MonthView.superclass.handleDayMouseEvent.apply(this, arguments);
  2847. }
  2848. });
  2849. Ext.reg('monthview', Ext.calendar.MonthView);
  2850. /**
  2851. * @class Ext.calendar.DayHeaderView
  2852. * @extends Ext.calendar.MonthView
  2853. * <p>This is the header area container within the day and week views where all-day events are displayed.
  2854. * Normally you should not need to use this class directly -- instead you should use {@link Ext.calendar.DayView DayView}
  2855. * which aggregates this class and the {@link Ext.calendar.DayBodyView DayBodyView} into the single unified view
  2856. * presented by {@link Ext.calendar.CalendarPanel CalendarPanel}.</p>
  2857. * @constructor
  2858. * @param {Object} config The config object
  2859. */
  2860. Ext.calendar.DayHeaderView = Ext.extend(Ext.calendar.MonthView, {
  2861. // private configs
  2862. weekCount: 1,
  2863. dayCount: 1,
  2864. allDayOnly: true,
  2865. monitorResize: false,
  2866. /**
  2867. * @event dayclick
  2868. * Fires after the user clicks within the day view container and not on an event element
  2869. * @param {Ext.calendar.DayBodyView} this
  2870. * @param {Date} dt The date/time that was clicked on
  2871. * @param {Boolean} allday True if the day clicked on represents an all-day box, else false. Clicks within the
  2872. * DayHeaderView always return true for this param.
  2873. * @param {Ext.Element} el The Element that was clicked on
  2874. */
  2875. // private
  2876. afterRender: function() {
  2877. if (!this.tpl) {
  2878. this.tpl = new Ext.calendar.DayHeaderTemplate({
  2879. id: this.id,
  2880. showTodayText: this.showTodayText,
  2881. todayText: this.todayText,
  2882. showTime: this.showTime
  2883. });
  2884. }
  2885. this.tpl.compile();
  2886. this.addClass('ext-cal-day-header');
  2887. Ext.calendar.DayHeaderView.superclass.afterRender.call(this);
  2888. },
  2889. // private
  2890. forceSize: Ext.emptyFn,
  2891. // private
  2892. refresh: function() {
  2893. Ext.calendar.DayHeaderView.superclass.refresh.call(this);
  2894. this.recalcHeaderBox();
  2895. },
  2896. // private
  2897. recalcHeaderBox: function() {
  2898. var tbl = this.el.child('.ext-cal-evt-tbl'),
  2899. h = tbl.getHeight();
  2900. this.el.setHeight(h + 7);
  2901. if (Ext.isIE && Ext.isStrict) {
  2902. this.el.child('.ext-cal-hd-ad-inner').setHeight(h + 4);
  2903. }
  2904. if (Ext.isOpera) {
  2905. //TODO: figure out why Opera refuses to refresh height when
  2906. //the new height is lower than the previous one
  2907. // var ct = this.el.child('.ext-cal-hd-ct');
  2908. // ct.repaint();
  2909. }
  2910. },
  2911. // private
  2912. moveNext: function(noRefresh) {
  2913. this.moveDays(this.dayCount, noRefresh);
  2914. },
  2915. // private
  2916. movePrev: function(noRefresh) {
  2917. this.moveDays( - this.dayCount, noRefresh);
  2918. },
  2919. // private
  2920. onClick: function(e, t) {
  2921. var el = e.getTarget('td', 3),
  2922. parts,
  2923. dt;
  2924. if (el) {
  2925. if (el.id && el.id.indexOf(this.dayElIdDelimiter) > -1) {
  2926. parts = el.id.split(this.dayElIdDelimiter);
  2927. dt = parts[parts.length - 1];
  2928. this.fireEvent('dayclick', this, Date.parseDate(dt, 'Ymd'), true, Ext.get(this.getDayId(dt)));
  2929. return;
  2930. }
  2931. }
  2932. Ext.calendar.DayHeaderView.superclass.onClick.apply(this, arguments);
  2933. }
  2934. });
  2935. Ext.reg('dayheaderview', Ext.calendar.DayHeaderView);
  2936. /**S
  2937. * @class Ext.calendar.DayBodyView
  2938. * @extends Ext.calendar.CalendarView
  2939. * <p>This is the scrolling container within the day and week views where non-all-day events are displayed.
  2940. * Normally you should not need to use this class directly -- instead you should use {@link Ext.calendar.DayView DayView}
  2941. * which aggregates this class and the {@link Ext.calendar.DayHeaderView DayHeaderView} into the single unified view
  2942. * presented by {@link Ext.calendar.CalendarPanel CalendarPanel}.</p>
  2943. * @constructor
  2944. * @param {Object} config The config object
  2945. */
  2946. Ext.calendar.DayBodyView = Ext.extend(Ext.calendar.CalendarView, {
  2947. //private
  2948. dayColumnElIdDelimiter: '-day-col-',
  2949. //private
  2950. initComponent: function() {
  2951. Ext.calendar.DayBodyView.superclass.initComponent.call(this);
  2952. this.addEvents({
  2953. /**
  2954. * @event eventresize
  2955. * Fires after the user drags the resize handle of an event to resize it
  2956. * @param {Ext.calendar.DayBodyView} this
  2957. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was resized
  2958. * containing the updated start and end dates
  2959. */
  2960. eventresize: true,
  2961. /**
  2962. * @event dayclick
  2963. * Fires after the user clicks within the day view container and not on an event element
  2964. * @param {Ext.calendar.DayBodyView} this
  2965. * @param {Date} dt The date/time that was clicked on
  2966. * @param {Boolean} allday True if the day clicked on represents an all-day box, else false. Clicks within the
  2967. * DayBodyView always return false for this param.
  2968. * @param {Ext.Element} el The Element that was clicked on
  2969. */
  2970. dayclick: true
  2971. });
  2972. },
  2973. //private
  2974. initDD: function() {
  2975. var cfg = {
  2976. createText: this.ddCreateEventText,
  2977. moveText: this.ddMoveEventText,
  2978. resizeText: this.ddResizeEventText
  2979. };
  2980. this.el.ddScrollConfig = {
  2981. // scrolling is buggy in IE/Opera for some reason. A larger vthresh
  2982. // makes it at least functional if not perfect
  2983. vthresh: Ext.isIE || Ext.isOpera ? 100: 40,
  2984. hthresh: -1,
  2985. frequency: 50,
  2986. increment: 100,
  2987. ddGroup: 'DayViewDD'
  2988. };
  2989. this.dragZone = new Ext.calendar.DayViewDragZone(this.el, Ext.apply({
  2990. view: this,
  2991. containerScroll: true
  2992. },
  2993. cfg));
  2994. this.dropZone = new Ext.calendar.DayViewDropZone(this.el, Ext.apply({
  2995. view: this
  2996. },
  2997. cfg));
  2998. },
  2999. //private
  3000. refresh: function() {
  3001. var top = this.el.getScroll().top;
  3002. this.prepareData();
  3003. this.renderTemplate();
  3004. this.renderItems();
  3005. // skip this if the initial render scroll position has not yet been set.
  3006. // necessary since IE/Opera must be deferred, so the first refresh will
  3007. // override the initial position by default and always set it to 0.
  3008. if (this.scrollReady) {
  3009. this.scrollTo(top);
  3010. }
  3011. },
  3012. /**
  3013. * Scrolls the container to the specified vertical position. If the view is large enough that
  3014. * there is no scroll overflow then this method will have no affect.
  3015. * @param {Number} y The new vertical scroll position in pixels
  3016. * @param {Boolean} defer (optional) <p>True to slightly defer the call, false to execute immediately.</p>
  3017. * <p>This method will automatically defer itself for IE and Opera (even if you pass false) otherwise
  3018. * the scroll position will not update in those browsers. You can optionally pass true, however, to
  3019. * force the defer in all browsers, or use your own custom conditions to determine whether this is needed.</p>
  3020. * <p>Note that this method should not generally need to be called directly as scroll position is managed internally.</p>
  3021. */
  3022. scrollTo: function(y, defer) {
  3023. defer = defer || (Ext.isIE || Ext.isOpera);
  3024. if (defer) {
  3025. (function() {
  3026. this.el.scrollTo('top', y);
  3027. this.scrollReady = true;
  3028. }).defer(10, this);
  3029. }
  3030. else {
  3031. this.el.scrollTo('top', y);
  3032. this.scrollReady = true;
  3033. }
  3034. },
  3035. // private
  3036. afterRender: function() {
  3037. if (!this.tpl) {
  3038. this.tpl = new Ext.calendar.DayBodyTemplate({
  3039. id: this.id,
  3040. dayCount: this.dayCount,
  3041. showTodayText: this.showTodayText,
  3042. todayText: this.todayText,
  3043. showTime: this.showTime
  3044. });
  3045. }
  3046. this.tpl.compile();
  3047. this.addClass('ext-cal-body-ct');
  3048. Ext.calendar.DayBodyView.superclass.afterRender.call(this);
  3049. // default scroll position to 7am:
  3050. this.scrollTo(7 * 42);
  3051. },
  3052. // private
  3053. forceSize: Ext.emptyFn,
  3054. // private
  3055. onEventResize: function(rec, data) {
  3056. var D = Ext.calendar.Date,
  3057. start = Ext.calendar.EventMappings.StartDate.name,
  3058. end = Ext.calendar.EventMappings.EndDate.name;
  3059. if (D.compare(rec.data[start], data.StartDate) === 0 &&
  3060. D.compare(rec.data[end], data.EndDate) === 0) {
  3061. // no changes
  3062. return;
  3063. }
  3064. rec.set(start, data.StartDate);
  3065. rec.set(end, data.EndDate);
  3066. this.fireEvent('eventresize', this, rec);
  3067. },
  3068. // inherited docs
  3069. getEventBodyMarkup: function() {
  3070. if (!this.eventBodyMarkup) {
  3071. this.eventBodyMarkup = ['{Title}',
  3072. '<tpl if="_isReminder">',
  3073. '<i class="ext-cal-ic ext-cal-ic-rem">&nbsp;</i>',
  3074. '</tpl>',
  3075. '<tpl if="_isRecurring">',
  3076. '<i class="ext-cal-ic ext-cal-ic-rcr">&nbsp;</i>',
  3077. '</tpl>'
  3078. // '<tpl if="spanLeft">',
  3079. // '<i class="ext-cal-spl">&nbsp;</i>',
  3080. // '</tpl>',
  3081. // '<tpl if="spanRight">',
  3082. // '<i class="ext-cal-spr">&nbsp;</i>',
  3083. // '</tpl>'
  3084. ].join('');
  3085. }
  3086. return this.eventBodyMarkup;
  3087. },
  3088. // inherited docs
  3089. getEventTemplate: function() {
  3090. if (!this.eventTpl) {
  3091. this.eventTpl = !(Ext.isIE || Ext.isOpera) ?
  3092. new Ext.XTemplate(
  3093. '<div id="{_elId}" class="{_selectorCls} {_colorCls} ext-cal-evt ext-cal-evr" style="left: {_left}%; width: {_width}%; top: {_top}px; height: {_height}px;">',
  3094. '<div class="ext-evt-bd">', this.getEventBodyMarkup(), '</div>',
  3095. '<div class="ext-evt-rsz"><div class="ext-evt-rsz-h">&nbsp;</div></div>',
  3096. '</div>'
  3097. )
  3098. : new Ext.XTemplate(
  3099. '<div id="{_elId}" class="ext-cal-evt {_selectorCls} {_colorCls}-x" style="left: {_left}%; width: {_width}%; top: {_top}px;">',
  3100. '<div class="ext-cal-evb">&nbsp;</div>',
  3101. '<dl style="height: {_height}px;" class="ext-cal-evdm">',
  3102. '<dd class="ext-evt-bd">',
  3103. this.getEventBodyMarkup(),
  3104. '</dd>',
  3105. '<div class="ext-evt-rsz"><div class="ext-evt-rsz-h">&nbsp;</div></div>',
  3106. '</dl>',
  3107. '<div class="ext-cal-evb">&nbsp;</div>',
  3108. '</div>'
  3109. );
  3110. this.eventTpl.compile();
  3111. }
  3112. return this.eventTpl;
  3113. },
  3114. /**
  3115. * <p>Returns the XTemplate that is bound to the calendar's event store (it expects records of type
  3116. * {@link Ext.calendar.EventRecord}) to populate the calendar views with <strong>all-day</strong> events.
  3117. * Internally this method by default generates different markup for browsers that support CSS border radius
  3118. * and those that don't. This method can be overridden as needed to customize the markup generated.</p>
  3119. * <p>Note that this method calls {@link #getEventBodyMarkup} to retrieve the body markup for events separately
  3120. * from the surrounding container markup. This provdes the flexibility to customize what's in the body without
  3121. * having to override the entire XTemplate. If you do override this method, you should make sure that your
  3122. * overridden version also does the same.</p>
  3123. * @return {Ext.XTemplate} The event XTemplate
  3124. */
  3125. getEventAllDayTemplate: function() {
  3126. if (!this.eventAllDayTpl) {
  3127. var tpl,
  3128. body = this.getEventBodyMarkup();
  3129. tpl = !(Ext.isIE || Ext.isOpera) ?
  3130. new Ext.XTemplate(
  3131. '<div id="{_elId}" class="{_selectorCls} {_colorCls} {values.spanCls} ext-cal-evt ext-cal-evr" style="left: {_left}%; width: {_width}%; top: {_top}px; height: {_height}px;">',
  3132. body,
  3133. '</div>'
  3134. )
  3135. : new Ext.XTemplate(
  3136. '<div id="{_elId}" class="ext-cal-evt" style="left: {_left}%; width: {_width}%; top: {_top}px; height: {_height}px;">',
  3137. '<div class="{_selectorCls} {values.spanCls} {_colorCls} ext-cal-evo">',
  3138. '<div class="ext-cal-evm">',
  3139. '<div class="ext-cal-evi">',
  3140. body,
  3141. '</div>',
  3142. '</div>',
  3143. '</div></div>'
  3144. );
  3145. tpl.compile();
  3146. this.eventAllDayTpl = tpl;
  3147. }
  3148. return this.eventAllDayTpl;
  3149. },
  3150. // private
  3151. getTemplateEventData: function(evt) {
  3152. var selector = this.getEventSelectorCls(evt[Ext.calendar.EventMappings.EventId.name]),
  3153. data = {},
  3154. M = Ext.calendar.EventMappings;
  3155. this.getTemplateEventBox(evt);
  3156. data._selectorCls = selector;
  3157. data._colorCls = 'ext-color-' + evt[M.CalendarId.name] + (evt._renderAsAllDay ? '-ad': '');
  3158. data._elId = selector + (evt._weekIndex ? '-' + evt._weekIndex: '');
  3159. data._isRecurring = evt.Recurrence && evt.Recurrence != '';
  3160. data._isReminder = evt[M.Reminder.name] && evt[M.Reminder.name] != '';
  3161. var title = evt[M.Title.name];
  3162. data.Title = (evt[M.IsAllDay.name] ? '': evt[M.StartDate.name].format('g:ia ')) + (!title || title.length == 0 ? '(No title)': title);
  3163. return Ext.applyIf(data, evt);
  3164. },
  3165. // private
  3166. getTemplateEventBox: function(evt) {
  3167. var heightFactor = 0.7,
  3168. start = evt[Ext.calendar.EventMappings.StartDate.name],
  3169. end = evt[Ext.calendar.EventMappings.EndDate.name],
  3170. startMins = start.getHours() * 60 + start.getMinutes(),
  3171. endMins = end.getHours() * 60 + end.getMinutes(),
  3172. diffMins = endMins - startMins;
  3173. evt._left = 0;
  3174. evt._width = 100;
  3175. evt._top = Math.round(startMins * heightFactor) + 1;
  3176. evt._height = Math.max((diffMins * heightFactor) - 2, 15);
  3177. },
  3178. // private
  3179. renderItems: function() {
  3180. var day = 0,
  3181. evts = [],
  3182. ev,
  3183. d,
  3184. ct,
  3185. item,
  3186. i,
  3187. j,
  3188. l,
  3189. overlapCols,
  3190. prevCol,
  3191. colWidth,
  3192. evtWidth,
  3193. markup,
  3194. target;
  3195. for (; day < this.dayCount; day++) {
  3196. ev = emptyCells = skipped = 0;
  3197. d = this.eventGrid[0][day];
  3198. ct = d ? d.length: 0;
  3199. for (; ev < ct; ev++) {
  3200. evt = d[ev];
  3201. if (!evt) {
  3202. continue;
  3203. }
  3204. item = evt.data || evt.event.data;
  3205. if (item._renderAsAllDay) {
  3206. continue;
  3207. }
  3208. Ext.apply(item, {
  3209. cls: 'ext-cal-ev',
  3210. _positioned: true
  3211. });
  3212. evts.push({
  3213. data: this.getTemplateEventData(item),
  3214. date: this.viewStart.add(Date.DAY, day)
  3215. });
  3216. }
  3217. }
  3218. // overlapping event pre-processing loop
  3219. i = j = overlapCols = prevCol = 0;
  3220. l = evts.length;
  3221. for (; i < l; i++) {
  3222. evt = evts[i].data;
  3223. evt2 = null;
  3224. prevCol = overlapCols;
  3225. for (j = 0; j < l; j++) {
  3226. if (i == j) {
  3227. continue;
  3228. }
  3229. evt2 = evts[j].data;
  3230. if (this.isOverlapping(evt, evt2)) {
  3231. evt._overlap = evt._overlap == undefined ? 1: evt._overlap + 1;
  3232. if (i < j) {
  3233. if (evt._overcol === undefined) {
  3234. evt._overcol = 0;
  3235. }
  3236. evt2._overcol = evt._overcol + 1;
  3237. overlapCols = Math.max(overlapCols, evt2._overcol);
  3238. }
  3239. }
  3240. }
  3241. }
  3242. // rendering loop
  3243. for (i = 0; i < l; i++) {
  3244. evt = evts[i].data;
  3245. if (evt._overlap !== undefined) {
  3246. colWidth = 100 / (overlapCols + 1);
  3247. evtWidth = 100 - (colWidth * evt._overlap);
  3248. evt._width = colWidth;
  3249. evt._left = colWidth * evt._overcol;
  3250. }
  3251. markup = this.getEventTemplate().apply(evt);
  3252. target = this.id + '-day-col-' + evts[i].date.format('Ymd');
  3253. Ext.DomHelper.append(target, markup);
  3254. }
  3255. this.fireEvent('eventsrendered', this);
  3256. },
  3257. // private
  3258. getDayEl: function(dt) {
  3259. return Ext.get(this.getDayId(dt));
  3260. },
  3261. // private
  3262. getDayId: function(dt) {
  3263. if (Ext.isDate(dt)) {
  3264. dt = dt.format('Ymd');
  3265. }
  3266. return this.id + this.dayColumnElIdDelimiter + dt;
  3267. },
  3268. // private
  3269. getDaySize: function() {
  3270. var box = this.el.child('.ext-cal-day-col-inner').getBox();
  3271. return {
  3272. height: box.height,
  3273. width: box.width
  3274. };
  3275. },
  3276. // private
  3277. getDayAt: function(x, y) {
  3278. var sel = '.ext-cal-body-ct',
  3279. xoffset = this.el.child('.ext-cal-day-times').getWidth(),
  3280. viewBox = this.el.getBox(),
  3281. daySize = this.getDaySize(false),
  3282. relX = x - viewBox.x - xoffset,
  3283. dayIndex = Math.floor(relX / daySize.width),
  3284. // clicked col index
  3285. scroll = this.el.getScroll(),
  3286. row = this.el.child('.ext-cal-bg-row'),
  3287. // first avail row, just to calc size
  3288. rowH = row.getHeight() / 2,
  3289. // 30 minute increment since a row is 60 minutes
  3290. relY = y - viewBox.y - rowH + scroll.top,
  3291. rowIndex = Math.max(0, Math.ceil(relY / rowH)),
  3292. mins = rowIndex * 30,
  3293. dt = this.viewStart.add(Date.DAY, dayIndex).add(Date.MINUTE, mins),
  3294. el = this.getDayEl(dt),
  3295. timeX = x;
  3296. if (el) {
  3297. timeX = el.getLeft();
  3298. }
  3299. return {
  3300. date: dt,
  3301. el: el,
  3302. // this is the box for the specific time block in the day that was clicked on:
  3303. timeBox: {
  3304. x: timeX,
  3305. y: (rowIndex * 21) + viewBox.y - scroll.top,
  3306. width: daySize.width,
  3307. height: rowH
  3308. }
  3309. };
  3310. },
  3311. // private
  3312. onClick: function(e, t) {
  3313. if (this.dragPending || Ext.calendar.DayBodyView.superclass.onClick.apply(this, arguments)) {
  3314. // The superclass handled the click already so exit
  3315. return;
  3316. }
  3317. if (e.getTarget('.ext-cal-day-times', 3) !== null) {
  3318. // ignore clicks on the times-of-day gutter
  3319. return;
  3320. }
  3321. var el = e.getTarget('td', 3);
  3322. if (el) {
  3323. if (el.id && el.id.indexOf(this.dayElIdDelimiter) > -1) {
  3324. var dt = this.getDateFromId(el.id, this.dayElIdDelimiter);
  3325. this.fireEvent('dayclick', this, Date.parseDate(dt, 'Ymd'), true, Ext.get(this.getDayId(dt, true)));
  3326. return;
  3327. }
  3328. }
  3329. var day = this.getDayAt(e.xy[0], e.xy[1]);
  3330. if (day && day.date) {
  3331. this.fireEvent('dayclick', this, day.date, false, null);
  3332. }
  3333. }
  3334. });
  3335. Ext.reg('daybodyview', Ext.calendar.DayBodyView);
  3336. /**
  3337. * @class Ext.calendar.DayView
  3338. * @extends Ext.Container
  3339. * <p>Unlike other calendar views, is not actually a subclass of {@link Ext.calendar.CalendarView CalendarView}.
  3340. * Instead it is a {@link Ext.Container Container} subclass that internally creates and manages the layouts of
  3341. * a {@link Ext.calendar.DayHeaderView DayHeaderView} and a {@link Ext.calendar.DayBodyView DayBodyView}. As such
  3342. * DayView accepts any config values that are valid for DayHeaderView and DayBodyView and passes those through
  3343. * to the contained views. It also supports the interface required of any calendar view and in turn calls methods
  3344. * on the contained views as necessary.</p>
  3345. * @constructor
  3346. * @param {Object} config The config object
  3347. */
  3348. Ext.calendar.DayView = Ext.extend(Ext.Container, {
  3349. /**
  3350. * @cfg {Boolean} showTime
  3351. * True to display the current time in today's box in the calendar, false to not display it (defautls to true)
  3352. */
  3353. showTime: true,
  3354. /**
  3355. * @cfg {Boolean} showTodayText
  3356. * True to display the {@link #todayText} string in today's box in the calendar, false to not display it (defautls to true)
  3357. */
  3358. showTodayText: true,
  3359. /**
  3360. * @cfg {String} todayText
  3361. * The text to display in the current day's box in the calendar when {@link #showTodayText} is true (defaults to 'Today')
  3362. */
  3363. todayText: 'Today',
  3364. /**
  3365. * @cfg {String} ddCreateEventText
  3366. * The text to display inside the drag proxy while dragging over the calendar to create a new event (defaults to
  3367. * 'Create event for {0}' where {0} is a date range supplied by the view)
  3368. */
  3369. ddCreateEventText: 'Create event for {0}',
  3370. /**
  3371. * @cfg {String} ddMoveEventText
  3372. * The text to display inside the drag proxy while dragging an event to reposition it (defaults to
  3373. * 'Move event to {0}' where {0} is the updated event start date/time supplied by the view)
  3374. */
  3375. ddMoveEventText: 'Move event to {0}',
  3376. /**
  3377. * @cfg {Number} dayCount
  3378. * The number of days to display in the view (defaults to 1)
  3379. */
  3380. dayCount: 1,
  3381. // private
  3382. initComponent : function(){
  3383. // rendering more than 7 days per view is not supported
  3384. this.dayCount = this.dayCount > 7 ? 7 : this.dayCount;
  3385. var cfg = Ext.apply({}, this.initialConfig);
  3386. cfg.showTime = this.showTime;
  3387. cfg.showTodatText = this.showTodayText;
  3388. cfg.todayText = this.todayText;
  3389. cfg.dayCount = this.dayCount;
  3390. cfg.wekkCount = 1;
  3391. var header = Ext.applyIf({
  3392. xtype: 'dayheaderview',
  3393. id: this.id+'-hd'
  3394. }, cfg);
  3395. var body = Ext.applyIf({
  3396. xtype: 'daybodyview',
  3397. id: this.id+'-bd'
  3398. }, cfg);
  3399. this.items = [header, body];
  3400. this.addClass('ext-cal-dayview ext-cal-ct');
  3401. Ext.calendar.DayView.superclass.initComponent.call(this);
  3402. },
  3403. // private
  3404. afterRender : function(){
  3405. Ext.calendar.DayView.superclass.afterRender.call(this);
  3406. this.header = Ext.getCmp(this.id+'-hd');
  3407. this.body = Ext.getCmp(this.id+'-bd');
  3408. this.body.on('eventsrendered', this.forceSize, this);
  3409. },
  3410. // private
  3411. refresh : function(){
  3412. this.header.refresh();
  3413. this.body.refresh();
  3414. },
  3415. // private
  3416. forceSize: function(){
  3417. // The defer call is mainly for good ol' IE, but it doesn't hurt in
  3418. // general to make sure that the window resize is good and done first
  3419. // so that we can properly calculate sizes.
  3420. (function(){
  3421. var ct = this.el.up('.x-panel-body'),
  3422. hd = this.el.child('.ext-cal-day-header'),
  3423. h = ct.getHeight() - hd.getHeight();
  3424. this.el.child('.ext-cal-body-ct').setHeight(h);
  3425. }).defer(10, this);
  3426. },
  3427. // private
  3428. onResize : function(){
  3429. this.forceSize();
  3430. },
  3431. // private
  3432. getViewBounds : function(){
  3433. return this.header.getViewBounds();
  3434. },
  3435. /**
  3436. * Returns the start date of the view, as set by {@link #setStartDate}. Note that this may not
  3437. * be the first date displayed in the rendered calendar -- to get the start and end dates displayed
  3438. * to the user use {@link #getViewBounds}.
  3439. * @return {Date} The start date
  3440. */
  3441. getStartDate : function(){
  3442. return this.header.getStartDate();
  3443. },
  3444. /**
  3445. * Sets the start date used to calculate the view boundaries to display. The displayed view will be the
  3446. * earliest and latest dates that match the view requirements and contain the date passed to this function.
  3447. * @param {Date} dt The date used to calculate the new view boundaries
  3448. */
  3449. setStartDate: function(dt){
  3450. this.header.setStartDate(dt, true);
  3451. this.body.setStartDate(dt, true);
  3452. },
  3453. // private
  3454. renderItems: function(){
  3455. this.header.renderItems();
  3456. this.body.renderItems();
  3457. },
  3458. /**
  3459. * Returns true if the view is currently displaying today's date, else false.
  3460. * @return {Boolean} True or false
  3461. */
  3462. isToday : function(){
  3463. return this.header.isToday();
  3464. },
  3465. /**
  3466. * Updates the view to contain the passed date
  3467. * @param {Date} dt The date to display
  3468. */
  3469. moveTo : function(dt, noRefresh){
  3470. this.header.moveTo(dt, noRefresh);
  3471. this.body.moveTo(dt, noRefresh);
  3472. },
  3473. /**
  3474. * Updates the view to the next consecutive date(s)
  3475. */
  3476. moveNext : function(noRefresh){
  3477. this.header.moveNext(noRefresh);
  3478. this.body.moveNext(noRefresh);
  3479. },
  3480. /**
  3481. * Updates the view to the previous consecutive date(s)
  3482. */
  3483. movePrev : function(noRefresh){
  3484. this.header.movePrev(noRefresh);
  3485. this.body.movePrev(noRefresh);
  3486. },
  3487. /**
  3488. * Shifts the view by the passed number of days relative to the currently set date
  3489. * @param {Number} value The number of days (positive or negative) by which to shift the view
  3490. */
  3491. moveDays : function(value, noRefresh){
  3492. this.header.moveDays(value, noRefresh);
  3493. this.body.moveDays(value, noRefresh);
  3494. },
  3495. /**
  3496. * Updates the view to show today
  3497. */
  3498. moveToday : function(noRefresh){
  3499. this.header.moveToday(noRefresh);
  3500. this.body.moveToday(noRefresh);
  3501. }
  3502. });
  3503. Ext.reg('dayview', Ext.calendar.DayView);
  3504. /**
  3505. * @class Ext.calendar.WeekView
  3506. * @extends Ext.calendar.DayView
  3507. * <p>Displays a calendar view by week. This class does not usually need ot be used directly as you can
  3508. * use a {@link Ext.calendar.CalendarPanel CalendarPanel} to manage multiple calendar views at once including
  3509. * the week view.</p>
  3510. * @constructor
  3511. * @param {Object} config The config object
  3512. */
  3513. Ext.calendar.WeekView = Ext.extend(Ext.calendar.DayView, {
  3514. /**
  3515. * @cfg {Number} dayCount
  3516. * The number of days to display in the view (defaults to 7)
  3517. */
  3518. dayCount: 7
  3519. });
  3520. Ext.reg('weekview', Ext.calendar.WeekView);/**
  3521. * @class Ext.calendar.DateRangeField
  3522. * @extends Ext.form.Field
  3523. * <p>A combination field that includes start and end dates and times, as well as an optional all-day checkbox.</p>
  3524. * @constructor
  3525. * @param {Object} config The config object
  3526. */
  3527. Ext.calendar.DateRangeField = Ext.extend(Ext.form.Field, {
  3528. /**
  3529. * @cfg {String} toText
  3530. * The text to display in between the date/time fields (defaults to 'to')
  3531. */
  3532. toText: 'to',
  3533. /**
  3534. * @cfg {String} toText
  3535. * The text to display as the label for the all day checkbox (defaults to 'All day')
  3536. */
  3537. allDayText: 'All day',
  3538. // private
  3539. onRender: function(ct, position) {
  3540. if (!this.el) {
  3541. this.startDate = new Ext.form.DateField({
  3542. id: this.id + '-start-date',
  3543. format: 'n/j/Y',
  3544. width: 100,
  3545. listeners: {
  3546. 'change': {
  3547. fn: function() {
  3548. this.checkDates('date', 'start');
  3549. },
  3550. scope: this
  3551. }
  3552. }
  3553. });
  3554. this.startTime = new Ext.form.TimeField({
  3555. id: this.id + '-start-time',
  3556. hidden: this.showTimes === false,
  3557. labelWidth: 0,
  3558. hideLabel: true,
  3559. width: 90,
  3560. listeners: {
  3561. 'select': {
  3562. fn: function() {
  3563. this.checkDates('time', 'start');
  3564. },
  3565. scope: this
  3566. }
  3567. }
  3568. });
  3569. this.endTime = new Ext.form.TimeField({
  3570. id: this.id + '-end-time',
  3571. hidden: this.showTimes === false,
  3572. labelWidth: 0,
  3573. hideLabel: true,
  3574. width: 90,
  3575. listeners: {
  3576. 'select': {
  3577. fn: function() {
  3578. this.checkDates('time', 'end');
  3579. },
  3580. scope: this
  3581. }
  3582. }
  3583. });
  3584. this.endDate = new Ext.form.DateField({
  3585. id: this.id + '-end-date',
  3586. format: 'n/j/Y',
  3587. hideLabel: true,
  3588. width: 100,
  3589. listeners: {
  3590. 'change': {
  3591. fn: function() {
  3592. this.checkDates('date', 'end');
  3593. },
  3594. scope: this
  3595. }
  3596. }
  3597. });
  3598. this.allDay = new Ext.form.Checkbox({
  3599. id: this.id + '-allday',
  3600. hidden: this.showTimes === false || this.showAllDay === false,
  3601. boxLabel: this.allDayText,
  3602. handler: function(chk, checked) {
  3603. this.startTime.setVisible(!checked);
  3604. this.endTime.setVisible(!checked);
  3605. },
  3606. scope: this
  3607. });
  3608. this.toLabel = new Ext.form.Label({
  3609. xtype: 'label',
  3610. id: this.id + '-to-label',
  3611. text: this.toText
  3612. });
  3613. this.fieldCt = new Ext.Container({
  3614. autoEl: {
  3615. id: this.id
  3616. },
  3617. //make sure the container el has the field's id
  3618. cls: 'ext-dt-range',
  3619. renderTo: ct,
  3620. layout: 'table',
  3621. layoutConfig: {
  3622. columns: 6
  3623. },
  3624. defaults: {
  3625. hideParent: true
  3626. },
  3627. items: [
  3628. this.startDate,
  3629. this.startTime,
  3630. this.toLabel,
  3631. this.endTime,
  3632. this.endDate,
  3633. this.allDay
  3634. ]
  3635. });
  3636. this.fieldCt.ownerCt = this;
  3637. this.el = this.fieldCt.getEl();
  3638. this.items = new Ext.util.MixedCollection();
  3639. this.items.addAll([this.startDate, this.endDate, this.toLabel, this.startTime, this.endTime, this.allDay]);
  3640. }
  3641. Ext.calendar.DateRangeField.superclass.onRender.call(this, ct, position);
  3642. },
  3643. // private
  3644. checkDates: function(type, startend) {
  3645. var startField = Ext.getCmp(this.id + '-start-' + type),
  3646. endField = Ext.getCmp(this.id + '-end-' + type),
  3647. startValue = this.getDT('start'),
  3648. endValue = this.getDT('end');
  3649. if (startValue > endValue) {
  3650. if (startend == 'start') {
  3651. endField.setValue(startValue);
  3652. } else {
  3653. startField.setValue(endValue);
  3654. this.checkDates(type, 'start');
  3655. }
  3656. }
  3657. if (type == 'date') {
  3658. this.checkDates('time', startend);
  3659. }
  3660. },
  3661. /**
  3662. * Returns an array containing the following values in order:<div class="mdetail-params"><ul>
  3663. * <li><b><code>DateTime</code></b> : <div class="sub-desc">The start date/time</div></li>
  3664. * <li><b><code>DateTime</code></b> : <div class="sub-desc">The end date/time</div></li>
  3665. * <li><b><code>Boolean</code></b> : <div class="sub-desc">True if the dates are all-day, false
  3666. * if the time values should be used</div></li><ul></div>
  3667. * @return {Array} The array of return values
  3668. */
  3669. getValue: function() {
  3670. return [
  3671. this.getDT('start'),
  3672. this.getDT('end'),
  3673. this.allDay.getValue()
  3674. ];
  3675. },
  3676. // private getValue helper
  3677. getDT: function(startend) {
  3678. var time = this[startend + 'Time'].getValue(),
  3679. dt = this[startend + 'Date'].getValue();
  3680. if (Ext.isDate(dt)) {
  3681. dt = dt.format(this[startend + 'Date'].format);
  3682. }
  3683. else {
  3684. return null;
  3685. };
  3686. if (time != '' && this[startend + 'Time'].isVisible()) {
  3687. return Date.parseDate(dt + ' ' + time, this[startend + 'Date'].format + ' ' + this[startend + 'Time'].format);
  3688. }
  3689. return Date.parseDate(dt, this[startend + 'Date'].format);
  3690. },
  3691. /**
  3692. * Sets the values to use in the date range.
  3693. * @param {Array/Date/Object} v The value(s) to set into the field. Valid types are as follows:<div class="mdetail-params"><ul>
  3694. * <li><b><code>Array</code></b> : <div class="sub-desc">An array containing, in order, a start date, end date and all-day flag.
  3695. * This array should exactly match the return type as specified by {@link #getValue}.</div></li>
  3696. * <li><b><code>DateTime</code></b> : <div class="sub-desc">A single Date object, which will be used for both the start and
  3697. * end dates in the range. The all-day flag will be defaulted to false.</div></li>
  3698. * <li><b><code>Object</code></b> : <div class="sub-desc">An object containing properties for StartDate, EndDate and IsAllDay
  3699. * as defined in {@link Ext.calendar.EventMappings}.</div></li><ul></div>
  3700. */
  3701. setValue: function(v) {
  3702. if (Ext.isArray(v)) {
  3703. this.setDT(v[0], 'start');
  3704. this.setDT(v[1], 'end');
  3705. this.allDay.setValue( !! v[2]);
  3706. }
  3707. else if (Ext.isDate(v)) {
  3708. this.setDT(v, 'start');
  3709. this.setDT(v, 'end');
  3710. this.allDay.setValue(false);
  3711. }
  3712. else if (v[Ext.calendar.EventMappings.StartDate.name]) {
  3713. //object
  3714. this.setDT(v[Ext.calendar.EventMappings.StartDate.name], 'start');
  3715. if (!this.setDT(v[Ext.calendar.EventMappings.EndDate.name], 'end')) {
  3716. this.setDT(v[Ext.calendar.EventMappings.StartDate.name], 'end');
  3717. }
  3718. this.allDay.setValue( !! v[Ext.calendar.EventMappings.IsAllDay.name]);
  3719. }
  3720. },
  3721. // private setValue helper
  3722. setDT: function(dt, startend) {
  3723. if (dt && Ext.isDate(dt)) {
  3724. this[startend + 'Date'].setValue(dt);
  3725. this[startend + 'Time'].setValue(dt.format(this[startend + 'Time'].format));
  3726. return true;
  3727. }
  3728. },
  3729. // inherited docs
  3730. isDirty: function() {
  3731. var dirty = false;
  3732. if (this.rendered && !this.disabled) {
  3733. this.items.each(function(item) {
  3734. if (item.isDirty()) {
  3735. dirty = true;
  3736. return false;
  3737. }
  3738. });
  3739. }
  3740. return dirty;
  3741. },
  3742. // private
  3743. onDisable: function() {
  3744. this.delegateFn('disable');
  3745. },
  3746. // private
  3747. onEnable: function() {
  3748. this.delegateFn('enable');
  3749. },
  3750. // inherited docs
  3751. reset: function() {
  3752. this.delegateFn('reset');
  3753. },
  3754. // private
  3755. delegateFn: function(fn) {
  3756. this.items.each(function(item) {
  3757. if (item[fn]) {
  3758. item[fn]();
  3759. }
  3760. });
  3761. },
  3762. // private
  3763. beforeDestroy: function() {
  3764. Ext.destroy(this.fieldCt);
  3765. Ext.calendar.DateRangeField.superclass.beforeDestroy.call(this);
  3766. },
  3767. /**
  3768. * @method getRawValue
  3769. * @hide
  3770. */
  3771. getRawValue: Ext.emptyFn,
  3772. /**
  3773. * @method setRawValue
  3774. * @hide
  3775. */
  3776. setRawValue: Ext.emptyFn
  3777. });
  3778. Ext.reg('daterangefield', Ext.calendar.DateRangeField);
  3779. /**
  3780. * @class Ext.calendar.ReminderField
  3781. * @extends Ext.form.ComboBox
  3782. * <p>A custom combo used for choosing a reminder setting for an event.</p>
  3783. * <p>This is pretty much a standard combo that is simply pre-configured for the options needed by the
  3784. * calendar components. The default configs are as follows:<pre><code>
  3785. width: 200,
  3786. fieldLabel: 'Reminder',
  3787. mode: 'local',
  3788. triggerAction: 'all',
  3789. forceSelection: true,
  3790. displayField: 'desc',
  3791. valueField: 'value'
  3792. </code></pre>
  3793. * @constructor
  3794. * @param {Object} config The config object
  3795. */
  3796. Ext.calendar.ReminderField = Ext.extend(Ext.form.ComboBox, {
  3797. width: 200,
  3798. fieldLabel: 'Reminder',
  3799. mode: 'local',
  3800. triggerAction: 'all',
  3801. forceSelection: true,
  3802. displayField: 'desc',
  3803. valueField: 'value',
  3804. // private
  3805. initComponent: function() {
  3806. Ext.calendar.ReminderField.superclass.initComponent.call(this);
  3807. this.store = this.store || new Ext.data.ArrayStore({
  3808. fields: ['value', 'desc'],
  3809. idIndex: 0,
  3810. data: [
  3811. ['', 'None'],
  3812. ['0', 'At start time'],
  3813. ['5', '5 minutes before start'],
  3814. ['15', '15 minutes before start'],
  3815. ['30', '30 minutes before start'],
  3816. ['60', '1 hour before start'],
  3817. ['90', '1.5 hours before start'],
  3818. ['120', '2 hours before start'],
  3819. ['180', '3 hours before start'],
  3820. ['360', '6 hours before start'],
  3821. ['720', '12 hours before start'],
  3822. ['1440', '1 day before start'],
  3823. ['2880', '2 days before start'],
  3824. ['4320', '3 days before start'],
  3825. ['5760', '4 days before start'],
  3826. ['7200', '5 days before start'],
  3827. ['10080', '1 week before start'],
  3828. ['20160', '2 weeks before start']
  3829. ]
  3830. });
  3831. },
  3832. // inherited docs
  3833. initValue: function() {
  3834. if (this.value !== undefined) {
  3835. this.setValue(this.value);
  3836. }
  3837. else {
  3838. this.setValue('');
  3839. }
  3840. this.originalValue = this.getValue();
  3841. }
  3842. });
  3843. Ext.reg('reminderfield', Ext.calendar.ReminderField);
  3844. /**
  3845. * @class Ext.calendar.EventEditForm
  3846. * @extends Ext.form.FormPanel
  3847. * <p>A custom form used for detailed editing of events.</p>
  3848. * <p>This is pretty much a standard form that is simply pre-configured for the options needed by the
  3849. * calendar components. It is also configured to automatically bind records of type {@link Ext.calendar.EventRecord}
  3850. * to and from the form.</p>
  3851. * <p>This form also provides custom events specific to the calendar so that other calendar components can be easily
  3852. * notified when an event has been edited via this component.</p>
  3853. * <p>The default configs are as follows:</p><pre><code>
  3854. labelWidth: 65,
  3855. title: 'Event Form',
  3856. titleTextAdd: 'Add Event',
  3857. titleTextEdit: 'Edit Event',
  3858. bodyStyle: 'background:transparent;padding:20px 20px 10px;',
  3859. border: false,
  3860. buttonAlign: 'center',
  3861. autoHeight: true,
  3862. cls: 'ext-evt-edit-form',
  3863. </code></pre>
  3864. * @constructor
  3865. * @param {Object} config The config object
  3866. */
  3867. Ext.calendar.EventEditForm = Ext.extend(Ext.form.FormPanel, {
  3868. labelWidth: 65,
  3869. title: 'Event Form',
  3870. titleTextAdd: 'Add Event',
  3871. titleTextEdit: 'Edit Event',
  3872. bodyStyle: 'background:transparent;padding:20px 20px 10px;',
  3873. border: false,
  3874. buttonAlign: 'center',
  3875. autoHeight: true,
  3876. // to allow for the notes field to autogrow
  3877. cls: 'ext-evt-edit-form',
  3878. // private properties:
  3879. newId: 10000,
  3880. layout: 'column',
  3881. // private
  3882. initComponent: function() {
  3883. this.addEvents({
  3884. /**
  3885. * @event eventadd
  3886. * Fires after a new event is added
  3887. * @param {Ext.calendar.EventEditForm} this
  3888. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was added
  3889. */
  3890. eventadd: true,
  3891. /**
  3892. * @event eventupdate
  3893. * Fires after an existing event is updated
  3894. * @param {Ext.calendar.EventEditForm} this
  3895. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was updated
  3896. */
  3897. eventupdate: true,
  3898. /**
  3899. * @event eventdelete
  3900. * Fires after an event is deleted
  3901. * @param {Ext.calendar.EventEditForm} this
  3902. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was deleted
  3903. */
  3904. eventdelete: true,
  3905. /**
  3906. * @event eventcancel
  3907. * Fires after an event add/edit operation is canceled by the user and no store update took place
  3908. * @param {Ext.calendar.EventEditForm} this
  3909. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was canceled
  3910. */
  3911. eventcancel: true
  3912. });
  3913. this.titleField = new Ext.form.TextField({
  3914. fieldLabel: 'Title',
  3915. name: Ext.calendar.EventMappings.Title.name,
  3916. anchor: '90%'
  3917. });
  3918. this.dateRangeField = new Ext.calendar.DateRangeField({
  3919. fieldLabel: 'When',
  3920. anchor: '90%'
  3921. });
  3922. this.reminderField = new Ext.calendar.ReminderField({
  3923. name: 'Reminder'
  3924. });
  3925. this.notesField = new Ext.form.TextArea({
  3926. fieldLabel: 'Notes',
  3927. name: Ext.calendar.EventMappings.Notes.name,
  3928. grow: true,
  3929. growMax: 150,
  3930. anchor: '100%'
  3931. });
  3932. this.locationField = new Ext.form.TextField({
  3933. fieldLabel: 'Location',
  3934. name: Ext.calendar.EventMappings.Location.name,
  3935. anchor: '100%'
  3936. });
  3937. this.urlField = new Ext.form.TextField({
  3938. fieldLabel: 'Web Link',
  3939. name: Ext.calendar.EventMappings.Url.name,
  3940. anchor: '100%'
  3941. });
  3942. var leftFields = [this.titleField, this.dateRangeField, this.reminderField],
  3943. rightFields = [this.notesField, this.locationField, this.urlField];
  3944. if (this.calendarStore) {
  3945. this.calendarField = new Ext.calendar.CalendarPicker({
  3946. store: this.calendarStore,
  3947. name: Ext.calendar.EventMappings.CalendarId.name
  3948. });
  3949. leftFields.splice(2, 0, this.calendarField);
  3950. };
  3951. this.items = [{
  3952. id: 'left-col',
  3953. columnWidth: 0.65,
  3954. layout: 'form',
  3955. border: false,
  3956. items: leftFields
  3957. },
  3958. {
  3959. id: 'right-col',
  3960. columnWidth: 0.35,
  3961. layout: 'form',
  3962. border: false,
  3963. items: rightFields
  3964. }];
  3965. this.fbar = [{
  3966. text: 'Save',
  3967. scope: this,
  3968. handler: this.onSave
  3969. },
  3970. {
  3971. cls: 'ext-del-btn',
  3972. text: 'Delete',
  3973. scope: this,
  3974. handler: this.onDelete
  3975. },
  3976. {
  3977. text: 'Cancel',
  3978. scope: this,
  3979. handler: this.onCancel
  3980. }];
  3981. Ext.calendar.EventEditForm.superclass.initComponent.call(this);
  3982. },
  3983. // inherited docs
  3984. loadRecord: function(rec) {
  3985. this.form.loadRecord.apply(this.form, arguments);
  3986. this.activeRecord = rec;
  3987. this.dateRangeField.setValue(rec.data);
  3988. if (this.calendarStore) {
  3989. this.form.setValues({
  3990. 'calendar': rec.data[Ext.calendar.EventMappings.CalendarId.name]
  3991. });
  3992. }
  3993. this.isAdd = !!rec.data[Ext.calendar.EventMappings.IsNew.name];
  3994. if (this.isAdd) {
  3995. rec.markDirty();
  3996. this.setTitle(this.titleTextAdd);
  3997. Ext.select('.ext-del-btn').setDisplayed(false);
  3998. }
  3999. else {
  4000. this.setTitle(this.titleTextEdit);
  4001. Ext.select('.ext-del-btn').setDisplayed(true);
  4002. }
  4003. this.titleField.focus();
  4004. },
  4005. // inherited docs
  4006. updateRecord: function() {
  4007. var dates = this.dateRangeField.getValue();
  4008. this.form.updateRecord(this.activeRecord);
  4009. this.activeRecord.set(Ext.calendar.EventMappings.StartDate.name, dates[0]);
  4010. this.activeRecord.set(Ext.calendar.EventMappings.EndDate.name, dates[1]);
  4011. this.activeRecord.set(Ext.calendar.EventMappings.IsAllDay.name, dates[2]);
  4012. },
  4013. // private
  4014. onCancel: function() {
  4015. this.cleanup(true);
  4016. this.fireEvent('eventcancel', this, this.activeRecord);
  4017. },
  4018. // private
  4019. cleanup: function(hide) {
  4020. if (this.activeRecord && this.activeRecord.dirty) {
  4021. this.activeRecord.reject();
  4022. }
  4023. delete this.activeRecord;
  4024. if (this.form.isDirty()) {
  4025. this.form.reset();
  4026. }
  4027. },
  4028. // private
  4029. onSave: function() {
  4030. if (!this.form.isValid()) {
  4031. return;
  4032. }
  4033. this.updateRecord();
  4034. if (!this.activeRecord.dirty) {
  4035. this.onCancel();
  4036. return;
  4037. }
  4038. this.fireEvent(this.isAdd ? 'eventadd': 'eventupdate', this, this.activeRecord);
  4039. },
  4040. // private
  4041. onDelete: function() {
  4042. this.fireEvent('eventdelete', this, this.activeRecord);
  4043. }
  4044. });
  4045. Ext.reg('eventeditform', Ext.calendar.EventEditForm);
  4046. /**
  4047. * @class Ext.calendar.EventEditWindow
  4048. * @extends Ext.Window
  4049. * <p>A custom window containing a basic edit form used for quick editing of events.</p>
  4050. * <p>This window also provides custom events specific to the calendar so that other calendar components can be easily
  4051. * notified when an event has been edited via this component.</p>
  4052. * @constructor
  4053. * @param {Object} config The config object
  4054. */
  4055. Ext.calendar.EventEditWindow = function(config) {
  4056. var formPanelCfg = {
  4057. xtype: 'form',
  4058. labelWidth: 65,
  4059. frame: false,
  4060. bodyStyle: 'background:transparent;padding:5px 10px 10px;',
  4061. bodyBorder: false,
  4062. border: false,
  4063. items: [{
  4064. id: 'title',
  4065. name: Ext.calendar.EventMappings.Title.name,
  4066. fieldLabel: 'Title',
  4067. xtype: 'textfield',
  4068. anchor: '100%'
  4069. },
  4070. {
  4071. xtype: 'daterangefield',
  4072. id: 'date-range',
  4073. anchor: '100%',
  4074. fieldLabel: 'When'
  4075. }]
  4076. };
  4077. if (config.calendarStore) {
  4078. this.calendarStore = config.calendarStore;
  4079. delete config.calendarStore;
  4080. formPanelCfg.items.push({
  4081. xtype: 'calendarpicker',
  4082. id: 'calendar',
  4083. name: 'calendar',
  4084. anchor: '100%',
  4085. store: this.calendarStore
  4086. });
  4087. }
  4088. Ext.calendar.EventEditWindow.superclass.constructor.call(this, Ext.apply({
  4089. titleTextAdd: 'Add Event',
  4090. titleTextEdit: 'Edit Event',
  4091. width: 600,
  4092. autocreate: true,
  4093. border: true,
  4094. closeAction: 'hide',
  4095. modal: false,
  4096. resizable: false,
  4097. buttonAlign: 'left',
  4098. savingMessage: 'Saving changes...',
  4099. deletingMessage: 'Deleting event...',
  4100. fbar: [{
  4101. xtype: 'tbtext',
  4102. text: '<a href="#" id="tblink">Edit Details...</a>'
  4103. },
  4104. '->', {
  4105. text: 'Save',
  4106. disabled: false,
  4107. handler: this.onSave,
  4108. scope: this
  4109. },
  4110. {
  4111. id: 'delete-btn',
  4112. text: 'Delete',
  4113. disabled: false,
  4114. handler: this.onDelete,
  4115. scope: this,
  4116. hideMode: 'offsets'
  4117. },
  4118. {
  4119. text: 'Cancel',
  4120. disabled: false,
  4121. handler: this.onCancel,
  4122. scope: this
  4123. }],
  4124. items: formPanelCfg
  4125. },
  4126. config));
  4127. };
  4128. Ext.extend(Ext.calendar.EventEditWindow, Ext.Window, {
  4129. // private
  4130. newId: 10000,
  4131. // private
  4132. initComponent: function() {
  4133. Ext.calendar.EventEditWindow.superclass.initComponent.call(this);
  4134. this.formPanel = this.items.items[0];
  4135. this.addEvents({
  4136. /**
  4137. * @event eventadd
  4138. * Fires after a new event is added
  4139. * @param {Ext.calendar.EventEditWindow} this
  4140. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was added
  4141. */
  4142. eventadd: true,
  4143. /**
  4144. * @event eventupdate
  4145. * Fires after an existing event is updated
  4146. * @param {Ext.calendar.EventEditWindow} this
  4147. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was updated
  4148. */
  4149. eventupdate: true,
  4150. /**
  4151. * @event eventdelete
  4152. * Fires after an event is deleted
  4153. * @param {Ext.calendar.EventEditWindow} this
  4154. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was deleted
  4155. */
  4156. eventdelete: true,
  4157. /**
  4158. * @event eventcancel
  4159. * Fires after an event add/edit operation is canceled by the user and no store update took place
  4160. * @param {Ext.calendar.EventEditWindow} this
  4161. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was canceled
  4162. */
  4163. eventcancel: true,
  4164. /**
  4165. * @event editdetails
  4166. * Fires when the user selects the option in this window to continue editing in the detailed edit form
  4167. * (by default, an instance of {@link Ext.calendar.EventEditForm}. Handling code should hide this window
  4168. * and transfer the current event record to the appropriate instance of the detailed form by showing it
  4169. * and calling {@link Ext.calendar.EventEditForm#loadRecord loadRecord}.
  4170. * @param {Ext.calendar.EventEditWindow} this
  4171. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} that is currently being edited
  4172. */
  4173. editdetails: true
  4174. });
  4175. },
  4176. // private
  4177. afterRender: function() {
  4178. Ext.calendar.EventEditWindow.superclass.afterRender.call(this);
  4179. this.el.addClass('ext-cal-event-win');
  4180. Ext.get('tblink').on('click',
  4181. function(e) {
  4182. e.stopEvent();
  4183. this.updateRecord();
  4184. this.fireEvent('editdetails', this, this.activeRecord);
  4185. },
  4186. this);
  4187. },
  4188. /**
  4189. * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
  4190. * @param {Ext.data.Record/Object} o Either a {@link Ext.data.Record} if showing the form
  4191. * for an existing event in edit mode, or a plain object containing a StartDate property (and
  4192. * optionally an EndDate property) for showing the form in add mode.
  4193. * @param {String/Element} animateTarget (optional) The target element or id from which the window should
  4194. * animate while opening (defaults to null with no animation)
  4195. * @return {Ext.Window} this
  4196. */
  4197. show: function(o, animateTarget) {
  4198. // Work around the CSS day cell height hack needed for initial render in IE8/strict:
  4199. var anim = (Ext.isIE8 && Ext.isStrict) ? null: animateTarget;
  4200. Ext.calendar.EventEditWindow.superclass.show.call(this, anim,
  4201. function() {
  4202. Ext.getCmp('title').focus(false, 100);
  4203. });
  4204. Ext.getCmp('delete-btn')[o.data && o.data[Ext.calendar.EventMappings.EventId.name] ? 'show': 'hide']();
  4205. var rec,
  4206. f = this.formPanel.form;
  4207. if (o.data) {
  4208. rec = o;
  4209. this.isAdd = !!rec.data[Ext.calendar.EventMappings.IsNew.name];
  4210. if (this.isAdd) {
  4211. // Enable adding the default record that was passed in
  4212. // if it's new even if the user makes no changes
  4213. rec.markDirty();
  4214. this.setTitle(this.titleTextAdd);
  4215. }
  4216. else {
  4217. this.setTitle(this.titleTextEdit);
  4218. }
  4219. f.loadRecord(rec);
  4220. }
  4221. else {
  4222. this.isAdd = true;
  4223. this.setTitle(this.titleTextAdd);
  4224. var M = Ext.calendar.EventMappings,
  4225. eventId = M.EventId.name,
  4226. start = o[M.StartDate.name],
  4227. end = o[M.EndDate.name] || start.add('h', 1);
  4228. rec = new Ext.calendar.EventRecord();
  4229. rec.data[M.EventId.name] = this.newId++;
  4230. rec.data[M.StartDate.name] = start;
  4231. rec.data[M.EndDate.name] = end;
  4232. rec.data[M.IsAllDay.name] = !!o[M.IsAllDay.name] || start.getDate() != end.clone().add(Date.MILLI, 1).getDate();
  4233. rec.data[M.IsNew.name] = true;
  4234. f.reset();
  4235. f.loadRecord(rec);
  4236. }
  4237. if (this.calendarStore) {
  4238. Ext.getCmp('calendar').setValue(rec.data[Ext.calendar.EventMappings.CalendarId.name]);
  4239. }
  4240. Ext.getCmp('date-range').setValue(rec.data);
  4241. this.activeRecord = rec;
  4242. return this;
  4243. },
  4244. // private
  4245. roundTime: function(dt, incr) {
  4246. incr = incr || 15;
  4247. var m = parseInt(dt.getMinutes(), 10);
  4248. return dt.add('mi', incr - (m % incr));
  4249. },
  4250. // private
  4251. onCancel: function() {
  4252. this.cleanup(true);
  4253. this.fireEvent('eventcancel', this);
  4254. },
  4255. // private
  4256. cleanup: function(hide) {
  4257. if (this.activeRecord && this.activeRecord.dirty) {
  4258. this.activeRecord.reject();
  4259. }
  4260. delete this.activeRecord;
  4261. if (hide === true) {
  4262. // Work around the CSS day cell height hack needed for initial render in IE8/strict:
  4263. //var anim = afterDelete || (Ext.isIE8 && Ext.isStrict) ? null : this.animateTarget;
  4264. this.hide();
  4265. }
  4266. },
  4267. // private
  4268. updateRecord: function() {
  4269. var f = this.formPanel.form,
  4270. dates = Ext.getCmp('date-range').getValue(),
  4271. M = Ext.calendar.EventMappings;
  4272. f.updateRecord(this.activeRecord);
  4273. this.activeRecord.set(M.StartDate.name, dates[0]);
  4274. this.activeRecord.set(M.EndDate.name, dates[1]);
  4275. this.activeRecord.set(M.IsAllDay.name, dates[2]);
  4276. this.activeRecord.set(M.CalendarId.name, this.formPanel.form.findField('calendar').getValue());
  4277. },
  4278. // private
  4279. onSave: function() {
  4280. if (!this.formPanel.form.isValid()) {
  4281. return;
  4282. }
  4283. this.updateRecord();
  4284. if (!this.activeRecord.dirty) {
  4285. this.onCancel();
  4286. return;
  4287. }
  4288. this.fireEvent(this.isAdd ? 'eventadd': 'eventupdate', this, this.activeRecord);
  4289. },
  4290. // private
  4291. onDelete: function() {
  4292. this.fireEvent('eventdelete', this, this.activeRecord);
  4293. }
  4294. });/**
  4295. * @class Ext.calendar.CalendarPanel
  4296. * @extends Ext.Panel
  4297. * <p>This is the default container for Ext calendar views. It supports day, week and month views as well
  4298. * as a built-in event edit form. The only requirement for displaying a calendar is passing in a valid
  4299. * {@link #calendarStore} config containing records of type {@link Ext.calendar.EventRecord EventRecord}. In order
  4300. * to make the calendar interactive (enable editing, drag/drop, etc.) you can handle any of the various
  4301. * events fired by the underlying views and exposed through the CalendarPanel.</p>
  4302. * {@link #layoutConfig} option if needed.</p>
  4303. * @constructor
  4304. * @param {Object} config The config object
  4305. * @xtype calendarpanel
  4306. */
  4307. Ext.calendar.CalendarPanel = Ext.extend(Ext.Panel, {
  4308. /**
  4309. * @cfg {Boolean} showDayView
  4310. * True to include the day view (and toolbar button), false to hide them (defaults to true).
  4311. */
  4312. showDayView: true,
  4313. /**
  4314. * @cfg {Boolean} showWeekView
  4315. * True to include the week view (and toolbar button), false to hide them (defaults to true).
  4316. */
  4317. showWeekView: true,
  4318. /**
  4319. * @cfg {Boolean} showMonthView
  4320. * True to include the month view (and toolbar button), false to hide them (defaults to true).
  4321. * If the day and week views are both hidden, the month view will show by default even if
  4322. * this config is false.
  4323. */
  4324. showMonthView: true,
  4325. /**
  4326. * @cfg {Boolean} showNavBar
  4327. * True to display the calendar navigation toolbar, false to hide it (defaults to true). Note that
  4328. * if you hide the default navigation toolbar you'll have to provide an alternate means of navigating the calendar.
  4329. */
  4330. showNavBar: true,
  4331. /**
  4332. * @cfg {String} todayText
  4333. * Alternate text to use for the 'Today' nav bar button.
  4334. */
  4335. todayText: 'Today',
  4336. /**
  4337. * @cfg {Boolean} showTodayText
  4338. * True to show the value of {@link #todayText} instead of today's date in the calendar's current day box,
  4339. * false to display the day number(defaults to true).
  4340. */
  4341. showTodayText: true,
  4342. /**
  4343. * @cfg {Boolean} showTime
  4344. * True to display the current time next to the date in the calendar's current day box, false to not show it
  4345. * (defaults to true).
  4346. */
  4347. showTime: true,
  4348. /**
  4349. * @cfg {String} dayText
  4350. * Alternate text to use for the 'Day' nav bar button.
  4351. */
  4352. dayText: 'Day',
  4353. /**
  4354. * @cfg {String} weekText
  4355. * Alternate text to use for the 'Week' nav bar button.
  4356. */
  4357. weekText: 'Week',
  4358. /**
  4359. * @cfg {String} monthText
  4360. * Alternate text to use for the 'Month' nav bar button.
  4361. */
  4362. monthText: 'Month',
  4363. // private
  4364. layoutConfig: {
  4365. layoutOnCardChange: true,
  4366. deferredRender: true
  4367. },
  4368. // private property
  4369. startDate: new Date(),
  4370. // private
  4371. initComponent: function() {
  4372. this.tbar = {
  4373. cls: 'ext-cal-toolbar',
  4374. border: true,
  4375. buttonAlign: 'center',
  4376. items: [{
  4377. id: this.id + '-tb-prev',
  4378. handler: this.onPrevClick,
  4379. scope: this,
  4380. iconCls: 'x-tbar-page-prev'
  4381. }]
  4382. };
  4383. this.viewCount = 0;
  4384. if (this.showDayView) {
  4385. this.tbar.items.push({
  4386. id: this.id + '-tb-day',
  4387. text: this.dayText,
  4388. handler: this.onDayClick,
  4389. scope: this,
  4390. toggleGroup: 'tb-views'
  4391. });
  4392. this.viewCount++;
  4393. }
  4394. if (this.showWeekView) {
  4395. this.tbar.items.push({
  4396. id: this.id + '-tb-week',
  4397. text: this.weekText,
  4398. handler: this.onWeekClick,
  4399. scope: this,
  4400. toggleGroup: 'tb-views'
  4401. });
  4402. this.viewCount++;
  4403. }
  4404. if (this.showMonthView || this.viewCount == 0) {
  4405. this.tbar.items.push({
  4406. id: this.id + '-tb-month',
  4407. text: this.monthText,
  4408. handler: this.onMonthClick,
  4409. scope: this,
  4410. toggleGroup: 'tb-views'
  4411. });
  4412. this.viewCount++;
  4413. this.showMonthView = true;
  4414. }
  4415. this.tbar.items.push({
  4416. id: this.id + '-tb-next',
  4417. handler: this.onNextClick,
  4418. scope: this,
  4419. iconCls: 'x-tbar-page-next'
  4420. });
  4421. this.tbar.items.push('->');
  4422. var idx = this.viewCount - 1;
  4423. this.activeItem = this.activeItem === undefined ? idx: (this.activeItem > idx ? idx: this.activeItem);
  4424. if (this.showNavBar === false) {
  4425. delete this.tbar;
  4426. this.addClass('x-calendar-nonav');
  4427. }
  4428. Ext.calendar.CalendarPanel.superclass.initComponent.call(this);
  4429. this.addEvents({
  4430. /**
  4431. * @event eventadd
  4432. * Fires after a new event is added to the underlying store
  4433. * @param {Ext.calendar.CalendarPanel} this
  4434. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was added
  4435. */
  4436. eventadd: true,
  4437. /**
  4438. * @event eventupdate
  4439. * Fires after an existing event is updated
  4440. * @param {Ext.calendar.CalendarPanel} this
  4441. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was updated
  4442. */
  4443. eventupdate: true,
  4444. /**
  4445. * @event eventdelete
  4446. * Fires after an event is removed from the underlying store
  4447. * @param {Ext.calendar.CalendarPanel} this
  4448. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was removed
  4449. */
  4450. eventdelete: true,
  4451. /**
  4452. * @event eventcancel
  4453. * Fires after an event add/edit operation is canceled by the user and no store update took place
  4454. * @param {Ext.calendar.CalendarPanel} this
  4455. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was canceled
  4456. */
  4457. eventcancel: true,
  4458. /**
  4459. * @event viewchange
  4460. * Fires after a different calendar view is activated (but not when the event edit form is activated)
  4461. * @param {Ext.calendar.CalendarPanel} this
  4462. * @param {Ext.CalendarView} view The view being activated (any valid {@link Ext.calendar.CalendarView CalendarView} subclass)
  4463. * @param {Object} info Extra information about the newly activated view. This is a plain object
  4464. * with following properties:<div class="mdetail-params"><ul>
  4465. * <li><b><code>activeDate</code></b> : <div class="sub-desc">The currently-selected date</div></li>
  4466. * <li><b><code>viewStart</code></b> : <div class="sub-desc">The first date in the new view range</div></li>
  4467. * <li><b><code>viewEnd</code></b> : <div class="sub-desc">The last date in the new view range</div></li>
  4468. * </ul></div>
  4469. */
  4470. viewchange: true
  4471. //
  4472. // NOTE: CalendarPanel also relays the following events from contained views as if they originated from this:
  4473. //
  4474. /**
  4475. * @event eventsrendered
  4476. * Fires after events are finished rendering in the view
  4477. * @param {Ext.calendar.CalendarPanel} this
  4478. */
  4479. /**
  4480. * @event eventclick
  4481. * Fires after the user clicks on an event element
  4482. * @param {Ext.calendar.CalendarPanel} this
  4483. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was clicked on
  4484. * @param {HTMLNode} el The DOM node that was clicked on
  4485. */
  4486. /**
  4487. * @event eventover
  4488. * Fires anytime the mouse is over an event element
  4489. * @param {Ext.calendar.CalendarPanel} this
  4490. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that the cursor is over
  4491. * @param {HTMLNode} el The DOM node that is being moused over
  4492. */
  4493. /**
  4494. * @event eventout
  4495. * Fires anytime the mouse exits an event element
  4496. * @param {Ext.calendar.CalendarPanel} this
  4497. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that the cursor exited
  4498. * @param {HTMLNode} el The DOM node that was exited
  4499. */
  4500. /**
  4501. * @event datechange
  4502. * Fires after the start date of the view changes
  4503. * @param {Ext.calendar.CalendarPanel} this
  4504. * @param {Date} startDate The start date of the view (as explained in {@link #getStartDate}
  4505. * @param {Date} viewStart The first displayed date in the view
  4506. * @param {Date} viewEnd The last displayed date in the view
  4507. */
  4508. /**
  4509. * @event rangeselect
  4510. * Fires after the user drags on the calendar to select a range of dates/times in which to create an event
  4511. * @param {Ext.calendar.CalendarPanel} this
  4512. * @param {Object} dates An object containing the start (StartDate property) and end (EndDate property) dates selected
  4513. * @param {Function} callback A callback function that MUST be called after the event handling is complete so that
  4514. * the view is properly cleaned up (shim elements are persisted in the view while the user is prompted to handle the
  4515. * range selection). The callback is already created in the proper scope, so it simply needs to be executed as a standard
  4516. * function call (e.g., callback()).
  4517. */
  4518. /**
  4519. * @event eventmove
  4520. * Fires after an event element is dragged by the user and dropped in a new position
  4521. * @param {Ext.calendar.CalendarPanel} this
  4522. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was moved with
  4523. * updated start and end dates
  4524. */
  4525. /**
  4526. * @event initdrag
  4527. * Fires when a drag operation is initiated in the view
  4528. * @param {Ext.calendar.CalendarPanel} this
  4529. */
  4530. /**
  4531. * @event eventresize
  4532. * Fires after the user drags the resize handle of an event to resize it
  4533. * @param {Ext.calendar.CalendarPanel} this
  4534. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was resized
  4535. * containing the updated start and end dates
  4536. */
  4537. /**
  4538. * @event dayclick
  4539. * Fires after the user clicks within a day/week view container and not on an event element
  4540. * @param {Ext.calendar.CalendarPanel} this
  4541. * @param {Date} dt The date/time that was clicked on
  4542. * @param {Boolean} allday True if the day clicked on represents an all-day box, else false.
  4543. * @param {Ext.Element} el The Element that was clicked on
  4544. */
  4545. });
  4546. this.layout = 'card';
  4547. // do not allow override
  4548. if (this.showDayView) {
  4549. var day = Ext.apply({
  4550. xtype: 'dayview',
  4551. title: this.dayText,
  4552. showToday: this.showToday,
  4553. showTodayText: this.showTodayText,
  4554. showTime: this.showTime
  4555. },
  4556. this.dayViewCfg);
  4557. day.id = this.id + '-day';
  4558. day.store = day.store || this.eventStore;
  4559. this.initEventRelay(day);
  4560. this.add(day);
  4561. }
  4562. if (this.showWeekView) {
  4563. var wk = Ext.applyIf({
  4564. xtype: 'weekview',
  4565. title: this.weekText,
  4566. showToday: this.showToday,
  4567. showTodayText: this.showTodayText,
  4568. showTime: this.showTime
  4569. },
  4570. this.weekViewCfg);
  4571. wk.id = this.id + '-week';
  4572. wk.store = wk.store || this.eventStore;
  4573. this.initEventRelay(wk);
  4574. this.add(wk);
  4575. }
  4576. if (this.showMonthView) {
  4577. var month = Ext.applyIf({
  4578. xtype: 'monthview',
  4579. title: this.monthText,
  4580. showToday: this.showToday,
  4581. showTodayText: this.showTodayText,
  4582. showTime: this.showTime,
  4583. listeners: {
  4584. 'weekclick': {
  4585. fn: function(vw, dt) {
  4586. this.showWeek(dt);
  4587. },
  4588. scope: this
  4589. }
  4590. }
  4591. },
  4592. this.monthViewCfg);
  4593. month.id = this.id + '-month';
  4594. month.store = month.store || this.eventStore;
  4595. this.initEventRelay(month);
  4596. this.add(month);
  4597. }
  4598. this.add(Ext.applyIf({
  4599. xtype: 'eventeditform',
  4600. id: this.id + '-edit',
  4601. calendarStore: this.calendarStore,
  4602. listeners: {
  4603. 'eventadd': {
  4604. scope: this,
  4605. fn: this.onEventAdd
  4606. },
  4607. 'eventupdate': {
  4608. scope: this,
  4609. fn: this.onEventUpdate
  4610. },
  4611. 'eventdelete': {
  4612. scope: this,
  4613. fn: this.onEventDelete
  4614. },
  4615. 'eventcancel': {
  4616. scope: this,
  4617. fn: this.onEventCancel
  4618. }
  4619. }
  4620. },
  4621. this.editViewCfg));
  4622. },
  4623. // private
  4624. initEventRelay: function(cfg) {
  4625. cfg.listeners = cfg.listeners || {};
  4626. cfg.listeners.afterrender = {
  4627. fn: function(c) {
  4628. // relay the view events so that app code only has to handle them in one place
  4629. this.relayEvents(c, ['eventsrendered', 'eventclick', 'eventover', 'eventout', 'dayclick',
  4630. 'eventmove', 'datechange', 'rangeselect', 'eventdelete', 'eventresize', 'initdrag']);
  4631. },
  4632. scope: this,
  4633. single: true
  4634. };
  4635. },
  4636. // private
  4637. afterRender: function() {
  4638. Ext.calendar.CalendarPanel.superclass.afterRender.call(this);
  4639. this.fireViewChange();
  4640. },
  4641. // private
  4642. onLayout: function() {
  4643. Ext.calendar.CalendarPanel.superclass.onLayout.call(this);
  4644. if (!this.navInitComplete) {
  4645. this.updateNavState();
  4646. this.navInitComplete = true;
  4647. }
  4648. },
  4649. // private
  4650. onEventAdd: function(form, rec) {
  4651. rec.data[Ext.calendar.EventMappings.IsNew.name] = false;
  4652. this.eventStore.add(rec);
  4653. this.hideEditForm();
  4654. this.fireEvent('eventadd', this, rec);
  4655. },
  4656. // private
  4657. onEventUpdate: function(form, rec) {
  4658. rec.commit();
  4659. this.hideEditForm();
  4660. this.fireEvent('eventupdate', this, rec);
  4661. },
  4662. // private
  4663. onEventDelete: function(form, rec) {
  4664. this.eventStore.remove(rec);
  4665. this.hideEditForm();
  4666. this.fireEvent('eventdelete', this, rec);
  4667. },
  4668. // private
  4669. onEventCancel: function(form, rec) {
  4670. this.hideEditForm();
  4671. this.fireEvent('eventcancel', this, rec);
  4672. },
  4673. /**
  4674. * Shows the built-in event edit form for the passed in event record. This method automatically
  4675. * hides the calendar views and navigation toolbar. To return to the calendar, call {@link #hideEditForm}.
  4676. * @param {Ext.calendar.EventRecord} record The event record to edit
  4677. * @return {Ext.calendar.CalendarPanel} this
  4678. */
  4679. showEditForm: function(rec) {
  4680. this.preEditView = this.layout.activeItem.id;
  4681. this.setActiveView(this.id + '-edit');
  4682. this.layout.activeItem.loadRecord(rec);
  4683. return this;
  4684. },
  4685. /**
  4686. * Hides the built-in event edit form and returns to the previous calendar view. If the edit form is
  4687. * not currently visible this method has no effect.
  4688. * @return {Ext.calendar.CalendarPanel} this
  4689. */
  4690. hideEditForm: function() {
  4691. if (this.preEditView) {
  4692. this.setActiveView(this.preEditView);
  4693. delete this.preEditView;
  4694. }
  4695. return this;
  4696. },
  4697. // private
  4698. setActiveView: function(id) {
  4699. var l = this.layout;
  4700. l.setActiveItem(id);
  4701. if (id == this.id + '-edit') {
  4702. this.getTopToolbar().hide();
  4703. this.doLayout();
  4704. }
  4705. else {
  4706. l.activeItem.refresh();
  4707. this.getTopToolbar().show();
  4708. this.updateNavState();
  4709. }
  4710. this.activeView = l.activeItem;
  4711. this.fireViewChange();
  4712. },
  4713. // private
  4714. fireViewChange: function() {
  4715. var info = null,
  4716. view = this.layout.activeItem;
  4717. if (view.getViewBounds) {
  4718. vb = view.getViewBounds();
  4719. info = {
  4720. activeDate: view.getStartDate(),
  4721. viewStart: vb.start,
  4722. viewEnd: vb.end
  4723. };
  4724. };
  4725. this.fireEvent('viewchange', this, view, info);
  4726. },
  4727. // private
  4728. updateNavState: function() {
  4729. if (this.showNavBar !== false) {
  4730. var item = this.layout.activeItem,
  4731. suffix = item.id.split(this.id + '-')[1];
  4732. var btn = Ext.getCmp(this.id + '-tb-' + suffix);
  4733. btn.toggle(true);
  4734. }
  4735. },
  4736. /**
  4737. * Sets the start date for the currently-active calendar view.
  4738. * @param {Date} dt
  4739. */
  4740. setStartDate: function(dt) {
  4741. this.layout.activeItem.setStartDate(dt, true);
  4742. this.updateNavState();
  4743. this.fireViewChange();
  4744. },
  4745. // private
  4746. showWeek: function(dt) {
  4747. this.setActiveView(this.id + '-week');
  4748. this.setStartDate(dt);
  4749. },
  4750. // private
  4751. onPrevClick: function() {
  4752. this.startDate = this.layout.activeItem.movePrev();
  4753. this.updateNavState();
  4754. this.fireViewChange();
  4755. },
  4756. // private
  4757. onNextClick: function() {
  4758. this.startDate = this.layout.activeItem.moveNext();
  4759. this.updateNavState();
  4760. this.fireViewChange();
  4761. },
  4762. // private
  4763. onDayClick: function() {
  4764. this.setActiveView(this.id + '-day');
  4765. },
  4766. // private
  4767. onWeekClick: function() {
  4768. this.setActiveView(this.id + '-week');
  4769. },
  4770. // private
  4771. onMonthClick: function() {
  4772. this.setActiveView(this.id + '-month');
  4773. },
  4774. /**
  4775. * Return the calendar view that is currently active, which will be a subclass of
  4776. * {@link Ext.calendar.CalendarView CalendarView}.
  4777. * @return {Ext.calendar.CalendarView} The active view
  4778. */
  4779. getActiveView: function() {
  4780. return this.layout.activeItem;
  4781. }
  4782. });
  4783. Ext.reg('calendarpanel', Ext.calendar.CalendarPanel);