Web Interface For Lite Argus Control modules
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.

5245 lines
184 KiB

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