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.

10613 lines
351 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. Ext.ns('Ext.ux.grid');
  16. /**
  17. * @class Ext.ux.grid.BufferView
  18. * @extends Ext.grid.GridView
  19. * A custom GridView which renders rows on an as-needed basis.
  20. */
  21. Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
  22. <div id="cfg-Ext.ux.grid.BufferView-rowHeight"></div>/**
  23. * @cfg {Number} rowHeight
  24. * The height of a row in the grid.
  25. */
  26. rowHeight: 19,
  27. <div id="cfg-Ext.ux.grid.BufferView-borderHeight"></div>/**
  28. * @cfg {Number} borderHeight
  29. * The combined height of border-top and border-bottom of a row.
  30. */
  31. borderHeight: 2,
  32. <div id="cfg-Ext.ux.grid.BufferView-scrollDelay"></div>/**
  33. * @cfg {Boolean/Number} scrollDelay
  34. * The number of milliseconds before rendering rows out of the visible
  35. * viewing area. Defaults to 100. Rows will render immediately with a config
  36. * of false.
  37. */
  38. scrollDelay: 100,
  39. <div id="cfg-Ext.ux.grid.BufferView-cacheSize"></div>/**
  40. * @cfg {Number} cacheSize
  41. * The number of rows to look forward and backwards from the currently viewable
  42. * area. The cache applies only to rows that have been rendered already.
  43. */
  44. cacheSize: 20,
  45. <div id="cfg-Ext.ux.grid.BufferView-cleanDelay"></div>/**
  46. * @cfg {Number} cleanDelay
  47. * The number of milliseconds to buffer cleaning of extra rows not in the
  48. * cache.
  49. */
  50. cleanDelay: 500,
  51. initTemplates : function(){
  52. Ext.ux.grid.BufferView.superclass.initTemplates.call(this);
  53. var ts = this.templates;
  54. // empty div to act as a place holder for a row
  55. ts.rowHolder = new Ext.Template(
  56. '<div class="x-grid3-row {alt}" style="{tstyle}"></div>'
  57. );
  58. ts.rowHolder.disableFormats = true;
  59. ts.rowHolder.compile();
  60. ts.rowBody = new Ext.Template(
  61. '<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
  62. '<tbody><tr>{cells}</tr>',
  63. (this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''),
  64. '</tbody></table>'
  65. );
  66. ts.rowBody.disableFormats = true;
  67. ts.rowBody.compile();
  68. },
  69. getStyleRowHeight : function(){
  70. return Ext.isBorderBox ? (this.rowHeight + this.borderHeight) : this.rowHeight;
  71. },
  72. getCalculatedRowHeight : function(){
  73. return this.rowHeight + this.borderHeight;
  74. },
  75. getVisibleRowCount : function(){
  76. var rh = this.getCalculatedRowHeight(),
  77. visibleHeight = this.scroller.dom.clientHeight;
  78. return (visibleHeight < 1) ? 0 : Math.ceil(visibleHeight / rh);
  79. },
  80. getVisibleRows: function(){
  81. var count = this.getVisibleRowCount(),
  82. sc = this.scroller.dom.scrollTop,
  83. start = (sc === 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1);
  84. return {
  85. first: Math.max(start, 0),
  86. last: Math.min(start + count + 2, this.ds.getCount()-1)
  87. };
  88. },
  89. doRender : function(cs, rs, ds, startRow, colCount, stripe, onlyBody){
  90. var ts = this.templates,
  91. ct = ts.cell,
  92. rt = ts.row,
  93. rb = ts.rowBody,
  94. last = colCount-1,
  95. rh = this.getStyleRowHeight(),
  96. vr = this.getVisibleRows(),
  97. tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;',
  98. // buffers
  99. buf = [],
  100. cb,
  101. c,
  102. p = {},
  103. rp = {tstyle: tstyle},
  104. r;
  105. for (var j = 0, len = rs.length; j < len; j++) {
  106. r = rs[j]; cb = [];
  107. var rowIndex = (j+startRow),
  108. visible = rowIndex >= vr.first && rowIndex <= vr.last;
  109. if (visible) {
  110. for (var i = 0; i < colCount; i++) {
  111. c = cs[i];
  112. p.id = c.id;
  113. p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
  114. p.attr = p.cellAttr = "";
  115. p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
  116. p.style = c.style;
  117. if (p.value === undefined || p.value === "") {
  118. p.value = "&#160;";
  119. }
  120. if (r.dirty && typeof r.modified[c.name] !== 'undefined') {
  121. p.css += ' x-grid3-dirty-cell';
  122. }
  123. cb[cb.length] = ct.apply(p);
  124. }
  125. }
  126. var alt = [];
  127. if(stripe && ((rowIndex+1) % 2 === 0)){
  128. alt[0] = "x-grid3-row-alt";
  129. }
  130. if(r.dirty){
  131. alt[1] = " x-grid3-dirty-row";
  132. }
  133. rp.cols = colCount;
  134. if(this.getRowClass){
  135. alt[2] = this.getRowClass(r, rowIndex, rp, ds);
  136. }
  137. rp.alt = alt.join(" ");
  138. rp.cells = cb.join("");
  139. buf[buf.length] = !visible ? ts.rowHolder.apply(rp) : (onlyBody ? rb.apply(rp) : rt.apply(rp));
  140. }
  141. return buf.join("");
  142. },
  143. isRowRendered: function(index){
  144. var row = this.getRow(index);
  145. return row && row.childNodes.length > 0;
  146. },
  147. syncScroll: function(){
  148. Ext.ux.grid.BufferView.superclass.syncScroll.apply(this, arguments);
  149. this.update();
  150. },
  151. // a (optionally) buffered method to update contents of gridview
  152. update: function(){
  153. if (this.scrollDelay) {
  154. if (!this.renderTask) {
  155. this.renderTask = new Ext.util.DelayedTask(this.doUpdate, this);
  156. }
  157. this.renderTask.delay(this.scrollDelay);
  158. }else{
  159. this.doUpdate();
  160. }
  161. },
  162. onRemove : function(ds, record, index, isUpdate){
  163. Ext.ux.grid.BufferView.superclass.onRemove.apply(this, arguments);
  164. if(isUpdate !== true){
  165. this.update();
  166. }
  167. },
  168. doUpdate: function(){
  169. if (this.getVisibleRowCount() > 0) {
  170. var g = this.grid,
  171. cm = g.colModel,
  172. ds = g.store,
  173. cs = this.getColumnData(),
  174. vr = this.getVisibleRows(),
  175. row;
  176. for (var i = vr.first; i <= vr.last; i++) {
  177. // if row is NOT rendered and is visible, render it
  178. if(!this.isRowRendered(i) && (row = this.getRow(i))){
  179. var html = this.doRender(cs, [ds.getAt(i)], ds, i, cm.getColumnCount(), g.stripeRows, true);
  180. row.innerHTML = html;
  181. }
  182. }
  183. this.clean();
  184. }
  185. },
  186. // a buffered method to clean rows
  187. clean : function(){
  188. if(!this.cleanTask){
  189. this.cleanTask = new Ext.util.DelayedTask(this.doClean, this);
  190. }
  191. this.cleanTask.delay(this.cleanDelay);
  192. },
  193. doClean: function(){
  194. if (this.getVisibleRowCount() > 0) {
  195. var vr = this.getVisibleRows();
  196. vr.first -= this.cacheSize;
  197. vr.last += this.cacheSize;
  198. var i = 0, rows = this.getRows();
  199. // if first is less than 0, all rows have been rendered
  200. // so lets clean the end...
  201. if(vr.first <= 0){
  202. i = vr.last + 1;
  203. }
  204. for(var len = this.ds.getCount(); i < len; i++){
  205. // if current row is outside of first and last and
  206. // has content, update the innerHTML to nothing
  207. if ((i < vr.first || i > vr.last) && rows[i].innerHTML) {
  208. rows[i].innerHTML = '';
  209. }
  210. }
  211. }
  212. },
  213. removeTask: function(name){
  214. var task = this[name];
  215. if(task && task.cancel){
  216. task.cancel();
  217. this[name] = null;
  218. }
  219. },
  220. destroy : function(){
  221. this.removeTask('cleanTask');
  222. this.removeTask('renderTask');
  223. Ext.ux.grid.BufferView.superclass.destroy.call(this);
  224. },
  225. layout: function(){
  226. Ext.ux.grid.BufferView.superclass.layout.call(this);
  227. this.update();
  228. }
  229. });// We are adding these custom layouts to a namespace that does not
  230. // exist by default in Ext, so we have to add the namespace first:
  231. Ext.ns('Ext.ux.layout');
  232. <div id="cls-Ext.ux.layout.CenterLayout"></div>/**
  233. * @class Ext.ux.layout.CenterLayout
  234. * @extends Ext.layout.FitLayout
  235. * <p>This is a very simple layout style used to center contents within a container. This layout works within
  236. * nested containers and can also be used as expected as a Viewport layout to center the page layout.</p>
  237. * <p>As a subclass of FitLayout, CenterLayout expects to have a single child panel of the container that uses
  238. * the layout. The layout does not require any config options, although the child panel contained within the
  239. * layout must provide a fixed or percentage width. The child panel's height will fit to the container by
  240. * default, but you can specify <tt>autoHeight:true</tt> to allow it to autosize based on its content height.
  241. * Example usage:</p>
  242. * <pre><code>
  243. // The content panel is centered in the container
  244. var p = new Ext.Panel({
  245. title: 'Center Layout',
  246. layout: 'ux.center',
  247. items: [{
  248. title: 'Centered Content',
  249. width: '75%',
  250. html: 'Some content'
  251. }]
  252. });
  253. // If you leave the title blank and specify no border
  254. // you'll create a non-visual, structural panel just
  255. // for centering the contents in the main container.
  256. var p = new Ext.Panel({
  257. layout: 'ux.center',
  258. border: false,
  259. items: [{
  260. title: 'Centered Content',
  261. width: 300,
  262. autoHeight: true,
  263. html: 'Some content'
  264. }]
  265. });
  266. </code></pre>
  267. */
  268. Ext.ux.layout.CenterLayout = Ext.extend(Ext.layout.FitLayout, {
  269. // private
  270. setItemSize : function(item, size){
  271. this.container.addClass('ux-layout-center');
  272. item.addClass('ux-layout-center-item');
  273. if(item && size.height > 0){
  274. if(item.width){
  275. size.width = item.width;
  276. }
  277. item.setSize(size);
  278. }
  279. }
  280. });
  281. Ext.Container.LAYOUTS['ux.center'] = Ext.ux.layout.CenterLayout;
  282. Ext.ns('Ext.ux.grid');
  283. <div id="cls-Ext.ux.grid.CheckColumn"></div>/**
  284. * @class Ext.ux.grid.CheckColumn
  285. * @extends Ext.grid.Column
  286. * <p>A Column subclass which renders a checkbox in each column cell which toggles the truthiness of the associated data field on click.</p>
  287. * <p><b>Note. As of ExtJS 3.3 this no longer has to be configured as a plugin of the GridPanel.</b></p>
  288. * <p>Example usage:</p>
  289. * <pre><code>
  290. var cm = new Ext.grid.ColumnModel([{
  291. header: 'Foo',
  292. ...
  293. },{
  294. xtype: 'checkcolumn',
  295. header: 'Indoor?',
  296. dataIndex: 'indoor',
  297. width: 55
  298. }
  299. ]);
  300. // create the grid
  301. var grid = new Ext.grid.EditorGridPanel({
  302. ...
  303. colModel: cm,
  304. ...
  305. });
  306. * </code></pre>
  307. * In addition to toggling a Boolean value within the record data, this
  308. * class toggles a css class between <tt>'x-grid3-check-col'</tt> and
  309. * <tt>'x-grid3-check-col-on'</tt> to alter the background image used for
  310. * a column.
  311. */
  312. Ext.ux.grid.CheckColumn = Ext.extend(Ext.grid.Column, {
  313. /**
  314. * @private
  315. * Process and refire events routed from the GridView's processEvent method.
  316. */
  317. processEvent : function(name, e, grid, rowIndex, colIndex){
  318. if (name == 'mousedown') {
  319. var record = grid.store.getAt(rowIndex);
  320. record.set(this.dataIndex, !record.data[this.dataIndex]);
  321. return false; // Cancel row selection.
  322. } else {
  323. return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
  324. }
  325. },
  326. renderer : function(v, p, record){
  327. p.css += ' x-grid3-check-col-td';
  328. return String.format('<div class="x-grid3-check-col{0}">&#160;</div>', v ? '-on' : '');
  329. },
  330. // Deprecate use as a plugin. Remove in 4.0
  331. init: Ext.emptyFn
  332. });
  333. // register ptype. Deprecate. Remove in 4.0
  334. Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);
  335. // backwards compat. Remove in 4.0
  336. Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;
  337. // register Column xtype
  338. Ext.grid.Column.types.checkcolumn = Ext.ux.grid.CheckColumn;Ext.ns('Ext.ux.grid');
  339. Ext.ux.grid.ColumnHeaderGroup = Ext.extend(Ext.util.Observable, {
  340. constructor: function(config){
  341. this.config = config;
  342. },
  343. init: function(grid){
  344. Ext.applyIf(grid.colModel, this.config);
  345. Ext.apply(grid.getView(), this.viewConfig);
  346. },
  347. viewConfig: {
  348. initTemplates: function(){
  349. this.constructor.prototype.initTemplates.apply(this, arguments);
  350. var ts = this.templates || {};
  351. if(!ts.gcell){
  352. ts.gcell = new Ext.XTemplate('<td class="x-grid3-hd x-grid3-gcell x-grid3-td-{id} ux-grid-hd-group-row-{row} {cls}" style="{style}">', '<div {tooltip} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">', this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '', '{value}</div></td>');
  353. }
  354. this.templates = ts;
  355. this.hrowRe = new RegExp("ux-grid-hd-group-row-(\\d+)", "");
  356. },
  357. renderHeaders: function(){
  358. var ts = this.templates, headers = [], cm = this.cm, rows = cm.rows, tstyle = 'width:' + this.getTotalWidth() + ';';
  359. for(var row = 0, rlen = rows.length; row < rlen; row++){
  360. var r = rows[row], cells = [];
  361. for(var i = 0, gcol = 0, len = r.length; i < len; i++){
  362. var group = r[i];
  363. group.colspan = group.colspan || 1;
  364. var id = this.getColumnId(group.dataIndex ? cm.findColumnIndex(group.dataIndex) : gcol), gs = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupStyle.call(this, group, gcol);
  365. cells[i] = ts.gcell.apply({
  366. cls: 'ux-grid-hd-group-cell',
  367. id: id,
  368. row: row,
  369. style: 'width:' + gs.width + ';' + (gs.hidden ? 'display:none;' : '') + (group.align ? 'text-align:' + group.align + ';' : ''),
  370. tooltip: group.tooltip ? (Ext.QuickTips.isEnabled() ? 'ext:qtip' : 'title') + '="' + group.tooltip + '"' : '',
  371. istyle: group.align == 'right' ? 'padding-right:16px' : '',
  372. btn: this.grid.enableHdMenu && group.header,
  373. value: group.header || '&nbsp;'
  374. });
  375. gcol += group.colspan;
  376. }
  377. headers[row] = ts.header.apply({
  378. tstyle: tstyle,
  379. cells: cells.join('')
  380. });
  381. }
  382. headers.push(this.constructor.prototype.renderHeaders.apply(this, arguments));
  383. return headers.join('');
  384. },
  385. onColumnWidthUpdated: function(){
  386. this.constructor.prototype.onColumnWidthUpdated.apply(this, arguments);
  387. Ext.ux.grid.ColumnHeaderGroup.prototype.updateGroupStyles.call(this);
  388. },
  389. onAllColumnWidthsUpdated: function(){
  390. this.constructor.prototype.onAllColumnWidthsUpdated.apply(this, arguments);
  391. Ext.ux.grid.ColumnHeaderGroup.prototype.updateGroupStyles.call(this);
  392. },
  393. onColumnHiddenUpdated: function(){
  394. this.constructor.prototype.onColumnHiddenUpdated.apply(this, arguments);
  395. Ext.ux.grid.ColumnHeaderGroup.prototype.updateGroupStyles.call(this);
  396. },
  397. getHeaderCell: function(index){
  398. return this.mainHd.query(this.cellSelector)[index];
  399. },
  400. findHeaderCell: function(el){
  401. return el ? this.fly(el).findParent('td.x-grid3-hd', this.cellSelectorDepth) : false;
  402. },
  403. findHeaderIndex: function(el){
  404. var cell = this.findHeaderCell(el);
  405. return cell ? this.getCellIndex(cell) : false;
  406. },
  407. updateSortIcon: function(col, dir){
  408. var sc = this.sortClasses, hds = this.mainHd.select(this.cellSelector).removeClass(sc);
  409. hds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]);
  410. },
  411. handleHdDown: function(e, t){
  412. var el = Ext.get(t);
  413. if(el.hasClass('x-grid3-hd-btn')){
  414. e.stopEvent();
  415. var hd = this.findHeaderCell(t);
  416. Ext.fly(hd).addClass('x-grid3-hd-menu-open');
  417. var index = this.getCellIndex(hd);
  418. this.hdCtxIndex = index;
  419. var ms = this.hmenu.items, cm = this.cm;
  420. ms.get('asc').setDisabled(!cm.isSortable(index));
  421. ms.get('desc').setDisabled(!cm.isSortable(index));
  422. this.hmenu.on('hide', function(){
  423. Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
  424. }, this, {
  425. single: true
  426. });
  427. this.hmenu.show(t, 'tl-bl?');
  428. }else if(el.hasClass('ux-grid-hd-group-cell') || Ext.fly(t).up('.ux-grid-hd-group-cell')){
  429. e.stopEvent();
  430. }
  431. },
  432. handleHdMove: function(e, t){
  433. var hd = this.findHeaderCell(this.activeHdRef);
  434. if(hd && !this.headersDisabled && !Ext.fly(hd).hasClass('ux-grid-hd-group-cell')){
  435. var hw = this.splitHandleWidth || 5, r = this.activeHdRegion, x = e.getPageX(), ss = hd.style, cur = '';
  436. if(this.grid.enableColumnResize !== false){
  437. if(x - r.left <= hw && this.cm.isResizable(this.activeHdIndex - 1)){
  438. cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'e-resize' : 'col-resize'; // col-resize
  439. // not
  440. // always
  441. // supported
  442. }else if(r.right - x <= (!this.activeHdBtn ? hw : 2) && this.cm.isResizable(this.activeHdIndex)){
  443. cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'w-resize' : 'col-resize';
  444. }
  445. }
  446. ss.cursor = cur;
  447. }
  448. },
  449. handleHdOver: function(e, t){
  450. var hd = this.findHeaderCell(t);
  451. if(hd && !this.headersDisabled){
  452. this.activeHdRef = t;
  453. this.activeHdIndex = this.getCellIndex(hd);
  454. var fly = this.fly(hd);
  455. this.activeHdRegion = fly.getRegion();
  456. if(!(this.cm.isMenuDisabled(this.activeHdIndex) || fly.hasClass('ux-grid-hd-group-cell'))){
  457. fly.addClass('x-grid3-hd-over');
  458. this.activeHdBtn = fly.child('.x-grid3-hd-btn');
  459. if(this.activeHdBtn){
  460. this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight - 1) + 'px';
  461. }
  462. }
  463. }
  464. },
  465. handleHdOut: function(e, t){
  466. var hd = this.findHeaderCell(t);
  467. if(hd && (!Ext.isIE || !e.within(hd, true))){
  468. this.activeHdRef = null;
  469. this.fly(hd).removeClass('x-grid3-hd-over');
  470. hd.style.cursor = '';
  471. }
  472. },
  473. handleHdMenuClick: function(item){
  474. var index = this.hdCtxIndex, cm = this.cm, ds = this.ds, id = item.getItemId();
  475. switch(id){
  476. case 'asc':
  477. ds.sort(cm.getDataIndex(index), 'ASC');
  478. break;
  479. case 'desc':
  480. ds.sort(cm.getDataIndex(index), 'DESC');
  481. break;
  482. default:
  483. if(id.substr(0, 6) == 'group-'){
  484. var i = id.split('-'), row = parseInt(i[1], 10), col = parseInt(i[2], 10), r = this.cm.rows[row], group, gcol = 0;
  485. for(var i = 0, len = r.length; i < len; i++){
  486. group = r[i];
  487. if(col >= gcol && col < gcol + group.colspan){
  488. break;
  489. }
  490. gcol += group.colspan;
  491. }
  492. if(item.checked){
  493. var max = cm.getColumnsBy(this.isHideableColumn, this).length;
  494. for(var i = gcol, len = gcol + group.colspan; i < len; i++){
  495. if(!cm.isHidden(i)){
  496. max--;
  497. }
  498. }
  499. if(max < 1){
  500. this.onDenyColumnHide();
  501. return false;
  502. }
  503. }
  504. for(var i = gcol, len = gcol + group.colspan; i < len; i++){
  505. if(cm.config[i].fixed !== true && cm.config[i].hideable !== false){
  506. cm.setHidden(i, item.checked);
  507. }
  508. }
  509. }else if(id.substr(0, 4) == 'col-'){
  510. index = cm.getIndexById(id.substr(4));
  511. if(index != -1){
  512. if(item.checked && cm.getColumnsBy(this.isHideableColumn, this).length <= 1){
  513. this.onDenyColumnHide();
  514. return false;
  515. }
  516. cm.setHidden(index, item.checked);
  517. }
  518. }
  519. if(id.substr(0, 6) == 'group-' || id.substr(0, 4) == 'col-'){
  520. item.checked = !item.checked;
  521. if(item.menu){
  522. var updateChildren = function(menu){
  523. menu.items.each(function(childItem){
  524. if(!childItem.disabled){
  525. childItem.setChecked(item.checked, false);
  526. if(childItem.menu){
  527. updateChildren(childItem.menu);
  528. }
  529. }
  530. });
  531. }
  532. updateChildren(item.menu);
  533. }
  534. var parentMenu = item, parentItem;
  535. while(parentMenu = parentMenu.parentMenu){
  536. if(!parentMenu.parentMenu || !(parentItem = parentMenu.parentMenu.items.get(parentMenu.getItemId())) || !parentItem.setChecked){
  537. break;
  538. }
  539. var checked = parentMenu.items.findIndexBy(function(m){
  540. return m.checked;
  541. }) >= 0;
  542. parentItem.setChecked(checked, true);
  543. }
  544. item.checked = !item.checked;
  545. }
  546. }
  547. return true;
  548. },
  549. beforeColMenuShow: function(){
  550. var cm = this.cm, rows = this.cm.rows;
  551. this.colMenu.removeAll();
  552. for(var col = 0, clen = cm.getColumnCount(); col < clen; col++){
  553. var menu = this.colMenu, title = cm.getColumnHeader(col), text = [];
  554. if(cm.config[col].fixed !== true && cm.config[col].hideable !== false){
  555. for(var row = 0, rlen = rows.length; row < rlen; row++){
  556. var r = rows[row], group, gcol = 0;
  557. for(var i = 0, len = r.length; i < len; i++){
  558. group = r[i];
  559. if(col >= gcol && col < gcol + group.colspan){
  560. break;
  561. }
  562. gcol += group.colspan;
  563. }
  564. if(group && group.header){
  565. if(cm.hierarchicalColMenu){
  566. var gid = 'group-' + row + '-' + gcol,
  567. item = menu.items ? menu.getComponent(gid) : null,
  568. submenu = item ? item.menu : null;
  569. if(!submenu){
  570. submenu = new Ext.menu.Menu({
  571. itemId: gid
  572. });
  573. submenu.on("itemclick", this.handleHdMenuClick, this);
  574. var checked = false, disabled = true;
  575. for(var c = gcol, lc = gcol + group.colspan; c < lc; c++){
  576. if(!cm.isHidden(c)){
  577. checked = true;
  578. }
  579. if(cm.config[c].hideable !== false){
  580. disabled = false;
  581. }
  582. }
  583. menu.add({
  584. itemId: gid,
  585. text: group.header,
  586. menu: submenu,
  587. hideOnClick: false,
  588. checked: checked,
  589. disabled: disabled
  590. });
  591. }
  592. menu = submenu;
  593. }else{
  594. text.push(group.header);
  595. }
  596. }
  597. }
  598. text.push(title);
  599. menu.add(new Ext.menu.CheckItem({
  600. itemId: "col-" + cm.getColumnId(col),
  601. text: text.join(' '),
  602. checked: !cm.isHidden(col),
  603. hideOnClick: false,
  604. disabled: cm.config[col].hideable === false
  605. }));
  606. }
  607. }
  608. },
  609. afterRenderUI: function(){
  610. this.constructor.prototype.afterRenderUI.apply(this, arguments);
  611. Ext.apply(this.columnDrop, Ext.ux.grid.ColumnHeaderGroup.prototype.columnDropConfig);
  612. Ext.apply(this.splitZone, Ext.ux.grid.ColumnHeaderGroup.prototype.splitZoneConfig);
  613. }
  614. },
  615. splitZoneConfig: {
  616. allowHeaderDrag: function(e){
  617. return !e.getTarget(null, null, true).hasClass('ux-grid-hd-group-cell');
  618. }
  619. },
  620. columnDropConfig: {
  621. getTargetFromEvent: function(e){
  622. var t = Ext.lib.Event.getTarget(e);
  623. return this.view.findHeaderCell(t);
  624. },
  625. positionIndicator: function(h, n, e){
  626. var data = Ext.ux.grid.ColumnHeaderGroup.prototype.getDragDropData.call(this, h, n, e);
  627. if(data === false){
  628. return false;
  629. }
  630. var px = data.px + this.proxyOffsets[0];
  631. this.proxyTop.setLeftTop(px, data.r.top + this.proxyOffsets[1]);
  632. this.proxyTop.show();
  633. this.proxyBottom.setLeftTop(px, data.r.bottom);
  634. this.proxyBottom.show();
  635. return data.pt;
  636. },
  637. onNodeDrop: function(n, dd, e, data){
  638. var h = data.header;
  639. if(h != n){
  640. var d = Ext.ux.grid.ColumnHeaderGroup.prototype.getDragDropData.call(this, h, n, e);
  641. if(d === false){
  642. return false;
  643. }
  644. var cm = this.grid.colModel, right = d.oldIndex < d.newIndex, rows = cm.rows;
  645. for(var row = d.row, rlen = rows.length; row < rlen; row++){
  646. var r = rows[row], len = r.length, fromIx = 0, span = 1, toIx = len;
  647. for(var i = 0, gcol = 0; i < len; i++){
  648. var group = r[i];
  649. if(d.oldIndex >= gcol && d.oldIndex < gcol + group.colspan){
  650. fromIx = i;
  651. }
  652. if(d.oldIndex + d.colspan - 1 >= gcol && d.oldIndex + d.colspan - 1 < gcol + group.colspan){
  653. span = i - fromIx + 1;
  654. }
  655. if(d.newIndex >= gcol && d.newIndex < gcol + group.colspan){
  656. toIx = i;
  657. }
  658. gcol += group.colspan;
  659. }
  660. var groups = r.splice(fromIx, span);
  661. rows[row] = r.splice(0, toIx - (right ? span : 0)).concat(groups).concat(r);
  662. }
  663. for(var c = 0; c < d.colspan; c++){
  664. var oldIx = d.oldIndex + (right ? 0 : c), newIx = d.newIndex + (right ? -1 : c);
  665. cm.moveColumn(oldIx, newIx);
  666. this.grid.fireEvent("columnmove", oldIx, newIx);
  667. }
  668. return true;
  669. }
  670. return false;
  671. }
  672. },
  673. getGroupStyle: function(group, gcol){
  674. var width = 0, hidden = true;
  675. for(var i = gcol, len = gcol + group.colspan; i < len; i++){
  676. if(!this.cm.isHidden(i)){
  677. var cw = this.cm.getColumnWidth(i);
  678. if(typeof cw == 'number'){
  679. width += cw;
  680. }
  681. hidden = false;
  682. }
  683. }
  684. return {
  685. width: (Ext.isBorderBox || (Ext.isWebKit && !Ext.isSafari2) ? width : Math.max(width - this.borderWidth, 0)) + 'px',
  686. hidden: hidden
  687. };
  688. },
  689. updateGroupStyles: function(col){
  690. var tables = this.mainHd.query('.x-grid3-header-offset > table'), tw = this.getTotalWidth(), rows = this.cm.rows;
  691. for(var row = 0; row < tables.length; row++){
  692. tables[row].style.width = tw;
  693. if(row < rows.length){
  694. var cells = tables[row].firstChild.firstChild.childNodes;
  695. for(var i = 0, gcol = 0; i < cells.length; i++){
  696. var group = rows[row][i];
  697. if((typeof col != 'number') || (col >= gcol && col < gcol + group.colspan)){
  698. var gs = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupStyle.call(this, group, gcol);
  699. cells[i].style.width = gs.width;
  700. cells[i].style.display = gs.hidden ? 'none' : '';
  701. }
  702. gcol += group.colspan;
  703. }
  704. }
  705. }
  706. },
  707. getGroupRowIndex: function(el){
  708. if(el){
  709. var m = el.className.match(this.hrowRe);
  710. if(m && m[1]){
  711. return parseInt(m[1], 10);
  712. }
  713. }
  714. return this.cm.rows.length;
  715. },
  716. getGroupSpan: function(row, col){
  717. if(row < 0){
  718. return {
  719. col: 0,
  720. colspan: this.cm.getColumnCount()
  721. };
  722. }
  723. var r = this.cm.rows[row];
  724. if(r){
  725. for(var i = 0, gcol = 0, len = r.length; i < len; i++){
  726. var group = r[i];
  727. if(col >= gcol && col < gcol + group.colspan){
  728. return {
  729. col: gcol,
  730. colspan: group.colspan
  731. };
  732. }
  733. gcol += group.colspan;
  734. }
  735. return {
  736. col: gcol,
  737. colspan: 0
  738. };
  739. }
  740. return {
  741. col: col,
  742. colspan: 1
  743. };
  744. },
  745. getDragDropData: function(h, n, e){
  746. if(h.parentNode != n.parentNode){
  747. return false;
  748. }
  749. var cm = this.grid.colModel, x = Ext.lib.Event.getPageX(e), r = Ext.lib.Dom.getRegion(n.firstChild), px, pt;
  750. if((r.right - x) <= (r.right - r.left) / 2){
  751. px = r.right + this.view.borderWidth;
  752. pt = "after";
  753. }else{
  754. px = r.left;
  755. pt = "before";
  756. }
  757. var oldIndex = this.view.getCellIndex(h), newIndex = this.view.getCellIndex(n);
  758. if(cm.isFixed(newIndex)){
  759. return false;
  760. }
  761. var row = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupRowIndex.call(this.view, h),
  762. oldGroup = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupSpan.call(this.view, row, oldIndex),
  763. newGroup = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupSpan.call(this.view, row, newIndex),
  764. oldIndex = oldGroup.col;
  765. newIndex = newGroup.col + (pt == "after" ? newGroup.colspan : 0);
  766. if(newIndex >= oldGroup.col && newIndex <= oldGroup.col + oldGroup.colspan){
  767. return false;
  768. }
  769. var parentGroup = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupSpan.call(this.view, row - 1, oldIndex);
  770. if(newIndex < parentGroup.col || newIndex > parentGroup.col + parentGroup.colspan){
  771. return false;
  772. }
  773. return {
  774. r: r,
  775. px: px,
  776. pt: pt,
  777. row: row,
  778. oldIndex: oldIndex,
  779. newIndex: newIndex,
  780. colspan: oldGroup.colspan
  781. };
  782. }
  783. });Ext.ns('Ext.ux.tree');
  784. <div id="cls-Ext.ux.tree.ColumnTree"></div>/**
  785. * @class Ext.ux.tree.ColumnTree
  786. * @extends Ext.tree.TreePanel
  787. *
  788. * @xtype columntree
  789. */
  790. Ext.ux.tree.ColumnTree = Ext.extend(Ext.tree.TreePanel, {
  791. lines : false,
  792. borderWidth : Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
  793. cls : 'x-column-tree',
  794. onRender : function(){
  795. Ext.tree.ColumnTree.superclass.onRender.apply(this, arguments);
  796. this.headers = this.header.createChild({cls:'x-tree-headers'});
  797. var cols = this.columns, c;
  798. var totalWidth = 0;
  799. var scrollOffset = 19; // similar to Ext.grid.GridView default
  800. for(var i = 0, len = cols.length; i < len; i++){
  801. c = cols[i];
  802. totalWidth += c.width;
  803. this.headers.createChild({
  804. cls:'x-tree-hd ' + (c.cls?c.cls+'-hd':''),
  805. cn: {
  806. cls:'x-tree-hd-text',
  807. html: c.header
  808. },
  809. style:'width:'+(c.width-this.borderWidth)+'px;'
  810. });
  811. }
  812. this.headers.createChild({cls:'x-clear'});
  813. // prevent floats from wrapping when clipped
  814. this.headers.setWidth(totalWidth+scrollOffset);
  815. this.innerCt.setWidth(totalWidth);
  816. }
  817. });
  818. Ext.reg('columntree', Ext.ux.tree.ColumnTree);
  819. //backwards compat
  820. Ext.tree.ColumnTree = Ext.ux.tree.ColumnTree;
  821. <div id="cls-Ext.ux.tree.ColumnNodeUI"></div>/**
  822. * @class Ext.ux.tree.ColumnNodeUI
  823. * @extends Ext.tree.TreeNodeUI
  824. */
  825. Ext.ux.tree.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  826. focus: Ext.emptyFn, // prevent odd scrolling behavior
  827. renderElements : function(n, a, targetNode, bulkRender){
  828. this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
  829. var t = n.getOwnerTree();
  830. var cols = t.columns;
  831. var bw = t.borderWidth;
  832. var c = cols[0];
  833. var buf = [
  834. '<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf ', a.cls,'">',
  835. '<div class="x-tree-col" style="width:',c.width-bw,'px;">',
  836. '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
  837. '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow">',
  838. '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on">',
  839. '<a hidefocus="on" class="x-tree-node-anchor" href="',a.href ? a.href : "#",'" tabIndex="1" ',
  840. a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '>',
  841. '<span unselectable="on">', n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</span></a>",
  842. "</div>"];
  843. for(var i = 1, len = cols.length; i < len; i++){
  844. c = cols[i];
  845. buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',
  846. '<div class="x-tree-col-text">',(c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</div>",
  847. "</div>");
  848. }
  849. buf.push(
  850. '<div class="x-clear"></div></div>',
  851. '<ul class="x-tree-node-ct" style="display:none;"></ul>',
  852. "</li>");
  853. if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
  854. this.wrap = Ext.DomHelper.insertHtml("beforeBegin",
  855. n.nextSibling.ui.getEl(), buf.join(""));
  856. }else{
  857. this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(""));
  858. }
  859. this.elNode = this.wrap.childNodes[0];
  860. this.ctNode = this.wrap.childNodes[1];
  861. var cs = this.elNode.firstChild.childNodes;
  862. this.indentNode = cs[0];
  863. this.ecNode = cs[1];
  864. this.iconNode = cs[2];
  865. this.anchor = cs[3];
  866. this.textNode = cs[3].firstChild;
  867. }
  868. });
  869. //backwards compat
  870. Ext.tree.ColumnNodeUI = Ext.ux.tree.ColumnNodeUI;
  871. <div id="cls-Ext.DataView.LabelEditor"></div>/**
  872. * @class Ext.DataView.LabelEditor
  873. * @extends Ext.Editor
  874. *
  875. */
  876. Ext.DataView.LabelEditor = Ext.extend(Ext.Editor, {
  877. alignment: "tl-tl",
  878. hideEl : false,
  879. cls: "x-small-editor",
  880. shim: false,
  881. completeOnEnter: true,
  882. cancelOnEsc: true,
  883. labelSelector: 'span.x-editable',
  884. constructor: function(cfg, field){
  885. Ext.DataView.LabelEditor.superclass.constructor.call(this,
  886. field || new Ext.form.TextField({
  887. allowBlank: false,
  888. growMin:90,
  889. growMax:240,
  890. grow:true,
  891. selectOnFocus:true
  892. }), cfg
  893. );
  894. },
  895. init : function(view){
  896. this.view = view;
  897. view.on('render', this.initEditor, this);
  898. this.on('complete', this.onSave, this);
  899. },
  900. initEditor : function(){
  901. this.view.on({
  902. scope: this,
  903. containerclick: this.doBlur,
  904. click: this.doBlur
  905. });
  906. this.view.getEl().on('mousedown', this.onMouseDown, this, {delegate: this.labelSelector});
  907. },
  908. doBlur: function(){
  909. if(this.editing){
  910. this.field.blur();
  911. }
  912. },
  913. onMouseDown : function(e, target){
  914. if(!e.ctrlKey && !e.shiftKey){
  915. var item = this.view.findItemFromChild(target);
  916. e.stopEvent();
  917. var record = this.view.store.getAt(this.view.indexOf(item));
  918. this.startEdit(target, record.data[this.dataIndex]);
  919. this.activeRecord = record;
  920. }else{
  921. e.preventDefault();
  922. }
  923. },
  924. onSave : function(ed, value){
  925. this.activeRecord.set(this.dataIndex, value);
  926. }
  927. });
  928. Ext.DataView.DragSelector = function(cfg){
  929. cfg = cfg || {};
  930. var view, proxy, tracker;
  931. var rs, bodyRegion, dragRegion = new Ext.lib.Region(0,0,0,0);
  932. var dragSafe = cfg.dragSafe === true;
  933. this.init = function(dataView){
  934. view = dataView;
  935. view.on('render', onRender);
  936. };
  937. function fillRegions(){
  938. rs = [];
  939. view.all.each(function(el){
  940. rs[rs.length] = el.getRegion();
  941. });
  942. bodyRegion = view.el.getRegion();
  943. }
  944. function cancelClick(){
  945. return false;
  946. }
  947. function onBeforeStart(e){
  948. return !dragSafe || e.target == view.el.dom;
  949. }
  950. function onStart(e){
  951. view.on('containerclick', cancelClick, view, {single:true});
  952. if(!proxy){
  953. proxy = view.el.createChild({cls:'x-view-selector'});
  954. }else{
  955. if(proxy.dom.parentNode !== view.el.dom){
  956. view.el.dom.appendChild(proxy.dom);
  957. }
  958. proxy.setDisplayed('block');
  959. }
  960. fillRegions();
  961. view.clearSelections();
  962. }
  963. function onDrag(e){
  964. var startXY = tracker.startXY;
  965. var xy = tracker.getXY();
  966. var x = Math.min(startXY[0], xy[0]);
  967. var y = Math.min(startXY[1], xy[1]);
  968. var w = Math.abs(startXY[0] - xy[0]);
  969. var h = Math.abs(startXY[1] - xy[1]);
  970. dragRegion.left = x;
  971. dragRegion.top = y;
  972. dragRegion.right = x+w;
  973. dragRegion.bottom = y+h;
  974. dragRegion.constrainTo(bodyRegion);
  975. proxy.setRegion(dragRegion);
  976. for(var i = 0, len = rs.length; i < len; i++){
  977. var r = rs[i], sel = dragRegion.intersect(r);
  978. if(sel && !r.selected){
  979. r.selected = true;
  980. view.select(i, true);
  981. }else if(!sel && r.selected){
  982. r.selected = false;
  983. view.deselect(i);
  984. }
  985. }
  986. }
  987. function onEnd(e){
  988. if (!Ext.isIE) {
  989. view.un('containerclick', cancelClick, view);
  990. }
  991. if(proxy){
  992. proxy.setDisplayed(false);
  993. }
  994. }
  995. function onRender(view){
  996. tracker = new Ext.dd.DragTracker({
  997. onBeforeStart: onBeforeStart,
  998. onStart: onStart,
  999. onDrag: onDrag,
  1000. onEnd: onEnd
  1001. });
  1002. tracker.initEl(view.el);
  1003. }
  1004. };Ext.ns('Ext.ux.form');
  1005. <div id="cls-Ext.ux.form.FileUploadField"></div>/**
  1006. * @class Ext.ux.form.FileUploadField
  1007. * @extends Ext.form.TextField
  1008. * Creates a file upload field.
  1009. * @xtype fileuploadfield
  1010. */
  1011. Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
  1012. <div id="cfg-Ext.ux.form.FileUploadField-buttonText"></div>/**
  1013. * @cfg {String} buttonText The button text to display on the upload button (defaults to
  1014. * 'Browse...'). Note that if you supply a value for {@link #buttonCfg}, the buttonCfg.text
  1015. * value will be used instead if available.
  1016. */
  1017. buttonText: 'Browse...',
  1018. <div id="cfg-Ext.ux.form.FileUploadField-buttonOnly"></div>/**
  1019. * @cfg {Boolean} buttonOnly True to display the file upload field as a button with no visible
  1020. * text field (defaults to false). If true, all inherited TextField members will still be available.
  1021. */
  1022. buttonOnly: false,
  1023. <div id="cfg-Ext.ux.form.FileUploadField-buttonOffset"></div>/**
  1024. * @cfg {Number} buttonOffset The number of pixels of space reserved between the button and the text field
  1025. * (defaults to 3). Note that this only applies if {@link #buttonOnly} = false.
  1026. */
  1027. buttonOffset: 3,
  1028. <div id="cfg-Ext.ux.form.FileUploadField-buttonCfg"></div>/**
  1029. * @cfg {Object} buttonCfg A standard {@link Ext.Button} config object.
  1030. */
  1031. // private
  1032. readOnly: true,
  1033. <div id="method-Ext.ux.form.FileUploadField-autoSize"></div>/**
  1034. * @hide
  1035. * @method autoSize
  1036. */
  1037. autoSize: Ext.emptyFn,
  1038. // private
  1039. initComponent: function(){
  1040. Ext.ux.form.FileUploadField.superclass.initComponent.call(this);
  1041. this.addEvents(
  1042. <div id="event-Ext.ux.form.FileUploadField-fileselected"></div>/**
  1043. * @event fileselected
  1044. * Fires when the underlying file input field's value has changed from the user
  1045. * selecting a new file from the system file selection dialog.
  1046. * @param {Ext.ux.form.FileUploadField} this
  1047. * @param {String} value The file value returned by the underlying file input field
  1048. */
  1049. 'fileselected'
  1050. );
  1051. },
  1052. // private
  1053. onRender : function(ct, position){
  1054. Ext.ux.form.FileUploadField.superclass.onRender.call(this, ct, position);
  1055. this.wrap = this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'});
  1056. this.el.addClass('x-form-file-text');
  1057. this.el.dom.removeAttribute('name');
  1058. this.createFileInput();
  1059. var btnCfg = Ext.applyIf(this.buttonCfg || {}, {
  1060. text: this.buttonText
  1061. });
  1062. this.button = new Ext.Button(Ext.apply(btnCfg, {
  1063. renderTo: this.wrap,
  1064. cls: 'x-form-file-btn' + (btnCfg.iconCls ? ' x-btn-icon' : '')
  1065. }));
  1066. if(this.buttonOnly){
  1067. this.el.hide();
  1068. this.wrap.setWidth(this.button.getEl().getWidth());
  1069. }
  1070. this.bindListeners();
  1071. this.resizeEl = this.positionEl = this.wrap;
  1072. },
  1073. bindListeners: function(){
  1074. this.fileInput.on({
  1075. scope: this,
  1076. mouseenter: function() {
  1077. this.button.addClass(['x-btn-over','x-btn-focus'])
  1078. },
  1079. mouseleave: function(){
  1080. this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click'])
  1081. },
  1082. mousedown: function(){
  1083. this.button.addClass('x-btn-click')
  1084. },
  1085. mouseup: function(){
  1086. this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click'])
  1087. },
  1088. change: function(){
  1089. var v = this.fileInput.dom.value;
  1090. this.setValue(v);
  1091. this.fireEvent('fileselected', this, v);
  1092. }
  1093. });
  1094. },
  1095. createFileInput : function() {
  1096. this.fileInput = this.wrap.createChild({
  1097. id: this.getFileInputId(),
  1098. name: this.name||this.getId(),
  1099. cls: 'x-form-file',
  1100. tag: 'input',
  1101. type: 'file',
  1102. size: 1
  1103. });
  1104. },
  1105. reset : function(){
  1106. this.fileInput.remove();
  1107. this.createFileInput();
  1108. this.bindListeners();
  1109. Ext.ux.form.FileUploadField.superclass.reset.call(this);
  1110. },
  1111. // private
  1112. getFileInputId: function(){
  1113. return this.id + '-file';
  1114. },
  1115. // private
  1116. onResize : function(w, h){
  1117. Ext.ux.form.FileUploadField.superclass.onResize.call(this, w, h);
  1118. this.wrap.setWidth(w);
  1119. if(!this.buttonOnly){
  1120. var w = this.wrap.getWidth() - this.button.getEl().getWidth() - this.buttonOffset;
  1121. this.el.setWidth(w);
  1122. }
  1123. },
  1124. // private
  1125. onDestroy: function(){
  1126. Ext.ux.form.FileUploadField.superclass.onDestroy.call(this);
  1127. Ext.destroy(this.fileInput, this.button, this.wrap);
  1128. },
  1129. onDisable: function(){
  1130. Ext.ux.form.FileUploadField.superclass.onDisable.call(this);
  1131. this.doDisable(true);
  1132. },
  1133. onEnable: function(){
  1134. Ext.ux.form.FileUploadField.superclass.onEnable.call(this);
  1135. this.doDisable(false);
  1136. },
  1137. // private
  1138. doDisable: function(disabled){
  1139. this.fileInput.dom.disabled = disabled;
  1140. this.button.setDisabled(disabled);
  1141. },
  1142. // private
  1143. preFocus : Ext.emptyFn,
  1144. // private
  1145. alignErrorIcon : function(){
  1146. this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
  1147. }
  1148. });
  1149. Ext.reg('fileuploadfield', Ext.ux.form.FileUploadField);
  1150. // backwards compat
  1151. Ext.form.FileUploadField = Ext.ux.form.FileUploadField;
  1152. <div id="cls-Ext.ux.GMapPanel"></div>/**
  1153. * @class Ext.ux.GMapPanel
  1154. * @extends Ext.Panel
  1155. * @author Shea Frederick
  1156. */
  1157. Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
  1158. initComponent : function(){
  1159. var defConfig = {
  1160. plain: true,
  1161. zoomLevel: 3,
  1162. yaw: 180,
  1163. pitch: 0,
  1164. zoom: 0,
  1165. gmapType: 'map',
  1166. border: false
  1167. };
  1168. Ext.applyIf(this,defConfig);
  1169. Ext.ux.GMapPanel.superclass.initComponent.call(this);
  1170. },
  1171. afterRender : function(){
  1172. var wh = this.ownerCt.getSize();
  1173. Ext.applyIf(this, wh);
  1174. Ext.ux.GMapPanel.superclass.afterRender.call(this);
  1175. if (this.gmapType === 'map'){
  1176. this.gmap = new GMap2(this.body.dom);
  1177. }
  1178. if (this.gmapType === 'panorama'){
  1179. this.gmap = new GStreetviewPanorama(this.body.dom);
  1180. }
  1181. if (typeof this.addControl == 'object' && this.gmapType === 'map') {
  1182. this.gmap.addControl(this.addControl);
  1183. }
  1184. if (typeof this.setCenter === 'object') {
  1185. if (typeof this.setCenter.geoCodeAddr === 'string'){
  1186. this.geoCodeLookup(this.setCenter.geoCodeAddr);
  1187. }else{
  1188. if (this.gmapType === 'map'){
  1189. var point = new GLatLng(this.setCenter.lat,this.setCenter.lng);
  1190. this.gmap.setCenter(point, this.zoomLevel);
  1191. }
  1192. if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){
  1193. this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear);
  1194. }
  1195. }
  1196. if (this.gmapType === 'panorama'){
  1197. this.gmap.setLocationAndPOV(new GLatLng(this.setCenter.lat,this.setCenter.lng), {yaw: this.yaw, pitch: this.pitch, zoom: this.zoom});
  1198. }
  1199. }
  1200. GEvent.bind(this.gmap, 'load', this, function(){
  1201. this.onMapReady();
  1202. });
  1203. },
  1204. onMapReady : function(){
  1205. this.addMarkers(this.markers);
  1206. this.addMapControls();
  1207. this.addOptions();
  1208. },
  1209. onResize : function(w, h){
  1210. if (typeof this.getMap() == 'object') {
  1211. this.gmap.checkResize();
  1212. }
  1213. Ext.ux.GMapPanel.superclass.onResize.call(this, w, h);
  1214. },
  1215. setSize : function(width, height, animate){
  1216. if (typeof this.getMap() == 'object') {
  1217. this.gmap.checkResize();
  1218. }
  1219. Ext.ux.GMapPanel.superclass.setSize.call(this, width, height, animate);
  1220. },
  1221. getMap : function(){
  1222. return this.gmap;
  1223. },
  1224. getCenter : function(){
  1225. return this.getMap().getCenter();
  1226. },
  1227. getCenterLatLng : function(){
  1228. var ll = this.getCenter();
  1229. return {lat: ll.lat(), lng: ll.lng()};
  1230. },
  1231. addMarkers : function(markers) {
  1232. if (Ext.isArray(markers)){
  1233. for (var i = 0; i < markers.length; i++) {
  1234. var mkr_point = new GLatLng(markers[i].lat,markers[i].lng);
  1235. this.addMarker(mkr_point,markers[i].marker,false,markers[i].setCenter, markers[i].listeners);
  1236. }
  1237. }
  1238. },
  1239. addMarker : function(point, marker, clear, center, listeners){
  1240. Ext.applyIf(marker,G_DEFAULT_ICON);
  1241. if (clear === true){
  1242. this.getMap().clearOverlays();
  1243. }
  1244. if (center === true) {
  1245. this.getMap().setCenter(point, this.zoomLevel);
  1246. }
  1247. var mark = new GMarker(point,marker);
  1248. if (typeof listeners === 'object'){
  1249. for (evt in listeners) {
  1250. GEvent.bind(mark, evt, this, listeners[evt]);
  1251. }
  1252. }
  1253. this.getMap().addOverlay(mark);
  1254. },
  1255. addMapControls : function(){
  1256. if (this.gmapType === 'map') {
  1257. if (Ext.isArray(this.mapControls)) {
  1258. for(i=0;i<this.mapControls.length;i++){
  1259. this.addMapControl(this.mapControls[i]);
  1260. }
  1261. }else if(typeof this.mapControls === 'string'){
  1262. this.addMapControl(this.mapControls);
  1263. }else if(typeof this.mapControls === 'object'){
  1264. this.getMap().addControl(this.mapControls);
  1265. }
  1266. }
  1267. },
  1268. addMapControl : function(mc){
  1269. var mcf = window[mc];
  1270. if (typeof mcf === 'function') {
  1271. this.getMap().addControl(new mcf());
  1272. }
  1273. },
  1274. addOptions : function(){
  1275. if (Ext.isArray(this.mapConfOpts)) {
  1276. var mc;
  1277. for(i=0;i<this.mapConfOpts.length;i++){
  1278. this.addOption(this.mapConfOpts[i]);
  1279. }
  1280. }else if(typeof this.mapConfOpts === 'string'){
  1281. this.addOption(this.mapConfOpts);
  1282. }
  1283. },
  1284. addOption : function(mc){
  1285. var mcf = this.getMap()[mc];
  1286. if (typeof mcf === 'function') {
  1287. this.getMap()[mc]();
  1288. }
  1289. },
  1290. geoCodeLookup : function(addr) {
  1291. this.geocoder = new GClientGeocoder();
  1292. this.geocoder.getLocations(addr, this.addAddressToMap.createDelegate(this));
  1293. },
  1294. addAddressToMap : function(response) {
  1295. if (!response || response.Status.code != 200) {
  1296. Ext.MessageBox.alert('Error', 'Code '+response.Status.code+' Error Returned');
  1297. }else{
  1298. place = response.Placemark[0];
  1299. addressinfo = place.AddressDetails;
  1300. accuracy = addressinfo.Accuracy;
  1301. if (accuracy === 0) {
  1302. Ext.MessageBox.alert('Unable to Locate Address', 'Unable to Locate the Address you provided');
  1303. }else{
  1304. if (accuracy < 7) {
  1305. Ext.MessageBox.alert('Address Accuracy', 'The address provided has a low accuracy.<br><br>Level '+accuracy+' Accuracy (8 = Exact Match, 1 = Vague Match)');
  1306. }else{
  1307. point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
  1308. if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){
  1309. this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear,true, this.setCenter.listeners);
  1310. }
  1311. }
  1312. }
  1313. }
  1314. }
  1315. });
  1316. Ext.reg('gmappanel', Ext.ux.GMapPanel); Ext.namespace('Ext.ux.grid');
  1317. /**
  1318. * @class Ext.ux.grid.GridFilters
  1319. * @extends Ext.util.Observable
  1320. * <p>GridFilter is a plugin (<code>ptype='gridfilters'</code>) for grids that
  1321. * allow for a slightly more robust representation of filtering than what is
  1322. * provided by the default store.</p>
  1323. * <p>Filtering is adjusted by the user using the grid's column header menu
  1324. * (this menu can be disabled through configuration). Through this menu users
  1325. * can configure, enable, and disable filters for each column.</p>
  1326. * <p><b><u>Features:</u></b></p>
  1327. * <div class="mdetail-params"><ul>
  1328. * <li><b>Filtering implementations</b> :
  1329. * <div class="sub-desc">
  1330. * Default filtering for Strings, Numeric Ranges, Date Ranges, Lists (which can
  1331. * be backed by a Ext.data.Store), and Boolean. Additional custom filter types
  1332. * and menus are easily created by extending Ext.ux.grid.filter.Filter.
  1333. * </div></li>
  1334. * <li><b>Graphical indicators</b> :
  1335. * <div class="sub-desc">
  1336. * Columns that are filtered have {@link #filterCls a configurable css class}
  1337. * applied to the column headers.
  1338. * </div></li>
  1339. * <li><b>Paging</b> :
  1340. * <div class="sub-desc">
  1341. * If specified as a plugin to the grid's configured PagingToolbar, the current page
  1342. * will be reset to page 1 whenever you update the filters.
  1343. * </div></li>
  1344. * <li><b>Automatic Reconfiguration</b> :
  1345. * <div class="sub-desc">
  1346. * Filters automatically reconfigure when the grid 'reconfigure' event fires.
  1347. * </div></li>
  1348. * <li><b>Stateful</b> :
  1349. * Filter information will be persisted across page loads by specifying a
  1350. * <code>stateId</code> in the Grid configuration.
  1351. * <div class="sub-desc">
  1352. * The filter collection binds to the
  1353. * <code>{@link Ext.grid.GridPanel#beforestaterestore beforestaterestore}</code>
  1354. * and <code>{@link Ext.grid.GridPanel#beforestatesave beforestatesave}</code>
  1355. * events in order to be stateful.
  1356. * </div></li>
  1357. * <li><b>Grid Changes</b> :
  1358. * <div class="sub-desc"><ul>
  1359. * <li>A <code>filters</code> <i>property</i> is added to the grid pointing to
  1360. * this plugin.</li>
  1361. * <li>A <code>filterupdate</code> <i>event</i> is added to the grid and is
  1362. * fired upon onStateChange completion.</li>
  1363. * </ul></div></li>
  1364. * <li><b>Server side code examples</b> :
  1365. * <div class="sub-desc"><ul>
  1366. * <li><a href="http://www.vinylfox.com/extjs/grid-filter-php-backend-code.php">PHP</a> - (Thanks VinylFox)</li>
  1367. * <li><a href="http://extjs.com/forum/showthread.php?p=77326#post77326">Ruby on Rails</a> - (Thanks Zyclops)</li>
  1368. * <li><a href="http://extjs.com/forum/showthread.php?p=176596#post176596">Ruby on Rails</a> - (Thanks Rotomaul)</li>
  1369. * <li><a href="http://www.debatablybeta.com/posts/using-extjss-grid-filtering-with-django/">Python</a> - (Thanks Matt)</li>
  1370. * <li><a href="http://mcantrell.wordpress.com/2008/08/22/extjs-grids-and-grails/">Grails</a> - (Thanks Mike)</li>
  1371. * </ul></div></li>
  1372. * </ul></div>
  1373. * <p><b><u>Example usage:</u></b></p>
  1374. * <pre><code>
  1375. var store = new Ext.data.GroupingStore({
  1376. ...
  1377. });
  1378. var filters = new Ext.ux.grid.GridFilters({
  1379. autoReload: false, //don&#39;t reload automatically
  1380. local: true, //only filter locally
  1381. // filters may be configured through the plugin,
  1382. // or in the column definition within the column model configuration
  1383. filters: [{
  1384. type: 'numeric',
  1385. dataIndex: 'id'
  1386. }, {
  1387. type: 'string',
  1388. dataIndex: 'name'
  1389. }, {
  1390. type: 'numeric',
  1391. dataIndex: 'price'
  1392. }, {
  1393. type: 'date',
  1394. dataIndex: 'dateAdded'
  1395. }, {
  1396. type: 'list',
  1397. dataIndex: 'size',
  1398. options: ['extra small', 'small', 'medium', 'large', 'extra large'],
  1399. phpMode: true
  1400. }, {
  1401. type: 'boolean',
  1402. dataIndex: 'visible'
  1403. }]
  1404. });
  1405. var cm = new Ext.grid.ColumnModel([{
  1406. ...
  1407. }]);
  1408. var grid = new Ext.grid.GridPanel({
  1409. ds: store,
  1410. cm: cm,
  1411. view: new Ext.grid.GroupingView(),
  1412. plugins: [filters],
  1413. height: 400,
  1414. width: 700,
  1415. bbar: new Ext.PagingToolbar({
  1416. store: store,
  1417. pageSize: 15,
  1418. plugins: [filters] //reset page to page 1 if filters change
  1419. })
  1420. });
  1421. store.load({params: {start: 0, limit: 15}});
  1422. // a filters property is added to the grid
  1423. grid.filters
  1424. * </code></pre>
  1425. */
  1426. Ext.ux.grid.GridFilters = Ext.extend(Ext.util.Observable, {
  1427. <div id="cfg-Ext.ux.grid.GridFilters-autoReload"></div>/**
  1428. * @cfg {Boolean} autoReload
  1429. * Defaults to true, reloading the datasource when a filter change happens.
  1430. * Set this to false to prevent the datastore from being reloaded if there
  1431. * are changes to the filters. See <code>{@link updateBuffer}</code>.
  1432. */
  1433. autoReload : true,
  1434. <div id="cfg-Ext.ux.grid.GridFilters-encode"></div>/**
  1435. * @cfg {Boolean} encode
  1436. * Specify true for {@link #buildQuery} to use Ext.util.JSON.encode to
  1437. * encode the filter query parameter sent with a remote request.
  1438. * Defaults to false.
  1439. */
  1440. <div id="cfg-Ext.ux.grid.GridFilters-filters"></div>/**
  1441. * @cfg {Array} filters
  1442. * An Array of filters config objects. Refer to each filter type class for
  1443. * configuration details specific to each filter type. Filters for Strings,
  1444. * Numeric Ranges, Date Ranges, Lists, and Boolean are the standard filters
  1445. * available.
  1446. */
  1447. <div id="cfg-Ext.ux.grid.GridFilters-filterCls"></div>/**
  1448. * @cfg {String} filterCls
  1449. * The css class to be applied to column headers with active filters.
  1450. * Defaults to <tt>'ux-filterd-column'</tt>.
  1451. */
  1452. filterCls : 'ux-filtered-column',
  1453. <div id="cfg-Ext.ux.grid.GridFilters-local"></div>/**
  1454. * @cfg {Boolean} local
  1455. * <tt>true</tt> to use Ext.data.Store filter functions (local filtering)
  1456. * instead of the default (<tt>false</tt>) server side filtering.
  1457. */
  1458. local : false,
  1459. <div id="cfg-Ext.ux.grid.GridFilters-menuFilterText"></div>/**
  1460. * @cfg {String} menuFilterText
  1461. * defaults to <tt>'Filters'</tt>.
  1462. */
  1463. menuFilterText : 'Filters',
  1464. <div id="cfg-Ext.ux.grid.GridFilters-paramPrefix"></div>/**
  1465. * @cfg {String} paramPrefix
  1466. * The url parameter prefix for the filters.
  1467. * Defaults to <tt>'filter'</tt>.
  1468. */
  1469. paramPrefix : 'filter',
  1470. <div id="cfg-Ext.ux.grid.GridFilters-showMenu"></div>/**
  1471. * @cfg {Boolean} showMenu
  1472. * Defaults to true, including a filter submenu in the default header menu.
  1473. */
  1474. showMenu : true,
  1475. <div id="cfg-Ext.ux.grid.GridFilters-stateId"></div>/**
  1476. * @cfg {String} stateId
  1477. * Name of the value to be used to store state information.
  1478. */
  1479. stateId : undefined,
  1480. <div id="cfg-Ext.ux.grid.GridFilters-updateBuffer"></div>/**
  1481. * @cfg {Integer} updateBuffer
  1482. * Number of milliseconds to defer store updates since the last filter change.
  1483. */
  1484. updateBuffer : 500,
  1485. /** @private */
  1486. constructor : function (config) {
  1487. config = config || {};
  1488. this.deferredUpdate = new Ext.util.DelayedTask(this.reload, this);
  1489. this.filters = new Ext.util.MixedCollection();
  1490. this.filters.getKey = function (o) {
  1491. return o ? o.dataIndex : null;
  1492. };
  1493. this.addFilters(config.filters);
  1494. delete config.filters;
  1495. Ext.apply(this, config);
  1496. },
  1497. /** @private */
  1498. init : function (grid) {
  1499. if (grid instanceof Ext.grid.GridPanel) {
  1500. this.grid = grid;
  1501. this.bindStore(this.grid.getStore(), true);
  1502. // assumes no filters were passed in the constructor, so try and use ones from the colModel
  1503. if(this.filters.getCount() == 0){
  1504. this.addFilters(this.grid.getColumnModel());
  1505. }
  1506. this.grid.filters = this;
  1507. this.grid.addEvents({'filterupdate': true});
  1508. grid.on({
  1509. scope: this,
  1510. beforestaterestore: this.applyState,
  1511. beforestatesave: this.saveState,
  1512. beforedestroy: this.destroy,
  1513. reconfigure: this.onReconfigure
  1514. });
  1515. if (grid.rendered){
  1516. this.onRender();
  1517. } else {
  1518. grid.on({
  1519. scope: this,
  1520. single: true,
  1521. render: this.onRender
  1522. });
  1523. }
  1524. } else if (grid instanceof Ext.PagingToolbar) {
  1525. this.toolbar = grid;
  1526. }
  1527. },
  1528. /**
  1529. * @private
  1530. * Handler for the grid's beforestaterestore event (fires before the state of the
  1531. * grid is restored).
  1532. * @param {Object} grid The grid object
  1533. * @param {Object} state The hash of state values returned from the StateProvider.
  1534. */
  1535. applyState : function (grid, state) {
  1536. var key, filter;
  1537. this.applyingState = true;
  1538. this.clearFilters();
  1539. if (state.filters) {
  1540. for (key in state.filters) {
  1541. filter = this.filters.get(key);
  1542. if (filter) {
  1543. filter.setValue(state.filters[key]);
  1544. filter.setActive(true);
  1545. }
  1546. }
  1547. }
  1548. this.deferredUpdate.cancel();
  1549. if (this.local) {
  1550. this.reload();
  1551. }
  1552. delete this.applyingState;
  1553. delete state.filters;
  1554. },
  1555. <div id="method-Ext.ux.grid.GridFilters-saveState"></div>/**
  1556. * Saves the state of all active filters
  1557. * @param {Object} grid
  1558. * @param {Object} state
  1559. * @return {Boolean}
  1560. */
  1561. saveState : function (grid, state) {
  1562. var filters = {};
  1563. this.filters.each(function (filter) {
  1564. if (filter.active) {
  1565. filters[filter.dataIndex] = filter.getValue();
  1566. }
  1567. });
  1568. return (state.filters = filters);
  1569. },
  1570. /**
  1571. * @private
  1572. * Handler called when the grid is rendered
  1573. */
  1574. onRender : function () {
  1575. this.grid.getView().on('refresh', this.onRefresh, this);
  1576. this.createMenu();
  1577. },
  1578. /**
  1579. * @private
  1580. * Handler called by the grid 'beforedestroy' event
  1581. */
  1582. destroy : function () {
  1583. this.removeAll();
  1584. this.purgeListeners();
  1585. if(this.filterMenu){
  1586. Ext.menu.MenuMgr.unregister(this.filterMenu);
  1587. this.filterMenu.destroy();
  1588. this.filterMenu = this.menu.menu = null;
  1589. }
  1590. },
  1591. <div id="method-Ext.ux.grid.GridFilters-removeAll"></div>/**
  1592. * Remove all filters, permanently destroying them.
  1593. */
  1594. removeAll : function () {
  1595. if(this.filters){
  1596. Ext.destroy.apply(Ext, this.filters.items);
  1597. // remove all items from the collection
  1598. this.filters.clear();
  1599. }
  1600. },
  1601. <div id="method-Ext.ux.grid.GridFilters-bindStore"></div>/**
  1602. * Changes the data store bound to this view and refreshes it.
  1603. * @param {Store} store The store to bind to this view
  1604. */
  1605. bindStore : function(store, initial){
  1606. if(!initial && this.store){
  1607. if (this.local) {
  1608. store.un('load', this.onLoad, this);
  1609. } else {
  1610. store.un('beforeload', this.onBeforeLoad, this);
  1611. }
  1612. }
  1613. if(store){
  1614. if (this.local) {
  1615. store.on('load', this.onLoad, this);
  1616. } else {
  1617. store.on('beforeload', this.onBeforeLoad, this);
  1618. }
  1619. }
  1620. this.store = store;
  1621. },
  1622. /**
  1623. * @private
  1624. * Handler called when the grid reconfigure event fires
  1625. */
  1626. onReconfigure : function () {
  1627. this.bindStore(this.grid.getStore());
  1628. this.store.clearFilter();
  1629. this.removeAll();
  1630. this.addFilters(this.grid.getColumnModel());
  1631. this.updateColumnHeadings();
  1632. },
  1633. createMenu : function () {
  1634. var view = this.grid.getView(),
  1635. hmenu = view.hmenu;
  1636. if (this.showMenu && hmenu) {
  1637. this.sep = hmenu.addSeparator();
  1638. this.filterMenu = new Ext.menu.Menu({
  1639. id: this.grid.id + '-filters-menu'
  1640. });
  1641. this.menu = hmenu.add({
  1642. checked: false,
  1643. itemId: 'filters',
  1644. text: this.menuFilterText,
  1645. menu: this.filterMenu
  1646. });
  1647. this.menu.on({
  1648. scope: this,
  1649. checkchange: this.onCheckChange,
  1650. beforecheckchange: this.onBeforeCheck
  1651. });
  1652. hmenu.on('beforeshow', this.onMenu, this);
  1653. }
  1654. this.updateColumnHeadings();
  1655. },
  1656. /**
  1657. * @private
  1658. * Get the filter menu from the filters MixedCollection based on the clicked header
  1659. */
  1660. getMenuFilter : function () {
  1661. var view = this.grid.getView();
  1662. if (!view || view.hdCtxIndex === undefined) {
  1663. return null;
  1664. }
  1665. return this.filters.get(
  1666. view.cm.config[view.hdCtxIndex].dataIndex
  1667. );
  1668. },
  1669. /**
  1670. * @private
  1671. * Handler called by the grid's hmenu beforeshow event
  1672. */
  1673. onMenu : function (filterMenu) {
  1674. var filter = this.getMenuFilter();
  1675. if (filter) {
  1676. /*
  1677. TODO: lazy rendering
  1678. if (!filter.menu) {
  1679. filter.menu = filter.createMenu();
  1680. }
  1681. */
  1682. this.menu.menu = filter.menu;
  1683. this.menu.setChecked(filter.active, false);
  1684. // disable the menu if filter.disabled explicitly set to true
  1685. this.menu.setDisabled(filter.disabled === true);
  1686. }
  1687. this.menu.setVisible(filter !== undefined);
  1688. this.sep.setVisible(filter !== undefined);
  1689. },
  1690. /** @private */
  1691. onCheckChange : function (item, value) {
  1692. this.getMenuFilter().setActive(value);
  1693. },
  1694. /** @private */
  1695. onBeforeCheck : function (check, value) {
  1696. return !value || this.getMenuFilter().isActivatable();
  1697. },
  1698. /**
  1699. * @private
  1700. * Handler for all events on filters.
  1701. * @param {String} event Event name
  1702. * @param {Object} filter Standard signature of the event before the event is fired
  1703. */
  1704. onStateChange : function (event, filter) {
  1705. if (event === 'serialize') {
  1706. return;
  1707. }
  1708. if (filter == this.getMenuFilter()) {
  1709. this.menu.setChecked(filter.active, false);
  1710. }
  1711. if ((this.autoReload || this.local) && !this.applyingState) {
  1712. this.deferredUpdate.delay(this.updateBuffer);
  1713. }
  1714. this.updateColumnHeadings();
  1715. if (!this.applyingState) {
  1716. this.grid.saveState();
  1717. }
  1718. this.grid.fireEvent('filterupdate', this, filter);
  1719. },
  1720. /**
  1721. * @private
  1722. * Handler for store's beforeload event when configured for remote filtering
  1723. * @param {Object} store
  1724. * @param {Object} options
  1725. */
  1726. onBeforeLoad : function (store, options) {
  1727. options.params = options.params || {};
  1728. this.cleanParams(options.params);
  1729. var params = this.buildQuery(this.getFilterData());
  1730. Ext.apply(options.params, params);
  1731. },
  1732. /**
  1733. * @private
  1734. * Handler for store's load event when configured for local filtering
  1735. * @param {Object} store
  1736. * @param {Object} options
  1737. */
  1738. onLoad : function (store, options) {
  1739. store.filterBy(this.getRecordFilter());
  1740. },
  1741. /**
  1742. * @private
  1743. * Handler called when the grid's view is refreshed
  1744. */
  1745. onRefresh : function () {
  1746. this.updateColumnHeadings();
  1747. },
  1748. <div id="method-Ext.ux.grid.GridFilters-updateColumnHeadings"></div>/**
  1749. * Update the styles for the header row based on the active filters
  1750. */
  1751. updateColumnHeadings : function () {
  1752. var view = this.grid.getView(),
  1753. i, len, filter;
  1754. if (view.mainHd) {
  1755. for (i = 0, len = view.cm.config.length; i < len; i++) {
  1756. filter = this.getFilter(view.cm.config[i].dataIndex);
  1757. Ext.fly(view.getHeaderCell(i))[filter && filter.active ? 'addClass' : 'removeClass'](this.filterCls);
  1758. }
  1759. }
  1760. },
  1761. /** @private */
  1762. reload : function () {
  1763. if (this.local) {
  1764. this.grid.store.clearFilter(true);
  1765. this.grid.store.filterBy(this.getRecordFilter());
  1766. } else {
  1767. var start,
  1768. store = this.grid.store;
  1769. this.deferredUpdate.cancel();
  1770. if (this.toolbar) {
  1771. start = store.paramNames.start;
  1772. if (store.lastOptions && store.lastOptions.params && store.lastOptions.params[start]) {
  1773. store.lastOptions.params[start] = 0;
  1774. }
  1775. }
  1776. store.reload();
  1777. }
  1778. },
  1779. /**
  1780. * Method factory that generates a record validator for the filters active at the time
  1781. * of invokation.
  1782. * @private
  1783. */
  1784. getRecordFilter : function () {
  1785. var f = [], len, i;
  1786. this.filters.each(function (filter) {
  1787. if (filter.active) {
  1788. f.push(filter);
  1789. }
  1790. });
  1791. len = f.length;
  1792. return function (record) {
  1793. for (i = 0; i < len; i++) {
  1794. if (!f[i].validateRecord(record)) {
  1795. return false;
  1796. }
  1797. }
  1798. return true;
  1799. };
  1800. },
  1801. <div id="method-Ext.ux.grid.GridFilters-addFilter"></div>/**
  1802. * Adds a filter to the collection and observes it for state change.
  1803. * @param {Object/Ext.ux.grid.filter.Filter} config A filter configuration or a filter object.
  1804. * @return {Ext.ux.grid.filter.Filter} The existing or newly created filter object.
  1805. */
  1806. addFilter : function (config) {
  1807. var Cls = this.getFilterClass(config.type),
  1808. filter = config.menu ? config : (new Cls(config));
  1809. this.filters.add(filter);
  1810. Ext.util.Observable.capture(filter, this.onStateChange, this);
  1811. return filter;
  1812. },
  1813. <div id="method-Ext.ux.grid.GridFilters-addFilters"></div>/**
  1814. * Adds filters to the collection.
  1815. * @param {Array/Ext.grid.ColumnModel} filters Either an Array of
  1816. * filter configuration objects or an Ext.grid.ColumnModel. The columns
  1817. * of a passed Ext.grid.ColumnModel will be examined for a <code>filter</code>
  1818. * property and, if present, will be used as the filter configuration object.
  1819. */
  1820. addFilters : function (filters) {
  1821. if (filters) {
  1822. var i, len, filter, cm = false, dI;
  1823. if (filters instanceof Ext.grid.ColumnModel) {
  1824. filters = filters.config;
  1825. cm = true;
  1826. }
  1827. for (i = 0, len = filters.length; i < len; i++) {
  1828. filter = false;
  1829. if (cm) {
  1830. dI = filters[i].dataIndex;
  1831. filter = filters[i].filter || filters[i].filterable;
  1832. if (filter){
  1833. filter = (filter === true) ? {} : filter;
  1834. Ext.apply(filter, {dataIndex:dI});
  1835. // filter type is specified in order of preference:
  1836. // filter type specified in config
  1837. // type specified in store's field's type config
  1838. filter.type = filter.type || this.store.fields.get(dI).type.type;
  1839. }
  1840. } else {
  1841. filter = filters[i];
  1842. }
  1843. // if filter config found add filter for the column
  1844. if (filter) {
  1845. this.addFilter(filter);
  1846. }
  1847. }
  1848. }
  1849. },
  1850. <div id="method-Ext.ux.grid.GridFilters-getFilter"></div>/**
  1851. * Returns a filter for the given dataIndex, if one exists.
  1852. * @param {String} dataIndex The dataIndex of the desired filter object.
  1853. * @return {Ext.ux.grid.filter.Filter}
  1854. */
  1855. getFilter : function (dataIndex) {
  1856. return this.filters.get(dataIndex);
  1857. },
  1858. <div id="method-Ext.ux.grid.GridFilters-clearFilters"></div>/**
  1859. * Turns all filters off. This does not clear the configuration information
  1860. * (see {@link #removeAll}).
  1861. */
  1862. clearFilters : function () {
  1863. this.filters.each(function (filter) {
  1864. filter.setActive(false);
  1865. });
  1866. },
  1867. <div id="method-Ext.ux.grid.GridFilters-getFilterData"></div>/**
  1868. * Returns an Array of the currently active filters.
  1869. * @return {Array} filters Array of the currently active filters.
  1870. */
  1871. getFilterData : function () {
  1872. var filters = [], i, len;
  1873. this.filters.each(function (f) {
  1874. if (f.active) {
  1875. var d = [].concat(f.serialize());
  1876. for (i = 0, len = d.length; i < len; i++) {
  1877. filters.push({
  1878. field: f.dataIndex,
  1879. data: d[i]
  1880. });
  1881. }
  1882. }
  1883. });
  1884. return filters;
  1885. },
  1886. <div id="method-Ext.ux.grid.GridFilters-buildQuery"></div>/**
  1887. * Function to take the active filters data and build it into a query.
  1888. * The format of the query depends on the <code>{@link #encode}</code>
  1889. * configuration:
  1890. * <div class="mdetail-params"><ul>
  1891. *
  1892. * <li><b><tt>false</tt></b> : <i>Default</i>
  1893. * <div class="sub-desc">
  1894. * Flatten into query string of the form (assuming <code>{@link #paramPrefix}='filters'</code>:
  1895. * <pre><code>
  1896. filters[0][field]="someDataIndex"&
  1897. filters[0][data][comparison]="someValue1"&
  1898. filters[0][data][type]="someValue2"&
  1899. filters[0][data][value]="someValue3"&
  1900. * </code></pre>
  1901. * </div></li>
  1902. * <li><b><tt>true</tt></b> :
  1903. * <div class="sub-desc">
  1904. * JSON encode the filter data
  1905. * <pre><code>
  1906. filters[0][field]="someDataIndex"&
  1907. filters[0][data][comparison]="someValue1"&
  1908. filters[0][data][type]="someValue2"&
  1909. filters[0][data][value]="someValue3"&
  1910. * </code></pre>
  1911. * </div></li>
  1912. * </ul></div>
  1913. * Override this method to customize the format of the filter query for remote requests.
  1914. * @param {Array} filters A collection of objects representing active filters and their configuration.
  1915. * Each element will take the form of {field: dataIndex, data: filterConf}. dataIndex is not assured
  1916. * to be unique as any one filter may be a composite of more basic filters for the same dataIndex.
  1917. * @return {Object} Query keys and values
  1918. */
  1919. buildQuery : function (filters) {
  1920. var p = {}, i, f, root, dataPrefix, key, tmp,
  1921. len = filters.length;
  1922. if (!this.encode){
  1923. for (i = 0; i < len; i++) {
  1924. f = filters[i];
  1925. root = [this.paramPrefix, '[', i, ']'].join('');
  1926. p[root + '[field]'] = f.field;
  1927. dataPrefix = root + '[data]';
  1928. for (key in f.data) {
  1929. p[[dataPrefix, '[', key, ']'].join('')] = f.data[key];
  1930. }
  1931. }
  1932. } else {
  1933. tmp = [];
  1934. for (i = 0; i < len; i++) {
  1935. f = filters[i];
  1936. tmp.push(Ext.apply(
  1937. {},
  1938. {field: f.field},
  1939. f.data
  1940. ));
  1941. }
  1942. // only build if there is active filter
  1943. if (tmp.length > 0){
  1944. p[this.paramPrefix] = Ext.util.JSON.encode(tmp);
  1945. }
  1946. }
  1947. return p;
  1948. },
  1949. <div id="method-Ext.ux.grid.GridFilters-cleanParams"></div>/**
  1950. * Removes filter related query parameters from the provided object.
  1951. * @param {Object} p Query parameters that may contain filter related fields.
  1952. */
  1953. cleanParams : function (p) {
  1954. // if encoding just delete the property
  1955. if (this.encode) {
  1956. delete p[this.paramPrefix];
  1957. // otherwise scrub the object of filter data
  1958. } else {
  1959. var regex, key;
  1960. regex = new RegExp('^' + this.paramPrefix + '\[[0-9]+\]');
  1961. for (key in p) {
  1962. if (regex.test(key)) {
  1963. delete p[key];
  1964. }
  1965. }
  1966. }
  1967. },
  1968. <div id="method-Ext.ux.grid.GridFilters-getFilterClass"></div>/**
  1969. * Function for locating filter classes, overwrite this with your favorite
  1970. * loader to provide dynamic filter loading.
  1971. * @param {String} type The type of filter to load ('Filter' is automatically
  1972. * appended to the passed type; eg, 'string' becomes 'StringFilter').
  1973. * @return {Class} The Ext.ux.grid.filter.Class
  1974. */
  1975. getFilterClass : function (type) {
  1976. // map the supported Ext.data.Field type values into a supported filter
  1977. switch(type) {
  1978. case 'auto':
  1979. type = 'string';
  1980. break;
  1981. case 'int':
  1982. case 'float':
  1983. type = 'numeric';
  1984. break;
  1985. case 'bool':
  1986. type = 'boolean';
  1987. break;
  1988. }
  1989. return Ext.ux.grid.filter[type.substr(0, 1).toUpperCase() + type.substr(1) + 'Filter'];
  1990. }
  1991. });
  1992. // register ptype
  1993. Ext.preg('gridfilters', Ext.ux.grid.GridFilters);
  1994. Ext.namespace('Ext.ux.grid.filter');
  1995. /**
  1996. * @class Ext.ux.grid.filter.Filter
  1997. * @extends Ext.util.Observable
  1998. * Abstract base class for filter implementations.
  1999. */
  2000. Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
  2001. <div id="cfg-Ext.ux.grid.filter.Filter-active"></div>/**
  2002. * @cfg {Boolean} active
  2003. * Indicates the initial status of the filter (defaults to false).
  2004. */
  2005. active : false,
  2006. <div id="prop-Ext.ux.grid.filter.Filter-active"></div>/**
  2007. * True if this filter is active. Use setActive() to alter after configuration.
  2008. * @type Boolean
  2009. * @property active
  2010. */
  2011. <div id="cfg-Ext.ux.grid.filter.Filter-dataIndex"></div>/**
  2012. * @cfg {String} dataIndex
  2013. * The {@link Ext.data.Store} dataIndex of the field this filter represents.
  2014. * The dataIndex does not actually have to exist in the store.
  2015. */
  2016. dataIndex : null,
  2017. <div id="prop-Ext.ux.grid.filter.Filter-menu"></div>/**
  2018. * The filter configuration menu that will be installed into the filter submenu of a column menu.
  2019. * @type Ext.menu.Menu
  2020. * @property
  2021. */
  2022. menu : null,
  2023. <div id="cfg-Ext.ux.grid.filter.Filter-updateBuffer"></div>/**
  2024. * @cfg {Number} updateBuffer
  2025. * Number of milliseconds to wait after user interaction to fire an update. Only supported
  2026. * by filters: 'list', 'numeric', and 'string'. Defaults to 500.
  2027. */
  2028. updateBuffer : 500,
  2029. constructor : function (config) {
  2030. Ext.apply(this, config);
  2031. this.addEvents(
  2032. <div id="event-Ext.ux.grid.filter.Filter-activate"></div>/**
  2033. * @event activate
  2034. * Fires when an inactive filter becomes active
  2035. * @param {Ext.ux.grid.filter.Filter} this
  2036. */
  2037. 'activate',
  2038. <div id="event-Ext.ux.grid.filter.Filter-deactivate"></div>/**
  2039. * @event deactivate
  2040. * Fires when an active filter becomes inactive
  2041. * @param {Ext.ux.grid.filter.Filter} this
  2042. */
  2043. 'deactivate',
  2044. <div id="event-Ext.ux.grid.filter.Filter-serialize"></div>/**
  2045. * @event serialize
  2046. * Fires after the serialization process. Use this to attach additional parameters to serialization
  2047. * data before it is encoded and sent to the server.
  2048. * @param {Array/Object} data A map or collection of maps representing the current filter configuration.
  2049. * @param {Ext.ux.grid.filter.Filter} filter The filter being serialized.
  2050. */
  2051. 'serialize',
  2052. <div id="event-Ext.ux.grid.filter.Filter-update"></div>/**
  2053. * @event update
  2054. * Fires when a filter configuration has changed
  2055. * @param {Ext.ux.grid.filter.Filter} this The filter object.
  2056. */
  2057. 'update'
  2058. );
  2059. Ext.ux.grid.filter.Filter.superclass.constructor.call(this);
  2060. this.menu = new Ext.menu.Menu();
  2061. this.init(config);
  2062. if(config && config.value){
  2063. this.setValue(config.value);
  2064. this.setActive(config.active !== false, true);
  2065. delete config.value;
  2066. }
  2067. },
  2068. <div id="method-Ext.ux.grid.filter.Filter-destroy"></div>/**
  2069. * Destroys this filter by purging any event listeners, and removing any menus.
  2070. */
  2071. destroy : function(){
  2072. if (this.menu){
  2073. this.menu.destroy();
  2074. }
  2075. this.purgeListeners();
  2076. },
  2077. <div id="prop-Ext.ux.grid.filter.Filter-init"></div>/**
  2078. * Template method to be implemented by all subclasses that is to
  2079. * initialize the filter and install required menu items.
  2080. * Defaults to Ext.emptyFn.
  2081. */
  2082. init : Ext.emptyFn,
  2083. <div id="method-Ext.ux.grid.filter.Filter-getValue"></div>/**
  2084. * Template method to be implemented by all subclasses that is to
  2085. * get and return the value of the filter.
  2086. * Defaults to Ext.emptyFn.
  2087. * @return {Object} The 'serialized' form of this filter
  2088. * @methodOf Ext.ux.grid.filter.Filter
  2089. */
  2090. getValue : Ext.emptyFn,
  2091. <div id="method-Ext.ux.grid.filter.Filter-setValue"></div>/**
  2092. * Template method to be implemented by all subclasses that is to
  2093. * set the value of the filter and fire the 'update' event.
  2094. * Defaults to Ext.emptyFn.
  2095. * @param {Object} data The value to set the filter
  2096. * @methodOf Ext.ux.grid.filter.Filter
  2097. */
  2098. setValue : Ext.emptyFn,
  2099. <div id="method-Ext.ux.grid.filter.Filter-isActivatable"></div>/**
  2100. * Template method to be implemented by all subclasses that is to
  2101. * return <tt>true</tt> if the filter has enough configuration information to be activated.
  2102. * Defaults to <tt>return true</tt>.
  2103. * @return {Boolean}
  2104. */
  2105. isActivatable : function(){
  2106. return true;
  2107. },
  2108. <div id="prop-Ext.ux.grid.filter.Filter-getSerialArgs"></div>/**
  2109. * Template method to be implemented by all subclasses that is to
  2110. * get and return serialized filter data for transmission to the server.
  2111. * Defaults to Ext.emptyFn.
  2112. */
  2113. getSerialArgs : Ext.emptyFn,
  2114. <div id="method-Ext.ux.grid.filter.Filter-validateRecord"></div>/**
  2115. * Template method to be implemented by all subclasses that is to
  2116. * validates the provided Ext.data.Record against the filters configuration.
  2117. * Defaults to <tt>return true</tt>.
  2118. * @param {Ext.data.Record} record The record to validate
  2119. * @return {Boolean} true if the record is valid within the bounds
  2120. * of the filter, false otherwise.
  2121. */
  2122. validateRecord : function(){
  2123. return true;
  2124. },
  2125. <div id="method-Ext.ux.grid.filter.Filter-serialize"></div>/**
  2126. * Returns the serialized filter data for transmission to the server
  2127. * and fires the 'serialize' event.
  2128. * @return {Object/Array} An object or collection of objects containing
  2129. * key value pairs representing the current configuration of the filter.
  2130. * @methodOf Ext.ux.grid.filter.Filter
  2131. */
  2132. serialize : function(){
  2133. var args = this.getSerialArgs();
  2134. this.fireEvent('serialize', args, this);
  2135. return args;
  2136. },
  2137. /** @private */
  2138. fireUpdate : function(){
  2139. if (this.active) {
  2140. this.fireEvent('update', this);
  2141. }
  2142. this.setActive(this.isActivatable());
  2143. },
  2144. <div id="method-Ext.ux.grid.filter.Filter-setActive"></div>/**
  2145. * Sets the status of the filter and fires the appropriate events.
  2146. * @param {Boolean} active The new filter state.
  2147. * @param {Boolean} suppressEvent True to prevent events from being fired.
  2148. * @methodOf Ext.ux.grid.filter.Filter
  2149. */
  2150. setActive : function(active, suppressEvent){
  2151. if(this.active != active){
  2152. this.active = active;
  2153. if (suppressEvent !== true) {
  2154. this.fireEvent(active ? 'activate' : 'deactivate', this);
  2155. }
  2156. }
  2157. }
  2158. });/**
  2159. * @class Ext.ux.grid.filter.BooleanFilter
  2160. * @extends Ext.ux.grid.filter.Filter
  2161. * Boolean filters use unique radio group IDs (so you can have more than one!)
  2162. * <p><b><u>Example Usage:</u></b></p>
  2163. * <pre><code>
  2164. var filters = new Ext.ux.grid.GridFilters({
  2165. ...
  2166. filters: [{
  2167. // required configs
  2168. type: 'boolean',
  2169. dataIndex: 'visible'
  2170. // optional configs
  2171. defaultValue: null, // leave unselected (false selected by default)
  2172. yesText: 'Yes', // default
  2173. noText: 'No' // default
  2174. }]
  2175. });
  2176. * </code></pre>
  2177. */
  2178. Ext.ux.grid.filter.BooleanFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
  2179. <div id="cfg-Ext.ux.grid.filter.BooleanFilter-defaultValue"></div>/**
  2180. * @cfg {Boolean} defaultValue
  2181. * Set this to null if you do not want either option to be checked by default. Defaults to false.
  2182. */
  2183. defaultValue : false,
  2184. <div id="cfg-Ext.ux.grid.filter.BooleanFilter-yesText"></div>/**
  2185. * @cfg {String} yesText
  2186. * Defaults to 'Yes'.
  2187. */
  2188. yesText : 'Yes',
  2189. <div id="cfg-Ext.ux.grid.filter.BooleanFilter-noText"></div>/**
  2190. * @cfg {String} noText
  2191. * Defaults to 'No'.
  2192. */
  2193. noText : 'No',
  2194. /**
  2195. * @private
  2196. * Template method that is to initialize the filter and install required menu items.
  2197. */
  2198. init : function (config) {
  2199. var gId = Ext.id();
  2200. this.options = [
  2201. new Ext.menu.CheckItem({text: this.yesText, group: gId, checked: this.defaultValue === true}),
  2202. new Ext.menu.CheckItem({text: this.noText, group: gId, checked: this.defaultValue === false})];
  2203. this.menu.add(this.options[0], this.options[1]);
  2204. for(var i=0; i<this.options.length; i++){
  2205. this.options[i].on('click', this.fireUpdate, this);
  2206. this.options[i].on('checkchange', this.fireUpdate, this);
  2207. }
  2208. },
  2209. /**
  2210. * @private
  2211. * Template method that is to get and return the value of the filter.
  2212. * @return {String} The value of this filter
  2213. */
  2214. getValue : function () {
  2215. return this.options[0].checked;
  2216. },
  2217. /**
  2218. * @private
  2219. * Template method that is to set the value of the filter.
  2220. * @param {Object} value The value to set the filter
  2221. */
  2222. setValue : function (value) {
  2223. this.options[value ? 0 : 1].setChecked(true);
  2224. },
  2225. /**
  2226. * @private
  2227. * Template method that is to get and return serialized filter data for
  2228. * transmission to the server.
  2229. * @return {Object/Array} An object or collection of objects containing
  2230. * key value pairs representing the current configuration of the filter.
  2231. */
  2232. getSerialArgs : function () {
  2233. var args = {type: 'boolean', value: this.getValue()};
  2234. return args;
  2235. },
  2236. <div id="method-Ext.ux.grid.filter.BooleanFilter-validateRecord"></div>/**
  2237. * Template method that is to validate the provided Ext.data.Record
  2238. * against the filters configuration.
  2239. * @param {Ext.data.Record} record The record to validate
  2240. * @return {Boolean} true if the record is valid within the bounds
  2241. * of the filter, false otherwise.
  2242. */
  2243. validateRecord : function (record) {
  2244. return record.get(this.dataIndex) == this.getValue();
  2245. }
  2246. });/**
  2247. * @class Ext.ux.grid.filter.DateFilter
  2248. * @extends Ext.ux.grid.filter.Filter
  2249. * Filter by a configurable Ext.menu.DateMenu
  2250. * <p><b><u>Example Usage:</u></b></p>
  2251. * <pre><code>
  2252. var filters = new Ext.ux.grid.GridFilters({
  2253. ...
  2254. filters: [{
  2255. // required configs
  2256. type: 'date',
  2257. dataIndex: 'dateAdded',
  2258. // optional configs
  2259. dateFormat: 'm/d/Y', // default
  2260. beforeText: 'Before', // default
  2261. afterText: 'After', // default
  2262. onText: 'On', // default
  2263. pickerOpts: {
  2264. // any DateMenu configs
  2265. },
  2266. active: true // default is false
  2267. }]
  2268. });
  2269. * </code></pre>
  2270. */
  2271. Ext.ux.grid.filter.DateFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
  2272. <div id="cfg-Ext.ux.grid.filter.DateFilter-afterText"></div>/**
  2273. * @cfg {String} afterText
  2274. * Defaults to 'After'.
  2275. */
  2276. afterText : 'After',
  2277. <div id="cfg-Ext.ux.grid.filter.DateFilter-beforeText"></div>/**
  2278. * @cfg {String} beforeText
  2279. * Defaults to 'Before'.
  2280. */
  2281. beforeText : 'Before',
  2282. <div id="cfg-Ext.ux.grid.filter.DateFilter-compareMap"></div>/**
  2283. * @cfg {Object} compareMap
  2284. * Map for assigning the comparison values used in serialization.
  2285. */
  2286. compareMap : {
  2287. before: 'lt',
  2288. after: 'gt',
  2289. on: 'eq'
  2290. },
  2291. <div id="cfg-Ext.ux.grid.filter.DateFilter-dateFormat"></div>/**
  2292. * @cfg {String} dateFormat
  2293. * The date format to return when using getValue.
  2294. * Defaults to 'm/d/Y'.
  2295. */
  2296. dateFormat : 'm/d/Y',
  2297. <div id="cfg-Ext.ux.grid.filter.DateFilter-maxDate"></div>/**
  2298. * @cfg {Date} maxDate
  2299. * Allowable date as passed to the Ext.DatePicker
  2300. * Defaults to undefined.
  2301. */
  2302. <div id="cfg-Ext.ux.grid.filter.DateFilter-minDate"></div>/**
  2303. * @cfg {Date} minDate
  2304. * Allowable date as passed to the Ext.DatePicker
  2305. * Defaults to undefined.
  2306. */
  2307. <div id="cfg-Ext.ux.grid.filter.DateFilter-menuItems"></div>/**
  2308. * @cfg {Array} menuItems
  2309. * The items to be shown in this menu
  2310. * Defaults to:<pre>
  2311. * menuItems : ['before', 'after', '-', 'on'],
  2312. * </pre>
  2313. */
  2314. menuItems : ['before', 'after', '-', 'on'],
  2315. <div id="cfg-Ext.ux.grid.filter.DateFilter-menuItemCfgs"></div>/**
  2316. * @cfg {Object} menuItemCfgs
  2317. * Default configuration options for each menu item
  2318. */
  2319. menuItemCfgs : {
  2320. selectOnFocus: true,
  2321. width: 125
  2322. },
  2323. <div id="cfg-Ext.ux.grid.filter.DateFilter-onText"></div>/**
  2324. * @cfg {String} onText
  2325. * Defaults to 'On'.
  2326. */
  2327. onText : 'On',
  2328. <div id="cfg-Ext.ux.grid.filter.DateFilter-pickerOpts"></div>/**
  2329. * @cfg {Object} pickerOpts
  2330. * Configuration options for the date picker associated with each field.
  2331. */
  2332. pickerOpts : {},
  2333. /**
  2334. * @private
  2335. * Template method that is to initialize the filter and install required menu items.
  2336. */
  2337. init : function (config) {
  2338. var menuCfg, i, len, item, cfg, Cls;
  2339. menuCfg = Ext.apply(this.pickerOpts, {
  2340. minDate: this.minDate,
  2341. maxDate: this.maxDate,
  2342. format: this.dateFormat,
  2343. listeners: {
  2344. scope: this,
  2345. select: this.onMenuSelect
  2346. }
  2347. });
  2348. this.fields = {};
  2349. for (i = 0, len = this.menuItems.length; i < len; i++) {
  2350. item = this.menuItems[i];
  2351. if (item !== '-') {
  2352. cfg = {
  2353. itemId: 'range-' + item,
  2354. text: this[item + 'Text'],
  2355. menu: new Ext.menu.DateMenu(
  2356. Ext.apply(menuCfg, {
  2357. itemId: item
  2358. })
  2359. ),
  2360. listeners: {
  2361. scope: this,
  2362. checkchange: this.onCheckChange
  2363. }
  2364. };
  2365. Cls = Ext.menu.CheckItem;
  2366. item = this.fields[item] = new Cls(cfg);
  2367. }
  2368. //this.add(item);
  2369. this.menu.add(item);
  2370. }
  2371. },
  2372. onCheckChange : function () {
  2373. this.setActive(this.isActivatable());
  2374. this.fireEvent('update', this);
  2375. },
  2376. /**
  2377. * @private
  2378. * Handler method called when there is a keyup event on an input
  2379. * item of this menu.
  2380. */
  2381. onInputKeyUp : function (field, e) {
  2382. var k = e.getKey();
  2383. if (k == e.RETURN && field.isValid()) {
  2384. e.stopEvent();
  2385. this.menu.hide(true);
  2386. return;
  2387. }
  2388. },
  2389. <div id="method-Ext.ux.grid.filter.DateFilter-onMenuSelect"></div>/**
  2390. * Handler for when the menu for a field fires the 'select' event
  2391. * @param {Object} date
  2392. * @param {Object} menuItem
  2393. * @param {Object} value
  2394. * @param {Object} picker
  2395. */
  2396. onMenuSelect : function (menuItem, value, picker) {
  2397. var fields = this.fields,
  2398. field = this.fields[menuItem.itemId];
  2399. field.setChecked(true);
  2400. if (field == fields.on) {
  2401. fields.before.setChecked(false, true);
  2402. fields.after.setChecked(false, true);
  2403. } else {
  2404. fields.on.setChecked(false, true);
  2405. if (field == fields.after && fields.before.menu.picker.value < value) {
  2406. fields.before.setChecked(false, true);
  2407. } else if (field == fields.before && fields.after.menu.picker.value > value) {
  2408. fields.after.setChecked(false, true);
  2409. }
  2410. }
  2411. this.fireEvent('update', this);
  2412. },
  2413. /**
  2414. * @private
  2415. * Template method that is to get and return the value of the filter.
  2416. * @return {String} The value of this filter
  2417. */
  2418. getValue : function () {
  2419. var key, result = {};
  2420. for (key in this.fields) {
  2421. if (this.fields[key].checked) {
  2422. result[key] = this.fields[key].menu.picker.getValue();
  2423. }
  2424. }
  2425. return result;
  2426. },
  2427. /**
  2428. * @private
  2429. * Template method that is to set the value of the filter.
  2430. * @param {Object} value The value to set the filter
  2431. * @param {Boolean} preserve true to preserve the checked status
  2432. * of the other fields. Defaults to false, unchecking the
  2433. * other fields
  2434. */
  2435. setValue : function (value, preserve) {
  2436. var key;
  2437. for (key in this.fields) {
  2438. if(value[key]){
  2439. this.fields[key].menu.picker.setValue(value[key]);
  2440. this.fields[key].setChecked(true);
  2441. } else if (!preserve) {
  2442. this.fields[key].setChecked(false);
  2443. }
  2444. }
  2445. this.fireEvent('update', this);
  2446. },
  2447. /**
  2448. * @private
  2449. * Template method that is to return <tt>true</tt> if the filter
  2450. * has enough configuration information to be activated.
  2451. * @return {Boolean}
  2452. */
  2453. isActivatable : function () {
  2454. var key;
  2455. for (key in this.fields) {
  2456. if (this.fields[key].checked) {
  2457. return true;
  2458. }
  2459. }
  2460. return false;
  2461. },
  2462. /**
  2463. * @private
  2464. * Template method that is to get and return serialized filter data for
  2465. * transmission to the server.
  2466. * @return {Object/Array} An object or collection of objects containing
  2467. * key value pairs representing the current configuration of the filter.
  2468. */
  2469. getSerialArgs : function () {
  2470. var args = [];
  2471. for (var key in this.fields) {
  2472. if(this.fields[key].checked){
  2473. args.push({
  2474. type: 'date',
  2475. comparison: this.compareMap[key],
  2476. value: this.getFieldValue(key).format(this.dateFormat)
  2477. });
  2478. }
  2479. }
  2480. return args;
  2481. },
  2482. <div id="method-Ext.ux.grid.filter.DateFilter-getFieldValue"></div>/**
  2483. * Get and return the date menu picker value
  2484. * @param {String} item The field identifier ('before', 'after', 'on')
  2485. * @return {Date} Gets the current selected value of the date field
  2486. */
  2487. getFieldValue : function(item){
  2488. return this.fields[item].menu.picker.getValue();
  2489. },
  2490. <div id="method-Ext.ux.grid.filter.DateFilter-getPicker"></div>/**
  2491. * Gets the menu picker associated with the passed field
  2492. * @param {String} item The field identifier ('before', 'after', 'on')
  2493. * @return {Object} The menu picker
  2494. */
  2495. getPicker : function(item){
  2496. return this.fields[item].menu.picker;
  2497. },
  2498. <div id="method-Ext.ux.grid.filter.DateFilter-validateRecord"></div>/**
  2499. * Template method that is to validate the provided Ext.data.Record
  2500. * against the filters configuration.
  2501. * @param {Ext.data.Record} record The record to validate
  2502. * @return {Boolean} true if the record is valid within the bounds
  2503. * of the filter, false otherwise.
  2504. */
  2505. validateRecord : function (record) {
  2506. var key,
  2507. pickerValue,
  2508. val = record.get(this.dataIndex);
  2509. if(!Ext.isDate(val)){
  2510. return false;
  2511. }
  2512. val = val.clearTime(true).getTime();
  2513. for (key in this.fields) {
  2514. if (this.fields[key].checked) {
  2515. pickerValue = this.getFieldValue(key).clearTime(true).getTime();
  2516. if (key == 'before' && pickerValue <= val) {
  2517. return false;
  2518. }
  2519. if (key == 'after' && pickerValue >= val) {
  2520. return false;
  2521. }
  2522. if (key == 'on' && pickerValue != val) {
  2523. return false;
  2524. }
  2525. }
  2526. }
  2527. return true;
  2528. }
  2529. });/**
  2530. * @class Ext.ux.grid.filter.ListFilter
  2531. * @extends Ext.ux.grid.filter.Filter
  2532. * <p>List filters are able to be preloaded/backed by an Ext.data.Store to load
  2533. * their options the first time they are shown. ListFilter utilizes the
  2534. * {@link Ext.ux.menu.ListMenu} component.</p>
  2535. * <p>Although not shown here, this class accepts all configuration options
  2536. * for {@link Ext.ux.menu.ListMenu}.</p>
  2537. *
  2538. * <p><b><u>Example Usage:</u></b></p>
  2539. * <pre><code>
  2540. var filters = new Ext.ux.grid.GridFilters({
  2541. ...
  2542. filters: [{
  2543. type: 'list',
  2544. dataIndex: 'size',
  2545. phpMode: true,
  2546. // options will be used as data to implicitly creates an ArrayStore
  2547. options: ['extra small', 'small', 'medium', 'large', 'extra large']
  2548. }]
  2549. });
  2550. * </code></pre>
  2551. *
  2552. */
  2553. Ext.ux.grid.filter.ListFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
  2554. <div id="cfg-Ext.ux.grid.filter.ListFilter-options"></div>/**
  2555. * @cfg {Array} options
  2556. * <p><code>data</code> to be used to implicitly create a data store
  2557. * to back this list when the data source is <b>local</b>. If the
  2558. * data for the list is remote, use the <code>{@link #store}</code>
  2559. * config instead.</p>
  2560. * <br><p>Each item within the provided array may be in one of the
  2561. * following formats:</p>
  2562. * <div class="mdetail-params"><ul>
  2563. * <li><b>Array</b> :
  2564. * <pre><code>
  2565. options: [
  2566. [11, 'extra small'],
  2567. [18, 'small'],
  2568. [22, 'medium'],
  2569. [35, 'large'],
  2570. [44, 'extra large']
  2571. ]
  2572. * </code></pre>
  2573. * </li>
  2574. * <li><b>Object</b> :
  2575. * <pre><code>
  2576. labelField: 'name', // override default of 'text'
  2577. options: [
  2578. {id: 11, name:'extra small'},
  2579. {id: 18, name:'small'},
  2580. {id: 22, name:'medium'},
  2581. {id: 35, name:'large'},
  2582. {id: 44, name:'extra large'}
  2583. ]
  2584. * </code></pre>
  2585. * </li>
  2586. * <li><b>String</b> :
  2587. * <pre><code>
  2588. * options: ['extra small', 'small', 'medium', 'large', 'extra large']
  2589. * </code></pre>
  2590. * </li>
  2591. */
  2592. <div id="cfg-Ext.ux.grid.filter.ListFilter-phpMode"></div>/**
  2593. * @cfg {Boolean} phpMode
  2594. * <p>Adjust the format of this filter. Defaults to false.</p>
  2595. * <br><p>When GridFilters <code>@cfg encode = false</code> (default):</p>
  2596. * <pre><code>
  2597. // phpMode == false (default):
  2598. filter[0][data][type] list
  2599. filter[0][data][value] value1
  2600. filter[0][data][value] value2
  2601. filter[0][field] prod
  2602. // phpMode == true:
  2603. filter[0][data][type] list
  2604. filter[0][data][value] value1, value2
  2605. filter[0][field] prod
  2606. * </code></pre>
  2607. * When GridFilters <code>@cfg encode = true</code>:
  2608. * <pre><code>
  2609. // phpMode == false (default):
  2610. filter : [{"type":"list","value":["small","medium"],"field":"size"}]
  2611. // phpMode == true:
  2612. filter : [{"type":"list","value":"small,medium","field":"size"}]
  2613. * </code></pre>
  2614. */
  2615. phpMode : false,
  2616. <div id="cfg-Ext.ux.grid.filter.ListFilter-store"></div>/**
  2617. * @cfg {Ext.data.Store} store
  2618. * The {@link Ext.data.Store} this list should use as its data source
  2619. * when the data source is <b>remote</b>. If the data for the list
  2620. * is local, use the <code>{@link #options}</code> config instead.
  2621. */
  2622. /**
  2623. * @private
  2624. * Template method that is to initialize the filter and install required menu items.
  2625. * @param {Object} config
  2626. */
  2627. init : function (config) {
  2628. this.dt = new Ext.util.DelayedTask(this.fireUpdate, this);
  2629. // if a menu already existed, do clean up first
  2630. if (this.menu){
  2631. this.menu.destroy();
  2632. }
  2633. this.menu = new Ext.ux.menu.ListMenu(config);
  2634. this.menu.on('checkchange', this.onCheckChange, this);
  2635. },
  2636. /**
  2637. * @private
  2638. * Template method that is to get and return the value of the filter.
  2639. * @return {String} The value of this filter
  2640. */
  2641. getValue : function () {
  2642. return this.menu.getSelected();
  2643. },
  2644. /**
  2645. * @private
  2646. * Template method that is to set the value of the filter.
  2647. * @param {Object} value The value to set the filter
  2648. */
  2649. setValue : function (value) {
  2650. this.menu.setSelected(value);
  2651. this.fireEvent('update', this);
  2652. },
  2653. /**
  2654. * @private
  2655. * Template method that is to return <tt>true</tt> if the filter
  2656. * has enough configuration information to be activated.
  2657. * @return {Boolean}
  2658. */
  2659. isActivatable : function () {
  2660. return this.getValue().length > 0;
  2661. },
  2662. /**
  2663. * @private
  2664. * Template method that is to get and return serialized filter data for
  2665. * transmission to the server.
  2666. * @return {Object/Array} An object or collection of objects containing
  2667. * key value pairs representing the current configuration of the filter.
  2668. */
  2669. getSerialArgs : function () {
  2670. var args = {type: 'list', value: this.phpMode ? this.getValue().join(',') : this.getValue()};
  2671. return args;
  2672. },
  2673. /** @private */
  2674. onCheckChange : function(){
  2675. this.dt.delay(this.updateBuffer);
  2676. },
  2677. <div id="method-Ext.ux.grid.filter.ListFilter-validateRecord"></div>/**
  2678. * Template method that is to validate the provided Ext.data.Record
  2679. * against the filters configuration.
  2680. * @param {Ext.data.Record} record The record to validate
  2681. * @return {Boolean} true if the record is valid within the bounds
  2682. * of the filter, false otherwise.
  2683. */
  2684. validateRecord : function (record) {
  2685. return this.getValue().indexOf(record.get(this.dataIndex)) > -1;
  2686. }
  2687. });/**
  2688. * @class Ext.ux.grid.filter.NumericFilter
  2689. * @extends Ext.ux.grid.filter.Filter
  2690. * Filters using an Ext.ux.menu.RangeMenu.
  2691. * <p><b><u>Example Usage:</u></b></p>
  2692. * <pre><code>
  2693. var filters = new Ext.ux.grid.GridFilters({
  2694. ...
  2695. filters: [{
  2696. type: 'numeric',
  2697. dataIndex: 'price'
  2698. }]
  2699. });
  2700. * </code></pre>
  2701. */
  2702. Ext.ux.grid.filter.NumericFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
  2703. <div id="cfg-Ext.ux.grid.filter.NumericFilter-fieldCls"></div>/**
  2704. * @cfg {Object} fieldCls
  2705. * The Class to use to construct each field item within this menu
  2706. * Defaults to:<pre>
  2707. * fieldCls : Ext.form.NumberField
  2708. * </pre>
  2709. */
  2710. fieldCls : Ext.form.NumberField,
  2711. <div id="cfg-Ext.ux.grid.filter.NumericFilter-fieldCfg"></div>/**
  2712. * @cfg {Object} fieldCfg
  2713. * The default configuration options for any field item unless superseded
  2714. * by the <code>{@link #fields}</code> configuration.
  2715. * Defaults to:<pre>
  2716. * fieldCfg : {}
  2717. * </pre>
  2718. * Example usage:
  2719. * <pre><code>
  2720. fieldCfg : {
  2721. width: 150,
  2722. },
  2723. * </code></pre>
  2724. */
  2725. <div id="cfg-Ext.ux.grid.filter.NumericFilter-fields"></div>/**
  2726. * @cfg {Object} fields
  2727. * The field items may be configured individually
  2728. * Defaults to <tt>undefined</tt>.
  2729. * Example usage:
  2730. * <pre><code>
  2731. fields : {
  2732. gt: { // override fieldCfg options
  2733. width: 200,
  2734. fieldCls: Ext.ux.form.CustomNumberField // to override default {@link #fieldCls}
  2735. }
  2736. },
  2737. * </code></pre>
  2738. */
  2739. <div id="cfg-Ext.ux.grid.filter.NumericFilter-iconCls"></div>/**
  2740. * @cfg {Object} iconCls
  2741. * The iconCls to be applied to each comparator field item.
  2742. * Defaults to:<pre>
  2743. iconCls : {
  2744. gt : 'ux-rangemenu-gt',
  2745. lt : 'ux-rangemenu-lt',
  2746. eq : 'ux-rangemenu-eq'
  2747. }
  2748. * </pre>
  2749. */
  2750. iconCls : {
  2751. gt : 'ux-rangemenu-gt',
  2752. lt : 'ux-rangemenu-lt',
  2753. eq : 'ux-rangemenu-eq'
  2754. },
  2755. <div id="cfg-Ext.ux.grid.filter.NumericFilter-menuItemCfgs"></div>/**
  2756. * @cfg {Object} menuItemCfgs
  2757. * Default configuration options for each menu item
  2758. * Defaults to:<pre>
  2759. menuItemCfgs : {
  2760. emptyText: 'Enter Filter Text...',
  2761. selectOnFocus: true,
  2762. width: 125
  2763. }
  2764. * </pre>
  2765. */
  2766. menuItemCfgs : {
  2767. emptyText: 'Enter Filter Text...',
  2768. selectOnFocus: true,
  2769. width: 125
  2770. },
  2771. <div id="cfg-Ext.ux.grid.filter.NumericFilter-menuItems"></div>/**
  2772. * @cfg {Array} menuItems
  2773. * The items to be shown in this menu. Items are added to the menu
  2774. * according to their position within this array. Defaults to:<pre>
  2775. * menuItems : ['lt','gt','-','eq']
  2776. * </pre>
  2777. */
  2778. menuItems : ['lt', 'gt', '-', 'eq'],
  2779. /**
  2780. * @private
  2781. * Template method that is to initialize the filter and install required menu items.
  2782. */
  2783. init : function (config) {
  2784. // if a menu already existed, do clean up first
  2785. if (this.menu){
  2786. this.menu.destroy();
  2787. }
  2788. this.menu = new Ext.ux.menu.RangeMenu(Ext.apply(config, {
  2789. // pass along filter configs to the menu
  2790. fieldCfg : this.fieldCfg || {},
  2791. fieldCls : this.fieldCls,
  2792. fields : this.fields || {},
  2793. iconCls: this.iconCls,
  2794. menuItemCfgs: this.menuItemCfgs,
  2795. menuItems: this.menuItems,
  2796. updateBuffer: this.updateBuffer
  2797. }));
  2798. // relay the event fired by the menu
  2799. this.menu.on('update', this.fireUpdate, this);
  2800. },
  2801. /**
  2802. * @private
  2803. * Template method that is to get and return the value of the filter.
  2804. * @return {String} The value of this filter
  2805. */
  2806. getValue : function () {
  2807. return this.menu.getValue();
  2808. },
  2809. /**
  2810. * @private
  2811. * Template method that is to set the value of the filter.
  2812. * @param {Object} value The value to set the filter
  2813. */
  2814. setValue : function (value) {
  2815. this.menu.setValue(value);
  2816. },
  2817. /**
  2818. * @private
  2819. * Template method that is to return <tt>true</tt> if the filter
  2820. * has enough configuration information to be activated.
  2821. * @return {Boolean}
  2822. */
  2823. isActivatable : function () {
  2824. var values = this.getValue();
  2825. for (key in values) {
  2826. if (values[key] !== undefined) {
  2827. return true;
  2828. }
  2829. }
  2830. return false;
  2831. },
  2832. /**
  2833. * @private
  2834. * Template method that is to get and return serialized filter data for
  2835. * transmission to the server.
  2836. * @return {Object/Array} An object or collection of objects containing
  2837. * key value pairs representing the current configuration of the filter.
  2838. */
  2839. getSerialArgs : function () {
  2840. var key,
  2841. args = [],
  2842. values = this.menu.getValue();
  2843. for (key in values) {
  2844. args.push({
  2845. type: 'numeric',
  2846. comparison: key,
  2847. value: values[key]
  2848. });
  2849. }
  2850. return args;
  2851. },
  2852. <div id="method-Ext.ux.grid.filter.NumericFilter-validateRecord"></div>/**
  2853. * Template method that is to validate the provided Ext.data.Record
  2854. * against the filters configuration.
  2855. * @param {Ext.data.Record} record The record to validate
  2856. * @return {Boolean} true if the record is valid within the bounds
  2857. * of the filter, false otherwise.
  2858. */
  2859. validateRecord : function (record) {
  2860. var val = record.get(this.dataIndex),
  2861. values = this.getValue();
  2862. if (values.eq !== undefined && val != values.eq) {
  2863. return false;
  2864. }
  2865. if (values.lt !== undefined && val >= values.lt) {
  2866. return false;
  2867. }
  2868. if (values.gt !== undefined && val <= values.gt) {
  2869. return false;
  2870. }
  2871. return true;
  2872. }
  2873. });/**
  2874. * @class Ext.ux.grid.filter.StringFilter
  2875. * @extends Ext.ux.grid.filter.Filter
  2876. * Filter by a configurable Ext.form.TextField
  2877. * <p><b><u>Example Usage:</u></b></p>
  2878. * <pre><code>
  2879. var filters = new Ext.ux.grid.GridFilters({
  2880. ...
  2881. filters: [{
  2882. // required configs
  2883. type: 'string',
  2884. dataIndex: 'name',
  2885. // optional configs
  2886. value: 'foo',
  2887. active: true, // default is false
  2888. iconCls: 'ux-gridfilter-text-icon' // default
  2889. // any Ext.form.TextField configs accepted
  2890. }]
  2891. });
  2892. * </code></pre>
  2893. */
  2894. Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
  2895. <div id="cfg-Ext.ux.grid.filter.StringFilter-iconCls"></div>/**
  2896. * @cfg {String} iconCls
  2897. * The iconCls to be applied to the menu item.
  2898. * Defaults to <tt>'ux-gridfilter-text-icon'</tt>.
  2899. */
  2900. iconCls : 'ux-gridfilter-text-icon',
  2901. emptyText: 'Enter Filter Text...',
  2902. selectOnFocus: true,
  2903. width: 125,
  2904. /**
  2905. * @private
  2906. * Template method that is to initialize the filter and install required menu items.
  2907. */
  2908. init : function (config) {
  2909. Ext.applyIf(config, {
  2910. enableKeyEvents: true,
  2911. iconCls: this.iconCls,
  2912. listeners: {
  2913. scope: this,
  2914. keyup: this.onInputKeyUp
  2915. }
  2916. });
  2917. this.inputItem = new Ext.form.TextField(config);
  2918. this.menu.add(this.inputItem);
  2919. this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
  2920. },
  2921. /**
  2922. * @private
  2923. * Template method that is to get and return the value of the filter.
  2924. * @return {String} The value of this filter
  2925. */
  2926. getValue : function () {
  2927. return this.inputItem.getValue();
  2928. },
  2929. /**
  2930. * @private
  2931. * Template method that is to set the value of the filter.
  2932. * @param {Object} value The value to set the filter
  2933. */
  2934. setValue : function (value) {
  2935. this.inputItem.setValue(value);
  2936. this.fireEvent('update', this);
  2937. },
  2938. /**
  2939. * @private
  2940. * Template method that is to return <tt>true</tt> if the filter
  2941. * has enough configuration information to be activated.
  2942. * @return {Boolean}
  2943. */
  2944. isActivatable : function () {
  2945. return this.inputItem.getValue().length > 0;
  2946. },
  2947. /**
  2948. * @private
  2949. * Template method that is to get and return serialized filter data for
  2950. * transmission to the server.
  2951. * @return {Object/Array} An object or collection of objects containing
  2952. * key value pairs representing the current configuration of the filter.
  2953. */
  2954. getSerialArgs : function () {
  2955. return {type: 'string', value: this.getValue()};
  2956. },
  2957. <div id="method-Ext.ux.grid.filter.StringFilter-validateRecord"></div>/**
  2958. * Template method that is to validate the provided Ext.data.Record
  2959. * against the filters configuration.
  2960. * @param {Ext.data.Record} record The record to validate
  2961. * @return {Boolean} true if the record is valid within the bounds
  2962. * of the filter, false otherwise.
  2963. */
  2964. validateRecord : function (record) {
  2965. var val = record.get(this.dataIndex);
  2966. if(typeof val != 'string') {
  2967. return (this.getValue().length === 0);
  2968. }
  2969. return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
  2970. },
  2971. /**
  2972. * @private
  2973. * Handler method called when there is a keyup event on this.inputItem
  2974. */
  2975. onInputKeyUp : function (field, e) {
  2976. var k = e.getKey();
  2977. if (k == e.RETURN && field.isValid()) {
  2978. e.stopEvent();
  2979. this.menu.hide(true);
  2980. return;
  2981. }
  2982. // restart the timer
  2983. this.updateTask.delay(this.updateBuffer);
  2984. }
  2985. });
  2986. Ext.namespace('Ext.ux.menu');
  2987. /**
  2988. * @class Ext.ux.menu.ListMenu
  2989. * @extends Ext.menu.Menu
  2990. * This is a supporting class for {@link Ext.ux.grid.filter.ListFilter}.
  2991. * Although not listed as configuration options for this class, this class
  2992. * also accepts all configuration options from {@link Ext.ux.grid.filter.ListFilter}.
  2993. */
  2994. Ext.ux.menu.ListMenu = Ext.extend(Ext.menu.Menu, {
  2995. <div id="cfg-Ext.ux.menu.ListMenu-labelField"></div>/**
  2996. * @cfg {String} labelField
  2997. * Defaults to 'text'.
  2998. */
  2999. labelField : 'text',
  3000. <div id="cfg-Ext.ux.menu.ListMenu-paramPrefix"></div>/**
  3001. * @cfg {String} paramPrefix
  3002. * Defaults to 'Loading...'.
  3003. */
  3004. loadingText : 'Loading...',
  3005. <div id="cfg-Ext.ux.menu.ListMenu-loadOnShow"></div>/**
  3006. * @cfg {Boolean} loadOnShow
  3007. * Defaults to true.
  3008. */
  3009. loadOnShow : true,
  3010. <div id="cfg-Ext.ux.menu.ListMenu-single"></div>/**
  3011. * @cfg {Boolean} single
  3012. * Specify true to group all items in this list into a single-select
  3013. * radio button group. Defaults to false.
  3014. */
  3015. single : false,
  3016. constructor : function (cfg) {
  3017. this.selected = [];
  3018. this.addEvents(
  3019. <div id="event-Ext.ux.menu.ListMenu-checkchange"></div>/**
  3020. * @event checkchange
  3021. * Fires when there is a change in checked items from this list
  3022. * @param {Object} item Ext.menu.CheckItem
  3023. * @param {Object} checked The checked value that was set
  3024. */
  3025. 'checkchange'
  3026. );
  3027. Ext.ux.menu.ListMenu.superclass.constructor.call(this, cfg = cfg || {});
  3028. if(!cfg.store && cfg.options){
  3029. var options = [];
  3030. for(var i=0, len=cfg.options.length; i<len; i++){
  3031. var value = cfg.options[i];
  3032. switch(Ext.type(value)){
  3033. case 'array': options.push(value); break;
  3034. case 'object': options.push([value.id, value[this.labelField]]); break;
  3035. case 'string': options.push([value, value]); break;
  3036. }
  3037. }
  3038. this.store = new Ext.data.Store({
  3039. reader: new Ext.data.ArrayReader({id: 0}, ['id', this.labelField]),
  3040. data: options,
  3041. listeners: {
  3042. 'load': this.onLoad,
  3043. scope: this
  3044. }
  3045. });
  3046. this.loaded = true;
  3047. } else {
  3048. this.add({text: this.loadingText, iconCls: 'loading-indicator'});
  3049. this.store.on('load', this.onLoad, this);
  3050. }
  3051. },
  3052. destroy : function () {
  3053. if (this.store) {
  3054. this.store.destroy();
  3055. }
  3056. Ext.ux.menu.ListMenu.superclass.destroy.call(this);
  3057. },
  3058. <div id="method-Ext.ux.menu.ListMenu-show"></div>/**
  3059. * Lists will initially show a 'loading' item while the data is retrieved from the store.
  3060. * In some cases the loaded data will result in a list that goes off the screen to the
  3061. * right (as placement calculations were done with the loading item). This adapter will
  3062. * allow show to be called with no arguments to show with the previous arguments and
  3063. * thus recalculate the width and potentially hang the menu from the left.
  3064. */
  3065. show : function () {
  3066. var lastArgs = null;
  3067. return function(){
  3068. if(arguments.length === 0){
  3069. Ext.ux.menu.ListMenu.superclass.show.apply(this, lastArgs);
  3070. } else {
  3071. lastArgs = arguments;
  3072. if (this.loadOnShow && !this.loaded) {
  3073. this.store.load();
  3074. }
  3075. Ext.ux.menu.ListMenu.superclass.show.apply(this, arguments);
  3076. }
  3077. };
  3078. }(),
  3079. /** @private */
  3080. onLoad : function (store, records) {
  3081. var visible = this.isVisible();
  3082. this.hide(false);
  3083. this.removeAll(true);
  3084. var gid = this.single ? Ext.id() : null;
  3085. for(var i=0, len=records.length; i<len; i++){
  3086. var item = new Ext.menu.CheckItem({
  3087. text: records[i].get(this.labelField),
  3088. group: gid,
  3089. checked: this.selected.indexOf(records[i].id) > -1,
  3090. hideOnClick: false});
  3091. item.itemId = records[i].id;
  3092. item.on('checkchange', this.checkChange, this);
  3093. this.add(item);
  3094. }
  3095. this.loaded = true;
  3096. if (visible) {
  3097. this.show();
  3098. }
  3099. this.fireEvent('load', this, records);
  3100. },
  3101. <div id="method-Ext.ux.menu.ListMenu-getSelected"></div>/**
  3102. * Get the selected items.
  3103. * @return {Array} selected
  3104. */
  3105. getSelected : function () {
  3106. return this.selected;
  3107. },
  3108. /** @private */
  3109. setSelected : function (value) {
  3110. value = this.selected = [].concat(value);
  3111. if (this.loaded) {
  3112. this.items.each(function(item){
  3113. item.setChecked(false, true);
  3114. for (var i = 0, len = value.length; i < len; i++) {
  3115. if (item.itemId == value[i]) {
  3116. item.setChecked(true, true);
  3117. }
  3118. }
  3119. }, this);
  3120. }
  3121. },
  3122. <div id="method-Ext.ux.menu.ListMenu-checkChange"></div>/**
  3123. * Handler for the 'checkchange' event from an check item in this menu
  3124. * @param {Object} item Ext.menu.CheckItem
  3125. * @param {Object} checked The checked value that was set
  3126. */
  3127. checkChange : function (item, checked) {
  3128. var value = [];
  3129. this.items.each(function(item){
  3130. if (item.checked) {
  3131. value.push(item.itemId);
  3132. }
  3133. },this);
  3134. this.selected = value;
  3135. this.fireEvent('checkchange', item, checked);
  3136. }
  3137. });Ext.ns('Ext.ux.menu');
  3138. /**
  3139. * @class Ext.ux.menu.RangeMenu
  3140. * @extends Ext.menu.Menu
  3141. * Custom implementation of Ext.menu.Menu that has preconfigured
  3142. * items for gt, lt, eq.
  3143. * <p><b><u>Example Usage:</u></b></p>
  3144. * <pre><code>
  3145. * </code></pre>
  3146. */
  3147. Ext.ux.menu.RangeMenu = Ext.extend(Ext.menu.Menu, {
  3148. constructor : function (config) {
  3149. Ext.ux.menu.RangeMenu.superclass.constructor.call(this, config);
  3150. this.addEvents(
  3151. <div id="event-Ext.ux.menu.RangeMenu-update"></div>/**
  3152. * @event update
  3153. * Fires when a filter configuration has changed
  3154. * @param {Ext.ux.grid.filter.Filter} this The filter object.
  3155. */
  3156. 'update'
  3157. );
  3158. this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
  3159. var i, len, item, cfg, Cls;
  3160. for (i = 0, len = this.menuItems.length; i < len; i++) {
  3161. item = this.menuItems[i];
  3162. if (item !== '-') {
  3163. // defaults
  3164. cfg = {
  3165. itemId: 'range-' + item,
  3166. enableKeyEvents: true,
  3167. iconCls: this.iconCls[item] || 'no-icon',
  3168. listeners: {
  3169. scope: this,
  3170. keyup: this.onInputKeyUp
  3171. }
  3172. };
  3173. Ext.apply(
  3174. cfg,
  3175. // custom configs
  3176. Ext.applyIf(this.fields[item] || {}, this.fieldCfg[item]),
  3177. // configurable defaults
  3178. this.menuItemCfgs
  3179. );
  3180. Cls = cfg.fieldCls || this.fieldCls;
  3181. item = this.fields[item] = new Cls(cfg);
  3182. }
  3183. this.add(item);
  3184. }
  3185. },
  3186. /**
  3187. * @private
  3188. * called by this.updateTask
  3189. */
  3190. fireUpdate : function () {
  3191. this.fireEvent('update', this);
  3192. },
  3193. <div id="method-Ext.ux.menu.RangeMenu-getValue"></div>/**
  3194. * Get and return the value of the filter.
  3195. * @return {String} The value of this filter
  3196. */
  3197. getValue : function () {
  3198. var result = {}, key, field;
  3199. for (key in this.fields) {
  3200. field = this.fields[key];
  3201. if (field.isValid() && String(field.getValue()).length > 0) {
  3202. result[key] = field.getValue();
  3203. }
  3204. }
  3205. return result;
  3206. },
  3207. <div id="method-Ext.ux.menu.RangeMenu-setValue"></div>/**
  3208. * Set the value of this menu and fires the 'update' event.
  3209. * @param {Object} data The data to assign to this menu
  3210. */
  3211. setValue : function (data) {
  3212. var key;
  3213. for (key in this.fields) {
  3214. this.fields[key].setValue(data[key] !== undefined ? data[key] : '');
  3215. }
  3216. this.fireEvent('update', this);
  3217. },
  3218. /**
  3219. * @private
  3220. * Handler method called when there is a keyup event on an input
  3221. * item of this menu.
  3222. */
  3223. onInputKeyUp : function (field, e) {
  3224. var k = e.getKey();
  3225. if (k == e.RETURN && field.isValid()) {
  3226. e.stopEvent();
  3227. this.hide(true);
  3228. return;
  3229. }
  3230. if (field == this.fields.eq) {
  3231. if (this.fields.gt) {
  3232. this.fields.gt.setValue(null);
  3233. }
  3234. if (this.fields.lt) {
  3235. this.fields.lt.setValue(null);
  3236. }
  3237. }
  3238. else {
  3239. this.fields.eq.setValue(null);
  3240. }
  3241. // restart the timer
  3242. this.updateTask.delay(this.updateBuffer);
  3243. }
  3244. });
  3245. Ext.ns('Ext.ux.grid');
  3246. /**
  3247. * @class Ext.ux.grid.GroupSummary
  3248. * @extends Ext.util.Observable
  3249. * A GridPanel plugin that enables dynamic column calculations and a dynamically
  3250. * updated grouped summary row.
  3251. */
  3252. Ext.ux.grid.GroupSummary = Ext.extend(Ext.util.Observable, {
  3253. <div id="cfg-Ext.ux.grid.GroupSummary-summaryRenderer"></div>/**
  3254. * @cfg {Function} summaryRenderer Renderer example:<pre><code>
  3255. summaryRenderer: function(v, params, data){
  3256. return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
  3257. },
  3258. * </code></pre>
  3259. */
  3260. <div id="cfg-Ext.ux.grid.GroupSummary-summaryType"></div>/**
  3261. * @cfg {String} summaryType (Optional) The type of
  3262. * calculation to be used for the column. For options available see
  3263. * {@link #Calculations}.
  3264. */
  3265. constructor : function(config){
  3266. Ext.apply(this, config);
  3267. Ext.ux.grid.GroupSummary.superclass.constructor.call(this);
  3268. },
  3269. init : function(grid){
  3270. this.grid = grid;
  3271. var v = this.view = grid.getView();
  3272. v.doGroupEnd = this.doGroupEnd.createDelegate(this);
  3273. v.afterMethod('onColumnWidthUpdated', this.doWidth, this);
  3274. v.afterMethod('onAllColumnWidthsUpdated', this.doAllWidths, this);
  3275. v.afterMethod('onColumnHiddenUpdated', this.doHidden, this);
  3276. v.afterMethod('onUpdate', this.doUpdate, this);
  3277. v.afterMethod('onRemove', this.doRemove, this);
  3278. if(!this.rowTpl){
  3279. this.rowTpl = new Ext.Template(
  3280. '<div class="x-grid3-summary-row" style="{tstyle}">',
  3281. '<table class="x-grid3-summary-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
  3282. '<tbody><tr>{cells}</tr></tbody>',
  3283. '</table></div>'
  3284. );
  3285. this.rowTpl.disableFormats = true;
  3286. }
  3287. this.rowTpl.compile();
  3288. if(!this.cellTpl){
  3289. this.cellTpl = new Ext.Template(
  3290. '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}">',
  3291. '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on">{value}</div>',
  3292. "</td>"
  3293. );
  3294. this.cellTpl.disableFormats = true;
  3295. }
  3296. this.cellTpl.compile();
  3297. },
  3298. <div id="method-Ext.ux.grid.GroupSummary-toggleSummaries"></div>/**
  3299. * Toggle the display of the summary row on/off
  3300. * @param {Boolean} visible <tt>true</tt> to show the summary, <tt>false</tt> to hide the summary.
  3301. */
  3302. toggleSummaries : function(visible){
  3303. var el = this.grid.getGridEl();
  3304. if(el){
  3305. if(visible === undefined){
  3306. visible = el.hasClass('x-grid-hide-summary');
  3307. }
  3308. el[visible ? 'removeClass' : 'addClass']('x-grid-hide-summary');
  3309. }
  3310. },
  3311. renderSummary : function(o, cs){
  3312. cs = cs || this.view.getColumnData();
  3313. var cfg = this.grid.getColumnModel().config,
  3314. buf = [], c, p = {}, cf, last = cs.length-1;
  3315. for(var i = 0, len = cs.length; i < len; i++){
  3316. c = cs[i];
  3317. cf = cfg[i];
  3318. p.id = c.id;
  3319. p.style = c.style;
  3320. p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
  3321. if(cf.summaryType || cf.summaryRenderer){
  3322. p.value = (cf.summaryRenderer || c.renderer)(o.data[c.name], p, o);
  3323. }else{
  3324. p.value = '';
  3325. }
  3326. if(p.value == undefined || p.value === "") p.value = "&#160;";
  3327. buf[buf.length] = this.cellTpl.apply(p);
  3328. }
  3329. return this.rowTpl.apply({
  3330. tstyle: 'width:'+this.view.getTotalWidth()+';',
  3331. cells: buf.join('')
  3332. });
  3333. },
  3334. /**
  3335. * @private
  3336. * @param {Object} rs
  3337. * @param {Object} cs
  3338. */
  3339. calculate : function(rs, cs){
  3340. var data = {}, r, c, cfg = this.grid.getColumnModel().config, cf;
  3341. for(var j = 0, jlen = rs.length; j < jlen; j++){
  3342. r = rs[j];
  3343. for(var i = 0, len = cs.length; i < len; i++){
  3344. c = cs[i];
  3345. cf = cfg[i];
  3346. if(cf.summaryType){
  3347. data[c.name] = Ext.ux.grid.GroupSummary.Calculations[cf.summaryType](data[c.name] || 0, r, c.name, data);
  3348. }
  3349. }
  3350. }
  3351. return data;
  3352. },
  3353. doGroupEnd : function(buf, g, cs, ds, colCount){
  3354. var data = this.calculate(g.rs, cs);
  3355. buf.push('</div>', this.renderSummary({data: data}, cs), '</div>');
  3356. },
  3357. doWidth : function(col, w, tw){
  3358. if(!this.isGrouped()){
  3359. return;
  3360. }
  3361. var gs = this.view.getGroups(),
  3362. len = gs.length,
  3363. i = 0,
  3364. s;
  3365. for(; i < len; ++i){
  3366. s = gs[i].childNodes[2];
  3367. s.style.width = tw;
  3368. s.firstChild.style.width = tw;
  3369. s.firstChild.rows[0].childNodes[col].style.width = w;
  3370. }
  3371. },
  3372. doAllWidths : function(ws, tw){
  3373. if(!this.isGrouped()){
  3374. return;
  3375. }
  3376. var gs = this.view.getGroups(),
  3377. len = gs.length,
  3378. i = 0,
  3379. j,
  3380. s,
  3381. cells,
  3382. wlen = ws.length;
  3383. for(; i < len; i++){
  3384. s = gs[i].childNodes[2];
  3385. s.style.width = tw;
  3386. s.firstChild.style.width = tw;
  3387. cells = s.firstChild.rows[0].childNodes;
  3388. for(j = 0; j < wlen; j++){
  3389. cells[j].style.width = ws[j];
  3390. }
  3391. }
  3392. },
  3393. doHidden : function(col, hidden, tw){
  3394. if(!this.isGrouped()){
  3395. return;
  3396. }
  3397. var gs = this.view.getGroups(),
  3398. len = gs.length,
  3399. i = 0,
  3400. s,
  3401. display = hidden ? 'none' : '';
  3402. for(; i < len; i++){
  3403. s = gs[i].childNodes[2];
  3404. s.style.width = tw;
  3405. s.firstChild.style.width = tw;
  3406. s.firstChild.rows[0].childNodes[col].style.display = display;
  3407. }
  3408. },
  3409. isGrouped : function(){
  3410. return !Ext.isEmpty(this.grid.getStore().groupField);
  3411. },
  3412. // Note: requires that all (or the first) record in the
  3413. // group share the same group value. Returns false if the group
  3414. // could not be found.
  3415. refreshSummary : function(groupValue){
  3416. return this.refreshSummaryById(this.view.getGroupId(groupValue));
  3417. },
  3418. getSummaryNode : function(gid){
  3419. var g = Ext.fly(gid, '_gsummary');
  3420. if(g){
  3421. return g.down('.x-grid3-summary-row', true);
  3422. }
  3423. return null;
  3424. },
  3425. refreshSummaryById : function(gid){
  3426. var g = Ext.getDom(gid);
  3427. if(!g){
  3428. return false;
  3429. }
  3430. var rs = [];
  3431. this.grid.getStore().each(function(r){
  3432. if(r._groupId == gid){
  3433. rs[rs.length] = r;
  3434. }
  3435. });
  3436. var cs = this.view.getColumnData(),
  3437. data = this.calculate(rs, cs),
  3438. markup = this.renderSummary({data: data}, cs),
  3439. existing = this.getSummaryNode(gid);
  3440. if(existing){
  3441. g.removeChild(existing);
  3442. }
  3443. Ext.DomHelper.append(g, markup);
  3444. return true;
  3445. },
  3446. doUpdate : function(ds, record){
  3447. this.refreshSummaryById(record._groupId);
  3448. },
  3449. doRemove : function(ds, record, index, isUpdate){
  3450. if(!isUpdate){
  3451. this.refreshSummaryById(record._groupId);
  3452. }
  3453. },
  3454. <div id="method-Ext.ux.grid.GroupSummary-showSummaryMsg"></div>/**
  3455. * Show a message in the summary row.
  3456. * <pre><code>
  3457. grid.on('afteredit', function(){
  3458. var groupValue = 'Ext Forms: Field Anchoring';
  3459. summary.showSummaryMsg(groupValue, 'Updating Summary...');
  3460. });
  3461. * </code></pre>
  3462. * @param {String} groupValue
  3463. * @param {String} msg Text to use as innerHTML for the summary row.
  3464. */
  3465. showSummaryMsg : function(groupValue, msg){
  3466. var gid = this.view.getGroupId(groupValue),
  3467. node = this.getSummaryNode(gid);
  3468. if(node){
  3469. node.innerHTML = '<div class="x-grid3-summary-msg">' + msg + '</div>';
  3470. }
  3471. }
  3472. });
  3473. //backwards compat
  3474. Ext.grid.GroupSummary = Ext.ux.grid.GroupSummary;
  3475. <div id="prop-Ext.ux.grid.GroupSummary-Calculations"></div>/**
  3476. * Calculation types for summary row:</p><div class="mdetail-params"><ul>
  3477. * <li><b><tt>sum</tt></b> : <div class="sub-desc"></div></li>
  3478. * <li><b><tt>count</tt></b> : <div class="sub-desc"></div></li>
  3479. * <li><b><tt>max</tt></b> : <div class="sub-desc"></div></li>
  3480. * <li><b><tt>min</tt></b> : <div class="sub-desc"></div></li>
  3481. * <li><b><tt>average</tt></b> : <div class="sub-desc"></div></li>
  3482. * </ul></div>
  3483. * <p>Custom calculations may be implemented. An example of
  3484. * custom <code>summaryType=totalCost</code>:</p><pre><code>
  3485. // define a custom summary function
  3486. Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
  3487. return v + (record.data.estimate * record.data.rate);
  3488. };
  3489. * </code></pre>
  3490. * @property Calculations
  3491. */
  3492. Ext.ux.grid.GroupSummary.Calculations = {
  3493. 'sum' : function(v, record, field){
  3494. return v + (record.data[field]||0);
  3495. },
  3496. 'count' : function(v, record, field, data){
  3497. return data[field+'count'] ? ++data[field+'count'] : (data[field+'count'] = 1);
  3498. },
  3499. 'max' : function(v, record, field, data){
  3500. var v = record.data[field];
  3501. var max = data[field+'max'] === undefined ? (data[field+'max'] = v) : data[field+'max'];
  3502. return v > max ? (data[field+'max'] = v) : max;
  3503. },
  3504. 'min' : function(v, record, field, data){
  3505. var v = record.data[field];
  3506. var min = data[field+'min'] === undefined ? (data[field+'min'] = v) : data[field+'min'];
  3507. return v < min ? (data[field+'min'] = v) : min;
  3508. },
  3509. 'average' : function(v, record, field, data){
  3510. var c = data[field+'count'] ? ++data[field+'count'] : (data[field+'count'] = 1);
  3511. var t = (data[field+'total'] = ((data[field+'total']||0) + (record.data[field]||0)));
  3512. return t === 0 ? 0 : t / c;
  3513. }
  3514. };
  3515. Ext.grid.GroupSummary.Calculations = Ext.ux.grid.GroupSummary.Calculations;
  3516. /**
  3517. * @class Ext.ux.grid.HybridSummary
  3518. * @extends Ext.ux.grid.GroupSummary
  3519. * Adds capability to specify the summary data for the group via json as illustrated here:
  3520. * <pre><code>
  3521. {
  3522. data: [
  3523. {
  3524. projectId: 100, project: 'House',
  3525. taskId: 112, description: 'Paint',
  3526. estimate: 6, rate: 150,
  3527. due:'06/24/2007'
  3528. },
  3529. ...
  3530. ],
  3531. summaryData: {
  3532. 'House': {
  3533. description: 14, estimate: 9,
  3534. rate: 99, due: new Date(2009, 6, 29),
  3535. cost: 999
  3536. }
  3537. }
  3538. }
  3539. * </code></pre>
  3540. *
  3541. */
  3542. Ext.ux.grid.HybridSummary = Ext.extend(Ext.ux.grid.GroupSummary, {
  3543. /**
  3544. * @private
  3545. * @param {Object} rs
  3546. * @param {Object} cs
  3547. */
  3548. calculate : function(rs, cs){
  3549. var gcol = this.view.getGroupField(),
  3550. gvalue = rs[0].data[gcol],
  3551. gdata = this.getSummaryData(gvalue);
  3552. return gdata || Ext.ux.grid.HybridSummary.superclass.calculate.call(this, rs, cs);
  3553. },
  3554. <div id="method-Ext.ux.grid.HybridSummary-updateSummaryData"></div>/**
  3555. * <pre><code>
  3556. grid.on('afteredit', function(){
  3557. var groupValue = 'Ext Forms: Field Anchoring';
  3558. summary.showSummaryMsg(groupValue, 'Updating Summary...');
  3559. setTimeout(function(){ // simulate server call
  3560. // HybridSummary class implements updateSummaryData
  3561. summary.updateSummaryData(groupValue,
  3562. // create data object based on configured dataIndex
  3563. {description: 22, estimate: 888, rate: 888, due: new Date(), cost: 8});
  3564. }, 2000);
  3565. });
  3566. * </code></pre>
  3567. * @param {String} groupValue
  3568. * @param {Object} data data object
  3569. * @param {Boolean} skipRefresh (Optional) Defaults to false
  3570. */
  3571. updateSummaryData : function(groupValue, data, skipRefresh){
  3572. var json = this.grid.getStore().reader.jsonData;
  3573. if(!json.summaryData){
  3574. json.summaryData = {};
  3575. }
  3576. json.summaryData[groupValue] = data;
  3577. if(!skipRefresh){
  3578. this.refreshSummary(groupValue);
  3579. }
  3580. },
  3581. <div id="method-Ext.ux.grid.HybridSummary-getSummaryData"></div>/**
  3582. * Returns the summaryData for the specified groupValue or null.
  3583. * @param {String} groupValue
  3584. * @return {Object} summaryData
  3585. */
  3586. getSummaryData : function(groupValue){
  3587. var reader = this.grid.getStore().reader,
  3588. json = reader.jsonData,
  3589. fields = reader.recordType.prototype.fields,
  3590. v;
  3591. if(json && json.summaryData){
  3592. v = json.summaryData[groupValue];
  3593. if(v){
  3594. return reader.extractValues(v, fields.items, fields.length);
  3595. }
  3596. }
  3597. return null;
  3598. }
  3599. });
  3600. //backwards compat
  3601. Ext.grid.HybridSummary = Ext.ux.grid.HybridSummary;
  3602. Ext.ux.GroupTab = Ext.extend(Ext.Container, {
  3603. mainItem: 0,
  3604. expanded: true,
  3605. deferredRender: true,
  3606. activeTab: null,
  3607. idDelimiter: '__',
  3608. headerAsText: false,
  3609. frame: false,
  3610. hideBorders: true,
  3611. initComponent: function(config){
  3612. Ext.apply(this, config);
  3613. this.frame = false;
  3614. Ext.ux.GroupTab.superclass.initComponent.call(this);
  3615. this.addEvents('activate', 'deactivate', 'changemainitem', 'beforetabchange', 'tabchange');
  3616. this.setLayout(new Ext.layout.CardLayout({
  3617. deferredRender: this.deferredRender
  3618. }));
  3619. if (!this.stack) {
  3620. this.stack = Ext.TabPanel.AccessStack();
  3621. }
  3622. this.initItems();
  3623. this.on('beforerender', function(){
  3624. this.groupEl = this.ownerCt.getGroupEl(this);
  3625. }, this);
  3626. this.on('add', this.onAdd, this, {
  3627. target: this
  3628. });
  3629. this.on('remove', this.onRemove, this, {
  3630. target: this
  3631. });
  3632. if (this.mainItem !== undefined) {
  3633. var item = (typeof this.mainItem == 'object') ? this.mainItem : this.items.get(this.mainItem);
  3634. delete this.mainItem;
  3635. this.setMainItem(item);
  3636. }
  3637. },
  3638. <div id="method-Ext.ux.grid.HybridSummary-setActiveTab"></div>/**
  3639. * Sets the specified tab as the active tab. This method fires the {@link #beforetabchange} event which
  3640. * can return false to cancel the tab change.
  3641. * @param {String/Panel} tab The id or tab Panel to activate
  3642. */
  3643. setActiveTab : function(item){
  3644. item = this.getComponent(item);
  3645. if(!item){
  3646. return false;
  3647. }
  3648. if(!this.rendered){
  3649. this.activeTab = item;
  3650. return true;
  3651. }
  3652. if(this.activeTab != item && this.fireEvent('beforetabchange', this, item, this.activeTab) !== false){
  3653. if(this.activeTab && this.activeTab != this.mainItem){
  3654. var oldEl = this.getTabEl(this.activeTab);
  3655. if(oldEl){
  3656. Ext.fly(oldEl).removeClass('x-grouptabs-strip-active');
  3657. }
  3658. }
  3659. var el = this.getTabEl(item);
  3660. Ext.fly(el).addClass('x-grouptabs-strip-active');
  3661. this.activeTab = item;
  3662. this.stack.add(item);
  3663. this.layout.setActiveItem(item);
  3664. if(this.layoutOnTabChange && item.doLayout){
  3665. item.doLayout();
  3666. }
  3667. if(this.scrolling){
  3668. this.scrollToTab(item, this.animScroll);
  3669. }
  3670. this.fireEvent('tabchange', this, item);
  3671. return true;
  3672. }
  3673. return false;
  3674. },
  3675. getTabEl: function(item){
  3676. if (item == this.mainItem) {
  3677. return this.groupEl;
  3678. }
  3679. return Ext.TabPanel.prototype.getTabEl.call(this, item);
  3680. },
  3681. onRender: function(ct, position){
  3682. Ext.ux.GroupTab.superclass.onRender.call(this, ct, position);
  3683. this.strip = Ext.fly(this.groupEl).createChild({
  3684. tag: 'ul',
  3685. cls: 'x-grouptabs-sub'
  3686. });
  3687. this.tooltip = new Ext.ToolTip({
  3688. target: this.groupEl,
  3689. delegate: 'a.x-grouptabs-text',
  3690. trackMouse: true,
  3691. renderTo: document.body,
  3692. listeners: {
  3693. beforeshow: function(tip) {
  3694. var item = (tip.triggerElement.parentNode === this.mainItem.tabEl)
  3695. ? this.mainItem
  3696. : this.findById(tip.triggerElement.parentNode.id.split(this.idDelimiter)[1]);
  3697. if(!item.tabTip) {
  3698. return false;
  3699. }
  3700. tip.body.dom.innerHTML = item.tabTip;
  3701. },
  3702. scope: this
  3703. }
  3704. });
  3705. if (!this.itemTpl) {
  3706. var tt = new Ext.Template('<li class="{cls}" id="{id}">', '<a onclick="return false;" class="x-grouptabs-text {iconCls}">{text}</a>', '</li>');
  3707. tt.disableFormats = true;
  3708. tt.compile();
  3709. Ext.ux.GroupTab.prototype.itemTpl = tt;
  3710. }
  3711. this.items.each(this.initTab, this);
  3712. },
  3713. afterRender: function(){
  3714. Ext.ux.GroupTab.superclass.afterRender.call(this);
  3715. if (this.activeTab !== undefined) {
  3716. var item = (typeof this.activeTab == 'object') ? this.activeTab : this.items.get(this.activeTab);
  3717. delete this.activeTab;
  3718. this.setActiveTab(item);
  3719. }
  3720. },
  3721. // private
  3722. initTab: function(item, index){
  3723. var before = this.strip.dom.childNodes[index];
  3724. var p = Ext.TabPanel.prototype.getTemplateArgs.call(this, item);
  3725. if (item === this.mainItem) {
  3726. item.tabEl = this.groupEl;
  3727. p.cls += ' x-grouptabs-main-item';
  3728. }
  3729. var el = before ? this.itemTpl.insertBefore(before, p) : this.itemTpl.append(this.strip, p);
  3730. item.tabEl = item.tabEl || el;
  3731. item.on('disable', this.onItemDisabled, this);
  3732. item.on('enable', this.onItemEnabled, this);
  3733. item.on('titlechange', this.onItemTitleChanged, this);
  3734. item.on('iconchange', this.onItemIconChanged, this);
  3735. item.on('beforeshow', this.onBeforeShowItem, this);
  3736. },
  3737. setMainItem: function(item){
  3738. item = this.getComponent(item);
  3739. if (!item || this.fireEvent('changemainitem', this, item, this.mainItem) === false) {
  3740. return;
  3741. }
  3742. this.mainItem = item;
  3743. },
  3744. getMainItem: function(){
  3745. return this.mainItem || null;
  3746. },
  3747. // private
  3748. onBeforeShowItem: function(item){
  3749. if (item != this.activeTab) {
  3750. this.setActiveTab(item);
  3751. return false;
  3752. }
  3753. },
  3754. // private
  3755. onAdd: function(gt, item, index){
  3756. if (this.rendered) {
  3757. this.initTab.call(this, item, index);
  3758. }
  3759. },
  3760. // private
  3761. onRemove: function(tp, item){
  3762. Ext.destroy(Ext.get(this.getTabEl(item)));
  3763. this.stack.remove(item);
  3764. item.un('disable', this.onItemDisabled, this);
  3765. item.un('enable', this.onItemEnabled, this);
  3766. item.un('titlechange', this.onItemTitleChanged, this);
  3767. item.un('iconchange', this.onItemIconChanged, this);
  3768. item.un('beforeshow', this.onBeforeShowItem, this);
  3769. if (item == this.activeTab) {
  3770. var next = this.stack.next();
  3771. if (next) {
  3772. this.setActiveTab(next);
  3773. }
  3774. else if (this.items.getCount() > 0) {
  3775. this.setActiveTab(0);
  3776. }
  3777. else {
  3778. this.activeTab = null;
  3779. }
  3780. }
  3781. },
  3782. // private
  3783. onBeforeAdd: function(item){
  3784. var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);
  3785. if (existing) {
  3786. this.setActiveTab(item);
  3787. return false;
  3788. }
  3789. Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);
  3790. var es = item.elements;
  3791. item.elements = es ? es.replace(',header', '') : es;
  3792. item.border = (item.border === true);
  3793. },
  3794. // private
  3795. onItemDisabled: Ext.TabPanel.prototype.onItemDisabled,
  3796. onItemEnabled: Ext.TabPanel.prototype.onItemEnabled,
  3797. // private
  3798. onItemTitleChanged: function(item){
  3799. var el = this.getTabEl(item);
  3800. if (el) {
  3801. Ext.fly(el).child('a.x-grouptabs-text', true).innerHTML = item.title;
  3802. }
  3803. },
  3804. //private
  3805. onItemIconChanged: function(item, iconCls, oldCls){
  3806. var el = this.getTabEl(item);
  3807. if (el) {
  3808. Ext.fly(el).child('a.x-grouptabs-text').replaceClass(oldCls, iconCls);
  3809. }
  3810. },
  3811. beforeDestroy: function(){
  3812. Ext.TabPanel.prototype.beforeDestroy.call(this);
  3813. this.tooltip.destroy();
  3814. }
  3815. });
  3816. Ext.reg('grouptab', Ext.ux.GroupTab);
  3817. Ext.ns('Ext.ux');
  3818. Ext.ux.GroupTabPanel = Ext.extend(Ext.TabPanel, {
  3819. tabPosition: 'left',
  3820. alternateColor: false,
  3821. alternateCls: 'x-grouptabs-panel-alt',
  3822. defaultType: 'grouptab',
  3823. deferredRender: false,
  3824. activeGroup : null,
  3825. initComponent: function(){
  3826. Ext.ux.GroupTabPanel.superclass.initComponent.call(this);
  3827. this.addEvents(
  3828. 'beforegroupchange',
  3829. 'groupchange'
  3830. );
  3831. this.elements = 'body,header';
  3832. this.stripTarget = 'header';
  3833. this.tabPosition = this.tabPosition == 'right' ? 'right' : 'left';
  3834. this.addClass('x-grouptabs-panel');
  3835. if (this.tabStyle && this.tabStyle != '') {
  3836. this.addClass('x-grouptabs-panel-' + this.tabStyle);
  3837. }
  3838. if (this.alternateColor) {
  3839. this.addClass(this.alternateCls);
  3840. }
  3841. this.on('beforeadd', function(gtp, item, index){
  3842. this.initGroup(item, index);
  3843. });
  3844. this.items.each(function(item){
  3845. item.on('tabchange',function(item){
  3846. this.fireEvent('tabchange', this, item.activeTab);
  3847. }, this);
  3848. },this);
  3849. },
  3850. initEvents : function() {
  3851. this.mon(this.strip, 'mousedown', this.onStripMouseDown, this);
  3852. },
  3853. onRender: function(ct, position){
  3854. Ext.TabPanel.superclass.onRender.call(this, ct, position);
  3855. if(this.plain){
  3856. var pos = this.tabPosition == 'top' ? 'header' : 'footer';
  3857. this[pos].addClass('x-tab-panel-'+pos+'-plain');
  3858. }
  3859. var st = this[this.stripTarget];
  3860. this.stripWrap = st.createChild({cls:'x-tab-strip-wrap ', cn:{
  3861. tag:'ul', cls:'x-grouptabs-strip x-grouptabs-tab-strip-'+this.tabPosition}});
  3862. var beforeEl = (this.tabPosition=='bottom' ? this.stripWrap : null);
  3863. this.strip = new Ext.Element(this.stripWrap.dom.firstChild);
  3864. this.header.addClass('x-grouptabs-panel-header');
  3865. this.bwrap.addClass('x-grouptabs-bwrap');
  3866. this.body.addClass('x-tab-panel-body-'+this.tabPosition + ' x-grouptabs-panel-body');
  3867. if (!this.groupTpl) {
  3868. var tt = new Ext.Template(
  3869. '<li class="{cls}" id="{id}">',
  3870. '<a class="x-grouptabs-expand" onclick="return false;"></a>',
  3871. '<a class="x-grouptabs-text {iconCls}" href="#" onclick="return false;">',
  3872. '<span>{text}</span></a>',
  3873. '</li>'
  3874. );
  3875. tt.disableFormats = true;
  3876. tt.compile();
  3877. Ext.ux.GroupTabPanel.prototype.groupTpl = tt;
  3878. }
  3879. this.items.each(this.initGroup, this);
  3880. },
  3881. afterRender: function(){
  3882. Ext.ux.GroupTabPanel.superclass.afterRender.call(this);
  3883. this.tabJoint = Ext.fly(this.body.dom.parentNode).createChild({
  3884. cls: 'x-tab-joint'
  3885. });
  3886. this.addClass('x-tab-panel-' + this.tabPosition);
  3887. this.header.setWidth(this.tabWidth);
  3888. if (this.activeGroup !== undefined) {
  3889. var group = (typeof this.activeGroup == 'object') ? this.activeGroup : this.items.get(this.activeGroup);
  3890. delete this.activeGroup;
  3891. this.setActiveGroup(group);
  3892. group.setActiveTab(group.getMainItem());
  3893. }
  3894. },
  3895. getGroupEl : Ext.TabPanel.prototype.getTabEl,
  3896. // private
  3897. findTargets: function(e){
  3898. var item = null,
  3899. itemEl = e.getTarget('li', this.strip);
  3900. if (itemEl) {
  3901. item = this.findById(itemEl.id.split(this.idDelimiter)[1]);
  3902. if (item.disabled) {
  3903. return {
  3904. expand: null,
  3905. item: null,
  3906. el: null
  3907. };
  3908. }
  3909. }
  3910. return {
  3911. expand: e.getTarget('.x-grouptabs-expand', this.strip),
  3912. isGroup: !e.getTarget('ul.x-grouptabs-sub', this.strip),
  3913. item: item,
  3914. el: itemEl
  3915. };
  3916. },
  3917. // private
  3918. onStripMouseDown: function(e){
  3919. if (e.button != 0) {
  3920. return;
  3921. }
  3922. e.preventDefault();
  3923. var t = this.findTargets(e);
  3924. if (t.expand) {
  3925. this.toggleGroup(t.el);
  3926. }
  3927. else if (t.item) {
  3928. if(t.isGroup) {
  3929. t.item.setActiveTab(t.item.getMainItem());
  3930. }
  3931. else {
  3932. t.item.ownerCt.setActiveTab(t.item);
  3933. }
  3934. }
  3935. },
  3936. expandGroup: function(groupEl){
  3937. if(groupEl.isXType) {
  3938. groupEl = this.getGroupEl(groupEl);
  3939. }
  3940. Ext.fly(groupEl).addClass('x-grouptabs-expanded');
  3941. this.syncTabJoint();
  3942. },
  3943. toggleGroup: function(groupEl){
  3944. if(groupEl.isXType) {
  3945. groupEl = this.getGroupEl(groupEl);
  3946. }
  3947. Ext.fly(groupEl).toggleClass('x-grouptabs-expanded');
  3948. this.syncTabJoint();
  3949. },
  3950. collapseGroup: function(groupEl){
  3951. if(groupEl.isXType) {
  3952. groupEl = this.getGroupEl(groupEl);
  3953. }
  3954. Ext.fly(groupEl).removeClass('x-grouptabs-expanded');
  3955. this.syncTabJoint();
  3956. },
  3957. syncTabJoint: function(groupEl){
  3958. if (!this.tabJoint) {
  3959. return;
  3960. }
  3961. groupEl = groupEl || this.getGroupEl(this.activeGroup);
  3962. if(groupEl) {
  3963. this.tabJoint.setHeight(Ext.fly(groupEl).getHeight() - 2);
  3964. var y = Ext.isGecko2 ? 0 : 1;
  3965. if (this.tabPosition == 'left'){
  3966. this.tabJoint.alignTo(groupEl, 'tl-tr', [-2,y]);
  3967. }
  3968. else {
  3969. this.tabJoint.alignTo(groupEl, 'tr-tl', [1,y]);
  3970. }
  3971. }
  3972. else {
  3973. this.tabJoint.hide();
  3974. }
  3975. },
  3976. getActiveTab : function() {
  3977. if(!this.activeGroup) return null;
  3978. return this.activeGroup.getTabEl(this.activeGroup.activeTab) || null;
  3979. },
  3980. onResize: function(){
  3981. Ext.ux.GroupTabPanel.superclass.onResize.apply(this, arguments);
  3982. this.syncTabJoint();
  3983. },
  3984. createCorner: function(el, pos){
  3985. return Ext.fly(el).createChild({
  3986. cls: 'x-grouptabs-corner x-grouptabs-corner-' + pos
  3987. });
  3988. },
  3989. initGroup: function(group, index){
  3990. var before = this.strip.dom.childNodes[index],
  3991. p = this.getTemplateArgs(group);
  3992. if (index === 0) {
  3993. p.cls += ' x-tab-first';
  3994. }
  3995. p.cls += ' x-grouptabs-main';
  3996. p.text = group.getMainItem().title;
  3997. var el = before ? this.groupTpl.insertBefore(before, p) : this.groupTpl.append(this.strip, p),
  3998. tl = this.createCorner(el, 'top-' + this.tabPosition),
  3999. bl = this.createCorner(el, 'bottom-' + this.tabPosition);
  4000. group.tabEl = el;
  4001. if (group.expanded) {
  4002. this.expandGroup(el);
  4003. }
  4004. if (Ext.isIE6 || (Ext.isIE && !Ext.isStrict)){
  4005. bl.setLeft('-10px');
  4006. bl.setBottom('-5px');
  4007. tl.setLeft('-10px');
  4008. tl.setTop('-5px');
  4009. }
  4010. this.mon(group, {
  4011. scope: this,
  4012. changemainitem: this.onGroupChangeMainItem,
  4013. beforetabchange: this.onGroupBeforeTabChange
  4014. });
  4015. },
  4016. setActiveGroup : function(group) {
  4017. group = this.getComponent(group);
  4018. if(!group){
  4019. return false;
  4020. }
  4021. if(!this.rendered){
  4022. this.activeGroup = group;
  4023. return true;
  4024. }
  4025. if(this.activeGroup != group && this.fireEvent('beforegroupchange', this, group, this.activeGroup) !== false){
  4026. if(this.activeGroup){
  4027. this.activeGroup.activeTab = null;
  4028. var oldEl = this.getGroupEl(this.activeGroup);
  4029. if(oldEl){
  4030. Ext.fly(oldEl).removeClass('x-grouptabs-strip-active');
  4031. }
  4032. }
  4033. var groupEl = this.getGroupEl(group);
  4034. Ext.fly(groupEl).addClass('x-grouptabs-strip-active');
  4035. this.activeGroup = group;
  4036. this.stack.add(group);
  4037. this.layout.setActiveItem(group);
  4038. this.syncTabJoint(groupEl);
  4039. this.fireEvent('groupchange', this, group);
  4040. return true;
  4041. }
  4042. return false;
  4043. },
  4044. onGroupBeforeTabChange: function(group, newTab, oldTab){
  4045. if(group !== this.activeGroup || newTab !== oldTab) {
  4046. this.strip.select('.x-grouptabs-sub > li.x-grouptabs-strip-active', true).removeClass('x-grouptabs-strip-active');
  4047. }
  4048. this.expandGroup(this.getGroupEl(group));
  4049. if(group !== this.activeGroup) {
  4050. return this.setActiveGroup(group);
  4051. }
  4052. },
  4053. getFrameHeight: function(){
  4054. var h = this.el.getFrameWidth('tb');
  4055. h += (this.tbar ? this.tbar.getHeight() : 0) +
  4056. (this.bbar ? this.bbar.getHeight() : 0);
  4057. return h;
  4058. },
  4059. adjustBodyWidth: function(w){
  4060. return w - this.tabWidth;
  4061. }
  4062. });
  4063. Ext.reg('grouptabpanel', Ext.ux.GroupTabPanel);
  4064. /*
  4065. * Note that this control will most likely remain as an example, and not as a core Ext form
  4066. * control. However, the API will be changing in a future release and so should not yet be
  4067. * treated as a final, stable API at this time.
  4068. */
  4069. /**
  4070. * @class Ext.ux.form.ItemSelector
  4071. * @extends Ext.form.Field
  4072. * A control that allows selection of between two Ext.ux.form.MultiSelect controls.
  4073. *
  4074. * @history
  4075. * 2008-06-19 bpm Original code contributed by Toby Stuart (with contributions from Robert Williams)
  4076. *
  4077. * @constructor
  4078. * Create a new ItemSelector
  4079. * @param {Object} config Configuration options
  4080. * @xtype itemselector
  4081. */
  4082. Ext.ux.form.ItemSelector = Ext.extend(Ext.form.Field, {
  4083. hideNavIcons:false,
  4084. imagePath:"",
  4085. iconUp:"up2.gif",
  4086. iconDown:"down2.gif",
  4087. iconLeft:"left2.gif",
  4088. iconRight:"right2.gif",
  4089. iconTop:"top2.gif",
  4090. iconBottom:"bottom2.gif",
  4091. drawUpIcon:true,
  4092. drawDownIcon:true,
  4093. drawLeftIcon:true,
  4094. drawRightIcon:true,
  4095. drawTopIcon:true,
  4096. drawBotIcon:true,
  4097. delimiter:',',
  4098. bodyStyle:null,
  4099. border:false,
  4100. defaultAutoCreate:{tag: "div"},
  4101. <div id="cfg-Ext.ux.form.ItemSelector-multiselects"></div>/**
  4102. * @cfg {Array} multiselects An array of {@link Ext.ux.form.MultiSelect} config objects, with at least all required parameters (e.g., store)
  4103. */
  4104. multiselects:null,
  4105. initComponent: function(){
  4106. Ext.ux.form.ItemSelector.superclass.initComponent.call(this);
  4107. this.addEvents({
  4108. 'rowdblclick' : true,
  4109. 'change' : true
  4110. });
  4111. },
  4112. onRender: function(ct, position){
  4113. Ext.ux.form.ItemSelector.superclass.onRender.call(this, ct, position);
  4114. // Internal default configuration for both multiselects
  4115. var msConfig = [{
  4116. legend: 'Available',
  4117. draggable: true,
  4118. droppable: true,
  4119. width: 100,
  4120. height: 100
  4121. },{
  4122. legend: 'Selected',
  4123. droppable: true,
  4124. draggable: true,
  4125. width: 100,
  4126. height: 100
  4127. }];
  4128. this.fromMultiselect = new Ext.ux.form.MultiSelect(Ext.applyIf(this.multiselects[0], msConfig[0]));
  4129. this.fromMultiselect.on('dblclick', this.onRowDblClick, this);
  4130. this.toMultiselect = new Ext.ux.form.MultiSelect(Ext.applyIf(this.multiselects[1], msConfig[1]));
  4131. this.toMultiselect.on('dblclick', this.onRowDblClick, this);
  4132. var p = new Ext.Panel({
  4133. bodyStyle:this.bodyStyle,
  4134. border:this.border,
  4135. layout:"table",
  4136. layoutConfig:{columns:3}
  4137. });
  4138. p.add(this.fromMultiselect);
  4139. var icons = new Ext.Panel({header:false});
  4140. p.add(icons);
  4141. p.add(this.toMultiselect);
  4142. p.render(this.el);
  4143. icons.el.down('.'+icons.bwrapCls).remove();
  4144. // ICON HELL!!!
  4145. if (this.imagePath!="" && this.imagePath.charAt(this.imagePath.length-1)!="/")
  4146. this.imagePath+="/";
  4147. this.iconUp = this.imagePath + (this.iconUp || 'up2.gif');
  4148. this.iconDown = this.imagePath + (this.iconDown || 'down2.gif');
  4149. this.iconLeft = this.imagePath + (this.iconLeft || 'left2.gif');
  4150. this.iconRight = this.imagePath + (this.iconRight || 'right2.gif');
  4151. this.iconTop = this.imagePath + (this.iconTop || 'top2.gif');
  4152. this.iconBottom = this.imagePath + (this.iconBottom || 'bottom2.gif');
  4153. var el=icons.getEl();
  4154. this.toTopIcon = el.createChild({tag:'img', src:this.iconTop, style:{cursor:'pointer', margin:'2px'}});
  4155. el.createChild({tag: 'br'});
  4156. this.upIcon = el.createChild({tag:'img', src:this.iconUp, style:{cursor:'pointer', margin:'2px'}});
  4157. el.createChild({tag: 'br'});
  4158. this.addIcon = el.createChild({tag:'img', src:this.iconRight, style:{cursor:'pointer', margin:'2px'}});
  4159. el.createChild({tag: 'br'});
  4160. this.removeIcon = el.createChild({tag:'img', src:this.iconLeft, style:{cursor:'pointer', margin:'2px'}});
  4161. el.createChild({tag: 'br'});
  4162. this.downIcon = el.createChild({tag:'img', src:this.iconDown, style:{cursor:'pointer', margin:'2px'}});
  4163. el.createChild({tag: 'br'});
  4164. this.toBottomIcon = el.createChild({tag:'img', src:this.iconBottom, style:{cursor:'pointer', margin:'2px'}});
  4165. this.toTopIcon.on('click', this.toTop, this);
  4166. this.upIcon.on('click', this.up, this);
  4167. this.downIcon.on('click', this.down, this);
  4168. this.toBottomIcon.on('click', this.toBottom, this);
  4169. this.addIcon.on('click', this.fromTo, this);
  4170. this.removeIcon.on('click', this.toFrom, this);
  4171. if (!this.drawUpIcon || this.hideNavIcons) { this.upIcon.dom.style.display='none'; }
  4172. if (!this.drawDownIcon || this.hideNavIcons) { this.downIcon.dom.style.display='none'; }
  4173. if (!this.drawLeftIcon || this.hideNavIcons) { this.addIcon.dom.style.display='none'; }
  4174. if (!this.drawRightIcon || this.hideNavIcons) { this.removeIcon.dom.style.display='none'; }
  4175. if (!this.drawTopIcon || this.hideNavIcons) { this.toTopIcon.dom.style.display='none'; }
  4176. if (!this.drawBotIcon || this.hideNavIcons) { this.toBottomIcon.dom.style.display='none'; }
  4177. var tb = p.body.first();
  4178. this.el.setWidth(p.body.first().getWidth());
  4179. p.body.removeClass();
  4180. this.hiddenName = this.name;
  4181. var hiddenTag = {tag: "input", type: "hidden", value: "", name: this.name};
  4182. this.hiddenField = this.el.createChild(hiddenTag);
  4183. },
  4184. doLayout: function(){
  4185. if(this.rendered){
  4186. this.fromMultiselect.fs.doLayout();
  4187. this.toMultiselect.fs.doLayout();
  4188. }
  4189. },
  4190. afterRender: function(){
  4191. Ext.ux.form.ItemSelector.superclass.afterRender.call(this);
  4192. this.toStore = this.toMultiselect.store;
  4193. this.toStore.on('add', this.valueChanged, this);
  4194. this.toStore.on('remove', this.valueChanged, this);
  4195. this.toStore.on('load', this.valueChanged, this);
  4196. this.valueChanged(this.toStore);
  4197. },
  4198. toTop : function() {
  4199. var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
  4200. var records = [];
  4201. if (selectionsArray.length > 0) {
  4202. selectionsArray.sort();
  4203. for (var i=0; i<selectionsArray.length; i++) {
  4204. record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
  4205. records.push(record);
  4206. }
  4207. selectionsArray = [];
  4208. for (var i=records.length-1; i>-1; i--) {
  4209. record = records[i];
  4210. this.toMultiselect.view.store.remove(record);
  4211. this.toMultiselect.view.store.insert(0, record);
  4212. selectionsArray.push(((records.length - 1) - i));
  4213. }
  4214. }
  4215. this.toMultiselect.view.refresh();
  4216. this.toMultiselect.view.select(selectionsArray);
  4217. },
  4218. toBottom : function() {
  4219. var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
  4220. var records = [];
  4221. if (selectionsArray.length > 0) {
  4222. selectionsArray.sort();
  4223. for (var i=0; i<selectionsArray.length; i++) {
  4224. record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
  4225. records.push(record);
  4226. }
  4227. selectionsArray = [];
  4228. for (var i=0; i<records.length; i++) {
  4229. record = records[i];
  4230. this.toMultiselect.view.store.remove(record);
  4231. this.toMultiselect.view.store.add(record);
  4232. selectionsArray.push((this.toMultiselect.view.store.getCount()) - (records.length - i));
  4233. }
  4234. }
  4235. this.toMultiselect.view.refresh();
  4236. this.toMultiselect.view.select(selectionsArray);
  4237. },
  4238. up : function() {
  4239. var record = null;
  4240. var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
  4241. selectionsArray.sort();
  4242. var newSelectionsArray = [];
  4243. if (selectionsArray.length > 0) {
  4244. for (var i=0; i<selectionsArray.length; i++) {
  4245. record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
  4246. if ((selectionsArray[i] - 1) >= 0) {
  4247. this.toMultiselect.view.store.remove(record);
  4248. this.toMultiselect.view.store.insert(selectionsArray[i] - 1, record);
  4249. newSelectionsArray.push(selectionsArray[i] - 1);
  4250. }
  4251. }
  4252. this.toMultiselect.view.refresh();
  4253. this.toMultiselect.view.select(newSelectionsArray);
  4254. }
  4255. },
  4256. down : function() {
  4257. var record = null;
  4258. var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
  4259. selectionsArray.sort();
  4260. selectionsArray.reverse();
  4261. var newSelectionsArray = [];
  4262. if (selectionsArray.length > 0) {
  4263. for (var i=0; i<selectionsArray.length; i++) {
  4264. record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
  4265. if ((selectionsArray[i] + 1) < this.toMultiselect.view.store.getCount()) {
  4266. this.toMultiselect.view.store.remove(record);
  4267. this.toMultiselect.view.store.insert(selectionsArray[i] + 1, record);
  4268. newSelectionsArray.push(selectionsArray[i] + 1);
  4269. }
  4270. }
  4271. this.toMultiselect.view.refresh();
  4272. this.toMultiselect.view.select(newSelectionsArray);
  4273. }
  4274. },
  4275. fromTo : function() {
  4276. var selectionsArray = this.fromMultiselect.view.getSelectedIndexes();
  4277. var records = [];
  4278. if (selectionsArray.length > 0) {
  4279. for (var i=0; i<selectionsArray.length; i++) {
  4280. record = this.fromMultiselect.view.store.getAt(selectionsArray[i]);
  4281. records.push(record);
  4282. }
  4283. if(!this.allowDup)selectionsArray = [];
  4284. for (var i=0; i<records.length; i++) {
  4285. record = records[i];
  4286. if(this.allowDup){
  4287. var x=new Ext.data.Record();
  4288. record.id=x.id;
  4289. delete x;
  4290. this.toMultiselect.view.store.add(record);
  4291. }else{
  4292. this.fromMultiselect.view.store.remove(record);
  4293. this.toMultiselect.view.store.add(record);
  4294. selectionsArray.push((this.toMultiselect.view.store.getCount() - 1));
  4295. }
  4296. }
  4297. }
  4298. this.toMultiselect.view.refresh();
  4299. this.fromMultiselect.view.refresh();
  4300. var si = this.toMultiselect.store.sortInfo;
  4301. if(si){
  4302. this.toMultiselect.store.sort(si.field, si.direction);
  4303. }
  4304. this.toMultiselect.view.select(selectionsArray);
  4305. },
  4306. toFrom : function() {
  4307. var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
  4308. var records = [];
  4309. if (selectionsArray.length > 0) {
  4310. for (var i=0; i<selectionsArray.length; i++) {
  4311. record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
  4312. records.push(record);
  4313. }
  4314. selectionsArray = [];
  4315. for (var i=0; i<records.length; i++) {
  4316. record = records[i];
  4317. this.toMultiselect.view.store.remove(record);
  4318. if(!this.allowDup){
  4319. this.fromMultiselect.view.store.add(record);
  4320. selectionsArray.push((this.fromMultiselect.view.store.getCount() - 1));
  4321. }
  4322. }
  4323. }
  4324. this.fromMultiselect.view.refresh();
  4325. this.toMultiselect.view.refresh();
  4326. var si = this.fromMultiselect.store.sortInfo;
  4327. if (si){
  4328. this.fromMultiselect.store.sort(si.field, si.direction);
  4329. }
  4330. this.fromMultiselect.view.select(selectionsArray);
  4331. },
  4332. valueChanged: function(store) {
  4333. var record = null;
  4334. var values = [];
  4335. for (var i=0; i<store.getCount(); i++) {
  4336. record = store.getAt(i);
  4337. values.push(record.get(this.toMultiselect.valueField));
  4338. }
  4339. this.hiddenField.dom.value = values.join(this.delimiter);
  4340. this.fireEvent('change', this, this.getValue(), this.hiddenField.dom.value);
  4341. },
  4342. getValue : function() {
  4343. return this.hiddenField.dom.value;
  4344. },
  4345. onRowDblClick : function(vw, index, node, e) {
  4346. if (vw == this.toMultiselect.view){
  4347. this.toFrom();
  4348. } else if (vw == this.fromMultiselect.view) {
  4349. this.fromTo();
  4350. }
  4351. return this.fireEvent('rowdblclick', vw, index, node, e);
  4352. },
  4353. reset: function(){
  4354. range = this.toMultiselect.store.getRange();
  4355. this.toMultiselect.store.removeAll();
  4356. this.fromMultiselect.store.add(range);
  4357. var si = this.fromMultiselect.store.sortInfo;
  4358. if (si){
  4359. this.fromMultiselect.store.sort(si.field, si.direction);
  4360. }
  4361. this.valueChanged(this.toMultiselect.store);
  4362. }
  4363. });
  4364. Ext.reg('itemselector', Ext.ux.form.ItemSelector);
  4365. //backwards compat
  4366. Ext.ux.ItemSelector = Ext.ux.form.ItemSelector;
  4367. /*!
  4368. * Ext JS Library 3.3.0
  4369. * Copyright(c) 2006-2010 Ext JS, Inc.
  4370. * licensing@extjs.com
  4371. * http://www.extjs.com/license
  4372. */
  4373. Ext.ns('Ext.ux.grid');
  4374. Ext.ux.grid.LockingGridView = Ext.extend(Ext.grid.GridView, {
  4375. lockText : 'Lock',
  4376. unlockText : 'Unlock',
  4377. rowBorderWidth : 1,
  4378. lockedBorderWidth : 1,
  4379. /*
  4380. * This option ensures that height between the rows is synchronized
  4381. * between the locked and unlocked sides. This option only needs to be used
  4382. * when the row heights aren't predictable.
  4383. */
  4384. syncHeights: false,
  4385. initTemplates : function(){
  4386. var ts = this.templates || {};
  4387. if (!ts.masterTpl) {
  4388. ts.masterTpl = new Ext.Template(
  4389. '<div class="x-grid3" hidefocus="true">',
  4390. '<div class="x-grid3-locked">',
  4391. '<div class="x-grid3-header"><div class="x-grid3-header-inner"><div class="x-grid3-header-offset" style="{lstyle}">{lockedHeader}</div></div><div class="x-clear"></div></div>',
  4392. '<div class="x-grid3-scroller"><div class="x-grid3-body" style="{lstyle}">{lockedBody}</div><div class="x-grid3-scroll-spacer"></div></div>',
  4393. '</div>',
  4394. '<div class="x-grid3-viewport x-grid3-unlocked">',
  4395. '<div class="x-grid3-header"><div class="x-grid3-header-inner"><div class="x-grid3-header-offset" style="{ostyle}">{header}</div></div><div class="x-clear"></div></div>',
  4396. '<div class="x-grid3-scroller"><div class="x-grid3-body" style="{bstyle}">{body}</div><a href="#" class="x-grid3-focus" tabIndex="-1"></a></div>',
  4397. '</div>',
  4398. '<div class="x-grid3-resize-marker">&#160;</div>',
  4399. '<div class="x-grid3-resize-proxy">&#160;</div>',
  4400. '</div>'
  4401. );
  4402. }
  4403. this.templates = ts;
  4404. Ext.ux.grid.LockingGridView.superclass.initTemplates.call(this);
  4405. },
  4406. getEditorParent : function(ed){
  4407. return this.el.dom;
  4408. },
  4409. initElements : function(){
  4410. var el = Ext.get(this.grid.getGridEl().dom.firstChild),
  4411. lockedWrap = el.child('div.x-grid3-locked'),
  4412. lockedHd = lockedWrap.child('div.x-grid3-header'),
  4413. lockedScroller = lockedWrap.child('div.x-grid3-scroller'),
  4414. mainWrap = el.child('div.x-grid3-viewport'),
  4415. mainHd = mainWrap.child('div.x-grid3-header'),
  4416. scroller = mainWrap.child('div.x-grid3-scroller');
  4417. if (this.grid.hideHeaders) {
  4418. lockedHd.setDisplayed(false);
  4419. mainHd.setDisplayed(false);
  4420. }
  4421. if(this.forceFit){
  4422. scroller.setStyle('overflow-x', 'hidden');
  4423. }
  4424. Ext.apply(this, {
  4425. el : el,
  4426. mainWrap: mainWrap,
  4427. mainHd : mainHd,
  4428. innerHd : mainHd.dom.firstChild,
  4429. scroller: scroller,
  4430. mainBody: scroller.child('div.x-grid3-body'),
  4431. focusEl : scroller.child('a'),
  4432. resizeMarker: el.child('div.x-grid3-resize-marker'),
  4433. resizeProxy : el.child('div.x-grid3-resize-proxy'),
  4434. lockedWrap: lockedWrap,
  4435. lockedHd: lockedHd,
  4436. lockedScroller: lockedScroller,
  4437. lockedBody: lockedScroller.child('div.x-grid3-body'),
  4438. lockedInnerHd: lockedHd.child('div.x-grid3-header-inner', true)
  4439. });
  4440. this.focusEl.swallowEvent('click', true);
  4441. },
  4442. getLockedRows : function(){
  4443. return this.hasRows() ? this.lockedBody.dom.childNodes : [];
  4444. },
  4445. getLockedRow : function(row){
  4446. return this.getLockedRows()[row];
  4447. },
  4448. getCell : function(row, col){
  4449. var lockedLen = this.cm.getLockedCount();
  4450. if(col < lockedLen){
  4451. return this.getLockedRow(row).getElementsByTagName('td')[col];
  4452. }
  4453. return Ext.ux.grid.LockingGridView.superclass.getCell.call(this, row, col - lockedLen);
  4454. },
  4455. getHeaderCell : function(index){
  4456. var lockedLen = this.cm.getLockedCount();
  4457. if(index < lockedLen){
  4458. return this.lockedHd.dom.getElementsByTagName('td')[index];
  4459. }
  4460. return Ext.ux.grid.LockingGridView.superclass.getHeaderCell.call(this, index - lockedLen);
  4461. },
  4462. addRowClass : function(row, cls){
  4463. var lockedRow = this.getLockedRow(row);
  4464. if(lockedRow){
  4465. this.fly(lockedRow).addClass(cls);
  4466. }
  4467. Ext.ux.grid.LockingGridView.superclass.addRowClass.call(this, row, cls);
  4468. },
  4469. removeRowClass : function(row, cls){
  4470. var lockedRow = this.getLockedRow(row);
  4471. if(lockedRow){
  4472. this.fly(lockedRow).removeClass(cls);
  4473. }
  4474. Ext.ux.grid.LockingGridView.superclass.removeRowClass.call(this, row, cls);
  4475. },
  4476. removeRow : function(row) {
  4477. Ext.removeNode(this.getLockedRow(row));
  4478. Ext.ux.grid.LockingGridView.superclass.removeRow.call(this, row);
  4479. },
  4480. removeRows : function(firstRow, lastRow){
  4481. var lockedBody = this.lockedBody.dom,
  4482. rowIndex = firstRow;
  4483. for(; rowIndex <= lastRow; rowIndex++){
  4484. Ext.removeNode(lockedBody.childNodes[firstRow]);
  4485. }
  4486. Ext.ux.grid.LockingGridView.superclass.removeRows.call(this, firstRow, lastRow);
  4487. },
  4488. syncScroll : function(e){
  4489. this.lockedScroller.dom.scrollTop = this.scroller.dom.scrollTop;
  4490. Ext.ux.grid.LockingGridView.superclass.syncScroll.call(this, e);
  4491. },
  4492. updateSortIcon : function(col, dir){
  4493. var sortClasses = this.sortClasses,
  4494. lockedHeaders = this.lockedHd.select('td').removeClass(sortClasses),
  4495. headers = this.mainHd.select('td').removeClass(sortClasses),
  4496. lockedLen = this.cm.getLockedCount(),
  4497. cls = sortClasses[dir == 'DESC' ? 1 : 0];
  4498. if(col < lockedLen){
  4499. lockedHeaders.item(col).addClass(cls);
  4500. }else{
  4501. headers.item(col - lockedLen).addClass(cls);
  4502. }
  4503. },
  4504. updateAllColumnWidths : function(){
  4505. var tw = this.getTotalWidth(),
  4506. clen = this.cm.getColumnCount(),
  4507. lw = this.getLockedWidth(),
  4508. llen = this.cm.getLockedCount(),
  4509. ws = [], len, i;
  4510. this.updateLockedWidth();
  4511. for(i = 0; i < clen; i++){
  4512. ws[i] = this.getColumnWidth(i);
  4513. var hd = this.getHeaderCell(i);
  4514. hd.style.width = ws[i];
  4515. }
  4516. var lns = this.getLockedRows(), ns = this.getRows(), row, trow, j;
  4517. for(i = 0, len = ns.length; i < len; i++){
  4518. row = lns[i];
  4519. row.style.width = lw;
  4520. if(row.firstChild){
  4521. row.firstChild.style.width = lw;
  4522. trow = row.firstChild.rows[0];
  4523. for (j = 0; j < llen; j++) {
  4524. trow.childNodes[j].style.width = ws[j];
  4525. }
  4526. }
  4527. row = ns[i];
  4528. row.style.width = tw;
  4529. if(row.firstChild){
  4530. row.firstChild.style.width = tw;
  4531. trow = row.firstChild.rows[0];
  4532. for (j = llen; j < clen; j++) {
  4533. trow.childNodes[j - llen].style.width = ws[j];
  4534. }
  4535. }
  4536. }
  4537. this.onAllColumnWidthsUpdated(ws, tw);
  4538. this.syncHeaderHeight();
  4539. },
  4540. updateColumnWidth : function(col, width){
  4541. var w = this.getColumnWidth(col),
  4542. llen = this.cm.getLockedCount(),
  4543. ns, rw, c, row;
  4544. this.updateLockedWidth();
  4545. if(col < llen){
  4546. ns = this.getLockedRows();
  4547. rw = this.getLockedWidth();
  4548. c = col;
  4549. }else{
  4550. ns = this.getRows();
  4551. rw = this.getTotalWidth();
  4552. c = col - llen;
  4553. }
  4554. var hd = this.getHeaderCell(col);
  4555. hd.style.width = w;
  4556. for(var i = 0, len = ns.length; i < len; i++){
  4557. row = ns[i];
  4558. row.style.width = rw;
  4559. if(row.firstChild){
  4560. row.firstChild.style.width = rw;
  4561. row.firstChild.rows[0].childNodes[c].style.width = w;
  4562. }
  4563. }
  4564. this.onColumnWidthUpdated(col, w, this.getTotalWidth());
  4565. this.syncHeaderHeight();
  4566. },
  4567. updateColumnHidden : function(col, hidden){
  4568. var llen = this.cm.getLockedCount(),
  4569. ns, rw, c, row,
  4570. display = hidden ? 'none' : '';
  4571. this.updateLockedWidth();
  4572. if(col < llen){
  4573. ns = this.getLockedRows();
  4574. rw = this.getLockedWidth();
  4575. c = col;
  4576. }else{
  4577. ns = this.getRows();
  4578. rw = this.getTotalWidth();
  4579. c = col - llen;
  4580. }
  4581. var hd = this.getHeaderCell(col);
  4582. hd.style.display = display;
  4583. for(var i = 0, len = ns.length; i < len; i++){
  4584. row = ns[i];
  4585. row.style.width = rw;
  4586. if(row.firstChild){
  4587. row.firstChild.style.width = rw;
  4588. row.firstChild.rows[0].childNodes[c].style.display = display;
  4589. }
  4590. }
  4591. this.onColumnHiddenUpdated(col, hidden, this.getTotalWidth());
  4592. delete this.lastViewWidth;
  4593. this.layout();
  4594. },
  4595. doRender : function(cs, rs, ds, startRow, colCount, stripe){
  4596. var ts = this.templates, ct = ts.cell, rt = ts.row, last = colCount-1,
  4597. tstyle = 'width:'+this.getTotalWidth()+';',
  4598. lstyle = 'width:'+this.getLockedWidth()+';',
  4599. buf = [], lbuf = [], cb, lcb, c, p = {}, rp = {}, r;
  4600. for(var j = 0, len = rs.length; j < len; j++){
  4601. r = rs[j]; cb = []; lcb = [];
  4602. var rowIndex = (j+startRow);
  4603. for(var i = 0; i < colCount; i++){
  4604. c = cs[i];
  4605. p.id = c.id;
  4606. p.css = (i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '')) +
  4607. (this.cm.config[i].cellCls ? ' ' + this.cm.config[i].cellCls : '');
  4608. p.attr = p.cellAttr = '';
  4609. p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
  4610. p.style = c.style;
  4611. if(Ext.isEmpty(p.value)){
  4612. p.value = '&#160;';
  4613. }
  4614. if(this.markDirty && r.dirty && Ext.isDefined(r.modified[c.name])){
  4615. p.css += ' x-grid3-dirty-cell';
  4616. }
  4617. if(c.locked){
  4618. lcb[lcb.length] = ct.apply(p);
  4619. }else{
  4620. cb[cb.length] = ct.apply(p);
  4621. }
  4622. }
  4623. var alt = [];
  4624. if(stripe && ((rowIndex+1) % 2 === 0)){
  4625. alt[0] = 'x-grid3-row-alt';
  4626. }
  4627. if(r.dirty){
  4628. alt[1] = ' x-grid3-dirty-row';
  4629. }
  4630. rp.cols = colCount;
  4631. if(this.getRowClass){
  4632. alt[2] = this.getRowClass(r, rowIndex, rp, ds);
  4633. }
  4634. rp.alt = alt.join(' ');
  4635. rp.cells = cb.join('');
  4636. rp.tstyle = tstyle;
  4637. buf[buf.length] = rt.apply(rp);
  4638. rp.cells = lcb.join('');
  4639. rp.tstyle = lstyle;
  4640. lbuf[lbuf.length] = rt.apply(rp);
  4641. }
  4642. return [buf.join(''), lbuf.join('')];
  4643. },
  4644. processRows : function(startRow, skipStripe){
  4645. if(!this.ds || this.ds.getCount() < 1){
  4646. return;
  4647. }
  4648. var rows = this.getRows(),
  4649. lrows = this.getLockedRows(),
  4650. row, lrow;
  4651. skipStripe = skipStripe || !this.grid.stripeRows;
  4652. startRow = startRow || 0;
  4653. for(var i = 0, len = rows.length; i < len; ++i){
  4654. row = rows[i];
  4655. lrow = lrows[i];
  4656. row.rowIndex = i;
  4657. lrow.rowIndex = i;
  4658. if(!skipStripe){
  4659. row.className = row.className.replace(this.rowClsRe, ' ');
  4660. lrow.className = lrow.className.replace(this.rowClsRe, ' ');
  4661. if ((i + 1) % 2 === 0){
  4662. row.className += ' x-grid3-row-alt';
  4663. lrow.className += ' x-grid3-row-alt';
  4664. }
  4665. }
  4666. this.syncRowHeights(row, lrow);
  4667. }
  4668. if(startRow === 0){
  4669. Ext.fly(rows[0]).addClass(this.firstRowCls);
  4670. Ext.fly(lrows[0]).addClass(this.firstRowCls);
  4671. }
  4672. Ext.fly(rows[rows.length - 1]).addClass(this.lastRowCls);
  4673. Ext.fly(lrows[lrows.length - 1]).addClass(this.lastRowCls);
  4674. },
  4675. syncRowHeights: function(row1, row2){
  4676. if(this.syncHeights){
  4677. var el1 = Ext.get(row1),
  4678. el2 = Ext.get(row2),
  4679. h1 = el1.getHeight(),
  4680. h2 = el2.getHeight();
  4681. if(h1 > h2){
  4682. el2.setHeight(h1);
  4683. }else if(h2 > h1){
  4684. el1.setHeight(h2);
  4685. }
  4686. }
  4687. },
  4688. afterRender : function(){
  4689. if(!this.ds || !this.cm){
  4690. return;
  4691. }
  4692. var bd = this.renderRows() || ['&#160;', '&#160;'];
  4693. this.mainBody.dom.innerHTML = bd[0];
  4694. this.lockedBody.dom.innerHTML = bd[1];
  4695. this.processRows(0, true);
  4696. if(this.deferEmptyText !== true){
  4697. this.applyEmptyText();
  4698. }
  4699. this.grid.fireEvent('viewready', this.grid);
  4700. },
  4701. renderUI : function(){
  4702. var templates = this.templates,
  4703. header = this.renderHeaders(),
  4704. body = templates.body.apply({rows:'&#160;'});
  4705. return templates.masterTpl.apply({
  4706. body : body,
  4707. header: header[0],
  4708. ostyle: 'width:' + this.getOffsetWidth() + ';',
  4709. bstyle: 'width:' + this.getTotalWidth() + ';',
  4710. lockedBody: body,
  4711. lockedHeader: header[1],
  4712. lstyle: 'width:'+this.getLockedWidth()+';'
  4713. });
  4714. },
  4715. afterRenderUI: function(){
  4716. var g = this.grid;
  4717. this.initElements();
  4718. Ext.fly(this.innerHd).on('click', this.handleHdDown, this);
  4719. Ext.fly(this.lockedInnerHd).on('click', this.handleHdDown, this);
  4720. this.mainHd.on({
  4721. scope: this,
  4722. mouseover: this.handleHdOver,
  4723. mouseout: this.handleHdOut,
  4724. mousemove: this.handleHdMove
  4725. });
  4726. this.lockedHd.on({
  4727. scope: this,
  4728. mouseover: this.handleHdOver,
  4729. mouseout: this.handleHdOut,
  4730. mousemove: this.handleHdMove
  4731. });
  4732. this.scroller.on('scroll', this.syncScroll, this);
  4733. if(g.enableColumnResize !== false){
  4734. this.splitZone = new Ext.grid.GridView.SplitDragZone(g, this.mainHd.dom);
  4735. this.splitZone.setOuterHandleElId(Ext.id(this.lockedHd.dom));
  4736. this.splitZone.setOuterHandleElId(Ext.id(this.mainHd.dom));
  4737. }
  4738. if(g.enableColumnMove){
  4739. this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd);
  4740. this.columnDrag.setOuterHandleElId(Ext.id(this.lockedInnerHd));
  4741. this.columnDrag.setOuterHandleElId(Ext.id(this.innerHd));
  4742. this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom);
  4743. }
  4744. if(g.enableHdMenu !== false){
  4745. this.hmenu = new Ext.menu.Menu({id: g.id + '-hctx'});
  4746. this.hmenu.add(
  4747. {itemId: 'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
  4748. {itemId: 'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
  4749. );
  4750. if(this.grid.enableColLock !== false){
  4751. this.hmenu.add('-',
  4752. {itemId: 'lock', text: this.lockText, cls: 'xg-hmenu-lock'},
  4753. {itemId: 'unlock', text: this.unlockText, cls: 'xg-hmenu-unlock'}
  4754. );
  4755. }
  4756. if(g.enableColumnHide !== false){
  4757. this.colMenu = new Ext.menu.Menu({id:g.id + '-hcols-menu'});
  4758. this.colMenu.on({
  4759. scope: this,
  4760. beforeshow: this.beforeColMenuShow,
  4761. itemclick: this.handleHdMenuClick
  4762. });
  4763. this.hmenu.add('-', {
  4764. itemId:'columns',
  4765. hideOnClick: false,
  4766. text: this.columnsText,
  4767. menu: this.colMenu,
  4768. iconCls: 'x-cols-icon'
  4769. });
  4770. }
  4771. this.hmenu.on('itemclick', this.handleHdMenuClick, this);
  4772. }
  4773. if(g.trackMouseOver){
  4774. this.mainBody.on({
  4775. scope: this,
  4776. mouseover: this.onRowOver,
  4777. mouseout: this.onRowOut
  4778. });
  4779. this.lockedBody.on({
  4780. scope: this,
  4781. mouseover: this.onRowOver,
  4782. mouseout: this.onRowOut
  4783. });
  4784. }
  4785. if(g.enableDragDrop || g.enableDrag){
  4786. this.dragZone = new Ext.grid.GridDragZone(g, {
  4787. ddGroup : g.ddGroup || 'GridDD'
  4788. });
  4789. }
  4790. this.updateHeaderSortState();
  4791. },
  4792. layout : function(){
  4793. if(!this.mainBody){
  4794. return;
  4795. }
  4796. var g = this.grid;
  4797. var c = g.getGridEl();
  4798. var csize = c.getSize(true);
  4799. var vw = csize.width;
  4800. if(!g.hideHeaders && (vw < 20 || csize.height < 20)){
  4801. return;
  4802. }
  4803. this.syncHeaderHeight();
  4804. if(g.autoHeight){
  4805. this.scroller.dom.style.overflow = 'visible';
  4806. this.lockedScroller.dom.style.overflow = 'visible';
  4807. if(Ext.isWebKit){
  4808. this.scroller.dom.style.position = 'static';
  4809. this.lockedScroller.dom.style.position = 'static';
  4810. }
  4811. }else{
  4812. this.el.setSize(csize.width, csize.height);
  4813. var hdHeight = this.mainHd.getHeight();
  4814. var vh = csize.height - (hdHeight);
  4815. }
  4816. this.updateLockedWidth();
  4817. if(this.forceFit){
  4818. if(this.lastViewWidth != vw){
  4819. this.fitColumns(false, false);
  4820. this.lastViewWidth = vw;
  4821. }
  4822. }else {
  4823. this.autoExpand();
  4824. this.syncHeaderScroll();
  4825. }
  4826. this.onLayout(vw, vh);
  4827. },
  4828. getOffsetWidth : function() {
  4829. return (this.cm.getTotalWidth() - this.cm.getTotalLockedWidth() + this.getScrollOffset()) + 'px';
  4830. },
  4831. renderHeaders : function(){
  4832. var cm = this.cm,
  4833. ts = this.templates,
  4834. ct = ts.hcell,
  4835. cb = [], lcb = [],
  4836. p = {},
  4837. len = cm.getColumnCount(),
  4838. last = len - 1;
  4839. for(var i = 0; i < len; i++){
  4840. p.id = cm.getColumnId(i);
  4841. p.value = cm.getColumnHeader(i) || '';
  4842. p.style = this.getColumnStyle(i, true);
  4843. p.tooltip = this.getColumnTooltip(i);
  4844. p.css = (i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '')) +
  4845. (cm.config[i].headerCls ? ' ' + cm.config[i].headerCls : '');
  4846. if(cm.config[i].align == 'right'){
  4847. p.istyle = 'padding-right:16px';
  4848. } else {
  4849. delete p.istyle;
  4850. }
  4851. if(cm.isLocked(i)){
  4852. lcb[lcb.length] = ct.apply(p);
  4853. }else{
  4854. cb[cb.length] = ct.apply(p);
  4855. }
  4856. }
  4857. return [ts.header.apply({cells: cb.join(''), tstyle:'width:'+this.getTotalWidth()+';'}),
  4858. ts.header.apply({cells: lcb.join(''), tstyle:'width:'+this.getLockedWidth()+';'})];
  4859. },
  4860. updateHeaders : function(){
  4861. var hd = this.renderHeaders();
  4862. this.innerHd.firstChild.innerHTML = hd[0];
  4863. this.innerHd.firstChild.style.width = this.getOffsetWidth();
  4864. this.innerHd.firstChild.firstChild.style.width = this.getTotalWidth();
  4865. this.lockedInnerHd.firstChild.innerHTML = hd[1];
  4866. var lw = this.getLockedWidth();
  4867. this.lockedInnerHd.firstChild.style.width = lw;
  4868. this.lockedInnerHd.firstChild.firstChild.style.width = lw;
  4869. },
  4870. getResolvedXY : function(resolved){
  4871. if(!resolved){
  4872. return null;
  4873. }
  4874. var c = resolved.cell, r = resolved.row;
  4875. return c ? Ext.fly(c).getXY() : [this.scroller.getX(), Ext.fly(r).getY()];
  4876. },
  4877. syncFocusEl : function(row, col, hscroll){
  4878. Ext.ux.grid.LockingGridView.superclass.syncFocusEl.call(this, row, col, col < this.cm.getLockedCount() ? false : hscroll);
  4879. },
  4880. ensureVisible : function(row, col, hscroll){
  4881. return Ext.ux.grid.LockingGridView.superclass.ensureVisible.call(this, row, col, col < this.cm.getLockedCount() ? false : hscroll);
  4882. },
  4883. insertRows : function(dm, firstRow, lastRow, isUpdate){
  4884. var last = dm.getCount() - 1;
  4885. if(!isUpdate && firstRow === 0 && lastRow >= last){
  4886. this.refresh();
  4887. }else{
  4888. if(!isUpdate){
  4889. this.fireEvent('beforerowsinserted', this, firstRow, lastRow);
  4890. }
  4891. var html = this.renderRows(firstRow, lastRow),
  4892. before = this.getRow(firstRow);
  4893. if(before){
  4894. if(firstRow === 0){
  4895. this.removeRowClass(0, this.firstRowCls);
  4896. }
  4897. Ext.DomHelper.insertHtml('beforeBegin', before, html[0]);
  4898. before = this.getLockedRow(firstRow);
  4899. Ext.DomHelper.insertHtml('beforeBegin', before, html[1]);
  4900. }else{
  4901. this.removeRowClass(last - 1, this.lastRowCls);
  4902. Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html[0]);
  4903. Ext.DomHelper.insertHtml('beforeEnd', this.lockedBody.dom, html[1]);
  4904. }
  4905. if(!isUpdate){
  4906. this.fireEvent('rowsinserted', this, firstRow, lastRow);
  4907. this.processRows(firstRow);
  4908. }else if(firstRow === 0 || firstRow >= last){
  4909. this.addRowClass(firstRow, firstRow === 0 ? this.firstRowCls : this.lastRowCls);
  4910. }
  4911. }
  4912. this.syncFocusEl(firstRow);
  4913. },
  4914. getColumnStyle : function(col, isHeader){
  4915. var style = !isHeader ? this.cm.config[col].cellStyle || this.cm.config[col].css || '' : this.cm.config[col].headerStyle || '';
  4916. style += 'width:'+this.getColumnWidth(col)+';';
  4917. if(this.cm.isHidden(col)){
  4918. style += 'display:none;';
  4919. }
  4920. var align = this.cm.config[col].align;
  4921. if(align){
  4922. style += 'text-align:'+align+';';
  4923. }
  4924. return style;
  4925. },
  4926. getLockedWidth : function() {
  4927. return this.cm.getTotalLockedWidth() + 'px';
  4928. },
  4929. getTotalWidth : function() {
  4930. return (this.cm.getTotalWidth() - this.cm.getTotalLockedWidth()) + 'px';
  4931. },
  4932. getColumnData : function(){
  4933. var cs = [], cm = this.cm, colCount = cm.getColumnCount();
  4934. for(var i = 0; i < colCount; i++){
  4935. var name = cm.getDataIndex(i);
  4936. cs[i] = {
  4937. name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name),
  4938. renderer : cm.getRenderer(i),
  4939. id : cm.getColumnId(i),
  4940. style : this.getColumnStyle(i),
  4941. locked : cm.isLocked(i)
  4942. };
  4943. }
  4944. return cs;
  4945. },
  4946. renderBody : function(){
  4947. var markup = this.renderRows() || ['&#160;', '&#160;'];
  4948. return [this.templates.body.apply({rows: markup[0]}), this.templates.body.apply({rows: markup[1]})];
  4949. },
  4950. refreshRow: function(record){
  4951. var store = this.ds,
  4952. colCount = this.cm.getColumnCount(),
  4953. columns = this.getColumnData(),
  4954. last = colCount - 1,
  4955. cls = ['x-grid3-row'],
  4956. rowParams = {
  4957. tstyle: String.format("width: {0};", this.getTotalWidth())
  4958. },
  4959. lockedRowParams = {
  4960. tstyle: String.format("width: {0};", this.getLockedWidth())
  4961. },
  4962. colBuffer = [],
  4963. lockedColBuffer = [],
  4964. cellTpl = this.templates.cell,
  4965. rowIndex,
  4966. row,
  4967. lockedRow,
  4968. column,
  4969. meta,
  4970. css,
  4971. i;
  4972. if (Ext.isNumber(record)) {
  4973. rowIndex = record;
  4974. record = store.getAt(rowIndex);
  4975. } else {
  4976. rowIndex = store.indexOf(record);
  4977. }
  4978. if (!record || rowIndex < 0) {
  4979. return;
  4980. }
  4981. for (i = 0; i < colCount; i++) {
  4982. column = columns[i];
  4983. if (i == 0) {
  4984. css = 'x-grid3-cell-first';
  4985. } else {
  4986. css = (i == last) ? 'x-grid3-cell-last ' : '';
  4987. }
  4988. meta = {
  4989. id: column.id,
  4990. style: column.style,
  4991. css: css,
  4992. attr: "",
  4993. cellAttr: ""
  4994. };
  4995. meta.value = column.renderer.call(column.scope, record.data[column.name], meta, record, rowIndex, i, store);
  4996. if (Ext.isEmpty(meta.value)) {
  4997. meta.value = ' ';
  4998. }
  4999. if (this.markDirty && record.dirty && typeof record.modified[column.name] != 'undefined') {
  5000. meta.css += ' x-grid3-dirty-cell';
  5001. }
  5002. if (column.locked) {
  5003. lockedColBuffer[i] = cellTpl.apply(meta);
  5004. } else {
  5005. colBuffer[i] = cellTpl.apply(meta);
  5006. }
  5007. }
  5008. row = this.getRow(rowIndex);
  5009. row.className = '';
  5010. lockedRow = this.getLockedRow(rowIndex);
  5011. lockedRow.className = '';
  5012. if (this.grid.stripeRows && ((rowIndex + 1) % 2 === 0)) {
  5013. cls.push('x-grid3-row-alt');
  5014. }
  5015. if (this.getRowClass) {
  5016. rowParams.cols = colCount;
  5017. cls.push(this.getRowClass(record, rowIndex, rowParams, store));
  5018. }
  5019. // Unlocked rows
  5020. this.fly(row).addClass(cls).setStyle(rowParams.tstyle);
  5021. rowParams.cells = colBuffer.join("");
  5022. row.innerHTML = this.templates.rowInner.apply(rowParams);
  5023. // Locked rows
  5024. this.fly(lockedRow).addClass(cls).setStyle(lockedRowParams.tstyle);
  5025. lockedRowParams.cells = lockedColBuffer.join("");
  5026. lockedRow.innerHTML = this.templates.rowInner.apply(lockedRowParams);
  5027. lockedRow.rowIndex = rowIndex;
  5028. this.syncRowHeights(row, lockedRow);
  5029. this.fireEvent('rowupdated', this, rowIndex, record);
  5030. },
  5031. refresh : function(headersToo){
  5032. this.fireEvent('beforerefresh', this);
  5033. this.grid.stopEditing(true);
  5034. var result = this.renderBody();
  5035. this.mainBody.update(result[0]).setWidth(this.getTotalWidth());
  5036. this.lockedBody.update(result[1]).setWidth(this.getLockedWidth());
  5037. if(headersToo === true){
  5038. this.updateHeaders();
  5039. this.updateHeaderSortState();
  5040. }
  5041. this.processRows(0, true);
  5042. this.layout();
  5043. this.applyEmptyText();
  5044. this.fireEvent('refresh', this);
  5045. },
  5046. onDenyColumnLock : function(){
  5047. },
  5048. initData : function(ds, cm){
  5049. if(this.cm){
  5050. this.cm.un('columnlockchange', this.onColumnLock, this);
  5051. }
  5052. Ext.ux.grid.LockingGridView.superclass.initData.call(this, ds, cm);
  5053. if(this.cm){
  5054. this.cm.on('columnlockchange', this.onColumnLock, this);
  5055. }
  5056. },
  5057. onColumnLock : function(){
  5058. this.refresh(true);
  5059. },
  5060. handleHdMenuClick : function(item){
  5061. var index = this.hdCtxIndex,
  5062. cm = this.cm,
  5063. id = item.getItemId(),
  5064. llen = cm.getLockedCount();
  5065. switch(id){
  5066. case 'lock':
  5067. if(cm.getColumnCount(true) <= llen + 1){
  5068. this.onDenyColumnLock();
  5069. return undefined;
  5070. }
  5071. cm.setLocked(index, true);
  5072. if(llen != index){
  5073. cm.moveColumn(index, llen);
  5074. this.grid.fireEvent('columnmove', index, llen);
  5075. }
  5076. break;
  5077. case 'unlock':
  5078. if(llen - 1 != index){
  5079. cm.setLocked(index, false, true);
  5080. cm.moveColumn(index, llen - 1);
  5081. this.grid.fireEvent('columnmove', index, llen - 1);
  5082. }else{
  5083. cm.setLocked(index, false);
  5084. }
  5085. break;
  5086. default:
  5087. return Ext.ux.grid.LockingGridView.superclass.handleHdMenuClick.call(this, item);
  5088. }
  5089. return true;
  5090. },
  5091. handleHdDown : function(e, t){
  5092. Ext.ux.grid.LockingGridView.superclass.handleHdDown.call(this, e, t);
  5093. if(this.grid.enableColLock !== false){
  5094. if(Ext.fly(t).hasClass('x-grid3-hd-btn')){
  5095. var hd = this.findHeaderCell(t),
  5096. index = this.getCellIndex(hd),
  5097. ms = this.hmenu.items, cm = this.cm;
  5098. ms.get('lock').setDisabled(cm.isLocked(index));
  5099. ms.get('unlock').setDisabled(!cm.isLocked(index));
  5100. }
  5101. }
  5102. },
  5103. syncHeaderHeight: function(){
  5104. var hrow = Ext.fly(this.innerHd).child('tr', true),
  5105. lhrow = Ext.fly(this.lockedInnerHd).child('tr', true);
  5106. hrow.style.height = 'auto';
  5107. lhrow.style.height = 'auto';
  5108. var hd = hrow.offsetHeight,
  5109. lhd = lhrow.offsetHeight,
  5110. height = Math.max(lhd, hd) + 'px';
  5111. hrow.style.height = height;
  5112. lhrow.style.height = height;
  5113. },
  5114. updateLockedWidth: function(){
  5115. var lw = this.cm.getTotalLockedWidth(),
  5116. tw = this.cm.getTotalWidth() - lw,
  5117. csize = this.grid.getGridEl().getSize(true),
  5118. lp = Ext.isBorderBox ? 0 : this.lockedBorderWidth,
  5119. rp = Ext.isBorderBox ? 0 : this.rowBorderWidth,
  5120. vw = (csize.width - lw - lp - rp) + 'px',
  5121. so = this.getScrollOffset();
  5122. if(!this.grid.autoHeight){
  5123. var vh = (csize.height - this.mainHd.getHeight()) + 'px';
  5124. this.lockedScroller.dom.style.height = vh;
  5125. this.scroller.dom.style.height = vh;
  5126. }
  5127. this.lockedWrap.dom.style.width = (lw + rp) + 'px';
  5128. this.scroller.dom.style.width = vw;
  5129. this.mainWrap.dom.style.left = (lw + lp + rp) + 'px';
  5130. if(this.innerHd){
  5131. this.lockedInnerHd.firstChild.style.width = lw + 'px';
  5132. this.lockedInnerHd.firstChild.firstChild.style.width = lw + 'px';
  5133. this.innerHd.style.width = vw;
  5134. this.innerHd.firstChild.style.width = (tw + rp + so) + 'px';
  5135. this.innerHd.firstChild.firstChild.style.width = tw + 'px';
  5136. }
  5137. if(this.mainBody){
  5138. this.lockedBody.dom.style.width = (lw + rp) + 'px';
  5139. this.mainBody.dom.style.width = (tw + rp) + 'px';
  5140. }
  5141. }
  5142. });
  5143. Ext.ux.grid.LockingColumnModel = Ext.extend(Ext.grid.ColumnModel, {
  5144. <div id="method-Ext.ux.form.ItemSelector-isLocked"></div>/**
  5145. * Returns true if the given column index is currently locked
  5146. * @param {Number} colIndex The column index
  5147. * @return {Boolean} True if the column is locked
  5148. */
  5149. isLocked : function(colIndex){
  5150. return this.config[colIndex].locked === true;
  5151. },
  5152. <div id="method-Ext.ux.form.ItemSelector-setLocked"></div>/**
  5153. * Locks or unlocks a given column
  5154. * @param {Number} colIndex The column index
  5155. * @param {Boolean} value True to lock, false to unlock
  5156. * @param {Boolean} suppressEvent Pass false to cause the columnlockchange event not to fire
  5157. */
  5158. setLocked : function(colIndex, value, suppressEvent){
  5159. if (this.isLocked(colIndex) == value) {
  5160. return;
  5161. }
  5162. this.config[colIndex].locked = value;
  5163. if (!suppressEvent) {
  5164. this.fireEvent('columnlockchange', this, colIndex, value);
  5165. }
  5166. },
  5167. <div id="method-Ext.ux.form.ItemSelector-getTotalLockedWidth"></div>/**
  5168. * Returns the total width of all locked columns
  5169. * @return {Number} The width of all locked columns
  5170. */
  5171. getTotalLockedWidth : function(){
  5172. var totalWidth = 0;
  5173. for (var i = 0, len = this.config.length; i < len; i++) {
  5174. if (this.isLocked(i) && !this.isHidden(i)) {
  5175. totalWidth += this.getColumnWidth(i);
  5176. }
  5177. }
  5178. return totalWidth;
  5179. },
  5180. <div id="method-Ext.ux.form.ItemSelector-getLockedCount"></div>/**
  5181. * Returns the total number of locked columns
  5182. * @return {Number} The number of locked columns
  5183. */
  5184. getLockedCount : function() {
  5185. var len = this.config.length;
  5186. for (var i = 0; i < len; i++) {
  5187. if (!this.isLocked(i)) {
  5188. return i;
  5189. }
  5190. }
  5191. //if we get to this point all of the columns are locked so we return the total
  5192. return len;
  5193. },
  5194. <div id="method-Ext.ux.form.ItemSelector-moveColumn"></div>/**
  5195. * Moves a column from one position to another
  5196. * @param {Number} oldIndex The current column index
  5197. * @param {Number} newIndex The destination column index
  5198. */
  5199. moveColumn : function(oldIndex, newIndex){
  5200. var oldLocked = this.isLocked(oldIndex),
  5201. newLocked = this.isLocked(newIndex);
  5202. if (oldIndex < newIndex && oldLocked && !newLocked) {
  5203. this.setLocked(oldIndex, false, true);
  5204. } else if (oldIndex > newIndex && !oldLocked && newLocked) {
  5205. this.setLocked(oldIndex, true, true);
  5206. }
  5207. Ext.ux.grid.LockingColumnModel.superclass.moveColumn.apply(this, arguments);
  5208. }
  5209. });Ext.ns('Ext.ux.form');
  5210. /**
  5211. * @class Ext.ux.form.MultiSelect
  5212. * @extends Ext.form.Field
  5213. * A control that allows selection and form submission of multiple list items.
  5214. *
  5215. * @history
  5216. * 2008-06-19 bpm Original code contributed by Toby Stuart (with contributions from Robert Williams)
  5217. * 2008-06-19 bpm Docs and demo code clean up
  5218. *
  5219. * @constructor
  5220. * Create a new MultiSelect
  5221. * @param {Object} config Configuration options
  5222. * @xtype multiselect
  5223. */
  5224. Ext.ux.form.MultiSelect = Ext.extend(Ext.form.Field, {
  5225. <div id="cfg-Ext.ux.form.MultiSelect-legend"></div>/**
  5226. * @cfg {String} legend Wraps the object with a fieldset and specified legend.
  5227. */
  5228. <div id="cfg-Ext.ux.form.MultiSelect-view"></div>/**
  5229. * @cfg {Ext.ListView} view The {@link Ext.ListView} used to render the multiselect list.
  5230. */
  5231. <div id="cfg-Ext.ux.form.MultiSelect-dragGroup"></div>/**
  5232. * @cfg {String/Array} dragGroup The ddgroup name(s) for the MultiSelect DragZone (defaults to undefined).
  5233. */
  5234. <div id="cfg-Ext.ux.form.MultiSelect-dropGroup"></div>/**
  5235. * @cfg {String/Array} dropGroup The ddgroup name(s) for the MultiSelect DropZone (defaults to undefined).
  5236. */
  5237. <div id="cfg-Ext.ux.form.MultiSelect-ddReorder"></div>/**
  5238. * @cfg {Boolean} ddReorder Whether the items in the MultiSelect list are drag/drop reorderable (defaults to false).
  5239. */
  5240. ddReorder:false,
  5241. <div id="cfg-Ext.ux.form.MultiSelect-tbar"></div>/**
  5242. * @cfg {Object/Array} tbar The top toolbar of the control. This can be a {@link Ext.Toolbar} object, a
  5243. * toolbar config, or an array of buttons/button configs to be added to the toolbar.
  5244. */
  5245. <div id="cfg-Ext.ux.form.MultiSelect-appendOnly"></div>/**
  5246. * @cfg {String} appendOnly True if the list should only allow append drops when drag/drop is enabled
  5247. * (use for lists which are sorted, defaults to false).
  5248. */
  5249. appendOnly:false,
  5250. <div id="cfg-Ext.ux.form.MultiSelect-width"></div>/**
  5251. * @cfg {Number} width Width in pixels of the control (defaults to 100).
  5252. */
  5253. width:100,
  5254. <div id="cfg-Ext.ux.form.MultiSelect-height"></div>/**
  5255. * @cfg {Number} height Height in pixels of the control (defaults to 100).
  5256. */
  5257. height:100,
  5258. <div id="cfg-Ext.ux.form.MultiSelect-displayField"></div>/**
  5259. * @cfg {String/Number} displayField Name/Index of the desired display field in the dataset (defaults to 0).
  5260. */
  5261. displayField:0,
  5262. <div id="cfg-Ext.ux.form.MultiSelect-valueField"></div>/**
  5263. * @cfg {String/Number} valueField Name/Index of the desired value field in the dataset (defaults to 1).
  5264. */
  5265. valueField:1,
  5266. <div id="cfg-Ext.ux.form.MultiSelect-allowBlank"></div>/**
  5267. * @cfg {Boolean} allowBlank False to require at least one item in the list to be selected, true to allow no
  5268. * selection (defaults to true).
  5269. */
  5270. allowBlank:true,
  5271. <div id="cfg-Ext.ux.form.MultiSelect-minSelections"></div>/**
  5272. * @cfg {Number} minSelections Minimum number of selections allowed (defaults to 0).
  5273. */
  5274. minSelections:0,
  5275. <div id="cfg-Ext.ux.form.MultiSelect-maxSelections"></div>/**
  5276. * @cfg {Number} maxSelections Maximum number of selections allowed (defaults to Number.MAX_VALUE).
  5277. */
  5278. maxSelections:Number.MAX_VALUE,
  5279. <div id="cfg-Ext.ux.form.MultiSelect-blankText"></div>/**
  5280. * @cfg {String} blankText Default text displayed when the control contains no items (defaults to the same value as
  5281. * {@link Ext.form.TextField#blankText}.
  5282. */
  5283. blankText:Ext.form.TextField.prototype.blankText,
  5284. <div id="cfg-Ext.ux.form.MultiSelect-minSelectionsText"></div>/**
  5285. * @cfg {String} minSelectionsText Validation message displayed when {@link #minSelections} is not met (defaults to 'Minimum {0}
  5286. * item(s) required'). The {0} token will be replaced by the value of {@link #minSelections}.
  5287. */
  5288. minSelectionsText:'Minimum {0} item(s) required',
  5289. <div id="cfg-Ext.ux.form.MultiSelect-maxSelectionsText"></div>/**
  5290. * @cfg {String} maxSelectionsText Validation message displayed when {@link #maxSelections} is not met (defaults to 'Maximum {0}
  5291. * item(s) allowed'). The {0} token will be replaced by the value of {@link #maxSelections}.
  5292. */
  5293. maxSelectionsText:'Maximum {0} item(s) allowed',
  5294. <div id="cfg-Ext.ux.form.MultiSelect-delimiter"></div>/**
  5295. * @cfg {String} delimiter The string used to delimit between items when set or returned as a string of values
  5296. * (defaults to ',').
  5297. */
  5298. delimiter:',',
  5299. <div id="cfg-Ext.ux.form.MultiSelect-store"></div>/**
  5300. * @cfg {Ext.data.Store/Array} store The data source to which this MultiSelect is bound (defaults to <tt>undefined</tt>).
  5301. * Acceptable values for this property are:
  5302. * <div class="mdetail-params"><ul>
  5303. * <li><b>any {@link Ext.data.Store Store} subclass</b></li>
  5304. * <li><b>an Array</b> : Arrays will be converted to a {@link Ext.data.ArrayStore} internally.
  5305. * <div class="mdetail-params"><ul>
  5306. * <li><b>1-dimensional array</b> : (e.g., <tt>['Foo','Bar']</tt>)<div class="sub-desc">
  5307. * A 1-dimensional array will automatically be expanded (each array item will be the combo
  5308. * {@link #valueField value} and {@link #displayField text})</div></li>
  5309. * <li><b>2-dimensional array</b> : (e.g., <tt>[['f','Foo'],['b','Bar']]</tt>)<div class="sub-desc">
  5310. * For a multi-dimensional array, the value in index 0 of each item will be assumed to be the combo
  5311. * {@link #valueField value}, while the value at index 1 is assumed to be the combo {@link #displayField text}.
  5312. * </div></li></ul></div></li></ul></div>
  5313. */
  5314. // private
  5315. defaultAutoCreate : {tag: "div"},
  5316. // private
  5317. initComponent: function(){
  5318. Ext.ux.form.MultiSelect.superclass.initComponent.call(this);
  5319. if(Ext.isArray(this.store)){
  5320. if (Ext.isArray(this.store[0])){
  5321. this.store = new Ext.data.ArrayStore({
  5322. fields: ['value','text'],
  5323. data: this.store
  5324. });
  5325. this.valueField = 'value';
  5326. }else{
  5327. this.store = new Ext.data.ArrayStore({
  5328. fields: ['text'],
  5329. data: this.store,
  5330. expandData: true
  5331. });
  5332. this.valueField = 'text';
  5333. }
  5334. this.displayField = 'text';
  5335. } else {
  5336. this.store = Ext.StoreMgr.lookup(this.store);
  5337. }
  5338. this.addEvents({
  5339. 'dblclick' : true,
  5340. 'click' : true,
  5341. 'change' : true,
  5342. 'drop' : true
  5343. });
  5344. },
  5345. // private
  5346. onRender: function(ct, position){
  5347. Ext.ux.form.MultiSelect.superclass.onRender.call(this, ct, position);
  5348. var fs = this.fs = new Ext.form.FieldSet({
  5349. renderTo: this.el,
  5350. title: this.legend,
  5351. height: this.height,
  5352. width: this.width,
  5353. style: "padding:0;",
  5354. tbar: this.tbar
  5355. });
  5356. fs.body.addClass('ux-mselect');
  5357. this.view = new Ext.ListView({
  5358. multiSelect: true,
  5359. store: this.store,
  5360. columns: [{ header: 'Value', width: 1, dataIndex: this.displayField }],
  5361. hideHeaders: true
  5362. });
  5363. fs.add(this.view);
  5364. this.view.on('click', this.onViewClick, this);
  5365. this.view.on('beforeclick', this.onViewBeforeClick, this);
  5366. this.view.on('dblclick', this.onViewDblClick, this);
  5367. this.hiddenName = this.name || Ext.id();
  5368. var hiddenTag = { tag: "input", type: "hidden", value: "", name: this.hiddenName };
  5369. this.hiddenField = this.el.createChild(hiddenTag);
  5370. this.hiddenField.dom.disabled = this.hiddenName != this.name;
  5371. fs.doLayout();
  5372. },
  5373. // private
  5374. afterRender: function(){
  5375. Ext.ux.form.MultiSelect.superclass.afterRender.call(this);
  5376. if (this.ddReorder && !this.dragGroup && !this.dropGroup){
  5377. this.dragGroup = this.dropGroup = 'MultiselectDD-' + Ext.id();
  5378. }
  5379. if (this.draggable || this.dragGroup){
  5380. this.dragZone = new Ext.ux.form.MultiSelect.DragZone(this, {
  5381. ddGroup: this.dragGroup
  5382. });
  5383. }
  5384. if (this.droppable || this.dropGroup){
  5385. this.dropZone = new Ext.ux.form.MultiSelect.DropZone(this, {
  5386. ddGroup: this.dropGroup
  5387. });
  5388. }
  5389. },
  5390. // private
  5391. onViewClick: function(vw, index, node, e) {
  5392. this.fireEvent('change', this, this.getValue(), this.hiddenField.dom.value);
  5393. this.hiddenField.dom.value = this.getValue();
  5394. this.fireEvent('click', this, e);
  5395. this.validate();
  5396. },
  5397. // private
  5398. onViewBeforeClick: function(vw, index, node, e) {
  5399. if (this.disabled || this.readOnly) {
  5400. return false;
  5401. }
  5402. },
  5403. // private
  5404. onViewDblClick : function(vw, index, node, e) {
  5405. return this.fireEvent('dblclick', vw, index, node, e);
  5406. },
  5407. <div id="method-Ext.ux.form.MultiSelect-getValue"></div>/**
  5408. * Returns an array of data values for the selected items in the list. The values will be separated
  5409. * by {@link #delimiter}.
  5410. * @return {Array} value An array of string data values
  5411. */
  5412. getValue: function(valueField){
  5413. var returnArray = [];
  5414. var selectionsArray = this.view.getSelectedIndexes();
  5415. if (selectionsArray.length == 0) {return '';}
  5416. for (var i=0; i<selectionsArray.length; i++) {
  5417. returnArray.push(this.store.getAt(selectionsArray[i]).get((valueField != null) ? valueField : this.valueField));
  5418. }
  5419. return returnArray.join(this.delimiter);
  5420. },
  5421. <div id="method-Ext.ux.form.MultiSelect-setValue"></div>/**
  5422. * Sets a delimited string (using {@link #delimiter}) or array of data values into the list.
  5423. * @param {String/Array} values The values to set
  5424. */
  5425. setValue: function(values) {
  5426. var index;
  5427. var selections = [];
  5428. this.view.clearSelections();
  5429. this.hiddenField.dom.value = '';
  5430. if (!values || (values == '')) { return; }
  5431. if (!Ext.isArray(values)) { values = values.split(this.delimiter); }
  5432. for (var i=0; i<values.length; i++) {
  5433. index = this.view.store.indexOf(this.view.store.query(this.valueField,
  5434. new RegExp('^' + values[i] + '$', "i")).itemAt(0));
  5435. selections.push(index);
  5436. }
  5437. this.view.select(selections);
  5438. this.hiddenField.dom.value = this.getValue();
  5439. this.validate();
  5440. },
  5441. // inherit docs
  5442. reset : function() {
  5443. this.setValue('');
  5444. },
  5445. // inherit docs
  5446. getRawValue: function(valueField) {
  5447. var tmp = this.getValue(valueField);
  5448. if (tmp.length) {
  5449. tmp = tmp.split(this.delimiter);
  5450. }
  5451. else {
  5452. tmp = [];
  5453. }
  5454. return tmp;
  5455. },
  5456. // inherit docs
  5457. setRawValue: function(values){
  5458. setValue(values);
  5459. },
  5460. // inherit docs
  5461. validateValue : function(value){
  5462. if (value.length < 1) { // if it has no value
  5463. if (this.allowBlank) {
  5464. this.clearInvalid();
  5465. return true;
  5466. } else {
  5467. this.markInvalid(this.blankText);
  5468. return false;
  5469. }
  5470. }
  5471. if (value.length < this.minSelections) {
  5472. this.markInvalid(String.format(this.minSelectionsText, this.minSelections));
  5473. return false;
  5474. }
  5475. if (value.length > this.maxSelections) {
  5476. this.markInvalid(String.format(this.maxSelectionsText, this.maxSelections));
  5477. return false;
  5478. }
  5479. return true;
  5480. },
  5481. // inherit docs
  5482. disable: function(){
  5483. this.disabled = true;
  5484. this.hiddenField.dom.disabled = true;
  5485. this.fs.disable();
  5486. },
  5487. // inherit docs
  5488. enable: function(){
  5489. this.disabled = false;
  5490. this.hiddenField.dom.disabled = false;
  5491. this.fs.enable();
  5492. },
  5493. // inherit docs
  5494. destroy: function(){
  5495. Ext.destroy(this.fs, this.dragZone, this.dropZone);
  5496. Ext.ux.form.MultiSelect.superclass.destroy.call(this);
  5497. }
  5498. });
  5499. Ext.reg('multiselect', Ext.ux.form.MultiSelect);
  5500. //backwards compat
  5501. Ext.ux.Multiselect = Ext.ux.form.MultiSelect;
  5502. Ext.ux.form.MultiSelect.DragZone = function(ms, config){
  5503. this.ms = ms;
  5504. this.view = ms.view;
  5505. var ddGroup = config.ddGroup || 'MultiselectDD';
  5506. var dd;
  5507. if (Ext.isArray(ddGroup)){
  5508. dd = ddGroup.shift();
  5509. } else {
  5510. dd = ddGroup;
  5511. ddGroup = null;
  5512. }
  5513. Ext.ux.form.MultiSelect.DragZone.superclass.constructor.call(this, this.ms.fs.body, { containerScroll: true, ddGroup: dd });
  5514. this.setDraggable(ddGroup);
  5515. };
  5516. Ext.extend(Ext.ux.form.MultiSelect.DragZone, Ext.dd.DragZone, {
  5517. onInitDrag : function(x, y){
  5518. var el = Ext.get(this.dragData.ddel.cloneNode(true));
  5519. this.proxy.update(el.dom);
  5520. el.setWidth(el.child('em').getWidth());
  5521. this.onStartDrag(x, y);
  5522. return true;
  5523. },
  5524. // private
  5525. collectSelection: function(data) {
  5526. data.repairXY = Ext.fly(this.view.getSelectedNodes()[0]).getXY();
  5527. var i = 0;
  5528. this.view.store.each(function(rec){
  5529. if (this.view.isSelected(i)) {
  5530. var n = this.view.getNode(i);
  5531. var dragNode = n.cloneNode(true);
  5532. dragNode.id = Ext.id();
  5533. data.ddel.appendChild(dragNode);
  5534. data.records.push(this.view.store.getAt(i));
  5535. data.viewNodes.push(n);
  5536. }
  5537. i++;
  5538. }, this);
  5539. },
  5540. // override
  5541. onEndDrag: function(data, e) {
  5542. var d = Ext.get(this.dragData.ddel);
  5543. if (d && d.hasClass("multi-proxy")) {
  5544. d.remove();
  5545. }
  5546. },
  5547. // override
  5548. getDragData: function(e){
  5549. var target = this.view.findItemFromChild(e.getTarget());
  5550. if(target) {
  5551. if (!this.view.isSelected(target) && !e.ctrlKey && !e.shiftKey) {
  5552. this.view.select(target);
  5553. this.ms.setValue(this.ms.getValue());
  5554. }
  5555. if (this.view.getSelectionCount() == 0 || e.ctrlKey || e.shiftKey) return false;
  5556. var dragData = {
  5557. sourceView: this.view,
  5558. viewNodes: [],
  5559. records: []
  5560. };
  5561. if (this.view.getSelectionCount() == 1) {
  5562. var i = this.view.getSelectedIndexes()[0];
  5563. var n = this.view.getNode(i);
  5564. dragData.viewNodes.push(dragData.ddel = n);
  5565. dragData.records.push(this.view.store.getAt(i));
  5566. dragData.repairXY = Ext.fly(n).getXY();
  5567. } else {
  5568. dragData.ddel = document.createElement('div');
  5569. dragData.ddel.className = 'multi-proxy';
  5570. this.collectSelection(dragData);
  5571. }
  5572. return dragData;
  5573. }
  5574. return false;
  5575. },
  5576. // override the default repairXY.
  5577. getRepairXY : function(e){
  5578. return this.dragData.repairXY;
  5579. },
  5580. // private
  5581. setDraggable: function(ddGroup){
  5582. if (!ddGroup) return;
  5583. if (Ext.isArray(ddGroup)) {
  5584. Ext.each(ddGroup, this.setDraggable, this);
  5585. return;
  5586. }
  5587. this.addToGroup(ddGroup);
  5588. }
  5589. });
  5590. Ext.ux.form.MultiSelect.DropZone = function(ms, config){
  5591. this.ms = ms;
  5592. this.view = ms.view;
  5593. var ddGroup = config.ddGroup || 'MultiselectDD';
  5594. var dd;
  5595. if (Ext.isArray(ddGroup)){
  5596. dd = ddGroup.shift();
  5597. } else {
  5598. dd = ddGroup;
  5599. ddGroup = null;
  5600. }
  5601. Ext.ux.form.MultiSelect.DropZone.superclass.constructor.call(this, this.ms.fs.body, { containerScroll: true, ddGroup: dd });
  5602. this.setDroppable(ddGroup);
  5603. };
  5604. Ext.extend(Ext.ux.form.MultiSelect.DropZone, Ext.dd.DropZone, {
  5605. <div id="method-Ext.ux.form.MultiSelect-getTargetFromEvent"></div>/**
  5606. * Part of the Ext.dd.DropZone interface. If no target node is found, the
  5607. * whole Element becomes the target, and this causes the drop gesture to append.
  5608. */
  5609. getTargetFromEvent : function(e) {
  5610. var target = e.getTarget();
  5611. return target;
  5612. },
  5613. // private
  5614. getDropPoint : function(e, n, dd){
  5615. if (n == this.ms.fs.body.dom) { return "below"; }
  5616. var t = Ext.lib.Dom.getY(n), b = t + n.offsetHeight;
  5617. var c = t + (b - t) / 2;
  5618. var y = Ext.lib.Event.getPageY(e);
  5619. if(y <= c) {
  5620. return "above";
  5621. }else{
  5622. return "below";
  5623. }
  5624. },
  5625. // private
  5626. isValidDropPoint: function(pt, n, data) {
  5627. if (!data.viewNodes || (data.viewNodes.length != 1)) {
  5628. return true;
  5629. }
  5630. var d = data.viewNodes[0];
  5631. if (d == n) {
  5632. return false;
  5633. }
  5634. if ((pt == "below") && (n.nextSibling == d)) {
  5635. return false;
  5636. }
  5637. if ((pt == "above") && (n.previousSibling == d)) {
  5638. return false;
  5639. }
  5640. return true;
  5641. },
  5642. // override
  5643. onNodeEnter : function(n, dd, e, data){
  5644. return false;
  5645. },
  5646. // override
  5647. onNodeOver : function(n, dd, e, data){
  5648. var dragElClass = this.dropNotAllowed;
  5649. var pt = this.getDropPoint(e, n, dd);
  5650. if (this.isValidDropPoint(pt, n, data)) {
  5651. if (this.ms.appendOnly) {
  5652. return "x-tree-drop-ok-below";
  5653. }
  5654. // set the insert point style on the target node
  5655. if (pt) {
  5656. var targetElClass;
  5657. if (pt == "above"){
  5658. dragElClass = n.previousSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-above";
  5659. targetElClass = "x-view-drag-insert-above";
  5660. } else {
  5661. dragElClass = n.nextSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-below";
  5662. targetElClass = "x-view-drag-insert-below";
  5663. }
  5664. if (this.lastInsertClass != targetElClass){
  5665. Ext.fly(n).replaceClass(this.lastInsertClass, targetElClass);
  5666. this.lastInsertClass = targetElClass;
  5667. }
  5668. }
  5669. }
  5670. return dragElClass;
  5671. },
  5672. // private
  5673. onNodeOut : function(n, dd, e, data){
  5674. this.removeDropIndicators(n);
  5675. },
  5676. // private
  5677. onNodeDrop : function(n, dd, e, data){
  5678. if (this.ms.fireEvent("drop", this, n, dd, e, data) === false) {
  5679. return false;
  5680. }
  5681. var pt = this.getDropPoint(e, n, dd);
  5682. if (n != this.ms.fs.body.dom)
  5683. n = this.view.findItemFromChild(n);
  5684. if(this.ms.appendOnly) {
  5685. insertAt = this.view.store.getCount();
  5686. } else {
  5687. insertAt = n == this.ms.fs.body.dom ? this.view.store.getCount() - 1 : this.view.indexOf(n);
  5688. if (pt == "below") {
  5689. insertAt++;
  5690. }
  5691. }
  5692. var dir = false;
  5693. // Validate if dragging within the same MultiSelect
  5694. if (data.sourceView == this.view) {
  5695. // If the first element to be inserted below is the target node, remove it
  5696. if (pt == "below") {
  5697. if (data.viewNodes[0] == n) {
  5698. data.viewNodes.shift();
  5699. }
  5700. } else { // If the last element to be inserted above is the target node, remove it
  5701. if (data.viewNodes[data.viewNodes.length - 1] == n) {
  5702. data.viewNodes.pop();
  5703. }
  5704. }
  5705. // Nothing to drop...
  5706. if (!data.viewNodes.length) {
  5707. return false;
  5708. }
  5709. // If we are moving DOWN, then because a store.remove() takes place first,
  5710. // the insertAt must be decremented.
  5711. if (insertAt > this.view.store.indexOf(data.records[0])) {
  5712. dir = 'down';
  5713. insertAt--;
  5714. }
  5715. }
  5716. for (var i = 0; i < data.records.length; i++) {
  5717. var r = data.records[i];
  5718. if (data.sourceView) {
  5719. data.sourceView.store.remove(r);
  5720. }
  5721. this.view.store.insert(dir == 'down' ? insertAt : insertAt++, r);
  5722. var si = this.view.store.sortInfo;
  5723. if(si){
  5724. this.view.store.sort(si.field, si.direction);
  5725. }
  5726. }
  5727. return true;
  5728. },
  5729. // private
  5730. removeDropIndicators : function(n){
  5731. if(n){
  5732. Ext.fly(n).removeClass([
  5733. "x-view-drag-insert-above",
  5734. "x-view-drag-insert-left",
  5735. "x-view-drag-insert-right",
  5736. "x-view-drag-insert-below"]);
  5737. this.lastInsertClass = "_noclass";
  5738. }
  5739. },
  5740. // private
  5741. setDroppable: function(ddGroup){
  5742. if (!ddGroup) return;
  5743. if (Ext.isArray(ddGroup)) {
  5744. Ext.each(ddGroup, this.setDroppable, this);
  5745. return;
  5746. }
  5747. this.addToGroup(ddGroup);
  5748. }
  5749. });
  5750. /* Fix for Opera, which does not seem to include the map function on Array's */
  5751. if (!Array.prototype.map) {
  5752. Array.prototype.map = function(fun){
  5753. var len = this.length;
  5754. if (typeof fun != 'function') {
  5755. throw new TypeError();
  5756. }
  5757. var res = new Array(len);
  5758. var thisp = arguments[1];
  5759. for (var i = 0; i < len; i++) {
  5760. if (i in this) {
  5761. res[i] = fun.call(thisp, this[i], i, this);
  5762. }
  5763. }
  5764. return res;
  5765. };
  5766. }
  5767. Ext.ns('Ext.ux.data');
  5768. /**
  5769. * @class Ext.ux.data.PagingMemoryProxy
  5770. * @extends Ext.data.MemoryProxy
  5771. * <p>Paging Memory Proxy, allows to use paging grid with in memory dataset</p>
  5772. */
  5773. Ext.ux.data.PagingMemoryProxy = Ext.extend(Ext.data.MemoryProxy, {
  5774. constructor : function(data){
  5775. Ext.ux.data.PagingMemoryProxy.superclass.constructor.call(this);
  5776. this.data = data;
  5777. },
  5778. doRequest : function(action, rs, params, reader, callback, scope, options){
  5779. params = params ||
  5780. {};
  5781. var result;
  5782. try {
  5783. result = reader.readRecords(this.data);
  5784. }
  5785. catch (e) {
  5786. this.fireEvent('loadexception', this, options, null, e);
  5787. callback.call(scope, null, options, false);
  5788. return;
  5789. }
  5790. // filtering
  5791. if (params.filter !== undefined) {
  5792. result.records = result.records.filter(function(el){
  5793. if (typeof(el) == 'object') {
  5794. var att = params.filterCol || 0;
  5795. return String(el.data[att]).match(params.filter) ? true : false;
  5796. }
  5797. else {
  5798. return String(el).match(params.filter) ? true : false;
  5799. }
  5800. });
  5801. result.totalRecords = result.records.length;
  5802. }
  5803. // sorting
  5804. if (params.sort !== undefined) {
  5805. // use integer as params.sort to specify column, since arrays are not named
  5806. // params.sort=0; would also match a array without columns
  5807. var dir = String(params.dir).toUpperCase() == 'DESC' ? -1 : 1;
  5808. var fn = function(v1, v2){
  5809. return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
  5810. };
  5811. result.records.sort(function(a, b){
  5812. var v = 0;
  5813. if (typeof(a) == 'object') {
  5814. v = fn(a.data[params.sort], b.data[params.sort]) * dir;
  5815. }
  5816. else {
  5817. v = fn(a, b) * dir;
  5818. }
  5819. if (v == 0) {
  5820. v = (a.index < b.index ? -1 : 1);
  5821. }
  5822. return v;
  5823. });
  5824. }
  5825. // paging (use undefined cause start can also be 0 (thus false))
  5826. if (params.start !== undefined && params.limit !== undefined) {
  5827. result.records = result.records.slice(params.start, params.start + params.limit);
  5828. }
  5829. callback.call(scope, result, options, true);
  5830. }
  5831. });
  5832. //backwards compat.
  5833. Ext.data.PagingMemoryProxy = Ext.ux.data.PagingMemoryProxy;
  5834. Ext.ux.PanelResizer = Ext.extend(Ext.util.Observable, {
  5835. minHeight: 0,
  5836. maxHeight:10000000,
  5837. constructor: function(config){
  5838. Ext.apply(this, config);
  5839. this.events = {};
  5840. Ext.ux.PanelResizer.superclass.constructor.call(this, config);
  5841. },
  5842. init : function(p){
  5843. this.panel = p;
  5844. if(this.panel.elements.indexOf('footer')==-1){
  5845. p.elements += ',footer';
  5846. }
  5847. p.on('render', this.onRender, this);
  5848. },
  5849. onRender : function(p){
  5850. this.handle = p.footer.createChild({cls:'x-panel-resize'});
  5851. this.tracker = new Ext.dd.DragTracker({
  5852. onStart: this.onDragStart.createDelegate(this),
  5853. onDrag: this.onDrag.createDelegate(this),
  5854. onEnd: this.onDragEnd.createDelegate(this),
  5855. tolerance: 3,
  5856. autoStart: 300
  5857. });
  5858. this.tracker.initEl(this.handle);
  5859. p.on('beforedestroy', this.tracker.destroy, this.tracker);
  5860. },
  5861. // private
  5862. onDragStart: function(e){
  5863. this.dragging = true;
  5864. this.startHeight = this.panel.el.getHeight();
  5865. this.fireEvent('dragstart', this, e);
  5866. },
  5867. // private
  5868. onDrag: function(e){
  5869. this.panel.setHeight((this.startHeight-this.tracker.getOffset()[1]).constrain(this.minHeight, this.maxHeight));
  5870. this.fireEvent('drag', this, e);
  5871. },
  5872. // private
  5873. onDragEnd: function(e){
  5874. this.dragging = false;
  5875. this.fireEvent('dragend', this, e);
  5876. }
  5877. });
  5878. Ext.preg('panelresizer', Ext.ux.PanelResizer);Ext.ux.Portal = Ext.extend(Ext.Panel, {
  5879. layout : 'column',
  5880. autoScroll : true,
  5881. cls : 'x-portal',
  5882. defaultType : 'portalcolumn',
  5883. initComponent : function(){
  5884. Ext.ux.Portal.superclass.initComponent.call(this);
  5885. this.addEvents({
  5886. validatedrop:true,
  5887. beforedragover:true,
  5888. dragover:true,
  5889. beforedrop:true,
  5890. drop:true
  5891. });
  5892. },
  5893. initEvents : function(){
  5894. Ext.ux.Portal.superclass.initEvents.call(this);
  5895. this.dd = new Ext.ux.Portal.DropZone(this, this.dropConfig);
  5896. },
  5897. beforeDestroy : function() {
  5898. if(this.dd){
  5899. this.dd.unreg();
  5900. }
  5901. Ext.ux.Portal.superclass.beforeDestroy.call(this);
  5902. }
  5903. });
  5904. Ext.reg('portal', Ext.ux.Portal);
  5905. Ext.ux.Portal.DropZone = Ext.extend(Ext.dd.DropTarget, {
  5906. constructor : function(portal, cfg){
  5907. this.portal = portal;
  5908. Ext.dd.ScrollManager.register(portal.body);
  5909. Ext.ux.Portal.DropZone.superclass.constructor.call(this, portal.bwrap.dom, cfg);
  5910. portal.body.ddScrollConfig = this.ddScrollConfig;
  5911. },
  5912. ddScrollConfig : {
  5913. vthresh: 50,
  5914. hthresh: -1,
  5915. animate: true,
  5916. increment: 200
  5917. },
  5918. createEvent : function(dd, e, data, col, c, pos){
  5919. return {
  5920. portal: this.portal,
  5921. panel: data.panel,
  5922. columnIndex: col,
  5923. column: c,
  5924. position: pos,
  5925. data: data,
  5926. source: dd,
  5927. rawEvent: e,
  5928. status: this.dropAllowed
  5929. };
  5930. },
  5931. notifyOver : function(dd, e, data){
  5932. var xy = e.getXY(), portal = this.portal, px = dd.proxy;
  5933. // case column widths
  5934. if(!this.grid){
  5935. this.grid = this.getGrid();
  5936. }
  5937. // handle case scroll where scrollbars appear during drag
  5938. var cw = portal.body.dom.clientWidth;
  5939. if(!this.lastCW){
  5940. this.lastCW = cw;
  5941. }else if(this.lastCW != cw){
  5942. this.lastCW = cw;
  5943. portal.doLayout();
  5944. this.grid = this.getGrid();
  5945. }
  5946. // determine column
  5947. var col = 0, xs = this.grid.columnX, cmatch = false;
  5948. for(var len = xs.length; col < len; col++){
  5949. if(xy[0] < (xs[col].x + xs[col].w)){
  5950. cmatch = true;
  5951. break;
  5952. }
  5953. }
  5954. // no match, fix last index
  5955. if(!cmatch){
  5956. col--;
  5957. }
  5958. // find insert position
  5959. var p, match = false, pos = 0,
  5960. c = portal.items.itemAt(col),
  5961. items = c.items.items, overSelf = false;
  5962. for(var len = items.length; pos < len; pos++){
  5963. p = items[pos];
  5964. var h = p.el.getHeight();
  5965. if(h === 0){
  5966. overSelf = true;
  5967. }
  5968. else if((p.el.getY()+(h/2)) > xy[1]){
  5969. match = true;
  5970. break;
  5971. }
  5972. }
  5973. pos = (match && p ? pos : c.items.getCount()) + (overSelf ? -1 : 0);
  5974. var overEvent = this.createEvent(dd, e, data, col, c, pos);
  5975. if(portal.fireEvent('validatedrop', overEvent) !== false &&
  5976. portal.fireEvent('beforedragover', overEvent) !== false){
  5977. // make sure proxy width is fluid
  5978. px.getProxy().setWidth('auto');
  5979. if(p){
  5980. px.moveProxy(p.el.dom.parentNode, match ? p.el.dom : null);
  5981. }else{
  5982. px.moveProxy(c.el.dom, null);
  5983. }
  5984. this.lastPos = {c: c, col: col, p: overSelf || (match && p) ? pos : false};
  5985. this.scrollPos = portal.body.getScroll();
  5986. portal.fireEvent('dragover', overEvent);
  5987. return overEvent.status;
  5988. }else{
  5989. return overEvent.status;
  5990. }
  5991. },
  5992. notifyOut : function(){
  5993. delete this.grid;
  5994. },
  5995. notifyDrop : function(dd, e, data){
  5996. delete this.grid;
  5997. if(!this.lastPos){
  5998. return;
  5999. }
  6000. var c = this.lastPos.c,
  6001. col = this.lastPos.col,
  6002. pos = this.lastPos.p,
  6003. panel = dd.panel,
  6004. dropEvent = this.createEvent(dd, e, data, col, c,
  6005. pos !== false ? pos : c.items.getCount());
  6006. if(this.portal.fireEvent('validatedrop', dropEvent) !== false &&
  6007. this.portal.fireEvent('beforedrop', dropEvent) !== false){
  6008. dd.proxy.getProxy().remove();
  6009. panel.el.dom.parentNode.removeChild(dd.panel.el.dom);
  6010. if(pos !== false){
  6011. c.insert(pos, panel);
  6012. }else{
  6013. c.add(panel);
  6014. }
  6015. c.doLayout();
  6016. this.portal.fireEvent('drop', dropEvent);
  6017. // scroll position is lost on drop, fix it
  6018. var st = this.scrollPos.top;
  6019. if(st){
  6020. var d = this.portal.body.dom;
  6021. setTimeout(function(){
  6022. d.scrollTop = st;
  6023. }, 10);
  6024. }
  6025. }
  6026. delete this.lastPos;
  6027. },
  6028. // internal cache of body and column coords
  6029. getGrid : function(){
  6030. var box = this.portal.bwrap.getBox();
  6031. box.columnX = [];
  6032. this.portal.items.each(function(c){
  6033. box.columnX.push({x: c.el.getX(), w: c.el.getWidth()});
  6034. });
  6035. return box;
  6036. },
  6037. // unregister the dropzone from ScrollManager
  6038. unreg: function() {
  6039. Ext.dd.ScrollManager.unregister(this.portal.body);
  6040. Ext.ux.Portal.DropZone.superclass.unreg.call(this);
  6041. }
  6042. });
  6043. Ext.ux.PortalColumn = Ext.extend(Ext.Container, {
  6044. layout : 'anchor',
  6045. //autoEl : 'div',//already defined by Ext.Component
  6046. defaultType : 'portlet',
  6047. cls : 'x-portal-column'
  6048. });
  6049. Ext.reg('portalcolumn', Ext.ux.PortalColumn);
  6050. Ext.ux.Portlet = Ext.extend(Ext.Panel, {
  6051. anchor : '100%',
  6052. frame : true,
  6053. collapsible : true,
  6054. draggable : true,
  6055. cls : 'x-portlet'
  6056. });
  6057. Ext.reg('portlet', Ext.ux.Portlet);
  6058. <div id="cls-Ext.ux.ProgressBarPager"></div>/**
  6059. * @class Ext.ux.ProgressBarPager
  6060. * @extends Object
  6061. * Plugin (ptype = 'tabclosemenu') for displaying a progressbar inside of a paging toolbar instead of plain text
  6062. *
  6063. * @ptype progressbarpager
  6064. * @constructor
  6065. * Create a new ItemSelector
  6066. * @param {Object} config Configuration options
  6067. * @xtype itemselector
  6068. */
  6069. Ext.ux.ProgressBarPager = Ext.extend(Object, {
  6070. <div id="cfg-Ext.ux.ProgressBarPager-progBarWidth"></div>/**
  6071. * @cfg {Integer} progBarWidth
  6072. * <p>The default progress bar width. Default is 225.</p>
  6073. */
  6074. progBarWidth : 225,
  6075. <div id="cfg-Ext.ux.ProgressBarPager-defaultText"></div>/**
  6076. * @cfg {String} defaultText
  6077. * <p>The text to display while the store is loading. Default is 'Loading...'</p>
  6078. */
  6079. defaultText : 'Loading...',
  6080. <div id="cfg-Ext.ux.ProgressBarPager-defaultAnimCfg"></div>/**
  6081. * @cfg {Object} defaultAnimCfg
  6082. * <p>A {@link Ext.Fx Ext.Fx} configuration object. Default is { duration : 1, easing : 'bounceOut' }.</p>
  6083. */
  6084. defaultAnimCfg : {
  6085. duration : 1,
  6086. easing : 'bounceOut'
  6087. },
  6088. constructor : function(config) {
  6089. if (config) {
  6090. Ext.apply(this, config);
  6091. }
  6092. },
  6093. //public
  6094. init : function (parent) {
  6095. if(parent.displayInfo){
  6096. this.parent = parent;
  6097. var ind = parent.items.indexOf(parent.displayItem);
  6098. parent.remove(parent.displayItem, true);
  6099. this.progressBar = new Ext.ProgressBar({
  6100. text : this.defaultText,
  6101. width : this.progBarWidth,
  6102. animate : this.defaultAnimCfg
  6103. });
  6104. parent.displayItem = this.progressBar;
  6105. parent.add(parent.displayItem);
  6106. parent.doLayout();
  6107. Ext.apply(parent, this.parentOverrides);
  6108. this.progressBar.on('render', function(pb) {
  6109. pb.mon(pb.getEl().applyStyles('cursor:pointer'), 'click', this.handleProgressBarClick, this);
  6110. }, this, {single: true});
  6111. }
  6112. },
  6113. // private
  6114. // This method handles the click for the progress bar
  6115. handleProgressBarClick : function(e){
  6116. var parent = this.parent,
  6117. displayItem = parent.displayItem,
  6118. box = this.progressBar.getBox(),
  6119. xy = e.getXY(),
  6120. position = xy[0]-box.x,
  6121. pages = Math.ceil(parent.store.getTotalCount()/parent.pageSize),
  6122. newpage = Math.ceil(position/(displayItem.width/pages));
  6123. parent.changePage(newpage);
  6124. },
  6125. // private, overriddes
  6126. parentOverrides : {
  6127. // private
  6128. // This method updates the information via the progress bar.
  6129. updateInfo : function(){
  6130. if(this.displayItem){
  6131. var count = this.store.getCount(),
  6132. pgData = this.getPageData(),
  6133. pageNum = this.readPage(pgData),
  6134. msg = count == 0 ?
  6135. this.emptyMsg :
  6136. String.format(
  6137. this.displayMsg,
  6138. this.cursor+1, this.cursor+count, this.store.getTotalCount()
  6139. );
  6140. pageNum = pgData.activePage; ;
  6141. var pct = pageNum / pgData.pages;
  6142. this.displayItem.updateProgress(pct, msg, this.animate || this.defaultAnimConfig);
  6143. }
  6144. }
  6145. }
  6146. });
  6147. Ext.preg('progressbarpager', Ext.ux.ProgressBarPager);
  6148. Ext.ns('Ext.ux.grid');
  6149. <div id="cls-Ext.ux.grid.RowEditor"></div>/**
  6150. * @class Ext.ux.grid.RowEditor
  6151. * @extends Ext.Panel
  6152. * Plugin (ptype = 'roweditor') that adds the ability to rapidly edit full rows in a grid.
  6153. * A validation mode may be enabled which uses AnchorTips to notify the user of all
  6154. * validation errors at once.
  6155. *
  6156. * @ptype roweditor
  6157. */
  6158. Ext.ux.grid.RowEditor = Ext.extend(Ext.Panel, {
  6159. floating: true,
  6160. shadow: false,
  6161. layout: 'hbox',
  6162. cls: 'x-small-editor',
  6163. buttonAlign: 'center',
  6164. baseCls: 'x-row-editor',
  6165. elements: 'header,footer,body',
  6166. frameWidth: 5,
  6167. buttonPad: 3,
  6168. clicksToEdit: 'auto',
  6169. monitorValid: true,
  6170. focusDelay: 250,
  6171. errorSummary: true,
  6172. saveText: 'Save',
  6173. cancelText: 'Cancel',
  6174. commitChangesText: 'You need to commit or cancel your changes',
  6175. errorText: 'Errors',
  6176. defaults: {
  6177. normalWidth: true
  6178. },
  6179. initComponent: function(){
  6180. Ext.ux.grid.RowEditor.superclass.initComponent.call(this);
  6181. this.addEvents(
  6182. <div id="event-Ext.ux.grid.RowEditor-beforeedit"></div>/**
  6183. * @event beforeedit
  6184. * Fired before the row editor is activated.
  6185. * If the listener returns <tt>false</tt> the editor will not be activated.
  6186. * @param {Ext.ux.grid.RowEditor} roweditor This object
  6187. * @param {Number} rowIndex The rowIndex of the row just edited
  6188. */
  6189. 'beforeedit',
  6190. <div id="event-Ext.ux.grid.RowEditor-canceledit"></div>/**
  6191. * @event canceledit
  6192. * Fired when the editor is cancelled.
  6193. * @param {Ext.ux.grid.RowEditor} roweditor This object
  6194. * @param {Boolean} forced True if the cancel button is pressed, false is the editor was invalid.
  6195. */
  6196. 'canceledit',
  6197. <div id="event-Ext.ux.grid.RowEditor-validateedit"></div>/**
  6198. * @event validateedit
  6199. * Fired after a row is edited and passes validation.
  6200. * If the listener returns <tt>false</tt> changes to the record will not be set.
  6201. * @param {Ext.ux.grid.RowEditor} roweditor This object
  6202. * @param {Object} changes Object with changes made to the record.
  6203. * @param {Ext.data.Record} r The Record that was edited.
  6204. * @param {Number} rowIndex The rowIndex of the row just edited
  6205. */
  6206. 'validateedit',
  6207. <div id="event-Ext.ux.grid.RowEditor-afteredit"></div>/**
  6208. * @event afteredit
  6209. * Fired after a row is edited and passes validation. This event is fired
  6210. * after the store's update event is fired with this edit.
  6211. * @param {Ext.ux.grid.RowEditor} roweditor This object
  6212. * @param {Object} changes Object with changes made to the record.
  6213. * @param {Ext.data.Record} r The Record that was edited.
  6214. * @param {Number} rowIndex The rowIndex of the row just edited
  6215. */
  6216. 'afteredit'
  6217. );
  6218. },
  6219. init: function(grid){
  6220. this.grid = grid;
  6221. this.ownerCt = grid;
  6222. if(this.clicksToEdit === 2){
  6223. grid.on('rowdblclick', this.onRowDblClick, this);
  6224. }else{
  6225. grid.on('rowclick', this.onRowClick, this);
  6226. if(Ext.isIE){
  6227. grid.on('rowdblclick', this.onRowDblClick, this);
  6228. }
  6229. }
  6230. // stopEditing without saving when a record is removed from Store.
  6231. grid.getStore().on('remove', function() {
  6232. this.stopEditing(false);
  6233. },this);
  6234. grid.on({
  6235. scope: this,
  6236. keydown: this.onGridKey,
  6237. columnresize: this.verifyLayout,
  6238. columnmove: this.refreshFields,
  6239. reconfigure: this.refreshFields,
  6240. beforedestroy : this.beforedestroy,
  6241. destroy : this.destroy,
  6242. bodyscroll: {
  6243. buffer: 250,
  6244. fn: this.positionButtons
  6245. }
  6246. });
  6247. grid.getColumnModel().on('hiddenchange', this.verifyLayout, this, {delay:1});
  6248. grid.getView().on('refresh', this.stopEditing.createDelegate(this, []));
  6249. },
  6250. beforedestroy: function() {
  6251. this.stopMonitoring();
  6252. this.grid.getStore().un('remove', this.onStoreRemove, this);
  6253. this.stopEditing(false);
  6254. Ext.destroy(this.btns, this.tooltip);
  6255. },
  6256. refreshFields: function(){
  6257. this.initFields();
  6258. this.verifyLayout();
  6259. },
  6260. isDirty: function(){
  6261. var dirty;
  6262. this.items.each(function(f){
  6263. if(String(this.values[f.id]) !== String(f.getValue())){
  6264. dirty = true;
  6265. return false;
  6266. }
  6267. }, this);
  6268. return dirty;
  6269. },
  6270. startEditing: function(rowIndex, doFocus){
  6271. if(this.editing && this.isDirty()){
  6272. this.showTooltip(this.commitChangesText);
  6273. return;
  6274. }
  6275. if(Ext.isObject(rowIndex)){
  6276. rowIndex = this.grid.getStore().indexOf(rowIndex);
  6277. }
  6278. if(this.fireEvent('beforeedit', this, rowIndex) !== false){
  6279. this.editing = true;
  6280. var g = this.grid, view = g.getView(),
  6281. row = view.getRow(rowIndex),
  6282. record = g.store.getAt(rowIndex);
  6283. this.record = record;
  6284. this.rowIndex = rowIndex;
  6285. this.values = {};
  6286. if(!this.rendered){
  6287. this.render(view.getEditorParent());
  6288. }
  6289. var w = Ext.fly(row).getWidth();
  6290. this.setSize(w);
  6291. if(!this.initialized){
  6292. this.initFields();
  6293. }
  6294. var cm = g.getColumnModel(), fields = this.items.items, f, val;
  6295. for(var i = 0, len = cm.getColumnCount(); i < len; i++){
  6296. val = this.preEditValue(record, cm.getDataIndex(i));
  6297. f = fields[i];
  6298. f.setValue(val);
  6299. this.values[f.id] = Ext.isEmpty(val) ? '' : val;
  6300. }
  6301. this.verifyLayout(true);
  6302. if(!this.isVisible()){
  6303. this.setPagePosition(Ext.fly(row).getXY());
  6304. } else{
  6305. this.el.setXY(Ext.fly(row).getXY(), {duration:0.15});
  6306. }
  6307. if(!this.isVisible()){
  6308. this.show().doLayout();
  6309. }
  6310. if(doFocus !== false){
  6311. this.doFocus.defer(this.focusDelay, this);
  6312. }
  6313. }
  6314. },
  6315. stopEditing : function(saveChanges){
  6316. this.editing = false;
  6317. if(!this.isVisible()){
  6318. return;
  6319. }
  6320. if(saveChanges === false || !this.isValid()){
  6321. this.hide();
  6322. this.fireEvent('canceledit', this, saveChanges === false);
  6323. return;
  6324. }
  6325. var changes = {},
  6326. r = this.record,
  6327. hasChange = false,
  6328. cm = this.grid.colModel,
  6329. fields = this.items.items;
  6330. for(var i = 0, len = cm.getColumnCount(); i < len; i++){
  6331. if(!cm.isHidden(i)){
  6332. var dindex = cm.getDataIndex(i);
  6333. if(!Ext.isEmpty(dindex)){
  6334. var oldValue = r.data[dindex],
  6335. value = this.postEditValue(fields[i].getValue(), oldValue, r, dindex);
  6336. if(String(oldValue) !== String(value)){
  6337. changes[dindex] = value;
  6338. hasChange = true;
  6339. }
  6340. }
  6341. }
  6342. }
  6343. if(hasChange && this.fireEvent('validateedit', this, changes, r, this.rowIndex) !== false){
  6344. r.beginEdit();
  6345. Ext.iterate(changes, function(name, value){
  6346. r.set(name, value);
  6347. });
  6348. r.endEdit();
  6349. this.fireEvent('afteredit', this, changes, r, this.rowIndex);
  6350. }
  6351. this.hide();
  6352. },
  6353. verifyLayout: function(force){
  6354. if(this.el && (this.isVisible() || force === true)){
  6355. var row = this.grid.getView().getRow(this.rowIndex);
  6356. this.setSize(Ext.fly(row).getWidth(), Ext.isIE ? Ext.fly(row).getHeight() + 9 : undefined);
  6357. var cm = this.grid.colModel, fields = this.items.items;
  6358. for(var i = 0, len = cm.getColumnCount(); i < len; i++){
  6359. if(!cm.isHidden(i)){
  6360. var adjust = 0;
  6361. if(i === (len - 1)){
  6362. adjust += 3; // outer padding
  6363. } else{
  6364. adjust += 1;
  6365. }
  6366. fields[i].show();
  6367. fields[i].setWidth(cm.getColumnWidth(i) - adjust);
  6368. } else{
  6369. fields[i].hide();
  6370. }
  6371. }
  6372. this.doLayout();
  6373. this.positionButtons();
  6374. }
  6375. },
  6376. slideHide : function(){
  6377. this.hide();
  6378. },
  6379. initFields: function(){
  6380. var cm = this.grid.getColumnModel(), pm = Ext.layout.ContainerLayout.prototype.parseMargins;
  6381. this.removeAll(false);
  6382. for(var i = 0, len = cm.getColumnCount(); i < len; i++){
  6383. var c = cm.getColumnAt(i),
  6384. ed = c.getEditor();
  6385. if(!ed){
  6386. ed = c.displayEditor || new Ext.form.DisplayField();
  6387. }
  6388. if(i == 0){
  6389. ed.margins = pm('0 1 2 1');
  6390. } else if(i == len - 1){
  6391. ed.margins = pm('0 0 2 1');
  6392. } else{
  6393. if (Ext.isIE) {
  6394. ed.margins = pm('0 0 2 0');
  6395. }
  6396. else {
  6397. ed.margins = pm('0 1 2 0');
  6398. }
  6399. }
  6400. ed.setWidth(cm.getColumnWidth(i));
  6401. ed.column = c;
  6402. if(ed.ownerCt !== this){
  6403. ed.on('focus', this.ensureVisible, this);
  6404. ed.on('specialkey', this.onKey, this);
  6405. }
  6406. this.insert(i, ed);
  6407. }
  6408. this.initialized = true;
  6409. },
  6410. onKey: function(f, e){
  6411. if(e.getKey() === e.ENTER){
  6412. this.stopEditing(true);
  6413. e.stopPropagation();
  6414. }
  6415. },
  6416. onGridKey: function(e){
  6417. if(e.getKey() === e.ENTER && !this.isVisible()){
  6418. var r = this.grid.getSelectionModel().getSelected();
  6419. if(r){
  6420. var index = this.grid.store.indexOf(r);
  6421. this.startEditing(index);
  6422. e.stopPropagation();
  6423. }
  6424. }
  6425. },
  6426. ensureVisible: function(editor){
  6427. if(this.isVisible()){
  6428. this.grid.getView().ensureVisible(this.rowIndex, this.grid.colModel.getIndexById(editor.column.id), true);
  6429. }
  6430. },
  6431. onRowClick: function(g, rowIndex, e){
  6432. if(this.clicksToEdit == 'auto'){
  6433. var li = this.lastClickIndex;
  6434. this.lastClickIndex = rowIndex;
  6435. if(li != rowIndex && !this.isVisible()){
  6436. return;
  6437. }
  6438. }
  6439. this.startEditing(rowIndex, false);
  6440. this.doFocus.defer(this.focusDelay, this, [e.getPoint()]);
  6441. },
  6442. onRowDblClick: function(g, rowIndex, e){
  6443. this.startEditing(rowIndex, false);
  6444. this.doFocus.defer(this.focusDelay, this, [e.getPoint()]);
  6445. },
  6446. onRender: function(){
  6447. Ext.ux.grid.RowEditor.superclass.onRender.apply(this, arguments);
  6448. this.el.swallowEvent(['keydown', 'keyup', 'keypress']);
  6449. this.btns = new Ext.Panel({
  6450. baseCls: 'x-plain',
  6451. cls: 'x-btns',
  6452. elements:'body',
  6453. layout: 'table',
  6454. width: (this.minButtonWidth * 2) + (this.frameWidth * 2) + (this.buttonPad * 4), // width must be specified for IE
  6455. items: [{
  6456. ref: 'saveBtn',
  6457. itemId: 'saveBtn',
  6458. xtype: 'button',
  6459. text: this.saveText,
  6460. width: this.minButtonWidth,
  6461. handler: this.stopEditing.createDelegate(this, [true])
  6462. }, {
  6463. xtype: 'button',
  6464. text: this.cancelText,
  6465. width: this.minButtonWidth,
  6466. handler: this.stopEditing.createDelegate(this, [false])
  6467. }]
  6468. });
  6469. this.btns.render(this.bwrap);
  6470. },
  6471. afterRender: function(){
  6472. Ext.ux.grid.RowEditor.superclass.afterRender.apply(this, arguments);
  6473. this.positionButtons();
  6474. if(this.monitorValid){
  6475. this.startMonitoring();
  6476. }
  6477. },
  6478. onShow: function(){
  6479. if(this.monitorValid){
  6480. this.startMonitoring();
  6481. }
  6482. Ext.ux.grid.RowEditor.superclass.onShow.apply(this, arguments);
  6483. },
  6484. onHide: function(){
  6485. Ext.ux.grid.RowEditor.superclass.onHide.apply(this, arguments);
  6486. this.stopMonitoring();
  6487. this.grid.getView().focusRow(this.rowIndex);
  6488. },
  6489. positionButtons: function(){
  6490. if(this.btns){
  6491. var g = this.grid,
  6492. h = this.el.dom.clientHeight,
  6493. view = g.getView(),
  6494. scroll = view.scroller.dom.scrollLeft,
  6495. bw = this.btns.getWidth(),
  6496. width = Math.min(g.getWidth(), g.getColumnModel().getTotalWidth());
  6497. this.btns.el.shift({left: (width/2)-(bw/2)+scroll, top: h - 2, stopFx: true, duration:0.2});
  6498. }
  6499. },
  6500. // private
  6501. preEditValue : function(r, field){
  6502. var value = r.data[field];
  6503. return this.autoEncode && typeof value === 'string' ? Ext.util.Format.htmlDecode(value) : value;
  6504. },
  6505. // private
  6506. postEditValue : function(value, originalValue, r, field){
  6507. return this.autoEncode && typeof value == 'string' ? Ext.util.Format.htmlEncode(value) : value;
  6508. },
  6509. doFocus: function(pt){
  6510. if(this.isVisible()){
  6511. var index = 0,
  6512. cm = this.grid.getColumnModel(),
  6513. c;
  6514. if(pt){
  6515. index = this.getTargetColumnIndex(pt);
  6516. }
  6517. for(var i = index||0, len = cm.getColumnCount(); i < len; i++){
  6518. c = cm.getColumnAt(i);
  6519. if(!c.hidden && c.getEditor()){
  6520. c.getEditor().focus();
  6521. break;
  6522. }
  6523. }
  6524. }
  6525. },
  6526. getTargetColumnIndex: function(pt){
  6527. var grid = this.grid,
  6528. v = grid.view,
  6529. x = pt.left,
  6530. cms = grid.colModel.config,
  6531. i = 0,
  6532. match = false;
  6533. for(var len = cms.length, c; c = cms[i]; i++){
  6534. if(!c.hidden){
  6535. if(Ext.fly(v.getHeaderCell(i)).getRegion().right >= x){
  6536. match = i;
  6537. break;
  6538. }
  6539. }
  6540. }
  6541. return match;
  6542. },
  6543. startMonitoring : function(){
  6544. if(!this.bound && this.monitorValid){
  6545. this.bound = true;
  6546. Ext.TaskMgr.start({
  6547. run : this.bindHandler,
  6548. interval : this.monitorPoll || 200,
  6549. scope: this
  6550. });
  6551. }
  6552. },
  6553. stopMonitoring : function(){
  6554. this.bound = false;
  6555. if(this.tooltip){
  6556. this.tooltip.hide();
  6557. }
  6558. },
  6559. isValid: function(){
  6560. var valid = true;
  6561. this.items.each(function(f){
  6562. if(!f.isValid(true)){
  6563. valid = false;
  6564. return false;
  6565. }
  6566. });
  6567. return valid;
  6568. },
  6569. // private
  6570. bindHandler : function(){
  6571. if(!this.bound){
  6572. return false; // stops binding
  6573. }
  6574. var valid = this.isValid();
  6575. if(!valid && this.errorSummary){
  6576. this.showTooltip(this.getErrorText().join(''));
  6577. }
  6578. this.btns.saveBtn.setDisabled(!valid);
  6579. this.fireEvent('validation', this, valid);
  6580. },
  6581. lastVisibleColumn : function() {
  6582. var i = this.items.getCount() - 1,
  6583. c;
  6584. for(; i >= 0; i--) {
  6585. c = this.items.items[i];
  6586. if (!c.hidden) {
  6587. return c;
  6588. }
  6589. }
  6590. },
  6591. showTooltip: function(msg){
  6592. var t = this.tooltip;
  6593. if(!t){
  6594. t = this.tooltip = new Ext.ToolTip({
  6595. maxWidth: 600,
  6596. cls: 'errorTip',
  6597. width: 300,
  6598. title: this.errorText,
  6599. autoHide: false,
  6600. anchor: 'left',
  6601. anchorToTarget: true,
  6602. mouseOffset: [40,0]
  6603. });
  6604. }
  6605. var v = this.grid.getView(),
  6606. top = parseInt(this.el.dom.style.top, 10),
  6607. scroll = v.scroller.dom.scrollTop,
  6608. h = this.el.getHeight();
  6609. if(top + h >= scroll){
  6610. t.initTarget(this.lastVisibleColumn().getEl());
  6611. if(!t.rendered){
  6612. t.show();
  6613. t.hide();
  6614. }
  6615. t.body.update(msg);
  6616. t.doAutoWidth(20);
  6617. t.show();
  6618. }else if(t.rendered){
  6619. t.hide();
  6620. }
  6621. },
  6622. getErrorText: function(){
  6623. var data = ['<ul>'];
  6624. this.items.each(function(f){
  6625. if(!f.isValid(true)){
  6626. data.push('<li>', f.getActiveError(), '</li>');
  6627. }
  6628. });
  6629. data.push('</ul>');
  6630. return data;
  6631. }
  6632. });
  6633. Ext.preg('roweditor', Ext.ux.grid.RowEditor);
  6634. Ext.ns('Ext.ux.grid');
  6635. /**
  6636. * @class Ext.ux.grid.RowExpander
  6637. * @extends Ext.util.Observable
  6638. * Plugin (ptype = 'rowexpander') that adds the ability to have a Column in a grid which enables
  6639. * a second row body which expands/contracts. The expand/contract behavior is configurable to react
  6640. * on clicking of the column, double click of the row, and/or hitting enter while a row is selected.
  6641. *
  6642. * @ptype rowexpander
  6643. */
  6644. Ext.ux.grid.RowExpander = Ext.extend(Ext.util.Observable, {
  6645. <div id="cfg-Ext.ux.grid.RowExpander-expandOnEnter"></div>/**
  6646. * @cfg {Boolean} expandOnEnter
  6647. * <tt>true</tt> to toggle selected row(s) between expanded/collapsed when the enter
  6648. * key is pressed (defaults to <tt>true</tt>).
  6649. */
  6650. expandOnEnter : true,
  6651. <div id="cfg-Ext.ux.grid.RowExpander-expandOnDblClick"></div>/**
  6652. * @cfg {Boolean} expandOnDblClick
  6653. * <tt>true</tt> to toggle a row between expanded/collapsed when double clicked
  6654. * (defaults to <tt>true</tt>).
  6655. */
  6656. expandOnDblClick : true,
  6657. header : '',
  6658. width : 20,
  6659. sortable : false,
  6660. fixed : true,
  6661. hideable: false,
  6662. menuDisabled : true,
  6663. dataIndex : '',
  6664. id : 'expander',
  6665. lazyRender : true,
  6666. enableCaching : true,
  6667. constructor: function(config){
  6668. Ext.apply(this, config);
  6669. this.addEvents({
  6670. <div id="event-Ext.ux.grid.RowExpander-beforeexpand"></div>/**
  6671. * @event beforeexpand
  6672. * Fires before the row expands. Have the listener return false to prevent the row from expanding.
  6673. * @param {Object} this RowExpander object.
  6674. * @param {Object} Ext.data.Record Record for the selected row.
  6675. * @param {Object} body body element for the secondary row.
  6676. * @param {Number} rowIndex The current row index.
  6677. */
  6678. beforeexpand: true,
  6679. <div id="event-Ext.ux.grid.RowExpander-expand"></div>/**
  6680. * @event expand
  6681. * Fires after the row expands.
  6682. * @param {Object} this RowExpander object.
  6683. * @param {Object} Ext.data.Record Record for the selected row.
  6684. * @param {Object} body body element for the secondary row.
  6685. * @param {Number} rowIndex The current row index.
  6686. */
  6687. expand: true,
  6688. <div id="event-Ext.ux.grid.RowExpander-beforecollapse"></div>/**
  6689. * @event beforecollapse
  6690. * Fires before the row collapses. Have the listener return false to prevent the row from collapsing.
  6691. * @param {Object} this RowExpander object.
  6692. * @param {Object} Ext.data.Record Record for the selected row.
  6693. * @param {Object} body body element for the secondary row.
  6694. * @param {Number} rowIndex The current row index.
  6695. */
  6696. beforecollapse: true,
  6697. <div id="event-Ext.ux.grid.RowExpander-collapse"></div>/**
  6698. * @event collapse
  6699. * Fires after the row collapses.
  6700. * @param {Object} this RowExpander object.
  6701. * @param {Object} Ext.data.Record Record for the selected row.
  6702. * @param {Object} body body element for the secondary row.
  6703. * @param {Number} rowIndex The current row index.
  6704. */
  6705. collapse: true
  6706. });
  6707. Ext.ux.grid.RowExpander.superclass.constructor.call(this);
  6708. if(this.tpl){
  6709. if(typeof this.tpl == 'string'){
  6710. this.tpl = new Ext.Template(this.tpl);
  6711. }
  6712. this.tpl.compile();
  6713. }
  6714. this.state = {};
  6715. this.bodyContent = {};
  6716. },
  6717. getRowClass : function(record, rowIndex, p, ds){
  6718. p.cols = p.cols-1;
  6719. var content = this.bodyContent[record.id];
  6720. if(!content && !this.lazyRender){
  6721. content = this.getBodyContent(record, rowIndex);
  6722. }
  6723. if(content){
  6724. p.body = content;
  6725. }
  6726. return this.state[record.id] ? 'x-grid3-row-expanded' : 'x-grid3-row-collapsed';
  6727. },
  6728. init : function(grid){
  6729. this.grid = grid;
  6730. var view = grid.getView();
  6731. view.getRowClass = this.getRowClass.createDelegate(this);
  6732. view.enableRowBody = true;
  6733. grid.on('render', this.onRender, this);
  6734. grid.on('destroy', this.onDestroy, this);
  6735. },
  6736. // @private
  6737. onRender: function() {
  6738. var grid = this.grid;
  6739. var mainBody = grid.getView().mainBody;
  6740. mainBody.on('mousedown', this.onMouseDown, this, {delegate: '.x-grid3-row-expander'});
  6741. if (this.expandOnEnter) {
  6742. this.keyNav = new Ext.KeyNav(this.grid.getGridEl(), {
  6743. 'enter' : this.onEnter,
  6744. scope: this
  6745. });
  6746. }
  6747. if (this.expandOnDblClick) {
  6748. grid.on('rowdblclick', this.onRowDblClick, this);
  6749. }
  6750. },
  6751. // @private
  6752. onDestroy: function() {
  6753. if(this.keyNav){
  6754. this.keyNav.disable();
  6755. delete this.keyNav;
  6756. }
  6757. /*
  6758. * A majority of the time, the plugin will be destroyed along with the grid,
  6759. * which means the mainBody won't be available. On the off chance that the plugin
  6760. * isn't destroyed with the grid, take care of removing the listener.
  6761. */
  6762. var mainBody = this.grid.getView().mainBody;
  6763. if(mainBody){
  6764. mainBody.un('mousedown', this.onMouseDown, this);
  6765. }
  6766. },
  6767. // @private
  6768. onRowDblClick: function(grid, rowIdx, e) {
  6769. this.toggleRow(rowIdx);
  6770. },
  6771. onEnter: function(e) {
  6772. var g = this.grid;
  6773. var sm = g.getSelectionModel();
  6774. var sels = sm.getSelections();
  6775. for (var i = 0, len = sels.length; i < len; i++) {
  6776. var rowIdx = g.getStore().indexOf(sels[i]);
  6777. this.toggleRow(rowIdx);
  6778. }
  6779. },
  6780. getBodyContent : function(record, index){
  6781. if(!this.enableCaching){
  6782. return this.tpl.apply(record.data);
  6783. }
  6784. var content = this.bodyContent[record.id];
  6785. if(!content){
  6786. content = this.tpl.apply(record.data);
  6787. this.bodyContent[record.id] = content;
  6788. }
  6789. return content;
  6790. },
  6791. onMouseDown : function(e, t){
  6792. e.stopEvent();
  6793. var row = e.getTarget('.x-grid3-row');
  6794. this.toggleRow(row);
  6795. },
  6796. renderer : function(v, p, record){
  6797. p.cellAttr = 'rowspan="2"';
  6798. return '<div class="x-grid3-row-expander">&#160;</div>';
  6799. },
  6800. beforeExpand : function(record, body, rowIndex){
  6801. if(this.fireEvent('beforeexpand', this, record, body, rowIndex) !== false){
  6802. if(this.tpl && this.lazyRender){
  6803. body.innerHTML = this.getBodyContent(record, rowIndex);
  6804. }
  6805. return true;
  6806. }else{
  6807. return false;
  6808. }
  6809. },
  6810. toggleRow : function(row){
  6811. if(typeof row == 'number'){
  6812. row = this.grid.view.getRow(row);
  6813. }
  6814. this[Ext.fly(row).hasClass('x-grid3-row-collapsed') ? 'expandRow' : 'collapseRow'](row);
  6815. },
  6816. expandRow : function(row){
  6817. if(typeof row == 'number'){
  6818. row = this.grid.view.getRow(row);
  6819. }
  6820. var record = this.grid.store.getAt(row.rowIndex);
  6821. var body = Ext.DomQuery.selectNode('tr:nth(2) div.x-grid3-row-body', row);
  6822. if(this.beforeExpand(record, body, row.rowIndex)){
  6823. this.state[record.id] = true;
  6824. Ext.fly(row).replaceClass('x-grid3-row-collapsed', 'x-grid3-row-expanded');
  6825. this.fireEvent('expand', this, record, body, row.rowIndex);
  6826. }
  6827. },
  6828. collapseRow : function(row){
  6829. if(typeof row == 'number'){
  6830. row = this.grid.view.getRow(row);
  6831. }
  6832. var record = this.grid.store.getAt(row.rowIndex);
  6833. var body = Ext.fly(row).child('tr:nth(1) div.x-grid3-row-body', true);
  6834. if(this.fireEvent('beforecollapse', this, record, body, row.rowIndex) !== false){
  6835. this.state[record.id] = false;
  6836. Ext.fly(row).replaceClass('x-grid3-row-expanded', 'x-grid3-row-collapsed');
  6837. this.fireEvent('collapse', this, record, body, row.rowIndex);
  6838. }
  6839. }
  6840. });
  6841. Ext.preg('rowexpander', Ext.ux.grid.RowExpander);
  6842. //backwards compat
  6843. Ext.grid.RowExpander = Ext.ux.grid.RowExpander;// We are adding these custom layouts to a namespace that does not
  6844. // exist by default in Ext, so we have to add the namespace first:
  6845. Ext.ns('Ext.ux.layout');
  6846. <div id="cls-Ext.ux.layout.RowLayout"></div>/**
  6847. * @class Ext.ux.layout.RowLayout
  6848. * @extends Ext.layout.ContainerLayout
  6849. * <p>This is the layout style of choice for creating structural layouts in a multi-row format where the height of
  6850. * each row can be specified as a percentage or fixed height. Row widths can also be fixed, percentage or auto.
  6851. * This class is intended to be extended or created via the layout:'ux.row' {@link Ext.Container#layout} config,
  6852. * and should generally not need to be created directly via the new keyword.</p>
  6853. * <p>RowLayout does not have any direct config options (other than inherited ones), but it does support a
  6854. * specific config property of <b><tt>rowHeight</tt></b> that can be included in the config of any panel added to it. The
  6855. * layout will use the rowHeight (if present) or height of each panel during layout to determine how to size each panel.
  6856. * If height or rowHeight is not specified for a given panel, its height will default to the panel's height (or auto).</p>
  6857. * <p>The height property is always evaluated as pixels, and must be a number greater than or equal to 1.
  6858. * The rowHeight property is always evaluated as a percentage, and must be a decimal value greater than 0 and
  6859. * less than 1 (e.g., .25).</p>
  6860. * <p>The basic rules for specifying row heights are pretty simple. The logic makes two passes through the
  6861. * set of contained panels. During the first layout pass, all panels that either have a fixed height or none
  6862. * specified (auto) are skipped, but their heights are subtracted from the overall container height. During the second
  6863. * pass, all panels with rowHeights are assigned pixel heights in proportion to their percentages based on
  6864. * the total <b>remaining</b> container height. In other words, percentage height panels are designed to fill the space
  6865. * left over by all the fixed-height and/or auto-height panels. Because of this, while you can specify any number of rows
  6866. * with different percentages, the rowHeights must always add up to 1 (or 100%) when added together, otherwise your
  6867. * layout may not render as expected. Example usage:</p>
  6868. * <pre><code>
  6869. // All rows are percentages -- they must add up to 1
  6870. var p = new Ext.Panel({
  6871. title: 'Row Layout - Percentage Only',
  6872. layout:'ux.row',
  6873. items: [{
  6874. title: 'Row 1',
  6875. rowHeight: .25
  6876. },{
  6877. title: 'Row 2',
  6878. rowHeight: .6
  6879. },{
  6880. title: 'Row 3',
  6881. rowHeight: .15
  6882. }]
  6883. });
  6884. // Mix of height and rowHeight -- all rowHeight values must add
  6885. // up to 1. The first row will take up exactly 120px, and the last two
  6886. // rows will fill the remaining container height.
  6887. var p = new Ext.Panel({
  6888. title: 'Row Layout - Mixed',
  6889. layout:'ux.row',
  6890. items: [{
  6891. title: 'Row 1',
  6892. height: 120,
  6893. // standard panel widths are still supported too:
  6894. width: '50%' // or 200
  6895. },{
  6896. title: 'Row 2',
  6897. rowHeight: .8,
  6898. width: 300
  6899. },{
  6900. title: 'Row 3',
  6901. rowHeight: .2
  6902. }]
  6903. });
  6904. </code></pre>
  6905. */
  6906. Ext.ux.layout.RowLayout = Ext.extend(Ext.layout.ContainerLayout, {
  6907. // private
  6908. monitorResize:true,
  6909. type: 'row',
  6910. // private
  6911. allowContainerRemove: false,
  6912. // private
  6913. isValidParent : function(c, target){
  6914. return this.innerCt && c.getPositionEl().dom.parentNode == this.innerCt.dom;
  6915. },
  6916. getLayoutTargetSize : function() {
  6917. var target = this.container.getLayoutTarget(), ret;
  6918. if (target) {
  6919. ret = target.getViewSize();
  6920. // IE in strict mode will return a height of 0 on the 1st pass of getViewSize.
  6921. // Use getStyleSize to verify the 0 height, the adjustment pass will then work properly
  6922. // with getViewSize
  6923. if (Ext.isIE && Ext.isStrict && ret.height == 0){
  6924. ret = target.getStyleSize();
  6925. }
  6926. ret.width -= target.getPadding('lr');
  6927. ret.height -= target.getPadding('tb');
  6928. }
  6929. return ret;
  6930. },
  6931. renderAll : function(ct, target) {
  6932. if(!this.innerCt){
  6933. // the innerCt prevents wrapping and shuffling while
  6934. // the container is resizing
  6935. this.innerCt = target.createChild({cls:'x-column-inner'});
  6936. this.innerCt.createChild({cls:'x-clear'});
  6937. }
  6938. Ext.layout.ColumnLayout.superclass.renderAll.call(this, ct, this.innerCt);
  6939. },
  6940. // private
  6941. onLayout : function(ct, target){
  6942. var rs = ct.items.items,
  6943. len = rs.length,
  6944. r,
  6945. m,
  6946. i,
  6947. margins = [];
  6948. this.renderAll(ct, target);
  6949. var size = this.getLayoutTargetSize();
  6950. if(size.width < 1 && size.height < 1){ // display none?
  6951. return;
  6952. }
  6953. var h = size.height,
  6954. ph = h;
  6955. this.innerCt.setSize({height:h});
  6956. // some rows can be percentages while others are fixed
  6957. // so we need to make 2 passes
  6958. for(i = 0; i < len; i++){
  6959. r = rs[i];
  6960. m = r.getPositionEl().getMargins('tb');
  6961. margins[i] = m;
  6962. if(!r.rowHeight){
  6963. ph -= (r.getHeight() + m);
  6964. }
  6965. }
  6966. ph = ph < 0 ? 0 : ph;
  6967. for(i = 0; i < len; i++){
  6968. r = rs[i];
  6969. m = margins[i];
  6970. if(r.rowHeight){
  6971. r.setSize({height: Math.floor(r.rowHeight*ph) - m});
  6972. }
  6973. }
  6974. // Browsers differ as to when they account for scrollbars. We need to re-measure to see if the scrollbar
  6975. // spaces were accounted for properly. If not, re-layout.
  6976. if (Ext.isIE) {
  6977. if (i = target.getStyle('overflow') && i != 'hidden' && !this.adjustmentPass) {
  6978. var ts = this.getLayoutTargetSize();
  6979. if (ts.width != size.width){
  6980. this.adjustmentPass = true;
  6981. this.onLayout(ct, target);
  6982. }
  6983. }
  6984. }
  6985. delete this.adjustmentPass;
  6986. }
  6987. <div id="prop-Ext.ux.layout.RowLayout-activeItem"></div>/**
  6988. * @property activeItem
  6989. * @hide
  6990. */
  6991. });
  6992. Ext.Container.LAYOUTS['ux.row'] = Ext.ux.layout.RowLayout;
  6993. Ext.ns('Ext.ux.form');
  6994. Ext.ux.form.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
  6995. initComponent : function(){
  6996. Ext.ux.form.SearchField.superclass.initComponent.call(this);
  6997. this.on('specialkey', function(f, e){
  6998. if(e.getKey() == e.ENTER){
  6999. this.onTrigger2Click();
  7000. }
  7001. }, this);
  7002. },
  7003. validationEvent:false,
  7004. validateOnBlur:false,
  7005. trigger1Class:'x-form-clear-trigger',
  7006. trigger2Class:'x-form-search-trigger',
  7007. hideTrigger1:true,
  7008. width:180,
  7009. hasSearch : false,
  7010. paramName : 'query',
  7011. onTrigger1Click : function(){
  7012. if(this.hasSearch){
  7013. this.el.dom.value = '';
  7014. var o = {start: 0};
  7015. this.store.baseParams = this.store.baseParams || {};
  7016. this.store.baseParams[this.paramName] = '';
  7017. this.store.reload({params:o});
  7018. this.triggers[0].hide();
  7019. this.hasSearch = false;
  7020. }
  7021. },
  7022. onTrigger2Click : function(){
  7023. var v = this.getRawValue();
  7024. if(v.length < 1){
  7025. this.onTrigger1Click();
  7026. return;
  7027. }
  7028. var o = {start: 0};
  7029. this.store.baseParams = this.store.baseParams || {};
  7030. this.store.baseParams[this.paramName] = v;
  7031. this.store.reload({params:o});
  7032. this.hasSearch = true;
  7033. this.triggers[0].show();
  7034. }
  7035. });Ext.ns('Ext.ux.form');
  7036. /**
  7037. * @class Ext.ux.form.SelectBox
  7038. * @extends Ext.form.ComboBox
  7039. * <p>Makes a ComboBox more closely mimic an HTML SELECT. Supports clicking and dragging
  7040. * through the list, with item selection occurring when the mouse button is released.
  7041. * When used will automatically set {@link #editable} to false and call {@link Ext.Element#unselectable}
  7042. * on inner elements. Re-enabling editable after calling this will NOT work.</p>
  7043. * @author Corey Gilmore http://extjs.com/forum/showthread.php?t=6392
  7044. * @history 2007-07-08 jvs
  7045. * Slight mods for Ext 2.0
  7046. * @xtype selectbox
  7047. */
  7048. Ext.ux.form.SelectBox = Ext.extend(Ext.form.ComboBox, {
  7049. constructor: function(config){
  7050. this.searchResetDelay = 1000;
  7051. config = config || {};
  7052. config = Ext.apply(config || {}, {
  7053. editable: false,
  7054. forceSelection: true,
  7055. rowHeight: false,
  7056. lastSearchTerm: false,
  7057. triggerAction: 'all',
  7058. mode: 'local'
  7059. });
  7060. Ext.ux.form.SelectBox.superclass.constructor.apply(this, arguments);
  7061. this.lastSelectedIndex = this.selectedIndex || 0;
  7062. },
  7063. initEvents : function(){
  7064. Ext.ux.form.SelectBox.superclass.initEvents.apply(this, arguments);
  7065. // you need to use keypress to capture upper/lower case and shift+key, but it doesn't work in IE
  7066. this.el.on('keydown', this.keySearch, this, true);
  7067. this.cshTask = new Ext.util.DelayedTask(this.clearSearchHistory, this);
  7068. },
  7069. keySearch : function(e, target, options) {
  7070. var raw = e.getKey();
  7071. var key = String.fromCharCode(raw);
  7072. var startIndex = 0;
  7073. if( !this.store.getCount() ) {
  7074. return;
  7075. }
  7076. switch(raw) {
  7077. case Ext.EventObject.HOME:
  7078. e.stopEvent();
  7079. this.selectFirst();
  7080. return;
  7081. case Ext.EventObject.END:
  7082. e.stopEvent();
  7083. this.selectLast();
  7084. return;
  7085. case Ext.EventObject.PAGEDOWN:
  7086. this.selectNextPage();
  7087. e.stopEvent();
  7088. return;
  7089. case Ext.EventObject.PAGEUP:
  7090. this.selectPrevPage();
  7091. e.stopEvent();
  7092. return;
  7093. }
  7094. // skip special keys other than the shift key
  7095. if( (e.hasModifier() && !e.shiftKey) || e.isNavKeyPress() || e.isSpecialKey() ) {
  7096. return;
  7097. }
  7098. if( this.lastSearchTerm == key ) {
  7099. startIndex = this.lastSelectedIndex;
  7100. }
  7101. this.search(this.displayField, key, startIndex);
  7102. this.cshTask.delay(this.searchResetDelay);
  7103. },
  7104. onRender : function(ct, position) {
  7105. this.store.on('load', this.calcRowsPerPage, this);
  7106. Ext.ux.form.SelectBox.superclass.onRender.apply(this, arguments);
  7107. if( this.mode == 'local' ) {
  7108. this.initList();
  7109. this.calcRowsPerPage();
  7110. }
  7111. },
  7112. onSelect : function(record, index, skipCollapse){
  7113. if(this.fireEvent('beforeselect', this, record, index) !== false){
  7114. this.setValue(record.data[this.valueField || this.displayField]);
  7115. if( !skipCollapse ) {
  7116. this.collapse();
  7117. }
  7118. this.lastSelectedIndex = index + 1;
  7119. this.fireEvent('select', this, record, index);
  7120. }
  7121. },
  7122. afterRender : function() {
  7123. Ext.ux.form.SelectBox.superclass.afterRender.apply(this, arguments);
  7124. if(Ext.isWebKit) {
  7125. this.el.swallowEvent('mousedown', true);
  7126. }
  7127. this.el.unselectable();
  7128. this.innerList.unselectable();
  7129. this.trigger.unselectable();
  7130. this.innerList.on('mouseup', function(e, target, options) {
  7131. if( target.id && target.id == this.innerList.id ) {
  7132. return;
  7133. }
  7134. this.onViewClick();
  7135. }, this);
  7136. this.innerList.on('mouseover', function(e, target, options) {
  7137. if( target.id && target.id == this.innerList.id ) {
  7138. return;
  7139. }
  7140. this.lastSelectedIndex = this.view.getSelectedIndexes()[0] + 1;
  7141. this.cshTask.delay(this.searchResetDelay);
  7142. }, this);
  7143. this.trigger.un('click', this.onTriggerClick, this);
  7144. this.trigger.on('mousedown', function(e, target, options) {
  7145. e.preventDefault();
  7146. this.onTriggerClick();
  7147. }, this);
  7148. this.on('collapse', function(e, target, options) {
  7149. Ext.getDoc().un('mouseup', this.collapseIf, this);
  7150. }, this, true);
  7151. this.on('expand', function(e, target, options) {
  7152. Ext.getDoc().on('mouseup', this.collapseIf, this);
  7153. }, this, true);
  7154. },
  7155. clearSearchHistory : function() {
  7156. this.lastSelectedIndex = 0;
  7157. this.lastSearchTerm = false;
  7158. },
  7159. selectFirst : function() {
  7160. this.focusAndSelect(this.store.data.first());
  7161. },
  7162. selectLast : function() {
  7163. this.focusAndSelect(this.store.data.last());
  7164. },
  7165. selectPrevPage : function() {
  7166. if( !this.rowHeight ) {
  7167. return;
  7168. }
  7169. var index = Math.max(this.selectedIndex-this.rowsPerPage, 0);
  7170. this.focusAndSelect(this.store.getAt(index));
  7171. },
  7172. selectNextPage : function() {
  7173. if( !this.rowHeight ) {
  7174. return;
  7175. }
  7176. var index = Math.min(this.selectedIndex+this.rowsPerPage, this.store.getCount() - 1);
  7177. this.focusAndSelect(this.store.getAt(index));
  7178. },
  7179. search : function(field, value, startIndex) {
  7180. field = field || this.displayField;
  7181. this.lastSearchTerm = value;
  7182. var index = this.store.find.apply(this.store, arguments);
  7183. if( index !== -1 ) {
  7184. this.focusAndSelect(index);
  7185. }
  7186. },
  7187. focusAndSelect : function(record) {
  7188. var index = Ext.isNumber(record) ? record : this.store.indexOf(record);
  7189. this.select(index, this.isExpanded());
  7190. this.onSelect(this.store.getAt(index), index, this.isExpanded());
  7191. },
  7192. calcRowsPerPage : function() {
  7193. if( this.store.getCount() ) {
  7194. this.rowHeight = Ext.fly(this.view.getNode(0)).getHeight();
  7195. this.rowsPerPage = this.maxHeight / this.rowHeight;
  7196. } else {
  7197. this.rowHeight = false;
  7198. }
  7199. }
  7200. });
  7201. Ext.reg('selectbox', Ext.ux.form.SelectBox);
  7202. //backwards compat
  7203. Ext.ux.SelectBox = Ext.ux.form.SelectBox;
  7204. <div id="prop-Ext.ux.form.SelectBox-SlidingPager"></div>/**
  7205. * Plugin for PagingToolbar which replaces the textfield input with a slider
  7206. */
  7207. Ext.ux.SlidingPager = Ext.extend(Object, {
  7208. init : function(pbar){
  7209. var idx = pbar.items.indexOf(pbar.inputItem);
  7210. Ext.each(pbar.items.getRange(idx - 2, idx + 2), function(c){
  7211. c.hide();
  7212. });
  7213. var slider = new Ext.Slider({
  7214. width: 114,
  7215. minValue: 1,
  7216. maxValue: 1,
  7217. plugins: new Ext.slider.Tip({
  7218. getText : function(thumb) {
  7219. return String.format('Page <b>{0}</b> of <b>{1}</b>', thumb.value, thumb.slider.maxValue);
  7220. }
  7221. }),
  7222. listeners: {
  7223. changecomplete: function(s, v){
  7224. pbar.changePage(v);
  7225. }
  7226. }
  7227. });
  7228. pbar.insert(idx + 1, slider);
  7229. pbar.on({
  7230. change: function(pb, data){
  7231. slider.setMaxValue(data.pages);
  7232. slider.setValue(data.activePage);
  7233. }
  7234. });
  7235. }
  7236. });Ext.ns('Ext.ux.form');
  7237. /**
  7238. * @class Ext.ux.form.SpinnerField
  7239. * @extends Ext.form.NumberField
  7240. * Creates a field utilizing Ext.ux.Spinner
  7241. * @xtype spinnerfield
  7242. */
  7243. Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {
  7244. actionMode: 'wrap',
  7245. deferHeight: true,
  7246. autoSize: Ext.emptyFn,
  7247. onBlur: Ext.emptyFn,
  7248. adjustSize: Ext.BoxComponent.prototype.adjustSize,
  7249. constructor: function(config) {
  7250. var spinnerConfig = Ext.copyTo({}, config, 'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass');
  7251. var spl = this.spinner = new Ext.ux.Spinner(spinnerConfig);
  7252. var plugins = config.plugins
  7253. ? (Ext.isArray(config.plugins)
  7254. ? config.plugins.push(spl)
  7255. : [config.plugins, spl])
  7256. : spl;
  7257. Ext.ux.form.SpinnerField.superclass.constructor.call(this, Ext.apply(config, {plugins: plugins}));
  7258. },
  7259. // private
  7260. getResizeEl: function(){
  7261. return this.wrap;
  7262. },
  7263. // private
  7264. getPositionEl: function(){
  7265. return this.wrap;
  7266. },
  7267. // private
  7268. alignErrorIcon: function(){
  7269. if (this.wrap) {
  7270. this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
  7271. }
  7272. },
  7273. validateBlur: function(){
  7274. return true;
  7275. }
  7276. });
  7277. Ext.reg('spinnerfield', Ext.ux.form.SpinnerField);
  7278. //backwards compat
  7279. Ext.form.SpinnerField = Ext.ux.form.SpinnerField;
  7280. /**
  7281. * @class Ext.ux.Spinner
  7282. * @extends Ext.util.Observable
  7283. * Creates a Spinner control utilized by Ext.ux.form.SpinnerField
  7284. */
  7285. Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
  7286. incrementValue: 1,
  7287. alternateIncrementValue: 5,
  7288. triggerClass: 'x-form-spinner-trigger',
  7289. splitterClass: 'x-form-spinner-splitter',
  7290. alternateKey: Ext.EventObject.shiftKey,
  7291. defaultValue: 0,
  7292. accelerate: false,
  7293. constructor: function(config){
  7294. Ext.ux.Spinner.superclass.constructor.call(this, config);
  7295. Ext.apply(this, config);
  7296. this.mimicing = false;
  7297. },
  7298. init: function(field){
  7299. this.field = field;
  7300. field.afterMethod('onRender', this.doRender, this);
  7301. field.afterMethod('onEnable', this.doEnable, this);
  7302. field.afterMethod('onDisable', this.doDisable, this);
  7303. field.afterMethod('afterRender', this.doAfterRender, this);
  7304. field.afterMethod('onResize', this.doResize, this);
  7305. field.afterMethod('onFocus', this.doFocus, this);
  7306. field.beforeMethod('onDestroy', this.doDestroy, this);
  7307. },
  7308. doRender: function(ct, position){
  7309. var el = this.el = this.field.getEl();
  7310. var f = this.field;
  7311. if (!f.wrap) {
  7312. f.wrap = this.wrap = el.wrap({
  7313. cls: "x-form-field-wrap"
  7314. });
  7315. }
  7316. else {
  7317. this.wrap = f.wrap.addClass('x-form-field-wrap');
  7318. }
  7319. this.trigger = this.wrap.createChild({
  7320. tag: "img",
  7321. src: Ext.BLANK_IMAGE_URL,
  7322. cls: "x-form-trigger " + this.triggerClass
  7323. });
  7324. if (!f.width) {
  7325. this.wrap.setWidth(el.getWidth() + this.trigger.getWidth());
  7326. }
  7327. this.splitter = this.wrap.createChild({
  7328. tag: 'div',
  7329. cls: this.splitterClass,
  7330. style: 'width:13px; height:2px;'
  7331. });
  7332. this.splitter.setRight((Ext.isIE) ? 1 : 2).setTop(10).show();
  7333. this.proxy = this.trigger.createProxy('', this.splitter, true);
  7334. this.proxy.addClass("x-form-spinner-proxy");
  7335. this.proxy.setStyle('left', '0px');
  7336. this.proxy.setSize(14, 1);
  7337. this.proxy.hide();
  7338. this.dd = new Ext.dd.DDProxy(this.splitter.dom.id, "SpinnerDrag", {
  7339. dragElId: this.proxy.id
  7340. });
  7341. this.initTrigger();
  7342. this.initSpinner();
  7343. },
  7344. doAfterRender: function(){
  7345. var y;
  7346. if (Ext.isIE && this.el.getY() != (y = this.trigger.getY())) {
  7347. this.el.position();
  7348. this.el.setY(y);
  7349. }
  7350. },
  7351. doEnable: function(){
  7352. if (this.wrap) {
  7353. this.disabled = false;
  7354. this.wrap.removeClass(this.field.disabledClass);
  7355. }
  7356. },
  7357. doDisable: function(){
  7358. if (this.wrap) {
  7359. this.disabled = true;
  7360. this.wrap.addClass(this.field.disabledClass);
  7361. this.el.removeClass(this.field.disabledClass);
  7362. }
  7363. },
  7364. doResize: function(w, h){
  7365. if (typeof w == 'number') {
  7366. this.el.setWidth(w - this.trigger.getWidth());
  7367. }
  7368. this.wrap.setWidth(this.el.getWidth() + this.trigger.getWidth());
  7369. },
  7370. doFocus: function(){
  7371. if (!this.mimicing) {
  7372. this.wrap.addClass('x-trigger-wrap-focus');
  7373. this.mimicing = true;
  7374. Ext.get(Ext.isIE ? document.body : document).on("mousedown", this.mimicBlur, this, {
  7375. delay: 10
  7376. });
  7377. this.el.on('keydown', this.checkTab, this);
  7378. }
  7379. },
  7380. // private
  7381. checkTab: function(e){
  7382. if (e.getKey() == e.TAB) {
  7383. this.triggerBlur();
  7384. }
  7385. },
  7386. // private
  7387. mimicBlur: function(e){
  7388. if (!this.wrap.contains(e.target) && this.field.validateBlur(e)) {
  7389. this.triggerBlur();
  7390. }
  7391. },
  7392. // private
  7393. triggerBlur: function(){
  7394. this.mimicing = false;
  7395. Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this);
  7396. this.el.un("keydown", this.checkTab, this);
  7397. this.field.beforeBlur();
  7398. this.wrap.removeClass('x-trigger-wrap-focus');
  7399. this.field.onBlur.call(this.field);
  7400. },
  7401. initTrigger: function(){
  7402. this.trigger.addClassOnOver('x-form-trigger-over');
  7403. this.trigger.addClassOnClick('x-form-trigger-click');
  7404. },
  7405. initSpinner: function(){
  7406. this.field.addEvents({
  7407. 'spin': true,
  7408. 'spinup': true,
  7409. 'spindown': true
  7410. });
  7411. this.keyNav = new Ext.KeyNav(this.el, {
  7412. "up": function(e){
  7413. e.preventDefault();
  7414. this.onSpinUp();
  7415. },
  7416. "down": function(e){
  7417. e.preventDefault();
  7418. this.onSpinDown();
  7419. },
  7420. "pageUp": function(e){
  7421. e.preventDefault();
  7422. this.onSpinUpAlternate();
  7423. },
  7424. "pageDown": function(e){
  7425. e.preventDefault();
  7426. this.onSpinDownAlternate();
  7427. },
  7428. scope: this
  7429. });
  7430. this.repeater = new Ext.util.ClickRepeater(this.trigger, {
  7431. accelerate: this.accelerate
  7432. });
  7433. this.field.mon(this.repeater, "click", this.onTriggerClick, this, {
  7434. preventDefault: true
  7435. });
  7436. this.field.mon(this.trigger, {
  7437. mouseover: this.onMouseOver,
  7438. mouseout: this.onMouseOut,
  7439. mousemove: this.onMouseMove,
  7440. mousedown: this.onMouseDown,
  7441. mouseup: this.onMouseUp,
  7442. scope: this,
  7443. preventDefault: true
  7444. });
  7445. this.field.mon(this.wrap, "mousewheel", this.handleMouseWheel, this);
  7446. this.dd.setXConstraint(0, 0, 10)
  7447. this.dd.setYConstraint(1500, 1500, 10);
  7448. this.dd.endDrag = this.endDrag.createDelegate(this);
  7449. this.dd.startDrag = this.startDrag.createDelegate(this);
  7450. this.dd.onDrag = this.onDrag.createDelegate(this);
  7451. },
  7452. onMouseOver: function(){
  7453. if (this.disabled) {
  7454. return;
  7455. }
  7456. var middle = this.getMiddle();
  7457. this.tmpHoverClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-overup' : 'x-form-spinner-overdown';
  7458. this.trigger.addClass(this.tmpHoverClass);
  7459. },
  7460. //private
  7461. onMouseOut: function(){
  7462. this.trigger.removeClass(this.tmpHoverClass);
  7463. },
  7464. //private
  7465. onMouseMove: function(){
  7466. if (this.disabled) {
  7467. return;
  7468. }
  7469. var middle = this.getMiddle();
  7470. if (((Ext.EventObject.getPageY() > middle) && this.tmpHoverClass == "x-form-spinner-overup") ||
  7471. ((Ext.EventObject.getPageY() < middle) && this.tmpHoverClass == "x-form-spinner-overdown")) {
  7472. }
  7473. },
  7474. //private
  7475. onMouseDown: function(){
  7476. if (this.disabled) {
  7477. return;
  7478. }
  7479. var middle = this.getMiddle();
  7480. this.tmpClickClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-clickup' : 'x-form-spinner-clickdown';
  7481. this.trigger.addClass(this.tmpClickClass);
  7482. },
  7483. //private
  7484. onMouseUp: function(){
  7485. this.trigger.removeClass(this.tmpClickClass);
  7486. },
  7487. //private
  7488. onTriggerClick: function(){
  7489. if (this.disabled || this.el.dom.readOnly) {
  7490. return;
  7491. }
  7492. var middle = this.getMiddle();
  7493. var ud = (Ext.EventObject.getPageY() < middle) ? 'Up' : 'Down';
  7494. this['onSpin' + ud]();
  7495. },
  7496. //private
  7497. getMiddle: function(){
  7498. var t = this.trigger.getTop();
  7499. var h = this.trigger.getHeight();
  7500. var middle = t + (h / 2);
  7501. return middle;
  7502. },
  7503. //private
  7504. //checks if control is allowed to spin
  7505. isSpinnable: function(){
  7506. if (this.disabled || this.el.dom.readOnly) {
  7507. Ext.EventObject.preventDefault(); //prevent scrolling when disabled/readonly
  7508. return false;
  7509. }
  7510. return true;
  7511. },
  7512. handleMouseWheel: function(e){
  7513. //disable scrolling when not focused
  7514. if (this.wrap.hasClass('x-trigger-wrap-focus') == false) {
  7515. return;
  7516. }
  7517. var delta = e.getWheelDelta();
  7518. if (delta > 0) {
  7519. this.onSpinUp();
  7520. e.stopEvent();
  7521. }
  7522. else
  7523. if (delta < 0) {
  7524. this.onSpinDown();
  7525. e.stopEvent();
  7526. }
  7527. },
  7528. //private
  7529. startDrag: function(){
  7530. this.proxy.show();
  7531. this._previousY = Ext.fly(this.dd.getDragEl()).getTop();
  7532. },
  7533. //private
  7534. endDrag: function(){
  7535. this.proxy.hide();
  7536. },
  7537. //private
  7538. onDrag: function(){
  7539. if (this.disabled) {
  7540. return;
  7541. }
  7542. var y = Ext.fly(this.dd.getDragEl()).getTop();
  7543. var ud = '';
  7544. if (this._previousY > y) {
  7545. ud = 'Up';
  7546. } //up
  7547. if (this._previousY < y) {
  7548. ud = 'Down';
  7549. } //down
  7550. if (ud != '') {
  7551. this['onSpin' + ud]();
  7552. }
  7553. this._previousY = y;
  7554. },
  7555. //private
  7556. onSpinUp: function(){
  7557. if (this.isSpinnable() == false) {
  7558. return;
  7559. }
  7560. if (Ext.EventObject.shiftKey == true) {
  7561. this.onSpinUpAlternate();
  7562. return;
  7563. }
  7564. else {
  7565. this.spin(false, false);
  7566. }
  7567. this.field.fireEvent("spin", this);
  7568. this.field.fireEvent("spinup", this);
  7569. },
  7570. //private
  7571. onSpinDown: function(){
  7572. if (this.isSpinnable() == false) {
  7573. return;
  7574. }
  7575. if (Ext.EventObject.shiftKey == true) {
  7576. this.onSpinDownAlternate();
  7577. return;
  7578. }
  7579. else {
  7580. this.spin(true, false);
  7581. }
  7582. this.field.fireEvent("spin", this);
  7583. this.field.fireEvent("spindown", this);
  7584. },
  7585. //private
  7586. onSpinUpAlternate: function(){
  7587. if (this.isSpinnable() == false) {
  7588. return;
  7589. }
  7590. this.spin(false, true);
  7591. this.field.fireEvent("spin", this);
  7592. this.field.fireEvent("spinup", this);
  7593. },
  7594. //private
  7595. onSpinDownAlternate: function(){
  7596. if (this.isSpinnable() == false) {
  7597. return;
  7598. }
  7599. this.spin(true, true);
  7600. this.field.fireEvent("spin", this);
  7601. this.field.fireEvent("spindown", this);
  7602. },
  7603. spin: function(down, alternate){
  7604. var v = parseFloat(this.field.getValue());
  7605. var incr = (alternate == true) ? this.alternateIncrementValue : this.incrementValue;
  7606. (down == true) ? v -= incr : v += incr;
  7607. v = (isNaN(v)) ? this.defaultValue : v;
  7608. v = this.fixBoundries(v);
  7609. this.field.setRawValue(v);
  7610. },
  7611. fixBoundries: function(value){
  7612. var v = value;
  7613. if (this.field.minValue != undefined && v < this.field.minValue) {
  7614. v = this.field.minValue;
  7615. }
  7616. if (this.field.maxValue != undefined && v > this.field.maxValue) {
  7617. v = this.field.maxValue;
  7618. }
  7619. return this.fixPrecision(v);
  7620. },
  7621. // private
  7622. fixPrecision: function(value){
  7623. var nan = isNaN(value);
  7624. if (!this.field.allowDecimals || this.field.decimalPrecision == -1 || nan || !value) {
  7625. return nan ? '' : value;
  7626. }
  7627. return parseFloat(parseFloat(value).toFixed(this.field.decimalPrecision));
  7628. },
  7629. doDestroy: function(){
  7630. if (this.trigger) {
  7631. this.trigger.remove();
  7632. }
  7633. if (this.wrap) {
  7634. this.wrap.remove();
  7635. delete this.field.wrap;
  7636. }
  7637. if (this.splitter) {
  7638. this.splitter.remove();
  7639. }
  7640. if (this.dd) {
  7641. this.dd.unreg();
  7642. this.dd = null;
  7643. }
  7644. if (this.proxy) {
  7645. this.proxy.remove();
  7646. }
  7647. if (this.repeater) {
  7648. this.repeater.purgeListeners();
  7649. }
  7650. if (this.mimicing){
  7651. Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this);
  7652. }
  7653. }
  7654. });
  7655. //backwards compat
  7656. Ext.form.Spinner = Ext.ux.Spinner;Ext.ux.Spotlight = function(config){
  7657. Ext.apply(this, config);
  7658. }
  7659. Ext.ux.Spotlight.prototype = {
  7660. active : false,
  7661. animate : true,
  7662. duration: .25,
  7663. easing:'easeNone',
  7664. // private
  7665. animated : false,
  7666. createElements : function(){
  7667. var bd = Ext.getBody();
  7668. this.right = bd.createChild({cls:'x-spotlight'});
  7669. this.left = bd.createChild({cls:'x-spotlight'});
  7670. this.top = bd.createChild({cls:'x-spotlight'});
  7671. this.bottom = bd.createChild({cls:'x-spotlight'});
  7672. this.all = new Ext.CompositeElement([this.right, this.left, this.top, this.bottom]);
  7673. },
  7674. show : function(el, callback, scope){
  7675. if(this.animated){
  7676. this.show.defer(50, this, [el, callback, scope]);
  7677. return;
  7678. }
  7679. this.el = Ext.get(el);
  7680. if(!this.right){
  7681. this.createElements();
  7682. }
  7683. if(!this.active){
  7684. this.all.setDisplayed('');
  7685. this.applyBounds(true, false);
  7686. this.active = true;
  7687. Ext.EventManager.onWindowResize(this.syncSize, this);
  7688. this.applyBounds(false, this.animate, false, callback, scope);
  7689. }else{
  7690. this.applyBounds(false, false, false, callback, scope); // all these booleans look hideous
  7691. }
  7692. },
  7693. hide : function(callback, scope){
  7694. if(this.animated){
  7695. this.hide.defer(50, this, [callback, scope]);
  7696. return;
  7697. }
  7698. Ext.EventManager.removeResizeListener(this.syncSize, this);
  7699. this.applyBounds(true, this.animate, true, callback, scope);
  7700. },
  7701. doHide : function(){
  7702. this.active = false;
  7703. this.all.setDisplayed(false);
  7704. },
  7705. syncSize : function(){
  7706. this.applyBounds(false, false);
  7707. },
  7708. applyBounds : function(basePts, anim, doHide, callback, scope){
  7709. var rg = this.el.getRegion();
  7710. var dw = Ext.lib.Dom.getViewWidth(true);
  7711. var dh = Ext.lib.Dom.getViewHeight(true);
  7712. var c = 0, cb = false;
  7713. if(anim){
  7714. cb = {
  7715. callback: function(){
  7716. c++;
  7717. if(c == 4){
  7718. this.animated = false;
  7719. if(doHide){
  7720. this.doHide();
  7721. }
  7722. Ext.callback(callback, scope, [this]);
  7723. }
  7724. },
  7725. scope: this,
  7726. duration: this.duration,
  7727. easing: this.easing
  7728. };
  7729. this.animated = true;
  7730. }
  7731. this.right.setBounds(
  7732. rg.right,
  7733. basePts ? dh : rg.top,
  7734. dw - rg.right,
  7735. basePts ? 0 : (dh - rg.top),
  7736. cb);
  7737. this.left.setBounds(
  7738. 0,
  7739. 0,
  7740. rg.left,
  7741. basePts ? 0 : rg.bottom,
  7742. cb);
  7743. this.top.setBounds(
  7744. basePts ? dw : rg.left,
  7745. 0,
  7746. basePts ? 0 : dw - rg.left,
  7747. rg.top,
  7748. cb);
  7749. this.bottom.setBounds(
  7750. 0,
  7751. rg.bottom,
  7752. basePts ? 0 : rg.right,
  7753. dh - rg.bottom,
  7754. cb);
  7755. if(!anim){
  7756. if(doHide){
  7757. this.doHide();
  7758. }
  7759. if(callback){
  7760. Ext.callback(callback, scope, [this]);
  7761. }
  7762. }
  7763. },
  7764. destroy : function(){
  7765. this.doHide();
  7766. Ext.destroy(
  7767. this.right,
  7768. this.left,
  7769. this.top,
  7770. this.bottom);
  7771. delete this.el;
  7772. delete this.all;
  7773. }
  7774. };
  7775. //backwards compat
  7776. Ext.Spotlight = Ext.ux.Spotlight;/**
  7777. * @class Ext.ux.StatusBar
  7778. * <p>Basic status bar component that can be used as the bottom toolbar of any {@link Ext.Panel}. In addition to
  7779. * supporting the standard {@link Ext.Toolbar} interface for adding buttons, menus and other items, the StatusBar
  7780. * provides a greedy status element that can be aligned to either side and has convenient methods for setting the
  7781. * status text and icon. You can also indicate that something is processing using the {@link #showBusy} method.</p>
  7782. * <pre><code>
  7783. new Ext.Panel({
  7784. title: 'StatusBar',
  7785. // etc.
  7786. bbar: new Ext.ux.StatusBar({
  7787. id: 'my-status',
  7788. // defaults to use when the status is cleared:
  7789. defaultText: 'Default status text',
  7790. defaultIconCls: 'default-icon',
  7791. // values to set initially:
  7792. text: 'Ready',
  7793. iconCls: 'ready-icon',
  7794. // any standard Toolbar items:
  7795. items: [{
  7796. text: 'A Button'
  7797. }, '-', 'Plain Text']
  7798. })
  7799. });
  7800. // Update the status bar later in code:
  7801. var sb = Ext.getCmp('my-status');
  7802. sb.setStatus({
  7803. text: 'OK',
  7804. iconCls: 'ok-icon',
  7805. clear: true // auto-clear after a set interval
  7806. });
  7807. // Set the status bar to show that something is processing:
  7808. sb.showBusy();
  7809. // processing....
  7810. sb.clearStatus(); // once completeed
  7811. </code></pre>
  7812. * @extends Ext.Toolbar
  7813. * @constructor
  7814. * Creates a new StatusBar
  7815. * @param {Object/Array} config A config object
  7816. */
  7817. Ext.ux.StatusBar = Ext.extend(Ext.Toolbar, {
  7818. <div id="cfg-Ext.ux.StatusBar-statusAlign"></div>/**
  7819. * @cfg {String} statusAlign
  7820. * The alignment of the status element within the overall StatusBar layout. When the StatusBar is rendered,
  7821. * it creates an internal div containing the status text and icon. Any additional Toolbar items added in the
  7822. * StatusBar's {@link #items} config, or added via {@link #add} or any of the supported add* methods, will be
  7823. * rendered, in added order, to the opposite side. The status element is greedy, so it will automatically
  7824. * expand to take up all sapce left over by any other items. Example usage:
  7825. * <pre><code>
  7826. // Create a left-aligned status bar containing a button,
  7827. // separator and text item that will be right-aligned (default):
  7828. new Ext.Panel({
  7829. title: 'StatusBar',
  7830. // etc.
  7831. bbar: new Ext.ux.StatusBar({
  7832. defaultText: 'Default status text',
  7833. id: 'status-id',
  7834. items: [{
  7835. text: 'A Button'
  7836. }, '-', 'Plain Text']
  7837. })
  7838. });
  7839. // By adding the statusAlign config, this will create the
  7840. // exact same toolbar, except the status and toolbar item
  7841. // layout will be reversed from the previous example:
  7842. new Ext.Panel({
  7843. title: 'StatusBar',
  7844. // etc.
  7845. bbar: new Ext.ux.StatusBar({
  7846. defaultText: 'Default status text',
  7847. id: 'status-id',
  7848. statusAlign: 'right',
  7849. items: [{
  7850. text: 'A Button'
  7851. }, '-', 'Plain Text']
  7852. })
  7853. });
  7854. </code></pre>
  7855. */
  7856. <div id="cfg-Ext.ux.StatusBar-defaultText"></div>/**
  7857. * @cfg {String} defaultText
  7858. * The default {@link #text} value. This will be used anytime the status bar is cleared with the
  7859. * <tt>useDefaults:true</tt> option (defaults to '').
  7860. */
  7861. <div id="cfg-Ext.ux.StatusBar-defaultIconCls"></div>/**
  7862. * @cfg {String} defaultIconCls
  7863. * The default {@link #iconCls} value (see the iconCls docs for additional details about customizing the icon).
  7864. * This will be used anytime the status bar is cleared with the <tt>useDefaults:true</tt> option (defaults to '').
  7865. */
  7866. <div id="cfg-Ext.ux.StatusBar-text"></div>/**
  7867. * @cfg {String} text
  7868. * A string that will be <b>initially</b> set as the status message. This string
  7869. * will be set as innerHTML (html tags are accepted) for the toolbar item.
  7870. * If not specified, the value set for <code>{@link #defaultText}</code>
  7871. * will be used.
  7872. */
  7873. <div id="cfg-Ext.ux.StatusBar-iconCls"></div>/**
  7874. * @cfg {String} iconCls
  7875. * A CSS class that will be <b>initially</b> set as the status bar icon and is
  7876. * expected to provide a background image (defaults to '').
  7877. * Example usage:<pre><code>
  7878. // Example CSS rule:
  7879. .x-statusbar .x-status-custom {
  7880. padding-left: 25px;
  7881. background: transparent url(images/custom-icon.gif) no-repeat 3px 2px;
  7882. }
  7883. // Setting a default icon:
  7884. var sb = new Ext.ux.StatusBar({
  7885. defaultIconCls: 'x-status-custom'
  7886. });
  7887. // Changing the icon:
  7888. sb.setStatus({
  7889. text: 'New status',
  7890. iconCls: 'x-status-custom'
  7891. });
  7892. </code></pre>
  7893. */
  7894. <div id="cfg-Ext.ux.StatusBar-cls"></div>/**
  7895. * @cfg {String} cls
  7896. * The base class applied to the containing element for this component on render (defaults to 'x-statusbar')
  7897. */
  7898. cls : 'x-statusbar',
  7899. <div id="cfg-Ext.ux.StatusBar-busyIconCls"></div>/**
  7900. * @cfg {String} busyIconCls
  7901. * The default <code>{@link #iconCls}</code> applied when calling
  7902. * <code>{@link #showBusy}</code> (defaults to <tt>'x-status-busy'</tt>).
  7903. * It can be overridden at any time by passing the <code>iconCls</code>
  7904. * argument into <code>{@link #showBusy}</code>.
  7905. */
  7906. busyIconCls : 'x-status-busy',
  7907. <div id="cfg-Ext.ux.StatusBar-busyText"></div>/**
  7908. * @cfg {String} busyText
  7909. * The default <code>{@link #text}</code> applied when calling
  7910. * <code>{@link #showBusy}</code> (defaults to <tt>'Loading...'</tt>).
  7911. * It can be overridden at any time by passing the <code>text</code>
  7912. * argument into <code>{@link #showBusy}</code>.
  7913. */
  7914. busyText : 'Loading...',
  7915. <div id="cfg-Ext.ux.StatusBar-autoClear"></div>/**
  7916. * @cfg {Number} autoClear
  7917. * The number of milliseconds to wait after setting the status via
  7918. * <code>{@link #setStatus}</code> before automatically clearing the status
  7919. * text and icon (defaults to <tt>5000</tt>). Note that this only applies
  7920. * when passing the <tt>clear</tt> argument to <code>{@link #setStatus}</code>
  7921. * since that is the only way to defer clearing the status. This can
  7922. * be overridden by specifying a different <tt>wait</tt> value in
  7923. * <code>{@link #setStatus}</code>. Calls to <code>{@link #clearStatus}</code>
  7924. * always clear the status bar immediately and ignore this value.
  7925. */
  7926. autoClear : 5000,
  7927. <div id="cfg-Ext.ux.StatusBar-emptyText"></div>/**
  7928. * @cfg {String} emptyText
  7929. * The text string to use if no text has been set. Defaults to
  7930. * <tt>'&nbsp;'</tt>). If there are no other items in the toolbar using
  7931. * an empty string (<tt>''</tt>) for this value would end up in the toolbar
  7932. * height collapsing since the empty string will not maintain the toolbar
  7933. * height. Use <tt>''</tt> if the toolbar should collapse in height
  7934. * vertically when no text is specified and there are no other items in
  7935. * the toolbar.
  7936. */
  7937. emptyText : '&nbsp;',
  7938. // private
  7939. activeThreadId : 0,
  7940. // private
  7941. initComponent : function(){
  7942. if(this.statusAlign=='right'){
  7943. this.cls += ' x-status-right';
  7944. }
  7945. Ext.ux.StatusBar.superclass.initComponent.call(this);
  7946. },
  7947. // private
  7948. afterRender : function(){
  7949. Ext.ux.StatusBar.superclass.afterRender.call(this);
  7950. var right = this.statusAlign == 'right';
  7951. this.currIconCls = this.iconCls || this.defaultIconCls;
  7952. this.statusEl = new Ext.Toolbar.TextItem({
  7953. cls: 'x-status-text ' + (this.currIconCls || ''),
  7954. text: this.text || this.defaultText || ''
  7955. });
  7956. if(right){
  7957. this.add('->');
  7958. this.add(this.statusEl);
  7959. }else{
  7960. this.insert(0, this.statusEl);
  7961. this.insert(1, '->');
  7962. }
  7963. this.doLayout();
  7964. },
  7965. <div id="method-Ext.ux.StatusBar-setStatus"></div>/**
  7966. * Sets the status {@link #text} and/or {@link #iconCls}. Also supports automatically clearing the
  7967. * status that was set after a specified interval.
  7968. * @param {Object/String} config A config object specifying what status to set, or a string assumed
  7969. * to be the status text (and all other options are defaulted as explained below). A config
  7970. * object containing any or all of the following properties can be passed:<ul>
  7971. * <li><tt>text</tt> {String} : (optional) The status text to display. If not specified, any current
  7972. * status text will remain unchanged.</li>
  7973. * <li><tt>iconCls</tt> {String} : (optional) The CSS class used to customize the status icon (see
  7974. * {@link #iconCls} for details). If not specified, any current iconCls will remain unchanged.</li>
  7975. * <li><tt>clear</tt> {Boolean/Number/Object} : (optional) Allows you to set an internal callback that will
  7976. * automatically clear the status text and iconCls after a specified amount of time has passed. If clear is not
  7977. * specified, the new status will not be auto-cleared and will stay until updated again or cleared using
  7978. * {@link #clearStatus}. If <tt>true</tt> is passed, the status will be cleared using {@link #autoClear},
  7979. * {@link #defaultText} and {@link #defaultIconCls} via a fade out animation. If a numeric value is passed,
  7980. * it will be used as the callback interval (in milliseconds), overriding the {@link #autoClear} value.
  7981. * All other options will be defaulted as with the boolean option. To customize any other options,
  7982. * you can pass an object in the format:<ul>
  7983. * <li><tt>wait</tt> {Number} : (optional) The number of milliseconds to wait before clearing
  7984. * (defaults to {@link #autoClear}).</li>
  7985. * <li><tt>anim</tt> {Number} : (optional) False to clear the status immediately once the callback
  7986. * executes (defaults to true which fades the status out).</li>
  7987. * <li><tt>useDefaults</tt> {Number} : (optional) False to completely clear the status text and iconCls
  7988. * (defaults to true which uses {@link #defaultText} and {@link #defaultIconCls}).</li>
  7989. * </ul></li></ul>
  7990. * Example usage:<pre><code>
  7991. // Simple call to update the text
  7992. statusBar.setStatus('New status');
  7993. // Set the status and icon, auto-clearing with default options:
  7994. statusBar.setStatus({
  7995. text: 'New status',
  7996. iconCls: 'x-status-custom',
  7997. clear: true
  7998. });
  7999. // Auto-clear with custom options:
  8000. statusBar.setStatus({
  8001. text: 'New status',
  8002. iconCls: 'x-status-custom',
  8003. clear: {
  8004. wait: 8000,
  8005. anim: false,
  8006. useDefaults: false
  8007. }
  8008. });
  8009. </code></pre>
  8010. * @return {Ext.ux.StatusBar} this
  8011. */
  8012. setStatus : function(o){
  8013. o = o || {};
  8014. if(typeof o == 'string'){
  8015. o = {text:o};
  8016. }
  8017. if(o.text !== undefined){
  8018. this.setText(o.text);
  8019. }
  8020. if(o.iconCls !== undefined){
  8021. this.setIcon(o.iconCls);
  8022. }
  8023. if(o.clear){
  8024. var c = o.clear,
  8025. wait = this.autoClear,
  8026. defaults = {useDefaults: true, anim: true};
  8027. if(typeof c == 'object'){
  8028. c = Ext.applyIf(c, defaults);
  8029. if(c.wait){
  8030. wait = c.wait;
  8031. }
  8032. }else if(typeof c == 'number'){
  8033. wait = c;
  8034. c = defaults;
  8035. }else if(typeof c == 'boolean'){
  8036. c = defaults;
  8037. }
  8038. c.threadId = this.activeThreadId;
  8039. this.clearStatus.defer(wait, this, [c]);
  8040. }
  8041. return this;
  8042. },
  8043. <div id="method-Ext.ux.StatusBar-clearStatus"></div>/**
  8044. * Clears the status {@link #text} and {@link #iconCls}. Also supports clearing via an optional fade out animation.
  8045. * @param {Object} config (optional) A config object containing any or all of the following properties. If this
  8046. * object is not specified the status will be cleared using the defaults below:<ul>
  8047. * <li><tt>anim</tt> {Boolean} : (optional) True to clear the status by fading out the status element (defaults
  8048. * to false which clears immediately).</li>
  8049. * <li><tt>useDefaults</tt> {Boolean} : (optional) True to reset the text and icon using {@link #defaultText} and
  8050. * {@link #defaultIconCls} (defaults to false which sets the text to '' and removes any existing icon class).</li>
  8051. * </ul>
  8052. * @return {Ext.ux.StatusBar} this
  8053. */
  8054. clearStatus : function(o){
  8055. o = o || {};
  8056. if(o.threadId && o.threadId !== this.activeThreadId){
  8057. // this means the current call was made internally, but a newer
  8058. // thread has set a message since this call was deferred. Since
  8059. // we don't want to overwrite a newer message just ignore.
  8060. return this;
  8061. }
  8062. var text = o.useDefaults ? this.defaultText : this.emptyText,
  8063. iconCls = o.useDefaults ? (this.defaultIconCls ? this.defaultIconCls : '') : '';
  8064. if(o.anim){
  8065. // animate the statusEl Ext.Element
  8066. this.statusEl.el.fadeOut({
  8067. remove: false,
  8068. useDisplay: true,
  8069. scope: this,
  8070. callback: function(){
  8071. this.setStatus({
  8072. text: text,
  8073. iconCls: iconCls
  8074. });
  8075. this.statusEl.el.show();
  8076. }
  8077. });
  8078. }else{
  8079. // hide/show the el to avoid jumpy text or icon
  8080. this.statusEl.hide();
  8081. this.setStatus({
  8082. text: text,
  8083. iconCls: iconCls
  8084. });
  8085. this.statusEl.show();
  8086. }
  8087. return this;
  8088. },
  8089. <div id="method-Ext.ux.StatusBar-setText"></div>/**
  8090. * Convenience method for setting the status text directly. For more flexible options see {@link #setStatus}.
  8091. * @param {String} text (optional) The text to set (defaults to '')
  8092. * @return {Ext.ux.StatusBar} this
  8093. */
  8094. setText : function(text){
  8095. this.activeThreadId++;
  8096. this.text = text || '';
  8097. if(this.rendered){
  8098. this.statusEl.setText(this.text);
  8099. }
  8100. return this;
  8101. },
  8102. <div id="method-Ext.ux.StatusBar-getText"></div>/**
  8103. * Returns the current status text.
  8104. * @return {String} The status text
  8105. */
  8106. getText : function(){
  8107. return this.text;
  8108. },
  8109. <div id="method-Ext.ux.StatusBar-setIcon"></div>/**
  8110. * Convenience method for setting the status icon directly. For more flexible options see {@link #setStatus}.
  8111. * See {@link #iconCls} for complete details about customizing the icon.
  8112. * @param {String} iconCls (optional) The icon class to set (defaults to '', and any current icon class is removed)
  8113. * @return {Ext.ux.StatusBar} this
  8114. */
  8115. setIcon : function(cls){
  8116. this.activeThreadId++;
  8117. cls = cls || '';
  8118. if(this.rendered){
  8119. if(this.currIconCls){
  8120. this.statusEl.removeClass(this.currIconCls);
  8121. this.currIconCls = null;
  8122. }
  8123. if(cls.length > 0){
  8124. this.statusEl.addClass(cls);
  8125. this.currIconCls = cls;
  8126. }
  8127. }else{
  8128. this.currIconCls = cls;
  8129. }
  8130. return this;
  8131. },
  8132. <div id="method-Ext.ux.StatusBar-showBusy"></div>/**
  8133. * Convenience method for setting the status text and icon to special values that are pre-configured to indicate
  8134. * a "busy" state, usually for loading or processing activities.
  8135. * @param {Object/String} config (optional) A config object in the same format supported by {@link #setStatus}, or a
  8136. * string to use as the status text (in which case all other options for setStatus will be defaulted). Use the
  8137. * <tt>text</tt> and/or <tt>iconCls</tt> properties on the config to override the default {@link #busyText}
  8138. * and {@link #busyIconCls} settings. If the config argument is not specified, {@link #busyText} and
  8139. * {@link #busyIconCls} will be used in conjunction with all of the default options for {@link #setStatus}.
  8140. * @return {Ext.ux.StatusBar} this
  8141. */
  8142. showBusy : function(o){
  8143. if(typeof o == 'string'){
  8144. o = {text:o};
  8145. }
  8146. o = Ext.applyIf(o || {}, {
  8147. text: this.busyText,
  8148. iconCls: this.busyIconCls
  8149. });
  8150. return this.setStatus(o);
  8151. }
  8152. });
  8153. Ext.reg('statusbar', Ext.ux.StatusBar);
  8154. /**
  8155. * @class Ext.ux.TabCloseMenu
  8156. * @extends Object
  8157. * Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs. Note that the menu respects
  8158. * the closable configuration on the tab. As such, commands like remove others and remove all will not
  8159. * remove items that are not closable.
  8160. *
  8161. * @constructor
  8162. * @param {Object} config The configuration options
  8163. * @ptype tabclosemenu
  8164. */
  8165. Ext.ux.TabCloseMenu = Ext.extend(Object, {
  8166. <div id="cfg-Ext.ux.TabCloseMenu-closeTabText"></div>/**
  8167. * @cfg {String} closeTabText
  8168. * The text for closing the current tab. Defaults to <tt>'Close Tab'</tt>.
  8169. */
  8170. closeTabText: 'Close Tab',
  8171. <div id="cfg-Ext.ux.TabCloseMenu-closeOtherTabsText"></div>/**
  8172. * @cfg {String} closeOtherTabsText
  8173. * The text for closing all tabs except the current one. Defaults to <tt>'Close Other Tabs'</tt>.
  8174. */
  8175. closeOtherTabsText: 'Close Other Tabs',
  8176. <div id="cfg-Ext.ux.TabCloseMenu-showCloseAll"></div>/**
  8177. * @cfg {Boolean} showCloseAll
  8178. * Indicates whether to show the 'Close All' option. Defaults to <tt>true</tt>.
  8179. */
  8180. showCloseAll: true,
  8181. <div id="cfg-Ext.ux.TabCloseMenu-closeAllTabsText"></div>/**
  8182. * @cfg {String} closeAllTabsText
  8183. * <p>The text for closing all tabs. Defaults to <tt>'Close All Tabs'</tt>.
  8184. */
  8185. closeAllTabsText: 'Close All Tabs',
  8186. constructor : function(config){
  8187. Ext.apply(this, config || {});
  8188. },
  8189. //public
  8190. init : function(tabs){
  8191. this.tabs = tabs;
  8192. tabs.on({
  8193. scope: this,
  8194. contextmenu: this.onContextMenu,
  8195. destroy: this.destroy
  8196. });
  8197. },
  8198. destroy : function(){
  8199. Ext.destroy(this.menu);
  8200. delete this.menu;
  8201. delete this.tabs;
  8202. delete this.active;
  8203. },
  8204. // private
  8205. onContextMenu : function(tabs, item, e){
  8206. this.active = item;
  8207. var m = this.createMenu(),
  8208. disableAll = true,
  8209. disableOthers = true,
  8210. closeAll = m.getComponent('closeall');
  8211. m.getComponent('close').setDisabled(!item.closable);
  8212. tabs.items.each(function(){
  8213. if(this.closable){
  8214. disableAll = false;
  8215. if(this != item){
  8216. disableOthers = false;
  8217. return false;
  8218. }
  8219. }
  8220. });
  8221. m.getComponent('closeothers').setDisabled(disableOthers);
  8222. if(closeAll){
  8223. closeAll.setDisabled(disableAll);
  8224. }
  8225. e.stopEvent();
  8226. m.showAt(e.getPoint());
  8227. },
  8228. createMenu : function(){
  8229. if(!this.menu){
  8230. var items = [{
  8231. itemId: 'close',
  8232. text: this.closeTabText,
  8233. scope: this,
  8234. handler: this.onClose
  8235. }];
  8236. if(this.showCloseAll){
  8237. items.push('-');
  8238. }
  8239. items.push({
  8240. itemId: 'closeothers',
  8241. text: this.closeOtherTabsText,
  8242. scope: this,
  8243. handler: this.onCloseOthers
  8244. });
  8245. if(this.showCloseAll){
  8246. items.push({
  8247. itemId: 'closeall',
  8248. text: this.closeAllTabsText,
  8249. scope: this,
  8250. handler: this.onCloseAll
  8251. });
  8252. }
  8253. this.menu = new Ext.menu.Menu({
  8254. items: items
  8255. });
  8256. }
  8257. return this.menu;
  8258. },
  8259. onClose : function(){
  8260. this.tabs.remove(this.active);
  8261. },
  8262. onCloseOthers : function(){
  8263. this.doClose(true);
  8264. },
  8265. onCloseAll : function(){
  8266. this.doClose(false);
  8267. },
  8268. doClose : function(excludeActive){
  8269. var items = [];
  8270. this.tabs.items.each(function(item){
  8271. if(item.closable){
  8272. if(!excludeActive || item != this.active){
  8273. items.push(item);
  8274. }
  8275. }
  8276. }, this);
  8277. Ext.each(items, function(item){
  8278. this.tabs.remove(item);
  8279. }, this);
  8280. }
  8281. });
  8282. Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);Ext.ns('Ext.ux.grid');
  8283. <div id="cls-Ext.ux.grid.TableGrid"></div>/**
  8284. * @class Ext.ux.grid.TableGrid
  8285. * @extends Ext.grid.GridPanel
  8286. * A Grid which creates itself from an existing HTML table element.
  8287. * @history
  8288. * 2007-03-01 Original version by Nige "Animal" White
  8289. * 2007-03-10 jvs Slightly refactored to reuse existing classes * @constructor
  8290. * @param {String/HTMLElement/Ext.Element} table The table element from which this grid will be created -
  8291. * The table MUST have some type of size defined for the grid to fill. The container will be
  8292. * automatically set to position relative if it isn't already.
  8293. * @param {Object} config A config object that sets properties on this grid and has two additional (optional)
  8294. * properties: fields and columns which allow for customizing data fields and columns for this grid.
  8295. */
  8296. Ext.ux.grid.TableGrid = function(table, config){
  8297. config = config ||
  8298. {};
  8299. Ext.apply(this, config);
  8300. var cf = config.fields || [], ch = config.columns || [];
  8301. table = Ext.get(table);
  8302. var ct = table.insertSibling();
  8303. var fields = [], cols = [];
  8304. var headers = table.query("thead th");
  8305. for (var i = 0, h; h = headers[i]; i++) {
  8306. var text = h.innerHTML;
  8307. var name = 'tcol-' + i;
  8308. fields.push(Ext.applyIf(cf[i] ||
  8309. {}, {
  8310. name: name,
  8311. mapping: 'td:nth(' + (i + 1) + ')/@innerHTML'
  8312. }));
  8313. cols.push(Ext.applyIf(ch[i] ||
  8314. {}, {
  8315. 'header': text,
  8316. 'dataIndex': name,
  8317. 'width': h.offsetWidth,
  8318. 'tooltip': h.title,
  8319. 'sortable': true
  8320. }));
  8321. }
  8322. var ds = new Ext.data.Store({
  8323. reader: new Ext.data.XmlReader({
  8324. record: 'tbody tr'
  8325. }, fields)
  8326. });
  8327. ds.loadData(table.dom);
  8328. var cm = new Ext.grid.ColumnModel(cols);
  8329. if (config.width || config.height) {
  8330. ct.setSize(config.width || 'auto', config.height || 'auto');
  8331. }
  8332. else {
  8333. ct.setWidth(table.getWidth());
  8334. }
  8335. if (config.remove !== false) {
  8336. table.remove();
  8337. }
  8338. Ext.applyIf(this, {
  8339. 'ds': ds,
  8340. 'cm': cm,
  8341. 'sm': new Ext.grid.RowSelectionModel(),
  8342. autoHeight: true,
  8343. autoWidth: false
  8344. });
  8345. Ext.ux.grid.TableGrid.superclass.constructor.call(this, ct, {});
  8346. };
  8347. Ext.extend(Ext.ux.grid.TableGrid, Ext.grid.GridPanel);
  8348. //backwards compat
  8349. Ext.grid.TableGrid = Ext.ux.grid.TableGrid;
  8350. Ext.ns('Ext.ux');
  8351. <div id="cls-Ext.ux.TabScrollerMenu"></div>/**
  8352. * @class Ext.ux.TabScrollerMenu
  8353. * @extends Object
  8354. * Plugin (ptype = 'tabscrollermenu') for adding a tab scroller menu to tabs.
  8355. * @constructor
  8356. * @param {Object} config Configuration options
  8357. * @ptype tabscrollermenu
  8358. */
  8359. Ext.ux.TabScrollerMenu = Ext.extend(Object, {
  8360. <div id="cfg-Ext.ux.TabScrollerMenu-pageSize"></div>/**
  8361. * @cfg {Number} pageSize How many items to allow per submenu.
  8362. */
  8363. pageSize : 10,
  8364. <div id="cfg-Ext.ux.TabScrollerMenu-maxText"></div>/**
  8365. * @cfg {Number} maxText How long should the title of each {@link Ext.menu.Item} be.
  8366. */
  8367. maxText : 15,
  8368. <div id="cfg-Ext.ux.TabScrollerMenu-menuPrefixText"></div>/**
  8369. * @cfg {String} menuPrefixText Text to prefix the submenus.
  8370. */
  8371. menuPrefixText : 'Items',
  8372. constructor : function(config) {
  8373. config = config || {};
  8374. Ext.apply(this, config);
  8375. },
  8376. //private
  8377. init : function(tabPanel) {
  8378. Ext.apply(tabPanel, this.parentOverrides);
  8379. tabPanel.tabScrollerMenu = this;
  8380. var thisRef = this;
  8381. tabPanel.on({
  8382. render : {
  8383. scope : tabPanel,
  8384. single : true,
  8385. fn : function() {
  8386. var newFn = tabPanel.createScrollers.createSequence(thisRef.createPanelsMenu, this);
  8387. tabPanel.createScrollers = newFn;
  8388. }
  8389. }
  8390. });
  8391. },
  8392. // private && sequeneced
  8393. createPanelsMenu : function() {
  8394. var h = this.stripWrap.dom.offsetHeight;
  8395. //move the right menu item to the left 18px
  8396. var rtScrBtn = this.header.dom.firstChild;
  8397. Ext.fly(rtScrBtn).applyStyles({
  8398. right : '18px'
  8399. });
  8400. var stripWrap = Ext.get(this.strip.dom.parentNode);
  8401. stripWrap.applyStyles({
  8402. 'margin-right' : '36px'
  8403. });
  8404. // Add the new righthand menu
  8405. var scrollMenu = this.header.insertFirst({
  8406. cls:'x-tab-tabmenu-right'
  8407. });
  8408. scrollMenu.setHeight(h);
  8409. scrollMenu.addClassOnOver('x-tab-tabmenu-over');
  8410. scrollMenu.on('click', this.showTabsMenu, this);
  8411. this.scrollLeft.show = this.scrollLeft.show.createSequence(function() {
  8412. scrollMenu.show();
  8413. });
  8414. this.scrollLeft.hide = this.scrollLeft.hide.createSequence(function() {
  8415. scrollMenu.hide();
  8416. });
  8417. },
  8418. <div id="method-Ext.ux.TabScrollerMenu-getPageSize"></div>/**
  8419. * Returns an the current page size (this.pageSize);
  8420. * @return {Number} this.pageSize The current page size.
  8421. */
  8422. getPageSize : function() {
  8423. return this.pageSize;
  8424. },
  8425. <div id="method-Ext.ux.TabScrollerMenu-setPageSize"></div>/**
  8426. * Sets the number of menu items per submenu "page size".
  8427. * @param {Number} pageSize The page size
  8428. */
  8429. setPageSize : function(pageSize) {
  8430. this.pageSize = pageSize;
  8431. },
  8432. <div id="method-Ext.ux.TabScrollerMenu-getMaxText"></div>/**
  8433. * Returns the current maxText length;
  8434. * @return {Number} this.maxText The current max text length.
  8435. */
  8436. getMaxText : function() {
  8437. return this.maxText;
  8438. },
  8439. <div id="method-Ext.ux.TabScrollerMenu-setMaxText"></div>/**
  8440. * Sets the maximum text size for each menu item.
  8441. * @param {Number} t The max text per each menu item.
  8442. */
  8443. setMaxText : function(t) {
  8444. this.maxText = t;
  8445. },
  8446. <div id="method-Ext.ux.TabScrollerMenu-getMenuPrefixText"></div>/**
  8447. * Returns the current menu prefix text String.;
  8448. * @return {String} this.menuPrefixText The current menu prefix text.
  8449. */
  8450. getMenuPrefixText : function() {
  8451. return this.menuPrefixText;
  8452. },
  8453. <div id="method-Ext.ux.TabScrollerMenu-setMenuPrefixText"></div>/**
  8454. * Sets the menu prefix text String.
  8455. * @param {String} t The menu prefix text.
  8456. */
  8457. setMenuPrefixText : function(t) {
  8458. this.menuPrefixText = t;
  8459. },
  8460. // private && applied to the tab panel itself.
  8461. parentOverrides : {
  8462. // all execute within the scope of the tab panel
  8463. // private
  8464. showTabsMenu : function(e) {
  8465. if (this.tabsMenu) {
  8466. this.tabsMenu.destroy();
  8467. this.un('destroy', this.tabsMenu.destroy, this.tabsMenu);
  8468. this.tabsMenu = null;
  8469. }
  8470. this.tabsMenu = new Ext.menu.Menu();
  8471. this.on('destroy', this.tabsMenu.destroy, this.tabsMenu);
  8472. this.generateTabMenuItems();
  8473. var target = Ext.get(e.getTarget());
  8474. var xy = target.getXY();
  8475. //
  8476. //Y param + 24 pixels
  8477. xy[1] += 24;
  8478. this.tabsMenu.showAt(xy);
  8479. },
  8480. // private
  8481. generateTabMenuItems : function() {
  8482. var curActive = this.getActiveTab();
  8483. var totalItems = this.items.getCount();
  8484. var pageSize = this.tabScrollerMenu.getPageSize();
  8485. if (totalItems > pageSize) {
  8486. var numSubMenus = Math.floor(totalItems / pageSize);
  8487. var remainder = totalItems % pageSize;
  8488. // Loop through all of the items and create submenus in chunks of 10
  8489. for (var i = 0 ; i < numSubMenus; i++) {
  8490. var curPage = (i + 1) * pageSize;
  8491. var menuItems = [];
  8492. for (var x = 0; x < pageSize; x++) {
  8493. index = x + curPage - pageSize;
  8494. var item = this.items.get(index);
  8495. menuItems.push(this.autoGenMenuItem(item));
  8496. }
  8497. this.tabsMenu.add({
  8498. text : this.tabScrollerMenu.getMenuPrefixText() + ' ' + (curPage - pageSize + 1) + ' - ' + curPage,
  8499. menu : menuItems
  8500. });
  8501. }
  8502. // remaining items
  8503. if (remainder > 0) {
  8504. var start = numSubMenus * pageSize;
  8505. menuItems = [];
  8506. for (var i = start ; i < totalItems; i ++ ) {
  8507. var item = this.items.get(i);
  8508. menuItems.push(this.autoGenMenuItem(item));
  8509. }
  8510. this.tabsMenu.add({
  8511. text : this.tabScrollerMenu.menuPrefixText + ' ' + (start + 1) + ' - ' + (start + menuItems.length),
  8512. menu : menuItems
  8513. });
  8514. }
  8515. }
  8516. else {
  8517. this.items.each(function(item) {
  8518. if (item.id != curActive.id && !item.hidden) {
  8519. this.tabsMenu.add(this.autoGenMenuItem(item));
  8520. }
  8521. }, this);
  8522. }
  8523. },
  8524. // private
  8525. autoGenMenuItem : function(item) {
  8526. var maxText = this.tabScrollerMenu.getMaxText();
  8527. var text = Ext.util.Format.ellipsis(item.title, maxText);
  8528. return {
  8529. text : text,
  8530. handler : this.showTabFromMenu,
  8531. scope : this,
  8532. disabled : item.disabled,
  8533. tabToShow : item,
  8534. iconCls : item.iconCls
  8535. }
  8536. },
  8537. // private
  8538. showTabFromMenu : function(menuItem) {
  8539. this.setActiveTab(menuItem.tabToShow);
  8540. }
  8541. }
  8542. });
  8543. Ext.reg('tabscrollermenu', Ext.ux.TabScrollerMenu);
  8544. Ext.ns('Ext.ux.tree');
  8545. <div id="cls-Ext.ux.tree.XmlTreeLoader"></div>/**
  8546. * @class Ext.ux.tree.XmlTreeLoader
  8547. * @extends Ext.tree.TreeLoader
  8548. * <p>A TreeLoader that can convert an XML document into a hierarchy of {@link Ext.tree.TreeNode}s.
  8549. * Any text value included as a text node in the XML will be added to the parent node as an attribute
  8550. * called <tt>innerText</tt>. Also, the tag name of each XML node will be added to the tree node as
  8551. * an attribute called <tt>tagName</tt>.</p>
  8552. * <p>By default, this class expects that your source XML will provide the necessary attributes on each
  8553. * node as expected by the {@link Ext.tree.TreePanel} to display and load properly. However, you can
  8554. * provide your own custom processing of node attributes by overriding the {@link #processNode} method
  8555. * and modifying the attributes as needed before they are used to create the associated TreeNode.</p>
  8556. * @constructor
  8557. * Creates a new XmlTreeloader.
  8558. * @param {Object} config A config object containing config properties.
  8559. */
  8560. Ext.ux.tree.XmlTreeLoader = Ext.extend(Ext.tree.TreeLoader, {
  8561. <div id="prop-Ext.ux.tree.XmlTreeLoader-XML_NODE_ELEMENT"></div>/**
  8562. * @property XML_NODE_ELEMENT
  8563. * XML element node (value 1, read-only)
  8564. * @type Number
  8565. */
  8566. XML_NODE_ELEMENT : 1,
  8567. <div id="prop-Ext.ux.tree.XmlTreeLoader-XML_NODE_TEXT"></div>/**
  8568. * @property XML_NODE_TEXT
  8569. * XML text node (value 3, read-only)
  8570. * @type Number
  8571. */
  8572. XML_NODE_TEXT : 3,
  8573. // private override
  8574. processResponse : function(response, node, callback){
  8575. var xmlData = response.responseXML,
  8576. root = xmlData.documentElement || xmlData;
  8577. try{
  8578. node.beginUpdate();
  8579. node.appendChild(this.parseXml(root));
  8580. node.endUpdate();
  8581. this.runCallback(callback, scope || node, [node]);
  8582. }catch(e){
  8583. this.handleFailure(response);
  8584. }
  8585. },
  8586. // private
  8587. parseXml : function(node) {
  8588. var nodes = [];
  8589. Ext.each(node.childNodes, function(n){
  8590. if(n.nodeType == this.XML_NODE_ELEMENT){
  8591. var treeNode = this.createNode(n);
  8592. if(n.childNodes.length > 0){
  8593. var child = this.parseXml(n);
  8594. if(typeof child == 'string'){
  8595. treeNode.attributes.innerText = child;
  8596. }else{
  8597. treeNode.appendChild(child);
  8598. }
  8599. }
  8600. nodes.push(treeNode);
  8601. }
  8602. else if(n.nodeType == this.XML_NODE_TEXT){
  8603. var text = n.nodeValue.trim();
  8604. if(text.length > 0){
  8605. return nodes = text;
  8606. }
  8607. }
  8608. }, this);
  8609. return nodes;
  8610. },
  8611. // private override
  8612. createNode : function(node){
  8613. var attr = {
  8614. tagName: node.tagName
  8615. };
  8616. Ext.each(node.attributes, function(a){
  8617. attr[a.nodeName] = a.nodeValue;
  8618. });
  8619. this.processAttributes(attr);
  8620. return Ext.ux.tree.XmlTreeLoader.superclass.createNode.call(this, attr);
  8621. },
  8622. /*
  8623. * Template method intended to be overridden by subclasses that need to provide
  8624. * custom attribute processing prior to the creation of each TreeNode. This method
  8625. * will be passed a config object containing existing TreeNode attribute name/value
  8626. * pairs which can be modified as needed directly (no need to return the object).
  8627. */
  8628. processAttributes: Ext.emptyFn
  8629. });
  8630. //backwards compat
  8631. Ext.ux.XmlTreeLoader = Ext.ux.tree.XmlTreeLoader;
  8632. /**
  8633. * @class Ext.ux.ValidationStatus
  8634. * A {@link Ext.StatusBar} plugin that provides automatic error notification when the
  8635. * associated form contains validation errors.
  8636. * @extends Ext.Component
  8637. * @constructor
  8638. * Creates a new ValiationStatus plugin
  8639. * @param {Object} config A config object
  8640. */
  8641. Ext.ux.ValidationStatus = Ext.extend(Ext.Component, {
  8642. <div id="cfg-Ext.ux.ValidationStatus-errorIconCls"></div>/**
  8643. * @cfg {String} errorIconCls
  8644. * The {@link #iconCls} value to be applied to the status message when there is a
  8645. * validation error. Defaults to <tt>'x-status-error'</tt>.
  8646. */
  8647. errorIconCls : 'x-status-error',
  8648. <div id="cfg-Ext.ux.ValidationStatus-errorListCls"></div>/**
  8649. * @cfg {String} errorListCls
  8650. * The css class to be used for the error list when there are validation errors.
  8651. * Defaults to <tt>'x-status-error-list'</tt>.
  8652. */
  8653. errorListCls : 'x-status-error-list',
  8654. <div id="cfg-Ext.ux.ValidationStatus-validIconCls"></div>/**
  8655. * @cfg {String} validIconCls
  8656. * The {@link #iconCls} value to be applied to the status message when the form
  8657. * validates. Defaults to <tt>'x-status-valid'</tt>.
  8658. */
  8659. validIconCls : 'x-status-valid',
  8660. <div id="cfg-Ext.ux.ValidationStatus-showText"></div>/**
  8661. * @cfg {String} showText
  8662. * The {@link #text} value to be applied when there is a form validation error.
  8663. * Defaults to <tt>'The form has errors (click for details...)'</tt>.
  8664. */
  8665. showText : 'The form has errors (click for details...)',
  8666. <div id="cfg-Ext.ux.ValidationStatus-showText"></div>/**
  8667. * @cfg {String} showText
  8668. * The {@link #text} value to display when the error list is displayed.
  8669. * Defaults to <tt>'Click again to hide the error list'</tt>.
  8670. */
  8671. hideText : 'Click again to hide the error list',
  8672. <div id="cfg-Ext.ux.ValidationStatus-submitText"></div>/**
  8673. * @cfg {String} submitText
  8674. * The {@link #text} value to be applied when the form is being submitted.
  8675. * Defaults to <tt>'Saving...'</tt>.
  8676. */
  8677. submitText : 'Saving...',
  8678. // private
  8679. init : function(sb){
  8680. sb.on('render', function(){
  8681. this.statusBar = sb;
  8682. this.monitor = true;
  8683. this.errors = new Ext.util.MixedCollection();
  8684. this.listAlign = (sb.statusAlign=='right' ? 'br-tr?' : 'bl-tl?');
  8685. if(this.form){
  8686. this.form = Ext.getCmp(this.form).getForm();
  8687. this.startMonitoring();
  8688. this.form.on('beforeaction', function(f, action){
  8689. if(action.type == 'submit'){
  8690. // Ignore monitoring while submitting otherwise the field validation
  8691. // events cause the status message to reset too early
  8692. this.monitor = false;
  8693. }
  8694. }, this);
  8695. var startMonitor = function(){
  8696. this.monitor = true;
  8697. };
  8698. this.form.on('actioncomplete', startMonitor, this);
  8699. this.form.on('actionfailed', startMonitor, this);
  8700. }
  8701. }, this, {single:true});
  8702. sb.on({
  8703. scope: this,
  8704. afterlayout:{
  8705. single: true,
  8706. fn: function(){
  8707. // Grab the statusEl after the first layout.
  8708. sb.statusEl.getEl().on('click', this.onStatusClick, this, {buffer:200});
  8709. }
  8710. },
  8711. beforedestroy:{
  8712. single: true,
  8713. fn: this.onDestroy
  8714. }
  8715. });
  8716. },
  8717. // private
  8718. startMonitoring : function(){
  8719. this.form.items.each(function(f){
  8720. f.on('invalid', this.onFieldValidation, this);
  8721. f.on('valid', this.onFieldValidation, this);
  8722. }, this);
  8723. },
  8724. // private
  8725. stopMonitoring : function(){
  8726. this.form.items.each(function(f){
  8727. f.un('invalid', this.onFieldValidation, this);
  8728. f.un('valid', this.onFieldValidation, this);
  8729. }, this);
  8730. },
  8731. // private
  8732. onDestroy : function(){
  8733. this.stopMonitoring();
  8734. this.statusBar.statusEl.un('click', this.onStatusClick, this);
  8735. Ext.ux.ValidationStatus.superclass.onDestroy.call(this);
  8736. },
  8737. // private
  8738. onFieldValidation : function(f, msg){
  8739. if(!this.monitor){
  8740. return false;
  8741. }
  8742. if(msg){
  8743. this.errors.add(f.id, {field:f, msg:msg});
  8744. }else{
  8745. this.errors.removeKey(f.id);
  8746. }
  8747. this.updateErrorList();
  8748. if(this.errors.getCount() > 0){
  8749. if(this.statusBar.getText() != this.showText){
  8750. this.statusBar.setStatus({text:this.showText, iconCls:this.errorIconCls});
  8751. }
  8752. }else{
  8753. this.statusBar.clearStatus().setIcon(this.validIconCls);
  8754. }
  8755. },
  8756. // private
  8757. updateErrorList : function(){
  8758. if(this.errors.getCount() > 0){
  8759. var msg = '<ul>';
  8760. this.errors.each(function(err){
  8761. msg += ('<li id="x-err-'+ err.field.id +'"><a href="#">' + err.msg + '</a></li>');
  8762. }, this);
  8763. this.getMsgEl().update(msg+'</ul>');
  8764. }else{
  8765. this.getMsgEl().update('');
  8766. }
  8767. },
  8768. // private
  8769. getMsgEl : function(){
  8770. if(!this.msgEl){
  8771. this.msgEl = Ext.DomHelper.append(Ext.getBody(), {
  8772. cls: this.errorListCls+' x-hide-offsets'
  8773. }, true);
  8774. this.msgEl.on('click', function(e){
  8775. var t = e.getTarget('li', 10, true);
  8776. if(t){
  8777. Ext.getCmp(t.id.split('x-err-')[1]).focus();
  8778. this.hideErrors();
  8779. }
  8780. }, this, {stopEvent:true}); // prevent anchor click navigation
  8781. }
  8782. return this.msgEl;
  8783. },
  8784. // private
  8785. showErrors : function(){
  8786. this.updateErrorList();
  8787. this.getMsgEl().alignTo(this.statusBar.getEl(), this.listAlign).slideIn('b', {duration:0.3, easing:'easeOut'});
  8788. this.statusBar.setText(this.hideText);
  8789. this.form.getEl().on('click', this.hideErrors, this, {single:true}); // hide if the user clicks directly into the form
  8790. },
  8791. // private
  8792. hideErrors : function(){
  8793. var el = this.getMsgEl();
  8794. if(el.isVisible()){
  8795. el.slideOut('b', {duration:0.2, easing:'easeIn'});
  8796. this.statusBar.setText(this.showText);
  8797. }
  8798. this.form.getEl().un('click', this.hideErrors, this);
  8799. },
  8800. // private
  8801. onStatusClick : function(){
  8802. if(this.getMsgEl().isVisible()){
  8803. this.hideErrors();
  8804. }else if(this.errors.getCount() > 0){
  8805. this.showErrors();
  8806. }
  8807. }
  8808. });(function() {
  8809. Ext.override(Ext.list.Column, {
  8810. init : function() {
  8811. var types = Ext.data.Types,
  8812. st = this.sortType;
  8813. if(this.type){
  8814. if(Ext.isString(this.type)){
  8815. this.type = Ext.data.Types[this.type.toUpperCase()] || types.AUTO;
  8816. }
  8817. }else{
  8818. this.type = types.AUTO;
  8819. }
  8820. // named sortTypes are supported, here we look them up
  8821. if(Ext.isString(st)){
  8822. this.sortType = Ext.data.SortTypes[st];
  8823. }else if(Ext.isEmpty(st)){
  8824. this.sortType = this.type.sortType;
  8825. }
  8826. }
  8827. });
  8828. Ext.tree.Column = Ext.extend(Ext.list.Column, {});
  8829. Ext.tree.NumberColumn = Ext.extend(Ext.list.NumberColumn, {});
  8830. Ext.tree.DateColumn = Ext.extend(Ext.list.DateColumn, {});
  8831. Ext.tree.BooleanColumn = Ext.extend(Ext.list.BooleanColumn, {});
  8832. Ext.reg('tgcolumn', Ext.tree.Column);
  8833. Ext.reg('tgnumbercolumn', Ext.tree.NumberColumn);
  8834. Ext.reg('tgdatecolumn', Ext.tree.DateColumn);
  8835. Ext.reg('tgbooleancolumn', Ext.tree.BooleanColumn);
  8836. })();
  8837. /**
  8838. * @class Ext.ux.tree.TreeGridNodeUI
  8839. * @extends Ext.tree.TreeNodeUI
  8840. */
  8841. Ext.ux.tree.TreeGridNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  8842. isTreeGridNodeUI: true,
  8843. renderElements : function(n, a, targetNode, bulkRender){
  8844. var t = n.getOwnerTree(),
  8845. cols = t.columns,
  8846. c = cols[0],
  8847. i, buf, len;
  8848. this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
  8849. buf = [
  8850. '<tbody class="x-tree-node">',
  8851. '<tr ext:tree-node-id="', n.id ,'" class="x-tree-node-el x-tree-node-leaf ', a.cls, '">',
  8852. '<td class="x-treegrid-col">',
  8853. '<span class="x-tree-node-indent">', this.indentMarkup, "</span>",
  8854. '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
  8855. '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon', (a.icon ? " x-tree-node-inline-icon" : ""), (a.iconCls ? " "+a.iconCls : ""), '" unselectable="on" />',
  8856. '<a hidefocus="on" class="x-tree-node-anchor" href="', a.href ? a.href : '#', '" tabIndex="1" ',
  8857. a.hrefTarget ? ' target="'+a.hrefTarget+'"' : '', '>',
  8858. '<span unselectable="on">', (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text), '</span></a>',
  8859. '</td>'
  8860. ];
  8861. for(i = 1, len = cols.length; i < len; i++){
  8862. c = cols[i];
  8863. buf.push(
  8864. '<td class="x-treegrid-col ', (c.cls ? c.cls : ''), '">',
  8865. '<div unselectable="on" class="x-treegrid-text"', (c.align ? ' style="text-align: ' + c.align + ';"' : ''), '>',
  8866. (c.tpl ? c.tpl.apply(a) : a[c.dataIndex]),
  8867. '</div>',
  8868. '</td>'
  8869. );
  8870. }
  8871. buf.push(
  8872. '</tr><tr class="x-tree-node-ct"><td colspan="', cols.length, '">',
  8873. '<table class="x-treegrid-node-ct-table" cellpadding="0" cellspacing="0" style="table-layout: fixed; display: none; width: ', t.innerCt.getWidth() ,'px;"><colgroup>'
  8874. );
  8875. for(i = 0, len = cols.length; i<len; i++) {
  8876. buf.push('<col style="width: ', (cols[i].hidden ? 0 : cols[i].width) ,'px;" />');
  8877. }
  8878. buf.push('</colgroup></table></td></tr></tbody>');
  8879. if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
  8880. this.wrap = Ext.DomHelper.insertHtml("beforeBegin", n.nextSibling.ui.getEl(), buf.join(''));
  8881. }else{
  8882. this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(''));
  8883. }
  8884. this.elNode = this.wrap.childNodes[0];
  8885. this.ctNode = this.wrap.childNodes[1].firstChild.firstChild;
  8886. var cs = this.elNode.firstChild.childNodes;
  8887. this.indentNode = cs[0];
  8888. this.ecNode = cs[1];
  8889. this.iconNode = cs[2];
  8890. this.anchor = cs[3];
  8891. this.textNode = cs[3].firstChild;
  8892. },
  8893. // private
  8894. animExpand : function(cb){
  8895. this.ctNode.style.display = "";
  8896. Ext.ux.tree.TreeGridNodeUI.superclass.animExpand.call(this, cb);
  8897. }
  8898. });
  8899. Ext.ux.tree.TreeGridRootNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  8900. isTreeGridNodeUI: true,
  8901. // private
  8902. render : function(){
  8903. if(!this.rendered){
  8904. this.wrap = this.ctNode = this.node.ownerTree.innerCt.dom;
  8905. this.node.expanded = true;
  8906. }
  8907. if(Ext.isWebKit) {
  8908. // weird table-layout: fixed issue in webkit
  8909. var ct = this.ctNode;
  8910. ct.style.tableLayout = null;
  8911. (function() {
  8912. ct.style.tableLayout = 'fixed';
  8913. }).defer(1);
  8914. }
  8915. },
  8916. destroy : function(){
  8917. if(this.elNode){
  8918. Ext.dd.Registry.unregister(this.elNode.id);
  8919. }
  8920. delete this.node;
  8921. },
  8922. collapse : Ext.emptyFn,
  8923. expand : Ext.emptyFn
  8924. });/**
  8925. * @class Ext.tree.ColumnResizer
  8926. * @extends Ext.util.Observable
  8927. */
  8928. Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
  8929. <div id="cfg-Ext.tree.ColumnResizer-minWidth"></div>/**
  8930. * @cfg {Number} minWidth The minimum width the column can be dragged to.
  8931. * Defaults to <tt>14</tt>.
  8932. */
  8933. minWidth: 14,
  8934. constructor: function(config){
  8935. Ext.apply(this, config);
  8936. Ext.tree.ColumnResizer.superclass.constructor.call(this);
  8937. },
  8938. init : function(tree){
  8939. this.tree = tree;
  8940. tree.on('render', this.initEvents, this);
  8941. },
  8942. initEvents : function(tree){
  8943. tree.mon(tree.innerHd, 'mousemove', this.handleHdMove, this);
  8944. this.tracker = new Ext.dd.DragTracker({
  8945. onBeforeStart: this.onBeforeStart.createDelegate(this),
  8946. onStart: this.onStart.createDelegate(this),
  8947. onDrag: this.onDrag.createDelegate(this),
  8948. onEnd: this.onEnd.createDelegate(this),
  8949. tolerance: 3,
  8950. autoStart: 300
  8951. });
  8952. this.tracker.initEl(tree.innerHd);
  8953. tree.on('beforedestroy', this.tracker.destroy, this.tracker);
  8954. },
  8955. handleHdMove : function(e, t){
  8956. var hw = 5,
  8957. x = e.getPageX(),
  8958. hd = e.getTarget('.x-treegrid-hd', 3, true);
  8959. if(hd){
  8960. var r = hd.getRegion(),
  8961. ss = hd.dom.style,
  8962. pn = hd.dom.parentNode;
  8963. if(x - r.left <= hw && hd.dom !== pn.firstChild) {
  8964. var ps = hd.dom.previousSibling;
  8965. while(ps && Ext.fly(ps).hasClass('x-treegrid-hd-hidden')) {
  8966. ps = ps.previousSibling;
  8967. }
  8968. if(ps) {
  8969. this.activeHd = Ext.get(ps);
  8970. ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
  8971. }
  8972. } else if(r.right - x <= hw) {
  8973. var ns = hd.dom;
  8974. while(ns && Ext.fly(ns).hasClass('x-treegrid-hd-hidden')) {
  8975. ns = ns.previousSibling;
  8976. }
  8977. if(ns) {
  8978. this.activeHd = Ext.get(ns);
  8979. ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
  8980. }
  8981. } else{
  8982. delete this.activeHd;
  8983. ss.cursor = '';
  8984. }
  8985. }
  8986. },
  8987. onBeforeStart : function(e){
  8988. this.dragHd = this.activeHd;
  8989. return !!this.dragHd;
  8990. },
  8991. onStart : function(e){
  8992. this.dragHeadersDisabled = this.tree.headersDisabled;
  8993. this.tree.headersDisabled = true;
  8994. this.proxy = this.tree.body.createChild({cls:'x-treegrid-resizer'});
  8995. this.proxy.setHeight(this.tree.body.getHeight());
  8996. var x = this.tracker.getXY()[0];
  8997. this.hdX = this.dragHd.getX();
  8998. this.hdIndex = this.tree.findHeaderIndex(this.dragHd);
  8999. this.proxy.setX(this.hdX);
  9000. this.proxy.setWidth(x-this.hdX);
  9001. this.maxWidth = this.tree.outerCt.getWidth() - this.tree.innerBody.translatePoints(this.hdX).left;
  9002. },
  9003. onDrag : function(e){
  9004. var cursorX = this.tracker.getXY()[0];
  9005. this.proxy.setWidth((cursorX-this.hdX).constrain(this.minWidth, this.maxWidth));
  9006. },
  9007. onEnd : function(e){
  9008. var nw = this.proxy.getWidth(),
  9009. tree = this.tree,
  9010. disabled = this.dragHeadersDisabled;
  9011. this.proxy.remove();
  9012. delete this.dragHd;
  9013. tree.columns[this.hdIndex].width = nw;
  9014. tree.updateColumnWidths();
  9015. setTimeout(function(){
  9016. tree.headersDisabled = disabled;
  9017. }, 100);
  9018. }
  9019. });Ext.ns('Ext.ux.tree');
  9020. /**
  9021. * @class Ext.ux.tree.TreeGridSorter
  9022. * @extends Ext.tree.TreeSorter
  9023. * Provides sorting of nodes in a {@link Ext.ux.tree.TreeGrid}. The TreeGridSorter automatically monitors events on the
  9024. * associated TreeGrid that might affect the tree's sort order (beforechildrenrendered, append, insert and textchange).
  9025. * Example usage:<br />
  9026. * <pre><code>
  9027. new Ext.ux.tree.TreeGridSorter(myTreeGrid, {
  9028. folderSort: true,
  9029. dir: "desc",
  9030. sortType: function(node) {
  9031. // sort by a custom, typed attribute:
  9032. return parseInt(node.id, 10);
  9033. }
  9034. });
  9035. </code></pre>
  9036. * @constructor
  9037. * @param {TreeGrid} tree
  9038. * @param {Object} config
  9039. */
  9040. Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
  9041. <div id="cfg-Ext.ux.tree.TreeGridSorter-sortClasses"></div>/**
  9042. * @cfg {Array} sortClasses The CSS classes applied to a header when it is sorted. (defaults to <tt>['sort-asc', 'sort-desc']</tt>)
  9043. */
  9044. sortClasses : ['sort-asc', 'sort-desc'],
  9045. <div id="cfg-Ext.ux.tree.TreeGridSorter-sortAscText"></div>/**
  9046. * @cfg {String} sortAscText The text displayed in the 'Sort Ascending' menu item (defaults to <tt>'Sort Ascending'</tt>)
  9047. */
  9048. sortAscText : 'Sort Ascending',
  9049. <div id="cfg-Ext.ux.tree.TreeGridSorter-sortDescText"></div>/**
  9050. * @cfg {String} sortDescText The text displayed in the 'Sort Descending' menu item (defaults to <tt>'Sort Descending'</tt>)
  9051. */
  9052. sortDescText : 'Sort Descending',
  9053. constructor : function(tree, config) {
  9054. if(!Ext.isObject(config)) {
  9055. config = {
  9056. property: tree.columns[0].dataIndex || 'text',
  9057. folderSort: true
  9058. }
  9059. }
  9060. Ext.ux.tree.TreeGridSorter.superclass.constructor.apply(this, arguments);
  9061. this.tree = tree;
  9062. tree.on('headerclick', this.onHeaderClick, this);
  9063. tree.ddAppendOnly = true;
  9064. var me = this;
  9065. this.defaultSortFn = function(n1, n2){
  9066. var desc = me.dir && me.dir.toLowerCase() == 'desc',
  9067. prop = me.property || 'text',
  9068. sortType = me.sortType,
  9069. caseSensitive = me.caseSensitive === true,
  9070. leafAttr = me.leafAttr || 'leaf',
  9071. attr1 = n1.attributes,
  9072. attr2 = n2.attributes;
  9073. if(me.folderSort){
  9074. if(attr1[leafAttr] && !attr2[leafAttr]){
  9075. return 1;
  9076. }
  9077. if(!attr1[leafAttr] && attr2[leafAttr]){
  9078. return -1;
  9079. }
  9080. }
  9081. var prop1 = attr1[prop],
  9082. prop2 = attr2[prop],
  9083. v1 = sortType ? sortType(prop1) : (caseSensitive ? prop1 : prop1.toUpperCase());
  9084. v2 = sortType ? sortType(prop2) : (caseSensitive ? prop2 : prop2.toUpperCase());
  9085. if(v1 < v2){
  9086. return desc ? +1 : -1;
  9087. }else if(v1 > v2){
  9088. return desc ? -1 : +1;
  9089. }else{
  9090. return 0;
  9091. }
  9092. };
  9093. tree.on('afterrender', this.onAfterTreeRender, this, {single: true});
  9094. tree.on('headermenuclick', this.onHeaderMenuClick, this);
  9095. },
  9096. onAfterTreeRender : function() {
  9097. if(this.tree.hmenu){
  9098. this.tree.hmenu.insert(0,
  9099. {itemId:'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
  9100. {itemId:'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
  9101. );
  9102. }
  9103. this.updateSortIcon(0, 'asc');
  9104. },
  9105. onHeaderMenuClick : function(c, id, index) {
  9106. if(id === 'asc' || id === 'desc') {
  9107. this.onHeaderClick(c, null, index);
  9108. return false;
  9109. }
  9110. },
  9111. onHeaderClick : function(c, el, i) {
  9112. if(c && !this.tree.headersDisabled){
  9113. var me = this;
  9114. me.property = c.dataIndex;
  9115. me.dir = c.dir = (c.dir === 'desc' ? 'asc' : 'desc');
  9116. me.sortType = c.sortType;
  9117. me.caseSensitive === Ext.isBoolean(c.caseSensitive) ? c.caseSensitive : this.caseSensitive;
  9118. me.sortFn = c.sortFn || this.defaultSortFn;
  9119. this.tree.root.cascade(function(n) {
  9120. if(!n.isLeaf()) {
  9121. me.updateSort(me.tree, n);
  9122. }
  9123. });
  9124. this.updateSortIcon(i, c.dir);
  9125. }
  9126. },
  9127. // private
  9128. updateSortIcon : function(col, dir){
  9129. var sc = this.sortClasses,
  9130. hds = this.tree.innerHd.select('td').removeClass(sc);
  9131. hds.item(col).addClass(sc[dir == 'desc' ? 1 : 0]);
  9132. }
  9133. });/**
  9134. * @class Ext.ux.tree.TreeGridLoader
  9135. * @extends Ext.tree.TreeLoader
  9136. */
  9137. Ext.ux.tree.TreeGridLoader = Ext.extend(Ext.tree.TreeLoader, {
  9138. createNode : function(attr) {
  9139. if (!attr.uiProvider) {
  9140. attr.uiProvider = Ext.ux.tree.TreeGridNodeUI;
  9141. }
  9142. return Ext.tree.TreeLoader.prototype.createNode.call(this, attr);
  9143. }
  9144. });/**
  9145. * @class Ext.ux.tree.TreeGrid
  9146. * @extends Ext.tree.TreePanel
  9147. *
  9148. * @xtype treegrid
  9149. */
  9150. Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
  9151. rootVisible : false,
  9152. useArrows : true,
  9153. lines : false,
  9154. borderWidth : Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
  9155. cls : 'x-treegrid',
  9156. columnResize : true,
  9157. enableSort : true,
  9158. reserveScrollOffset : true,
  9159. enableHdMenu : true,
  9160. columnsText : 'Columns',
  9161. initComponent : function() {
  9162. if(!this.root) {
  9163. this.root = new Ext.tree.AsyncTreeNode({text: 'Root'});
  9164. }
  9165. // initialize the loader
  9166. var l = this.loader;
  9167. if(!l){
  9168. l = new Ext.ux.tree.TreeGridLoader({
  9169. dataUrl: this.dataUrl,
  9170. requestMethod: this.requestMethod,
  9171. store: this.store
  9172. });
  9173. }else if(Ext.isObject(l) && !l.load){
  9174. l = new Ext.ux.tree.TreeGridLoader(l);
  9175. }
  9176. this.loader = l;
  9177. Ext.ux.tree.TreeGrid.superclass.initComponent.call(this);
  9178. this.initColumns();
  9179. if(this.enableSort) {
  9180. this.treeGridSorter = new Ext.ux.tree.TreeGridSorter(this, this.enableSort);
  9181. }
  9182. if(this.columnResize){
  9183. this.colResizer = new Ext.tree.ColumnResizer(this.columnResize);
  9184. this.colResizer.init(this);
  9185. }
  9186. var c = this.columns;
  9187. if(!this.internalTpl){
  9188. this.internalTpl = new Ext.XTemplate(
  9189. '<div class="x-grid3-header">',
  9190. '<div class="x-treegrid-header-inner">',
  9191. '<div class="x-grid3-header-offset">',
  9192. '<table style="table-layout: fixed;" cellspacing="0" cellpadding="0" border="0"><colgroup><tpl for="columns"><col /></tpl></colgroup>',
  9193. '<thead><tr class="x-grid3-hd-row">',
  9194. '<tpl for="columns">',
  9195. '<td class="x-grid3-hd x-grid3-cell x-treegrid-hd" style="text-align: {align};" id="', this.id, '-xlhd-{#}">',
  9196. '<div class="x-grid3-hd-inner x-treegrid-hd-inner" unselectable="on">',
  9197. this.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '',
  9198. '{header}<img class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />',
  9199. '</div>',
  9200. '</td></tpl>',
  9201. '</tr></thead>',
  9202. '</table>',
  9203. '</div></div>',
  9204. '</div>',
  9205. '<div class="x-treegrid-root-node">',
  9206. '<table class="x-treegrid-root-table" cellpadding="0" cellspacing="0" style="table-layout: fixed;"></table>',
  9207. '</div>'
  9208. );
  9209. }
  9210. if(!this.colgroupTpl) {
  9211. this.colgroupTpl = new Ext.XTemplate(
  9212. '<colgroup><tpl for="columns"><col style="width: {width}px"/></tpl></colgroup>'
  9213. );
  9214. }
  9215. },
  9216. initColumns : function() {
  9217. var cs = this.columns,
  9218. len = cs.length,
  9219. columns = [],
  9220. i, c;
  9221. for(i = 0; i < len; i++){
  9222. c = cs[i];
  9223. if(!c.isColumn) {
  9224. c.xtype = c.xtype ? (/^tg/.test(c.xtype) ? c.xtype : 'tg' + c.xtype) : 'tgcolumn';
  9225. c = Ext.create(c);
  9226. }
  9227. c.init(this);
  9228. columns.push(c);
  9229. if(this.enableSort !== false && c.sortable !== false) {
  9230. c.sortable = true;
  9231. this.enableSort = true;
  9232. }
  9233. }
  9234. this.columns = columns;
  9235. },
  9236. onRender : function(){
  9237. Ext.tree.TreePanel.superclass.onRender.apply(this, arguments);
  9238. this.el.addClass('x-treegrid');
  9239. this.outerCt = this.body.createChild({
  9240. cls:'x-tree-root-ct x-treegrid-ct ' + (this.useArrows ? 'x-tree-arrows' : this.lines ? 'x-tree-lines' : 'x-tree-no-lines')
  9241. });
  9242. this.internalTpl.overwrite(this.outerCt, {columns: this.columns});
  9243. this.mainHd = Ext.get(this.outerCt.dom.firstChild);
  9244. this.innerHd = Ext.get(this.mainHd.dom.firstChild);
  9245. this.innerBody = Ext.get(this.outerCt.dom.lastChild);
  9246. this.innerCt = Ext.get(this.innerBody.dom.firstChild);
  9247. this.colgroupTpl.insertFirst(this.innerCt, {columns: this.columns});
  9248. if(this.hideHeaders){
  9249. this.el.child('.x-grid3-header').setDisplayed('none');
  9250. }
  9251. else if(this.enableHdMenu !== false){
  9252. this.hmenu = new Ext.menu.Menu({id: this.id + '-hctx'});
  9253. if(this.enableColumnHide !== false){
  9254. this.colMenu = new Ext.menu.Menu({id: this.id + '-hcols-menu'});
  9255. this.colMenu.on({
  9256. scope: this,
  9257. beforeshow: this.beforeColMenuShow,
  9258. itemclick: this.handleHdMenuClick
  9259. });
  9260. this.hmenu.add({
  9261. itemId:'columns',
  9262. hideOnClick: false,
  9263. text: this.columnsText,
  9264. menu: this.colMenu,
  9265. iconCls: 'x-cols-icon'
  9266. });
  9267. }
  9268. this.hmenu.on('itemclick', this.handleHdMenuClick, this);
  9269. }
  9270. },
  9271. setRootNode : function(node){
  9272. node.attributes.uiProvider = Ext.ux.tree.TreeGridRootNodeUI;
  9273. node = Ext.ux.tree.TreeGrid.superclass.setRootNode.call(this, node);
  9274. if(this.innerCt) {
  9275. this.colgroupTpl.insertFirst(this.innerCt, {columns: this.columns});
  9276. }
  9277. return node;
  9278. },
  9279. clearInnerCt : function(){
  9280. if(Ext.isIE){
  9281. var dom = this.innerCt.dom;
  9282. while(dom.firstChild){
  9283. dom.removeChild(dom.firstChild);
  9284. }
  9285. }else{
  9286. Ext.ux.tree.TreeGrid.superclass.clearInnerCt.call(this);
  9287. }
  9288. },
  9289. initEvents : function() {
  9290. Ext.ux.tree.TreeGrid.superclass.initEvents.apply(this, arguments);
  9291. this.mon(this.innerBody, 'scroll', this.syncScroll, this);
  9292. this.mon(this.innerHd, 'click', this.handleHdDown, this);
  9293. this.mon(this.mainHd, {
  9294. scope: this,
  9295. mouseover: this.handleHdOver,
  9296. mouseout: this.handleHdOut
  9297. });
  9298. },
  9299. onResize : function(w, h) {
  9300. Ext.ux.tree.TreeGrid.superclass.onResize.apply(this, arguments);
  9301. var bd = this.innerBody.dom;
  9302. var hd = this.innerHd.dom;
  9303. if(!bd){
  9304. return;
  9305. }
  9306. if(Ext.isNumber(h)){
  9307. bd.style.height = this.body.getHeight(true) - hd.offsetHeight + 'px';
  9308. }
  9309. if(Ext.isNumber(w)){
  9310. var sw = Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
  9311. if(this.reserveScrollOffset || ((bd.offsetWidth - bd.clientWidth) > 10)){
  9312. this.setScrollOffset(sw);
  9313. }else{
  9314. var me = this;
  9315. setTimeout(function(){
  9316. me.setScrollOffset(bd.offsetWidth - bd.clientWidth > 10 ? sw : 0);
  9317. }, 10);
  9318. }
  9319. }
  9320. },
  9321. updateColumnWidths : function() {
  9322. var cols = this.columns,
  9323. colCount = cols.length,
  9324. groups = this.outerCt.query('colgroup'),
  9325. groupCount = groups.length,
  9326. c, g, i, j;
  9327. for(i = 0; i<colCount; i++) {
  9328. c = cols[i];
  9329. for(j = 0; j<groupCount; j++) {
  9330. g = groups[j];
  9331. g.childNodes[i].style.width = (c.hidden ? 0 : c.width) + 'px';
  9332. }
  9333. }
  9334. for(i = 0, groups = this.innerHd.query('td'), len = groups.length; i<len; i++) {
  9335. c = Ext.fly(groups[i]);
  9336. if(cols[i] && cols[i].hidden) {
  9337. c.addClass('x-treegrid-hd-hidden');
  9338. }
  9339. else {
  9340. c.removeClass('x-treegrid-hd-hidden');
  9341. }
  9342. }
  9343. var tcw = this.getTotalColumnWidth();
  9344. Ext.fly(this.innerHd.dom.firstChild).setWidth(tcw + (this.scrollOffset || 0));
  9345. this.outerCt.select('table').setWidth(tcw);
  9346. this.syncHeaderScroll();
  9347. },
  9348. getVisibleColumns : function() {
  9349. var columns = [],
  9350. cs = this.columns,
  9351. len = cs.length,
  9352. i;
  9353. for(i = 0; i<len; i++) {
  9354. if(!cs[i].hidden) {
  9355. columns.push(cs[i]);
  9356. }
  9357. }
  9358. return columns;
  9359. },
  9360. getTotalColumnWidth : function() {
  9361. var total = 0;
  9362. for(var i = 0, cs = this.getVisibleColumns(), len = cs.length; i<len; i++) {
  9363. total += cs[i].width;
  9364. }
  9365. return total;
  9366. },
  9367. setScrollOffset : function(scrollOffset) {
  9368. this.scrollOffset = scrollOffset;
  9369. this.updateColumnWidths();
  9370. },
  9371. // private
  9372. handleHdDown : function(e, t){
  9373. var hd = e.getTarget('.x-treegrid-hd');
  9374. if(hd && Ext.fly(t).hasClass('x-grid3-hd-btn')){
  9375. var ms = this.hmenu.items,
  9376. cs = this.columns,
  9377. index = this.findHeaderIndex(hd),
  9378. c = cs[index],
  9379. sort = c.sortable;
  9380. e.stopEvent();
  9381. Ext.fly(hd).addClass('x-grid3-hd-menu-open');
  9382. this.hdCtxIndex = index;
  9383. this.fireEvent('headerbuttonclick', ms, c, hd, index);
  9384. this.hmenu.on('hide', function(){
  9385. Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
  9386. }, this, {single:true});
  9387. this.hmenu.show(t, 'tl-bl?');
  9388. }
  9389. else if(hd) {
  9390. var index = this.findHeaderIndex(hd);
  9391. this.fireEvent('headerclick', this.columns[index], hd, index);
  9392. }
  9393. },
  9394. // private
  9395. handleHdOver : function(e, t){
  9396. var hd = e.getTarget('.x-treegrid-hd');
  9397. if(hd && !this.headersDisabled){
  9398. index = this.findHeaderIndex(hd);
  9399. this.activeHdRef = t;
  9400. this.activeHdIndex = index;
  9401. var el = Ext.get(hd);
  9402. this.activeHdRegion = el.getRegion();
  9403. el.addClass('x-grid3-hd-over');
  9404. this.activeHdBtn = el.child('.x-grid3-hd-btn');
  9405. if(this.activeHdBtn){
  9406. this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight-1)+'px';
  9407. }
  9408. }
  9409. },
  9410. // private
  9411. handleHdOut : function(e, t){
  9412. var hd = e.getTarget('.x-treegrid-hd');
  9413. if(hd && (!Ext.isIE || !e.within(hd, true))){
  9414. this.activeHdRef = null;
  9415. Ext.fly(hd).removeClass('x-grid3-hd-over');
  9416. hd.style.cursor = '';
  9417. }
  9418. },
  9419. findHeaderIndex : function(hd){
  9420. hd = hd.dom || hd;
  9421. var cs = hd.parentNode.childNodes;
  9422. for(var i = 0, c; c = cs[i]; i++){
  9423. if(c == hd){
  9424. return i;
  9425. }
  9426. }
  9427. return -1;
  9428. },
  9429. // private
  9430. beforeColMenuShow : function(){
  9431. var cols = this.columns,
  9432. colCount = cols.length,
  9433. i, c;
  9434. this.colMenu.removeAll();
  9435. for(i = 1; i < colCount; i++){
  9436. c = cols[i];
  9437. if(c.hideable !== false){
  9438. this.colMenu.add(new Ext.menu.CheckItem({
  9439. itemId: 'col-' + i,
  9440. text: c.header,
  9441. checked: !c.hidden,
  9442. hideOnClick:false,
  9443. disabled: c.hideable === false
  9444. }));
  9445. }
  9446. }
  9447. },
  9448. // private
  9449. handleHdMenuClick : function(item){
  9450. var index = this.hdCtxIndex,
  9451. id = item.getItemId();
  9452. if(this.fireEvent('headermenuclick', this.columns[index], id, index) !== false) {
  9453. index = id.substr(4);
  9454. if(index > 0 && this.columns[index]) {
  9455. this.setColumnVisible(index, !item.checked);
  9456. }
  9457. }
  9458. return true;
  9459. },
  9460. setColumnVisible : function(index, visible) {
  9461. this.columns[index].hidden = !visible;
  9462. this.updateColumnWidths();
  9463. },
  9464. <div id="method-Ext.ux.tree.TreeGrid-scrollToTop"></div>/**
  9465. * Scrolls the grid to the top
  9466. */
  9467. scrollToTop : function(){
  9468. this.innerBody.dom.scrollTop = 0;
  9469. this.innerBody.dom.scrollLeft = 0;
  9470. },
  9471. // private
  9472. syncScroll : function(){
  9473. this.syncHeaderScroll();
  9474. var mb = this.innerBody.dom;
  9475. this.fireEvent('bodyscroll', mb.scrollLeft, mb.scrollTop);
  9476. },
  9477. // private
  9478. syncHeaderScroll : function(){
  9479. var mb = this.innerBody.dom;
  9480. this.innerHd.dom.scrollLeft = mb.scrollLeft;
  9481. this.innerHd.dom.scrollLeft = mb.scrollLeft; // second time for IE (1/2 time first fails, other browsers ignore)
  9482. },
  9483. registerNode : function(n) {
  9484. Ext.ux.tree.TreeGrid.superclass.registerNode.call(this, n);
  9485. if(!n.uiProvider && !n.isRoot && !n.ui.isTreeGridNodeUI) {
  9486. n.ui = new Ext.ux.tree.TreeGridNodeUI(n);
  9487. }
  9488. }
  9489. });
  9490. Ext.reg('treegrid', Ext.ux.tree.TreeGrid);</pre>
  9491. </body>
  9492. </html>